airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [12/13] airavata git commit: introducing summary type, dependencies and code clean up
Date Tue, 13 Dec 2016 16:14:38 GMT
introducing summary type, dependencies and code clean up


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

Branch: refs/heads/develop
Commit: c1b696badd3ccfa686cdb21ab2da0012ec7dd354
Parents: 122fb8d
Author: Anuj Bhandar <bhandar.anuj@gmail.com>
Authored: Mon Dec 12 11:58:57 2016 -0500
Committer: Anuj Bhandar <bhandar.anuj@gmail.com>
Committed: Mon Dec 12 11:58:57 2016 -0500

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |   68 +-
 .../java/org/apache/airavata/api/Airavata.java  |  766 +++++++-----
 .../credentialsummary/CredentialSummary.java    |  927 ---------------
 .../credential/store/CredentialSummary.java     | 1040 +++++++++++++++++
 .../model/credential/store/SummaryType.java     |   69 ++
 .../server/CredentialStoreServerHandler.java    |  143 ++-
 .../store/cpi/CredentialStoreService.java       | 1093 ++++++++++++------
 .../airavata-apis/airavata_api.thrift           |   36 +-
 .../component-cpis/credential-store-cpi.thrift  |   15 +-
 .../credential_store_data_models.thrift         |   25 +-
 .../credential_summary.thrift                   |   33 -
 .../resource_catalog_models.thrift              |    3 +-
 12 files changed, 2505 insertions(+), 1713 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c1b696ba/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 c3a7dd1..827ba1a 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
@@ -31,10 +31,7 @@ import org.apache.airavata.common.utils.Constants;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.credential.store.client.CredentialStoreClientFactory;
 import org.apache.airavata.credential.store.cpi.CredentialStoreService;
-import org.apache.airavata.model.credential.store.CredentialOwnerType;
-import org.apache.airavata.model.credential.store.PasswordCredential;
-import org.apache.airavata.model.credential.store.SSHCredential;
-import org.apache.airavata.model.credential.store.SSHCredentialSummary;
+import org.apache.airavata.model.credential.store.*;
 import org.apache.airavata.credential.store.exception.CredentialStoreException;
 import org.apache.airavata.messaging.core.MessageContext;
 import org.apache.airavata.messaging.core.MessagingFactory;
@@ -45,7 +42,7 @@ import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentD
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
 import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
 import org.apache.airavata.model.appcatalog.computeresource.*;
-import org.apache.airavata.model.appcatalog.credentialsummary.CredentialSummary;
+import org.apache.airavata.model.credential.store.CredentialSummary;
 import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
@@ -545,25 +542,21 @@ public class AiravataServerHandler implements Airavata.Iface {
 
     @Override
     @SecurityCheck
-    public List<CredentialSummary> getAllGatewaySSHPubKeysSummary(AuthzToken authzToken,
String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException,
TException {
+    public List<CredentialSummary> getAllCredentialSummaryForGateway(AuthzToken authzToken,
SummaryType type, String gatewayId) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, TException {
         try {
-            List<CredentialSummary> allCredentialSummaries =  new ArrayList<>();
-            if (csClient == null){
-                csClient = getCredentialStoreServiceClient();
-            }
-            List<SSHCredentialSummary> sshSummaryList = csClient.getAllGatewaySSHCredentialSummary(gatewayId);
-            for(SSHCredentialSummary key : sshSummaryList){
-                CredentialSummary summary = new CredentialSummary();
-                summary.setGatewayId(key.getGatewayId());
-                summary.setUsername(key.getUsername());
-                summary.setPublicKey(key.getPublicKey());
-                summary.setToken(key.getToken());
-                summary.setDescription(key.getDescription());
-                summary.setPersistedTime(key.getPersistedTime());
-                allCredentialSummaries.add(summary);
+            if(type.equals(SummaryType.SSH)){
+                if (csClient == null){
+                    csClient = getCredentialStoreServiceClient();
+                }
+                logger.debug("Airavata will retrieve all SSH pub keys summaries for gateway
Id : " + gatewayId);
+                return csClient.getAllCredentialSummaryForGateway(type, gatewayId);
+            } else {
+                logger.info("Summay Type"+ type.toString() + " not supported by Airavata");
+                AiravataSystemException ex = new AiravataSystemException();
+                ex.setAiravataErrorType(AiravataErrorType.UNSUPPORTED_OPERATION);
+                ex.setMessage("Summay Type"+ type.toString() + " not supported by Airavata");
+                throw ex;
             }
-            logger.debug("Airavata retrieved all SSH pub keys summaries for gateway Id :
" + gatewayId);
-            return allCredentialSummaries;
         }catch (Exception e){
             logger.error("Error occurred while retrieving SSH public keys summaries for gateway
: " + gatewayId , e);
             AiravataSystemException exception = new AiravataSystemException();
@@ -574,25 +567,22 @@ public class AiravataServerHandler implements Airavata.Iface {
     }
 
     @Override
-    public List<CredentialSummary> getAllSSHPubKeysSummaryForUserInGateway(AuthzToken
authzToken, String gatewayId, String userId) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, TException {
+    @SecurityCheck
+    public List<CredentialSummary> getAllCredentialSummaryForUsersInGateway(AuthzToken
authzToken,SummaryType type, String gatewayId, String userId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
         try {
-            List<CredentialSummary> allCredentialSummaries =  new ArrayList<>();
-            if (csClient == null){
-                csClient = getCredentialStoreServiceClient();
-            }
-            List<SSHCredentialSummary> sshSummaryListForUser = csClient.getAllSSHCredentialSummaryForUserInGateway(gatewayId,userId);
-            for(SSHCredentialSummary key : sshSummaryListForUser){
-                CredentialSummary userPubKeySummary = new CredentialSummary();
-                userPubKeySummary.setGatewayId(key.getGatewayId());
-                userPubKeySummary.setUsername(key.getUsername());
-                userPubKeySummary.setPublicKey(key.getPublicKey());
-                userPubKeySummary.setToken(key.getToken());
-                userPubKeySummary.setDescription(key.getDescription());
-                userPubKeySummary.setPersistedTime(key.getPersistedTime());
-                allCredentialSummaries.add(userPubKeySummary);
+            if(type.equals(SummaryType.SSH)){
+                if (csClient == null){
+                    csClient = getCredentialStoreServiceClient();
+                }
+                logger.debug("Airavata will retrieve all SSH pub keys summaries for gateway
Id : " + gatewayId);
+                return csClient.getAllCredentialSummaryForUserInGateway(type, gatewayId,
userId);
+            } else {
+                logger.info("Summay Type"+ type.toString() + " not supported by Airavata");
+                AiravataSystemException ex = new AiravataSystemException();
+                ex.setAiravataErrorType(AiravataErrorType.UNSUPPORTED_OPERATION);
+                ex.setMessage("Summay Type"+ type.toString() + " not supported by Airavata");
+                throw ex;
             }
-            logger.debug("Airavata retrieved all SSH pub keys summaries for gateway Id :
" + gatewayId + " & user ID : " +userId);
-            return allCredentialSummaries;
         }catch (Exception e){
             logger.error("Error occurred while retrieving SSH public keys summaries for user
: " + userId , e);
             AiravataSystemException exception = new AiravataSystemException();


Mime
View raw message