You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2014/04/14 20:30:45 UTC
[43/90] [abbrv] [partial] AIRAVATA-1124
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/registry/airavata-registry-test/src/test/java/org/apache/airavata/registry/api/test/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-registry-test/src/test/java/org/apache/airavata/registry/api/test/util/Initialize.java b/modules/registry/airavata-registry-test/src/test/java/org/apache/airavata/registry/api/test/util/Initialize.java
deleted file mode 100644
index 9a0a0ce..0000000
--- a/modules/registry/airavata-registry-test/src/test/java/org/apache/airavata/registry/api/test/util/Initialize.java
+++ /dev/null
@@ -1,296 +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.registry.api.test.util;
-
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.resources.*;
-import org.apache.airavata.registry.api.exception.RegistrySettingsException;
-import org.apache.airavata.registry.api.util.RegistrySettings;
-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;
-
-public class Initialize {
- private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
- private static final String delimiter = ";";
- public static final String PERSISTANT_DATA = "Configuration";
-
- 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;
- }
-
- public void initializeDB() {
- String jdbcUrl = null;
- String jdbcDriver = null;
- String jdbcUser = null;
- String jdbcPassword = null;
- try{
- jdbcDriver = RegistrySettings.getSetting("registry.jdbc.driver");
- jdbcUrl = RegistrySettings.getSetting("registry.jdbc.url");
- jdbcUser = RegistrySettings.getSetting("registry.jdbc.user");
- jdbcPassword = RegistrySettings.getSetting("registry.jdbc.password");
- jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
- } catch (RegistrySettingsException e) {
- logger.error("Unable to read properties" , e);
- }
-
-
- startDerbyInServerMode();
-// startDerbyInEmbeddedMode();
-
- 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 Registry");
- } else {
- logger.debug("Database already created for Registry!");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RuntimeException("Database failure");
- } finally {
- try {
- if (!conn.getAutoCommit()) {
- conn.commit();
- }
- conn.close();
- } catch (SQLException e) {
- logger.error(e.getMessage(), e);
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- try{
- GatewayResource gatewayResource = new GatewayResource();
- gatewayResource.setGatewayName(RegistrySettings.getSetting("default.registry.gateway"));
- gatewayResource.setOwner(RegistrySettings.getSetting("default.registry.gateway"));
- gatewayResource.save();
-
- UserResource userResource = (UserResource) gatewayResource.create(ResourceType.USER);
- userResource.setUserName(RegistrySettings.getSetting("default.registry.user"));
- userResource.setPassword(RegistrySettings.getSetting("default.registry.password"));
- userResource.save();
-
- WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
- workerResource.setUser(userResource.getUserName());
- workerResource.save();
-
- ProjectResource projectResource = workerResource.createProject("default");
- projectResource.setGateway(gatewayResource);
- projectResource.save();
- } catch (RegistrySettingsException e) {
- logger.error("Unable to read properties", 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("registry-derby.sql");
- 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 {
- DerbyUtil.startDerbyInServerMode(Utils.getHost(), 20000, Utils.getJDBCUser(), Utils.getJDBCUser());
- } catch (Exception e) {
- logger.error("Unable to start Apache derby in the server mode! Check whether " +
- "specified port is available", e);
- }
-
- }
-
- private void startDerbyInEmbeddedMode(){
- try {
- DerbyUtil.startDerbyInEmbeddedMode();
- } catch (Exception e) {
- logger.error("Error occurred while starting Derby in embedded mode", e);
- }
- }
-
- public void stopDerbyServer() {
- try {
- DerbyUtil.stopDerbyServer();
- } catch (Exception e) {
- logger.error("Error occurred while stopping Derby", e);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/registry/airavata-registry-test/src/test/resources/registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-registry-test/src/test/resources/registry-derby.sql b/modules/registry/airavata-registry-test/src/test/resources/registry-derby.sql
deleted file mode 100644
index 7b8fb39..0000000
--- a/modules/registry/airavata-registry-test/src/test/resources/registry-derby.sql
+++ /dev/null
@@ -1,380 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PROJECT_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE HOST_DESCRIPTOR
-(
- GATEWAY_NAME VARCHAR(255),
- UPDATED_USER VARCHAR(255),
- HOST_DESCRIPTOR_ID VARCHAR(255),
- HOST_DESCRIPTOR_XML BLOB,
- PRIMARY KEY(GATEWAY_NAME, HOST_DESCRIPTOR_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (UPDATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE SERVICE_DESCRIPTOR
-(
- GATEWAY_NAME VARCHAR(255),
- UPDATED_USER VARCHAR(255),
- SERVICE_DESCRIPTOR_ID VARCHAR(255),
- SERVICE_DESCRIPTOR_XML BLOB,
- PRIMARY KEY(GATEWAY_NAME,SERVICE_DESCRIPTOR_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (UPDATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_DESCRIPTOR
-(
- GATEWAY_NAME VARCHAR(255),
- UPDATED_USER VARCHAR(255),
- APPLICATION_DESCRIPTOR_ID VARCHAR(255),
- HOST_DESCRIPTOR_ID VARCHAR(255),
- SERVICE_DESCRIPTOR_ID VARCHAR(255),
- APPLICATION_DESCRIPTOR_XML BLOB,
- PRIMARY KEY(GATEWAY_NAME,APPLICATION_DESCRIPTOR_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (UPDATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255),
- PROJECT_NAME VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255),
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_NAME) REFERENCES PROJECT(PROJECT_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255),
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255),
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255),
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255),
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255),
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255),
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC VARCHAR(255),
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/registry/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/pom.xml b/modules/registry/pom.xml
index 6c52e41..02c1603 100644
--- a/modules/registry/pom.xml
+++ b/modules/registry/pom.xml
@@ -33,8 +33,6 @@
<module>registry-api</module>
<module>registry-cpi</module>
<module>airavata-jpa-registry</module>
- <module>airavata-registry-service</module>
- <!--<module>airavata-registry-test</module>-->
</modules>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest/client/pom.xml b/modules/rest/client/pom.xml
deleted file mode 100644
index 38056a9..0000000
--- a/modules/rest/client/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--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. -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.apache.airavata</groupId>
- <artifactId>rest</artifactId>
- <version>0.12-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>airavata-rest-client</artifactId>
- <packaging>jar</packaging>
- <name>airavata-rest-client</name>
- <dependencies>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>${jersey.version}</version>
- </dependency>
-
- <!-- Airavata -->
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-gfac-schema-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-registry-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-rest-mappings</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- </dependencies>
-
- <properties>
- <jersey.version>1.13</jersey.version>
- <org.slf4j.version>1.6.1</org.slf4j.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <javaagent />
- </properties>
-</project>
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
----------------------------------------------------------------------
diff --git a/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java b/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
deleted file mode 100644
index 0d9b6b1..0000000
--- a/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
+++ /dev/null
@@ -1,542 +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.rest;
-
-
-import org.apache.airavata.rest.client.*;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-public class Test {
- public static void main(String[] args) {
-// configurationResourceClientTest();
-// hostDescriptorClientTest();
-// serviceDescriptorClientTest();
-// appDescriptorClientTest();
-// projectRegistryClientTest();
-// experimentRegistryClient();
-// userWFClientTest();
-// publishWFClientTest();
-// provenanceClientTest();
- }
-
-
- public static void configurationResourceClientTest(){
- //configuration resource test
-// ConfigurationResourceClient configurationResourceClient = new ConfigurationResourceClient("admin",
-// "http://localhost:8080/airavata-registry/", new PasswordCallbackImpl("admin", "admin"));
-
-// System.out.println("###############getConfiguration###############");
-// Object configuration = configurationResourceClient.getConfiguration("gfac.url");
-// System.out.println(configuration.toString());
-
-
-// System.out.println("###############getConfiguration###############");
-// Object configuration = configurationResourceClient.getConfiguration("key3");
-// System.out.println(configuration.toString());
-//
-// System.out.println("###############getConfigurationList###############");
-// try {
-// configurationResourceClient.addWFInterpreterURI(new URI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor2"));
-// } catch (URISyntaxException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-// List<Object> configurationList = configurationResourceClient.getConfigurationList("testKey1");
-// for(Object object : configurationList){
-// System.out.println(object.toString());
-// }
-//
-// System.out.println("###############setConfiguration###############");
-// configurationResourceClient.setConfiguration("testKey1", "testVal1", "2012-11-12 00:12:31");
-//
-// System.out.println("###############addConfiguration###############");
-// configurationResourceClient.addConfiguration("testKey1", "testVal2", "2012-11-12 05:12:31");
-
-// System.out.println("###############remove all configuration ###############");
-// configurationResourceClient.removeAllConfiguration("testKey1");
-//
-// System.out.println("###############remove configuration ###############");
-// configurationResourceClient.setConfiguration("testKey2", "testVal2", "2012-11-12 00:12:31");
-// configurationResourceClient.removeAllConfiguration("testKey2");
-//
-// System.out.println("###############get GFAC URI ###############");
-// configurationResourceClient.addGFacURI("http://192.168.17.1:8080/axis2/services/GFacService2");
-// List<URI> gFacURIs = configurationResourceClient.getGFacURIs();
-// for (URI uri : gFacURIs){
-// System.out.println(uri.toString());
-// }
-
-// System.out.println("###############get WF interpreter URIs ###############");
-// List<URI> workflowInterpreterURIs = configurationResourceClient.getWorkflowInterpreterURIs();
-// for (URI uri : workflowInterpreterURIs){
-// System.out.println(uri.toString());
-// }
-//
-// System.out.println("###############get eventing URI ###############");
-// URI eventingURI = configurationResourceClient.getEventingURI();
-// System.out.println(eventingURI.toString());
-//
-// System.out.println("###############get message Box URI ###############");
-// URI mesgBoxUri = configurationResourceClient.getMsgBoxURI();
-// System.out.println(mesgBoxUri.toString());
-//
-// System.out.println("###############Set eventing URI ###############");
-// configurationResourceClient.setEventingURI("http://192.168.17.1:8080/axis2/services/EventingService2");
-//
-// System.out.println("###############Set MSGBox URI ###############");
-// configurationResourceClient.setEventingURI("http://192.168.17.1:8080/axis2/services/MsgBoxService2");
-//
-// System.out.println("###############Add GFAC URI by date ###############");
-// configurationResourceClient.addGFacURIByDate("http://192.168.17.1:8080/axis2/services/GFacService3", "2012-11-12 00:12:27");
-//
-// System.out.println("###############Add WF interpreter URI by date ###############");
-// configurationResourceClient.addWorkflowInterpreterURI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor3", "2012-11-12 00:12:27");
-
-// System.out.println("###############Set eventing URI by date ###############");
-// configurationResourceClient.setEventingURIByDate("http://192.168.17.1:8080/axis2/services/EventingService3", "2012-11-12 00:12:27");
-//
-// System.out.println("###############Set MsgBox URI by date ###############");
-// configurationResourceClient.setMessageBoxURIByDate("http://192.168.17.1:8080/axis2/services/MsgBoxService3", "2012-11-12 00:12:27");
-
-// System.out.println("############### Remove GFac URI ###############");
-// configurationResourceClient.removeGFacURI("http://192.168.17.1:8080/axis2/services/GFacService3");
-//
-// System.out.println("############### Remove all GFac URI ###############");
-// configurationResourceClient.removeAllGFacURI();
-//
-// System.out.println("############### Remove removeWorkflowInterpreter URI ###############");
-// configurationResourceClient.removeWorkflowInterpreterURI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor3");
-
-// System.out.println("############### Remove removeAllWorkflowInterpreterURI ###############");
-// configurationResourceClient.removeAllWorkflowInterpreterURI();
-//
-// System.out.println("############### Remove eventing URI ###############");
-// configurationResourceClient.unsetEventingURI();
-//
-// System.out.println("############### unsetMessageBoxURI ###############");
-// configurationResourceClient.unsetMessageBoxURI();
- }
-
- public static void hostDescriptorClientTest(){
-// DescriptorResourceClient descriptorResourceClient = new DescriptorResourceClient();
-
-// boolean localHost = descriptorResourceClient.isHostDescriptorExists("LocalHost");
-// System.out.println(localHost);
-
-// HostDescription descriptor = new HostDescription(GlobusHostType.type);
-// descriptor.getType().setHostName("testHost");
-// descriptor.getType().setHostAddress("testHostAddress2");
-// descriptorResourceClient.addHostDescriptor(descriptor);
-
-// HostDescription localHost = descriptorResourceClient.getHostDescriptor("purdue.teragrid.org");
-// List<HostDescription> hostDescriptors = descriptorResourceClient.getHostDescriptors();
-// for(HostDescription hostDescription : hostDescriptors){
-// System.out.println(hostDescription.getType().getHostName());
-// System.out.println(hostDescription.getType().getHostAddress());
-// }
-//
-// List<String> hostDescriptorNames = descriptorResourceClient.getHostDescriptorNames();
-// for (String hostName : hostDescriptorNames){
-// System.out.println(hostName);
-// }
-
-// descriptorResourceClient.removeHostDescriptor("testHost");
-
-// System.out.println(localHost.getType().getHostName());
-// System.out.println(localHost.getType().getHostAddress());
-
- }
-
- public static void serviceDescriptorClientTest (){
-
-// DescriptorResourceClient descriptorResourceClient = new DescriptorResourceClient("admin",
-// "http://localhost:9080/airavata-services/api", new PasswordCallbackImpl("admin", "admin"));
-// //service descriptor exists
-// boolean exists = descriptorResourceClient.isServiceDescriptorExists("echo");
-// System.out.println(exists);
-
- //service descriptor save
-// ServiceDescription serviceDescription = new ServiceDescription();
-// List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
-// List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-// serviceDescription.getType().setName("testServiceDesc");
-// serviceDescription.getType().setDescription("testDescription");
-// InputParameterType parameter = InputParameterType.Factory.newInstance();
-// parameter.setParameterName("input1");
-// parameter.setParameterDescription("testDesc");
-// ParameterType parameterType = parameter.addNewParameterType();
-// parameterType.setType(DataType.STRING);
-// parameterType.setName("testParamtype");
-// inputParameters.add(parameter);
-//
-// OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
-// outputParameter.setParameterName("output1");
-// outputParameter.setParameterDescription("testDesc");
-// ParameterType outputParaType = outputParameter.addNewParameterType();
-// outputParaType.setType(DataType.STRING);
-// outputParaType.setName("testParamtype");
-// outputParameters.add(outputParameter);
-//
-// serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
-// serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
-//
-// descriptorResourceClient.saveServiceDescriptor(serviceDescription);
-
- // Service descriptor update
-// ServiceDescription testServiceDesc = descriptorResourceClient.getServiceDescriptor("testServiceDesc");
-// testServiceDesc.getType().setDescription("testDescription2");
-// List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
-// List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-// InputParameterType parameter = InputParameterType.Factory.newInstance();
-// parameter.setParameterName("input2");
-// parameter.setParameterDescription("testDesc2");
-// ParameterType parameterType = parameter.addNewParameterType();
-// parameterType.setType(DataType.STRING);
-// parameterType.setName("testParamtype2");
-// inputParameters.add(parameter);
-//
-// OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
-// outputParameter.setParameterName("output2");
-// outputParameter.setParameterDescription("testDesc2");
-// ParameterType outputParaType = outputParameter.addNewParameterType();
-// outputParaType.setType(DataType.STRING);
-// outputParaType.setName("testParamtype2");
-// outputParameters.add(outputParameter);
-//
-// testServiceDesc.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
-// testServiceDesc.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
-//
-// descriptorResourceClient.updateServiceDescriptor(testServiceDesc);
-
- //getServiceDescriptor
-// ServiceDescription testServiceDesc = descriptorResourceClient.getServiceDescriptor("testServiceDesc");
-// System.out.println(testServiceDesc.getType().getName());
-// System.out.println(testServiceDesc.getType().getDescription());
-
- //removeServiceDescriptor
-// descriptorResourceClient.removeServiceDescriptor("testServiceDesc");
-
- //getServiceDescriptors
-// List<ServiceDescription> serviceDescriptors = descriptorResourceClient.getServiceDescriptors();
-// for (ServiceDescription serviceDescription : serviceDescriptors){
-// System.out.println(serviceDescription.getType().getName());
-// System.out.println(serviceDescription.getType().getDescription());
-// }
- }
-
- public static void appDescriptorClientTest (){
-// DescriptorResourceClient descriptorResourceClient = new DescriptorResourceClient();
-
- //isApplicationDescriptorExist
-// boolean descriptorExist = descriptorResourceClient.isApplicationDescriptorExist("echo", "LocalHost", "LocalHost_application");
-// System.out.println(descriptorExist);
-
- // addApplicationDescriptor
-// ServiceDescription serviceDescription = new ServiceDescription();
-// List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
-// List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-// serviceDescription.getType().setName("testServiceDesc");
-// serviceDescription.getType().setDescription("testDescription");
-// InputParameterType parameter = InputParameterType.Factory.newInstance();
-// parameter.setParameterName("input1");
-// parameter.setParameterDescription("testDesc");
-// ParameterType parameterType = parameter.addNewParameterType();
-// parameterType.setType(DataType.STRING);
-// parameterType.setName("testParamtype");
-// inputParameters.add(parameter);
-//
-// OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
-// outputParameter.setParameterName("output1");
-// outputParameter.setParameterDescription("testDesc");
-// ParameterType outputParaType = outputParameter.addNewParameterType();
-// outputParaType.setType(DataType.STRING);
-// outputParaType.setName("testParamtype");
-// outputParameters.add(outputParameter);
-//
-// serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
-// serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
-//
-// HostDescription hostDescription = new HostDescription(GlobusHostType.type);
-// hostDescription.getType().setHostName("testHost");
-// hostDescription.getType().setHostAddress("testHostAddress");
-// descriptorResourceClient.addHostDescriptor(hostDescription);
-//
-// ApplicationDeploymentDescription applicationDeploymentDescription = new ApplicationDeploymentDescription(ApplicationDeploymentDescriptionType.type);
-// ApplicationDeploymentDescriptionType.ApplicationName applicationName = applicationDeploymentDescription.getType().addNewApplicationName();
-// applicationName.setStringValue("testApplication");
-// applicationDeploymentDescription.getType().setApplicationName(applicationName);
-// applicationDeploymentDescription.getType().setInputDataDirectory("/bin");
-// applicationDeploymentDescription.getType().setExecutableLocation("/bin/echo");
-// applicationDeploymentDescription.getType().setOutputDataDirectory("/tmp");
-//
-// descriptorResourceClient.addApplicationDescriptor(serviceDescription, hostDescription, applicationDeploymentDescription);
-
- //addApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor)
-// ApplicationDeploymentDescription applicationDeploymentDescription = new ApplicationDeploymentDescription(ApplicationDeploymentDescriptionType.type);
-// ApplicationDeploymentDescriptionType.ApplicationName applicationName = applicationDeploymentDescription.getType().addNewApplicationName();
-// applicationName.setStringValue("testApplication2");
-// applicationDeploymentDescription.getType().setApplicationName(applicationName);
-// applicationDeploymentDescription.getType().setInputDataDirectory("/bin");
-// applicationDeploymentDescription.getType().setExecutableLocation("/bin/echo");
-// applicationDeploymentDescription.getType().setOutputDataDirectory("/tmp");
-// descriptorResourceClient.addApplicationDescriptor("testServiceDesc", "testHost", applicationDeploymentDescription);
-
- //udpateApplicationDescriptor
-// ApplicationDeploymentDescription applicationDescriptor = descriptorResourceClient.getApplicationDescriptor("testServiceDesc", "testHost", "testApplication2");
-// applicationDescriptor.getType().setInputDataDirectory("/bin1");
-// applicationDescriptor.getType().setExecutableLocation("/bin/echo1");
-// applicationDescriptor.getType().setOutputDataDirectory("/tmp1");
-// descriptorResourceClient.updateApplicationDescriptor("testServiceDesc", "testHost", applicationDescriptor);
-
- //getApplicationDescriptors(String serviceName, String hostname)
-// ApplicationDeploymentDescription applicationDescriptors = descriptorResourceClient.getApplicationDescriptors("testServiceDesc", "testHost");
-// System.out.println(applicationDescriptors.getType().getApplicationName().getStringValue());
-// System.out.println(applicationDescriptors.getType().getExecutableLocation());
-// System.out.println(applicationDescriptors.getType().getOutputDataDirectory());
-
- //getApplicationDescriptors(String serviceName)
-// Map<String,ApplicationDeploymentDescription> testServiceDesc = descriptorResourceClient.getApplicationDescriptors("testServiceDesc");
-// for (String host : testServiceDesc.keySet()){
-// System.out.println(host);
-// ApplicationDeploymentDescription applicationDeploymentDescription = testServiceDesc.get(host);
-// System.out.println(applicationDeploymentDescription.getType().getApplicationName().getStringValue());
-// }
- //getApplicationDescriptors()
-// Map<String[], ApplicationDeploymentDescription> applicationDescriptors = descriptorResourceClient.getApplicationDescriptors();
-// for (String[] desc : applicationDescriptors.keySet()){
-// System.out.println(desc[0]);
-// System.out.println(desc[1]);
-// ApplicationDeploymentDescription applicationDeploymentDescription = applicationDescriptors.get(desc);
-// System.out.println(applicationDeploymentDescription.getType().getApplicationName().getStringValue());
-// }
-
- //getApplicationDescriptorNames ()
-// List<String> applicationDescriptorNames = descriptorResourceClient.getApplicationDescriptorNames();
-// for (String appName : applicationDescriptorNames){
-// System.out.println(appName);
-// }
- }
-
- public static void projectRegistryClientTest(){
-// ProjectResourceClient projectResourceClient = new ProjectResourceClient();
- //isWorkspaceProjectExists
-// boolean projectExists = projectResourceClient.isWorkspaceProjectExists("default");
-// System.out.println(projectExists);
- //isWorkspaceProjectExists(String projectName, boolean createIfNotExists)
-// projectResourceClient.isWorkspaceProjectExists("testproject", true);
- // addWorkspaceProject
-// projectResourceClient.addWorkspaceProject("testproject2");
-
- //updateWorkspaceProject(String projectName)
-// projectResourceClient.updateWorkspaceProject("testproject");
-
- // deleteWorkspaceProject
-// projectResourceClient.deleteWorkspaceProject("testproject");
-
- //getWorkspaceProject
-// WorkspaceProject project = projectResourceClient.getWorkspaceProject("default");
-// System.out.println(project.getGateway().getGatewayName());
-
- //getWorkspaceProjects
-// List<WorkspaceProject> workspaceProjects = projectResourceClient.getWorkspaceProjects();
-// for (WorkspaceProject workspaceProject : workspaceProjects){
-// System.out.println(workspaceProject.getProjectName());
-// }
-
- }
-
- public static void experimentRegistryClient(){
-// ExperimentResourceClient experimentResourceClient = new ExperimentResourceClient();
- //add experiment
-// try {
-// AiravataExperiment experiment = new AiravataExperiment();
-// experiment.setExperimentId("testExperiment2");
-// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-// Date formattedDate = dateFormat.parse("2012-11-13 11:50:32");
-// experiment.setSubmittedDate(formattedDate);
-// experimentResourceClient.addExperiment("default", experiment);
-// } catch (ParseException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-
- //remove experiment
-// experimentResourceClient.removeExperiment("testExperiment");
-
-// List<AiravataExperiment> experiments = experimentResourceClient.getExperiments();
-// System.out.println(experiments.size());
- //getExperiments(Date from, Date to)
-// try{
-// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-// Date date1 = dateFormat.parse("2012-11-01 11:50:32");
-// Date date2 = dateFormat.parse("2012-11-15 11:50:32");
-// List<AiravataExperiment> experiments = experimentResourceClient.getExperiments(date1, date2);
-// System.out.println(experiments.size());
-// } catch (ParseException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-
- //getExperiments(String projectName, Date from, Date to)
-// try{
-// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-// Date date1 = dateFormat.parse("2012-11-01 11:50:32");
-// Date date2 = dateFormat.parse("2012-11-15 11:50:32");
-// List<AiravataExperiment> experiments = experimentResourceClient.getExperiments("default",date1, date2);
-// System.out.println(experiments.size());
-// } catch (ParseException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-
- //isExperimentExists(String experimentId)
-// boolean exists = experimentResourceClient.isExperimentExists("testExperiment");
-// System.out.println(exists);
-
-
- //isExperimentExists(String experimentId, boolean createIfNotPresent)
-// experimentResourceClient.isExperimentExists("testExp", true);
-
-
- }
-
- public static void userWFClientTest (){
-// UserWorkflowResourceClient userWorkflowResourceClient = new UserWorkflowResourceClient();
-// boolean exists = userWorkflowResourceClient.isWorkflowExists("Workflow1");
-// System.out.println(exists);
-// userWorkflowResourceClient.addWorkflow("workflow5", "testworlflowcontent");
-// userWorkflowResourceClient.updateWorkflow("worklfow5", "updatedtestworlflowcontent");
-// String workflow2 = userWorkflowResourceClient.getWorkflowGraphXML("workflow2");
-// System.out.println(workflow2);
-// Map<String, String> workflows = userWorkflowResourceClient.getWorkflows();
-// System.out.println(workflows.size());
-// userWorkflowResourceClient.removeWorkflow("workflow5");
- }
-
- public static void publishWFClientTest () {
-// PublishedWorkflowResourceClient publishedWorkflowResourceClient = new PublishedWorkflowResourceClient();
-// boolean exists = publishedWorkflowResourceClient.isPublishedWorkflowExists("Workflow2");
-// System.out.println(exists);
-
-// publishedWorkflowResourceClient.publishWorkflow("workflow3", "publishedWF3");
-// publishedWorkflowResourceClient.publishWorkflow("workflow4");
-// String workflow1 = publishedWorkflowResourceClient.getPublishedWorkflowGraphXML("Workflow2");
-// System.out.println(workflow1);
-// List<String> publishedWorkflowNames = publishedWorkflowResourceClient.getPublishedWorkflowNames();
-// System.out.println(publishedWorkflowNames.size());
-
-// publishedWorkflowResourceClient.removePublishedWorkflow("workflow4");
-
- }
-
- public static void provenanceClientTest() {
-// ProvenanceResourceClient provenanceResourceClient = new ProvenanceResourceClient();
-// provenanceResourceClient.updateExperimentExecutionUser("eb9e67cf-6fe3-46f1-b50b-7b42936d347d", "aaa");
-// String experimentExecutionUser = provenanceResourceClient.getExperimentExecutionUser("eb9e67cf-6fe3-46f1-b50b-7b42936d347d");
-// System.out.println(experimentExecutionUser);
-// boolean nameExist = provenanceResourceClient.isExperimentNameExist("exp1");
-// System.out.println(nameExist);
-// String experimentName = provenanceResourceClient.getExperimentName("eb9e67cf-6fe3-46f1-b50b-7b42936d347d");
-// System.out.println(experimentName);
-// String workflowExecutionTemplateName = provenanceResourceClient.getWorkflowExecutionTemplateName("e00ddc5e-f8d5-4492-9eb2-10372efb103c");
-// System.out.println(workflowExecutionTemplateName);
-// provenanceResourceClient.setWorkflowInstanceTemplateName("eb9e67cf-6fe3-46f1-b50b-7b42936d347d", "wftemplate2");
-// List<WorkflowInstance> experimentWorkflowInstances = provenanceResourceClient.getExperimentWorkflowInstances("e00ddc5e-f8d5-4492-9eb2-10372efb103c");
-// System.out.println(experimentWorkflowInstances.size());
-// System.out.println(provenanceResourceClient.isWorkflowInstanceExists("e00ddc5e-f8d5-4492-9eb2-10372efb103c"));
-// provenanceResourceClient.isWorkflowInstanceExists("testInstance", true);
-
-// try {
-// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-// Date date = dateFormat.parse("2012-11-01 11:50:32");
-// WorkflowInstanceStatus workflowInstanceStatus = new WorkflowInstanceStatus(new WorkflowInstance("testInstance", "testInstance"), WorkflowInstanceStatus.ExecutionStatus.FINISHED, date);
-// provenanceResourceClient.updateWorkflowInstanceStatus(workflowInstanceStatus);
-// } catch (ParseException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-
-// System.out.println(provenanceResourceClient.getWorkflowInstanceStatus("testInstance").getExecutionStatus().name());
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// provenanceResourceClient.updateWorkflowNodeInput(workflowInstanceNode, "testInput2");
-
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// provenanceResourceClient.updateWorkflowNodeOutput(workflowInstanceNode, "testOutput");
-
-// ExperimentData experiment = provenanceResourceClient.getExperiment("ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4");
-// String experimentName = experiment.getExperimentName();
-// System.out.println(experimentName);
-
-// ExperimentData experiment = provenanceResourceClient.getExperimentMetaInformation("ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4");
-// String experimentName = experiment.getExperimentName();
-// System.out.println(experimentName);
-
-// List<ExperimentData> admin = provenanceResourceClient.getAllExperimentMetaInformation("admin");
-// System.out.println(admin.size());
-
-// List<ExperimentData> experimentDataList = provenanceResourceClient.searchExperiments("admin", "exp");
-// System.out.println(experimentDataList.size());
-
-// List<String> admin = provenanceResourceClient.getExperimentIdByUser("admin");
-// for (String exp : admin){
-// System.out.println(exp);
-// }
-// List<ExperimentData> experimentByUser = provenanceResourceClient.getExperimentByUser("admin");
-// System.out.println(experimentByUser.size());
-
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// WorkflowInstanceNodeStatus workflowInstanceNodeStatus = new WorkflowInstanceNodeStatus(workflowInstanceNode, WorkflowInstanceStatus.ExecutionStatus.STARTED);
-// provenanceResourceClient.updateWorkflowNodeStatus(workflowInstanceNodeStatus);
-
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// provenanceResourceClient.updateWorkflowNodeStatus(workflowInstanceNode, WorkflowInstanceStatus.ExecutionStatus.FINISHED);
-
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// WorkflowInstanceNodeStatus workflowNodeStatus = provenanceResourceClient.getWorkflowNodeStatus(workflowInstanceNode);
-// System.out.println(workflowNodeStatus.getExecutionStatus().name());
-
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// Date workflowNodeStartTime = provenanceResourceClient.getWorkflowNodeStartTime(workflowInstanceNode);
-// System.out.println(workflowNodeStartTime.toString());
-
-// WorkflowInstance tempConvertSoap_fahrenheitToCelsius = provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance();
-// Date workflowStartTime = provenanceResourceClient.getWorkflowStartTime(tempConvertSoap_fahrenheitToCelsius);
-// System.out.println(workflowStartTime.toString());
-
-// WorkflowNodeGramData workflowNodeGramData = new WorkflowNodeGramData("TempConvertSoap_FahrenheitToCelsius", "TempConvertSoap_FahrenheitToCelsius", "rsl", "invokedHost", "jobID");
-// provenanceResourceClient.updateWorkflowNodeGramData(workflowNodeGramData);
-
-// WorkflowInstanceData instanceData = provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius");
-// System.out.println(instanceData.getWorkflowInstance().getExperimentId());
-
-// System.out.println(provenanceResourceClient.isWorkflowInstanceNodePresent("TempConvertSoap_FahrenheitToCelsius", "TempConvertSoap_FahrenheitToCelsius"));
-
-// provenanceResourceClient.isWorkflowInstanceNodePresent("TempConvertSoap_FahrenheitToCelsius", "TempConvertSoap_FahrenheitToCelsius1", true);
-
-// provenanceResourceClient.addWorkflowInstance("testInstance", "testWF", "testWotrfklow");
-// WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(provenanceResourceClient.getWorkflowInstanceData("TempConvertSoap_FahrenheitToCelsius").getWorkflowInstance(), "TempConvertSoap_FahrenheitToCelsius");
-// WorkflowNodeType workflowNodeType = new WorkflowNodeType();
-// workflowNodeType.setNodeType(WorkflowNodeType.WorkflowNode.SERVICENODE);
-// provenanceResourceClient.updateWorkflowNodeType(workflowInstanceNode, workflowNodeType);
-
-// provenanceResourceClient.addWorkflowInstanceNode("TempConvertSoap_FahrenheitToCelsius", "testNode");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
----------------------------------------------------------------------
diff --git a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java b/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
deleted file mode 100644
index 5458e09..0000000
--- a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
+++ /dev/null
@@ -1,429 +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.rest.client;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-import org.apache.airavata.common.utils.Version;
-import org.apache.airavata.registry.api.AiravataUser;
-import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.PasswordCallback;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.utils.BasicAuthHeaderUtil;
-import org.apache.airavata.rest.utils.ClientConstant;
-import org.apache.airavata.rest.utils.CookieManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * This is the client class for all the basic registry operations. This class is being
- * instantiated by <code>AiravataClient</code>. Users of Airavata can also call this
- * client class if he wants to use REST service
- */
-public class BasicRegistryResourceClient {
- private WebResource webResource;
- private final static Logger logger = LoggerFactory.getLogger(BasicRegistryResourceClient.class);
- private String userName;
- private PasswordCallback callback;
- private String baseURI;
- private Cookie cookie;
- private WebResource.Builder builder;
- private String gatewayName;
-// private CookieManager cookieManager = new CookieManager();
-
- /**
- * Creates a BasicRegistryResourceClient
- *
- * @param userName registry user
- * @param seriveURI REST service URL
- * @param callback implementation of the <code>PasswordCallback</code>
- */
- public BasicRegistryResourceClient(String userName,
- String gateway,
- String seriveURI,
- PasswordCallback callback,
- Cookie cookie) {
- this.userName = userName;
- this.callback = callback;
- this.baseURI = seriveURI;
- this.gatewayName = gateway;
- this.cookie = cookie;
- }
-
- /**
- * Get base URL of the REST service
- *
- * @return REST url
- */
- private URI getBaseURI() {
- logger.debug("Creating Base URI");
- return UriBuilder.fromUri(baseURI).build();
- }
-
- /**
- * Creating the web resource for base url
- *
- * @return web resource related to the base url
- */
- private WebResource getBasicRegistryBaseResource() {
- ClientConfig config = new DefaultClientConfig();
- config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
- Boolean.TRUE);
- Client client = Client.create(config);
- WebResource baseWebResource = client.resource(getBaseURI());
- webResource = baseWebResource.path(
- ResourcePathConstants.BasicRegistryConstants.REGISTRY_API_BASICREGISTRY);
- return webResource;
- }
-
- /**
- * Get gateway related to the instance
- *
- * @return gateway
- */
- public Gateway getGateway() {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(
- MediaType.APPLICATION_JSON).get(ClientResponse.class);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- return response.getEntity(Gateway.class);
- }
-
- /**
- * Get executing user for the instance
- *
- * @return airavata user
- */
- public AiravataUser getUser() {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.GET_USER);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(
- MediaType.APPLICATION_JSON).get(ClientResponse.class);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- return response.getEntity(AiravataUser.class);
- }
-
- /**
- * setting the gateway
- *
- * @param gateway gateway
- */
- public void setGateway(Gateway gateway) {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(MediaType.TEXT_PLAIN).type(
- MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.TEXT_PLAIN).type(
- MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- }
-
- /**
- * Setting the airavata user
- *
- * @param user airavata user
- */
- public void setUser(AiravataUser user) {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.SET_USER);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(MediaType.TEXT_PLAIN).type(
- MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.TEXT_PLAIN).type(
- MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- }
-
- /**
- * Get service API version
- *
- * @return API version
- */
- public Version getVersion() {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.VERSION);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(
- MediaType.APPLICATION_JSON).get(ClientResponse.class);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- return response.getEntity(Version.class);
- }
-
- /**
- * Get registry REST service connection URL
- *
- * @return service URL
- */
- public URI getConnectionURI() {
- try {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.GET_SERVICE_URL);
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.accept(
- MediaType.TEXT_PLAIN).get(ClientResponse.class);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
-
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
-
- String uri = response.getEntity(String.class);
- return new URI(uri);
- } catch (URISyntaxException e) {
- logger.error("URI syntax is not correct...");
- }
- return null;
- }
-
- /**
- * set service connection URL
- *
- * @param connectionURI service connection URL
- */
- public void setConnectionURI(URI connectionURI) {
- webResource = getBasicRegistryBaseResource().path(
- ResourcePathConstants.BasicRegistryConstants.SET_SERVICE_URL);
- MultivaluedMap formData = new MultivaluedMapImpl();
- formData.add("connectionurl", connectionURI.toString());
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, null, cookie, gatewayName);
-
- ClientResponse response = builder.type(
- MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
- int status = response.getStatus();
-
- if (status == ClientConstant.HTTP_OK) {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
- builder = BasicAuthHeaderUtil.getBuilder(
- webResource, null, userName, callback.getPassword(userName), null, gatewayName);
- response = builder.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-
- status = response.getStatus();
-
- if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- } else {
- if (response.getCookies().size() > 0) {
- cookie = response.getCookies().get(0).toCookie();
- CookieManager.setCookie(cookie);
- }
- }
- } else {
- logger.error(response.getEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : "
- + status);
- }
- }
-}