airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [11/32] airavata-sandbox git commit: adding datacat system
Date Mon, 24 Aug 2015 19:28:49 GMT
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParser.java
----------------------------------------------------------------------
diff --git a/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParser.java b/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParser.java
new file mode 100644
index 0000000..2dbbdd5
--- /dev/null
+++ b/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParser.java
@@ -0,0 +1,114 @@
+package org.apache.airavata.datacat.regexParser;
+
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.models.OutputMonitorMessage;
+import org.apache.airavata.datacat.parsers.DefaultParser;
+import org.apache.airavata.datacat.parsers.IParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class RegexParser extends DefaultParser implements IParser {
+    private static Logger log = LoggerFactory.getLogger(RegexParser.class);
+    private Map<String, String> regexMap;
+
+    /**
+     * parses a file using the provided regular expression
+     * @param file
+     * @param regex
+     * @return (String) extracted value
+     * @throws IOException
+     */
+    public String parseRegex(String file, String regex) throws IOException {
+        String fileContent = readFile(file, null);
+        Pattern p = Pattern.compile(regex);
+        Matcher m = p.matcher(fileContent);
+
+        String result = "";
+        while (m.find() && m.find()) {
+
+            //return one value
+            if (m.groupCount() == 1)
+                result = m.group(1);
+
+            //allowing it to return a string of values
+            else if (m.groupCount() > 1)
+                for (int i = 0; i < m.groupCount(); i++)
+                    result = m.group(i) + "\t";
+            else
+                result = null;
+        }
+        return result;
+    }
+
+    /**
+     * Reads a file
+     * @param path
+     * @param encoding
+     * @return the file converted to a String
+     * @throws IOException
+     */
+    private String readFile(String path, Charset encoding)
+            throws IOException {
+        if (encoding == null) {
+            encoding = Charset.defaultCharset();
+        }
+        byte[] encoded = Files.readAllBytes(Paths.get(path));
+        return new String(encoded, encoding);
+    }
+
+    /**
+     * Parses the file
+     * @param outputMonitorMessage
+     * @return OutputMetadataDTO
+     */
+    @Override
+    public OutputMetadataDTO parse(OutputMonitorMessage outputMonitorMessage) {
+        OutputMetadataDTO outputMetadataDTO = super.parse(outputMonitorMessage);
+        HashMap<String, String> customMetadata = new HashMap<>();
+
+        //looking for the gaussian output files
+        String[] outPutFiles = (new File(outputMonitorMessage.getOutputPath())).list(new FilenameFilter() {
+            public boolean accept(File dir, String filename) {
+                return filename.endsWith(".out");
+            }
+        });
+        if (outPutFiles != null && outPutFiles.length > 0) {
+            String outFile = outputMonitorMessage.getOutputPath() + File.separator + outPutFiles[0];
+            String uniqueID = UUID.randomUUID().toString();
+
+            //parsing the file using regex
+            String result = "";
+
+            //reading the regexes provided in the properties file
+            regexMap = RegexParserProperties.getInstance().getRegexMap();
+            for (Map.Entry<String, String> entry : regexMap.entrySet()) {
+                try {
+                    result = parseRegex(outFile, entry.getValue());
+                    if (result == null || result.length() < 1)
+                        continue;
+                } catch (IOException e) {
+                    log.error("Error occured while parsing the regex " + e.toString());
+                }
+                customMetadata.put(entry.getKey(), result);
+            }
+        }
+        outputMetadataDTO.setCustomMetaData(customMetadata);
+
+        return outputMetadataDTO;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParserProperties.java
----------------------------------------------------------------------
diff --git a/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParserProperties.java b/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParserProperties.java
new file mode 100644
index 0000000..53d12ce
--- /dev/null
+++ b/datacat/regexParser/src/main/java/org/apache/airavata/datacat/regexParser/RegexParserProperties.java
@@ -0,0 +1,86 @@
+package org.apache.airavata.datacat.regexParser;
+
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class RegexParserProperties {
+
+    //location of the properties file
+    public static final String REGEX_PARSER_PROPERTIES = "../conf/regexParser.properties";
+    public static final String DEFAULT_REGEX_PARSER_PROPERTIES = "regexParser.properties";
+
+    private static RegexParserProperties instance;
+
+    private final Logger logger = LogManager.getLogger(RegexParserProperties.class);
+    private Map<String, String> properties;
+    private Map<String, String> regexMap;
+
+    // the singleton method for the RegexParserConstructor
+    public static RegexParserProperties getInstance() {
+        if (instance == null) {
+            instance = new RegexParserProperties();
+        }
+        return instance;
+    }
+
+    private RegexParserProperties() {
+        try {
+            //resolute the correct property file
+            InputStream fileInput;
+            if (new File(REGEX_PARSER_PROPERTIES).exists()) {
+                fileInput = new FileInputStream(REGEX_PARSER_PROPERTIES);
+            } else {
+                fileInput = ClassLoader.getSystemResource(DEFAULT_REGEX_PARSER_PROPERTIES).openStream();
+            }
+            //load the properties file and extract the regular expressions as a Hashmap
+            this.properties = getProperties(fileInput);
+            fileInput.close();
+
+            //initialize the map of regular expressions
+            this.regexMap = new HashMap<String, String>();
+            try {
+                for (Map.Entry<String, String> entry : this.properties.entrySet()) {
+                    this.regexMap.put(entry.getKey(), entry.getValue());
+                }
+            } catch (Exception e) {
+                logger.error("Error occured while reading regexes from file " + e.getMessage());
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This method reads an input stream, and returns the regular expressions as a Map
+     * @param fileInputStream
+     * @return Map of regular expressions with the provided tokens
+     * @throws IOException
+     */
+    private Map<String, String> getProperties(InputStream fileInputStream) throws IOException {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
+        String line;
+        Map<String, String> result = new HashMap<String, String>();
+        while ((line = reader.readLine()) != null) {
+            if (line.trim().length() == 0 || line.startsWith("#"))
+                continue;
+
+            //extract the key value pairs of the property file
+            String key = line.replaceFirst("([^=]+)=(.*)", "$1");
+            String val = line.replaceFirst("([^=]+)=(.*)", "$2");
+            result.put(key, val);
+
+        }
+        reader.close();
+        return result;
+    }
+
+    public Map<String, String> getRegexMap() {
+        return regexMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/regexParser/src/main/resources/regexParser.properties
----------------------------------------------------------------------
diff --git a/datacat/regexParser/src/main/resources/regexParser.properties b/datacat/regexParser/src/main/resources/regexParser.properties
new file mode 100644
index 0000000..3464bf5
--- /dev/null
+++ b/datacat/regexParser/src/main/resources/regexParser.properties
@@ -0,0 +1,9 @@
+#here you can specify which details to extract by
+#<key_value>=<regex>
+#ex: RMS FORCE=RMS\s+Force\s+(\d*\.?\d*)
+
+RMS_Force = RMS\s+Force\s+(\d*\.?\d*)
+Maximum_Force = Maximum\s+Force\s+(\d*\.?\d*)
+Maximum_Displacement =  Maximum\s+Displacement\s+(\d*\.?\d*)
+RMS_Displacement  = RMS\s+Displacement\s+(\d*\.?\d*)
+Energy = Predicted\s+change\s+in\s+Energy=(.*)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/regexParser/src/test/java/org/apache/airavata/datacat/regexParser/RegexParserTest.java
----------------------------------------------------------------------
diff --git a/datacat/regexParser/src/test/java/org/apache/airavata/datacat/regexParser/RegexParserTest.java b/datacat/regexParser/src/test/java/org/apache/airavata/datacat/regexParser/RegexParserTest.java
new file mode 100644
index 0000000..10d6c4d
--- /dev/null
+++ b/datacat/regexParser/src/test/java/org/apache/airavata/datacat/regexParser/RegexParserTest.java
@@ -0,0 +1,57 @@
+package org.apache.airavata.datacat.regexParser;
+
+import junit.framework.Assert;
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.models.OutputMonitorMessage;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class RegexParserTest {
+    private static Logger log = LoggerFactory.getLogger(RegexParserTest.class);
+
+    // Configure the output files here
+    private final static String FILEPATH = "/data-root/scnakandala/Gaussian/Regex_test_6IDontNeedaNode_1db684c9-8641-472a-8e85-0aaebc37d6ff/";
+    private final static String FILE = "/data-root/scnakandala/Gaussian/Regex_test_6IDontNeedaNode_1db684c9-8641-472a-8e85-0aaebc37d6ff/gaussian1.out";
+
+    private RegexParser regexParser;
+
+    @Before
+    public void setup() {
+        regexParser = new RegexParser();
+    }
+
+    /*
+     * This method tests the complete functionality of the regexParser
+     *
+     */
+    @Test
+    public void testParser() {
+        //create a dummy output monitor message
+        OutputMonitorMessage message = new OutputMonitorMessage();
+        message.setApplicationName("Gaussian");
+        message.setOutputPath(FILEPATH);
+        message.setExperimentID("Sachith");
+
+        //parse it to the parser
+        OutputMetadataDTO outputMetadataDTO = regexParser.parse(message);
+
+        System.out.println(String.valueOf(outputMetadataDTO.getCustomMetaData().entrySet()));
+        Assert.assertNotNull(outputMetadataDTO.getCustomMetaData().entrySet());
+
+    }
+
+    /*
+    * This method tests if the parseRegex Method works properly
+     */
+    @Test
+    public void testParseRegex() throws IOException {
+        String s = regexParser.parseRegex(FILE, "RMS\\s+Force\\s+(\\d*\\.?\\d*)");
+        log.debug(s);
+        Assert.assertNotNull(s);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/pom.xml
----------------------------------------------------------------------
diff --git a/datacat/server/pom.xml b/datacat/server/pom.xml
new file mode 100644
index 0000000..fb22ffe
--- /dev/null
+++ b/datacat/server/pom.xml
@@ -0,0 +1,168 @@
+<?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>datacat</artifactId>
+        <groupId>org.apache.airavata.datacat</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>server</artifactId>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>${jdk.version}</source>
+                    <target>${jdk.version}</target>
+                    <compilerArgument>-Xlint:unchecked</compilerArgument>
+                    <optimize>true</optimize>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.airavata.datacat.server.DataCatServer</mainClass>
+                            <addClasspath>true</addClasspath>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.3</version>
+                <executions>
+                    <execution>
+                        <id>distribution-package</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>src/main/assembly/bin-assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <repositories>
+        <!--These are needed for Jersey -->
+        <repository>
+            <id>maven2-repository.dev.java.net</id>
+            <name>Java.net Repository for Maven</name>
+            <url>http://download.java.net/maven/2/</url>
+            <layout>default</layout>
+        </repository>
+        <repository>
+            <id>maven-repository.dev.java.net</id>
+            <name>Java.net Maven 1 Repository (legacy)</name>
+            <url>http://download.java.net/maven/1</url>
+            <layout>legacy</layout>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata.datacat</groupId>
+            <artifactId>models</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.solr</groupId>
+            <artifactId>solr-solrj</artifactId>
+            <version>${solrj.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.3</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-framework</artifactId>
+            <version>2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.0-m09</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-common</artifactId>
+            <version>2.0-m05-1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-server</artifactId>
+            <version>2.0-m05-1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-grizzly2-http</artifactId>
+            <version>2.0-m05-1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <version>${curator.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-x-discovery</artifactId>
+            <version>${curator.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
+
+        <!--dependencies required for user api-->
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.authenticator.stub</artifactId>
+            <version>${carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.um.ws.api.stub</artifactId>
+            <version>${carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.um.ws.api</artifactId>
+            <version>${carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2-client</artifactId>
+            <version>${axis2.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.authenticator.stub</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/assembly/bin-assembly.xml
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/assembly/bin-assembly.xml b/datacat/server/src/main/assembly/bin-assembly.xml
new file mode 100644
index 0000000..d916d35
--- /dev/null
+++ b/datacat/server/src/main/assembly/bin-assembly.xml
@@ -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.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>bin</id>
+    <includeBaseDirectory>true</includeBaseDirectory>
+    <baseDirectory>datacat-server</baseDirectory>
+    <formats>
+        <format>tar.gz</format>
+        <format>zip</format>
+    </formats>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/resources/bin</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>*.sh</include>
+            </includes>
+            <fileMode>755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/conf</directory>
+            <outputDirectory>conf</outputDirectory>
+            <includes>
+                <include>*.properties</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/security</directory>
+            <outputDirectory>security</outputDirectory>
+            <includes>
+                <include>*.jks</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources</directory>
+            <outputDirectory>conf</outputDirectory>
+            <includes>
+                <include>log4j.properties</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>../solr-server</directory>
+            <outputDirectory>solr-server</outputDirectory>
+            <includes>
+                <include>**/*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <includes>
+                <include>*:jar:*</include>
+            </includes>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/DataCatServer.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/DataCatServer.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/DataCatServer.java
new file mode 100644
index 0000000..11483bd
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/DataCatServer.java
@@ -0,0 +1,203 @@
+/*
+*
+* 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.datacat.server;
+
+import org.apache.airavata.datacat.server.services.DataCatService;
+import org.apache.airavata.datacat.server.services.PublisherService;
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.airavata.datacat.server.util.ServerProperties;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.ExponentialBackoffRetry;
+import org.apache.curator.x.discovery.ServiceDiscovery;
+import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
+import org.apache.curator.x.discovery.ServiceInstance;
+import org.apache.curator.x.discovery.UriSpec;
+import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.grizzly.ssl.SSLContextConfigurator;
+import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
+import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.UriBuilder;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+
+public class DataCatServer {
+    private final static Logger logger = LoggerFactory.getLogger(DataCatService.class);
+
+    public static void main(String[] args) throws IOException {
+        try {
+            // Grizzly ssl configuration
+            SSLContextConfigurator sslContext = new SSLContextConfigurator();
+
+            // set up security context
+            if (new File("../security/" + ServerProperties.getInstance()
+                    .getProperty(Constants.KEYSTORE_FILE, "")).exists()) {
+                sslContext.setKeyStoreFile("../security/" + ServerProperties.getInstance()
+                        .getProperty(Constants.KEYSTORE_FILE, ""));
+                logger.info("Using the configured key store");
+            } else {
+                sslContext.setKeyStoreFile(ClassLoader.getSystemResource("security/" +
+                        ServerProperties.getInstance()
+                                .getProperty(Constants.KEYSTORE_FILE, "")).getPath());
+                logger.info("Using the default key store");
+            }
+            sslContext.setKeyStorePass(ServerProperties.getInstance()
+                    .getProperty(Constants.KEYSTORE_PWD,""));
+
+            if (new File("../security/" + ServerProperties.getInstance()
+                    .getProperty(Constants.TRUSTSTORE_FILE, "")).exists()) {
+                sslContext.setTrustStoreFile("../security/" + ServerProperties.getInstance()
+                        .getProperty(Constants.TRUSTSTORE_FILE, ""));
+                logger.info("Using the configured trust store");
+            } else {
+                sslContext.setTrustStoreFile(ClassLoader.getSystemResource("security/" +
+                        ServerProperties.getInstance()
+                                .getProperty(Constants.TRUSTSTORE_FILE, "")).getPath());
+                logger.info("Using the default trust store");
+            }
+            sslContext.setTrustStoreFile(ServerProperties.getInstance()
+                    .getProperty(Constants.TRUSTSTORE_PWD, ""));
+
+            URI datacatUri = UriBuilder.fromUri(
+                    ServerProperties.getInstance().getProperty(Constants.DATACAT_URI, "")).build();
+
+            ResourceConfig dataCatConfig = new ResourceConfig(DataCatService.class);
+            final HttpServer dataCatServer = GrizzlyHttpServerFactory.createHttpServer(
+                    datacatUri, dataCatConfig, true,
+                    new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
+
+            URI publisherUri = UriBuilder.fromUri(
+                    ServerProperties.getInstance().getProperty(Constants.PUBLISHER_URI, "")).build();
+
+            ResourceConfig publisherConfig = new ResourceConfig(PublisherService.class);
+            final HttpServer publisherServer = GrizzlyHttpServerFactory.createHttpServer(
+                    publisherUri, publisherConfig,
+                true,new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
+
+            //Running a proxy api for the user api is not essential
+            //URI userstoreUri = UriBuilder.fromUri(
+            //        ServerProperties.getInstance().getProperty(Constants.USERSTORE_URI, "")).build();
+
+            //ResourceConfig userstoreConfig = new ResourceConfig(UserStoreService.class);
+            //final HttpServer userstoreServer = GrizzlyHttpServerFactory.createHttpServer(userstoreUri, userstoreConfig);
+            //userstoreServer.start();
+
+            try {
+                new Thread() {
+                    public void run() {
+                        try {
+                            logger.info("Starting DataCat Service. URI:"
+                                    + ServerProperties.getInstance().getProperty(Constants.DATACAT_URI,"")
+                                    ,"datacat-service");
+                            dataCatServer.start();
+                            //registerWithZk(ServerProperties.getInstance().getProperty(Constants.DATACAT_URI,"")
+                            //        ,"datacat-service");
+                            Thread.currentThread().join();
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                            logger.error("There was an error when starting DataCat Service." +
+                                    "Unable to start DataCat Service", e);
+                            System.exit(-1);
+                        }
+                    }
+                }.start();
+                Runtime.getRuntime().addShutdownHook(new Thread() {
+                    public void run() {
+                        dataCatServer.stop();
+                        logger.info("DataCat Service Stopped!");
+                    }
+                });
+            } catch (Exception e) {
+                e.printStackTrace();
+                logger.error("Unable to start DataCat Service", e);
+                throw e;
+            }
+            try {
+                new Thread() {
+                    public void run() {
+                        try {
+                            logger.info("Starting Publisher Service. URI:"
+                                    +ServerProperties.getInstance().getProperty(Constants.PUBLISHER_URI,"")
+                                    ,"publisher-service");
+                            publisherServer.start();
+                            //registerWithZk(ServerProperties.getInstance().getProperty(Constants.PUBLISHER_URI,"")
+                            //       ,"publisher-service");
+                            Thread.currentThread().join();
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                            logger.error("There was an error when starting Publisher Service." +
+                                    "Unable to start Publisher Service", e);
+                            System.exit(-1);
+                        }
+                    }
+                }.start();
+                Runtime.getRuntime().addShutdownHook(new Thread() {
+                    public void run() {
+                        publisherServer.stop();
+                        logger.info("Publisher Service Stopped!");
+                    }
+                });
+            } catch (Exception e) {
+                e.printStackTrace();
+                logger.error("Unable to start Publisher Service", e);
+                throw e;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.toString(), e);
+        }
+    }
+
+    /**
+     * Method to register the service with Zookeeper
+     * @throws Exception
+     */
+    private static void registerWithZk(String uri, String name) throws Exception {
+        CuratorFramework curator = CuratorFrameworkFactory.newClient(
+                ServerProperties.getInstance().getProperty(
+                        Constants.ZK_HOST, ""),
+                new ExponentialBackoffRetry(1000, 3));
+        curator.start();
+        JsonInstanceSerializer<String> serializer =
+                new JsonInstanceSerializer<String>(String.class );
+        ServiceInstance<String> instance =
+                ServiceInstance.<String>builder()
+                        .name(name)
+                        .payload(new String(Constants.DATACAT_SERVER_VERSION))
+                        .sslPort(Integer.parseInt(uri.split(":")[2].replaceAll("/","")))
+                        .uriSpec(new UriSpec(uri))
+                        .build();
+        ServiceDiscovery<String> discovery =
+                ServiceDiscoveryBuilder.builder(String.class)
+                        .client(curator)
+                        .basePath("services")
+                        .serializer(serializer)
+                        .thisInstance(instance)
+                        .build();
+        discovery.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/IDataModel.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/IDataModel.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/IDataModel.java
new file mode 100644
index 0000000..5ae3dc0
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/IDataModel.java
@@ -0,0 +1,48 @@
+/*
+*
+* 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.datacat.server.db;
+
+import org.apache.airavata.datacat.models.AclDTO;
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.models.PrimaryQueryParameter;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public interface IDataModel {
+
+    public void addMetadata(OutputMetadataDTO outputMetadataDTO) throws Exception;
+
+    public void updateMetadata(OutputMetadataDTO outputMetadataDTO) throws Exception;
+
+    public void deleteFileMetadata(String dataArchiveNode, String filePath, String fileName) throws  Exception;
+
+    public ArrayList<String> getAclList(String id) throws Exception;
+
+    public void updateAclList(AclDTO aclDTO) throws Exception;
+
+    public String getMetadataDocHTMLById(String id) throws Exception;
+
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromParameters(List<PrimaryQueryParameter> primaryQueryParameters, String username, String[] userRoles, int startRow, int endRow) throws Exception;
+
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromQueryString(String query, String username, String[] userRoles, int startRow, int endRow) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrClientFactory.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrClientFactory.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrClientFactory.java
new file mode 100644
index 0000000..ef94c03
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrClientFactory.java
@@ -0,0 +1,49 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+package org.apache.airavata.datacat.server.db.solr;
+
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.airavata.datacat.server.util.ServerProperties;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.solr.client.solrj.impl.HttpClientUtil;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+
+public class SolrClientFactory {
+    public HttpSolrServer createSolrMetadataClient() {
+        HttpSolrServer server = new HttpSolrServer(
+                ServerProperties.getInstance().getProperty(Constants.SOLR_METADATA_URL,""));
+        HttpClientUtil.setBasicAuth((DefaultHttpClient) server.getHttpClient(),
+                ServerProperties.getInstance().getProperty(Constants.SOLR_USERNAME, ""),
+                ServerProperties.getInstance().getProperty(Constants.SOLR_PASSWORD, "")
+        );
+        return server;
+    }
+
+    public HttpSolrServer createSolrAclClient() {
+        HttpSolrServer server = new HttpSolrServer(
+                ServerProperties.getInstance().getProperty(Constants.SOLR_ACL_URL,""));
+        HttpClientUtil.setBasicAuth((DefaultHttpClient) server.getHttpClient(),
+                ServerProperties.getInstance().getProperty(Constants.SOLR_USERNAME, ""),
+                ServerProperties.getInstance().getProperty(Constants.SOLR_PASSWORD, "")
+        );
+        return server;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrDataModel.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrDataModel.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrDataModel.java
new file mode 100644
index 0000000..0ded691
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrDataModel.java
@@ -0,0 +1,83 @@
+/*
+*
+* 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.datacat.server.db.solr;
+
+import org.apache.airavata.datacat.models.AclDTO;
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.models.PrimaryQueryParameter;
+import org.apache.airavata.datacat.server.db.IDataModel;
+import org.apache.http.MethodNotSupportedException;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class SolrDataModel implements IDataModel {
+
+    private SolrIndexer solrIndexer;
+
+    private SolrQuerier solrQuerier;
+
+    public SolrDataModel(){
+        this.solrIndexer = new SolrIndexer();
+        solrQuerier = new SolrQuerier();
+    }
+
+    @Override
+    public void addMetadata(OutputMetadataDTO outputMetadataDTO) throws Exception{
+        solrIndexer.addMetadata(outputMetadataDTO);
+    }
+
+    @Override
+    public void updateMetadata(OutputMetadataDTO outputMetadataDTO)throws Exception {
+        solrIndexer.updateMetadata(outputMetadataDTO);
+    }
+
+    @Override
+    public void deleteFileMetadata(String dataArchiveNode, String filePath, String fileName) throws Exception {
+        throw new MethodNotSupportedException("Method still not implemented!!");
+    }
+
+    @Override
+    public ArrayList<String> getAclList(String id) throws Exception {
+        return solrQuerier.getAclList(id);
+    }
+
+    @Override
+    public void updateAclList(AclDTO aclDTO) throws Exception {
+        solrIndexer.updateACL(aclDTO);
+    }
+
+    @Override
+    public String getMetadataDocHTMLById(String id) throws Exception {
+       return solrQuerier.getMetadataDocHTMLById(id);
+    }
+
+    @Override
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromParameters(List<PrimaryQueryParameter> primaryQueryParameters, String username, String[] userRoles, int startRow, int numberOfRows) throws Exception {
+        return solrQuerier.getResultsFromParameters(primaryQueryParameters, username, userRoles, startRow, numberOfRows);
+    }
+
+    @Override
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromQueryString(String query, String username, String[] userRoles, int startRow, int numberOfRows) throws Exception {
+        return solrQuerier.getResultsFromQueryString(query, username, userRoles, startRow, numberOfRows);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrIndexer.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrIndexer.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrIndexer.java
new file mode 100644
index 0000000..cf2ecb1
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrIndexer.java
@@ -0,0 +1,107 @@
+/*
+*
+* 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.datacat.server.db.solr;
+
+import org.apache.airavata.datacat.models.AclDTO;
+import org.apache.airavata.datacat.models.AclFields;
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.models.MetadataFields;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import java.io.IOException;
+import java.util.UUID;
+
+public class SolrIndexer {
+
+    private final Logger logger = LogManager.getLogger(SolrIndexer.class);
+
+    private SolrClientFactory solrClientFactory;
+
+    public SolrIndexer() {
+        solrClientFactory = new SolrClientFactory();
+    }
+
+    public void addMetadata(OutputMetadataDTO outputMetadataDTO) throws IOException, SolrServerException {
+        addData(outputMetadataDTO);
+    }
+
+    public void updateMetadata(OutputMetadataDTO outputMetadataDTO) throws IOException, SolrServerException {
+        addData(outputMetadataDTO);
+    }
+
+    public void updateACL(AclDTO aclDTO) throws IOException, SolrServerException {
+        HttpSolrServer aclClient = solrClientFactory.createSolrAclClient();
+        SolrInputDocument aclDoc = new SolrInputDocument();
+        aclDoc.addField(AclFields.ID, aclDTO.getId());
+        aclDoc.addField(AclFields.ACL, aclDTO.getAcl());
+
+        aclClient.add(aclDoc, 1);
+        logger.info("Updated ACL for metadata file. Id:"+aclDTO.getId());
+    }
+
+    private void addData(OutputMetadataDTO outputMetadataDTO) throws IOException, SolrServerException {
+        HttpSolrServer metadataClient = solrClientFactory.createSolrMetadataClient();
+        SolrInputDocument metadataDoc = new SolrInputDocument();
+
+        HttpSolrServer aclClient = solrClientFactory.createSolrAclClient();
+        SolrInputDocument aclDoc = new SolrInputDocument();
+
+        if (outputMetadataDTO.getId() == "") {
+            String primaryKey = UUID.randomUUID().toString();
+            metadataDoc.addField(MetadataFields.ID, primaryKey);
+            aclDoc.addField(AclFields.ID, primaryKey);
+        } else {
+            metadataDoc.addField(MetadataFields.ID, outputMetadataDTO.getId());
+            aclDoc.addField(AclFields.ID, outputMetadataDTO.getId());
+        }
+
+        metadataDoc.addField(MetadataFields.EXPERIMENT_ID, outputMetadataDTO.getExperimentId());
+        metadataDoc.addField(MetadataFields.EXPERIMENT_NAME, outputMetadataDTO.getExperimentName());
+        metadataDoc.addField(MetadataFields.OUTPUT_PATH, outputMetadataDTO.getOutputPath());
+        metadataDoc.addField(MetadataFields.OWNER_ID, outputMetadataDTO.getOwnerId());
+        metadataDoc.addField(MetadataFields.GATEWAY_ID, outputMetadataDTO.getGatewayId());
+        metadataDoc.addField(MetadataFields.APPLICATION_NAME, outputMetadataDTO.getApplicationName());
+        metadataDoc.addField(MetadataFields.HOST, outputMetadataDTO.getHost());
+        metadataDoc.addField(MetadataFields.CREATED_DATE, outputMetadataDTO.getCreatedDate());
+
+        if(outputMetadataDTO.getCustomMetaData()!=null) {
+            Object[] metadata_keys = outputMetadataDTO.getCustomMetaData().keySet().toArray();
+            String key = "";
+            for (int i = 0; i < metadata_keys.length; i++) {
+                key = (String) metadata_keys[i];
+                if (key.equals("id"))
+                    continue;
+                metadataDoc.addField(key,
+                        outputMetadataDTO.getCustomMetaData().get(key)
+                );
+            }
+        }
+        metadataClient.add(metadataDoc,1);
+
+        aclDoc.addField(AclFields.ACL, outputMetadataDTO.getOwnerId());
+        aclClient.add(aclDoc,1);
+        logger.info("Indexed Metadata file. Experiment Name:"+ outputMetadataDTO.getExperimentName());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQuerier.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQuerier.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQuerier.java
new file mode 100644
index 0000000..bf89a88
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQuerier.java
@@ -0,0 +1,133 @@
+/*
+*
+* 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.datacat.server.db.solr;
+
+import com.google.gson.Gson;
+import org.apache.airavata.datacat.models.AclFields;
+import org.apache.airavata.datacat.models.MetadataFields;
+import org.apache.airavata.datacat.models.PrimaryQueryParameter;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import java.io.IOException;
+import java.util.*;
+
+public class SolrQuerier {
+    private final Logger logger = LogManager.getLogger(SolrQuerier.class);
+
+    private SolrQueryBuilder solrQueryBuilder;
+
+    private SolrClientFactory solrClientFactory;
+
+    private ObjectMapper objectMapper;
+
+    public SolrQuerier(){
+        this.solrClientFactory = new SolrClientFactory();
+        this.solrQueryBuilder = new SolrQueryBuilder();
+        this.objectMapper = new ObjectMapper();
+    }
+
+    public String getMetadataDocHTMLById(String id) throws SolrServerException {
+        SolrServer server = solrClientFactory.createSolrMetadataClient();
+        SolrQuery solrQuery = new SolrQuery(MetadataFields.ID+":"+id);
+        QueryResponse solrResponse = server.query(solrQuery);
+        SolrDocumentList docs = solrResponse.getResults();
+        String html = "<html>\n" +
+                "\n" +
+                "<head>\n" +
+                "<style>\n" +
+                "table, th, td {\n" +
+                "    border: 1px solid black;\n" +
+                "    border-collapse: collapse;\n" +
+                "}\n" +
+                "th, td {\n" +
+                "    padding: 5px;\n" +
+                "    text-align: left;\n" +
+                "}\n" +
+                "</style>\n" +
+                "</head>\n" +
+                "\n" +
+                "<body>"+
+                "<table>";
+        html += "<tr><th>Property</th><th>Value</th></tr>";
+        if(docs.size()==1){
+            SolrDocument doc = docs.get(0);
+            Collection<String> fieldNames = doc.getFieldNames();
+            Iterator<String> fieldNamesIterator = fieldNames.iterator();
+            for(int i=0;i<fieldNames.size();i++){
+                html += "<tr>";
+                String fieldName = fieldNamesIterator.next();
+                html += "<td>" + fieldName + "</td>" + "<td>" + doc.getFieldValue(fieldName) + "</td>";
+                html += "</tr>";
+            }
+        }
+        html += "</table>" +
+                 "</html>";
+        return  html;
+    }
+
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromParameters(List<PrimaryQueryParameter> primaryQueryParameters,
+                                                          String username, String[] userRoles, int startRow, int numberOfRows
+    )throws SolrServerException, IOException {
+        SolrQuery solrQuery;
+        logger.info("Retrieving results for the query parameters");
+        solrQuery = solrQueryBuilder.generateQueryFromParameters(primaryQueryParameters, username, userRoles, startRow,
+                numberOfRows
+        );
+        return getResults(solrQuery);
+    }
+
+    public ArrayList<LinkedHashMap<String, Object>> getResultsFromQueryString(String queryString, String username, String[] userRoles,
+                                                           int startRow, int numberOfRows
+    )throws SolrServerException, IOException {
+        SolrQuery solrQuery;
+        logger.info("Retrieving results for the query string:"+queryString);
+        solrQuery = solrQueryBuilder.generateQueryFromQueryString(queryString, username, userRoles, startRow, numberOfRows);
+        return getResults(solrQuery);
+    }
+
+    private ArrayList<LinkedHashMap<String, Object>> getResults(SolrQuery solrQuery) throws IOException, SolrServerException {
+        SolrServer server = solrClientFactory.createSolrMetadataClient();
+        QueryResponse solrResponse = server.query(solrQuery);
+        SolrDocumentList docs = solrResponse.getResults();
+        String json= (new Gson()).toJson(docs);
+        ArrayList<LinkedHashMap<String, Object>> result =
+                new ObjectMapper().readValue(json, ArrayList.class);
+         return result;
+    }
+
+    public ArrayList<String> getAclList(String id) throws SolrServerException, IOException {
+        SolrServer server = solrClientFactory.createSolrAclClient();
+        SolrQuery solrQuery = new SolrQuery(AclFields.ID+":"+id);
+        QueryResponse solrResponse = server.query(solrQuery);
+        SolrDocumentList docs = solrResponse.getResults();
+        String json= (new Gson()).toJson(docs);
+        ArrayList<LinkedHashMap<String, Object>> result = objectMapper.readValue(json, ArrayList.class);
+        return (ArrayList<String>)result.get(0).get(AclFields.ACL);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQueryBuilder.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQueryBuilder.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQueryBuilder.java
new file mode 100644
index 0000000..d334a74
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/db/solr/SolrQueryBuilder.java
@@ -0,0 +1,101 @@
+/*
+*
+* 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.datacat.server.db.solr;
+
+import org.apache.airavata.datacat.models.PrimaryQueryParameter;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import java.util.List;
+
+public class SolrQueryBuilder {
+
+    public SolrQuery generateQueryFromParameters(List<PrimaryQueryParameter> primaryQueryParameters,
+                                                 String username, String[] userGroups, int startRow, int numberOfRows
+    ) {
+        SolrQuery solrQuery = new SolrQuery();
+        String aclSubQuery = getAclSubQuery(username, userGroups);
+        solrQuery.setQuery(aclSubQuery);
+
+        PrimaryQueryParameter qp;
+        for (int i = 0; i < primaryQueryParameters.size(); i++) {
+            qp = primaryQueryParameters.get(i);
+            switch (qp.getPrimaryQueryType()) {
+                case EQUALS:
+                    solrQuery = solrQuery.addFilterQuery(qp.getField() + ":\"" + qp.getFirstParameter() + "\"");
+                    break;
+                case PHRASE:
+                    solrQuery = solrQuery.addFilterQuery(qp.getField() + ":\"" + qp.getFirstParameter() + "\"");
+                    break;
+                case SUBSTRING:
+                    solrQuery = solrQuery.addFilterQuery(qp.getField() + ":*" + qp.getFirstParameter() + "*");
+                    break;
+                case WILDCARD:
+                    solrQuery = solrQuery.addFilterQuery(qp.getField() + ":" + qp.getFirstParameter());
+                    break;
+                case RANGE:
+                    solrQuery = solrQuery.addFilterQuery(qp.getField() + ":["
+                            + qp.getFirstParameter() + " TO " + qp.getSecondParameter() + "]");
+                    break;
+            }
+        }
+
+        solrQuery.setStart(startRow-1);
+        solrQuery.setRows(numberOfRows);
+
+        return solrQuery;
+    }
+
+    public SolrQuery generateQueryFromQueryString(String userQuery, String username, String[] userGroups,
+                                                  int startRow, int numberOfRows
+    ) {
+        String aclSubQuery = getAclSubQuery(username, userGroups);
+
+        SolrQuery solrQuery = new SolrQuery(aclSubQuery);
+        solrQuery = solrQuery.addFilterQuery(userQuery);
+        solrQuery = solrQuery.setStart(startRow-1);
+        solrQuery = solrQuery.setRows(numberOfRows);
+
+        return solrQuery;
+    }
+
+    private String getAclSubQuery(String username, String[] userGroups){
+        //for generating access control filter query
+        String query = "";
+        if (username != null && username != "") {
+            if (userGroups != null && userGroups.length > 0) {
+                String temp = "(" + username + " OR ";
+                for (int i = 0; i < userGroups.length - 1; i++) {
+                    temp = temp + userGroups[i] + " OR ";
+                }
+                temp = temp + userGroups[userGroups.length - 1] + ")";
+
+                query = "{!join from=id to=id fromIndex=acl}acl:" + temp;
+            } else {
+                query = "{!join from=id to=id fromIndex=acl}acl:" + username;
+            }
+        } else {
+            query = "{!join from=id to=id fromIndex=acl}acl:public";
+        }
+
+        return query;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/DataCatService.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/DataCatService.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/DataCatService.java
new file mode 100644
index 0000000..4537cd1
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/DataCatService.java
@@ -0,0 +1,168 @@
+/*
+*
+* 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.datacat.server.services;
+
+import org.apache.airavata.datacat.models.AclDTO;
+import org.apache.airavata.datacat.models.QueryObject;
+import org.apache.airavata.datacat.server.db.IDataModel;
+import org.apache.airavata.datacat.server.db.solr.SolrDataModel;
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.airavata.datacat.server.util.ServerProperties;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+@Path("/datacat")
+public class DataCatService{
+
+    private final Logger logger = LogManager.getLogger(DataCatService.class);
+
+    private IDataModel dataModel;
+
+    private ObjectMapper objectMapper;
+
+    public DataCatService(){
+        this.dataModel = new SolrDataModel();
+        this.objectMapper = new ObjectMapper();
+    }
+
+    private String serialize (Object object) throws IOException {                                       // serialize given objects
+        return objectMapper.writeValueAsString(object);
+    }
+
+
+    @GET                                                                                                // http request type
+    @Path("/getAPIVersion")                                                                             // relative path annotation
+    @Consumes("application/json")                                                                       // accepting data type
+    public Response getAPIVersion(){
+        return Response.status(200).entity(Constants.DATACAT_SERVER_VERSION).build();                   // response with corresponding header
+    }
+
+    @GET
+    @Path("/getMetadataDocHTMLById")
+    @Consumes("application/json")                                                                       // get full metadata list of a data product
+    public Response getMetadataDocHTMLById(@QueryParam("id") String id){
+        try {
+            String jsonDoc = dataModel.getMetadataDocHTMLById(id);
+            return Response.status(200).entity(jsonDoc).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @POST
+    @Path("/getResults")
+    @Consumes("application/json")
+    public Response getResults(InputStream incomingData){                                               // search metadata
+        StringBuilder stringBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new InputStreamReader(incomingData));
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                stringBuilder.append(line);
+            }
+            QueryObject queryObject = objectMapper.readValue(stringBuilder.toString(), QueryObject.class);
+            String username = queryObject.getUsername();
+            String[] userRoles = queryObject.getUserGroups();
+            ArrayList<LinkedHashMap<String, Object>> fileMetadataDTO;
+            if(!queryObject.isQueryStringSet()){
+                fileMetadataDTO =  dataModel.getResultsFromParameters(                                  // do full text search
+                        queryObject.getPrimaryQueryParameterList(), username, userRoles, queryObject.getStartRow(),
+                        queryObject.getNumberOfRows()
+                );
+            }else {
+                fileMetadataDTO =  dataModel.getResultsFromQueryString(                                 // do fielded search
+                        queryObject.getQueryString(), username, userRoles,queryObject.getStartRow(),
+                        queryObject.getNumberOfRows()
+                );
+            }
+            String result = serialize(fileMetadataDTO);                                                 // serialize response object
+            return Response.status(200).entity(result).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @GET
+    @Path("/getAclList")
+    @Produces("application/json")
+    public Response getAclList(@QueryParam("id") String id){                                            // retrieve ACL list of a data product given the id
+        try {
+            ArrayList<String> result = dataModel.getAclList(id);
+            return Response.status(200).entity(serialize(result)).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @POST
+    @Path("/updateAclList")
+    public Response updateAclList(InputStream incomingData){                                            // update ACL list of a data product
+        StringBuilder stringBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new InputStreamReader(incomingData));
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                stringBuilder.append(line);
+            }
+            AclDTO aclDTO = objectMapper.readValue(stringBuilder.toString(), AclDTO.class);
+            dataModel.updateAclList(aclDTO);
+            return Response.status(200).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @GET
+    @Path("/getMetadataFieldList")
+    @Produces("application/json")
+    public Response getMetadataFieldList(){                                                             // get the list of searchable/indexed fields in database
+        try {
+            String[] fields = ServerProperties.getInstance().getProperty(Constants.FILE_METADATA_FIELDS, "").split(",");
+            String json = "";
+            if(fields.length>=1){
+                json = "[";
+                for(int i=0;i<fields.length-1;i++){
+                    json = json + "\"" + fields[i] + "\",";
+                }
+                json = json + "\"" + fields[fields.length-1] + "\"]";
+            }
+            return Response.status(200).entity(json).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/PublisherService.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/PublisherService.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/PublisherService.java
new file mode 100644
index 0000000..e595dcb
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/PublisherService.java
@@ -0,0 +1,112 @@
+/*
+*
+* 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.datacat.server.services;
+
+//These are Jersey jars
+
+import org.apache.airavata.datacat.models.OutputMetadataDTO;
+import org.apache.airavata.datacat.server.db.IDataModel;
+import org.apache.airavata.datacat.server.db.solr.SolrDataModel;
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+@Path("/publisher")
+public class PublisherService{
+
+    private final Logger logger = LogManager.getLogger(PublisherService.class);
+
+    private IDataModel dataModel =  new SolrDataModel();
+
+    ObjectMapper mapper = new ObjectMapper();
+
+
+    @GET
+    @Path("/getAPIVersion")
+    public Response getAPIVersion(){
+        return Response.status(200).entity(Constants.DATACAT_SERVER_VERSION).build();
+    }
+
+    @DELETE
+    @Path("/deleteFileMetadata")
+    public Response deleteFileMetadata(@QueryParam("dataArchiveNode") String dataArchiveNode,
+                                       @QueryParam("fileName") String fileName,
+                                       @QueryParam("filePath") String filePath
+    ) {
+        try {
+            dataModel.deleteFileMetadata(dataArchiveNode, filePath, fileName);
+
+            // return HTTP response 200 in case of success
+            return Response.status(200).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @POST
+    @Path("/addFileMetadata")
+    public Response addFileMetadata(InputStream incomingData) {
+        StringBuilder stringBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new InputStreamReader(incomingData));
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                stringBuilder.append(line);
+            }
+            OutputMetadataDTO outputMetadataDTO = mapper.readValue(stringBuilder.toString(),OutputMetadataDTO.class);
+            dataModel.addMetadata(outputMetadataDTO);
+            // return HTTP response 200 in case of success
+            return Response.status(200).entity(stringBuilder.toString()).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @PUT
+    @Path("/updateFileMetadata")
+    public Response updateFileMetadata(InputStream incomingData) {
+        StringBuilder stringBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new InputStreamReader(incomingData));
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                stringBuilder.append(line);
+            }
+            OutputMetadataDTO outputMetadataDTO = mapper.readValue(stringBuilder.toString(),OutputMetadataDTO.class);
+            dataModel.updateMetadata(outputMetadataDTO);
+            // return HTTP response 200 in case of success
+            return Response.status(200).entity(stringBuilder.toString()).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/UserStoreService.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/UserStoreService.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/UserStoreService.java
new file mode 100644
index 0000000..0503fb1
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/services/UserStoreService.java
@@ -0,0 +1,109 @@
+/*
+*
+* 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.datacat.server.services;
+
+import org.apache.airavata.datacat.server.userstore.IUserStoreClient;
+import org.apache.airavata.datacat.server.userstore.WSO2IUserStoreClient;
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+@Path("/userstore")
+public class UserStoreService {
+
+    private final Logger logger = LogManager.getLogger(UserStoreService.class);
+
+    private IUserStoreClient iUserStoreClient;
+
+    private ObjectMapper objectMapper;
+
+    public UserStoreService(){
+        this.iUserStoreClient = new WSO2IUserStoreClient();
+    }
+
+    @GET
+    @Path("/getAPIVersion")
+    @Consumes("application/json")
+    public Response getAPIVersion(){
+        return Response.status(200).entity(Constants.DATACAT_SERVER_VERSION).build();
+    }
+
+    @GET
+    @Path("/authenticate")
+    @Produces("application/json")
+    public Response authenticate(@QueryParam("username") String username, @QueryParam("password") String password){
+        try {
+            boolean status = iUserStoreClient.authenticateUser(username, password);
+            return Response.status(200).entity(status+"").build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+
+    @GET
+    @Path("/getGroupsOfUser")
+    @Produces("application/json")
+    public Response getGroupsOfUser(@QueryParam("username") String username){
+        try {
+            List<String> groups = iUserStoreClient.getUserGroups(username);
+            String json = "";
+            if(groups.size()>=1){
+                json = "[";
+                for(int i=0;i<groups.size()-1;i++){
+                    json = json + "\"" + groups.get(i) + "\",";
+                }
+                json = json + "\"" + groups.get(groups.size()-1) + "\"]";
+            }
+            return Response.status(200).entity(json).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+
+    @GET
+    @Path("/getGroupsList")
+    @Produces("application/json")
+    public Response getGroupsList(){
+        try {
+            List<String> groups = iUserStoreClient.getAllGroups();
+            String json = "";
+            if(groups.size()>=1){
+                json = "[";
+                for(int i=0;i<groups.size()-1;i++){
+                    json = json + "\"" + groups.get(i) + "\",";
+                }
+                json = json + "\"" + groups.get(groups.size()-1) + "\"]";
+            }
+            return Response.status(200).entity(json).build();
+        } catch (Exception e) {
+            logger.error(e.toString());
+            return Response.status(503).entity(e.toString()).build();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/IUserStoreClient.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/IUserStoreClient.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/IUserStoreClient.java
new file mode 100644
index 0000000..6b69b59
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/IUserStoreClient.java
@@ -0,0 +1,29 @@
+/*
+*
+* 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.datacat.server.userstore;
+
+import java.util.List;
+
+public interface IUserStoreClient {
+    public boolean authenticateUser(String username, String password) throws Exception;
+    public List<String> getUserGroups(String username) throws Exception;
+    public List<String> getAllGroups() throws Exception;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/WSO2IUserStoreClient.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/WSO2IUserStoreClient.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/WSO2IUserStoreClient.java
new file mode 100644
index 0000000..678d0ee
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/userstore/WSO2IUserStoreClient.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.datacat.server.userstore;
+
+import org.apache.airavata.datacat.server.util.Constants;
+import org.apache.airavata.datacat.server.util.ServerProperties;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.Stub;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceStub;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This class contains the basic functionality based on a backend wso2 IS
+ */
+
+public class WSO2IUserStoreClient implements IUserStoreClient {
+
+    private static final String ADMIN_ROLE = "admin";
+    private static final String INTERNAL_ROLE_PREFIX = "Internal";
+
+    @Override
+    public boolean authenticateUser(String username, String password) throws Exception{
+        Stub serviceStub = getServiceStub();
+        boolean isAuthentic = ((RemoteUserStoreManagerServiceStub) serviceStub).authenticate(username, password);
+        return isAuthentic;
+    }
+
+    @Override
+    public List<String> getUserGroups(String username) throws Exception {
+        Stub serviceStub = getServiceStub();
+        List<String> temp = Arrays.asList(((RemoteUserStoreManagerServiceStub) serviceStub).getRoleListOfUser(username));
+        List<String> result = new ArrayList<String>();
+        for(int i=0;i<temp.size();i++){
+            if(temp.get(i).equals(ADMIN_ROLE) || temp.get(i).startsWith(INTERNAL_ROLE_PREFIX)){
+                continue;
+            }
+            result.add(temp.get(i));
+        }
+        return result;
+    }
+
+    @Override
+    public List<String> getAllGroups() throws Exception {
+        Stub serviceStub = getServiceStub();
+        List<String> temp = Arrays.asList(((RemoteUserStoreManagerServiceStub) serviceStub).getRoleNames());
+        List<String> result = new ArrayList<String>();
+        for(int i=0;i<temp.size();i++){
+            if(temp.get(i).equals(ADMIN_ROLE) || temp.get(i).startsWith(INTERNAL_ROLE_PREFIX)){
+                continue;
+            }
+            result.add(temp.get(i));
+        }
+
+        return result;
+    }
+
+    private Stub getServiceStub() throws AxisFault {
+        String serviceName = "RemoteUserStoreManagerService";
+        ServerProperties properties = ServerProperties.getInstance();
+        String endPoint = properties.getProperty(Constants.IS_URL, "") + "/services/" + serviceName;
+        Stub serviceStub = new RemoteUserStoreManagerServiceStub(endPoint);
+
+        ServiceClient serviceClient;
+        Options options;
+        serviceClient = serviceStub._getServiceClient();
+        options = serviceClient.getOptions();
+        HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
+
+        authenticator.setUsername(properties.getProperty(Constants.IS_USERNAME,""));
+        authenticator.setPassword(properties.getProperty(Constants.IS_PASSWORD, ""));
+        authenticator.setPreemptiveAuthentication(true);
+        options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
+        serviceClient.setOptions(options);
+
+        return serviceStub;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/Constants.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/Constants.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/Constants.java
new file mode 100644
index 0000000..d42aeb8
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/Constants.java
@@ -0,0 +1,22 @@
+package org.apache.airavata.datacat.server.util;
+
+public class Constants {
+    public static final String DATACAT_SERVER_VERSION = "1.0-SNAPSHOT";
+    public static final String DATACAT_URI = "DATACAT_URI";
+    public static final String PUBLISHER_URI = "PUBLISHER_URI";
+    public static final String SOLR_METADATA_URL = "SOLR_METADATA_URL";
+    public static final String SOLR_ACL_URL = "SOLR_ACL_URL";
+    public static final String SOLR_USERNAME = "SOLR_USERNAME";
+    public static final String SOLR_PASSWORD = "SOLR_PASSWORD";
+    public static final String IS_URL = "IS_URL";
+    public static final String IS_USERNAME = "IS_USERNAME";
+    public static final String IS_PASSWORD = "IS_PASSWORD";
+    public static final String METADATA_PRIMARY_INDEX= "METADATA_PRIMARY_INDEX";
+    public static final String FILE_METADATA_FIELDS = "FILE_METADATA_FIELDS";
+    public static final String USERSTORE_URI = "USERSTORE_URI";
+    public static final String KEYSTORE_FILE = "KEYSTORE_FILE";
+    public static final String KEYSTORE_PWD = "KEYSTORE_PWD";
+    public static final String TRUSTSTORE_FILE = "TRUSTSTORE_FILE";
+    public static final String TRUSTSTORE_PWD = "TRUSTSTORE_PWD";
+    public static final String ZK_HOST = "ZK_HOST";
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/ServerProperties.java
----------------------------------------------------------------------
diff --git a/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/ServerProperties.java b/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/ServerProperties.java
new file mode 100644
index 0000000..b74d955
--- /dev/null
+++ b/datacat/server/src/main/java/org/apache/airavata/datacat/server/util/ServerProperties.java
@@ -0,0 +1,55 @@
+package org.apache.airavata.datacat.server.util;
+
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.*;
+
+public class ServerProperties {
+    public static final String SERVER_PROPERTY_FILE = "../conf/server.properties";
+    public static final String DEFAULT_SERVER_PROPERTY_FILE = "conf/server.properties";
+
+    private static ServerProperties instance;
+
+    private final Logger logger = LogManager.getLogger(ServerProperties.class);
+
+    private java.util.Properties properties = null;
+
+    private ServerProperties() {
+        try {
+            InputStream fileInput;
+            if (new File(SERVER_PROPERTY_FILE).exists()) {
+                fileInput = new FileInputStream(SERVER_PROPERTY_FILE);
+                logger.info("Using configured server property (server.properties) file");
+            } else {
+                logger.info("Using default server property (server.properties) file");
+                fileInput = ClassLoader.getSystemResource(DEFAULT_SERVER_PROPERTY_FILE).openStream();
+            }
+            java.util.Properties properties = new java.util.Properties();
+            properties.load(fileInput);
+            fileInput.close();
+            this.properties = properties;
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static ServerProperties getInstance() {
+        if (instance == null) {
+            instance = new ServerProperties();
+        }
+        return instance;
+    }
+
+    public String getProperty(String key, String defaultVal) {
+        String val = this.properties.getProperty(key);
+
+        if (val.isEmpty() || val == "") {
+            return defaultVal;
+        } else {
+            return val;
+        }
+    }
+}


Mime
View raw message