diff --git a/pom.xml b/pom.xml
index a4f3f4d..0a429a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,13 +63,7 @@
2.8.2
compile
-
-
-
-
-
-
-
+
org.gcube.common
common-authorization
@@ -123,12 +117,14 @@
compile
+
org.slf4j
slf4j-api
provided
+
org.slf4j
slf4j-log4j12
@@ -194,6 +190,8 @@
+
+
diff --git a/src/main/java/org/gcube/data/analysis/nlphub/is/DMDiscover.java b/src/main/java/org/gcube/data/analysis/nlphub/is/DMDiscover.java
index 8dc9b6e..39bd085 100644
--- a/src/main/java/org/gcube/data/analysis/nlphub/is/DMDiscover.java
+++ b/src/main/java/org/gcube/data/analysis/nlphub/is/DMDiscover.java
@@ -28,7 +28,7 @@ public class DMDiscover {
private String retrieveServiceInScope(String scope) throws Exception {
List serviceAddress = InformationSystemUtils
- .retrieveServiceAddress(Constants.DATAMINER_SERVICE_CATEGORY, Constants.DATA_MINER_SERVICE_NAME, scope);
+ .retrieveServiceEndpoint(Constants.DATAMINER_SERVICE_CATEGORY, Constants.DATA_MINER_SERVICE_NAME, scope);
logger.debug("Service Address retrieved:" + serviceAddress);
if (serviceAddress == null || serviceAddress.size() < 1) {
logger.error("No DataMiner service address available!");
diff --git a/src/main/java/org/gcube/data/analysis/nlphub/is/InformationSystemUtils.java b/src/main/java/org/gcube/data/analysis/nlphub/is/InformationSystemUtils.java
index 61c88fa..b15932b 100644
--- a/src/main/java/org/gcube/data/analysis/nlphub/is/InformationSystemUtils.java
+++ b/src/main/java/org/gcube/data/analysis/nlphub/is/InformationSystemUtils.java
@@ -3,6 +3,7 @@ package org.gcube.data.analysis.nlphub.is;
import java.util.ArrayList;
import java.util.List;
+import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
@@ -14,7 +15,7 @@ import org.slf4j.LoggerFactory;
public class InformationSystemUtils {
private static Logger logger = LoggerFactory.getLogger(InformationSystemUtils.class);
- public static List retrieveServiceAddress(String category, String name, String scope) throws Exception {
+ public static List retrieveServiceEndpoint(String category, String name, String scope) throws Exception {
try {
if (scope == null || scope.length() == 0)
@@ -33,8 +34,31 @@ public class InformationSystemUtils {
} catch (Throwable e) {
logger.error("Error in discovery DataMiner Service Endpoint in scope: " + scope);
- logger.error("Error: " + e.getLocalizedMessage());
- e.printStackTrace();
+ logger.error("Error: " + e.getLocalizedMessage(),e);
+ throw e;
+ }
+ }
+
+
+ public static List retrieveGCoreEndpoint(String category, String name, String scope) throws Exception {
+ try {
+
+ if (scope == null || scope.length() == 0)
+ return new ArrayList();
+
+ ScopeProvider.instance.set(scope);
+
+ SimpleQuery query = ICFactory.queryFor(GCoreEndpoint.class);
+ query.addCondition("$resource/Profile/ServiceClass/text() eq '" + category + "'")
+ .addCondition("$resource/Profile/ServiceName/text() eq '" + name + "'")
+ .setResult("$resource/Profile/AccessPoint/Interface/text()");
+ DiscoveryClient client = ICFactory.client();
+ List addresses = client.submit(query);
+ return addresses;
+
+ } catch (Throwable e) {
+ logger.error("Error in discovery DataMiner Service Endpoint in scope: " + scope);
+ logger.error("Error: " + e.getLocalizedMessage(),e);
throw e;
}
}
diff --git a/src/main/java/org/gcube/data/analysis/nlphub/shared/Constants.java b/src/main/java/org/gcube/data/analysis/nlphub/shared/Constants.java
index 9990cc5..abc824c 100644
--- a/src/main/java/org/gcube/data/analysis/nlphub/shared/Constants.java
+++ b/src/main/java/org/gcube/data/analysis/nlphub/shared/Constants.java
@@ -1,43 +1,39 @@
package org.gcube.data.analysis.nlphub.shared;
-
public class Constants {
public static final boolean DEBUG = false;
- public static final boolean TEST_ENABLE = false;
-
+ public static final boolean TEST_ENABLE = true;
+
public static final String DEFAULT_USER = "giancarlo.panichi";
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
- public static final String DEFAULT_TOKEN = "";
-
+ public static final String DEFAULT_TOKEN = "d35c72d3-f6b5-4363-afbe-8e330ef9a913-843339462";
+
+ public static final String IS_URL = "http://registry.d4science.org";
+
+ public static final String STORAGEHUB_SERVICE_CLASS = "DataAccess";
+ public static final String STORAGEHUB_SERVICE_NAME = "StorageHub";
+
public static final String DATA_MINER_SERVICE_NAME = "DataMiner";
public static final String DATAMINER_SERVICE_CATEGORY = "DataAnalysis";
public static final String DEFAULT_DATAMINER_URL = "http://dataminer-prototypes.d4science.org/wps/WebProcessingService";
-
+
public static final String TOKEN_PARAMETER = "gcube-token";
-
public static final String DEFAULT_DESCRIPTION = "NlpHub upload";
-
-
+
public static final String MIME_TEXT = "text/plain";
public static final String CONTENT_TYPE = "Content-Type";
public static final String UNAVAILABLE = "unavailable";
public static final String ERROR_ID = "ERROR";
public static final String INPUT_FILE_PARAMETER = "input";
public static final String REQUEST = "Request";
-
-
-
-
- /*public static String hexDump(byte[] bytes) {
- char[] hexArray = "0123456789ABCDEF".toCharArray();
- char[] hexChars = new char[bytes.length * 3];
- for (int j = 0; j < bytes.length; j++) {
- hexChars[3*j] = hexArray[bytes[j] / 16];
- hexChars[3*j+1] = hexArray[bytes[j] % 16];
- hexChars[3*j+2] = ' ';
- }
- return new String(hexChars);
- }*/
+
+ /*
+ * public static String hexDump(byte[] bytes) { char[] hexArray =
+ * "0123456789ABCDEF".toCharArray(); char[] hexChars = new char[bytes.length
+ * * 3]; for (int j = 0; j < bytes.length; j++) { hexChars[3*j] =
+ * hexArray[bytes[j] / 16]; hexChars[3*j+1] = hexArray[bytes[j] % 16];
+ * hexChars[3*j+2] = ' '; } return new String(hexChars); }
+ */
}
diff --git a/src/test/java/nlphub/DiscoverDataMinerServiceTest.java b/src/test/java/nlphub/DiscoverDataMinerServiceTest.java
deleted file mode 100644
index 201caf3..0000000
--- a/src/test/java/nlphub/DiscoverDataMinerServiceTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package nlphub;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.gcube.data.analysis.nlphub.shared.Constants;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DiscoverDataMinerServiceTest {
- private static final Logger logger = LoggerFactory.getLogger(DiscoverDataMinerServiceTest.class);
-
- @Test
- public void discover() {
- if (Constants.TEST_ENABLE) {
-
- try {
- String dataMinerServiceUrl = null;
- String urlInformationSystem = "http://registry.d4science.org/icproxy/gcube/service/ServiceEndpoint/DataAnalysis/DataMiner?";
-
- logger.debug("Request url: " + urlInformationSystem);
- urlInformationSystem += "gcube-token=" + "f57441ac-b361-4c2d-992a-40db034f1b8c-843339462";
- URL url = new URL(urlInformationSystem);
-
- HttpURLConnection connection = null;
-
- connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setDoInput(true);
- connection.setDoOutput(false);
- connection.setUseCaches(false);
-
- try (BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
- dataMinerServiceUrl = readProfileInfo(r);
- }
-
- logger.debug("DataMinerServiceUrl: " + dataMinerServiceUrl);
- Assert.assertTrue(true);
- } catch (Throwable e) {
- logger.error("Error retrieving DataMinerServiceUrl: "+e.getLocalizedMessage(),e);
- Assert.fail("Error retrieving DataMinerServiceUrl: "+e.getLocalizedMessage());
- }
- } else {
- Assert.assertTrue(true);
- }
-
- }
-
- private String readProfileInfo(BufferedReader r) throws FactoryConfigurationError, XMLStreamException {
- String dataMinerServiceUrl = null;
- XMLInputFactory xmlInFact = XMLInputFactory.newInstance();
- XMLStreamReader reader = xmlInFact.createXMLStreamReader(r);
- while (reader.hasNext()) {
- int eventType = reader.next();
- if (eventType == XMLStreamConstants.START_ELEMENT) {
- logger.debug("Read Element: " + reader.getLocalName());
- if (reader.getLocalName().compareToIgnoreCase("EndPoint") == 0) {
- logger.debug("Attribute count:" + reader.getAttributeCount());
- for (int i = 0; i < reader.getAttributeCount(); i++) {
- logger.debug("Attribute Name: " + reader.getAttributeName(i));
- logger.debug("Attribute Value: " + reader.getAttributeValue(i));
- if (reader.getAttributeName(i).toString().compareToIgnoreCase("EntryName") == 0
- && reader.getAttributeValue(i).toString()
- .compareToIgnoreCase("dataminer-prototypes.d4science.org") == 0) {
- dataMinerServiceUrl = reader.getElementText();
- dataMinerServiceUrl = dataMinerServiceUrl.replace("\\n", "").replace("\\r", "");
- logger.debug("DataMiner service url retrieved: " + dataMinerServiceUrl);
- return dataMinerServiceUrl;
- }
-
- }
-
- }
- }
- }
- return dataMinerServiceUrl;
- }
-}
diff --git a/src/test/java/org/gcube/data/analysis/nlphub/DiscoverDataMinerServiceTest.java b/src/test/java/org/gcube/data/analysis/nlphub/DiscoverDataMinerServiceTest.java
new file mode 100644
index 0000000..627493d
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/nlphub/DiscoverDataMinerServiceTest.java
@@ -0,0 +1,30 @@
+package org.gcube.data.analysis.nlphub;
+
+import org.gcube.data.analysis.nlphub.is.DMDiscover;
+import org.gcube.data.analysis.nlphub.shared.Constants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DiscoverDataMinerServiceTest {
+ private static final Logger logger = LoggerFactory.getLogger(DiscoverDataMinerServiceTest.class);
+
+ @Test
+ public void discover() {
+ if (Constants.TEST_ENABLE) {
+ try{
+ DMDiscover dmDiscover=new DMDiscover();
+ String url=dmDiscover.retrieveServiceUrl(Constants.DEFAULT_TOKEN);
+ logger.debug("Url Retrieved: "+url);
+ Assert.assertTrue(true);
+ } catch (Throwable e) {
+ logger.error("Error retrieving DataMinerServiceUrl: "+e.getLocalizedMessage(),e);
+ Assert.fail("Error retrieving DataMinerServiceUrl: "+e.getLocalizedMessage());
+ }
+ } else {
+ Assert.assertTrue(true);
+ }
+
+ }
+}
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
deleted file mode 100644
index d3931ec..0000000
--- a/src/test/resources/logback.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
- /home/gcube/tomcat/logs/ghn.log
- true
-
- %date [%thread] %-5level %logger{0}: %msg%n
-
-
- /home/gcube/tomcat/logs/ghn.%d{yyyy-MM-dd}.%i.log
- 30
- 10MB
- 2GB
-
-
-
-
- /home/gcube/tomcat/logs/accounting.log
- true
-
- %date [%thread] %-5level %logger{0}: %msg%n
-
-
- /home/gcube/tomcat/logs/accounting.%d{yyyy-MM-dd}.%i.log
- 30
- 10MB
- 2GB
-
-
-
-
- /home/gcube/tomcat/logs/access.log
- true
-
- %date [%thread] %-5level %logger{0}: %msg%n
-
-
- /home/gcube/tomcat/logs/access.%d{yyyy-MM-dd}.%i.log
- 30
- 10MB
- 2GB
-
-
-
-
- /home/gcube/tomcat/logs/nlphub.log
- true
-
- %date [%thread] %-5level %logger{0}: %msg%n
-
-
- /home/gcube/tomcat/logs/nlphub.%d{yyyy-MM-dd}.%i.log
- 30
- 10MB
- 2GB
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-