Class LegacyIdFactory
- java.lang.Object
-
- org.symphonyoss.s2.common.legacy.id.LegacyIdFactory
-
public class LegacyIdFactory extends Object
A factory to create inferred Hash values each of which is a 2.0 ID which acts as a mirror for an object in the legacy (Symphony1.5) space. Many methods take a tenantId which it uses to generate a globally unique ID for each object across all pods. This means that if the same threadId happens to exist in 2 separate pods and we create a 2.0 Sequence to represent those two threads that the 2.0 IDs will not collide in a multi tenant environment. This also means that where the same message goes xpod that events about the same message originating from different pods will have different event IDs. In the comments below where it says "originating pod" it means the pod where the event originates which may be different from the pod where the message originated. User IDs ======== User IDs in SBE contain a 36 bit per pod user Id and a 27 bit podId which are OR'ed together to form a single 63 bit value which is stored in a long integer, the most significant (sign) bit, in bit position 0, is always zero the podId is in bit positions 1-28 and the per tenant user Id is in bit positions 29-63. Internal pod IDs are not unique so these userIds are not globally unique and we therefore have a separate "external podId" and code in https://github.com/SymphonyOSF/SBE/blob/dev/commons/runtimecommons/src/main/java/com/symphony/runtime/commons/util/UserIDUtil.java to manipulate these IDs to replace the "internal podId" with an "externalPodId" In the 2.0 space we use a globally unique hash to refer to a user called the principalId which is constructed from the external userId, i.e. the userId with the podId part replaced with the pod's externalPodId. This class takes an internal and external podId in its constructor which allows it to map internal userId values to their external equivalents where necessary. Where a userId value is passed into methods in this class it is always safe to pass either internal or external values. 63 bit userId 0x7FFFFFFFFFFFFFFFL 0111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 27 bit podId 0x7FFFFFF000000000L 0111 1111 1111 1111 1111 1111 1111 0000 0000 0000 0000 0000 0000 0000 0000 0000 36 bit user part 0x0000000FFFFFFFFFL 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 1111 1111- Author:
- Bruce Skingle
-
-
Field Summary
Fields Modifier and Type Field Description static longUSER_ID_MASKAll bits which may be non-zero in an SBE userIdstatic longUSER_ID_POD_MASKBits representing the pod part in an SBE userIdstatic intUSER_ID_POD_SHIFTNumber of bits by which the pod part of an SBE userId are shiftedstatic longUSER_ID_USER_MASKBits representing the user part in an SBE userId
-
Constructor Summary
Constructors Constructor Description LegacyIdFactory(long internalPodId, long externalPodId)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.symphonyoss.s2.common.hash.HashbookmarkId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)Create a 2.0 Hash (ID) for the given bookmark event.org.symphonyoss.s2.common.hash.HashdeleteEventId(String tenantId, long requesterId, byte[] deleteMessageId)Create a 2.0 Hash (ID) for a DeleteEvent.org.symphonyoss.s2.common.hash.HashdeleteEventId(String tenantId, long requesterId, org.symphonyoss.s2.common.immutable.ImmutableByteArray deleteMessageId)Create a 2.0 Hash (ID) for a DeleteEvent.org.symphonyoss.s2.common.hash.HashdeliveryReceiptId(String tenantId, long internalOrExternalUserId, byte[] messageId, byte[] threadId)Create a 2.0 Hash (ID) for the delivery receipt of the given messageId for the given userId.org.symphonyoss.s2.common.hash.HashdeliveryReceiptId(String tenantId, long internalOrExternalUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)Create a 2.0 Hash (ID) for the delivery receipt of the given messageId for the given userId.org.symphonyoss.s2.common.hash.HashdownloadAttachmentEventId(String tenantId, long downloadedByUserId, byte[] messageId, String fileId)Create a 2.0 Hash (ID) for a DownloadAttachmentEvent.org.symphonyoss.s2.common.hash.HashdownloadAttachmentEventId(String tenantId, long downloadedByUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, String fileId)Create a 2.0 Hash (ID) for a DownloadAttachmentEvent.org.symphonyoss.s2.common.hash.HashexternalUserId(String subjectTenantId, long subjectUserId, String viewTenantId)Create a 2.0 Hash (ID) for the given userId, as seen from another tenant.org.symphonyoss.s2.common.hash.HashlikeEventId(String tenantId, long liker, byte[] likedMessageId)Create a 2.0 Hash (ID) for a LikeEvent.org.symphonyoss.s2.common.hash.HashlikeEventId(String tenantId, long liker, org.symphonyoss.s2.common.immutable.ImmutableByteArray likedMessageId)Create a 2.0 Hash (ID) for a LikeEvent.org.symphonyoss.s2.common.hash.HashmaestroId(String tenantId, byte[] messageId, byte[] threadId)Create a 2.0 Hash (ID) for a MaestroMessage.org.symphonyoss.s2.common.hash.HashmaestroId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)Create a 2.0 Hash (ID) for a MaestroMessage.org.symphonyoss.s2.common.hash.HashmessageId(String tenantId, byte[] messageId)Create a 2.0 Hash (ID) for the given messageId.org.symphonyoss.s2.common.hash.HashmessageId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)Create a 2.0 Hash (ID) for the given messageId.org.symphonyoss.s2.common.hash.HashobjectStatusId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)Create a 2.0 Hash (ID) for an object status of the given messageId for the given tenantId.org.symphonyoss.s2.common.hash.HashofflineNoticeId(String tenantId, long toUserId, byte[] messageId)Create a 2.0 Hash (ID) for an offline notification event.org.symphonyoss.s2.common.hash.HashofflineNoticeId(String tenantId, long toUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)Create a 2.0 Hash (ID) for an offline notification event.org.symphonyoss.s2.common.hash.HashpresenceChangeId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)Create a 2.0 Hash (ID) for the given presence change message.org.symphonyoss.s2.common.hash.HashreadReceiptId(String tenantId, long internalOrExternalUserId, byte[] messageId, byte[] threadId)Create a 2.0 Hash (ID) for the read receipt of the given messageId for the given userId.org.symphonyoss.s2.common.hash.HashreadReceiptId(String tenantId, long internalOrExternalUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)Create a 2.0 Hash (ID) for the read receipt of the given messageId for the given userId.org.symphonyoss.s2.common.hash.HashsignalId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)Create a 2.0 Hash (ID) for the given signal messageId.org.symphonyoss.s2.common.hash.HashthreadId(String tenantId, byte[] threadId)Create a 2.0 Hash (ID) for the given threadId.org.symphonyoss.s2.common.hash.HashthreadId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)Create a 2.0 Hash (ID) for the given threadId.longtoExternalUserId(long internalOrExternalUserId)Return the externalUserId for the given userId which may be internal or external.org.symphonyoss.s2.common.hash.HashuserId(long internalOrExternalUserId)Create a 2.0 Hash (ID) for the given userId.
-
-
-
Field Detail
-
USER_ID_MASK
public static final long USER_ID_MASK
All bits which may be non-zero in an SBE userId- See Also:
- Constant Field Values
-
USER_ID_POD_MASK
public static final long USER_ID_POD_MASK
Bits representing the pod part in an SBE userId- See Also:
- Constant Field Values
-
USER_ID_USER_MASK
public static final long USER_ID_USER_MASK
Bits representing the user part in an SBE userId- See Also:
- Constant Field Values
-
USER_ID_POD_SHIFT
public static final int USER_ID_POD_SHIFT
Number of bits by which the pod part of an SBE userId are shifted- See Also:
- Constant Field Values
-
-
Method Detail
-
toExternalUserId
public long toExternalUserId(long internalOrExternalUserId)
Return the externalUserId for the given userId which may be internal or external.- Parameters:
internalOrExternalUserId- A userId which may be internal or external.- Returns:
- The externalUserId for the given internalOrExternalUserId.
-
userId
public org.symphonyoss.s2.common.hash.Hash userId(long internalOrExternalUserId)
Create a 2.0 Hash (ID) for the given userId.- Parameters:
internalOrExternalUserId- An SBE userId- Returns:
- The 2.0 object ID for the mirror of the given ID.
-
externalUserId
public org.symphonyoss.s2.common.hash.Hash externalUserId(String subjectTenantId, long subjectUserId, String viewTenantId)
Create a 2.0 Hash (ID) for the given userId, as seen from another tenant.- Parameters:
subjectTenantId- The tenant ID of the pod to which the user belongs.subjectUserId- An internal or external userIdviewTenantId- The tenant ID of the pod from which this view is visible.- Returns:
- The 2.0 object ID for the mirror of the given ID.
-
signalId
public org.symphonyoss.s2.common.hash.Hash signalId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)
Create a 2.0 Hash (ID) for the given signal messageId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- A messageId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
presenceChangeId
public org.symphonyoss.s2.common.hash.Hash presenceChangeId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)
Create a 2.0 Hash (ID) for the given presence change message.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- A messageId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
bookmarkId
public org.symphonyoss.s2.common.hash.Hash bookmarkId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)
Create a 2.0 Hash (ID) for the given bookmark event.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- A messageId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
messageId
public org.symphonyoss.s2.common.hash.Hash messageId(String tenantId, byte[] messageId)
Create a 2.0 Hash (ID) for the given messageId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- A messageId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
messageId
public org.symphonyoss.s2.common.hash.Hash messageId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)
Create a 2.0 Hash (ID) for the given messageId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- A messageId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
threadId
public org.symphonyoss.s2.common.hash.Hash threadId(String tenantId, byte[] threadId)
Create a 2.0 Hash (ID) for the given threadId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.threadId- A threadId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
threadId
public org.symphonyoss.s2.common.hash.Hash threadId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)
Create a 2.0 Hash (ID) for the given threadId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.threadId- A threadId- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
objectStatusId
public org.symphonyoss.s2.common.hash.Hash objectStatusId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)
Create a 2.0 Hash (ID) for an object status of the given messageId for the given tenantId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- The id of the message read.threadId- The threadId of the message read.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
readReceiptId
public org.symphonyoss.s2.common.hash.Hash readReceiptId(String tenantId, long internalOrExternalUserId, byte[] messageId, byte[] threadId)
Create a 2.0 Hash (ID) for the read receipt of the given messageId for the given userId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.internalOrExternalUserId- The SBE userId of the user who read the message.messageId- The id of the message read.threadId- The threadId of the message read.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
readReceiptId
public org.symphonyoss.s2.common.hash.Hash readReceiptId(String tenantId, long internalOrExternalUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)
Create a 2.0 Hash (ID) for the read receipt of the given messageId for the given userId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.internalOrExternalUserId- The SBE userId of the user who read the message.messageId- The id of the message read.threadId- The threadId of the message read.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
deliveryReceiptId
public org.symphonyoss.s2.common.hash.Hash deliveryReceiptId(String tenantId, long internalOrExternalUserId, byte[] messageId, byte[] threadId)
Create a 2.0 Hash (ID) for the delivery receipt of the given messageId for the given userId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.internalOrExternalUserId- The SBE userId of the user who read the message.messageId- The id of the message read.threadId- The threadId of the message read.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
deliveryReceiptId
public org.symphonyoss.s2.common.hash.Hash deliveryReceiptId(String tenantId, long internalOrExternalUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)
Create a 2.0 Hash (ID) for the delivery receipt of the given messageId for the given userId.- Parameters:
tenantId- The tenant ID of the pod where this event originated.internalOrExternalUserId- The SBE userId of the user who read the message.messageId- The id of the message read.threadId- The threadId of the message read.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
maestroId
public org.symphonyoss.s2.common.hash.Hash maestroId(String tenantId, byte[] messageId, @Nullable byte[] threadId)
Create a 2.0 Hash (ID) for a MaestroMessage.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- The message ID.threadId- The thread ID.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
maestroId
public org.symphonyoss.s2.common.hash.Hash maestroId(String tenantId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, @Nullable org.symphonyoss.s2.common.immutable.ImmutableByteArray threadId)
Create a 2.0 Hash (ID) for a MaestroMessage.- Parameters:
tenantId- The tenant ID of the pod where this event originated.messageId- The message ID.threadId- The thread ID.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
offlineNoticeId
public org.symphonyoss.s2.common.hash.Hash offlineNoticeId(String tenantId, long toUserId, byte[] messageId)
Create a 2.0 Hash (ID) for an offline notification event.- Parameters:
tenantId- The tenant ID of the pod where this event originated. This event means that a user was offline when a message was delivered and an email was sent to them.toUserId- The id of the offline user.messageId- The message ID.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
offlineNoticeId
public org.symphonyoss.s2.common.hash.Hash offlineNoticeId(String tenantId, long toUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId)
Create a 2.0 Hash (ID) for an offline notification event.- Parameters:
tenantId- The tenant ID of the pod where this event originated. This event means that a user was offline when a message was delivered and an email was sent to them.toUserId- The id of the offline user.messageId- The message ID.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
deleteEventId
public org.symphonyoss.s2.common.hash.Hash deleteEventId(String tenantId, long requesterId, byte[] deleteMessageId)
Create a 2.0 Hash (ID) for a DeleteEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.requesterId- The id of the requesting user.deleteMessageId- The message ID of the deleted message.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
deleteEventId
public org.symphonyoss.s2.common.hash.Hash deleteEventId(String tenantId, long requesterId, org.symphonyoss.s2.common.immutable.ImmutableByteArray deleteMessageId)
Create a 2.0 Hash (ID) for a DeleteEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.requesterId- The id of the requesting user.deleteMessageId- The message ID of the deleted message.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
downloadAttachmentEventId
public org.symphonyoss.s2.common.hash.Hash downloadAttachmentEventId(String tenantId, long downloadedByUserId, byte[] messageId, String fileId)
Create a 2.0 Hash (ID) for a DownloadAttachmentEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.downloadedByUserId- The user ID of the user downloading the attachment.messageId- The message ID of the attachment.fileId- The file ID of the attachment.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
downloadAttachmentEventId
public org.symphonyoss.s2.common.hash.Hash downloadAttachmentEventId(String tenantId, long downloadedByUserId, org.symphonyoss.s2.common.immutable.ImmutableByteArray messageId, String fileId)
Create a 2.0 Hash (ID) for a DownloadAttachmentEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.downloadedByUserId- The user ID of the user downloading the attachment.messageId- The message ID of the attachment.fileId- The file ID of the attachment.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
likeEventId
public org.symphonyoss.s2.common.hash.Hash likeEventId(String tenantId, long liker, byte[] likedMessageId)
Create a 2.0 Hash (ID) for a LikeEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.liker- The user ID of the user sending the like.likedMessageId- The message ID of liked message.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
likeEventId
public org.symphonyoss.s2.common.hash.Hash likeEventId(String tenantId, long liker, org.symphonyoss.s2.common.immutable.ImmutableByteArray likedMessageId)
Create a 2.0 Hash (ID) for a LikeEvent.- Parameters:
tenantId- The tenant ID of the pod where this event originated.liker- The user ID of the user sending the like.likedMessageId- The message ID of liked message.- Returns:
- The 2.0 object ID for the mirror of the given ID.
- Throws:
NullPointerException- if any parameter is null.
-
-