Search in sources :

Example 1 with GroupModel

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;
    }
}
Also used : SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) GroupModel(org.apache.airavata.model.group.GroupModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Aggregations

AiravataException (org.apache.airavata.common.exception.AiravataException)1 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)1 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)1 GroupModel (org.apache.airavata.model.group.GroupModel)1 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)1 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)1 SharingRegistryService (org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService)1 TException (org.apache.thrift.TException)1