http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/bin/datacat-server.sh ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/bin/datacat-server.sh b/datacat/server/src/main/resources/bin/datacat-server.sh new file mode 100644 index 0000000..9cf6994 --- /dev/null +++ b/datacat/server/src/main/resources/bin/datacat-server.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# 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. + +. `dirname $0`/setenv.sh +cd $DATACAT_SERVER_HOME + +IS_DAEMON_MODE=false +DATACAT_SERVER_COMMAND="" +STOP=false +FORCE=false + +for var in "$@" +do + case $var in + start) + IS_DAEMON_MODE=true + shift + ;; + stop) + STOP=true + DATACAT_SERVER_COMMAND="$ + DATACAT_SERVER_COMMAND $var" + shift + ;; + -h) + echo "Usage: datacat-server.sh [command-options]" + echo "command options:" + echo " start Start server in daemon mode" + echo " stop Stop server." + echo " -h Display this help and exit" + shift + exit 0 + ;; + *) + DATACAT_SERVER_COMMAND="$DATACAT_SERVER_COMMAND $var" + shift + esac +done + +if $STOP; +then + for f in `find . -name "*-start_*"`; do + IFS='_' read -a f_split <<< "$f" + echo "Found process file : $f" + echo -n " Sending kill signals to process ${f_split[1]}..." + out=`kill -9 ${f_split[1]} 2>&1` + if [ -z "$out" ]; then + echo "done" + else + echo "failed (REASON: $out)" + fi + echo -n " Removing process file..." + out=`rm $f 2>&1` + if [ -z "$out" ]; then + echo "done" + else + echo "failed (REASON: $out)" + fi + done +else + if $IS_DAEMON_MODE ; then + echo "Starting Solr Server in daemon mode..." + cd "$DATACAT_SERVER_HOME"/solr-server + nohup $JAVA_HOME/bin/java -jar start.jar > solr-server.out & echo $! > "solr-start_$!" + cd .. + echo "Starting DataCat server in daemon mode..." + cd "$DATACAT_SERVER_HOME"/lib + nohup $JAVA_HOME/bin/java -jar "$DATACAT_SERVER_HOME"/lib/server-1.0-SNAPSHOT.jar > ../datacat-server.out & echo $! > "../server-start_$!" + cd .. + else + cd "$DATACAT_SERVER_HOME"/solr-server + nohup $JAVA_HOME/bin/java -jar start.jar > solr-server.out & echo $! > "solr-start_$!" + cd .. + cd "$DATACAT_SERVER_HOME"/lib + $JAVA_HOME/bin/java -jar "$DATACAT_SERVER_HOME"/lib/server-1.0-SNAPSHOT.jar & echo $! > "server-start_$!" + cd .. + fi +fi \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/bin/setenv.sh ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/bin/setenv.sh b/datacat/server/src/main/resources/bin/setenv.sh new file mode 100644 index 0000000..09ba303 --- /dev/null +++ b/datacat/server/src/main/resources/bin/setenv.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# 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. + +# Get standard environment variables +# if JAVA_HOME is not set we're not happy +if [ -z "$JAVA_HOME" ]; then + echo "You must set the JAVA_HOME variable before running datacat-server scripts." + exit 1 +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +os400=false +case "`uname`" in +CYGWIN*) cygwin=true;; +OS400*) os400=true;; +esac + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '.*/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` + +# Only set DATACAT_SERVER_HOME if not already set +[ -z "$DATACAT_SERVER_HOME" ] && DATACAT_SERVER_HOME=`cd "$PRGDIR/.." ; pwd` + +DATACAT_SERVER_CLASSPATH="" + + + +for f in "DATACAT_SERVER_HOME"/lib/*.jar +do + DATACAT_SERVER_CLASSPATH="$DATACAT_SERVER_CLASSPATH":$f +done + +DATACAT_SERVER_CLASSPATH="$DATACAT_SERVER_CLASSPATH":"$DATACAT_SERVER_HOME"/conf/log4j.properties + +export DATACAT_SERVER_HOME +export DATACAT_SERVER_CLASSPATH \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/conf/server.properties ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/conf/server.properties b/datacat/server/src/main/resources/conf/server.properties new file mode 100644 index 0000000..4de2872 --- /dev/null +++ b/datacat/server/src/main/resources/conf/server.properties @@ -0,0 +1,34 @@ +DATACAT_URI=https://192.168.0.2:8887/ + +PUBLISHER_URI=https://192.168.0.2:8888/ + +USERSTORE_URI=https://localhost:8889/ + +SOLR_METADATA_URL=http://localhost:8983/solr/metadata + +SOLR_ACL_URL=http://localhost:8983/solr/acl + +SOLR_USERNAME=datacat + +SOLR_PASSWORD=datacat + +IS_URL=https://localhost:9443 + +IS_USERNAME=admin + +IS_PASSWORD=admin + +#When empty server adds a randomly generated GUID +METADATA_PRIMARY_INDEX= + +FILE_METADATA_FIELDS=InChi,InChiKey,GoptEnergy + +KEYSTORE_FILE=keystore.jks + +KEYSTORE_PWD=wso2carbon + +TRUSTSTORE_FILE=client-truststore.jks + +TRUSTSTORE_PWD=wso2carbon + +ZK_HOST=localhost \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/log4j.properties b/datacat/server/src/main/resources/log4j.properties new file mode 100644 index 0000000..9e0e04d --- /dev/null +++ b/datacat/server/src/main/resources/log4j.properties @@ -0,0 +1,16 @@ +#CONSOLE AND FILE LOGGING +#CONSOLE LOGGING +log4j.rootLogger=INFO, CONSOLE +log4j.logger.console=WARN, CONSOLE +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n +log4j.appender.CONSOLE.Threshold=DEBUG + +#FILE LOGGING +log4j.logger.file=ALL, DAILYROLLINGFILEAPPENDER +log4j.appender.DAILYROLLINGFILEAPPENDER=org.apache.log4j.DailyRollingFileAppender +log4j.appender.DAILYROLLINGFILEAPPENDER.layout=org.apache.log4j.PatternLayout +log4j.appender.DAILYROLLINGFILEAPPENDER.layout.ConversionPattern=%d [%t] %-5p %c - %m%n +log4j.appender.DAILYROLLINGFILEAPPENDER.File=/tmp/datacat-agent.log +log4j.appender.DAILYROLLINGFILEAPPENDER.Threshold=ALL \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/security/client-truststore.jks ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/security/client-truststore.jks b/datacat/server/src/main/resources/security/client-truststore.jks new file mode 100644 index 0000000..be441f3 Binary files /dev/null and b/datacat/server/src/main/resources/security/client-truststore.jks differ http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/main/resources/security/keystore.jks ---------------------------------------------------------------------- diff --git a/datacat/server/src/main/resources/security/keystore.jks b/datacat/server/src/main/resources/security/keystore.jks new file mode 100644 index 0000000..7942c53 Binary files /dev/null and b/datacat/server/src/main/resources/security/keystore.jks differ http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrIndexerTest.java ---------------------------------------------------------------------- diff --git a/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrIndexerTest.java b/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrIndexerTest.java new file mode 100644 index 0000000..faa6bd6 --- /dev/null +++ b/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrIndexerTest.java @@ -0,0 +1,62 @@ +/* +* +* 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 junit.framework.TestCase; +import org.apache.airavata.datacat.models.OutputMetadataDTO; +import org.apache.airavata.datacat.server.db.solr.SolrIndexer; +import org.apache.solr.client.solrj.SolrServerException; +import org.junit.Test; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class SolrIndexerTest extends TestCase { + + private SolrIndexer indexer; + + private OutputMetadataDTO outputMetadataDTO; + + public void setUp() throws Exception { + super.setUp(); + indexer = new SolrIndexer(); + + //populating a dummy fileMetaDataDTO + outputMetadataDTO = new OutputMetadataDTO(); + Map<String, String> customMetaData = new HashMap<String, String>(); + customMetaData.put("id", "InChI=1S/H2O.HO/h1H2;1LMLKF4HXB"); + customMetaData.put("InChi_s", "InChI=1S/H2O.HO/h1H2;LMLKF4HXB"); + + outputMetadataDTO.setOutputPath("/Users/swithana/data_root/gaussian_sample_23"); + outputMetadataDTO.setApplicationName("gaussian 9"); + outputMetadataDTO.setHost("localhost"); + outputMetadataDTO.setCreatedDate("2014-10-25T19:41:04Z"); + outputMetadataDTO.setOwnerId("sudhakar"); + outputMetadataDTO.setCustomMetaData(customMetaData); + + } + + @Test + public void testAddData() throws IOException, SolrServerException { + indexer.addMetadata(outputMetadataDTO); + } +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrQuerierTest.java ---------------------------------------------------------------------- diff --git a/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrQuerierTest.java b/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrQuerierTest.java new file mode 100644 index 0000000..a7b9afa --- /dev/null +++ b/datacat/server/src/test/java/org/apache/airavata/datacat/server/db/SolrQuerierTest.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.datacat.server.db; + +import junit.framework.Assert; +import junit.framework.TestCase; +import org.apache.airavata.datacat.models.MetadataFields; +import org.apache.airavata.datacat.models.PrimaryQueryParameter; +import org.apache.airavata.datacat.models.PrimaryQueryType; +import org.apache.airavata.datacat.server.db.solr.SolrQuerier; +import org.apache.airavata.datacat.server.util.Constants; +import org.apache.airavata.datacat.server.util.ServerProperties; +import org.apache.solr.client.solrj.SolrServerException; +import org.junit.Test; + +import java.io.IOException; +import java.util.*; + +public class SolrQuerierTest extends TestCase { + + private SolrQuerier solrQuerier; + private List<PrimaryQueryParameter> primaryQueryParameters; + private PrimaryQueryParameter parameter; + private ArrayList<LinkedHashMap<String, Object>> result; + private final String USERNAME = "test"; + private String[] groups; + + public void setUp() throws Exception { + super.setUp(); + groups = new String[]{"group_1", "group_2", "sudhakar"}; + solrQuerier = new SolrQuerier(); + + } + + @Test + public void testSubstringSearch() throws IOException, SolrServerException { + List<PrimaryQueryParameter> primaryQueryParameters; + PrimaryQueryParameter parameter; + ArrayList<LinkedHashMap<String, Object>> result; + String primaryKey = ServerProperties.getInstance().getProperty(Constants.METADATA_PRIMARY_INDEX,"InChi_s"); + String username = "test"; + String[] groups = new String[]{"group_1", "group_2", "sudhakar"}; + + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("C5H9O4"); + parameter.setPrimaryQueryType(PrimaryQueryType.SUBSTRING); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 5); + Assert.assertTrue(result.size() >= 1); + } + + @Test + public void testRangeSearch() throws IOException, SolrServerException { + //range search + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(MetadataFields.CREATED_DATE); + parameter.setFirstParameter("*"); + parameter.setSecondParameter("2014-10-25T19:41:04Z"); + parameter.setPrimaryQueryType(PrimaryQueryType.RANGE); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, USERNAME, groups, 0, 1); + Assert.assertTrue(result.size() >= 1); + + } + + @Test + public void testGetResults() throws Exception { + List<PrimaryQueryParameter> primaryQueryParameters; + PrimaryQueryParameter parameter; + ArrayList<LinkedHashMap<String, Object>> result; + + String username = "test"; + String[] groups = new String[]{"group_1", "group_2", "sudhakar"}; + + String primaryKey = ServerProperties.getInstance().getProperty(Constants.METADATA_PRIMARY_INDEX,"InChi_s"); + + //Field value search + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("InChI=1S/C5H9O4.C2H8N3/c1-4(6)8-9-5(2,3)7;1-5-2(3)4/h1-3H3;5H,3-4H2,1H3"); + parameter.setPrimaryQueryType(PrimaryQueryType.EQUALS); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 1); + Assert.assertTrue(result.size() >= 1); + + //Sub string search + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("C5H9O4"); + parameter.setPrimaryQueryType(PrimaryQueryType.SUBSTRING); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 5); + Assert.assertTrue(result.size() >= 1); + + //wildcard search + //primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + //parameter = new PrimaryQueryParameter(); + //parameter.setField(MetadataFields.INCHI); + //parameter.setFirstParameter("C5H*O4"); + //parameter.setPrimaryQueryType(PrimaryQueryType.WILDCARD); + //primaryQueryParameters.add(parameter); + //result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups); + //Assert.assertTrue(result.size() >= 1); + + //phrase search + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("InChI=1S/C5H9O4.C2H8N3/c1-4(6)8-9-5(2,3)7;1-5-2(3)4/h1-3H3;5H,3-4H2,1H3"); + parameter.setPrimaryQueryType(PrimaryQueryType.PHRASE); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 2); + Assert.assertTrue(result.size() >= 1); + + //range search + //Todo The range search is not working properly + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(MetadataFields.CREATED_DATE); + parameter.setFirstParameter("*"); + parameter.setSecondParameter("2015-09-08T00:43:54Z"); + parameter.setPrimaryQueryType(PrimaryQueryType.RANGE); + primaryQueryParameters.add(parameter); + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 1); + //Assert.assertTrue(result.size() >= 1); + + //field value AND substring AND range + primaryQueryParameters = new ArrayList<PrimaryQueryParameter>(); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("InChI*"); + parameter.setPrimaryQueryType(PrimaryQueryType.WILDCARD); + primaryQueryParameters.add(parameter); + parameter = new PrimaryQueryParameter(); + parameter.setField(primaryKey); + parameter.setFirstParameter("C"); + parameter.setPrimaryQueryType(PrimaryQueryType.SUBSTRING); + primaryQueryParameters.add(parameter); + parameter = new PrimaryQueryParameter(); + parameter.setField(MetadataFields.CREATED_DATE); + parameter.setFirstParameter("*"); + parameter.setSecondParameter("2015-09-08T00:43:54Z"); + parameter.setPrimaryQueryType(PrimaryQueryType.RANGE); + primaryQueryParameters.add(parameter); + //parameter = new PrimaryQueryParameter(); + //parameter.setField(MetadataFields.INCHI); + //parameter.setFirstParameter("InChI=1S/C5H9O4.C2H8N3/c1-4(6)8-9-5(2,3)7;1-5-2(3)4/h1-3H3;5H,3-4H2,1H3"); + //parameter.setPrimaryQueryType(PrimaryQueryType.PHRASE); + //primaryQueryParameters.add(parameter); + + result = solrQuerier.getResultsFromParameters(primaryQueryParameters, username, groups, 0, 2); + //Assert.assertTrue(result.size() >= 1); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/web/portal/dataStoreService.php ---------------------------------------------------------------------- diff --git a/datacat/web/portal/dataStoreService.php b/datacat/web/portal/dataStoreService.php new file mode 100755 index 0000000..e30a83b --- /dev/null +++ b/datacat/web/portal/dataStoreService.php @@ -0,0 +1,181 @@ +<?php + +session_start(); + +$call = $_POST['call']; +if(isset($_POST['data'])){ + $data = $_POST['data']; +} + +function getResults($data) +{ + if($_SESSION['loggedIn'] == "Y"){ // append username ang groups of user to a query parameter array + $data['username'] = $_SESSION['username']; + $data['userGroups'] = $_SESSION['userGroups']; + } + + $url = 'http://localhost:8887/datacat/getResults'; + $jsonData = json_encode($data); + + $options = array( + 'http' => array( + 'method' => 'POST', + 'content' => $jsonData, + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); // get the resulting data products for a given query + $result = file_get_contents( $url, false, $context ); + + return $result ; +} + +function getMetadataFieldList() +{ + $url = 'http://localhost:8887/datacat/getMetadataFieldList'; + + $options = array( + 'http' => array( + 'method' => 'GET', + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $result = file_get_contents( $url, false, $context ); // get the full list of searchable/indexed fields + + return $result; +} + +function getAclList($data) +{ + $url = 'http://localhost:8887/datacat/getAclList?id=' . urlencode($data['id']); + + $options = array( + 'http' => array( + 'method' => 'GET', + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $result = file_get_contents( $url, false, $context ); // get the ACL list of a data product given its id + + return $result ; +} + +function updateAclList($data) +{ + + $url = 'http://localhost:8887/datacat/updateAclList'; + $jsonData = json_encode($data); + + $options = array( + 'http' => array( + 'method' => 'POST', + 'content' => $jsonData, + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $result = file_get_contents( $url, false, $context ); // update ACL list of a data product + + return $result ; +} + +function getAllUserGroups() +{ + $url = 'http://localhost:8889/userstore/getGroupsList'; + + $options = array( + 'http' => array( + 'method' => 'GET', + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $result = file_get_contents( $url, false, $context ); // get the full list of user groups for sharing data products + + return $result ; +} + +function checkLogin() // from frontend javascript, check user logged in and get username +{ + if ($_SESSION['loggedIn'] == "Y") { + return $_SESSION['username']; + } else { + return "%%false%%"; + } +} + +function login($data) +{ + $url = 'http://localhost:8889/userstore/authenticate?username=' . urlencode($data['username']) . '&password=' . urlencode($data['password']); + + $options = array( + 'http' => array( + 'method' => 'GET', + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $auth = file_get_contents( $url, false, $context ); // authenticate user + + if ($auth == 'true') { + + $url = 'http://localhost:8889/userstore/getGroupsOfUser?username=' . urlencode($data['username']); + + $options = array( + 'http' => array( + 'method' => 'GET', + 'header'=> "Content-Type: application/json\r\n" . + "Accept: application/json\r\n" + ) + ); + + $context = stream_context_create( $options ); + $userGroups = file_get_contents( $url, false, $context ); // if authenticated, get users list of access groups + + $_SESSION['loggedIn'] = "Y"; // login user + + $_SESSION['username'] = $data['username']; + $_SESSION['userGroups'] = json_decode( $userGroups ); + } + + return $auth; +} + +function logout() // destroy session and logout +{ + session_destroy(); + return true; +} + + +if ($call == 'getResults') { // adaptor to run corresponding functions + print_r(getResults($data)); +} else if ($call == 'getMetadataFieldList') { + print_r(getMetadataFieldList()); +} else if ($call == 'getAclList') { + print_r(getAclList($data)); +} else if ($call == 'login') { + print_r(login($data)); +} else if ($call == 'logout') { + print_r(logout()); +} else if ($call == 'checkLogin') { + print_r(checkLogin()); +} else if ($call == 'getAllUserGroups') { + print_r(getAllUserGroups()); +} else if ($call == 'updateAclList') { + print_r(updateAclList($data)); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/web/portal/favicon.ico ---------------------------------------------------------------------- diff --git a/datacat/web/portal/favicon.ico b/datacat/web/portal/favicon.ico new file mode 100755 index 0000000..1a10f78 Binary files /dev/null and b/datacat/web/portal/favicon.ico differ http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/web/portal/fonts/glyphicons-halflings-regular.eot ---------------------------------------------------------------------- diff --git a/datacat/web/portal/fonts/glyphicons-halflings-regular.eot b/datacat/web/portal/fonts/glyphicons-halflings-regular.eot new file mode 100755 index 0000000..4a4ca86 Binary files /dev/null and b/datacat/web/portal/fonts/glyphicons-halflings-regular.eot differ
