airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: pass gateway id when initialize registry - AIRAVATA-1608
Date Wed, 04 Mar 2015 21:49:24 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 7c5f1c85a -> c69d322b2


pass gateway id when initialize registry - AIRAVATA-1608


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

Branch: refs/heads/master
Commit: c69d322b23e2d7b066191934dc832f2c9e20ec36
Parents: 7c5f1c8
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Wed Mar 4 16:49:19 2015 -0500
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Wed Mar 4 16:49:19 2015 -0500

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 37 +++++++++++---------
 .../registry/jpa/impl/ExperimentRegistry.java   |  2 ++
 .../registry/jpa/impl/RegistryFactory.java      | 17 +++++++++
 .../persistance/registry/jpa/model/Project.java | 11 ++++++
 .../registry/jpa/resources/ProjectResource.java |  2 ++
 .../airavata/registry/cpi/utils/Constants.java  |  3 +-
 6 files changed, 55 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/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 32aa08b..66e4c94 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
@@ -139,7 +139,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public void updateGateway(String gatewayId, Gateway updatedGateway) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             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();
@@ -159,7 +159,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public Gateway getGateway(String gatewayId) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             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();
@@ -179,7 +179,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public boolean deleteGateway(String gatewayId) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             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();
@@ -219,7 +219,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public boolean isGatewayExist(String gatewayId) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             return registry.isExist(RegistryModelType.GATEWAY, gatewayId);
         } catch (RegistryException e) {
             logger.error("Error while getting gateway", e);
@@ -253,7 +253,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public String createProject(String gatewayId, Project project) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             if (!validateString(project.getName()) || !validateString(project.getOwner())){
                 logger.error("Project name and owner cannot be empty...");
                 throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
@@ -370,7 +370,7 @@ public class AiravataServerHandler implements Airavata.Iface {
                 exception.setMessage("User does not exist in the system. Please provide a
valid user..");
                 throw exception;
             }
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             List<Object> list = registry.get(RegistryModelType.PROJECT, Constants.FieldConstants.ProjectConstants.OWNER,
userName);
             if (list != null && !list.isEmpty()){
                 for (Object o : list){
@@ -411,9 +411,10 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<Project> projects = new ArrayList<Project>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
+            filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
             filters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, projectName);
             List<Object> results = registry.search(RegistryModelType.PROJECT, filters);
             for (Object object : results) {
@@ -453,9 +454,10 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<Project> projects = new ArrayList<Project>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
+            filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
             filters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, description);
             List<Object> results = registry.search(RegistryModelType.PROJECT, filters);
             for (Object object : results) {
@@ -495,9 +497,10 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
             filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, expName);
             List<Object> results = registry.search(RegistryModelType.EXPERIMENT, filters);
             for (Object object : results) {
@@ -537,9 +540,10 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
             filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_DESC, description);
             List<Object> results = registry.search(RegistryModelType.EXPERIMENT, filters);
             for (Object object : results) {
@@ -576,10 +580,11 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
             filters.put(Constants.FieldConstants.ExperimentConstants.APPLICATION_ID, applicationId);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
             List<Object> results = registry.search(RegistryModelType.EXPERIMENT, filters);
             for (Object object : results) {
                 summaries.add((ExperimentSummary) object);
@@ -616,7 +621,7 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
             filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, experimentState.toString());
@@ -656,7 +661,7 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             Map<String, String> filters = new HashMap<String, String>();
             filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
             filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, String.valueOf(fromTime));
@@ -745,7 +750,7 @@ public class AiravataServerHandler implements Airavata.Iface {
                 throw exception;
             }
             List<Experiment> experiments = new ArrayList<Experiment>();
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             List<Object> list = registry.get(RegistryModelType.EXPERIMENT, Constants.FieldConstants.ExperimentConstants.USER_NAME,
userName);
             if (list != null && !list.isEmpty()){
                 for (Object o : list){
@@ -787,7 +792,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     @Override
     public String createExperiment(String gatewayId, Experiment experiment) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
         try {
-            registry = RegistryFactory.getDefaultRegistry();
+            registry = RegistryFactory.getRegistry(gatewayId);
             if (!validateString(experiment.getName())){
                 logger.error("Cannot create experiments with empty experiment name");
                 AiravataSystemException exception = new AiravataSystemException();
@@ -1595,7 +1600,7 @@ public class AiravataServerHandler implements Airavata.Iface {
     /**
      * Fetch all Application Deployment Descriptions.
      *
-     * @return list<applicationDeployment.
+     * @return list applicationDeployment.
      * Returns the list of all application Deployment Objects.
      */
     @Override

http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index d2d99a0..0c90322 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -2796,6 +2796,8 @@ public class ExperimentRegistry {
                         fil.put(AbstractResource.ExperimentConstants.EXPERIMENT_NAME, filters.get(field));
                     } else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME))
{
                         fil.put(AbstractResource.ExperimentConstants.EXECUTION_USER, filters.get(field));
+                    }else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY))
{
+                        fil.put(AbstractResource.ExperimentConstants.GATEWAY_ID, filters.get(field));
                     } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_DESC))
{
                         fil.put(AbstractResource.ExperimentConstants.DESCRIPTION, filters.get(field));
                     } else if (field.equals(Constants.FieldConstants.ExperimentConstants.APPLICATION_ID))
{

http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
index 91d2bc4..8af4f19 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
@@ -21,6 +21,8 @@
 
 package org.apache.airavata.persistance.registry.jpa.impl;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.registry.cpi.Registry;
 import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
@@ -42,6 +44,21 @@ public class RegistryFactory {
         return registry;
     }
 
+    public static Registry getRegistry(String gateway) throws RegistryException {
+        try {
+            if (registry == null) {
+                registry = new RegistryImpl(gateway, ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword());
+            }
+        } catch (RegistryException e) {
+            logger.error("Unable to create registry instance", e);
+            throw new RegistryException(e);
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to create registry instance", e);
+            throw new RegistryException(e);
+        }
+        return registry;
+    }
+
     public static Registry getDefaultRegistry () throws RegistryException {
         try {
             if (registry == null) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java
index 78a45b2..054411d 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java
@@ -34,6 +34,9 @@ public class Project implements Serializable {
     @Column(name = "PROJECT_ID")
     private String project_id;
 
+    @Column(name = "GATEWAY_ID")
+    private String gateway_id;
+
     @Column(name = "PROJECT_NAME")
     private String project_name;
 
@@ -110,5 +113,13 @@ public class Project implements Serializable {
     public void setUser_name(String user_name) {
         this.user_name = user_name;
     }
+
+    public String getGateway_id() {
+        return gateway_id;
+    }
+
+    public void setGateway_id(String gateway_id) {
+        this.gateway_id = gateway_id;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
index 1926158..c53b489 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
@@ -255,6 +255,7 @@ public class ProjectResource extends AbstractResource {
             project.setProject_name(name);
             Gateway modelGateway = em.find(Gateway.class, gateway.getGatewayId());
             project.setGateway(modelGateway);
+            project.setGateway_id(modelGateway.getGateway_id());
             Users user = em.find(Users.class, worker.getUser());
             project.setUsers(user);
             project.setUser_name(user.getUser_name());
@@ -264,6 +265,7 @@ public class ProjectResource extends AbstractResource {
             if (existingProject != null) {
                 existingProject.setProject_name(name);
                 existingProject.setGateway(modelGateway);
+                existingProject.setGateway_id(modelGateway.getGateway_id());
                 existingProject.setUsers(user);
                 existingProject.setUser_name(user.getUser_name());
                 existingProject.setDescription(description);

http://git-wip-us.apache.org/repos/asf/airavata/blob/c69d322b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
index f7ef9ff..5defafe 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
@@ -25,6 +25,7 @@ public class Constants {
     public final class FieldConstants {
         public final class ProjectConstants {
             public static final String PROJECT_ID = "projectID";
+            public static final String GATEWAY_ID = "gateway_id";
             public static final String OWNER = "owner";
             public static final String PROJECT_NAME = "name";
             public static final String DESCRIPTION = "description";
@@ -33,7 +34,7 @@ public class Constants {
         public final class ExperimentConstants {
             public static final String EXPERIMENT_NAME = "experimentName";
             public static final String USER_NAME = "userName";
-            public static final String GATEWAY = "gateway";
+            public static final String GATEWAY = "gatewayId";
             public static final String EXPERIMENT_DESC = "experimentDescription";
             public static final String PROJECT_ID = "projectId";
             public static final String CREATION_TIME = "creationTime";


Mime
View raw message