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 are very confusing, there is 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. Unfortunately we defined 2 pods with podId 1 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 low order 36 bits of the SBE userId (so it does not matter if we pass an internal or external user ID) as well as the tenantId and a constant value to ensure a principalId cannot collide with some other type of ID. Note that where we refer to userId in this class that we expect the "external" userId which already includes the tenantId and is already globally unique. In this case the tenantId is not included again.- Author:
- Bruce Skingle
-
-
Constructor Summary
Constructors Constructor Description LegacyIdFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.static longextractUserId(long internalOrExternalUserId)Extract the local user part from an internal or external userId.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.org.symphonyoss.s2.common.hash.HashuserId(String tenantId, long internalOrExternalUserId)Create a 2.0 Hash (ID) for the given userId.
-
-
-
Method Detail
-
extractUserId
public static long extractUserId(long internalOrExternalUserId)
Extract the local user part from an internal or external userId.- Parameters:
internalOrExternalUserId- An SBE user ID, it makes no difference if its the internal or external version as we will extract away the podId part.- Returns:
- The local user part of the given ID.
-
userId
public org.symphonyoss.s2.common.hash.Hash userId(String tenantId, long internalOrExternalUserId)
Create a 2.0 Hash (ID) for the given userId.- Parameters:
tenantId- The tenant ID of the pod to which the user belongs.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.
-
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.
-
-