-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed MS bot identifier to MS Teams app identifier. (#37463)
* Changed MS bot identifier to MS Teams app identifier. * Made SetRawId protected for MSTeams app identifier * Updating changelog. * Fixing Changelog. * Changed communication common package version to minor version bump * Changing the version to beta.2 as beta.1 was already released
- Loading branch information
1 parent
fc8e083
commit 2b02072
Showing
9 changed files
with
131 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 0 additions & 132 deletions
132
...unication-common/src/main/java/com/azure/communication/common/MicrosoftBotIdentifier.java
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
...tion-common/src/main/java/com/azure/communication/common/MicrosoftTeamsAppIdentifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.communication.common; | ||
|
||
import com.azure.core.util.CoreUtils; | ||
|
||
/** | ||
* Communication identifier for Microsoft Teams Application | ||
*/ | ||
public final class MicrosoftTeamsAppIdentifier extends CommunicationIdentifier { | ||
private final String appId; | ||
|
||
private final CommunicationCloudEnvironment cloudEnvironment; | ||
|
||
/** | ||
* Creates a MicrosoftTeamsAppIdentifier object | ||
* | ||
* @param appId ID of the Microsoft Teams Application. | ||
* @param cloudEnvironment the cloud environment in which this identifier is created. | ||
* @throws IllegalArgumentException thrown if appId parameter fails the validation. | ||
*/ | ||
public MicrosoftTeamsAppIdentifier(String appId, CommunicationCloudEnvironment cloudEnvironment) { | ||
if (CoreUtils.isNullOrEmpty(appId)) { | ||
throw new IllegalArgumentException("The initialization parameter [appId] cannot be null or empty."); | ||
} | ||
this.appId = appId; | ||
this.cloudEnvironment = cloudEnvironment; | ||
generateRawId(); | ||
} | ||
|
||
/** | ||
* Creates a MicrosoftTeamsAppIdentifier object | ||
* | ||
* @param appId ID of the Microsoft Teams Application. | ||
* @throws IllegalArgumentException thrown if appId parameter fails the validation. | ||
*/ | ||
public MicrosoftTeamsAppIdentifier(String appId) { | ||
this(appId, CommunicationCloudEnvironment.PUBLIC); | ||
} | ||
|
||
/** | ||
* Get application ID | ||
* @return ID of the Microsoft Teams Application. | ||
*/ | ||
public String getAppId() { | ||
return this.appId; | ||
} | ||
|
||
/** | ||
* Get cloud environment of the application identifier | ||
* | ||
* @return cloud environment in which this identifier is created. | ||
*/ | ||
public CommunicationCloudEnvironment getCloudEnvironment() { | ||
return cloudEnvironment; | ||
} | ||
|
||
/** | ||
* 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 MicrosoftTeamsAppIdentifier object itself. | ||
*/ | ||
@Override | ||
protected MicrosoftTeamsAppIdentifier setRawId(String rawId) { | ||
super.setRawId(rawId); | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object that) { | ||
if (this == that) { | ||
return true; | ||
} | ||
|
||
if (!(that instanceof MicrosoftTeamsAppIdentifier)) { | ||
return false; | ||
} | ||
|
||
return ((MicrosoftTeamsAppIdentifier) that).getRawId().equals(getRawId()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getRawId().hashCode(); | ||
} | ||
|
||
private void generateRawId() { | ||
if (cloudEnvironment.equals(CommunicationCloudEnvironment.DOD)) { | ||
super.setRawId(TEAMS_APP_DOD_CLOUD_PREFIX + this.appId); | ||
} else if (cloudEnvironment.equals(CommunicationCloudEnvironment.GCCH)) { | ||
super.setRawId(TEAMS_APP_GCCH_CLOUD_PREFIX + this.appId); | ||
} else { | ||
super.setRawId(TEAMS_APP_PUBLIC_CLOUD_PREFIX + this.appId); | ||
} | ||
} | ||
} |
Oops, something went wrong.