You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/01/12 16:47:50 UTC
[07/24] airavata git commit: renaming the module
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/pom.xml b/modules/data-manager/data-manager-core/pom.xml
new file mode 100644
index 0000000..0dfa59a
--- /dev/null
+++ b/modules/data-manager/data-manager-core/pom.xml
@@ -0,0 +1,95 @@
+<?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>data-manager</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.16-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>data-manager-core</artifactId>
+ <packaging>jar</packaging>
+ <name>Airavata Data Manager Core</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.apache.airavata</groupId>
+ <artifactId>data-manager-cpi</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.jglobus</groupId>
+ <artifactId>gss</artifactId>
+ <version>${jglobus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jglobus</groupId>
+ <artifactId>gridftp</artifactId>
+ <version>${jglobus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jglobus</groupId>
+ <artifactId>myproxy</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk16</artifactId>
+ <version>1.44</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerFactory.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerFactory.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerFactory.java
new file mode 100644
index 0000000..af908a3
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerFactory.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.core;
+
+import org.apache.airavata.data.manager.cpi.DataManager;
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileManagerFactory {
+ private final static Logger logger = LoggerFactory.getLogger(FileManagerFactory.class);
+
+ public static DataManager getFileManager() throws DataManagerException {
+ return new FileManagerImpl();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerImpl.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerImpl.java
new file mode 100644
index 0000000..2570fc5
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileManagerImpl.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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.core;
+
+import org.apache.airavata.data.manager.cpi.DataManager;
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.apache.airavata.data.manager.cpi.FileTransferService;
+import org.apache.airavata.data.manager.cpi.ReplicaCatalogService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class FileManagerImpl implements DataManager {
+ private final static Logger logger = LoggerFactory.getLogger(FileManagerImpl.class);
+
+ /**
+ * Return file transfer service instance
+ *
+ * @return
+ */
+ @Override
+ public FileTransferService getFileTransferService() throws DataManagerException {
+ try{
+ return new FileTransferServiceImpl();
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ /**
+ * Return replica catalog service instance
+ *
+ * @return
+ */
+ @Override
+ public ReplicaCatalogService getReplicaCatalogService() throws DataManagerException {
+ try{
+ return new ReplicaCatalogServiceImpl();
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ /**
+ * Return metadata catalog service
+ *
+ * @return
+ */
+ @Override
+ public MetadataCatalogService getMetadataCatalogService() throws DataManagerException {
+ try{
+ return new MetadataCatalogServiceImpl();
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileTransferServiceImpl.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileTransferServiceImpl.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileTransferServiceImpl.java
new file mode 100644
index 0000000..a782ba7
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/FileTransferServiceImpl.java
@@ -0,0 +1,484 @@
+/*
+ *
+ * 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.core;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
+import org.apache.airavata.data.manager.core.db.dao.FileTransferRequestDao;
+import org.apache.airavata.data.manager.core.remote.client.RemoteStorageClient;
+import org.apache.airavata.data.manager.core.remote.client.http.HTTPStorageClient;
+import org.apache.airavata.data.manager.core.remote.client.scp.SCPStorageClient;
+import org.apache.airavata.data.manager.core.remote.client.sftp.SFTPStorageClient;
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.apache.airavata.data.manager.cpi.FileTransferService;
+import org.apache.airavata.model.data.transfer.*;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.List;
+import java.util.UUID;
+
+public class FileTransferServiceImpl implements FileTransferService {
+
+ private final static Logger logger = LoggerFactory.getLogger(FileTransferServiceImpl.class);
+
+ private FileTransferRequestDao fileTransferRequestDao;
+
+ public FileTransferServiceImpl() throws IOException {
+ this.fileTransferRequestDao = new FileTransferRequestDao();
+ }
+
+ /**
+ * Method to upload the give bytes to the destination storage system
+ *
+ * @param gatewayId
+ * @param username
+ * @param fileData
+ * @param destHostName
+ * @param destLoginName
+ * @param destPort
+ * @param destProtocol
+ * @param destinationPath
+ * @param destHostCredToken
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String uploadFile(String gatewayId, String username, byte[] fileData, String destHostName, String destLoginName, int destPort,
+ StorageResourceProtocol destProtocol,
+ String destinationPath, String destHostCredToken) throws DataManagerException {
+ long transferTime = System.currentTimeMillis();
+ if(destProtocol == StorageResourceProtocol.SCP || destProtocol == StorageResourceProtocol.SFTP) {
+ Object credential = getCredential(destHostCredToken);
+ SSHCredential sshCredential;
+ if (credential instanceof SSHCredential) {
+ sshCredential = (SSHCredential) credential;
+ File srcFile = null;
+ FileWriter fileWriter = null;
+ FileTransferRequestModel fileTransferRequestModel = null;
+ try {
+ String srcFilePath = System.getProperty("java.io.tmpdir")+File.separator+ UUID.randomUUID().toString();
+ srcFile = new File(srcFilePath);
+ fileWriter = new FileWriter(srcFile);
+ fileWriter.write(new String(fileData));
+ fileWriter.close();
+ RemoteStorageClient remoteStorageClient;
+ if(destProtocol == StorageResourceProtocol.SCP)
+ remoteStorageClient = new SCPStorageClient(destHostName, destPort, destLoginName,
+ sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+ else
+ remoteStorageClient = new SFTPStorageClient(destHostName, destPort, destLoginName,
+ sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+
+ fileTransferRequestModel = new FileTransferRequestModel();
+ fileTransferRequestModel.setGatewayId(gatewayId);
+ fileTransferRequestModel.setUsername(username);
+ fileTransferRequestModel.setSrcHostname(InetAddress.getLocalHost().getHostName());
+ fileTransferRequestModel.setSrcProtocol(StorageResourceProtocol.LOCAL);
+ fileTransferRequestModel.setDestHostname(destHostName);
+ fileTransferRequestModel.setDestLoginName(destLoginName);
+ fileTransferRequestModel.setDestPort(destPort);
+ fileTransferRequestModel.setDestProtocol(destProtocol);
+ fileTransferRequestModel.setDestFilePath(destinationPath);
+ fileTransferRequestModel.setDestHostCredToken(destHostCredToken);
+ fileTransferRequestModel.setFileTransferMode(FileTransferMode.SYNC);
+ remoteStorageClient.writeFile(srcFile, destinationPath);
+ transferTime = System.currentTimeMillis() - transferTime;
+ fileTransferRequestModel.setTransferTime(transferTime);
+ fileTransferRequestModel.setTransferStatus(FileTransferStatus.COMPLETED);
+ fileTransferRequestModel.setCreatedTime(System.currentTimeMillis());
+ fileTransferRequestModel.setLastModifiedType(fileTransferRequestModel.getCreatedTime());
+ fileTransferRequestModel.setFileSize(srcFile.length());
+ String transferId = fileTransferRequestDao.createFileTransferRequest(fileTransferRequestModel);
+ return transferId;
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ if(fileTransferRequestModel != null) {
+ fileTransferRequestModel.setTransferStatus(FileTransferStatus.FAILED);
+ try {
+ fileTransferRequestDao.createFileTransferRequest(fileTransferRequestModel);
+ } catch (JsonProcessingException e1) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+ throw new DataManagerException(e.getMessage());
+ } finally {
+ if(srcFile != null)
+ srcFile.delete();
+ if(fileWriter != null)
+ try {
+ fileWriter.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+ } else {
+ throw new DataManagerException("Only SSHCredential type is supported");
+ }
+ }else{
+ throw new DataManagerException(destProtocol.toString() + " protocol is not supported for this method");
+ }
+ }
+
+ /**
+ * Transfer file between two storage resources synchronously. Returns the file transfer request id
+ *
+ * @param gatewayId
+ * @param username
+ * @param srcHostname
+ * @param srcLoginName
+ * @param srcPort
+ * @param srcProtocol
+ * @param srcPath
+ * @param srcHostCredToken
+ * @param destHostname
+ * @param destLoginName
+ * @param destPort
+ * @param destProtocol
+ * @param destinationPath
+ * @param destHostCredToken
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String transferFile(String gatewayId, String username, String srcHostname, String srcLoginName, int srcPort, StorageResourceProtocol srcProtocol,
+ String srcPath, String srcHostCredToken, String destHostname, String destLoginName, int destPort,
+ StorageResourceProtocol destProtocol, String destinationPath, String destHostCredToken)
+ throws DataManagerException {
+ long transferTime = System.currentTimeMillis();
+ File srcFile = null;
+ FileTransferRequestModel fileTransferRequestModel = null;
+ try{
+ fileTransferRequestModel = new FileTransferRequestModel();
+ fileTransferRequestModel.setGatewayId(gatewayId);
+ fileTransferRequestModel.setUsername(username);
+ fileTransferRequestModel.setSrcHostname(srcHostname);
+ fileTransferRequestModel.setSrcPort(srcPort);
+ fileTransferRequestModel.setSrcLoginName(srcLoginName);
+ fileTransferRequestModel.setSrcFilePath(srcPath);
+ fileTransferRequestModel.setSrcProtocol(srcProtocol);
+ fileTransferRequestModel.setSrcHostCredToken(srcHostCredToken);
+ fileTransferRequestModel.setDestHostname(destHostname);
+ fileTransferRequestModel.setDestPort(destPort);
+ fileTransferRequestModel.setDestLoginName(destLoginName);
+ fileTransferRequestModel.setDestFilePath(destinationPath);
+ fileTransferRequestModel.setDestProtocol(destProtocol);
+ fileTransferRequestModel.setDestHostCredToken(destHostCredToken);
+ fileTransferRequestModel.setCreatedTime(System.currentTimeMillis());
+ fileTransferRequestModel.setLastModifiedType(fileTransferRequestModel.getCreatedTime());
+ fileTransferRequestModel.setFileTransferMode(FileTransferMode.SYNC);
+
+ if(srcProtocol == StorageResourceProtocol.HTTP || srcProtocol == StorageResourceProtocol.HTTPS ||
+ srcProtocol == StorageResourceProtocol.SCP || srcProtocol == StorageResourceProtocol.SFTP){
+ RemoteStorageClient srcClient = null;
+ if(srcProtocol == StorageResourceProtocol.HTTP){
+ srcClient = new HTTPStorageClient(HTTPStorageClient.Protocol.HTTP, srcHostname, srcPort);
+ }else if(srcProtocol == StorageResourceProtocol.HTTPS){
+ srcClient = new HTTPStorageClient(HTTPStorageClient.Protocol.HTTPS, srcHostname, srcPort);
+ }else if(srcProtocol == StorageResourceProtocol.SCP){
+ Object credential = getCredential(srcHostCredToken);
+ if(credential instanceof SSHCredential){
+ SSHCredential sshCredential = (SSHCredential) credential;
+ srcClient = new SCPStorageClient(srcHostname, srcPort, srcLoginName, sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+ }else{
+ throw new DataManagerException("Only support SSHCredentials for SCP host");
+ }
+ }else{
+ Object credential = getCredential(srcHostCredToken);
+ if(credential instanceof SSHCredential){
+ SSHCredential sshCredential = (SSHCredential) credential;
+ srcClient = new SFTPStorageClient(srcHostname, srcPort, srcLoginName, sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+ }else{
+ throw new DataManagerException("Only support SSHCredentials for SFTP host");
+ }
+ }
+ fileTransferRequestModel.setTransferStatus(FileTransferStatus.RUNNING);
+ srcFile = srcClient.readFile(srcPath);
+ }else{
+ throw new DataManagerException("Unsupported src protocol " + srcProtocol);
+ }
+
+ if(destProtocol == StorageResourceProtocol.SCP || destProtocol == StorageResourceProtocol.SFTP){
+ RemoteStorageClient destClient = null;
+ if(destProtocol == StorageResourceProtocol.SCP){
+ Object credential = getCredential(srcHostCredToken);
+ if(credential instanceof SSHCredential){
+ SSHCredential sshCredential = (SSHCredential) credential;
+ destClient = new SCPStorageClient(srcHostname, srcPort, srcLoginName, sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+ }else{
+ throw new DataManagerException("Only support SSHCredentials for SCP host");
+ }
+ }else{
+ Object credential = getCredential(srcHostCredToken);
+ if(credential instanceof SSHCredential){
+ SSHCredential sshCredential = (SSHCredential) credential;
+ destClient = new SFTPStorageClient(srcHostname, srcPort, srcLoginName, sshCredential.getPrivateKey(),
+ sshCredential.getPublicKey(), sshCredential.getPassphrase().getBytes());
+ }else{
+ throw new DataManagerException("Only support SSHCredentials for SFTP host");
+ }
+ }
+ destClient.writeFile(srcFile, destinationPath);
+ transferTime = System.currentTimeMillis() - transferTime;
+ fileTransferRequestModel.setTransferTime(transferTime);
+ fileTransferRequestModel.setFileSize(srcFile.length());
+ fileTransferRequestModel.setTransferStatus(FileTransferStatus.COMPLETED);
+ String transferId = fileTransferRequestDao.createFileTransferRequest(fileTransferRequestModel);
+ return transferId;
+ }else{
+ throw new DataManagerException("Unsupported src protocol " + srcProtocol);
+ }
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ if(fileTransferRequestModel != null) {
+ fileTransferRequestModel.setTransferStatus(FileTransferStatus.FAILED);
+ try {
+ fileTransferRequestDao.createFileTransferRequest(fileTransferRequestModel);
+ } catch (JsonProcessingException ex) {
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+ throw new DataManagerException(e);
+ }finally {
+ if(srcFile != null)
+ srcFile.delete();
+ }
+ }
+
+ /**
+ * Transfer file between two storage resources asynchronously. Returns the file transfer request id
+ *
+ * @param gatewayId
+ * @param username
+ * @param srcHostname
+ * @param srcLoginName
+ * @param srcPort
+ * @param srcProtocol
+ * @param srcPath
+ * @param srcHostCredToken
+ * @param destHostname
+ * @param destLoginName
+ * @param destPort
+ * @param destProtocol
+ * @param destinationPath
+ * @param destHostCredToken
+ * @param callbackEmails
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String transferFileAsync(String gatewayId, String username, String srcHostname, String srcLoginName, int srcPort, StorageResourceProtocol srcProtocol,
+ String srcPath, String srcHostCredToken, String destHostname, String destLoginName,
+ int destPort, StorageResourceProtocol destProtocol, String destinationPath,
+ String destHostCredToken, String[] callbackEmails) throws DataManagerException {
+ return null;
+ }
+
+ /**
+ * Get a directory listing of the specified source directory
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param path
+ * @param hostCredential
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public List<LSEntryModel> getDirectoryListing(String hostname, String loginName, int port, StorageResourceProtocol protocol,
+ String path, String hostCredential) throws DataManagerException {
+ return null;
+ }
+
+ /**
+ * Move file from one place to another inside the same storage resource
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param sourcePath
+ * @param destinationPath
+ * @throws DataManagerException
+ */
+ @Override
+ public void moveFile(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String sourcePath, String destinationPath) throws DataManagerException {
+
+ }
+
+ /**
+ * Rename a file
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param sourcePath
+ * @param newName
+ * @throws DataManagerException
+ */
+ @Override
+ public void renameFile(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String sourcePath, String newName) throws DataManagerException {
+
+ }
+
+ /**
+ * Create new directory
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param dirPath
+ * @throws DataManagerException
+ */
+ @Override
+ public void mkdir(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String dirPath) throws DataManagerException {
+
+ }
+
+ /**
+ * Delete File in storage resource
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param filePath
+ * @throws DataManagerException
+ */
+ @Override
+ public void deleteFile(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String filePath) throws DataManagerException {
+
+ }
+
+ /**
+ * Check whether the specified file exists
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param filePath
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public boolean isExists(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String filePath) throws DataManagerException {
+ return false;
+ }
+
+ /**
+ * Check whether the path points to a directory
+ *
+ * @param hostname
+ * @param loginName
+ * @param port
+ * @param protocol
+ * @param hostCredential
+ * @param filePath
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public boolean isDirectory(String hostname, String loginName, int port, StorageResourceProtocol protocol, String hostCredential,
+ String filePath) throws DataManagerException {
+ return false;
+ }
+
+ /**
+ * Method to retrieve file transfer status giving transfer id
+ *
+ * @param transferId
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public FileTransferRequestModel getFileTransferRequestStatus(String transferId) throws DataManagerException {
+ try{
+ return fileTransferRequestDao.getFileTransferRequest(transferId);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+
+ //TODO API Call to Credential Store
+ private SSHCredential getCredential(String credentialStoreToken) throws DataManagerException {
+ try{
+ SSHCredential sshCredential = new SSHCredential();
+ File privateKey = new File("/Users/supun/.ssh/id_rsa");
+ byte[] privateKeyBytes = IOUtils.toByteArray(new FileInputStream(privateKey));
+ File publicKey = new File("/Users/supun/.ssh/id_rsa.pub");
+ byte[] publicKeyBytes = IOUtils.toByteArray(new FileInputStream(publicKey));
+ String passPhrase = "cecilia@1990";
+ sshCredential.setPrivateKey(privateKeyBytes);
+ sshCredential.setPublicKey(publicKeyBytes);
+ sshCredential.setPassphrase(passPhrase);
+ return sshCredential;
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ public static void main(String[] args) throws IOException, DataManagerException {
+ FileTransferServiceImpl fileTransferService = new FileTransferServiceImpl();
+ String sourceFile = "fsgsdgsdgsdgsdg";
+ String transferId = fileTransferService.uploadFile("default", "supun", sourceFile.getBytes(), "gw75.iu.xsede.org",
+ "pga", 22, StorageResourceProtocol.SCP, "/var/www/portals/test.file", null);
+ FileTransferRequestModel fileTransferRequestModel = fileTransferService.fileTransferRequestDao.getFileTransferRequest(transferId);
+ System.out.println("file transfer id:" + fileTransferRequestModel.getTransferId());
+
+ transferId = fileTransferService.transferFile("default", "supun", "gw75.iu.xsede.org", "pga", 22, StorageResourceProtocol.SCP,
+ "/var/www/portals/test.file", null, "gw75.iu.xsede.org", "pga", 22, StorageResourceProtocol.SCP,
+ "/var/www/portals/test2.file", null);
+ fileTransferRequestModel = fileTransferService.fileTransferRequestDao.getFileTransferRequest(transferId);
+ System.out.println("file transfer id:" + fileTransferRequestModel.getTransferId());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogService.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogService.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogService.java
new file mode 100644
index 0000000..15172a3
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogService.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.core;
+
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.apache.airavata.model.data.metadata.MetadataModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MetadataCatalogService implements org.apache.airavata.data.manager.cpi.MetadataCatalogService {
+ private final static Logger logger = LoggerFactory.getLogger(MetadataCatalogService.class);
+
+ /**
+ * Create new metadata model
+ *
+ * @param metadataModel
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String createMetadata(MetadataModel metadataModel) throws DataManagerException {
+ return null;
+ }
+
+ /**
+ * Update existing metadata model
+ *
+ * @param metadataModel
+ * @throws DataManagerException
+ */
+ @Override
+ public void updateMetadata(MetadataModel metadataModel) throws DataManagerException {
+
+ }
+
+ /**
+ * Delete existing metadata model
+ *
+ * @param metadataId
+ * @throws DataManagerException
+ */
+ @Override
+ public void deleteMetadata(String metadataId) throws DataManagerException {
+
+ }
+
+ /**
+ * Retrieve metadata model
+ *
+ * @param metadataId
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public MetadataModel getMetadata(String metadataId) throws DataManagerException {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogServiceImpl.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogServiceImpl.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogServiceImpl.java
new file mode 100644
index 0000000..9f29c92
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/MetadataCatalogServiceImpl.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.data.manager.core;
+
+import org.apache.airavata.data.manager.core.db.dao.MetadataDao;
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.apache.airavata.model.data.metadata.MetadataModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class MetadataCatalogServiceImpl extends MetadataCatalogService {
+ private final static Logger logger = LoggerFactory.getLogger(MetadataCatalogServiceImpl.class);
+
+ private MetadataDao metadataDao;
+
+ public MetadataCatalogServiceImpl() throws IOException {
+ this.metadataDao = new MetadataDao();
+ }
+
+ /**
+ * Create new metadata model
+ *
+ * @param metadataModel
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String createMetadata(MetadataModel metadataModel) throws DataManagerException {
+ try{
+ return metadataDao.createMetadata(metadataModel);
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ /**
+ * Update exisiting metadata model
+ *
+ * @param metadataModel
+ * @throws DataManagerException
+ */
+ @Override
+ public void updateMetadata(MetadataModel metadataModel) throws DataManagerException {
+ try{
+ metadataDao.updateMetadata(metadataModel);
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ /**
+ * Delete existing metadata model
+ *
+ * @param metadataId
+ * @throws DataManagerException
+ */
+ @Override
+ public void deleteMetadata(String metadataId) throws DataManagerException {
+ try{
+ metadataDao.deleteMetadata(metadataId);
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+
+ /**
+ * Retrieve metadata model
+ *
+ * @param metadataId
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public MetadataModel getMetadata(String metadataId) throws DataManagerException {
+ try{
+ return metadataDao.getMetadata(metadataId);
+ }catch (Exception e){
+ logger.error(e.getMessage(), e);
+ throw new DataManagerException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ReplicaCatalogServiceImpl.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ReplicaCatalogServiceImpl.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ReplicaCatalogServiceImpl.java
new file mode 100644
index 0000000..e7bde66
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ReplicaCatalogServiceImpl.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.core;
+
+import org.apache.airavata.data.manager.core.db.dao.FileCollectionDao;
+import org.apache.airavata.data.manager.core.db.dao.FileDao;
+import org.apache.airavata.data.manager.cpi.DataManagerException;
+import org.apache.airavata.data.manager.cpi.ReplicaCatalogService;
+import org.apache.airavata.model.data.replica.FileCollectionModel;
+import org.apache.airavata.model.data.replica.FileModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ReplicaCatalogServiceImpl implements ReplicaCatalogService {
+ private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogServiceImpl.class);
+
+ private FileDao fileDao;
+ private FileCollectionDao fileCollectionDao;
+
+ public ReplicaCatalogServiceImpl() throws IOException {
+ this.fileDao = new FileDao();
+ this.fileCollectionDao = new FileCollectionDao();
+ }
+
+ /**
+ * Creates a new file entry in the replica catalog
+ *
+ * @param fileModel
+ * @return
+ */
+ @Override
+ public String registerFileDetails(FileModel fileModel) throws DataManagerException {
+ try{
+ return fileDao.createFile(fileModel);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Updates an existing file information
+ *
+ * @param fileModel
+ */
+ @Override
+ public void updateFileDetails(FileModel fileModel) throws DataManagerException {
+ try{
+ fileDao.updateFile(fileModel);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Deletes the specified file details entry
+ *
+ * @param fileId
+ */
+ @Override
+ public void deleteFileDetails(String fileId) throws DataManagerException {
+ try{
+ fileDao.deleteFile(fileId);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Retrieves file details for the specified file id
+ *
+ * @param fileId
+ * @return
+ */
+ @Override
+ public FileModel getFileDetails(String fileId) throws DataManagerException {
+ try{
+ return fileDao.getFile(fileId);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Create new file collection entry
+ *
+ * @param fileCollectionModel
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public String registerFileCollection(FileCollectionModel fileCollectionModel) throws DataManagerException {
+ try{
+ return fileCollectionDao.createFileCollection(fileCollectionModel);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Update existing file collection
+ *
+ * @param fileCollectionModel
+ * @throws DataManagerException
+ */
+ @Override
+ public void updateFileCollection(FileCollectionModel fileCollectionModel) throws DataManagerException {
+ try{
+ fileCollectionDao.updateFileCollection(fileCollectionModel);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Delete exisiting file collection
+ *
+ * @param collectionId
+ * @throws DataManagerException
+ */
+ @Override
+ public void deleteFileCollection(String collectionId) throws DataManagerException {
+ try{
+ fileCollectionDao.deleteFileCollection(collectionId);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+
+ /**
+ * Retrieve file collection specifying the collection id
+ *
+ * @param collectionId
+ * @return
+ * @throws DataManagerException
+ */
+ @Override
+ public FileCollectionModel getFileCollection(String collectionId) throws DataManagerException {
+ try{
+ return fileCollectionDao.getFileCollection(collectionId);
+ }catch (Exception ex){
+ logger.error(ex.getMessage(), ex);
+ throw new DataManagerException(ex);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftDeserializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftDeserializer.java
new file mode 100644
index 0000000..0841f45
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftDeserializer.java
@@ -0,0 +1,151 @@
+/*
+ *
+ * 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.core.db.conversion;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.node.JsonNodeType;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.google.common.base.CaseFormat;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TException;
+import org.apache.thrift.TFieldIdEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This abstract class represents a generic de-serializer for converting JSON to Thrift-based entities.
+ *
+ * @param <E> An implementation of the {@link org.apache.thrift.TFieldIdEnum} interface.
+ * @param <T> An implementation of the {@link org.apache.thrift.TBase} interface.
+ */
+public abstract class AbstractThriftDeserializer<E extends TFieldIdEnum, T extends TBase<T, E>> extends JsonDeserializer<T> {
+
+ private static Logger log = LoggerFactory.getLogger(AbstractThriftDeserializer.class);
+
+ @Override
+ public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
+ final T instance = newInstance();
+ final ObjectMapper mapper = (ObjectMapper)jp.getCodec();
+ final ObjectNode rootNode = (ObjectNode)mapper.readTree(jp);
+ final Iterator<Map.Entry<String, JsonNode>> iterator = rootNode.fields();
+
+ while(iterator.hasNext()) {
+ final Map.Entry<String, JsonNode> currentField = iterator.next();
+ try {
+ /*
+ * If the current node is not a null value, process it. Otherwise,
+ * skip it. Jackson will treat the null as a 0 for primitive
+ * number types, which in turn will make Thrift think the field
+ * has been set. Also we ignore the MongoDB specific _id field
+ */
+ if(currentField.getValue().getNodeType() != JsonNodeType.NULL) {
+ final E field = getField(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, currentField.getKey()));
+ final JsonParser parser = currentField.getValue().traverse();
+ parser.setCodec(mapper);
+ final Object value = mapper.readValue(parser, generateValueType(instance, field));
+ if(value != null) {
+ log.debug(String.format("Field %s produced value %s of type %s.",
+ currentField.getKey(), value, value.getClass().getName()));
+ instance.setFieldValue(field, value);
+ } else {
+ log.debug("Field {} contains a null value. Skipping...", currentField.getKey());
+ }
+ } else {
+ log.debug("Field {} contains a null value. Skipping...", currentField.getKey());
+ }
+ } catch (final NoSuchFieldException | IllegalArgumentException e) {
+ log.error("Unable to de-serialize field '{}'.", currentField.getKey(), e);
+ ctxt.mappingException(e.getMessage());
+ }
+ }
+
+ try {
+ // Validate that the instance contains all required fields.
+ validate(instance);
+ } catch (final TException e) {
+ log.error(String.format("Unable to deserialize JSON '%s' to type '%s'.",
+ jp.getValueAsString(), instance.getClass().getName(), e));
+ ctxt.mappingException(e.getMessage());
+ }
+
+ return instance;
+ }
+
+ /**
+ * Returns the {@code <E>} enumerated value that represents the target
+ * field in the Thrift entity referenced in the JSON document.
+ * @param fieldName The name of the Thrift entity target field.
+ * @return The {@code <E>} enumerated value that represents the target
+ * field in the Thrift entity referenced in the JSON document.
+ */
+ protected abstract E getField(String fieldName);
+
+ /**
+ * Creates a new instance of the Thrift entity class represented by this deserializer.
+ * @return A new instance of the Thrift entity class represented by this deserializer.
+ */
+ protected abstract T newInstance();
+
+ /**
+ * Validates that the Thrift entity instance contains all required fields after deserialization.
+ * @param instance A Thrift entity instance.
+ * @throws org.apache.thrift.TException if unable to validate the instance.
+ */
+ protected abstract void validate(T instance) throws TException;
+
+ /**
+ * Generates a {@link JavaType} that matches the target Thrift field represented by the provided
+ * {@code <E>} enumerated value. If the field's type includes generics, the generics will
+ * be added to the generated {@link JavaType} to support proper conversion.
+ * @param thriftInstance The Thrift-generated class instance that will be converted to/from JSON.
+ * @param field A {@code <E>} enumerated value that represents a field in a Thrift-based entity.
+ * @return The {@link JavaType} representation of the type associated with the field.
+ * @throws NoSuchFieldException if unable to determine the field's type.
+ * @throws SecurityException if unable to determine the field's type.
+ */
+ protected JavaType generateValueType(final T thriftInstance, final E field) throws NoSuchFieldException, SecurityException {
+ final TypeFactory typeFactory = TypeFactory.defaultInstance();
+
+ final Field declaredField = thriftInstance.getClass().getDeclaredField(field.getFieldName());
+ if(declaredField.getType().equals(declaredField.getGenericType())) {
+ log.debug("Generating JavaType for type '{}'.", declaredField.getType());
+ return typeFactory.constructType(declaredField.getType());
+ } else {
+ final ParameterizedType type = (ParameterizedType)declaredField.getGenericType();
+ final Class<?>[] parameterizedTypes = new Class<?>[type.getActualTypeArguments().length];
+ for(int i=0; i<type.getActualTypeArguments().length; i++) {
+ parameterizedTypes[i] = (Class<?>)type.getActualTypeArguments()[i];
+ }
+ log.debug("Generating JavaType for type '{}' with generics '{}'", declaredField.getType(), parameterizedTypes);
+ return typeFactory.constructParametricType(declaredField.getType(), parameterizedTypes);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftSerializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftSerializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftSerializer.java
new file mode 100644
index 0000000..c469af6
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/AbstractThriftSerializer.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.core.db.conversion;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.google.common.base.CaseFormat;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TFieldIdEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * This abstract class represents a generic serializer for converting Thrift-based entities
+ * to JSON.
+ *
+ * @param <E> An implementation of the {@link org.apache.thrift.TFieldIdEnum} interface.
+ * @param <T> An implementation of the {@link org.apache.thrift.TBase} interface.
+ */
+public abstract class AbstractThriftSerializer<E extends TFieldIdEnum, T extends TBase<T, E>>
+ extends JsonSerializer<T> {
+
+ private static final Logger log = LoggerFactory.getLogger(AbstractThriftSerializer.class);
+
+ @Override
+ public Class<T> handledType() {
+ return getThriftClass();
+ }
+
+ @Override
+ public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ jgen.writeStartObject();
+ for(final E field : getFieldValues()) {
+ if(value.isSet(field)) {
+ final Object fieldValue = value.getFieldValue(field);
+ if(fieldValue != null) {
+ log.debug("Adding field {} to the JSON string...",
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+ );
+
+ jgen.writeFieldName(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName()));
+ if(fieldValue instanceof Short) {
+ jgen.writeNumber((Short)fieldValue);
+ } else if(fieldValue instanceof Integer) {
+ jgen.writeNumber((Integer)fieldValue);
+ } else if(fieldValue instanceof Long) {
+ jgen.writeNumber((Long)fieldValue);
+ } else if(fieldValue instanceof Double) {
+ jgen.writeNumber((Double)fieldValue);
+ } else if(fieldValue instanceof Float) {
+ jgen.writeNumber((Float)fieldValue);
+ } else if(fieldValue instanceof Boolean) {
+ jgen.writeBoolean((Boolean)fieldValue);
+ } else if(fieldValue instanceof String) {
+ jgen.writeString(fieldValue.toString());
+ } else if(fieldValue instanceof Collection) {
+ log.debug("Array opened for field {}.",
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+ );
+ jgen.writeStartArray();
+ for(final Object arrayObject : (Collection<?>)fieldValue) {
+ jgen.writeObject(arrayObject);
+ }
+ jgen.writeEndArray();
+ log.debug("Array closed for field {}.",
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+ );
+ } else {
+ jgen.writeObject(fieldValue);
+ }
+ } else {
+ log.debug("Skipping converting field {} to JSON: value is null!",
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+ );
+ }
+ } else {
+ log.debug("Skipping converting field {} to JSON: field has not been set!",
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+ );
+ }
+ }
+ jgen.writeEndObject();
+ }
+
+ /**
+ * Returns an array of {@code <E>} enumerated values that represent the fields present in the
+ * Thrift class associated with this serializer.
+ * @return The array of {@code <E>} enumerated values that represent the fields present in the
+ * Thrift class.
+ */
+ protected abstract E[] getFieldValues();
+
+ /**
+ * Returns the {@code <T>} implementation class associated with this serializer.
+ * @return The {@code <T>} implementation class
+ */
+ protected abstract Class<T> getThriftClass();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/ModelConversionHelper.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/ModelConversionHelper.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/ModelConversionHelper.java
new file mode 100644
index 0000000..99dfbfc
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/ModelConversionHelper.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.core.db.conversion;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import org.apache.airavata.data.manager.core.db.conversion.metadata.MetadataDeserializer;
+import org.apache.airavata.data.manager.core.db.conversion.metadata.MetadataSerializer;
+import org.apache.airavata.data.manager.core.db.conversion.transfer.FileTransferRequestDeserializer;
+import org.apache.airavata.data.manager.core.db.conversion.transfer.FileTransferRequestSerializer;
+import org.apache.airavata.data.manager.core.db.conversion.replica.FileCollectionDeserializer;
+import org.apache.airavata.data.manager.core.db.conversion.replica.FileCollectionSerializer;
+import org.apache.airavata.data.manager.core.db.conversion.replica.FileDeserializer;
+import org.apache.airavata.data.manager.core.db.conversion.replica.FileSerializer;
+import org.apache.airavata.model.data.metadata.MetadataModel;
+import org.apache.airavata.model.data.transfer.FileTransferRequestModel;
+import org.apache.airavata.model.data.replica.FileCollectionModel;
+import org.apache.airavata.model.data.replica.FileModel;
+import org.apache.thrift.TBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+
+/**
+ * This is utility class for model conversion of thrift to/from json
+ */
+public class ModelConversionHelper {
+ private final static Logger logger = LoggerFactory.getLogger(ModelConversionHelper.class);
+
+ private ObjectMapper objectMapper;
+
+ public ModelConversionHelper(){
+ init();
+ }
+
+ /**
+ * Private method to register the custom serializers and deserializers
+ */
+ private void init(){
+ this.objectMapper = new ObjectMapper();
+ SimpleModule module = new SimpleModule("DataManager",
+ new Version(1,0,0,null,null,null));
+
+ module.addSerializer(FileTransferRequestModel.class, new FileTransferRequestSerializer());
+ module.addDeserializer(FileTransferRequestModel.class, new FileTransferRequestDeserializer());
+
+ module.addSerializer(FileModel.class, new FileSerializer());
+ module.addDeserializer(FileModel.class, new FileDeserializer());
+
+ module.addSerializer(FileCollectionModel.class, new FileCollectionSerializer());
+ module.addDeserializer(FileCollectionModel.class, new FileCollectionDeserializer());
+
+ module.addSerializer(MetadataModel.class, new MetadataSerializer());
+ module.addDeserializer(MetadataModel.class, new MetadataDeserializer());
+
+ objectMapper.registerModule(module);
+ }
+
+ /**
+ * Method to serialize a thrift object to json
+ * @param object
+ * @return
+ * @throws JsonProcessingException
+ */
+ public String serializeObject(TBase object) throws JsonProcessingException {
+ String json = this.objectMapper.writeValueAsString(object);
+ return json;
+ }
+
+ /**
+ * Method to deserialize a json to the thrift object
+ * @param clz
+ * @param json
+ * @return
+ * @throws IOException
+ */
+ public TBase deserializeObject(Class<?> clz, String json) throws IOException {
+ return (TBase)this.objectMapper.readValue(json, clz);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataDeserializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataDeserializer.java
new file mode 100644
index 0000000..a6ce1b4
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataDeserializer.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.core.db.conversion.metadata;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftDeserializer;
+import org.apache.airavata.model.data.metadata.MetadataModel;
+import org.apache.thrift.TException;
+
+public class MetadataDeserializer extends
+ AbstractThriftDeserializer<MetadataModel._Fields, MetadataModel> {
+
+ @Override
+ protected MetadataModel._Fields getField(final String fieldName) {
+ return MetadataModel._Fields.valueOf(fieldName);
+ }
+
+ @Override
+ protected MetadataModel newInstance() {
+ return new MetadataModel();
+ }
+
+ @Override
+ protected void validate(final MetadataModel instance) throws TException {
+ instance.validate();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataSerializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataSerializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataSerializer.java
new file mode 100644
index 0000000..c07484a
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/metadata/MetadataSerializer.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.core.db.conversion.metadata;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftSerializer;
+import org.apache.airavata.model.data.metadata.MetadataModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MetadataSerializer extends
+ AbstractThriftSerializer<MetadataModel._Fields, MetadataModel> {
+ private final static Logger logger = LoggerFactory.getLogger(MetadataSerializer.class);
+
+ @Override
+ protected MetadataModel._Fields[] getFieldValues() {
+ return MetadataModel._Fields.values();
+ }
+
+ @Override
+ protected Class<MetadataModel> getThriftClass() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionDeserializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionDeserializer.java
new file mode 100644
index 0000000..a34ab1b
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionDeserializer.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.core.db.conversion.replica;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftDeserializer;
+import org.apache.airavata.model.data.replica.FileCollectionModel;
+import org.apache.thrift.TException;
+
+public class FileCollectionDeserializer extends
+ AbstractThriftDeserializer<FileCollectionModel._Fields, FileCollectionModel> {
+
+ @Override
+ protected FileCollectionModel._Fields getField(final String fieldName) {
+ return FileCollectionModel._Fields.valueOf(fieldName);
+ }
+
+ @Override
+ protected FileCollectionModel newInstance() {
+ return new FileCollectionModel();
+ }
+
+ @Override
+ protected void validate(final FileCollectionModel instance) throws TException {
+ instance.validate();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionSerializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionSerializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionSerializer.java
new file mode 100644
index 0000000..56ed65e
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileCollectionSerializer.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.core.db.conversion.replica;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftSerializer;
+import org.apache.airavata.model.data.replica.FileCollectionModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileCollectionSerializer extends
+ AbstractThriftSerializer<FileCollectionModel._Fields, FileCollectionModel> {
+ private final static Logger logger = LoggerFactory.getLogger(FileCollectionSerializer.class);
+
+ @Override
+ protected FileCollectionModel._Fields[] getFieldValues() {
+ return FileCollectionModel._Fields.values();
+ }
+
+ @Override
+ protected Class<FileCollectionModel> getThriftClass() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileDeserializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileDeserializer.java
new file mode 100644
index 0000000..d1e84d5
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileDeserializer.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.core.db.conversion.replica;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftDeserializer;
+import org.apache.airavata.model.data.replica.FileModel;
+import org.apache.thrift.TException;
+
+public class FileDeserializer extends
+ AbstractThriftDeserializer<FileModel._Fields, FileModel> {
+
+ @Override
+ protected FileModel._Fields getField(final String fieldName) {
+ return FileModel._Fields.valueOf(fieldName);
+ }
+
+ @Override
+ protected FileModel newInstance() {
+ return new FileModel();
+ }
+
+ @Override
+ protected void validate(final FileModel instance) throws TException {
+ instance.validate();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileSerializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileSerializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileSerializer.java
new file mode 100644
index 0000000..3a37645
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/replica/FileSerializer.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.core.db.conversion.replica;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftSerializer;
+import org.apache.airavata.model.data.replica.FileModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileSerializer extends
+ AbstractThriftSerializer<FileModel._Fields, FileModel> {
+ private final static Logger logger = LoggerFactory.getLogger(FileSerializer.class);
+
+ @Override
+ protected FileModel._Fields[] getFieldValues() {
+ return FileModel._Fields.values();
+ }
+
+ @Override
+ protected Class<FileModel> getThriftClass() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestDeserializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestDeserializer.java
new file mode 100644
index 0000000..e039d1c
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestDeserializer.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.core.db.conversion.transfer;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftDeserializer;
+import org.apache.airavata.model.data.transfer.FileTransferRequestModel;
+import org.apache.thrift.TException;
+
+public class FileTransferRequestDeserializer extends
+ AbstractThriftDeserializer<FileTransferRequestModel._Fields, FileTransferRequestModel> {
+
+ @Override
+ protected FileTransferRequestModel._Fields getField(final String fieldName) {
+ return FileTransferRequestModel._Fields.valueOf(fieldName);
+ }
+
+ @Override
+ protected FileTransferRequestModel newInstance() {
+ return new FileTransferRequestModel();
+ }
+
+ @Override
+ protected void validate(final FileTransferRequestModel instance) throws TException {
+ instance.validate();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/1ad9ae5d/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestSerializer.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestSerializer.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestSerializer.java
new file mode 100644
index 0000000..0c40d2c
--- /dev/null
+++ b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/db/conversion/transfer/FileTransferRequestSerializer.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.core.db.conversion.transfer;
+
+import org.apache.airavata.data.manager.core.db.conversion.AbstractThriftSerializer;
+import org.apache.airavata.model.data.transfer.FileTransferRequestModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileTransferRequestSerializer extends
+ AbstractThriftSerializer<FileTransferRequestModel._Fields, FileTransferRequestModel> {
+ private final static Logger logger = LoggerFactory.getLogger(FileTransferRequestSerializer.class);
+
+ @Override
+ protected FileTransferRequestModel._Fields[] getFieldValues() {
+ return FileTransferRequestModel._Fields.values();
+ }
+
+ @Override
+ protected Class<FileTransferRequestModel> getThriftClass() {
+ return null;
+ }
+}
\ No newline at end of file