Source:
public boolean shareResourceWithUsers(AuthzToken authzToken, String resourceId, ResourceType resourceType, Map<String, ResourcePermissionType> userPermissionList) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException { RegistryService.Client regClient = registryClientPool.getResource(); SharingRegistryService.Client sharingClient = sharingClientPool.getResource(); try { for(Map.Entry<String, ResourcePermissionType> userPermission : userPermissionList.entrySet()){ String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID); if(userPermission.getValue().equals(ResourcePermissionType.WRITE)) sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "WRITE", true); else if(userPermission.getValue().equals(ResourcePermissionType.READ)) sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "READ", true); else sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "EXEC", true); } registryClientPool.returnResource(regClient); sharingClientPool.returnResource(sharingClient); return true; } catch (Exception e) { String msg = "Error in sharing resource with users. Resource ID : " + resourceId + " Resource Type : " + resourceType.toString() ; logger.error(msg, e); AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); exception.setMessage(msg + " More info : " + e.getMessage()); sharingClientPool.returnBrokenResource(sharingClient); registryClientPool.returnBrokenResource(regClient); throw exception; } }

Target:
public boolean shareResourceWithUsers(AuthzToken authzToken, String resourceId, ResourceType resourceType, Map<String, ResourcePermissionType> userPermissionList) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException { RegistryService.Client regClient = registryClientPool.getResource(); SharingRegistryService.Client sharingClient = sharingClientPool.getResource(); try { for(Map.Entry<String, ResourcePermissionType> userPermission : userPermissionList.entrySet()){ String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID); if(userPermission.getValue().equals(ResourcePermissionType.WRITE)) sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "WRITE", true); else if(userPermission.getValue().equals(ResourcePermissionType.READ)) sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "READ", true); else if(userPermission.getValue().equals(ResourcePermissionType.EXEC)) sharingClient.shareEntityWithUsers(gatewayId, resourceId, Arrays.asList(userPermission.getKey()), authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":" + "EXEC", true); else { logger.error("Invalid ResourcePermissionType : " + userPermission.getValue().toString()); throw new AiravataClientException(AiravataErrorType.UNSUPPORTED_OPERATION); } } registryClientPool.returnResource(regClient); sharingClientPool.returnResource(sharingClient); return true; } catch (Exception e) { String msg = "Error in sharing resource with users. Resource ID : " + resourceId + " Resource Type : " + resourceType.toString() ; logger.error(msg, e); AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); exception.setMessage(msg + " More info : " + e.getMessage()); sharingClientPool.returnBrokenResource(sharingClient); registryClientPool.returnBrokenResource(regClient); throw exception; } }