airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [01/10] airavata git commit: Initial Changes for the API to support data sharing
Date Thu, 07 Jul 2016 06:31:57 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop 4766b37c5 -> edfbbfe09


http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerException.java
----------------------------------------------------------------------
diff --git a/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerException.java
b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerException.java
new file mode 100644
index 0000000..4f8951e
--- /dev/null
+++ b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerException.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.grouper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GroupManagerException extends Exception {
+    private final static Logger logger = LoggerFactory.getLogger(GroupManagerException.class);
+
+    public GroupManagerException(Exception e) {
+        super(e);
+    }
+
+    public GroupManagerException(String s) {
+        super(s);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerFactory.java
----------------------------------------------------------------------
diff --git a/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerFactory.java
b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerFactory.java
new file mode 100644
index 0000000..5c6a447
--- /dev/null
+++ b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerFactory.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.grouper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GroupManagerFactory {
+    private final static Logger logger = LoggerFactory.getLogger(GroupManagerFactory.class);
+
+    private static GroupManagerCPI groupManager;
+
+    public static GroupManagerCPI getGroupManager() throws GroupManagerException {
+        try {
+            if (groupManager == null) {
+                 groupManager = new GroupManagerImpl();
+            }
+        } catch (Exception e) {
+            logger.error("Unable to create Group Manager client", e);
+            throw new GroupManagerException(e);
+        }
+        return groupManager;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerImpl.java
b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerImpl.java
index 6f75aa2..db5993d 100644
--- a/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerImpl.java
+++ b/modules/group-manager/src/main/java/org/apache/airavata/grouper/GroupManagerImpl.java
@@ -20,9 +20,61 @@
 */
 package org.apache.airavata.grouper;
 
+import org.apache.airavata.grouper.permission.PermissionAction;
+import org.apache.airavata.grouper.permission.PermissionServiceImpl;
+import org.apache.airavata.grouper.resource.Resource;
+import org.apache.airavata.grouper.resource.ResourceServiceImpl;
+import org.apache.airavata.grouper.resource.ResourceType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
 public class GroupManagerImpl implements GroupManagerCPI {
     private final static Logger logger = LoggerFactory.getLogger(GroupManagerImpl.class);
+
+    private ResourceServiceImpl resourceService;
+    private PermissionServiceImpl permissionService;
+
+    public GroupManagerImpl(){
+        this.resourceService = new ResourceServiceImpl();
+        this.permissionService = new PermissionServiceImpl();
+    }
+
+    @Override
+    public void createResource(Resource projectResource) {
+        resourceService.createResource(projectResource);
+    }
+
+    @Override
+    public boolean isResourceRegistered(String resourceId, ResourceType resourceType) {
+        return resourceService.getResource(resourceId, resourceType) != null;
+    }
+
+    @Override
+    public void grantPermission(String userId, SubjectType subjectType, String resourceId,
ResourceType resourceType,
+                                PermissionAction permissionAction) {
+        permissionService.grantPermission(userId, subjectType, resourceId, resourceType,
permissionAction);
+    }
+
+    @Override
+    public void revokePermission(String userId, SubjectType subjectType, String resourceId,
ResourceType resourceType,
+                                 PermissionAction action) {
+        permissionService.revokePermission(userId, subjectType, resourceId, resourceType,
action);
+    }
+
+    @Override
+    public Set<String> getAllAccessibleUsers(String resourceId, ResourceType resourceType,
PermissionAction permissionType) {
+        return resourceService.getAllAccessibleUsers(resourceId, resourceType, permissionType);
+    }
+
+    @Override
+    public List<String> getAccessibleResourcesForUser(String userId, ResourceType resourceType,
PermissionAction permissionAction) {
+        Set<Resource> allResources = resourceService.getAccessibleResourcesForUser(userId,
resourceType, permissionAction, false, 0, -1);
+        List<String> ids = new ArrayList<>(allResources.size());
+        allResources.stream().forEach(r->ids.add(r.getId()));
+        return ids;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
index a95b85e..737746f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
@@ -63,6 +63,7 @@ public class ThriftDataModelConversion {
 			}
 			project.setDescription(pr.getDescription());
             project.setOwner(pr.getWorker().getUser());
+            project.setGatewayId(pr.getGatewayId());
             List<ProjectUserResource> projectUserList = pr.getProjectUserList();
             List<String> sharedUsers = new ArrayList<String>();
             if (projectUserList != null && !projectUserList.isEmpty()){

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
index 5dad27e..4efd940 100644
--- a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
+++ b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
@@ -41,6 +41,7 @@ include "../data-models/resource-catalog-models/gateway_resource_profile_model.t
 include "../data-models/resource-catalog-models/data_movement_models.thrift"
 include "../data-models/workflow-models/workflow_data_model.thrift"
 include "../data-models/replica-catalog-models/replica_catalog_models.thrift"
+include "../data-models/user-group-models/group_manager_model.thrift"
 
 namespace java org.apache.airavata.api
 namespace php Airavata.API
@@ -2871,6 +2872,31 @@ service Airavata {
                                  2: airavata_errors.AiravataClientException ace,
                                  3: airavata_errors.AiravataSystemException ase,
                                  4: airavata_errors.AuthorizationException ae)
+
+ /**
+  * Group Manager and Data Sharing Related API methods
+  **/
+  bool shareResourceWithUsers(1: required security_model.AuthzToken authzToken, 2: required
string resourceId, 3: required group_manager_model.ResourceType resourceType,
+                                4: map<string, group_manager_model.ResourcePermissionType>
userPermissionList)
+               throws (1: airavata_errors.InvalidRequestException ire,
+                                                2: airavata_errors.AiravataClientException
ace,
+                                                3: airavata_errors.AiravataSystemException
ase,
+                                                4: airavata_errors.AuthorizationException
ae)
+
+ bool revokeSharingOfResourceFromUsers(1: required security_model.AuthzToken authzToken,
2: required string resourceId, 3: required group_manager_model.ResourceType resourceType,
+                                 4: map<string, group_manager_model.ResourcePermissionType>
userPermissionList)
+                throws (1: airavata_errors.InvalidRequestException ire,
+                                                 2: airavata_errors.AiravataClientException
ace,
+                                                 3: airavata_errors.AiravataSystemException
ase,
+                                                 4: airavata_errors.AuthorizationException
ae)
+
+ list<string> getAllAccessibleUsers(1: required security_model.AuthzToken authzToken,
2: required string resourceId, 3: required group_manager_model.ResourceType resourceType,
+                                  4: required group_manager_model.ResourcePermissionType
permissionType)
+                throws (1: airavata_errors.InvalidRequestException ire,
+                                                 2: airavata_errors.AiravataClientException
ace,
+                                                 3: airavata_errors.AiravataSystemException
ase,
+                                                 4: airavata_errors.AuthorizationException
ae)
+
  //End of API
  }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/thrift-interface-descriptions/data-models/airavata_data_models.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/airavata_data_models.thrift b/thrift-interface-descriptions/data-models/airavata_data_models.thrift
index 6eae503..b67614f 100644
--- a/thrift-interface-descriptions/data-models/airavata_data_models.thrift
+++ b/thrift-interface-descriptions/data-models/airavata_data_models.thrift
@@ -32,6 +32,7 @@ include "experiment-catalog-models/status_models.thrift"
 include "resource-catalog-models/data_movement_models.thrift"
 include "replica-catalog-models/replica_catalog_models.thrift"
 include "user-group-models/user_profile_model.thrift"
+include "user-group-models/group_manager_model.thrift"
 
 namespace java org.apache.airavata.model
 namespace php Airavata.Model

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
b/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
index f2532dd..e214d39 100644
--- a/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
+++ b/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
@@ -43,16 +43,21 @@ struct Group {
 struct Project {
     1: required string projectID = airavata_commons.DEFAULT_ID,
     2: required string owner,
-    3: required string name,
-    4: optional string description
-    5: optional i64 creationTime
-    6: optional list<string> sharedUsers,
-    7: optional list<string> sharedGroups
+    3: required string gatewayId,
+    4: required string name,
+    5: optional string description
+    6: optional i64 creationTime
+    7: optional list<string> sharedUsers,
+    8: optional list<string> sharedGroups
 }
 
 struct User {
-    1: required string userName,
-    2: optional list<Group> groupList
+    1: required string airavataInternalUserId = airavata_commons.DEFAULT_ID,
+    2: optional string userName,
+    3: required string gatewayId,
+    4: optional string firstName,
+    5: optional string lastName,
+    6: optional string email
 }
 
 struct Gateway {

http://git-wip-us.apache.org/repos/asf/airavata/blob/edfbbfe0/thrift-interface-descriptions/data-models/user-group-models/group_manager_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/user-group-models/group_manager_model.thrift
b/thrift-interface-descriptions/data-models/user-group-models/group_manager_model.thrift
index 9a82c60..547020e 100644
--- a/thrift-interface-descriptions/data-models/user-group-models/group_manager_model.thrift
+++ b/thrift-interface-descriptions/data-models/user-group-models/group_manager_model.thrift
@@ -25,8 +25,6 @@
  namespace cpp apache.airavata.model.group
  namespace py apache.airavata.model.group
 
-const string GROUP_MANAGER_VERSION = "1.0"
-
 
 enum ResourceType {
     PROJECT,
@@ -36,53 +34,6 @@ enum ResourceType {
 }
 
 enum ResourcePermissionType {
-    READ_WRITE,
-    READ_ONLY
-}
-
-struct Resource {
-    1: required string resourceId = airavata_commons.DEFAULT_ID,
-    2: required string resourceName,
-    3: required ResourceType resourceType,
-    4: required string ownerId,
-    5: optional string resourceDescription,
-    6: optional i64 createdTime,
-    8: optional string parentResourceId,
-    9: optional list<Resource> childResources,
-    10: optional map<string,string> metadata
-}
-
-struct Group{
-    1: required string groupId = airavata_commons.DEFAULT_ID,
-    2: required string groupId,
-    3: required string groupName,
-    4: optional string description,
-    5: optional list<User> users,
-    6: optional list<Group> subGroups,
-    7: optional map<string,string> metadata
-}
-
-struct User {
-    1: required string airavataInternalUserId,
-    2: required string userId,
-    3: optional map<string,string> metadata
-}
-
-enum SubjectType {
-    USER,
-    GROUP
-}
-
-enum GroupMembershipType {
-    DIRECT,
-    INDIRECT
-}
-
-struct GroupMembership{
-    1: required string groupId,
-    2: required string childId,
-    3: required SubjectType childSubjectType,
-    4: required string parentSubjectName,
-    5: required string childSubjectName,
-    6: required GroupMembershipType groupMembershipType
+    WRITE,
+    READ
 }
\ No newline at end of file


Mime
View raw message