Skip to content

Commit 133c2ab

Browse files
author
bgarciaentornos
committed
EVDOC01-149 i EVDOC01-151 Truncar noms massa llargs per Teams i Channels
1 parent e03eff1 commit 133c2ab

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

microsoft-integration/impl/src/main/java/org/sakaiproject/microsoft/impl/MicrosoftCommonServiceImpl.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ public class MicrosoftCommonServiceImpl implements MicrosoftCommonService {
151151
private static final String LINK_TYPE_EDIT = "edit";
152152
private static final String LINK_TYPE_VIEW = "view";
153153
private static final String LINK_SCOPE_USERS = "users";
154+
private static final int TEAM_CHARACTER_LIMIT = 80;
155+
private static final int CHANNEL_CHARACTER_LIMIT = 50;
154156

155157

156158
@Setter private ServerConfigurationService serverConfigurationService;
@@ -529,7 +531,9 @@ public String createTeam(String name, String ownerEmail) throws MicrosoftCredent
529531
try {
530532
LinkedList<String> rolesList = new LinkedList<String>();
531533
rolesList.add("owner");
532-
534+
535+
String truncatedName = name.length() > TEAM_CHARACTER_LIMIT ? name.substring(0, TEAM_CHARACTER_LIMIT) : name;
536+
533537
User userOwner = getGraphClient().users(ownerEmail).buildRequest().get();
534538
AadUserConversationMember conversationMember = new AadUserConversationMember();
535539
conversationMember.oDataType = "#microsoft.graph.aadUserConversationMember";
@@ -544,8 +548,8 @@ public String createTeam(String name, String ownerEmail) throws MicrosoftCredent
544548
ConversationMemberCollectionPage conversationMemberCollectionPage = new ConversationMemberCollectionPage(conversationMemberCollectionResponse, null);
545549

546550
Team team = new Team();
547-
team.displayName = name;
548-
team.description = name;
551+
team.displayName = truncatedName;
552+
team.description = truncatedName;
549553
team.visibility = TeamVisibilityType.PRIVATE;
550554
team.members = conversationMemberCollectionPage;
551555
team.additionalDataManager().put("[email protected]", new JsonPrimitive("https://graph.microsoft.com/v1.0/teamsTemplates('standard')"));
@@ -568,8 +572,8 @@ public String createTeam(String name, String ownerEmail) throws MicrosoftCredent
568572
Map<String, MicrosoftTeam> teamsMap = (Map<String, MicrosoftTeam>)cachedValue.get();
569573
teamsMap.put(teamId, MicrosoftTeam.builder()
570574
.id(teamId)
571-
.name(name)
572-
.description(name)
575+
.name(truncatedName)
576+
.description(truncatedName)
573577
.build());
574578

575579
getCache().put(CACHE_TEAMS, teamsMap);
@@ -1079,10 +1083,12 @@ public Map<String, MicrosoftChannel> getTeamPrivateChannels(String teamId, boole
10791083
@Override
10801084
public String createChannel(String teamId, String name, String ownerEmail) throws MicrosoftCredentialsException {
10811085
try {
1086+
String truncatedName = name.length() > CHANNEL_CHARACTER_LIMIT ? name.substring(0, CHANNEL_CHARACTER_LIMIT) : name;
1087+
10821088
Channel channel = new Channel();
10831089
channel.membershipType = ChannelMembershipType.PRIVATE;
1084-
channel.displayName = formatMicrosoftString(name);
1085-
channel.description = name;
1090+
channel.displayName = formatMicrosoftString(truncatedName);
1091+
channel.description = truncatedName;
10861092

10871093
User userOwner = getGraphClient().users(ownerEmail).buildRequest().get();
10881094
AadUserConversationMember conversationMember = new AadUserConversationMember();

0 commit comments

Comments
 (0)