use of org.alfresco.rest.api.model.GroupMember in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroupMember.
private GroupMember getGroupMember(AuthorityInfo authorityInfo) {
if (authorityInfo == null) {
return null;
}
GroupMember groupMember = new GroupMember();
groupMember.setId(authorityInfo.getAuthorityName());
String authorityDisplayName = authorityInfo.getAuthorityDisplayName();
if (authorityDisplayName == null || authorityDisplayName.isEmpty()) {
authorityDisplayName = authorityService.getAuthorityDisplayName(authorityInfo.getAuthorityName());
}
groupMember.setDisplayName(authorityDisplayName);
String memberType = null;
AuthorityType authorityType = AuthorityType.getAuthorityType(authorityInfo.getAuthorityName());
switch(authorityType) {
case GROUP:
memberType = PARAM_MEMBER_TYPE_GROUP;
break;
case USER:
memberType = PARAM_MEMBER_TYPE_PERSON;
break;
default:
}
groupMember.setMemberType(memberType);
return groupMember;
}
use of org.alfresco.rest.api.model.GroupMember in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroupMembers.
public CollectionWithPagingInfo<GroupMember> getGroupMembers(String groupId, final Parameters parameters) {
validateGroupId(groupId, false);
// Not allowed to list all members.
if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
throw new UnsupportedResourceOperationException();
}
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
AuthorityType authorityType = null;
// Parse where clause properties.
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_GROUP_MEMBERS_QUERY_PROPERTIES, null);
QueryHelper.walk(q, propertyWalker);
String memberTypeStr = propertyWalker.getProperty(PARAM_MEMBER_TYPE, WhereClauseParser.EQUALS, String.class);
authorityType = getAuthorityType(memberTypeStr);
}
PagingResults<AuthorityInfo> pagingResult = getAuthoritiesInfo(authorityType, groupId, sortProp, paging);
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
List<GroupMember> groupMembers = new AbstractList<GroupMember>() {
@Override
public GroupMember get(int index) {
AuthorityInfo authorityInfo = page.get(index);
return getGroupMember(authorityInfo);
}
@Override
public int size() {
return page.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, groupMembers, pagingResult.hasMoreItems(), totalItems);
}
use of org.alfresco.rest.api.model.GroupMember in project alfresco-remote-api by Alfresco.
the class GroupsFilter method getGroupMembers.
public CollectionWithPagingInfo<GroupMember> getGroupMembers(String groupId, final Parameters parameters) {
validateGroupId(groupId, false);
// Not allowed to list all members.
if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
throw new UnsupportedResourceOperationException();
}
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
AuthorityType authorityType = null;
// Parse where clause properties.
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_GROUP_MEMBERS_QUERY_PROPERTIES, null);
QueryHelper.walk(q, propertyWalker);
String memberTypeStr = propertyWalker.getProperty(PARAM_MEMBER_TYPE, WhereClauseParser.EQUALS, String.class);
authorityType = getAuthorityType(memberTypeStr);
}
PagingResults<AuthorityInfo> pagingResult = getAuthoritiesInfo(authorityType, groupId, sortProp, paging);
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
List<GroupMember> groupMembers = new AbstractList<GroupMember>() {
@Override
public GroupMember get(int index) {
AuthorityInfo authorityInfo = page.get(index);
return getGroupMember(authorityInfo);
}
@Override
public int size() {
return page.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, groupMembers, pagingResult.hasMoreItems(), totalItems);
}
use of org.alfresco.rest.api.model.GroupMember in project alfresco-remote-api by Alfresco.
the class GroupsFilter method getGroupMember.
private GroupMember getGroupMember(AuthorityInfo authorityInfo) {
if (authorityInfo == null) {
return null;
}
GroupMember groupMember = new GroupMember();
groupMember.setId(authorityInfo.getAuthorityName());
String authorityDisplayName = authorityInfo.getAuthorityDisplayName();
if (authorityDisplayName == null || authorityDisplayName.isEmpty()) {
authorityDisplayName = authorityService.getAuthorityDisplayName(authorityInfo.getAuthorityName());
}
groupMember.setDisplayName(authorityDisplayName);
String memberType = null;
AuthorityType authorityType = AuthorityType.getAuthorityType(authorityInfo.getAuthorityName());
switch(authorityType) {
case GROUP:
memberType = PARAM_MEMBER_TYPE_GROUP;
break;
case USER:
memberType = PARAM_MEMBER_TYPE_PERSON;
break;
default:
}
groupMember.setMemberType(memberType);
return groupMember;
}
Aggregations