Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CommunicationIdentifier] Added setter for rawId #30240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
* Common communication identifier for Communication Services
*/
public abstract class CommunicationIdentifier {
/**
* encoded format for identifiers to store in databases or as stable keys in general.
*/
protected String rawId;

private String rawId;

/**
* When storing rawIds, use this function to restore the identifier that was encoded in the rawId.
Expand Down Expand Up @@ -61,6 +59,18 @@ public String getRawId() {
return rawId;
}

/**
* Set full id of the identifier
* RawId is the encoded format for identifiers to store in databases or as stable keys in general.
*
* @param rawId full id of the identifier
* @return CommunicationIdentifier object itself
*/
protected CommunicationIdentifier setRawId(String rawId) {
this.rawId = rawId;
return this;
}

@Override
public boolean equals(Object that) {
if (this == that) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CommunicationUserIdentifier(String id) {
throw new IllegalArgumentException("The initialization parameter [id] cannot be null or empty.");
}
this.id = id;
this.rawId = id;
this.setRawId(id);
}

/**
Expand All @@ -34,6 +34,19 @@ public String getId() {
return id;
}

/**
* Set full id of the identifier
* RawId is the encoded format for identifiers to store in databases or as stable keys in general.
*
* @param rawId full id of the identifier
* @return CommunicationUserIdentifier object itself
*/
@Override
protected CommunicationUserIdentifier setRawId(String rawId) {
super.setRawId(rawId);
return this;
}

@Override
public boolean equals(Object that) {
if (this == that) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ public MicrosoftTeamsUserIdentifier setCloudEnvironment(CommunicationCloudEnviro

/**
* Set full id of the identifier
* RawId is the encoded format for identifiers to store in databases or as stable keys in general.
*
* @param rawId full id of the identifier
* @return CommunicationIdentifier object itself
* @return MicrosoftTeamsUserIdentifier object itself
*/
@Override
public MicrosoftTeamsUserIdentifier setRawId(String rawId) {
this.rawId = rawId;
super.setRawId(rawId);
rawIdSet = true;
return this;
}
Expand Down Expand Up @@ -124,13 +126,13 @@ public int hashCode() {
private void generateRawId() {
if (!rawIdSet) {
if (this.isAnonymous) {
this.rawId = "8:teamsvisitor:" + this.userId;
super.setRawId("8:teamsvisitor:" + this.userId);
} else if (cloudEnvironment.equals(CommunicationCloudEnvironment.DOD)) {
this.rawId = "8:dod:" + this.userId;
super.setRawId("8:dod:" + this.userId);
} else if (cloudEnvironment.equals(CommunicationCloudEnvironment.GCCH)) {
this.rawId = "8:gcch:" + this.userId;
super.setRawId("8:gcch:" + this.userId);
} else {
this.rawId = "8:orgid:" + this.userId;
super.setRawId("8:orgid:" + this.userId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PhoneNumberIdentifier(String phoneNumber) {
throw new IllegalArgumentException("The initialization parameter [phoneNumber] cannot be null to empty.");
}
this.phoneNumber = phoneNumber;
this.rawId = "4:" + phoneNumber.replaceAll("^[+]", "");
this.setRawId("4:" + phoneNumber.replaceAll("^[+]", ""));
}

/**
Expand All @@ -35,12 +35,14 @@ public String getPhoneNumber() {

/**
* Set full id of the identifier
* RawId is the encoded format for identifiers to store in databases or as stable keys in general.
*
* @param rawId full id of the identifier
* @return PhoneNumberIdentifier object itself
*/
@Override
public PhoneNumberIdentifier setRawId(String rawId) {
this.rawId = rawId;
super.setRawId(rawId);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public UnknownIdentifier(String id) {
throw new IllegalArgumentException("The initialization parameter [id] cannot be null or empty.");
}
this.id = id;
this.rawId = id;
this.setRawId(id);
}

/**
Expand All @@ -34,6 +34,19 @@ public String getId() {
return id;
}

/**
* Set full id of the identifier
* RawId is the encoded format for identifiers to store in databases or as stable keys in general.
*
* @param rawId full id of the identifier
* @return UnknownIdentifier object itself
*/
@Override
protected UnknownIdentifier setRawId(String rawId) {
super.setRawId(rawId);
return this;
}

@Override
public boolean equals(Object that) {
if (this == that) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void rawIdStaysTheSameAfterConversionToIdentifierAndBack() {
}

private void assertRawId(CommunicationIdentifier identifier, String expectedRawId) {
assertEquals(identifier.rawId, expectedRawId);
assertEquals(identifier.getRawId(), expectedRawId);
}

private void assertIdentifier(String rawId, CommunicationIdentifier expectedIdentifier) {
Expand Down