refs 2521: Explore the possibility to port the StatMan interface onto Dataminer
https://support.d4science.org/issues/2521 Fixed Algorithms Descriptions retrivial git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@129016 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2df5f625e2
commit
ccfaca4dcd
154
pom.xml
154
pom.xml
|
@ -48,7 +48,7 @@
|
|||
<gwtVersion>2.6.1</gwtVersion>
|
||||
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||
<gxtVersion>3.1.1</gxtVersion>
|
||||
<gxt2Version>2.6.1</gxt2Version>
|
||||
<gxt2Version>2.6.1</gxt2Version>
|
||||
|
||||
<KEYS>${env.KEYS}</KEYS>
|
||||
|
||||
|
@ -60,12 +60,8 @@
|
|||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.7.1</version>
|
||||
</dependency> -->
|
||||
<!-- <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId>
|
||||
<version>2.7.1</version> </dependency> -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
@ -77,7 +73,7 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
|
@ -106,7 +102,7 @@
|
|||
<artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -139,12 +135,8 @@
|
|||
<version>${gwtVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- GXT 2
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt2.2.5-gwt2.X</artifactId>
|
||||
<version>${gxt2Version}</version>
|
||||
</dependency> -->
|
||||
<!-- GXT 2 <dependency> <groupId>com.sencha.gxt</groupId> <artifactId>gxt2.2.5-gwt2.X</artifactId>
|
||||
<version>${gxt2Version}</version> </dependency> -->
|
||||
|
||||
|
||||
<!-- GXT 3 -->
|
||||
|
@ -153,27 +145,14 @@
|
|||
<artifactId>gxt</artifactId>
|
||||
<version>${gxtVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.ibm.icu</groupId>
|
||||
<artifactId>icu4j</artifactId>
|
||||
<version>51.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-generic-clients</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>com.ibm.icu</groupId> <artifactId>icu4j</artifactId>
|
||||
<version>51.2</version> <scope>compile</scope> </dependency> <dependency>
|
||||
<groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.7.1</version>
|
||||
<scope>provided</scope> </dependency> <dependency> <groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-generic-clients</artifactId> <version>[1.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
|
@ -182,18 +161,18 @@
|
|||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
|
@ -205,8 +184,8 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
|
@ -220,39 +199,35 @@
|
|||
<artifactId>authorization-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- GCube Widget -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Session Checker -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[0.0.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-fw-clients</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>org.gcube.core</groupId> <artifactId>common-fw-clients</artifactId>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
|
@ -266,35 +241,6 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Information System Client IC-Client -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Nord52 -->
|
||||
<dependency>
|
||||
<groupId>org.n52.wps</groupId>
|
||||
<artifactId>52n-wps-client-lib</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>gt-opengis</artifactId>
|
||||
<groupId>org.geotools</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -313,9 +259,41 @@
|
|||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Apache HttpClient -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Information System Client IC-Client -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Nord52 -->
|
||||
<dependency>
|
||||
<groupId>org.n52.wps</groupId>
|
||||
<artifactId>52n-wps-client-lib</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>gt-opengis</artifactId>
|
||||
<groupId>org.geotools</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- csv4j -->
|
||||
<dependency>
|
||||
|
|
|
@ -356,6 +356,7 @@ public class SClient4WPS extends SClient {
|
|||
return;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("RequestCapability(): "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new Exception(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server.smservice.wps;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -400,26 +406,64 @@ public class StatWPSClientSession implements Serializable {
|
|||
try {
|
||||
logger.debug("RetrieveDescription GET: " + processIDs + " url:"
|
||||
+ url);
|
||||
StatClientDescribeProcessRequest req = new StatClientDescribeProcessRequest();
|
||||
req.setIdentifier(processIDs);
|
||||
String requestURL = req.getRequest(url);
|
||||
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
Path tempFile = Files.createTempFile("WPSProcessDescriptions",
|
||||
"txt");
|
||||
|
||||
URL urlObj = new URL(requestURL);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add("<wps:ProcessDescriptions xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" "
|
||||
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
||||
+ "xmlns:ows=\"http://www.opengis.net/ows/1.1\" "
|
||||
+ "xsi:schemaLocation=\"http://www.opengis.net/wps/1.0.0 "
|
||||
+ "http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd\" "
|
||||
+ "xml:lang=\"en-US\" "
|
||||
+ "service=\"WPS\" version=\"1.0.0\">");
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
|
||||
Document doc = checkInputStream(is);
|
||||
return ProcessDescriptionsDocument.Factory.parse(doc, options);
|
||||
for (String processId : processIDs) {
|
||||
String[] process = { processId };
|
||||
StatClientDescribeProcessRequest req = new StatClientDescribeProcessRequest();
|
||||
req.setIdentifier(process);
|
||||
String requestURL = req.getRequest(url);
|
||||
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64
|
||||
.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL urlObj = new URL(requestURL);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic "
|
||||
+ encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
lines=retrievesSingleDescription(is);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
}
|
||||
lines = new ArrayList<>();
|
||||
lines.add("</wps:ProcessDescriptions>");
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
|
||||
logger.debug(tempFile.toString());
|
||||
Document doc=null;
|
||||
try (InputStream inputStream = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)){
|
||||
doc = checkInputStream(inputStream);
|
||||
|
||||
}
|
||||
ProcessDescriptionsDocument processDescriptionsDocument = ProcessDescriptionsDocument.Factory.parse(doc, options);
|
||||
|
||||
Files.delete(tempFile);
|
||||
return processDescriptionsDocument;
|
||||
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
logger.error("URL seems not to be valid");
|
||||
e.printStackTrace();
|
||||
|
@ -443,6 +487,60 @@ public class StatWPSClientSession implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
protected List<String> retrievesSingleDescription(InputStream is) throws WPSClientException {
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
List<String> lines = new ArrayList<>();
|
||||
String line = null;
|
||||
boolean elementProcessDescriptionsFound = false;
|
||||
boolean elementProcessDescriptionsClosureFound = false;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (elementProcessDescriptionsFound) {
|
||||
if (elementProcessDescriptionsClosureFound) {
|
||||
if (line.contains("</wps:ProcessDescriptions>")) {
|
||||
break;
|
||||
} else {
|
||||
lines.add(line);
|
||||
}
|
||||
} else {
|
||||
int closeIndex = line.indexOf(">");
|
||||
if (closeIndex != -1) {
|
||||
elementProcessDescriptionsClosureFound = true;
|
||||
if (closeIndex == line.length() - 1) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (line.contains("<wps:ProcessDescriptions")) {
|
||||
elementProcessDescriptionsFound = true;
|
||||
int closeIndex = line.indexOf(">");
|
||||
if (closeIndex != -1) {
|
||||
elementProcessDescriptionsClosureFound = true;
|
||||
if (closeIndex == line.length() - 1) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(e.getLocalizedMessage(),
|
||||
new Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream retrieveDataViaPOST(XmlObject obj, String urlString)
|
||||
throws WPSClientException {
|
||||
try {
|
||||
|
@ -479,10 +577,17 @@ public class StatWPSClientSession implements Serializable {
|
|||
}
|
||||
|
||||
private Document checkInputStream(InputStream is) throws WPSClientException {
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(true);
|
||||
Document doc = fac.newDocumentBuilder().parse(is);
|
||||
logger.debug("Document: " + doc);
|
||||
if (doc == null) {
|
||||
logger.error("Document is null");
|
||||
throw new WPSClientException(
|
||||
"Error in check input stream: Document is null");
|
||||
}
|
||||
|
||||
if (getFirstElementNode(doc.getFirstChild()).getLocalName().equals(
|
||||
"ExceptionReport")
|
||||
&& getFirstElementNode(doc.getFirstChild())
|
||||
|
@ -498,18 +603,28 @@ public class StatWPSClientSession implements Serializable {
|
|||
"Error while parsing ExceptionReport retrieved from server",
|
||||
e);
|
||||
}
|
||||
} else {
|
||||
logger.debug("No Exception Report");
|
||||
}
|
||||
return doc;
|
||||
} catch (SAXException e) {
|
||||
logger.error("Error while parsing input: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error while parsing input.", e);
|
||||
throw new WPSClientException("Error while parsing input", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occured while transfer: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while transfer", e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
logger.error("Error occured, parser is not correctly configured: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured, parser is not correctly configured", e);
|
||||
} catch (WPSClientException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue