Skip to content

Commit

Permalink
ACS-5506 Add proper exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Jan 17, 2024
1 parent e27eac5 commit e0e2f74
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthorityService;
Expand All @@ -79,6 +80,7 @@
import org.alfresco.service.namespace.QName;
import org.alfresco.util.AlfrescoCollator;
import org.alfresco.util.Pair;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.extensions.surf.util.I18NUtil;

Expand Down Expand Up @@ -613,12 +615,26 @@ private Group getGroup(AuthorityInfo authorityInfo, List<String> includeParam, S
group.setDisplayName(authorityDisplayName);

group.setIsRoot(isRootAuthority(rootAuthorities, authorityInfo.getAuthorityName()));
group.setHasSubgroups(!authorityService.getContainedAuthorities(AuthorityType.GROUP, authorityInfo.getAuthorityName(), true).isEmpty());

Set<String> containedAuthorities;
try {
containedAuthorities = authorityService.getContainedAuthorities(AuthorityType.GROUP, authorityInfo.getAuthorityName(), true);
} catch (UnknownAuthorityException e)
{
containedAuthorities = Collections.emptySet();
}
group.setHasSubgroups(CollectionUtils.isNotEmpty(containedAuthorities));

NodeRef groupNodeRef = authorityService.getAuthorityNodeRef(authorityInfo.getAuthorityName());
String description = nodeService.getProperty(groupNodeRef, ContentModel.PROP_DESCRIPTION) != null ?
nodeService.getProperty(groupNodeRef, ContentModel.PROP_DESCRIPTION).toString() :
null;
String description;
try {
description = nodeService.getProperty(groupNodeRef, ContentModel.PROP_DESCRIPTION) != null ?
nodeService.getProperty(groupNodeRef, ContentModel.PROP_DESCRIPTION).toString() :
null;
} catch (InvalidNodeRefException e)
{
description = null;
}
group.setDescription(description);

// Optionally include
Expand Down

0 comments on commit e0e2f74

Please sign in to comment.