use of org.apache.airavata.model.group.GroupModel in project airavata by apache.
the class AiravataServerHandler method getGroup.
@Override
@SecurityCheck
public GroupModel getGroup(AuthzToken authzToken, String groupId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
UserGroup userGroup = sharingClient.getGroup(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), groupId);
GroupModel groupModel = new GroupModel();
groupModel.setId(userGroup.getGroupId());
groupModel.setName(userGroup.getName());
groupModel.setDescription(userGroup.getDescription());
groupModel.setOwnerId(userGroup.getOwnerId());
sharingClient.getGroupMembersOfTypeUser(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), groupId, 0, -1).stream().forEach(user -> groupModel.addToMembers(user.getUserId()));
return groupModel;
} catch (Exception e) {
String msg = "Error Retreiving Group. Group ID: " + groupId;
logger.error(msg, e);
AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg + " More info : " + e.getMessage());
throw exception;
}
}
Aggregations