airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [1/3] airavata git commit: insert only if the default gateway and user does not exist
Date Thu, 19 Mar 2015 19:58:50 GMT
Repository: airavata
Updated Branches:
  refs/heads/new-workflow-design 0db33d2e5 -> d3f67fd85


insert only if the default gateway and user does not exist


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

Branch: refs/heads/new-workflow-design
Commit: c05d5e6c8df0a243fa240074f650b0d7800cfe69
Parents: 73f371d
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Thu Mar 19 15:34:05 2015 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Thu Mar 19 15:34:05 2015 -0400

----------------------------------------------------------------------
 .../api/server/util/RegistryInitUtil.java       | 43 +++++++++++++++-----
 1 file changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c05d5e6c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
index 6de38f4..2e610c5 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
@@ -84,17 +84,38 @@ public class RegistryInitUtil {
                 logger.info("Database already created for Registry!");
             }
             try{
-                GatewayResource gateway = (GatewayResource)ResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
-                gateway.save();
-                UserResource user = ResourceUtils.createUser(ServerSettings.getDefaultUser(),
ServerSettings.getDefaultUserPassword());
-                user.save();
-                WorkerResource workerResource = (WorkerResource)gateway.create(ResourceType.GATEWAY_WORKER);
-                workerResource.setUser(user.getUserName());
-                workerResource.save();
-                ProjectResource projectResource = workerResource.createProject(DEFAULT_PROJECT_NAME);
-                projectResource.setName(DEFAULT_PROJECT_NAME);
-                projectResource.setGateway(gateway);
-                projectResource.save();
+                GatewayResource gateway;
+                if (!ResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){
+                    gateway = (GatewayResource)ResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
+                    gateway.save();
+                }else {
+                    gateway = (GatewayResource)ResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+                }
+
+                UserResource user;
+                if (!ResourceUtils.isUserExist(ServerSettings.getDefaultUser())){
+                    user = ResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword());
+                    user.save();
+                }else {
+                    user = (UserResource)ResourceUtils.getUser(ServerSettings.getDefaultUser());
+                }
+
+                WorkerResource workerResource;
+                if (!gateway.isExists(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUserGateway())){
+                    workerResource = (WorkerResource)gateway.create(ResourceType.GATEWAY_WORKER);
+                    workerResource.setUser(user.getUserName());
+                    workerResource.save();
+                }else {
+                    workerResource =  (WorkerResource)gateway.get(ResourceType.GATEWAY_WORKER,
ServerSettings.getDefaultUser());
+                }
+                ProjectResource projectResource;
+                if (!workerResource.isExists(ResourceType.PROJECT, DEFAULT_PROJECT_NAME)){
+                    projectResource = workerResource.createProject(DEFAULT_PROJECT_NAME);
+                    projectResource.setName(DEFAULT_PROJECT_NAME);
+                    projectResource.setGateway(gateway);
+                    projectResource.save();
+                }
+
             } catch (ApplicationSettingsException e) {
                 logger.error("Unable to read airavata-server properties...", e.getMessage());
             }


Mime
View raw message