You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2015/03/02 21:27:53 UTC

[7/7] airavata git commit: adding CRUD operations to gateway - AIRAVATA-1608, AIRAVATA-1604

adding CRUD operations to gateway - AIRAVATA-1608, AIRAVATA-1604


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

Branch: refs/heads/master
Commit: 658e5e9e66147830adb848ca9a9f4700e10a5583
Parents: ed6d1af
Author: Chathuri Wimalasena <ka...@gmail.com>
Authored: Mon Mar 2 15:27:37 2015 -0500
Committer: Chathuri Wimalasena <ka...@gmail.com>
Committed: Mon Mar 2 15:27:37 2015 -0500

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |   115 +-
 .../java/org/apache/airavata/api/Airavata.java  | 10814 ++++++++++++++---
 .../main/resources/lib/airavata/Airavata.cpp    |  3411 +++++-
 .../src/main/resources/lib/airavata/Airavata.h  |  1025 +-
 .../lib/airavata/Airavata_server.skeleton.cpp   |    30 +
 .../gatewayResourceProfileModel_constants.cpp   |     2 -
 .../gatewayResourceProfileModel_constants.h     |     1 -
 .../gatewayResourceProfileModel_types.cpp       |    36 +-
 .../gatewayResourceProfileModel_types.h         |    26 +-
 .../lib/airavata/workspaceModel_types.cpp       |    51 +-
 .../lib/airavata/workspaceModel_types.h         |    45 +-
 .../resources/lib/Airavata/API/Airavata.php     |  4978 +++++---
 .../Model/AppCatalog/GatewayProfile/Types.php   |    46 +-
 .../lib/Airavata/Model/Workspace/Types.php      |    58 +-
 .../client/samples/RegisterSampleData.java      |     1 -
 .../tools/RegisterOGCEUS3Application.java       |     2 +-
 .../tools/RegisterSampleApplications.java       |     1 -
 .../client/tools/RegisterUS3Application.java    |     2 +-
 .../gatewayprofile/GatewayResourceProfile.java  |   220 +-
 .../airavata/model/workspace/Gateway.java       |   334 +-
 .../airavataAPI.thrift                          |    32 +-
 .../gatewayResourceProfileModel.thrift          |     8 +-
 .../workspaceModel.thrift                       |     6 +-
 .../data/impl/GwyResourceProfileImpl.java       |    28 +-
 .../catalog/data/model/GatewayProfile.java      |    19 -
 .../data/resources/AbstractResource.java        |     1 -
 .../data/resources/GatewayProfileResource.java  |    30 +-
 .../catalog/data/util/AppCatalogJPAUtils.java   |     2 -
 .../data/util/AppCatalogThriftConversion.java   |     2 -
 .../src/main/resources/appcatalog-derby.sql     |     2 -
 .../src/main/resources/appcatalog-mysql.sql     |     4 +-
 .../app/catalog/test/GatewayProfileTest.java    |     5 +-
 .../src/test/resources/appcatalog-derby.sql     |     2 -
 .../integration/tools/DocumentCreatorNew.java   |     4 +-
 .../persistance/registry/jpa/ResourceUtils.java |    33 +
 .../registry/jpa/impl/GatewayRegistry.java      |    76 +
 .../registry/jpa/impl/RegistryImpl.java         |    20 +
 .../jpa/utils/ThriftDataModelConversion.java    |    19 +
 .../airavata/registry/cpi/ParentDataType.java   |     3 +-
 .../registry/cpi/RegistryModelType.java         |     1 +
 40 files changed, 16714 insertions(+), 4781 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/658e5e9e/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 722c1d0..c23ad66 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
@@ -59,6 +59,7 @@ import org.apache.airavata.model.error.InvalidRequestException;
 import org.apache.airavata.model.error.ProjectNotFoundException;
 import org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent;
 import org.apache.airavata.model.messaging.event.MessageType;
+import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
 import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
@@ -117,7 +118,119 @@ public class AiravataServerHandler implements Airavata.Iface {
         return airavataAPIConstants.AIRAVATA_API_VERSION;
     }
 
-    /**
+    @Override
+    public String addGateway(Gateway gateway) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            registry = RegistryFactory.getDefaultRegistry();
+            if (!validateString(gateway.getGatewayId())){
+                logger.error("Gateway id cannot be empty...");
+                throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+            }
+            return (String)registry.add(ParentDataType.GATEWAY, gateway);
+        } catch (RegistryException e) {
+            logger.error("Error while adding gateway", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while adding gateway. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
+    public void updateGateway(String gatewayId, Gateway updatedGateway) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            registry = RegistryFactory.getDefaultRegistry();
+            if (!registry.isExist(RegistryModelType.GATEWAY, gatewayId)){
+                logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                throw exception;
+            }
+            registry.update(RegistryModelType.GATEWAY, updatedGateway, gatewayId);
+        } catch (RegistryException e) {
+            logger.error("Error while updating the gateway", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while updating the gateway. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
+    public Gateway getGateway(String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            registry = RegistryFactory.getDefaultRegistry();
+            if (!registry.isExist(RegistryModelType.GATEWAY, gatewayId)){
+                logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                throw exception;
+            }
+            return (Gateway)registry.get(RegistryModelType.GATEWAY, gatewayId);
+        } catch (RegistryException e) {
+            logger.error("Error while getting the gateway", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while getting the gateway. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
+    public boolean deleteGateway(String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            registry = RegistryFactory.getDefaultRegistry();
+            if (!registry.isExist(RegistryModelType.GATEWAY, gatewayId)){
+                logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
+                throw exception;
+            }
+            registry.remove(RegistryModelType.GATEWAY, gatewayId);
+            return true;
+        } catch (RegistryException e) {
+            logger.error("Error while deleting the gateway", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while deleting the gateway. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
+    public List<Gateway> getAllGateways() throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            List<Gateway> gateways = new ArrayList<Gateway>();
+            registry = RegistryFactory.getDefaultRegistry();
+            List<Object> list = registry.get(RegistryModelType.GATEWAY, null, null);
+            for (Object gateway : list){
+                gateways.add((Gateway)gateway);
+            }
+            return gateways;
+        } catch (RegistryException e) {
+            logger.error("Error while getting all the gateways", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while getting all the gateways. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
+    public boolean isGatewayExist(String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+        try {
+            registry = RegistryFactory.getDefaultRegistry();
+            return registry.isExist(RegistryModelType.GATEWAY, gatewayId);
+        } catch (RegistryException e) {
+            logger.error("Error while getting gateway", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while getting gateway. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+        /**
      * Create a Project
      *
      * @param project