airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: minor fixes
Date Sat, 16 Jul 2016 15:51:31 GMT
Repository: airavata
Updated Branches:
  refs/heads/grouper-integration 971947c16 -> 3d5af1950


minor fixes


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/3d5af195
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/3d5af195
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/3d5af195

Branch: refs/heads/grouper-integration
Commit: 3d5af1950f181804dee250b041b28366de465500
Parents: 971947c
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Sat Jul 16 11:51:19 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Sat Jul 16 11:51:19 2016 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 27 ++++++++------------
 1 file changed, 10 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/3d5af195/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index a7efbf5..47d9fb6 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -1965,27 +1965,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             logger.debug("Airavata cloned experiment with experiment id : " + existingExperimentID);
             existingExperiment.setUserName(authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME));
             String expId = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT,
existingExperiment, gatewayId);
-            GroupManagerCPI groupManagerCPI = GroupManagerFactory.getGroupManager();
 
             String projectId = existingExperiment.getProjectId();
-            if(!groupManagerCPI.isResourceRegistered(projectId, org.apache.airavata.grouper.resource.ResourceType.PROJECT)){
-                Project project = (Project)experimentCatalog.get(ExperimentCatalogModelType.PROJECT,
projectId);
-                Resource projectResource = new Resource(projectId, org.apache.airavata.grouper.resource.ResourceType.PROJECT);
-                projectResource.setName(project.getName());
-                projectResource.setDescription(project.getDescription());
-                projectResource.setOwnerId(project.getOwner()+"@"+project.getGatewayId());
+            if(!isResourceExistsInGrouper(projectId, ResourceType.PROJECT)){
+                initializeResourceWithGrouper(projectId, ResourceType.PROJECT);
             }
-
-            Resource expResource = new Resource(expId, org.apache.airavata.grouper.resource.ResourceType.EXPERIMENT);
-            expResource.setParentResourceId(existingExperiment.getProjectId());
-            expResource.setName(existingExperiment.getExperimentName());
-            expResource.setOwnerId(existingExperiment.getUserName()+"@"+existingExperiment.getGatewayId());
-            expResource.setDescription(existingExperiment.getDescription());
-            groupManagerCPI.createResource(expResource);
-
+            initializeResourceWithGrouper(expId, ResourceType.EXPERIMENT);
             return expId;
         } catch (Exception e) {
-
             logger.error(existingExperimentID, "Error while cloning the experiment with existing
configuration...", e);
             AiravataSystemException exception = new AiravataSystemException();
             exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -4630,6 +4617,9 @@ public class AiravataServerHandler implements Airavata.Iface {
 
         }else if(resourceType.equals(ResourceType.EXPERIMENT)){
             ExperimentModel experiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
resourceId);
+            if(!isResourceExistsInGrouper(experiment.getProjectId(), ResourceType.PROJECT)){
+                initializeResourceWithGrouper(experiment.getProjectId(), ResourceType.PROJECT);
+            }
             Resource experimentResource = new Resource(experiment.getExperimentId(), org.apache.airavata.grouper.resource.ResourceType.EXPERIMENT);
             experimentResource.setName(experiment.getExperimentName());
             experimentResource.setDescription(experiment.getDescription());
@@ -4654,7 +4644,10 @@ public class AiravataServerHandler implements Airavata.Iface {
 
     }
 
-    private boolean hasPermission(String userId, String resourceId, ResourceType resourceType,
ResourcePermissionType permissionType) throws GroupManagerException {
+    private boolean hasPermission(String userId, String resourceId, ResourceType resourceType,
ResourcePermissionType permissionType) throws GroupManagerException, RegistryException {
+        if(!isResourceExistsInGrouper(resourceId, resourceType)){
+            initializeResourceWithGrouper(resourceId, resourceType);
+        }
         GroupManagerCPI groupManager = GroupManagerFactory.getGroupManager();
         org.apache.airavata.grouper.resource.ResourceType gResourceType;
         if(resourceType.equals(ResourceType.PROJECT)){


Mime
View raw message