airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [02/16] airavata git commit: refactoring the datacatalog code
Date Tue, 22 Mar 2016 16:37:17 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/SSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/SSHUtils.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/SSHUtils.java
deleted file mode 100644
index 582cade..0000000
--- a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/SSHUtils.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.data.manager.core.ssh;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.*;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Utility class to do all ssh and scp related things.
- */
-public class SSHUtils {
-    private static final Logger log = LoggerFactory.getLogger(SSHUtils.class);
-
-
-    /**
-     * This will copy a local file to a remote location
-     *
-     * @param remoteFile remote location you want to transfer the file, this cannot be a directory, if user pass
-     *                   a dirctory we do copy it to that directory but we simply return the directory name
-     *                   todo handle the directory name as input and return the proper final output file name
-     * @param localFile  Local file to transfer, this can be a directory
-     * @return returns the final remote file path, so that users can use the new file location
-     */
-    public static String scpTo(String localFile, String remoteFile, Session session) throws IOException,
-            JSchException, SSHApiException {
-        FileInputStream fis = null;
-        String prefix = null;
-        if (new File(localFile).isDirectory()) {
-            prefix = localFile + File.separator;
-        }
-        boolean ptimestamp = true;
-
-        // exec 'scp -t rfile' remotely
-        String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + remoteFile;
-        Channel channel = session.openChannel("exec");
-
-        StandardOutReader stdOutReader = new StandardOutReader();
-        ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError());
-        ((ChannelExec) channel).setCommand(command);
-
-        // get I/O streams for remote scp
-        OutputStream out = channel.getOutputStream();
-        InputStream in = channel.getInputStream();
-
-        channel.connect();
-
-        if (checkAck(in) != 0) {
-            String error = "Error Reading input Stream";
-            log.error(error);
-            throw new SSHApiException(error);
-        }
-
-        File _lfile = new File(localFile);
-
-        if (ptimestamp) {
-            command = "T" + (_lfile.lastModified() / 1000) + " 0";
-            // The access time should be sent here,
-            // but it is not accessible with JavaAPI ;-<
-            command += (" " + (_lfile.lastModified() / 1000) + " 0\n");
-            out.write(command.getBytes());
-            out.flush();
-            if (checkAck(in) != 0) {
-                String error = "Error Reading input Stream";
-                log.error(error);
-                throw new SSHApiException(error);
-            }
-        }
-
-        // send "C0644 filesize filename", where filename should not include '/'
-        long filesize = _lfile.length();
-        command = "C0644 " + filesize + " ";
-        if (localFile.lastIndexOf('/') > 0) {
-            command += localFile.substring(localFile.lastIndexOf('/') + 1);
-        } else {
-            command += localFile;
-        }
-        command += "\n";
-        out.write(command.getBytes());
-        out.flush();
-        if (checkAck(in) != 0) {
-            String error = "Error Reading input Stream";
-            log.error(error);
-            throw new SSHApiException(error);
-        }
-
-        // send a content of localFile
-        fis = new FileInputStream(localFile);
-        byte[] buf = new byte[1024];
-        while (true) {
-            int len = fis.read(buf, 0, buf.length);
-            if (len <= 0) break;
-            out.write(buf, 0, len); //out.flush();
-        }
-        fis.close();
-        fis = null;
-        // send '\0'
-        buf[0] = 0;
-        out.write(buf, 0, 1);
-        out.flush();
-        if (checkAck(in) != 0) {
-            String error = "Error Reading input Stream";
-            log.error(error);
-            throw new SSHApiException(error);
-        }
-        out.close();
-        stdOutReader.onOutput(channel);
-
-
-        channel.disconnect();
-        if (stdOutReader.getStdErrorString().contains("scp:")) {
-            throw new SSHApiException(stdOutReader.getStdErrorString());
-        }
-        //since remote file is always a file  we just return the file
-        return remoteFile;
-    }
-
-    /**
-     * This method will copy a remote file to a local directory
-     *
-     * @param remoteFile remote file path, this has to be a full qualified path
-     * @param localFile  This is the local file to copy, this can be a directory too
-     * @return returns the final local file path of the new file came from the remote resource
-     */
-    public static void scpFrom(String remoteFile, String localFile, Session session) throws IOException,
-            JSchException, SSHApiException {
-        FileOutputStream fos = null;
-        try {
-            String prefix = null;
-            if (new File(localFile).isDirectory()) {
-                prefix = localFile + File.separator;
-            }
-
-            // exec 'scp -f remotefile' remotely
-            String command = "scp -f " + remoteFile;
-            Channel channel = session.openChannel("exec");
-            ((ChannelExec) channel).setCommand(command);
-
-            StandardOutReader stdOutReader = new StandardOutReader();
-            ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError());
-            // get I/O streams for remote scp
-            OutputStream out = channel.getOutputStream();
-            InputStream in = channel.getInputStream();
-
-            if (!channel.isClosed()){
-                channel.connect();
-            }
-
-            byte[] buf = new byte[1024];
-
-            // send '\0'
-            buf[0] = 0;
-            out.write(buf, 0, 1);
-            out.flush();
-
-            while (true) {
-                int c = checkAck(in);
-                if (c != 'C') {
-                    break;
-                }
-
-                // read '0644 '
-                in.read(buf, 0, 5);
-
-                long filesize = 0L;
-                while (true) {
-                    if (in.read(buf, 0, 1) < 0) {
-                        // error
-                        break;
-                    }
-                    if (buf[0] == ' ') break;
-                    filesize = filesize * 10L + (long) (buf[0] - '0');
-                }
-
-                String file = null;
-                for (int i = 0; ; i++) {
-                    in.read(buf, i, 1);
-                    if (buf[i] == (byte) 0x0a) {
-                        file = new String(buf, 0, i);
-                        break;
-                    }
-                }
-
-                //System.out.println("filesize="+filesize+", file="+file);
-
-                // send '\0'
-                buf[0] = 0;
-                out.write(buf, 0, 1);
-                out.flush();
-
-                // read a content of lfile
-                fos = new FileOutputStream(prefix == null ? localFile : prefix + file);
-                int foo;
-                while (true) {
-                    if (buf.length < filesize) foo = buf.length;
-                    else foo = (int) filesize;
-                    foo = in.read(buf, 0, foo);
-                    if (foo < 0) {
-                        // error
-                        break;
-                    }
-                    fos.write(buf, 0, foo);
-                    filesize -= foo;
-                    if (filesize == 0L) break;
-                }
-                fos.close();
-                fos = null;
-
-                if (checkAck(in) != 0) {
-                    String error = "Error transfering the file content";
-                    log.error(error);
-                    throw new SSHApiException(error);
-                }
-
-                // send '\0'
-                buf[0] = 0;
-                out.write(buf, 0, 1);
-                out.flush();
-            }
-            stdOutReader.onOutput(channel);
-            if (stdOutReader.getStdErrorString().contains("scp:")) {
-                throw new SSHApiException(stdOutReader.getStdErrorString());
-            }
-
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-        } finally {
-            try {
-                if (fos != null) fos.close();
-            } catch (Exception ee) {
-            }
-        }
-    }
-
-    /**
-     * This method will copy a remote file to a local directory
-     *
-     * @param sourceFile remote file path, this has to be a full qualified path
-     * @param sourceSession JSch session for source
-     * @param destinationFile This is the local file to copy, this can be a directory too
-     * @param destinationSession JSch Session for target
-     * @return returns the final local file path of the new file came from the remote resource
-     */
-    public static void scpThirdParty(String sourceFile, Session sourceSession, String destinationFile, Session destinationSession) throws
-            Exception{
-        OutputStream sout = null;
-        InputStream sin = null;
-        OutputStream dout = null;
-        InputStream din = null;
-        try {
-            String prefix = null;
-
-            // exec 'scp -f sourceFile'
-            String sourceCommand = "scp -f " + sourceFile;
-            Channel sourceChannel = sourceSession.openChannel("exec");
-            ((ChannelExec) sourceChannel).setCommand(sourceCommand);
-            StandardOutReader sourceStdOutReader = new StandardOutReader();
-            ((ChannelExec) sourceChannel).setErrStream(sourceStdOutReader.getStandardError());
-            // get I/O streams for remote scp
-            sout = sourceChannel.getOutputStream();
-            sin = sourceChannel.getInputStream();
-            sourceChannel.connect();
-
-
-            boolean ptimestamp = true;
-            // exec 'scp -t destinationFile'
-            String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + destinationFile;
-            Channel targetChannel = destinationSession.openChannel("exec");
-            StandardOutReader targetStdOutReader = new StandardOutReader();
-            ((ChannelExec) targetChannel).setErrStream(targetStdOutReader.getStandardError());
-            ((ChannelExec) targetChannel).setCommand(command);
-            // get I/O streams for remote scp
-            dout = targetChannel.getOutputStream();
-            din = targetChannel.getInputStream();
-            targetChannel.connect();
-
-            if (checkAck(din) != 0) {
-                String error = "Error Reading input Stream";
-                log.error(error);
-                throw new Exception(error);
-            }
-
-
-            byte[] buf = new byte[1024];
-
-            // send '\0'
-            buf[0] = 0;
-            sout.write(buf, 0, 1);
-            sout.flush();
-
-            while (true) {
-                int c = checkAck(sin);
-                if (c != 'C') {
-                    break;
-                }
-
-                // read '0644 '
-                sin.read(buf, 0, 5);
-
-                long fileSize = 0L;
-                while (true) {
-                    if (sin.read(buf, 0, 1) < 0) {
-                        // error
-                        break;
-                    }
-                    if (buf[0] == ' ') break;
-                    fileSize = fileSize * 10L + (long) (buf[0] - '0');
-                }
-
-                String fileName = null;
-                for (int i = 0; ; i++) {
-                    sin.read(buf, i, 1);
-                    if (buf[i] == (byte) 0x0a) {
-                        fileName = new String(buf, 0, i);
-                        break;
-                    }
-                }
-                String initData = "C0644 " + fileSize + " " + fileName + "\n";
-                assert dout != null;
-                dout.write(initData.getBytes());
-                dout.flush();
-
-                // send '\0' to source
-                buf[0] = 0;
-                sout.write(buf, 0, 1);
-                sout.flush();
-
-                int rLength;
-                while (true) {
-                    if (buf.length < fileSize) rLength = buf.length;
-                    else rLength = (int) fileSize;
-                    rLength = sin.read(buf, 0, rLength); // read content of the source File
-                    if (rLength < 0) {
-                        // error
-                        break;
-                    }
-                    dout.write(buf, 0, rLength); // write to destination file
-                    fileSize -= rLength;
-                    if (fileSize == 0L) break;
-                }
-
-                // send '\0' to target
-                buf[0] = 0;
-                dout.write(buf, 0, 1);
-                dout.flush();
-                if (checkAck(din) != 0) {
-                    String error = "Error Reading input Stream";
-                    log.error(error);
-                    throw new Exception(error);
-                }
-                dout.close();
-                dout = null;
-
-                if (checkAck(sin) != 0) {
-                    String error = "Error transfering the file content";
-                    log.error(error);
-                    throw new Exception(error);
-                }
-
-                // send '\0'
-                buf[0] = 0;
-                sout.write(buf, 0, 1);
-                sout.flush();
-            }
-
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            throw e;
-        } finally {
-            try {
-                if (dout != null) dout.close();
-            } catch (Exception ee) {
-                log.error("", ee);
-            }
-            try {
-                if (din != null) din.close();
-            } catch (Exception ee) {
-                log.error("", ee);
-            }
-            try {
-                if (sout != null) sout.close();
-            } catch (Exception ee) {
-                log.error("", ee);
-            }
-            try {
-                if (din != null) din.close();
-            } catch (Exception ee) {
-                log.error("", ee);
-            }
-        }
-    }
-
-    public static void makeDirectory(String path, Session session) throws IOException, JSchException, SSHApiException {
-
-        // exec 'scp -t rfile' remotely
-        String command = "mkdir -p " + path;
-        Channel channel = session.openChannel("exec");
-        StandardOutReader stdOutReader = new StandardOutReader();
-
-        ((ChannelExec) channel).setCommand(command);
-
-
-        ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError());
-        try {
-            channel.connect();
-        } catch (JSchException e) {
-
-            channel.disconnect();
-//            session.disconnect();
-
-            throw new SSHApiException("Unable to retrieve command output. Command - " + command +
-                    " on server - " + session.getHost() + ":" + session.getPort() +
-                    " connecting user name - "
-                    + session.getUserName(), e);
-        }
-        stdOutReader.onOutput(channel);
-        if (stdOutReader.getStdErrorString().contains("mkdir:")) {
-            throw new SSHApiException(stdOutReader.getStdErrorString());
-        }
-
-        channel.disconnect();
-    }
-
-    public static List<String> listDirectory(String path, Session session) throws IOException, JSchException,
-            SSHApiException {
-
-        // exec 'scp -t rfile' remotely
-        String command = "ls " + path;
-        Channel channel = session.openChannel("exec");
-        StandardOutReader stdOutReader = new StandardOutReader();
-
-        ((ChannelExec) channel).setCommand(command);
-
-
-        ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError());
-        try {
-            channel.connect();
-        } catch (JSchException e) {
-
-            channel.disconnect();
-//            session.disconnect();
-
-            throw new SSHApiException("Unable to retrieve command output. Command - " + command +
-                    " on server - " + session.getHost() + ":" + session.getPort() +
-                    " connecting user name - "
-                    + session.getUserName(), e);
-        }
-        stdOutReader.onOutput(channel);
-        stdOutReader.getStdOutputString();
-        if (stdOutReader.getStdErrorString().contains("ls:")) {
-            throw new SSHApiException(stdOutReader.getStdErrorString());
-        }
-        channel.disconnect();
-        return Arrays.asList(stdOutReader.getStdOutputString().split("\n"));
-    }
-
-
-    static int checkAck(InputStream in) throws IOException {
-        int b = in.read();
-        if (b == 0) return b;
-        if (b == -1) return b;
-
-        if (b == 1 || b == 2) {
-            StringBuffer sb = new StringBuffer();
-            int c;
-            do {
-                c = in.read();
-                sb.append((char) c);
-            }
-            while (c != '\n');
-            if (b == 1) { // error
-                System.out.print(sb.toString());
-            }
-            if (b == 2) { // fatal error
-                System.out.print(sb.toString());
-            }
-        }
-        return b;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/StandardOutReader.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/StandardOutReader.java b/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/StandardOutReader.java
deleted file mode 100644
index c03660b..0000000
--- a/modules/data-manager/data-manager-core/src/main/java/org/apache/airavata/data/manager/core/ssh/StandardOutReader.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.data.manager.core.ssh;
-
-import com.jcraft.jsch.Channel;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class StandardOutReader implements CommandOutput {
-
-    private static final Logger logger = LoggerFactory.getLogger(StandardOutReader.class);
-    String stdOutputString = null;
-    ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
-    private int exitCode;
-
-    public void onOutput(Channel channel) {
-        try {
-            StringBuffer pbsOutput = new StringBuffer("");
-            InputStream inputStream =  channel.getInputStream();
-            byte[] tmp = new byte[1024];
-            do {
-                while (inputStream.available() > 0) {
-                    int i = inputStream.read(tmp, 0, 1024);
-                    if (i < 0) break;
-                    pbsOutput.append(new String(tmp, 0, i));
-                }
-            } while (!channel.isClosed()) ;
-            String output = pbsOutput.toString();
-            this.setStdOutputString(output);
-        } catch (IOException e) {
-            logger.error(e.getMessage(), e);
-        }
-
-    }
-
-
-    public void exitCode(int code) {
-        System.out.println("Program exit code - " + code);
-        this.exitCode = code;
-    }
-
-    @Override
-    public int getExitCode() {
-        return exitCode;
-    }
-
-    public String getStdOutputString() {
-        return stdOutputString;
-    }
-
-    public void setStdOutputString(String stdOutputString) {
-        this.stdOutputString = stdOutputString;
-    }
-
-    public String getStdErrorString() {
-        return errorStream.toString();
-    }
-
-    public OutputStream getStandardError() {
-        return errorStream;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerFactoryTest.java b/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerFactoryTest.java
deleted file mode 100644
index 359c286..0000000
--- a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerFactoryTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.aoache.airavata.data.manager.core;
-
-import junit.framework.Assert;
-import org.apache.airavata.data.manager.core.DataManagerImpl;
-import org.apache.airavata.data.manager.cpi.DataManager;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.AppCatalog;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.apache.airavata.registry.cpi.DataCatalog;
-import org.apache.airavata.registry.cpi.DataCatalogException;
-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 DataCatalogException, DataCatalogException, AppCatalogException {
-        DataCatalog dataCatalog = RegistryFactory.getDataCatalog();
-        AppCatalog appCatalog = RegistryFactory.getAppCatalog();
-        DataManager dataManagerImpl = new DataManagerImpl(appCatalog, dataCatalog);
-        Assert.assertNotNull(dataManagerImpl);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerImplTest.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerImplTest.java b/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerImplTest.java
deleted file mode 100644
index 42c4091..0000000
--- a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/DataManagerImplTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.aoache.airavata.data.manager.core;
-
-import org.apache.airavata.data.manager.core.DataManagerImpl;
-import org.apache.airavata.data.manager.cpi.DataManagerException;
-import org.aoache.airavata.data.manager.core.utils.AppCatInit;
-import org.aoache.airavata.data.manager.core.utils.DataCatInit;
-import org.apache.airavata.model.data.resource.DataReplicaLocationModel;
-import org.apache.airavata.model.data.resource.DataResourceModel;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.AppCatalog;
-import org.apache.airavata.registry.cpi.DataCatalog;
-import org.apache.airavata.data.manager.cpi.DataManager;
-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.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;
-    private static DataReplicaLocationModel dataReplicaLocationModel;
-
-    @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();
-            AppCatalog appCatalog = RegistryFactory.getAppCatalog();
-            DataCatalog dataCatalog = RegistryFactory.getDataCatalog();
-            DataManagerImplTest.dataManager = new DataManagerImpl(appCatalog, dataCatalog);
-            dataResourceModel = new DataResourceModel();
-            dataResourceModel.setResourceName("test-file.txt");
-            dataReplicaLocationModel = new DataReplicaLocationModel();
-            dataReplicaLocationModel.setReplicaName("1-st-replica");
-        } catch (Exception 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.registerResource(dataResourceModel);
-            org.junit.Assert.assertNotNull(resourceId);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testRemoveDataResource(){
-        try {
-            boolean result = dataManager.removeResource("234234234");
-            Assert.assertFalse(result);
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            Assert.assertNotNull(resourceId);
-            result = dataManager.removeResource(resourceId);
-            Assert.assertTrue(result);
-            result = dataManager.removeResource(resourceId);
-            Assert.assertFalse(result);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testGetDataResource(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            Assert.assertNotNull(resourceId);
-            DataResourceModel persistedCopy = dataManager.getResource(resourceId);
-            Assert.assertNotNull(persistedCopy);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testUpdateDataResource(){
-        try {
-            dataResourceModel.setResourceId(UUID.randomUUID().toString());
-            boolean result = dataManager.updateResource(dataResourceModel);
-            Assert.assertFalse(result);
-            dataManager.registerResource(dataResourceModel);
-            dataResourceModel.setResourceName("updated-name");
-            dataManager.updateResource(dataResourceModel);
-            dataResourceModel = dataManager.getResource(dataResourceModel.getResourceId());
-            Assert.assertTrue(dataResourceModel.getResourceName().equals("updated-name"));
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testPublishReplicaLocation(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            dataReplicaLocationModel.setResourceId(resourceId);
-            String replicaId = dataManager.registerReplicaLocation(dataReplicaLocationModel);
-            org.junit.Assert.assertNotNull(replicaId);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testRemoveReplicaLocation(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            dataReplicaLocationModel.setResourceId(resourceId);
-            String replicaId = dataManager.registerReplicaLocation(dataReplicaLocationModel);
-            boolean result = dataManager.removeReplicaLocation(replicaId);
-            Assert.assertTrue(result);
-            result = dataManager.removeReplicaLocation(dataReplicaLocationModel.getReplicaId());
-            Assert.assertFalse(result);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testGetReplicaLocation(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            dataReplicaLocationModel.setResourceId(resourceId);
-            String replicaId = dataManager.registerReplicaLocation(dataReplicaLocationModel);
-            DataReplicaLocationModel persistedCopy = dataManager.getReplicaLocation(replicaId);
-            Assert.assertNotNull(persistedCopy);
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testUpdateReplicaLocation(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            dataReplicaLocationModel.setResourceId(resourceId);
-            String replicaId = dataManager.registerReplicaLocation(dataReplicaLocationModel);
-            DataReplicaLocationModel persistedCopy = dataManager.getReplicaLocation(replicaId);
-            persistedCopy.setReplicaDescription("updated-description");
-            dataManager.updateReplicaLocation(persistedCopy);
-            persistedCopy = dataManager.getReplicaLocation(replicaId);
-            Assert.assertTrue(persistedCopy.getReplicaDescription().equals("updated-description"));
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void testGetAllReplicaLocations(){
-        try {
-            String resourceId = dataManager.registerResource(dataResourceModel);
-            dataReplicaLocationModel.setResourceId(resourceId);
-            String replicaId = dataManager.registerReplicaLocation(dataReplicaLocationModel);
-            List<DataReplicaLocationModel> replicaLocationModelList = dataManager.getAllReplicaLocations(resourceId);
-            Assert.assertTrue(replicaLocationModelList.get(0).getReplicaId().equals(replicaId));
-        } catch (DataManagerException e) {
-            e.printStackTrace();
-            Assert.fail();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/AppCatInit.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/AppCatInit.java b/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/AppCatInit.java
deleted file mode 100644
index cdeb0ce..0000000
--- a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/AppCatInit.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.aoache.airavata.data.manager.core.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/a963d3f0/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/DataCatInit.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/DataCatInit.java b/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/DataCatInit.java
deleted file mode 100644
index d1c8491..0000000
--- a/modules/data-manager/data-manager-core/src/test/java/org/aoache/airavata/data/manager/core/utils/DataCatInit.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.aoache.airavata.data.manager.core.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/a963d3f0/modules/data-manager/data-manager-cpi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-cpi/pom.xml b/modules/data-manager/data-manager-cpi/pom.xml
deleted file mode 100644
index 93137ef..0000000
--- a/modules/data-manager/data-manager-cpi/pom.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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-cpi</artifactId>
-    <packaging>jar</packaging>
-    <name>Airavata Data Manager CPI</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-commons</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManager.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManager.java b/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManager.java
deleted file mode 100644
index fd06f8c..0000000
--- a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManager.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.airavata.data.manager.cpi;
-
-import org.apache.airavata.model.data.resource.DataReplicaLocationModel;
-import org.apache.airavata.model.data.resource.DataResourceModel;
-
-import java.util.List;
-
-public interface DataManager {
-
-    /**
-     * To create a new dataResourceModel. This is how the system comes to know about already
-     * existing resources
-     * @param dataResourceModel
-     * @return
-     */
-    String registerResource(DataResourceModel dataResourceModel) throws DataManagerException;
-
-    /**
-     * To remove a resource entry from the replica catalog
-     * @param resourceId
-     * @return
-     */
-    boolean removeResource(String resourceId) throws DataManagerException;
-
-
-    /**
-     * To update an existing data resource model
-     * @param dataResourceModel
-     * @return
-     * @throws DataManagerException
-     */
-    boolean updateResource(DataResourceModel dataResourceModel) throws DataManagerException;
-
-    /**
-     * To retrieve a resource object providing the resourceId
-     * @param resourceId
-     * @return
-     */
-    DataResourceModel getResource(String resourceId) throws DataManagerException;
-
-    /**
-     * To create a new data replica location. This is how the system comes to know about already
-     * existing resources
-     * @param dataReplicaLocationModel
-     * @return
-     */
-    String registerReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataManagerException;
-
-    /**
-     * To remove a replica entry from the replica catalog
-     * @param replicaId
-     * @return
-     */
-    boolean removeReplicaLocation(String replicaId) throws DataManagerException;
-
-    /**
-     * To update an existing data replica model
-     * @param dataReplicaLocationModel
-     * @return
-     * @throws DataManagerException
-     */
-    boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataManagerException;
-
-    /**
-     * To retrieve a replica object providing the replicaId
-     * @param replicaId
-     * @return
-     */
-    DataReplicaLocationModel getReplicaLocation(String replicaId) throws DataManagerException;
-
-    /**
-     * To retrieve all the replica entries for a given resource id
-     * @param resourceId
-     * @return
-     * @throws DataCatalogException
-     */
-    List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws DataManagerException;
-
-
-    /**
-     * API method to copy a resource to the provided destination storage resource. Only resources of type FILE can be
-     * copied using this API method. Method returns the new replicaId.
-     * @param dataResourceId
-     * @param destStorageResourceId
-     * @param destinationParentPath
-     * @return
-     */
-    String copyResource(String dataResourceId, String destStorageResourceId, String destinationParentPath) throws DataManagerException;
-
-    /**
-     * API method to copy the specified replica to the provided destination storage resource. Only resources of type FILE
-     * can be copied using this API method. Method returns the new replicaId
-     * @param dataResourceId
-     * @param replicaId
-     * @param destStorageResourceId
-     * @param destinationParentPath
-     * @return
-     * @throws DataManagerException
-     */
-    String copyReplica(String dataResourceId, String replicaId, String destStorageResourceId, String destinationParentPath) throws DataManagerException;
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerConstants.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerConstants.java b/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerConstants.java
deleted file mode 100644
index d46604a..0000000
--- a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerConstants.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.data.manager.cpi;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataManagerConstants {
-    private final static Logger logger = LoggerFactory.getLogger(DataManagerConstants.class);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerException.java
----------------------------------------------------------------------
diff --git a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerException.java b/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerException.java
deleted file mode 100644
index b1c1cb8..0000000
--- a/modules/data-manager/data-manager-cpi/src/main/java/org/apache/airavata/data/manager/cpi/DataManagerException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.airavata.data.manager.cpi;
-
-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/a963d3f0/modules/data-manager/pom.xml
----------------------------------------------------------------------
diff --git a/modules/data-manager/pom.xml b/modules/data-manager/pom.xml
deleted file mode 100644
index eb81d40..0000000
--- a/modules/data-manager/pom.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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>pom</packaging>
-    <name>Airavata Data Manager</name>
-    <url>http://airavata.apache.org/</url>
-
-    <modules>
-        <module>data-manager-cpi</module>
-        <module>data-manager-core</module>
-    </modules>
-    <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.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/a963d3f0/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
index f596980..887b6d0 100644
--- 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
@@ -21,11 +21,11 @@
 
 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.model.data.product.DataProductModel;
+import org.apache.airavata.model.data.product.DataReplicaLocationModel;
+import org.apache.airavata.registry.core.data.catalog.model.DataProduct;
 import org.apache.airavata.registry.core.data.catalog.model.DataReplicaLocation;
 import org.apache.airavata.registry.core.data.catalog.utils.DataCatalogJPAUtils;
-import org.apache.airavata.registry.core.data.catalog.model.DataResource;
 import org.apache.airavata.registry.core.data.catalog.utils.ThriftDataModelConversion;
 import org.apache.airavata.registry.cpi.DataCatalog;
 import org.apache.airavata.registry.cpi.DataCatalogException;
@@ -42,28 +42,28 @@ public class DataCatalogImpl implements DataCatalog {
     private final static Logger logger = LoggerFactory.getLogger(DataCatalogImpl.class);
 
     @Override
-    public String registerResource(DataResourceModel resourceModel) throws DataCatalogException {
-        String resourceId = UUID.randomUUID().toString();
-        resourceModel.setResourceId(resourceId);
+    public String registerDataProduct(DataProductModel productModel) throws DataCatalogException {
+        String productId = UUID.randomUUID().toString();
+        productModel.setProductId(productId);
         long currentTime = System.currentTimeMillis();
-        resourceModel.setCreationTime(currentTime);
-        resourceModel.setLastModifiedTime(currentTime);
-        if(resourceModel.getReplicaLocations() != null){
-            resourceModel.getReplicaLocations().stream().forEach(r-> {
-                r.setResourceId(resourceId);
+        productModel.setCreationTime(currentTime);
+        productModel.setLastModifiedTime(currentTime);
+        if(productModel.getReplicaLocations() != null){
+            productModel.getReplicaLocations().stream().forEach(r-> {
+                r.setProductId(productId);
                 r.setReplicaId(UUID.randomUUID().toString());
                 r.setCreationTime(currentTime);
                 r.setLastModifiedTime(currentTime);
             });
         }
-        resourceModel.setCreationTime(System.currentTimeMillis());
-        resourceModel.setLastModifiedTime(System.currentTimeMillis());
-        DataResource dataResource = ThriftDataModelConversion.getDataResource(resourceModel);
+        productModel.setCreationTime(System.currentTimeMillis());
+        productModel.setLastModifiedTime(System.currentTimeMillis());
+        DataProduct dataProduct = ThriftDataModelConversion.getDataProduct(productModel);
         EntityManager em = null;
         try {
             em = DataCatalogJPAUtils.getEntityManager();
             em.getTransaction().begin();
-            em.persist(dataResource);
+            em.persist(dataProduct);
             em.getTransaction().commit();
             em.close();
         } catch (Exception e) {
@@ -77,19 +77,19 @@ public class DataCatalogImpl implements DataCatalog {
                 em.close();
             }
         }
-        return resourceId;
+        return productId;
     }
 
     @Override
-    public boolean removeResource(String resourceId) throws DataCatalogException {
+    public boolean removeDataProduct(String productId) throws DataCatalogException {
         EntityManager em = null;
         try {
             em = DataCatalogJPAUtils.getEntityManager();
-            DataResource dataResource = em.find(DataResource.class, resourceId);
-            if(dataResource == null)
+            DataProduct dataProduct = em.find(DataProduct.class, productId);
+            if(dataProduct == null)
                 return false;
             em.getTransaction().begin();
-            em.remove(dataResource);
+            em.remove(dataProduct);
             em.getTransaction().commit();
             em.close();
         } catch (Exception e) {
@@ -107,17 +107,17 @@ public class DataCatalogImpl implements DataCatalog {
     }
 
     @Override
-    public boolean updateResource(DataResourceModel resourceModel) throws DataCatalogException {
+    public boolean updateDataProduct(DataProductModel productModel) throws DataCatalogException {
         EntityManager em = null;
         try {
             em = DataCatalogJPAUtils.getEntityManager();
-            DataResource dataResource = em.find(DataResource.class, resourceModel.getResourceId());
-            if(dataResource == null)
+            DataProduct dataProduct = em.find(DataProduct.class, productModel.getProductId());
+            if(dataProduct == null)
                 return false;
             em.getTransaction().begin();
-            resourceModel.setCreationTime(dataResource.getCreationTime().getTime());
-            resourceModel.setLastModifiedTime(System.currentTimeMillis());
-            em.merge(ThriftDataModelConversion.getUpdatedDataResource(resourceModel, dataResource));
+            productModel.setCreationTime(dataProduct.getCreationTime().getTime());
+            productModel.setLastModifiedTime(System.currentTimeMillis());
+            em.merge(ThriftDataModelConversion.getUpdatedDataProduct(productModel, dataProduct));
             em.getTransaction().commit();
             em.close();
         } catch (Exception e) {
@@ -135,12 +135,12 @@ public class DataCatalogImpl implements DataCatalog {
     }
 
     @Override
-    public DataResourceModel getResource(String resourceId) throws DataCatalogException {
+    public DataProductModel getDataProduct(String productId) throws DataCatalogException {
         EntityManager em = null;
         try {
             em = DataCatalogJPAUtils.getEntityManager();
-            DataResource dataResource = em.find(DataResource.class, resourceId);
-            return ThriftDataModelConversion.getDataResourceModel(dataResource);
+            DataProduct dataProduct = em.find(DataProduct.class, productId);
+            return ThriftDataModelConversion.getDataProductModel(dataProduct);
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new DataCatalogException(e);
@@ -260,15 +260,16 @@ public class DataCatalogImpl implements DataCatalog {
     }
 
     @Override
-    public List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws DataCatalogException {
+    public List<DataReplicaLocationModel> getAllReplicaLocations(String
+                                                                             productId) throws DataCatalogException {
         EntityManager em = null;
         try {
             em = DataCatalogJPAUtils.getEntityManager();
-            DataResource dataResource = em.find(DataResource.class, resourceId);
-            if(dataResource == null)
+            DataProduct dataProduct = em.find(DataProduct.class, productId);
+            if(dataProduct == null)
                 return null;
             ArrayList<DataReplicaLocationModel> dataReplicaLocationModels = new ArrayList<>();
-            dataResource.getDataReplicaLocations().stream().forEach(rl->dataReplicaLocationModels
+            dataProduct.getDataReplicaLocations().stream().forEach(rl->dataReplicaLocationModels
                     .add(ThriftDataModelConversion.getDataReplicaLocationModel(rl)));
             return dataReplicaLocationModels;
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProduct.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProduct.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProduct.java
new file mode 100644
index 0000000..52ea8c7
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProduct.java
@@ -0,0 +1,177 @@
+/*
+ *
+ * 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_PRODUCT")
+public class DataProduct {
+    private final static Logger logger = LoggerFactory.getLogger(DataProduct.class);
+    private String resourceId;
+    private String gatewayId;
+    private String productName;
+    private String productDescription;
+    private String dataProductType;
+    private String ownerName;
+    private String parentProductId;
+    private int productSize;
+    private Timestamp creationTime;
+    private Timestamp lastModifiedTime;
+
+    private DataProduct parentDataProduct;
+    private Collection<DataReplicaLocation> dataReplicaLocations;
+    private Collection<DataProductMetaData> dataProductMetaData;
+    private Collection<DataProduct> childDataProducts;
+
+    @Id
+    @Column(name = "PRODUCT_ID")
+    public String getResourceId() {
+        return resourceId;
+    }
+
+    public void setResourceId(String resourceId) {
+        this.resourceId = resourceId;
+    }
+
+    @Column(name = "GATEWAY_ID")
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    @Column(name = "PRODUCT_NAME")
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    @Column(name = "PRODUCT_DESCRIPTION")
+    public String getProductDescription() {
+        return productDescription;
+    }
+
+    public void setProductDescription(String productDescription) {
+        this.productDescription = productDescription;
+    }
+
+    @Column(name = "OWNER_NAME")
+    public String getOwnerName() {
+        return ownerName;
+    }
+
+    public void setOwnerName(String ownerName) {
+        this.ownerName = ownerName;
+    }
+
+    @Column(name = "PARENT_PRODUCT_ID")
+    public String getParentProductId() {
+        return parentProductId;
+    }
+
+    public void setParentProductId(String parentProductId) {
+        this.parentProductId = parentProductId;
+    }
+
+    @Column(name = "PRODUCT_TYPE")
+    public String getDataProductType() {
+        return dataProductType;
+    }
+
+    public void setDataProductType(String dataProductType) {
+        this.dataProductType = dataProductType;
+    }
+
+    @Column(name = "PRODUCT_SIZE")
+    public int getProductSize() {
+        return productSize;
+    }
+
+    public void setProductSize(int productSize) {
+        this.productSize = productSize;
+    }
+
+    @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 = "dataProduct", cascade = {CascadeType.ALL})
+    public Collection<DataReplicaLocation> getDataReplicaLocations() {
+        return dataReplicaLocations;
+    }
+
+    public void setDataReplicaLocations(Collection<DataReplicaLocation> dataReplicaLocations) {
+        this.dataReplicaLocations = dataReplicaLocations;
+    }
+
+    @OneToMany(mappedBy = "dataProduct", cascade = {CascadeType.ALL})
+    public Collection<DataProductMetaData> getDataProductMetaData() {
+        return dataProductMetaData;
+    }
+
+    public void setDataProductMetaData(Collection<DataProductMetaData> dataProductMetaData) {
+        this.dataProductMetaData = dataProductMetaData;
+    }
+
+    @ManyToOne
+    @JoinColumn(name = "PARENT_PRODUCT_ID", referencedColumnName = "PRODUCT_ID")
+    public DataProduct getParentDataProduct() {
+        return parentDataProduct;
+    }
+
+    public void setParentDataProduct(DataProduct parentDataProduct) {
+        this.parentDataProduct = parentDataProduct;
+    }
+
+    @OneToMany(mappedBy = "parentDataProduct", cascade = {CascadeType.ALL})
+    public Collection<DataProduct> getChildDataProducts() {
+        return childDataProducts;
+    }
+
+    public void setChildDataProducts(Collection<DataProduct> childDataProducts) {
+        this.childDataProducts = childDataProducts;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a963d3f0/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProductMetaData.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProductMetaData.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProductMetaData.java
new file mode 100644
index 0000000..8285fcf
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataProductMetaData.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.*;
+
+@Entity
+@Table(name = "DATA_PRODUCT_METADATA")
+@IdClass(DataProductMetaData_PK.class)
+public class DataProductMetaData {
+    private final static Logger logger = LoggerFactory.getLogger(DataProductMetaData.class);
+    private String productId;
+    private String key;
+    private String value;
+
+    private DataProduct dataProduct;
+
+    @Id
+    @Column(name = "PRODUCT_ID")
+    public String getProductId() {
+        return productId;
+    }
+
+    public void setProductId(String productId) {
+        this.productId = productId;
+    }
+
+    @Id
+    @Column(name = "METADATA_KEY")
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    @Column(name = "METADATA_VALUE")
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    @ManyToOne
+    @JoinColumn(name = "PRODUCT_ID", referencedColumnName = "PRODUCT_ID")
+    public DataProduct getDataProduct() {
+        return dataProduct;
+    }
+
+    public void setDataProduct(DataProduct dataProduct) {
+        this.dataProduct = dataProduct;
+    }
+}
\ No newline at end of file


Mime
View raw message