You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/12/04 22:01:57 UTC
[32/54] [abbrv] airavata git commit: adding data manager code to
develop branch
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/ProcessStatus.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/ProcessStatus.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/ProcessStatus.java
index fd17488..fef36f8 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/ProcessStatus.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/ProcessStatus.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class ProcessStatus implements org.apache.thrift.TBase<ProcessStatus, ProcessStatus._Fields>, java.io.Serializable, Cloneable, Comparable<ProcessStatus> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ProcessStatus");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/TaskStatus.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/TaskStatus.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/TaskStatus.java
index 17acb57..ad606cb 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/TaskStatus.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/status/TaskStatus.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class TaskStatus implements org.apache.thrift.TBase<TaskStatus, TaskStatus._Fields>, java.io.Serializable, Cloneable, Comparable<TaskStatus> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TaskStatus");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/DataStagingTaskModel.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/DataStagingTaskModel.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/DataStagingTaskModel.java
index 679aacb..7386125 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/DataStagingTaskModel.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/DataStagingTaskModel.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class DataStagingTaskModel implements org.apache.thrift.TBase<DataStagingTaskModel, DataStagingTaskModel._Fields>, java.io.Serializable, Cloneable, Comparable<DataStagingTaskModel> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DataStagingTaskModel");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/EnvironmentSetupTaskModel.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/EnvironmentSetupTaskModel.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/EnvironmentSetupTaskModel.java
index 72442f9..8e5b241 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/EnvironmentSetupTaskModel.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/EnvironmentSetupTaskModel.java
@@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory;
* EnvironmentSetupTaskModel: A structure holding the environment creation task details
*
*/
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class EnvironmentSetupTaskModel implements org.apache.thrift.TBase<EnvironmentSetupTaskModel, EnvironmentSetupTaskModel._Fields>, java.io.Serializable, Cloneable, Comparable<EnvironmentSetupTaskModel> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("EnvironmentSetupTaskModel");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/JobSubmissionTaskModel.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/JobSubmissionTaskModel.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/JobSubmissionTaskModel.java
index c5c84bc..b1be35a 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/JobSubmissionTaskModel.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/JobSubmissionTaskModel.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class JobSubmissionTaskModel implements org.apache.thrift.TBase<JobSubmissionTaskModel, JobSubmissionTaskModel._Fields>, java.io.Serializable, Cloneable, Comparable<JobSubmissionTaskModel> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("JobSubmissionTaskModel");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/MonitorTaskModel.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/MonitorTaskModel.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/MonitorTaskModel.java
index 5f5740a..3502006 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/MonitorTaskModel.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/MonitorTaskModel.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class MonitorTaskModel implements org.apache.thrift.TBase<MonitorTaskModel, MonitorTaskModel._Fields>, java.io.Serializable, Cloneable, Comparable<MonitorTaskModel> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("MonitorTaskModel");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/TaskModel.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/TaskModel.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/TaskModel.java
index a1e14ab..578ae7b 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/TaskModel.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/task/TaskModel.java
@@ -60,7 +60,7 @@ import org.slf4j.LoggerFactory;
* subTaskModel:
* A generic byte object for the Task developer to store internal serialized data into registry catalogs.
*/
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class TaskModel implements org.apache.thrift.TBase<TaskModel, TaskModel._Fields>, java.io.Serializable, Cloneable, Comparable<TaskModel> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TaskModel");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Gateway.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Gateway.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Gateway.java
index 8a752c9..3e58644 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Gateway.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Gateway.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields>, java.io.Serializable, Cloneable, Comparable<Gateway> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Gateway");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Group.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Group.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Group.java
index 6b51643..7c12d6f 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Group.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Group.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class Group implements org.apache.thrift.TBase<Group, Group._Fields>, java.io.Serializable, Cloneable, Comparable<Group> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Group");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Project.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Project.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Project.java
index c57eadd..4b726a4 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Project.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/Project.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class Project implements org.apache.thrift.TBase<Project, Project._Fields>, java.io.Serializable, Cloneable, Comparable<Project> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Project");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/User.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/User.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/User.java
index 150d8c3..793ad5f 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/User.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/User.java
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-11-23")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-12-2")
public class User implements org.apache.thrift.TBase<User, User._Fields>, java.io.Serializable, Cloneable, Comparable<User> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("User");
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index cb4d93d..870b229 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -66,6 +66,19 @@ appcatalog.jdbc.user=airavata
appcatalog.jdbc.password=airavata
appcatalog.validationQuery=SELECT 1 from CONFIGURATION
+##########################################################################
+# Data Catalog DB Configuration
+###########################################################################
+#for derby [AiravataJPARegistry]
+datacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver
+datacatalog.jdbc.url=jdbc:derby://localhost:1527/data_catalog;create=true;user=airavata;password=airavata
+# MySql database configuration
+#datacatalog.jdbc.driver=com.mysql.jdbc.Driver
+#datacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog
+datacatalog.jdbc.user=airavata
+datacatalog.jdbc.password=airavata
+datacatalog.validationQuery=SELECT 1 from CONFIGURATION
+
###########################################################################
# Server module Configuration
###########################################################################
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties b/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties
index 1f3afd6..7aadf21 100644
--- a/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties
+++ b/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties
@@ -65,6 +65,19 @@ appcatalog.jdbc.user=airavata
appcatalog.jdbc.password=airavata
appcatalog.validationQuery=SELECT 1 from CONFIGURATION
+##########################################################################
+# Data Catalog DB Configuration
+###########################################################################
+#for derby [AiravataJPARegistry]
+datacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver
+datacatalog.jdbc.url=jdbc:derby://localhost:1527/data_catalog;create=true;user=airavata;password=airavata
+# MySql database configuration
+#datacatalog.jdbc.driver=com.mysql.jdbc.Driver
+#datacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog
+datacatalog.jdbc.user=airavata
+datacatalog.jdbc.password=airavata
+datacatalog.validationQuery=SELECT 1 from CONFIGURATION
+
###########################################################################
# Server module Configuration
###########################################################################
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/pom.xml
----------------------------------------------------------------------
diff --git a/modules/data-manager/pom.xml b/modules/data-manager/pom.xml
new file mode 100644
index 0000000..205fe58
--- /dev/null
+++ b/modules/data-manager/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <artifactId>airavata</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.16-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>data-manager</artifactId>
+ <packaging>jar</packaging>
+ <name>Airavata Data Manager</name>
+ <url>http://airavata.apache.org/</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-data-models</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-registry-core</artifactId>
+ <version>${project.version}</version>
+ </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-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-server-configuration</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManager.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManager.java b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManager.java
new file mode 100644
index 0000000..7b046d5
--- /dev/null
+++ b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManager.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.data.manager;
+
+import org.apache.airavata.model.data.resource.DataResourceModel;
+
+public interface DataManager {
+
+ /**
+ * To create a replica entry for an already existing file(s). This is how the system comes to know about already
+ * existing resources
+ * @param resource
+ * @return
+ */
+ String publishDataResource(DataResourceModel resource) throws DataManagerException;
+
+ /**
+ * To remove a resource entry from the replica catalog
+ * @param resourceId
+ * @return
+ */
+ boolean removeDataResource(String resourceId) throws DataManagerException;
+
+
+ /**
+ * To update an existing data resource model
+ * @param dataResourceModel
+ * @return
+ * @throws DataManagerException
+ */
+ boolean updateDataResource(DataResourceModel dataResourceModel) throws DataManagerException;
+
+ /**
+ * To retrieve a resource object providing the resourceId
+ * @param resourceId
+ * @return
+ */
+ DataResourceModel getDataResource(String resourceId) throws DataManagerException;
+
+ /**
+ * To copy an already existing resource to a specified location. After successful copying the new location will be
+ * added to the available replica locations of the resource
+ * @param resourceId
+ * @param destLocation
+ * @return
+ */
+ boolean copyDataResource(String resourceId, String destLocation) throws DataManagerException;
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerException.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerException.java b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerException.java
new file mode 100644
index 0000000..36a1a13
--- /dev/null
+++ b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.data.manager;
+
+public class DataManagerException extends Exception{
+
+ public DataManagerException(Throwable e) {
+ super(e);
+ }
+
+ public DataManagerException(String message) {
+ super(message, null);
+ }
+
+ public DataManagerException(String message, Throwable e) {
+ super(message, e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerFactory.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerFactory.java b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerFactory.java
new file mode 100644
index 0000000..94de8a9
--- /dev/null
+++ b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerFactory.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.data.manager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataManagerFactory {
+ private final static Logger logger = LoggerFactory.getLogger(DataManagerFactory.class);
+
+ public static DataManager getDataManager() throws DataManagerException {
+ return new DataManagerImpl();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerImpl.java b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerImpl.java
new file mode 100644
index 0000000..a8b1ae6
--- /dev/null
+++ b/modules/data-manager/src/main/java/org/apache/airavata/data/manager/DataManagerImpl.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.data.manager;
+
+import org.apache.airavata.model.data.resource.DataResourceModel;
+import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
+import org.apache.airavata.registry.cpi.DataCatalog;
+import org.apache.airavata.registry.cpi.DataCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataManagerImpl implements DataManager{
+ private final static Logger logger = LoggerFactory.getLogger(DataManagerImpl.class);
+
+ private DataCatalog dataCatalog;
+
+ public DataManagerImpl() throws DataManagerException {
+ try {
+ this.dataCatalog = RegistryFactory.getDataCatalog();
+ } catch (DataCatalogException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ @Override
+ public String publishDataResource(DataResourceModel resourceModel) throws DataManagerException{
+ try {
+ String resourceId = dataCatalog.publishResource(resourceModel);
+ return resourceId;
+ } catch (DataCatalogException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ @Override
+ public boolean removeDataResource(String resourceId) throws DataManagerException {
+ try {
+ boolean result = dataCatalog.removeResource(resourceId);
+ return result;
+ } catch (DataCatalogException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ @Override
+ public boolean updateDataResource(DataResourceModel dataResourceModel) throws DataManagerException {
+ try {
+ boolean result = dataCatalog.updateResource(dataResourceModel);
+ return result;
+ } catch (DataCatalogException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ @Override
+ public DataResourceModel getDataResource(String resourceId) throws DataManagerException {
+ try {
+ DataResourceModel dataResource = dataCatalog.getResource(resourceId);
+ return dataResource;
+ } catch (DataCatalogException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ @Override
+ public boolean copyDataResource(String resourceId, String destLocation) throws DataManagerException{
+ return false;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerFactoryTest.java b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerFactoryTest.java
new file mode 100644
index 0000000..365c250
--- /dev/null
+++ b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerFactoryTest.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.data.manager;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataManagerFactoryTest {
+ private final static Logger logger = LoggerFactory.getLogger(DataManagerFactoryTest.class);
+
+ @Test
+ public void testCreateDataManager() throws DataManagerException {
+ DataManager dataManager = DataManagerFactory.getDataManager();
+ Assert.assertNotNull(dataManager);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerImplTest.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerImplTest.java b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerImplTest.java
new file mode 100644
index 0000000..af8b54b
--- /dev/null
+++ b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/DataManagerImplTest.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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.data.manager;
+
+import org.apache.airavata.data.manager.utils.AppCatInit;
+import org.apache.airavata.data.manager.utils.DataCatInit;
+import org.apache.airavata.model.data.resource.DataReplicaLocationModel;
+import org.apache.airavata.model.data.resource.DataResourceModel;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class DataManagerImplTest {
+ private final static Logger logger = LoggerFactory.getLogger(DataManagerImplTest.class);
+ private static AppCatInit appCatInit;
+ private static DataCatInit dataCatInit;
+ private static DataManager dataManager;
+ private static DataResourceModel dataResourceModel;
+
+ @BeforeClass
+ public static void setUp() {
+ try {
+ System.out.println("********** SET UP ************");
+ appCatInit = new AppCatInit("appcatalog-derby.sql");
+ appCatInit.initializeDB();
+ dataCatInit = new DataCatInit("datacatalog-derby.sql");
+ dataCatInit.initializeDB();
+ dataManager = DataManagerFactory.getDataManager();
+ dataResourceModel = new DataResourceModel();
+ dataResourceModel.setResourceName("test-file.txt");
+ List<DataReplicaLocationModel> replicaLocationModelList = new ArrayList<>();
+ DataReplicaLocationModel dataReplicaLocationModel = new DataReplicaLocationModel();
+ dataReplicaLocationModel.setReplicaName("1-st-replica");
+ ArrayList<String> dataLocations = new ArrayList<>();
+ dataLocations.add("scp://g75.iu.xsede.org:/var/www/portal/experimentData/test-file.txt");
+ dataReplicaLocationModel.setDataLocations(dataLocations);
+ replicaLocationModelList.add(dataReplicaLocationModel);
+ dataResourceModel.setReplicaLocations(replicaLocationModelList);
+ } catch (DataManagerException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("********** TEAR DOWN ************");
+ dataCatInit.stopDerbyServer();
+ }
+
+ @Test
+ public void testPublishDataResource(){
+ try {
+ String resourceId = dataManager.publishDataResource(dataResourceModel);
+ org.junit.Assert.assertNotNull(resourceId);
+ } catch (DataManagerException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testRemoveDataResource(){
+ try {
+ boolean result = dataManager.removeDataResource("234234234");
+ Assert.assertFalse(result);
+ String resourceId = dataManager.publishDataResource(dataResourceModel);
+ Assert.assertNotNull(resourceId);
+ result = dataManager.removeDataResource(resourceId);
+ Assert.assertTrue(result);
+ result = dataManager.removeDataResource(resourceId);
+ Assert.assertFalse(result);
+ } catch (DataManagerException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testGetDataResource(){
+ try {
+ String resourceId = dataManager.publishDataResource(dataResourceModel);
+ Assert.assertNotNull(resourceId);
+ DataResourceModel persistedCopy = dataManager.getDataResource(resourceId);
+ Assert.assertNotNull(persistedCopy);
+ Assert.assertTrue(persistedCopy.getReplicaLocations().size()==1);
+ } catch (DataManagerException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testUpdateDataResource(){
+ try {
+ dataResourceModel.setResourceId(UUID.randomUUID().toString());
+ boolean result = dataManager.updateDataResource(dataResourceModel);
+ Assert.assertFalse(result);
+ dataManager.publishDataResource(dataResourceModel);
+ DataReplicaLocationModel dataReplicaLocationModel = new DataReplicaLocationModel();
+ dataReplicaLocationModel.setReplicaName("2-nd-replica");
+ ArrayList<String> dataLocations = new ArrayList<>();
+ dataLocations.add("scp://g175.iu.xsede.org:/var/www/portal/experimentData/test-file.txt");
+ dataResourceModel.getReplicaLocations().add(dataReplicaLocationModel);
+ dataManager.updateDataResource(dataResourceModel);
+ dataResourceModel = dataManager.getDataResource(dataResourceModel.getResourceId());
+ Assert.assertTrue(dataResourceModel.getReplicaLocations().size()==2);
+ dataResourceModel.getReplicaLocations().remove(1);
+ dataManager.updateDataResource(dataResourceModel);
+ dataResourceModel = dataManager.getDataResource(dataResourceModel.getResourceId());
+ Assert.assertTrue(dataResourceModel.getReplicaLocations().size()==1);
+ } catch (DataManagerException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/AppCatInit.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/AppCatInit.java b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/AppCatInit.java
new file mode 100644
index 0000000..c2f66c7
--- /dev/null
+++ b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/AppCatInit.java
@@ -0,0 +1,320 @@
+/*
+ *
+ * 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.data.manager.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/9bfdc52a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/DataCatInit.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/DataCatInit.java b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/DataCatInit.java
new file mode 100644
index 0000000..05165a2
--- /dev/null
+++ b/modules/data-manager/src/test/java/org/apache/airavata/data/manager/utils/DataCatInit.java
@@ -0,0 +1,315 @@
+/*
+ *
+ * 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.data.manager.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.core.data.catalog.utils.DataCatalogConstants;
+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 DataCatInit {
+ private static final Logger logger = LoggerFactory.getLogger(DataCatInit.class);
+ public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
+ public String scriptName = "datacatalog-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 DataCatInit(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("datacatalog.jdbc.driver");
+ jdbcUrl = ServerSettings.getSetting("datacatalog.jdbc.url");
+ jdbcUser = ServerSettings.getSetting("datacatalog.jdbc.user");
+ jdbcPassword = ServerSettings.getSetting("datacatalog.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(DataCatalogConstants.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);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/pom.xml b/modules/registry/registry-core/pom.xml
index 030d39c..1b95738 100644
--- a/modules/registry/registry-core/pom.xml
+++ b/modules/registry/registry-core/pom.xml
@@ -107,32 +107,33 @@
<build>
<plugins>
- <!--<plugin>-->
- <!--<groupId>org.apache.openjpa</groupId>-->
- <!--<artifactId>openjpa-maven-plugin</artifactId>-->
- <!--<version>2.2.0</version>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>enhancer</id>-->
- <!--<phase>process-classes</phase>-->
- <!--<goals>-->
- <!--<goal>enhance</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--<configuration>-->
- <!--<addDefaultConstructor>true</addDefaultConstructor>-->
- <!--<enforcePropertyRestrictions>true</enforcePropertyRestrictions>-->
- <!--<persistenceXmlFile>${project.basedir}/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>-->
- <!--</configuration>-->
- <!--<dependencies>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.openjpa</groupId>-->
- <!--<artifactId>openjpa</artifactId>-->
- <!--<version>2.2.0</version>-->
- <!--</dependency>-->
- <!--</dependencies>-->
- <!--</plugin>-->
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.0</version>
+ <configuration>
+ <includes>**/entities/*.class</includes>
+ <excludes>**/entities/XML*.class</excludes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-antrun-plugin</artifactId>-->
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java
new file mode 100644
index 0000000..98dc8c3
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java
@@ -0,0 +1,149 @@
+/*
+ *
+ * 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.core.data.catalog.impl;
+
+import org.apache.airavata.model.data.resource.DataReplicaLocationModel;
+import org.apache.airavata.model.data.resource.DataResourceModel;
+import org.apache.airavata.registry.core.data.catalog.model.DataResource;
+import org.apache.airavata.registry.core.data.catalog.utils.DataCatalogJPAUtils;
+import org.apache.airavata.registry.core.data.catalog.utils.ThriftDataModelConversion;
+import org.apache.airavata.registry.cpi.DataCatalog;
+import org.apache.airavata.registry.cpi.DataCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.util.UUID;
+
+public class DataCatalogImpl implements DataCatalog {
+
+ private final static Logger logger = LoggerFactory.getLogger(DataCatalogImpl.class);
+
+ @Override
+ public String publishResource(DataResourceModel resourceModel) throws DataCatalogException {
+ String resourceId = UUID.randomUUID().toString();
+ resourceModel.setResourceId(resourceId);
+ for(DataReplicaLocationModel replicaLocationModel : resourceModel.getReplicaLocations()){
+ replicaLocationModel.setReplicaId(UUID.randomUUID().toString());
+ replicaLocationModel.setResourceId(resourceId);
+ }
+ DataResource dataResource = ThriftDataModelConversion.getDataResource(resourceModel);
+ EntityManager em = null;
+ try {
+ em = DataCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ em.persist(dataResource);
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new DataCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceId;
+ }
+
+ @Override
+ public boolean removeResource(String resourceId) throws DataCatalogException {
+ EntityManager em = null;
+ try {
+ em = DataCatalogJPAUtils.getEntityManager();
+ DataResource dataResource = em.find(DataResource.class, resourceId);
+ if(dataResource == null)
+ return false;
+ em.getTransaction().begin();
+ em.remove(dataResource);
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new DataCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateResource(DataResourceModel resourceModel) throws DataCatalogException {
+ EntityManager em = null;
+ try {
+ em = DataCatalogJPAUtils.getEntityManager();
+ DataResource dataResource = em.find(DataResource.class, resourceModel.getResourceId());
+ if(dataResource == null)
+ return false;
+ //FIXME - Every time we delete and create
+ em.getTransaction().begin();
+ em.remove(dataResource);
+ em.flush();
+ resourceModel.getReplicaLocations().stream().forEach(rl->{
+ rl.setReplicaId(UUID.randomUUID().toString());
+ rl.setResourceId(resourceModel.getResourceId());
+ });
+ em.persist(ThriftDataModelConversion.getDataResource(resourceModel));
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new DataCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public DataResourceModel getResource(String resourceId) throws DataCatalogException {
+ EntityManager em = null;
+ try {
+ em = DataCatalogJPAUtils.getEntityManager();
+ DataResource dataResource = em.find(DataResource.class, resourceId);
+ return ThriftDataModelConversion.getDataResourceModel(dataResource);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new DataCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java
new file mode 100644
index 0000000..e4ad0ec
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java
@@ -0,0 +1,55 @@
+/*
+*
+* 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.core.data.catalog.model;
+
+import org.apache.airavata.registry.core.app.catalog.model.Configuration_PK;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name ="CONFIGURATION")
+@IdClass(Configuration_PK.class)
+public class Configuration implements Serializable {
+ @Id
+ @Column(name = "CONFIG_KEY")
+ private String config_key;
+
+ @Id
+ @Column(name = "CONFIG_VAL")
+ private String config_val;
+
+ public String getConfig_key() {
+ return config_key;
+ }
+
+ public String getConfig_val() {
+ return config_val;
+ }
+
+ public void setConfig_key(String config_key) {
+ this.config_key = config_key;
+ }
+
+ public void setConfig_val(String config_val) {
+ this.config_val = config_val;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java
new file mode 100644
index 0000000..16db298
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java
@@ -0,0 +1,105 @@
+/*
+ *
+ * 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.core.data.catalog.model;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "DATA_REPLICA_LOCATION")
+public class DataReplicaLocation {
+ private final static Logger logger = LoggerFactory.getLogger(DataReplicaLocation.class);
+ private String resourceId;
+ private String replicaName;
+ private String replicaDescription;
+ private String dataLocations;
+ private Timestamp creationTime;
+ private Timestamp lastModifiedTime;
+
+ private DataResource dataResource;
+
+ @Column(name = "RESOURCE_ID")
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ @Column(name = "DATA_LOCATIONS")
+ public String getDataLocations() {
+ return dataLocations;
+ }
+
+ public void setDataLocations(String dataLocations) {
+ this.dataLocations = dataLocations;
+ }
+
+ @Column(name = "REPLICA_NAME")
+ public String getReplicaName() {
+ return replicaName;
+ }
+
+ public void setReplicaName(String replicaName) {
+ this.replicaName = replicaName;
+ }
+
+ @Column(name = "REPLICA_DESCRIPTION")
+ public String getReplicaDescription() {
+ return replicaDescription;
+ }
+
+ public void setReplicaDescription(String replicaDescription) {
+ this.replicaDescription = replicaDescription;
+ }
+
+ @Column(name = "CREATION_TIME")
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ @Column(name = "LAST_MODIFIED_TIME")
+ public Timestamp getLastModifiedTime() {
+ return lastModifiedTime;
+ }
+
+ public void setLastModifiedTime(Timestamp lastModifiedTime) {
+ this.lastModifiedTime = lastModifiedTime;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "RESOURCE_ID")
+ public DataResource getDataResource() {
+ return dataResource;
+ }
+
+ public void setDataResource(DataResource dataResource) {
+ this.dataResource = dataResource;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java
new file mode 100644
index 0000000..392f2f3
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.core.data.catalog.model;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.Collection;
+
+@Entity
+@Table(name = "DATA_RESOURCE")
+public class DataResource {
+ private final static Logger logger = LoggerFactory.getLogger(DataResource.class);
+ private String resourceId;
+ private String resourceName;
+ private String resourceDescription;
+ private int resourceSize;
+ private Timestamp creationTime;
+ private Timestamp lastModifiedTime;
+
+ private Collection<DataReplicaLocation> dataReplicaLocations;
+
+ @Id
+ @Column(name = "RESOURCE_ID")
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ @Column(name = "RESOURCE_NAME")
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ @Column(name = "RESOURCE_DESCRIPTION")
+ public String getResourceDescription() {
+ return resourceDescription;
+ }
+
+ public void setResourceDescription(String resourceDescription) {
+ this.resourceDescription = resourceDescription;
+ }
+
+ @Column(name = "RESOURCE_SIZE")
+ public int getResourceSize() {
+ return resourceSize;
+ }
+
+ public void setResourceSize(int resourceSize) {
+ this.resourceSize = resourceSize;
+ }
+
+ @Column(name = "CREATION_TIME")
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ @Column(name = "LAST_MODIFIED_TIME")
+ public Timestamp getLastModifiedTime() {
+ return lastModifiedTime;
+ }
+
+ public void setLastModifiedTime(Timestamp lastModifiedTime) {
+ this.lastModifiedTime = lastModifiedTime;
+ }
+
+ @OneToMany(mappedBy = "dataResource", cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
+ public Collection<DataReplicaLocation> getDataReplicaLocations() {
+ return dataReplicaLocations;
+ }
+
+ public void setDataReplicaLocations(Collection<DataReplicaLocation> dataReplicaLocations) {
+ this.dataReplicaLocations = dataReplicaLocations;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bfdc52a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java
new file mode 100644
index 0000000..c9e18f6
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.core.data.catalog.utils;
+
+public class DataCatalogConstants {
+ // table names
+ public static final String DATA_RESOURCE = "DataResource";
+ public static final String DATA_REPLICA_LOCATION = "DataReplicaLocation";
+ public static final String CONFIGURATION = "Configuration";
+
+ // DataResource Table
+ public final class DataResourceConstants {
+ public static final String RESOURCE_ID = "resourceId";
+ public static final String RESOURCE_NAME = "resourceName";
+ public static final String RESOURCE_DESCRIPTION = "resourceDescription";
+ public static final String RESOURCE_SIZE = "resourceSize";
+ public static final String CREATION_TIME = "creationTime";
+ public static final String LAST_MODIFIED_TIME = "lastModifiedTime";
+ }
+
+ // Users table
+ public final class DataReplicaLocationConstants {
+ public static final String REPLICA_ID = "replicaId";
+ public static final String RESOURCE_ID = "resourceId";
+ public static final String DATA_LOCATIONS = "dataLocations";
+ public static final String REPLICA_NAME = "replicaName";
+ public static final String REPLICA_DESCRIPTION = "replicaDescription";
+ public static final String CREATION_TIME = "creationTime";
+ public static final String LAST_MODIFIED_TIME = "lastModifiedTime";
+ }
+}