You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/08/11 16:44:57 UTC

[1/3] airavata git commit: removing registry core and cpi dependencies from Airavata API Server

Repository: airavata
Updated Branches:
  refs/heads/develop 63696ffa1 -> b9b2480c5


http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ReplicaCatalogInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ReplicaCatalogInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ReplicaCatalogInitUtil.java
deleted file mode 100644
index 908d82d..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ReplicaCatalogInitUtil.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class ReplicaCatalogInitUtil {
-    private static final Logger logger = LoggerFactory.getLogger(ReplicaCatalogInitUtil.class);
-    public static final String REPLICA_CATALOG = "DATA_PRODUCT";
-    public static final String REPLICA_CATALOG_JDBC_DRIVER = "replicacatalog.jdbc.driver";
-    public static final String REPLICA_CATALOG_JDBC_URL = "replicacatalog.jdbc.url";
-    public static final String REPLICA_CATALOG_JDBC_USER = "replicacatalog.jdbc.user";
-    public static final String REPLICA_CATALOG_JDBC_PASSWORD = "replicacatalog.jdbc.password";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    public static void initializeDB() {
-//        System.setProperty("appcatalog.initialize.state", "0");
-        try{
-            jdbcDriver = ServerSettings.getSetting(REPLICA_CATALOG_JDBC_DRIVER);
-            jdbcURl = ServerSettings.getSetting(REPLICA_CATALOG_JDBC_URL);
-            jdbcUser = ServerSettings.getSetting(REPLICA_CATALOG_JDBC_USER);
-            jdbcPassword = ServerSettings.getSetting(REPLICA_CATALOG_JDBC_PASSWORD);
-            jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage());
-        }
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(REPLICA_CATALOG, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/replicacatalog", conn);
-                logger.info("New Database created for Replica Catalog !!! ");
-            } else {
-                logger.info("Database already created for Replica Catalog!!!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-//        System.setProperty("appcatalog.initialize.state", "1");
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-    
-    public static void stopDerbyInServerMode() {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-            if (server!=null){
-            	try {
-					server.shutdown();
-				} catch (Exception e) {
-		            logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-				}
-            }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/WorkflowCatalogInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/WorkflowCatalogInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/WorkflowCatalogInitUtil.java
deleted file mode 100644
index ea20c63..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/WorkflowCatalogInitUtil.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.app.catalog.resources.GatewayProfileResource;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class WorkflowCatalogInitUtil {
-    private static final Logger logger = LoggerFactory.getLogger(WorkflowCatalogInitUtil.class);
-    public static final String WORKFLOW = "WORKFLOW";
-    public static final String WORKFLOWCATALOG_JDBC_DRIVER = "workflowcatalog.jdbc.driver";
-    public static final String WORKFLOWCATALOG_JDBC_URL = "workflowcatalog.jdbc.url";
-    public static final String WORKFLOWCATALOG_JDBC_USER = "workflowcatalog.jdbc.user";
-    public static final String WORKFLOWCATALOG_JDBC_PASSWORD = "workflowcatalog.jdbc.password";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    public static void initializeDB() {
-//        System.setProperty("appcatalog.initialize.state", "0");
-        try{
-            jdbcDriver = ServerSettings.getSetting(WORKFLOWCATALOG_JDBC_DRIVER);
-            jdbcURl = ServerSettings.getSetting(WORKFLOWCATALOG_JDBC_URL);
-            jdbcUser = ServerSettings.getSetting(WORKFLOWCATALOG_JDBC_USER);
-            jdbcPassword = ServerSettings.getSetting(WORKFLOWCATALOG_JDBC_PASSWORD);
-            jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage());
-        }
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(WORKFLOW, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/workflowcatalog", conn);
-                logger.info("New Database created for Workflow Catalog !!! ");
-            } else {
-                logger.info("Database already created for Workflow Catalog!!!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-//        System.setProperty("appcatalog.initialize.state", "1");
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-    
-    public static void stopDerbyInServerMode() {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-            if (server!=null){
-            	try {
-					server.shutdown();
-				} catch (Exception e) {
-		            logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-				}
-            }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/AppCatInit.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/AppCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/AppCatInit.java
deleted file mode 100644
index 86cb1ba..0000000
--- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/AppCatInit.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- *
- * 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.api.server.handler.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-public class AppCatInit {
-    private static final Logger logger = LoggerFactory.getLogger(AppCatInit.class);
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    public  String scriptName = "appcatalog-derby.sql";
-    private NetworkServerControl server;
-    private static final String delimiter = ";";
-    public static final String COMPUTE_RESOURCE_TABLE = "COMPUTE_RESOURCE";
-    private String jdbcUrl = null;
-    private String jdbcDriver = null;
-    private String jdbcUser = null;
-    private String jdbcPassword = null;
-
-    public AppCatInit(String scriptName) {
-        this.scriptName = scriptName;
-    }
-
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-
-    private static boolean isServerStarted(NetworkServerControl server, int ntries)
-    {
-        for (int i = 1; i <= ntries; i ++)
-        {
-            try {
-                Thread.sleep(500);
-                server.ping();
-                return true;
-            }
-            catch (Exception e) {
-                if (i == ntries)
-                    return false;
-            }
-        }
-        return false;
-    }
-
-    public void initializeDB() {
-
-        try{
-            jdbcDriver = ServerSettings.getSetting("appcatalog.jdbc.driver");
-            jdbcUrl = ServerSettings.getSetting("appcatalog.jdbc.url");
-            jdbcUser = ServerSettings.getSetting("appcatalog.jdbc.user");
-            jdbcPassword = ServerSettings.getSetting("appcatalog.jdbc.password");
-            jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read properties", e);
-        }
-
-        startDerbyInServerMode();
-        if(!isServerStarted(server, 20)){
-           throw new RuntimeException("Derby server cound not started within five seconds...");
-        }
-//      startDerbyInEmbeddedMode();
-
-        Connection conn = null;
-        try {
-            Class.forName(jdbcDriver).newInstance();
-            conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
-            if (!isDatabaseStructureCreated(COMPUTE_RESOURCE_TABLE, conn)) {
-                executeSQLScript(conn);
-                logger.info("New Database created for App Catalog !!!");
-            } else {
-                logger.debug("Database already created for App Catalog!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            try {
-                if (conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error(e.getMessage(), e);
-            }
-        }
-    }
-
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-            System.out.println("Running a query to test the database tables existence.");
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    private void executeSQLScript(Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-        try{
-
-        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName);
-        reader = new BufferedReader(new InputStreamReader(inputStream));
-        String line;
-        while ((line = reader.readLine()) != null) {
-            line = line.trim();
-            if (line.startsWith("//")) {
-                continue;
-            }
-            if (line.startsWith("--")) {
-                continue;
-            }
-            StringTokenizer st = new StringTokenizer(line);
-            if (st.hasMoreTokens()) {
-                String token = st.nextToken();
-                if ("REM".equalsIgnoreCase(token)) {
-                    continue;
-                }
-            }
-            sql.append(" ").append(line);
-
-            // SQL defines "--" as a comment to EOL
-            // and in Oracle it may contain a hint
-            // so we cannot just remove it, instead we must end it
-            if (line.indexOf("--") >= 0) {
-                sql.append("\n");
-            }
-            if ((checkStringBufferEndsWith(sql, delimiter))) {
-                executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                sql.replace(0, sql.length(), "");
-            }
-        }
-        // Catch any statements not followed by ;
-        if (sql.length() > 0) {
-            executeSQL(sql.toString(), conn);
-        }
-        }catch (IOException e){
-            logger.error("Error occurred while executing SQL script for creating Airavata database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-        }finally {
-            if (reader != null) {
-                reader.close();
-            }
-
-        }
-
-    }
-
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            logger.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            logger.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                logger.warn(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                logger.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    logger.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    private void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    20000,
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    private void startDerbyInEmbeddedMode(){
-        try {
-            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
-            DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
-        } catch (ClassNotFoundException e) {
-            logger.error(e.getMessage(), e);
-        } catch (SQLException e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-
-    public void stopDerbyServer() {
-        try {
-            server.shutdown();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
deleted file mode 100644
index 90bbeeb..0000000
--- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- *
- * 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.api.server.handler.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.*;
-import org.apache.airavata.registry.cpi.*;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-public class ExpCatInit {
-    private static final Logger logger = LoggerFactory.getLogger(ExpCatInit.class);
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    public  String expCatScript = "expcatalog-derby.sql";
-    private NetworkServerControl server;
-    private static final String delimiter = ";";
-    public static final String PERSISTANT_DATA = "Configuration";
-
-    public ExpCatInit(String scriptName) {
-        this.expCatScript = scriptName;
-    }
-
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-
-    private static boolean isServerStarted(NetworkServerControl server, int ntries)
-    {
-        for (int i = 1; i <= ntries; i ++)
-        {
-            try {
-                Thread.sleep(500);
-                server.ping();
-                return true;
-            }
-            catch (Exception e) {
-                if (i == ntries)
-                    return false;
-            }
-        }
-        return false;
-    }
-
-    public void initializeDB() throws SQLException{
-        String jdbcUrl = null;
-        String jdbcUser = null;
-        String jdbcPassword = null;
-        try{
-            jdbcUrl = ServerSettings.getSetting("registry.jdbc.url");
-            jdbcUser = ServerSettings.getSetting("registry.jdbc.user");
-            jdbcPassword = ServerSettings.getSetting("registry.jdbc.password");
-            jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read properties", e);
-        }
-        startDerbyInServerMode();
-        if(!isServerStarted(server, 20)){
-           throw new RuntimeException("Derby server cound not started within five seconds...");
-        }
-
-        Connection conn = null;
-        try {
-            Class.forName(Utils.getJDBCDriver()).newInstance();
-            conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
-            if (!isDatabaseStructureCreated(PERSISTANT_DATA, conn)) {
-                executeSQLScript(conn);
-                logger.info("New Database created for Exp Catalog");
-            } else {
-                logger.debug("Database already created for Exp Catalog!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            try {
-                if (conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error(e.getMessage(), e);
-            }
-        }
-
-        try{
-            GatewayResource gatewayResource = new GatewayResource();
-            gatewayResource.setGatewayId(ServerSettings.getSetting("default.registry.gateway"));
-            gatewayResource.setGatewayName(ServerSettings.getSetting("default.registry.gateway"));
-            gatewayResource.setDomain("test-domain");
-            gatewayResource.setEmailAddress("test-email");
-            gatewayResource.save();
-            
-            UserResource userResource = new UserResource();
-            userResource.setUserName(ServerSettings.getSetting("default.registry.user"));
-            userResource.setPassword(ServerSettings.getSetting("default.registry.password"));
-            userResource.setGatewayId(ServerSettings.getDefaultUserGateway());
-            userResource.save();
-
-            WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
-            workerResource.setUser(userResource.getUserName());
-            workerResource.save();
-            
-            ProjectResource projectResource = (ProjectResource)workerResource.create(ResourceType.PROJECT);
-            projectResource.setGatewayId(gatewayResource.getGatewayId());
-            projectResource.setId("default");
-            projectResource.setName("default");
-            projectResource.setWorker(workerResource);
-            projectResource.save();
-        
-          
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read properties", e);
-            throw new SQLException(e.getMessage(), e);
-        } catch (RegistryException e) {
-            logger.error("Unable to save data to registry", e);
-            throw new SQLException(e.getMessage(), e);
-        }
-    }
-
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-            System.out.println("Running a query to test the database tables existence.");
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    private void executeSQLScript(Connection conn) throws Exception {
-        StringBuffer expCatsql = new StringBuffer();
-        BufferedReader expCatReader = null;
-        try{
-
-        InputStream expCatStream = this.getClass().getClassLoader().getResourceAsStream(expCatScript);
-        expCatReader = new BufferedReader(new InputStreamReader(expCatStream));
-        String line;
-        while ((line = expCatReader.readLine()) != null) {
-            line = line.trim();
-            if (line.startsWith("//")) {
-                continue;
-            }
-            if (line.startsWith("--")) {
-                continue;
-            }
-            StringTokenizer st = new StringTokenizer(line);
-            if (st.hasMoreTokens()) {
-                String token = st.nextToken();
-                if ("REM".equalsIgnoreCase(token)) {
-                    continue;
-                }
-            }
-            expCatsql.append(" ").append(line);
-
-            // SQL defines "--" as a comment to EOL
-            // and in Oracle it may contain a hint
-            // so we cannot just remove it, instead we must end it
-            if (line.indexOf("--") >= 0) {
-                expCatsql.append("\n");
-            }
-            if ((checkStringBufferEndsWith(expCatsql, delimiter))) {
-                executeSQL(expCatsql.substring(0, expCatsql.length() - delimiter.length()), conn);
-                expCatsql.replace(0, expCatsql.length(), "");
-            }
-        }
-        // Catch any statements not followed by ;
-        if (expCatsql.length() > 0) {
-            executeSQL(expCatsql.toString(), conn);
-        }
-        }catch (IOException e){
-            logger.error("Error occurred while executing SQL script for creating Airavata database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-        }finally {
-            if (expCatReader != null) {
-                expCatReader.close();
-            }
-
-        }
-
-    }
-
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            logger.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            logger.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                logger.warn(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                logger.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    logger.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    private void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName(Utils.getHost()),
-                    20000,
-                    Utils.getJDBCUser(), Utils.getJDBCPassword());
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-
-    }
-
-    public void stopDerbyServer() throws SQLException{
-        try {
-            server.shutdown();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new SQLException("Error while stopping derby server", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java
deleted file mode 100644
index 977454a..0000000
--- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *
- * 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.api.server.handler.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.replica.catalog.utils.ReplicaCatalogConstants;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-public class ReplicaCatInit {
-    private static final Logger logger = LoggerFactory.getLogger(ReplicaCatInit.class);
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    public  String scriptName = "replicacatalog-derby.sql";
-    private NetworkServerControl server;
-    private static final String delimiter = ";";
-    private String jdbcUrl = null;
-    private String jdbcDriver = null;
-    private String jdbcUser = null;
-    private String jdbcPassword = null;
-
-    public ReplicaCatInit(String scriptName) {
-        this.scriptName = scriptName;
-    }
-
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-
-    private static boolean isServerStarted(NetworkServerControl server, int ntries)
-    {
-        for (int i = 1; i <= ntries; i ++)
-        {
-            try {
-                Thread.sleep(500);
-                server.ping();
-                return true;
-            }
-            catch (Exception e) {
-                if (i == ntries)
-                    return false;
-            }
-        }
-        return false;
-    }
-
-    public void initializeDB() {
-        try{
-            jdbcDriver = ServerSettings.getSetting("replicacatalog.jdbc.driver");
-            jdbcUrl = ServerSettings.getSetting("replicacatalog.jdbc.url");
-            jdbcUser = ServerSettings.getSetting("replicacatalog.jdbc.user");
-            jdbcPassword = ServerSettings.getSetting("replicacatalog.jdbc.password");
-            jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read properties", e);
-        }
-
-        startDerbyInServerMode();
-        if(!isServerStarted(server, 20)){
-           throw new RuntimeException("Derby server could not started within five seconds...");
-        }
-        Connection conn = null;
-        try {
-            Class.forName(jdbcDriver).newInstance();
-            conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
-            if (!isDatabaseStructureCreated(ReplicaCatalogConstants.CONFIGURATION, conn)) {
-                executeSQLScript(conn);
-                logger.info("New Database created for Data Catalog !!!");
-            } else {
-                logger.debug("Database already created for Data Catalog!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            try {
-                if (conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error(e.getMessage(), e);
-            }
-        }
-    }
-
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-            System.out.println("Running a query to test the database tables existence.");
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    private void executeSQLScript(Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-        try{
-
-        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName);
-        reader = new BufferedReader(new InputStreamReader(inputStream));
-        String line;
-        while ((line = reader.readLine()) != null) {
-            line = line.trim();
-            if (line.startsWith("//")) {
-                continue;
-            }
-            if (line.startsWith("--")) {
-                continue;
-            }
-            StringTokenizer st = new StringTokenizer(line);
-            if (st.hasMoreTokens()) {
-                String token = st.nextToken();
-                if ("REM".equalsIgnoreCase(token)) {
-                    continue;
-                }
-            }
-            sql.append(" ").append(line);
-
-            // SQL defines "--" as a comment to EOL
-            // and in Oracle it may contain a hint
-            // so we cannot just remove it, instead we must end it
-            if (line.indexOf("--") >= 0) {
-                sql.append("\n");
-            }
-            if ((checkStringBufferEndsWith(sql, delimiter))) {
-                executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                sql.replace(0, sql.length(), "");
-            }
-        }
-        // Catch any statements not followed by ;
-        if (sql.length() > 0) {
-            executeSQL(sql.toString(), conn);
-        }
-        }catch (IOException e){
-            logger.error("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
-        }finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-    }
-
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            logger.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            logger.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                logger.warn(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                logger.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    logger.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    private void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    20000,
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    private void startDerbyInEmbeddedMode(){
-        try {
-            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
-            DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
-        } catch (ClassNotFoundException e) {
-            logger.error(e.getMessage(), e);
-        } catch (SQLException e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-
-    public void stopDerbyServer() {
-        try {
-            server.shutdown();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-}


[3/3] airavata git commit: Merge remote-tracking branch 'origin/develop' into develop

Posted by sc...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop


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

Branch: refs/heads/develop
Commit: b9b2480c5d68dc77d94aecca305e21604865962a
Parents: 1eb3b41 63696ff
Author: scnakandala <su...@gmail.com>
Authored: Thu Aug 11 12:44:54 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Thu Aug 11 12:44:54 2016 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |   5 +-
 .../airavata/common/utils/ServerSettings.java   |  10 -
 .../main/resources/airavata-server.properties   |   1 -
 .../org/apache/airavata/gfac/impl/Factory.java  |   9 +-
 .../airavata/gfac/server/GfacServerHandler.java |   6 +-
 .../messaging/client/RabbitMQListener.java      |   3 +-
 .../messaging/core/MessagingFactory.java        |  86 +++-
 .../airavata/messaging/core/Publisher.java      |   4 +-
 .../messaging/core/PublisherFactory.java        | 138 +++---
 .../messaging/core/RabbitMQProperties.java      | 125 ++++++
 .../airavata/messaging/core/Subscriber.java     |   5 -
 .../messaging/core/SubscriberProperties.java    | 125 ------
 .../airavata/messaging/core/TestClient.java     |   2 +-
 .../apache/airavata/messaging/core/Type.java    |  27 ++
 .../impl/RabbitMQProcessLaunchPublisher.java    | 156 +++----
 .../messaging/core/impl/RabbitMQProducer.java   | 440 +++++++++----------
 .../messaging/core/impl/RabbitMQPublisher.java  | 118 +++++
 .../core/impl/RabbitMQStatusPublisher.java      | 212 ++++-----
 .../messaging/core/impl/RabbitMQSubscriber.java |   7 +-
 .../core/impl/GFACPassiveJobSubmitter.java      |   9 +-
 .../server/OrchestratorServerHandler.java       |   6 +-
 .../ExperimentExecution.java                    |   3 +-
 .../workflow/core/WorkflowEnactmentService.java |   7 +-
 .../workflow/core/WorkflowInterpreter.java      |   8 +-
 24 files changed, 856 insertions(+), 656 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b9b2480c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------


[2/3] airavata git commit: removing registry core and cpi dependencies from Airavata API Server

Posted by sc...@apache.org.
removing registry core and cpi dependencies from Airavata API Server


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

Branch: refs/heads/develop
Commit: 1eb3b4155808dd1bfe2f08002cf49a7018e549af
Parents: 3a70c59
Author: scnakandala <su...@gmail.com>
Authored: Thu Aug 11 12:44:39 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Thu Aug 11 12:44:39 2016 -0400

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |   7 +-
 .../airavata/api/server/AiravataAPIServer.java  |  16 +-
 .../server/handler/AiravataServerHandler.java   |  35 +-
 .../DefaultAiravataSecurityManager.java         |  29 +-
 .../util/AiravataServerThreadPoolExecutor.java  |  55 ---
 .../api/server/util/AppCatalogInitUtil.java     | 168 --------
 .../api/server/util/ConnectionPool.java         | 383 -------------------
 .../server/util/CredentialStoreInitUtil.java    | 156 --------
 .../api/server/util/DataModelUtils.java         |  56 ---
 .../api/server/util/DatabaseCreator.java        | 353 -----------------
 .../server/util/ExperimentCatalogInitUtil.java  | 203 ----------
 .../airavata/api/server/util/JdbcStorage.java   | 176 ---------
 .../api/server/util/OrchestratorInitUtil.java   |  25 --
 .../api/server/util/ReplicaCatalogInitUtil.java | 160 --------
 .../server/util/WorkflowCatalogInitUtil.java    | 162 --------
 .../api/server/handler/utils/AppCatInit.java    | 320 ----------------
 .../api/server/handler/utils/ExpCatInit.java    | 330 ----------------
 .../server/handler/utils/ReplicaCatInit.java    | 315 ---------------
 18 files changed, 26 insertions(+), 2923 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml
index 2108ce0..e5b549c 100644
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@ -48,7 +48,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-registry-core</artifactId>
+            <artifactId>airavata-credential-store-stubs</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
@@ -58,11 +58,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-registry-cpi</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-orchestrator-client</artifactId>
             <version>${project.version}</version>
         </dependency>

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
index 5290e83..97a9761 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
@@ -64,17 +64,6 @@ public class AiravataAPIServer implements IServer{
 	
     public void startAiravataServer(Airavata.Processor<Airavata.Iface> airavataAPIServer) throws AiravataSystemException {
         try {
-            // creating experiment catalog db
-            ExperimentCatalogInitUtil.initializeDB();
-            // creating app catalog db
-            AppCatalogInitUtil.initializeDB();
-            // creating workflow catalog db
-            WorkflowCatalogInitUtil.initializeDB();
-            // creating credential store db
-            CredentialStoreInitUtil.initializeDB();
-			// creating replica catalog db
-			ReplicaCatalogInitUtil.initializeDB();
-
             final String serverHost = ServerSettings.getSetting(Constants.API_SERVER_HOST, null);
             if (!ServerSettings.isTLSEnabled()) {
                 final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_PORT, "8930"));
@@ -106,7 +95,6 @@ public class AiravataAPIServer implements IServer{
 				new Thread() {
 					public void run() {
                         server.serve();
-						ExperimentCatalogInitUtil.stopDerbyInServerMode();
 						setStatus(ServerStatus.STOPPED);
 						logger.info("Airavata API Server Stopped.");
 					}
@@ -142,7 +130,6 @@ public class AiravataAPIServer implements IServer{
                 new Thread() {
                     public void run() {
                         TLSServer.serve();
-                        ExperimentCatalogInitUtil.stopDerbyInServerMode();
                         setStatus(ServerStatus.STOPPED);
                         logger.info("Airavata API Server over TLS Stopped.");
                     }
@@ -172,8 +159,7 @@ public class AiravataAPIServer implements IServer{
         } catch (TTransportException e) {
             logger.error(e.getMessage());
             setStatus(ServerStatus.FAILED);
-            ExperimentCatalogInitUtil.stopDerbyInServerMode();
-			logger.error("Failed to start Gfac server ...");
+			logger.error("Failed to start API server ...");
 			throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
         } catch (ApplicationSettingsException e) {
             logger.error(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/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 68ffa97..208cd1b 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
@@ -81,8 +81,6 @@ import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client;
 import org.apache.airavata.registry.api.RegistryService;
 import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
 import org.apache.airavata.registry.api.exception.RegistryServiceException;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.*;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -913,7 +911,7 @@ public class AiravataServerHandler implements Airavata.Iface {
 
             if(!(experimentModel.getExperimentStatus().getState() == ExperimentState.CREATED)){
                 logger.error("Error while deleting the experiment");
-                throw new ExperimentCatalogException("Experiment is not in CREATED state. Hence cannot deleted. ID:"+ experimentId);
+                throw new RegistryServiceException("Experiment is not in CREATED state. Hence cannot deleted. ID:"+ experimentId);
             }
             return regClient.deleteExperiment(experimentId);
         } catch (Exception e) {
@@ -2203,17 +2201,6 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
-    private String addJobSubmissionInterface(ComputeResource computeResource,
-			String computeResourceId, String jobSubmissionInterfaceId,
-			JobSubmissionProtocol protocolType, int priorityOrder)
-			throws AppCatalogException {
-		JobSubmissionInterface jobSubmissionInterface = new JobSubmissionInterface();
-		jobSubmissionInterface.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
-		jobSubmissionInterface.setPriorityOrder(priorityOrder);
-		jobSubmissionInterface.setJobSubmissionProtocol(protocolType);
-		return computeResource.addJobSubmissionProtocol(computeResourceId,jobSubmissionInterface);
-	}
-
     /**
      * Add a SSH Job Submission details to a compute resource
      * App catalog will return a jobSubmissionInterfaceId which will be added to the jobSubmissionInterfaces.
@@ -2480,16 +2467,6 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
-    private String addDataMovementInterface(ComputeResource computeResource,
-			String computeResourceId, DMType dmType, String dataMovementInterfaceId,
-			DataMovementProtocol protocolType, int priorityOrder)
-			throws AppCatalogException {
-		DataMovementInterface dataMovementInterface = new DataMovementInterface();
-		dataMovementInterface.setDataMovementInterfaceId(dataMovementInterfaceId);
-		dataMovementInterface.setPriorityOrder(priorityOrder);
-		dataMovementInterface.setDataMovementProtocol(protocolType);
-		return computeResource.addDataMovementProtocol(computeResourceId, dmType, dataMovementInterface);
-	}
 
     /**
      * Add a SCP data moevement details to a compute resource
@@ -3554,11 +3531,10 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
-    private void initializeResourceWithGrouper(String resourceId, ResourceType resourceType) throws RegistryException, GroupManagerException {
-        ExperimentCatalog experimentCatalog = RegistryFactory.getDefaultExpCatalog();
+    private void initializeResourceWithGrouper(String resourceId, ResourceType resourceType) throws RegistryServiceException, GroupManagerException, TException, ApplicationSettingsException {
         GroupManagerCPI groupManager = GroupManagerFactory.getGroupManager();
         if(resourceType.equals(ResourceType.PROJECT)){
-            Project project = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, resourceId);
+            Project project = (Project) getRegistryServiceClient().getProject(resourceId);
 
             Resource projectResource = new Resource(project.getProjectID(), org.apache.airavata.grouper.resource.ResourceType.PROJECT);
             projectResource.setName(project.getName());
@@ -3567,7 +3543,7 @@ public class AiravataServerHandler implements Airavata.Iface {
             groupManager.createResource(projectResource);
 
         }else if(resourceType.equals(ResourceType.EXPERIMENT)){
-            ExperimentModel experiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, resourceId);
+            ExperimentModel experiment = getRegistryServiceClient().getExperiment(resourceId);
             if(!isResourceExistsInGrouper(experiment.getProjectId(), ResourceType.PROJECT)){
                 initializeResourceWithGrouper(experiment.getProjectId(), ResourceType.PROJECT);
             }
@@ -3595,7 +3571,8 @@ public class AiravataServerHandler implements Airavata.Iface {
 
     }
 
-    private boolean hasPermission(String userId, String resourceId, ResourceType resourceType, ResourcePermissionType permissionType) throws GroupManagerException, RegistryException {
+    private boolean hasPermission(String userId, String resourceId, ResourceType resourceType, ResourcePermissionType permissionType)
+            throws GroupManagerException, TException, ApplicationSettingsException {
         if(!isResourceExistsInGrouper(resourceId, resourceType)){
             initializeResourceWithGrouper(resourceId, resourceType);
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
index 90039f4..3dbab86 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
@@ -33,9 +33,9 @@ import org.apache.airavata.credential.store.datamodel.PasswordCredential;
 import org.apache.airavata.credential.store.exception.CredentialStoreException;
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.security.AuthzToken;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.AppCatalog;
-import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.api.RegistryService;
+import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
+import org.apache.airavata.registry.api.exception.RegistryServiceException;
 import org.apache.airavata.security.AiravataSecurityException;
 import org.apache.airavata.security.util.TrustStoreManager;
 import org.apache.axis2.AxisFault;
@@ -69,8 +69,7 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
                 TrustStoreManager trustStoreManager = new TrustStoreManager();
                 trustStoreManager.initializeTrustStoreManager(ServerSettings.getTrustStorePath(),
                         ServerSettings.getTrustStorePassword());
-                AppCatalog appCatalog = RegistryFactory.getAppCatalog();
-                List<GatewayResourceProfile> gwProfiles = appCatalog.getGatewayProfile().getAllGatewayProfiles();
+                List<GatewayResourceProfile> gwProfiles = getRegistryServiceClient().getAllGatewayResourceProfiles();
                 //read the policy as a string
                 BufferedReader bufferedReader = new BufferedReader(new FileReader(new File(
                         ServerSettings.getAuthorizationPoliyName() + ".xml")));
@@ -117,7 +116,7 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
         } catch (IOException e) {
             logger.error(e.getMessage(), e);
             throw new AiravataSecurityException("Error in reading the authorization policy.");
-        } catch (AppCatalogException e) {
+        } catch (RegistryServiceException e) {
             logger.error(e.getMessage(), e);
             throw new AiravataSecurityException("Error in reading the Gateway Profiles from App Catalog.");
         } catch (TException e) {
@@ -153,8 +152,7 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
                             "Obtaining it from the authorization server.");
 
                     CredentialStoreService.Client csClient = getCredentialStoreServiceClient();
-                    AppCatalog appCatalog = RegistryFactory.getAppCatalog();
-                    GatewayResourceProfile gwrp = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
+                    GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
                     PasswordCredential credential = csClient.getPasswordCredential(gwrp.getIdentityServerPwdCredToken(), gwrp.getGatewayID());
                     String username = credential.getLoginUserName();
                     if(gwrp.getIdentityServerTenant() != null && !gwrp.getIdentityServerTenant().isEmpty())
@@ -209,8 +207,7 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
                 }
             } else {
                 CredentialStoreService.Client csClient = getCredentialStoreServiceClient();
-                AppCatalog appCatalog = RegistryFactory.getAppCatalog();
-                GatewayResourceProfile gwrp = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
+                GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
                 PasswordCredential credential = csClient.getPasswordCredential(gwrp.getIdentityServerPwdCredToken(), gwrp.getGatewayID());
                 String username = credential.getLoginUserName();
                 if(gwrp.getIdentityServerTenant() != null && !gwrp.getIdentityServerTenant().isEmpty())
@@ -245,7 +242,7 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
         } catch (ApplicationSettingsException e) {
             logger.error(e.getMessage(), e);
             throw new AiravataSecurityException("Error in reading OAuth server configuration.");
-        } catch (AppCatalogException e) {
+        } catch (RegistryServiceException e) {
             logger.error(e.getMessage(), e);
             throw new AiravataSecurityException("Error in accessing AppCatalog.");
         } catch (TException e) {
@@ -263,4 +260,14 @@ public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
             throw new TException("Unable to create credential store client...", e);
         }
     }
+
+    private RegistryService.Client getRegistryServiceClient() throws TException, ApplicationSettingsException {
+        final int serverPort = Integer.parseInt(ServerSettings.getRegistryServerPort());
+        final String serverHost = ServerSettings.getRegistryServerHost();
+        try {
+            return RegistryServiceClientFactory.createRegistryClient(serverHost, serverPort);
+        } catch (RegistryServiceException e) {
+            throw new TException("Unable to create registry client...", e);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java
deleted file mode 100644
index 9f04ddb..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class AiravataServerThreadPoolExecutor {
-    private final static Logger logger = LoggerFactory.getLogger(AiravataServerThreadPoolExecutor.class);
-    public static final String AIRAVATA_SERVER_THREAD_POOL_SIZE = "airavata.server.thread.pool.size";
-
-    private static ExecutorService threadPool;
-
-    public static ExecutorService getCachedThreadPool() {
-        if(threadPool ==null){
-            threadPool = Executors.newCachedThreadPool();
-        }
-        return threadPool;
-    }
-
-    public static ExecutorService client() {
-        if(threadPool ==null){
-            try {
-                threadPool = Executors.newFixedThreadPool(Integer.parseInt(ServerSettings.getSetting(AIRAVATA_SERVER_THREAD_POOL_SIZE)));
-            } catch (ApplicationSettingsException e) {
-                logger.error("Error reading " + AIRAVATA_SERVER_THREAD_POOL_SIZE+ " property");
-            }
-        }
-        return threadPool;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AppCatalogInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AppCatalogInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AppCatalogInitUtil.java
deleted file mode 100644
index 0be8922..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AppCatalogInitUtil.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.app.catalog.resources.GatewayProfileResource;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class AppCatalogInitUtil {
-    public static final String COMPUTE_RESOURCE = "GATEWAY_PROFILE";
-    private static final Logger logger = LoggerFactory.getLogger(AppCatalogInitUtil.class);
-    public static final String APPCATALOG_JDBC_DRIVER = "appcatalog.jdbc.driver";
-    public static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url";
-    public static final String APPCATALOG_JDBC_USER = "appcatalog.jdbc.user";
-    public static final String APPCATALOG_JDBC_PASSWORD = "appcatalog.jdbc.password";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    public static void initializeDB() {
-//        System.setProperty("appcatalog.initialize.state", "0");
-        try{
-            jdbcDriver = ServerSettings.getSetting(APPCATALOG_JDBC_DRIVER);
-            jdbcURl = ServerSettings.getSetting(APPCATALOG_JDBC_URL);
-            jdbcUser = ServerSettings.getSetting(APPCATALOG_JDBC_USER);
-            jdbcPassword = ServerSettings.getSetting(APPCATALOG_JDBC_PASSWORD);
-            jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage());
-        }
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(COMPUTE_RESOURCE, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/appcatalog", conn);
-                logger.info("New Database created for App Catalog !!!");
-            } else {
-                logger.info("Database already created for App Catalog !!!");
-            }
-            GatewayProfileResource gatewayProfileResource = new GatewayProfileResource();
-            if (!gatewayProfileResource.isExists(ServerSettings.getDefaultUserGateway())){
-                gatewayProfileResource.setGatewayID(ServerSettings.getDefaultUserGateway());
-                gatewayProfileResource.setCreatedTime(AiravataUtils.getCurrentTimestamp());
-                gatewayProfileResource.save();
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-//        System.setProperty("appcatalog.initialize.state", "1");
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-    
-    public static void stopDerbyInServerMode() {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-            if (server!=null){
-            	try {
-					server.shutdown();
-				} catch (Exception e) {
-		            logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-				}
-            }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ConnectionPool.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ConnectionPool.java
deleted file mode 100644
index 5715b9d..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ConnectionPool.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- *
- * 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.api.server.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Stack;
-import java.util.concurrent.Semaphore;
-
-
-/**
- * A class for preallocating, recycling, and managing JDBC connections.
- */
-public class ConnectionPool {
-    private static final Logger logger = LoggerFactory.getLogger(ConnectionPool.class);
-
-    private long MAX_IDLE_TIME = 5 * 60 * 1000; // 5 minutes
-
-    private String driver;
-    private String url;
-    private String username;
-    private String password;
-    private String jdbcUrl;
-
-    private int maxConnections;
-
-    private boolean autoCommit = true;
-    private boolean waitIfBusy;
-
-    private Semaphore needConnection = new Semaphore(0);
-    private boolean stop;
-
-    private Stack<Connection> availableConnections;
-    private Stack<Connection> busyConnections;
-
-    private HashMap<Connection, Long> lastAccessTimeRecord = new HashMap<Connection, Long>();
-
-    private String urlType = "";
-
-    private DataSource datasource;
-
-    private int transactionIsolation = Connection.TRANSACTION_NONE;
-
-    private Thread clenupThread;
-    private Thread producerThread;
-
-    public ConnectionPool(String driver, String url, String username, String password, int initialConnections,
-                          int maxConnections, boolean waitIfBusy) throws SQLException {
-        this.driver = driver;
-        this.url = url;
-        this.username = username;
-        this.password = password;
-        this.urlType = "speratedURL";
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections,
-                          boolean waitIfBusy, boolean autoCommit, int transactionIsolation) throws SQLException {
-        this.driver = driver;
-        this.jdbcUrl = jdbcUrl;
-        this.urlType = "simpleURL";
-        this.autoCommit = autoCommit;
-        this.transactionIsolation = transactionIsolation;
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections, boolean waitIfBusy)
-            throws SQLException {
-        this.driver = driver;
-        this.jdbcUrl = jdbcUrl;
-        this.urlType = "simpleURL";
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(DataSource dataSource, int initialConnections, int maxConnections, boolean waitIfBusy)
-            throws SQLException {
-        this.urlType = "dataSource";
-        this.datasource = dataSource;
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    /**
-     * Check if this connection pool is auto commit or not
-     *
-     * @return
-     */
-    public boolean isAutoCommit() {
-        return this.autoCommit;
-    }
-
-    private void initialize(int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
-        this.maxConnections = maxConnections;
-        this.waitIfBusy = waitIfBusy;
-
-        int sizeOfConnections = (initialConnections > maxConnections) ? maxConnections : initialConnections;
-
-        availableConnections = new Stack<Connection>();
-        busyConnections = new Stack<Connection>();
-
-        for (int i = 0; i < sizeOfConnections; i++) {
-            Connection con = makeNewConnection();
-            setTimeStamp(con);
-            availableConnections.push(con);
-
-        }
-
-        producerThread = new Thread(new FillUpThread());
-        producerThread.start();
-
-        clenupThread = new Thread(new CleanUpThread());
-        clenupThread.start();
-    }
-
-    public synchronized Connection getConnection() throws SQLException {
-        if (!availableConnections.isEmpty()) {
-            Connection existingConnection = availableConnections.pop();
-
-            // If connection on available list is closed (e.g.,
-            // it timed out), then remove it from available list
-            // and race for a connection again.
-            if (existingConnection.isClosed()) {
-                lastAccessTimeRecord.remove(existingConnection);
-                // notifyAll for fairness
-                notifyAll();
-            } else {
-                busyConnections.push(existingConnection);
-                setTimeStamp(existingConnection);
-                return existingConnection;
-            }
-        } else if (!waitIfBusy && busyConnections.size() >= maxConnections) {
-            // You reached maxConnections limit and waitIfBusy flag is false.
-            // Throw SQLException in such a case.
-            throw new SQLException("Connection limit reached");
-        } else {
-
-            if (busyConnections.size() < maxConnections) {
-                // available connection is empty, but total number of connection
-                // doesn't reach maxConnection. Request for more connection
-                needConnection.release();
-            }
-
-            try {
-                // wait for free connection
-                wait();
-            } catch (InterruptedException ie) {
-            }
-        }
-        // always race for connection forever
-        return getConnection();
-    }
-
-    // This explicitly makes a new connection. Called in
-    // the foreground when initializing the ConnectionPool,
-    // and called in the background when running.
-    private Connection makeNewConnection() throws SQLException {
-        try {
-            // Load database driver if not already loaded
-            Class.forName(driver);
-            Connection connection;
-            // Establish network connection to database
-            if (urlType.equals("speratedURL")) {
-                connection = DriverManager.getConnection(url, username, password);
-            } else if (urlType.equals("simpleURL")) {
-                connection = DriverManager.getConnection(jdbcUrl);
-            } else { // if(urlType.equals("dataSource")){
-                connection = datasource.getConnection();
-            }
-            connection.setTransactionIsolation(this.transactionIsolation);
-            connection.setAutoCommit(this.autoCommit);
-            return connection;
-        } catch (ClassNotFoundException cnfe) {
-            // Simplify try/catch blocks of people using this by
-            // throwing only one exception type.
-            throw new SQLException("Can't find class for driver: " + driver);
-        }
-    }
-
-    private synchronized void fillUpConnection(Connection conn) {
-        setTimeStamp(conn);
-        availableConnections.push(conn);
-
-        // notify all since new connection is created
-        notifyAll();
-    }
-
-    private void setTimeStamp(Connection connection) {
-        lastAccessTimeRecord.put(connection, System.currentTimeMillis());
-    }
-
-    // The database connection cannot be left idle for too long, otherwise TCP
-    // connection will be broken.
-    /**
-     * From http://forums.mysql.com/read.php?39,28450,57460#msg-57460 Okay, then it looks like wait_timeout on the
-     * server is killing your connection (it is set to 8 hours of idle time by default). Either set that value higher on
-     * your server, or configure your connection pool to not hold connections idle that long (I prefer the latter). Most
-     * folks I know that run MySQL with a connection pool in high-load production environments only let connections sit
-     * idle for a matter of minutes, since it only takes a few milliseconds to open a connection, and the longer one
-     * sits idle the more chance it will go "bad" because of a network hiccup or the MySQL server being restarted.
-     *
-     * @throws java.sql.SQLException
-     */
-    private boolean isConnectionStale(Connection connection) {
-        long currentTime = System.currentTimeMillis();
-        long lastAccess = lastAccessTimeRecord.get(connection);
-        if (currentTime - lastAccess > MAX_IDLE_TIME) {
-            return true;
-        } else
-            return false;
-    }
-
-    private synchronized void closeStaleConnections() {
-        // close idle connections
-        Iterator<Connection> iter = availableConnections.iterator();
-        while (iter.hasNext()) {
-            Connection existingConnection = iter.next();
-            if (isConnectionStale(existingConnection)) {
-                try {
-                    existingConnection.close();
-                    iter.remove();
-                } catch (SQLException sql) {
-                    logger.error(sql.getMessage(), sql);
-                }
-            }
-        }
-        // close busy connections that have been checked out for too long.
-        // This should not happen since this means program has bug for not
-        // releasing connections .
-        iter = busyConnections.iterator();
-        while (iter.hasNext()) {
-            Connection busyConnection = iter.next();
-            if (isConnectionStale(busyConnection)) {
-                try {
-                    busyConnection.close();
-                    iter.remove();
-                    logger.warn("****Connection has checked out too long. Forced release. Check the program for calling release connection [free(Connection) method]");
-                } catch (SQLException sql) {
-                    logger.error(sql.getMessage(), sql);
-                }
-            }
-        }
-    }
-
-    public synchronized void free(Connection connection) {
-        busyConnections.removeElement(connection);
-        availableConnections.addElement(connection);
-        // Wake up threads that are waiting for a connection
-        notifyAll();
-    }
-
-    /**
-     * Close all the connections. Use with caution: be sure no connections are in use before calling. Note that you are
-     * not <I>required</I> to call this when done with a ConnectionPool, since connections are guaranteed to be closed
-     * when garbage collected. But this method gives more control regarding when the connections are closed.
-     */
-    public synchronized void dispose() {
-        logger.info("Connection Pool Shutting down");
-
-        // stop clean up thread
-        this.stop = true;
-        this.clenupThread.interrupt();
-
-        // stop producer up thread
-        this.producerThread.interrupt();
-
-        // close all connection
-        closeConnections(availableConnections);
-        availableConnections = new Stack<Connection>();
-        closeConnections(busyConnections);
-        busyConnections = new Stack<Connection>();
-        lastAccessTimeRecord.clear();
-
-        logger.info("All connection is closed");
-
-        try {
-            this.clenupThread.join();
-            this.producerThread.join();
-        } catch (Exception e) {
-            logger.error("Cannot shutdown cleanup thread", e);
-        }
-
-        logger.info("Connection Pool Shutdown");
-    }
-
-    private void closeConnections(Stack<Connection> connections) {
-        while (!connections.isEmpty()) {
-            Connection connection = connections.pop();
-            try {
-                if (!connection.isClosed()) {
-                    connection.close();
-                }
-            } catch (SQLException sqle) {
-                // Ignore errors; garbage collect anyhow
-                logger.warn(sqle.getMessage());
-            }
-        }
-    }
-
-    public synchronized String toString() {
-        String info = "ConnectionPool(" + url + "," + username + ")" + ", available=" + availableConnections.size()
-                + ", busy=" + busyConnections.size() + ", max=" + maxConnections;
-        return (info);
-    }
-
-    class CleanUpThread implements Runnable {
-        public void run() {
-            while (!stop) {
-                try {
-                    Thread.sleep(MAX_IDLE_TIME);
-                    closeStaleConnections();
-                } catch (InterruptedException e) {
-                    logger.info("Clean up thread is interrupted to close");
-                }
-            }
-        }
-    }
-
-    class FillUpThread implements Runnable {
-        public void run() {
-            while (!stop) {
-                try {
-                    // block until get
-                    needConnection.acquire();
-
-                    Connection conn = makeNewConnection();
-                    fillUpConnection(conn);
-                } catch (SQLException e) {
-                    // cannot create connection (increase semaphore value back)
-                    needConnection.release();
-                    logger.error(e.getMessage(), e);
-                } catch (InterruptedException e) {
-                    logger.info("Fill up thread is interrupted to close");
-                    break;
-                }
-            }
-        }
-    }
-
-    public void shutdown() throws SQLException{
-        for (Connection c : availableConnections) {
-            try {
-                c.close();
-            } catch (SQLException e) {
-                logger.error("Error while closing the connection", e);
-                throw new SQLException("Error while closing the connection", e);
-            }
-        }
-
-        for (Connection c : busyConnections) {
-            try {
-                c.close();
-            } catch (SQLException e) {
-                logger.error("Error while closing the connection", e);
-                throw new SQLException("Error while closing the connection", e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/CredentialStoreInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/CredentialStoreInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/CredentialStoreInitUtil.java
deleted file mode 100644
index 20dd1aa..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/CredentialStoreInitUtil.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class CredentialStoreInitUtil {
-    private static final Logger logger = LoggerFactory.getLogger(CredentialStoreInitUtil.class);
-    public static final String CREDENTIALS = "CREDENTIALS";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    public static void initializeDB() {
-//        System.setProperty("appcatalog.initialize.state", "0");
-        try{
-            jdbcDriver = ServerSettings.getCredentialStoreDBDriver();
-            jdbcURl = ServerSettings.getCredentialStoreDBURL();
-            jdbcUser = ServerSettings.getCredentialStoreDBUser();
-            jdbcPassword = ServerSettings.getCredentialStoreDBPassword();
-            jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage());
-        }
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(CREDENTIALS, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/credstore", conn);
-                logger.info("New Database created for Credential Store !!! ");
-            } else {
-                logger.info("Database already created for Credential Store !!!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-//        System.setProperty("appcatalog.initialize.state", "1");
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-    
-    public static void stopDerbyInServerMode() {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-            if (server!=null){
-            	try {
-					server.shutdown();
-				} catch (Exception e) {
-		            logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-				}
-            }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java
deleted file mode 100644
index d3d410f..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * 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.api.server.util;
-
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.apache.airavata.registry.cpi.ApplicationInterface;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.model.util.ExecutionType;
-import org.apache.airavata.model.experiment.ExperimentModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class DataModelUtils {
-    private static final Logger logger = LoggerFactory.getLogger(DataModelUtils.class);
-	public static ExecutionType getExecutionType(ExperimentModel experiment) throws Exception{
-		try {
-			ApplicationInterface applicationInterface = RegistryFactory.getAppCatalog().getApplicationInterface();
-			List<String> allApplicationInterfaceIds = applicationInterface.getAllApplicationInterfaceIds();
-			String applicationId = experiment.getExecutionId();
-			if (allApplicationInterfaceIds.contains(applicationId)){
-				return ExecutionType.SINGLE_APP;
-			} else {
-				List<String> allWorkflows = RegistryFactory.getAppCatalog().getWorkflowCatalog().getAllWorkflows(ServerSettings.getDefaultUserGateway());
-				if (allWorkflows.contains(applicationId)){
-					return ExecutionType.WORKFLOW;
-				}
-			}
-		} catch (AppCatalogException e) {
-            logger.error("Error while retrieving execution type for experiment : " + experiment.getExperimentId(), e);
-            throw new Exception("Error while retrieving execution type for experiment : " + experiment.getExperimentId(), e);
-		}
-		return ExecutionType.UNKNOWN;
-	}
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
deleted file mode 100644
index f52d5d8..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- *
- * 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.api.server.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-/**
- * This class creates the database tables required for airavata with default configuration this
- * class creates derby database in server mode. User can specify required database in appropriate
- * properties files.
- */
-public class DatabaseCreator {
-    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
-
-    public enum DatabaseType {
-        derby("(?i).*derby.*"), mysql("(?i).*mysql.*"), other("");
-
-        private String pattern;
-
-        private DatabaseType(String matchingPattern) {
-            this.pattern = matchingPattern;
-        }
-
-        public String getMatchingPattern() {
-            return this.pattern;
-        }
-    }
-
-    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
-
-    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
-    private static final String delimiter = ";";
-
-    /**
-     * Creates database
-     *
-     * @throws Exception
-     */
-    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
-        createDatabase(prefix, conn);
-    }
-
-
-
-    /**
-     * Checks whether database tables are created by using select * on given table name
-     *
-     * @param tableName
-     *            Table which should be existed
-     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
-     */
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-
-            log.debug("Running a query to test the database tables existence.");
-
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * executes given sql
-     *
-     * @param sql
-     * @throws Exception
-     */
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            log.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            log.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                log.info(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                log.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    log.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    /**
-     * computes relatational database type using database name
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
-        try {
-            if (conn != null && (!conn.isClosed())) {
-                DatabaseMetaData metaData = conn.getMetaData();
-                String databaseProductName = metaData.getDatabaseProductName();
-                return checkType(databaseProductName);
-            }
-        } catch (SQLException e) {
-            String msg = "Failed to create Airavata database." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        return DatabaseType.other;
-    }
-
-    /**
-     * Overloaded method with String input
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
-        return checkType(dbUrl);
-    }
-
-    private static DatabaseType checkType(String text) throws Exception {
-        try {
-            if (text != null) {
-                for (DatabaseType type : supportedDatabase) {
-                    if (text.matches(type.getMatchingPattern()))
-                        return type;
-                }
-            }
-            String msg = "Unsupported database: " + text
-                    + ". Database will not be created automatically by the Airavata. "
-                    + "Please create the database using appropriate database scripts for " + "the database.";
-            throw new Exception(msg);
-
-        } catch (SQLException e) {
-            String msg = "Failed to create Airavatadatabase." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-
-    /**
-     * Get scripts location which is prefix + "-" + databaseType + ".sql"
-     *
-     * @param prefix
-     * @param databaseType
-     * @return script location
-     */
-    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
-        String scriptName = prefix + "-" + databaseType + ".sql";
-        log.debug("Loading database script from :" + scriptName);
-        return  scriptName;
-    }
-
-    private static void createDatabase(String prefix, Connection conn) throws Exception {
-        Statement statement = null;
-        try {
-            conn.setAutoCommit(false);
-            statement = conn.createStatement();
-            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
-            conn.commit();
-            log.debug("Tables are created successfully.");
-        } catch (SQLException e) {
-            String msg = "Failed to create database tables for Airavata resource store. " + e.getMessage();
-            log.error(msg, e);
-            conn.rollback();
-            throw new Exception(msg, e);
-        } finally {
-            conn.setAutoCommit(true);
-            try {
-                if (statement != null) {
-                    statement.close();
-                }
-            } catch (SQLException e) {
-                log.error("Failed to close statement.", e);
-            }
-        }
-    }
-
-    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-
-        try {
-            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
-            if(is == null) {
-                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
-                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
-                if(databaseType.equals(DatabaseType.derby)){
-                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-derby.sql");
-                }else if(databaseType.equals(DatabaseType.mysql)){
-                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-mysql.sql");
-                }
-            }
-            reader = new BufferedReader(new InputStreamReader(is));
-            String line;
-            while ((line = reader.readLine()) != null) {
-                line = line.trim();
-                if (line.startsWith("//")) {
-                    continue;
-                }
-                if (line.startsWith("--")) {
-                    continue;
-                }
-                StringTokenizer st = new StringTokenizer(line);
-                if (st.hasMoreTokens()) {
-                    String token = st.nextToken();
-                    if ("REM".equalsIgnoreCase(token)) {
-                        continue;
-                    }
-                }
-                sql.append(" ").append(line);
-
-                // SQL defines "--" as a comment to EOL
-                // and in Oracle it may contain a hint
-                // so we cannot just remove it, instead we must end it
-                if (line.indexOf("--") >= 0) {
-                    sql.append("\n");
-                }
-                if ((checkStringBufferEndsWith(sql, delimiter))) {
-                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                    sql.replace(0, sql.length(), "");
-                }
-            }
-            // Catch any statements not followed by ;
-            if (sql.length() > 0) {
-                executeSQL(sql.toString(), conn);
-            }
-        } catch (IOException e) {
-            log.error("Error occurred while executing SQL script for creating Airavata database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-    }
-
-    /**
-     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
-     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
-     * massive memory allocation and copying. See
-     *
-     * @param buffer
-     *            the buffer to perform the check on
-     * @param suffix
-     *            the suffix
-     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
-     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
-     *         be <code>true</code> if the argument is the empty string.
-     */
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ExperimentCatalogInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ExperimentCatalogInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ExperimentCatalogInitUtil.java
deleted file mode 100644
index 5e68c40..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/ExperimentCatalogInitUtil.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*
-* 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.api.server.util;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.UserResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerResource;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExperimentCatalogInitUtil {
-    public static final String CONFIGURATION_TABLE = "CONFIGURATION";
-    private static final Logger logger = LoggerFactory.getLogger(ExperimentCatalogInitUtil.class);
-    public static final String REGISTRY_JDBC_DRIVER = "registry.jdbc.driver";
-    public static final String REGISTRY_JDBC_URL = "registry.jdbc.url";
-    public static final String REGISTRY_JDBC_USER = "registry.jdbc.user";
-    public static final String REGISTRY_JDBC_PASSWORD = "registry.jdbc.password";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    public static final String DEFAULT_PROJECT_NAME = "default";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    public static void initializeDB() {
-        System.setProperty("registry.initialize.state", "0");
-        try{
-            jdbcDriver = ServerSettings.getSetting(REGISTRY_JDBC_DRIVER);
-            jdbcURl = ServerSettings.getSetting(REGISTRY_JDBC_URL);
-            jdbcUser = ServerSettings.getSetting(REGISTRY_JDBC_USER);
-            jdbcPassword = ServerSettings.getSetting(REGISTRY_JDBC_PASSWORD);
-            jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage());
-        }
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(CONFIGURATION_TABLE, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/expcatalog", conn);
-                logger.info("New Database created for Experiment Catalog !!!");
-            } else {
-                logger.info("Database already created for Experiment Catalog !!!");
-            }
-            try{
-                GatewayResource gateway;
-                if (!ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){
-                    gateway = (GatewayResource)ExpCatResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
-                    gateway.save();
-                }else {
-                    gateway = (GatewayResource)ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
-                }
-
-                UserResource user;
-                if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway())){
-                    user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword(), ServerSettings.getDefaultUserGateway());
-                    user.save();
-                }else {
-                    user = (UserResource)ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway());
-                }
-
-                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.setGatewayId(gateway.getGatewayId());
-                    projectResource.save();
-                }
-
-            } catch (ApplicationSettingsException e) {
-                logger.error("Unable to read airavata-server properties...", e.getMessage());
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-        System.setProperty("registry.initialize.state", "1");
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-    
-    public static void stopDerbyInServerMode() {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-            if (server!=null){
-            	try {
-					server.shutdown();
-				} catch (Exception e) {
-		            logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-				}
-            }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/JdbcStorage.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/JdbcStorage.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/JdbcStorage.java
deleted file mode 100644
index 37320a3..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/JdbcStorage.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- *
- * 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.api.server.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.*;
-
-public class JdbcStorage {
-    private static Logger log = LoggerFactory.getLogger(JdbcStorage.class);
-
-    private ConnectionPool connectionPool;
-
-    public JdbcStorage(String jdbcUrl, String jdbcDriver) {
-        // default init connection and max connection
-        this(3, 50, jdbcUrl, jdbcDriver, true);
-    }
-
-    public JdbcStorage(int initCon, int maxCon, String url, String driver, boolean enableTransactions) {
-        try {
-            if (enableTransactions) {
-                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true, false,
-                        Connection.TRANSACTION_SERIALIZABLE);
-            } else {
-                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true);
-            }
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to create database connection pool.", e);
-        }
-    }
-
-    /**
-     * Check if this connection pool is auto commit or not
-     *
-     * @return
-     */
-    public boolean isAutoCommit() {
-        return connectionPool.isAutoCommit();
-    }
-
-    public void commit(Connection conn) {
-        try {
-            if (conn != null && !conn.getAutoCommit()) {
-                conn.commit();
-            }
-        } catch (SQLException sqle) {
-            log.error("Cannot commit data", sqle);
-        }
-    }
-
-    public void commitAndFree(Connection conn) {
-        commit(conn);
-        closeConnection(conn);
-    }
-
-    public void rollback(Connection conn) {
-        try {
-            if (conn != null && !conn.getAutoCommit()) {
-                conn.rollback();
-            }
-        } catch (SQLException sqle) {
-            log.error("Cannot Rollback data", sqle);
-        }
-    }
-
-    public void rollbackAndFree(Connection conn) {
-        rollback(conn);
-        closeConnection(conn);
-    }
-
-    public Connection connect() {
-
-        Connection conn = null;
-        try {
-            conn = connectionPool.getConnection();
-        } catch (SQLException e) {
-            log.error(e.getMessage(), e);
-        }
-        return conn;
-    }
-
-    /**
-     * This method is provided so that you can have better control over the statement. For example: You can use
-     * stmt.setString to convert quotation mark automatically in an UPDATE statement
-     *
-     * NOTE: Statement is closed after execution
-     */
-    public int executeUpdateAndClose(PreparedStatement stmt) throws SQLException {
-        int rows = 0;
-        try {
-            rows = stmt.executeUpdate();
-            if (rows == 0) {
-                log.info("Problem: 0 rows affected by insert/update/delete statement.");
-            }
-        } finally {
-            stmt.close();
-        }
-        return rows;
-    }
-
-    public int countRow(String tableName, String columnName) throws SQLException {
-        String query = new String("SELECT COUNT(" + columnName + ") FROM " + tableName);
-        int count = -1;
-        Connection conn = null;
-        PreparedStatement stmt = null;
-        try {
-            conn = connectionPool.getConnection();
-            stmt = conn.prepareStatement(query);
-            ResultSet rs = stmt.executeQuery();
-            rs.next();
-            count = rs.getInt(1);
-            commit(conn);
-        } catch (SQLException sql) {
-            rollback(conn);
-            throw sql;
-        } finally {
-            try {
-                if (stmt != null && !stmt.isClosed()) {
-                    stmt.close();
-                }
-            } finally {
-                closeConnection(conn);
-            }
-        }
-        return count;
-    }
-
-    public void quietlyClose(Connection conn, Statement... stmts) {
-        if (stmts != null) {
-            for (Statement stmt : stmts) {
-                try {
-                    if (stmt != null && !stmt.isClosed()) {
-                        stmt.close();
-                    }
-                } catch (SQLException sql) {
-                    log.error(sql.getMessage(), sql);
-                }
-            }
-        }
-        closeConnection(conn);
-    }
-
-    public void closeConnection(Connection conn) {
-        if (conn != null) {
-            connectionPool.free(conn);
-        }
-    }
-
-    public void closeAllConnections() {
-        if (connectionPool != null)
-            connectionPool.dispose();
-    }
-
-    public void shutdown() throws SQLException {
-        connectionPool.shutdown();
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1eb3b415/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/OrchestratorInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/OrchestratorInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/OrchestratorInitUtil.java
deleted file mode 100644
index 5add438..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/OrchestratorInitUtil.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * 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.api.server.util;
-
-public class OrchestratorInitUtil {
-}