Bug fix: always update exp entity in sharing registry
@@ -1629,25 +1629,31 @@ public class AiravataServerHandler implements Airavata.Iface {
SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
try {
ExperimentModel experimentModel = regClient.getExperiment(airavataExperimentId);
+ String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
if(ServerSettings.isEnableSharing() && !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(experimentModel.getUserName())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
try {
// Verify WRITE access
- String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
String userId = authzToken.getClaimsMap().get(Constants.USER_NAME);
if (!sharingClient.userHasAccess(gatewayId, userId + "@" + gatewayId,
airavataExperimentId, gatewayId + ":WRITE")){
throw new AuthorizationException("User does not have permission to access this resource");
}
+ } catch (Exception e) {
+ throw new AuthorizationException("User does not have permission to access this resource");
+ }
+ }
+
+ try {
// Update name, description and parent on Entity
+ // TODO: update the experiment via a DB event
Entity entity = sharingClient.getEntity(gatewayId, airavataExperimentId);
entity.setName(experiment.getExperimentName());
entity.setDescription(experiment.getDescription());
entity.setParentEntityId(experiment.getProjectId());
sharingClient.updateEntity(entity);
} catch (Exception e) {
- throw new AuthorizationException("User does not have permission to access this resource");
- }
+ throw new Exception("Failed to update entity in sharing registry", e);
}
regClient.updateExperiment(airavataExperimentId, experiment);
