ref 8471:TDM - DataMiner Manager - Support Java 8 compatibility
https://support.d4science.org/issues/8471 Updated to support Java 8 compatibility git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@148563 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5497d22d2f
commit
0f41e3ba14
|
@ -50,8 +50,7 @@ import org.xml.sax.SAXException;
|
|||
public class SClient4WPSSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1387670579312851370L;
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(SClient4WPSSession.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(SClient4WPSSession.class);
|
||||
private static final String OGC_OWS_URI = "http://www.opengeospatial.net/ows";
|
||||
private static String SUPPORTED_VERSION = "1.0.0";
|
||||
|
||||
|
@ -67,11 +66,14 @@ public class SClient4WPSSession implements Serializable {
|
|||
/**
|
||||
* Initializes a WPS client session.
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param password
|
||||
* password
|
||||
*/
|
||||
public SClient4WPSSession(String user, String password) {
|
||||
super();
|
||||
logger.debug("Create SClient4WPSSession: [user=" + user
|
||||
+ ", password=" + password + "]");
|
||||
logger.debug("Create SClient4WPSSession: [user=" + user + ", password=" + password + "]");
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
options = new XmlOptions();
|
||||
|
@ -90,6 +92,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
* further identification of the service.
|
||||
* @return true, if connect succeeded, false else.
|
||||
* @throws WPSClientException
|
||||
* wps client exception
|
||||
*/
|
||||
|
||||
public boolean connect(String url) throws WPSClientException {
|
||||
|
@ -111,11 +114,9 @@ public class SClient4WPSSession implements Serializable {
|
|||
|
||||
ProcessDescriptionsDocument processDescs = describeAllProcesses(url);
|
||||
if (processDescs != null && capsDoc != null) {
|
||||
logger.debug("Adding processes descriptions to logged services "
|
||||
+ url);
|
||||
logger.debug("Adding processes descriptions to logged services " + url);
|
||||
processDescriptions.put(url, processDescs);
|
||||
logger.debug("ProcessDescriptions key: "
|
||||
+ processDescriptions.keySet());
|
||||
logger.debug("ProcessDescriptions key: " + processDescriptions.keySet());
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
@ -135,6 +136,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
* further identification of the service.
|
||||
* @return true, if connect succeeded, false else.
|
||||
* @throws WPSClientException
|
||||
* wps client exception
|
||||
*/
|
||||
public boolean connectForMonitoring(String url) throws WPSClientException {
|
||||
logger.debug("CONNECT");
|
||||
|
@ -151,6 +153,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
* removes a service from the session
|
||||
*
|
||||
* @param url
|
||||
* url
|
||||
*/
|
||||
public void disconnect(String url) {
|
||||
/*
|
||||
|
@ -163,7 +166,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
/**
|
||||
* returns the serverIDs of all loggedServices
|
||||
*
|
||||
* @return
|
||||
* @return list of service
|
||||
*/
|
||||
public List<String> getLoggedServices() {
|
||||
if (loggedServices != null && loggedServices.keySet() != null) {
|
||||
|
@ -178,7 +181,8 @@ public class SClient4WPSSession implements Serializable {
|
|||
* the session. in normal case it should return true :)
|
||||
*
|
||||
* @param serverID
|
||||
* @return success
|
||||
* server id
|
||||
* @return success if contain descriptions in cache
|
||||
*/
|
||||
public boolean descriptionsAvailableInCache(String serverID) {
|
||||
return processDescriptions.containsKey(serverID);
|
||||
|
@ -187,12 +191,14 @@ public class SClient4WPSSession implements Serializable {
|
|||
/**
|
||||
* returns the cached processdescriptions of a service.
|
||||
*
|
||||
* @param serverID
|
||||
* @return success
|
||||
*
|
||||
* @param wpsUrl
|
||||
* wps url
|
||||
* @return process description document
|
||||
* @throws IOException
|
||||
* IO exception
|
||||
*/
|
||||
private ProcessDescriptionsDocument getProcessDescriptionsFromCache(
|
||||
String wpsUrl) throws IOException {
|
||||
private ProcessDescriptionsDocument getProcessDescriptionsFromCache(String wpsUrl) throws IOException {
|
||||
if (!descriptionsAvailableInCache(wpsUrl)) {
|
||||
try {
|
||||
connect(wpsUrl);
|
||||
|
@ -207,14 +213,16 @@ public class SClient4WPSSession implements Serializable {
|
|||
* return the processDescription for a specific process from Cache.
|
||||
*
|
||||
* @param serverID
|
||||
* server id
|
||||
* @param processID
|
||||
* process id
|
||||
* @return a ProcessDescription for a specific process from Cache.
|
||||
* @throws IOException
|
||||
* IO exception
|
||||
*/
|
||||
public ProcessDescriptionType getProcessDescription(String serverID,
|
||||
String processID) throws IOException {
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(
|
||||
serverID).getProcessDescriptions().getProcessDescriptionArray();
|
||||
public ProcessDescriptionType getProcessDescription(String serverID, String processID) throws IOException {
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(serverID).getProcessDescriptions()
|
||||
.getProcessDescriptionArray();
|
||||
for (ProcessDescriptionType process : processes) {
|
||||
if (process.getIdentifier().getStringValue().equals(processID)) {
|
||||
return process;
|
||||
|
@ -230,15 +238,18 @@ public class SClient4WPSSession implements Serializable {
|
|||
* the URL of the WPS
|
||||
* @return An Array of ProcessDescriptions
|
||||
* @throws IOException
|
||||
* IO exception
|
||||
*/
|
||||
public ProcessDescriptionType[] getAllProcessDescriptions(String wpsUrl)
|
||||
throws IOException {
|
||||
return getProcessDescriptionsFromCache(wpsUrl).getProcessDescriptions()
|
||||
.getProcessDescriptionArray();
|
||||
public ProcessDescriptionType[] getAllProcessDescriptions(String wpsUrl) throws IOException {
|
||||
return getProcessDescriptionsFromCache(wpsUrl).getProcessDescriptions().getProcessDescriptionArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* looks up, if the service exists already in session.
|
||||
*
|
||||
* @param serverID
|
||||
* service id
|
||||
* @return true if service is registered
|
||||
*/
|
||||
public boolean serviceAlreadyRegistered(String serverID) {
|
||||
return loggedServices.containsKey(serverID);
|
||||
|
@ -248,7 +259,8 @@ public class SClient4WPSSession implements Serializable {
|
|||
* provides you the cached capabilities for a specified service.
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* service url
|
||||
* @return capabilities document
|
||||
*/
|
||||
public CapabilitiesDocument getWPSCaps(String url) {
|
||||
return loggedServices.get(url);
|
||||
|
@ -261,18 +273,18 @@ public class SClient4WPSSession implements Serializable {
|
|||
* descriptions will not be cached, so only transient information!
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* service url
|
||||
* @return process descriptions document
|
||||
* @throws WPSClientException
|
||||
* WPS Client expcetion
|
||||
*/
|
||||
public ProcessDescriptionsDocument describeAllProcesses(String url)
|
||||
throws WPSClientException {
|
||||
public ProcessDescriptionsDocument describeAllProcesses(String url) throws WPSClientException {
|
||||
CapabilitiesDocument doc = loggedServices.get(url);
|
||||
if (doc == null) {
|
||||
logger.warn("serviceCaps are null, perhaps server does not exist");
|
||||
return null;
|
||||
}
|
||||
ProcessBriefType[] processes = doc.getCapabilities()
|
||||
.getProcessOfferings().getProcessArray();
|
||||
ProcessBriefType[] processes = doc.getCapabilities().getProcessOfferings().getProcessArray();
|
||||
String[] processIDs = new String[processes.length];
|
||||
for (int i = 0; i < processIDs.length; i++) {
|
||||
processIDs[i] = processes[i].getIdentifier().getStringValue();
|
||||
|
@ -285,27 +297,27 @@ public class SClient4WPSSession implements Serializable {
|
|||
* retrieves the desired description for a service. the retrieved
|
||||
* information will not be held in cache!
|
||||
*
|
||||
*
|
||||
* @param processIDs
|
||||
* one or more processIDs
|
||||
* process ids
|
||||
* @param serverID
|
||||
* server id
|
||||
* @return process description document
|
||||
* @throws WPSClientException
|
||||
* WPS Client expcetion
|
||||
*/
|
||||
public ProcessDescriptionsDocument describeProcess(String[] processIDs,
|
||||
String serverID) throws WPSClientException {
|
||||
public ProcessDescriptionsDocument describeProcess(String[] processIDs, String serverID) throws WPSClientException {
|
||||
|
||||
CapabilitiesDocument caps = this.loggedServices.get(serverID);
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata()
|
||||
.getOperationArray();
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata().getOperationArray();
|
||||
String url = null;
|
||||
for (Operation operation : operations) {
|
||||
if (operation.getName().equals("DescribeProcess")) {
|
||||
url = operation.getDCPArray()[0].getHTTP().getGetArray()[0]
|
||||
.getHref();
|
||||
url = operation.getDCPArray()[0].getHTTP().getGetArray()[0].getHref();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
throw new WPSClientException(
|
||||
"Missing DescribeOperation in Capabilities");
|
||||
throw new WPSClientException("Missing DescribeOperation in Capabilities");
|
||||
}
|
||||
return retrieveDescriptionViaGET(processIDs, url);
|
||||
}
|
||||
|
@ -320,16 +332,25 @@ public class SClient4WPSSession implements Serializable {
|
|||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
*/
|
||||
private Object execute(String serverID, ExecuteDocument execute,
|
||||
boolean rawData) throws WPSClientException {
|
||||
/**
|
||||
*
|
||||
* @param serverID
|
||||
* server id
|
||||
* @param execute
|
||||
* execute document
|
||||
* @param rawData
|
||||
* true if raw data
|
||||
* @return Object
|
||||
* @throws WPSClientException
|
||||
* WPS Client exception
|
||||
*/
|
||||
private Object execute(String serverID, ExecuteDocument execute, boolean rawData) throws WPSClientException {
|
||||
CapabilitiesDocument caps = loggedServices.get(serverID);
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata()
|
||||
.getOperationArray();
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata().getOperationArray();
|
||||
String url = null;
|
||||
for (Operation operation : operations) {
|
||||
if (operation.getName().equals("Execute")) {
|
||||
url = operation.getDCPArray()[0].getHTTP().getPostArray()[0]
|
||||
.getHref();
|
||||
url = operation.getDCPArray()[0].getHTTP().getPostArray()[0].getHref();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
|
@ -343,17 +364,18 @@ public class SClient4WPSSession implements Serializable {
|
|||
/**
|
||||
* Executes a process at a WPS
|
||||
*
|
||||
* @param serverId server id
|
||||
* url of server not the entry additionally defined in the caps.
|
||||
* @param serverId
|
||||
* server id url of server not the entry additionally defined in
|
||||
* the caps.
|
||||
* @param execute
|
||||
* Execute document
|
||||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
* @throws WPSClientException
|
||||
* WPS Client Exception
|
||||
*/
|
||||
public Object execute(String serverId, ExecuteDocument execute)
|
||||
throws WPSClientException {
|
||||
if (execute.getExecute().isSetResponseForm() == true
|
||||
&& execute.getExecute().isSetResponseForm() == true
|
||||
public Object execute(String serverId, ExecuteDocument execute) throws WPSClientException {
|
||||
if (execute.getExecute().isSetResponseForm() == true && execute.getExecute().isSetResponseForm() == true
|
||||
&& execute.getExecute().getResponseForm().isSetRawDataOutput() == true) {
|
||||
return execute(serverId, execute, true);
|
||||
} else {
|
||||
|
@ -362,8 +384,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
private CapabilitiesDocument retrieveCapsViaGET(String url)
|
||||
throws WPSClientException {
|
||||
private CapabilitiesDocument retrieveCapsViaGET(String url) throws WPSClientException {
|
||||
logger.debug("retrieveCapsViaGET: " + url);
|
||||
ClientCapabiltiesRequest req = new ClientCapabiltiesRequest();
|
||||
url = req.getRequest(url);
|
||||
|
@ -376,50 +397,41 @@ public class SClient4WPSSession implements Serializable {
|
|||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
Document doc = checkInputStream(is);
|
||||
CapabilitiesDocument capabilitiesDocument = CapabilitiesDocument.Factory
|
||||
.parse(doc, options);
|
||||
CapabilitiesDocument capabilitiesDocument = CapabilitiesDocument.Factory.parse(doc, options);
|
||||
return capabilitiesDocument;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + url, e);
|
||||
throw new WPSClientException("Capabilities URL seems to be unvalid: " + url, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ url, e);
|
||||
throw new WPSClientException("Error occured while retrieving capabilities from url: " + url, e);
|
||||
} catch (XmlException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while parsing XML", e);
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessDescriptionsDocument retrieveDescriptionViaGET(
|
||||
String[] processIDs, String url) throws WPSClientException {
|
||||
private ProcessDescriptionsDocument retrieveDescriptionViaGET(String[] processIDs, String url)
|
||||
throws WPSClientException {
|
||||
try {
|
||||
logger.debug("RetrieveDescription GET: " + processIDs + " url:"
|
||||
+ url);
|
||||
logger.debug("RetrieveDescription GET: " + processIDs + " url:" + url);
|
||||
|
||||
Path tempFile = Files.createTempFile("WPSProcessDescriptions",
|
||||
"txt");
|
||||
Path tempFile = Files.createTempFile("WPSProcessDescriptions", "txt");
|
||||
|
||||
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\" "
|
||||
+ "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);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.APPEND);
|
||||
|
||||
for (String processId : processIDs) {
|
||||
String[] process = { processId };
|
||||
|
@ -429,41 +441,35 @@ public class SClient4WPSSession implements Serializable {
|
|||
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64
|
||||
.encodeBase64(authString.getBytes());
|
||||
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();
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic "
|
||||
+ encoded);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
lines=retrievesSingleDescription(is);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
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);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.APPEND);
|
||||
|
||||
logger.debug(tempFile.toString());
|
||||
Document doc=null;
|
||||
try (InputStream inputStream = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)){
|
||||
Document doc = null;
|
||||
try (InputStream inputStream = Files.newInputStream(tempFile, StandardOpenOption.READ)) {
|
||||
doc = checkInputStream(inputStream);
|
||||
|
||||
}
|
||||
ProcessDescriptionsDocument processDescriptionsDocument = ProcessDescriptionsDocument.Factory.parse(doc, options);
|
||||
|
||||
|
||||
}
|
||||
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();
|
||||
|
@ -471,23 +477,19 @@ public class SClient4WPSSession implements Serializable {
|
|||
} catch (IOException e) {
|
||||
logger.error("Error occured while receiving data");
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while receiving data",
|
||||
e);
|
||||
throw new WPSClientException("Error occured while receiving data", e);
|
||||
} catch (XmlException e) {
|
||||
logger.error("Error occured while parsing ProcessDescription document");
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing ProcessDescription document",
|
||||
e);
|
||||
throw new WPSClientException("Error occured while parsing ProcessDescription document", e);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(e.getLocalizedMessage(),
|
||||
new Exception(e));
|
||||
throw new WPSClientException(e.getLocalizedMessage(), new Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
protected List<String> retrievesSingleDescription(InputStream is) throws WPSClientException {
|
||||
protected List<String> retrievesSingleDescription(InputStream is) throws WPSClientException {
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
|
@ -536,13 +538,11 @@ public class SClient4WPSSession implements Serializable {
|
|||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(e.getLocalizedMessage(),
|
||||
new Exception(e));
|
||||
throw new WPSClientException(e.getLocalizedMessage(), new Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream retrieveDataViaPOST(XmlObject obj, String urlString)
|
||||
throws WPSClientException {
|
||||
private InputStream retrieveDataViaPOST(XmlObject obj, String urlString) throws WPSClientException {
|
||||
try {
|
||||
logger.debug("RetrieveDataViaPost(): " + urlString);
|
||||
String authString = user + ":" + password;
|
||||
|
@ -584,45 +584,34 @@ public class SClient4WPSSession implements Serializable {
|
|||
logger.debug("Document: " + doc);
|
||||
if (doc == null) {
|
||||
logger.error("Document is null");
|
||||
throw new WPSClientException(
|
||||
"Error in check input stream: Document is null");
|
||||
throw new WPSClientException("Error in check input stream: Document is null");
|
||||
}
|
||||
|
||||
if (getFirstElementNode(doc.getFirstChild()).getLocalName().equals(
|
||||
"ExceptionReport")
|
||||
&& getFirstElementNode(doc.getFirstChild())
|
||||
.getNamespaceURI().equals(OGC_OWS_URI)) {
|
||||
if (getFirstElementNode(doc.getFirstChild()).getLocalName().equals("ExceptionReport")
|
||||
&& getFirstElementNode(doc.getFirstChild()).getNamespaceURI().equals(OGC_OWS_URI)) {
|
||||
try {
|
||||
ExceptionReportDocument exceptionDoc = ExceptionReportDocument.Factory
|
||||
.parse(doc);
|
||||
ExceptionReportDocument exceptionDoc = ExceptionReportDocument.Factory.parse(doc);
|
||||
logger.debug(exceptionDoc.xmlText(options));
|
||||
throw new WPSClientException(
|
||||
"Error occured while executing query", exceptionDoc);
|
||||
throw new WPSClientException("Error occured while executing query", exceptionDoc);
|
||||
} catch (XmlException e) {
|
||||
throw new WPSClientException(
|
||||
"Error while parsing ExceptionReport retrieved from server",
|
||||
e);
|
||||
throw new WPSClientException("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());
|
||||
logger.error("Error while parsing input: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error while parsing input", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occured while transfer: "
|
||||
+ e.getLocalizedMessage());
|
||||
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());
|
||||
logger.error("Error occured, parser is not correctly configured: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured, parser is not correctly configured", e);
|
||||
throw new WPSClientException("Error occured, parser is not correctly configured", e);
|
||||
} catch (WPSClientException e) {
|
||||
throw e;
|
||||
}
|
||||
|
@ -640,18 +629,8 @@ public class SClient4WPSSession implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* either an ExecuteResponseDocument or an InputStream if asked for RawData
|
||||
* or an Exception Report
|
||||
*
|
||||
* @param url
|
||||
* @param doc
|
||||
* @param rawData
|
||||
* @return
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
private Object retrieveExecuteResponseViaPOST(String url,
|
||||
ExecuteDocument doc, boolean rawData) throws WPSClientException {
|
||||
private Object retrieveExecuteResponseViaPOST(String url, ExecuteDocument doc, boolean rawData)
|
||||
throws WPSClientException {
|
||||
InputStream is = retrieveDataViaPOST(doc, url);
|
||||
if (rawData) {
|
||||
return is;
|
||||
|
@ -665,16 +644,15 @@ public class SClient4WPSSession implements Serializable {
|
|||
try {
|
||||
erDoc = ExceptionReportDocument.Factory.parse(documentObj);
|
||||
} catch (XmlException e1) {
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", e);
|
||||
throw new WPSClientException("Error occured while parsing executeResponse", e);
|
||||
}
|
||||
return erDoc;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getProcessNames(String url) throws IOException {
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(
|
||||
url).getProcessDescriptions().getProcessDescriptionArray();
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(url).getProcessDescriptions()
|
||||
.getProcessDescriptionArray();
|
||||
String[] processNames = new String[processes.length];
|
||||
for (int i = 0; i < processNames.length; i++) {
|
||||
processNames[i] = processes[i].getIdentifier().getStringValue();
|
||||
|
@ -691,9 +669,10 @@ public class SClient4WPSSession implements Serializable {
|
|||
* KVP Execute request
|
||||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
* @throws WPSClientException
|
||||
* WPS Client exception
|
||||
*/
|
||||
public Object executeViaGET(String urlString, String executeAsGETString)
|
||||
throws WPSClientException {
|
||||
public Object executeViaGET(String urlString, String executeAsGETString) throws WPSClientException {
|
||||
urlString = urlString + executeAsGETString;
|
||||
logger.debug("ExecuteViaGet() Url: " + urlString);
|
||||
try {
|
||||
|
@ -727,28 +706,22 @@ public class SClient4WPSSession implements Serializable {
|
|||
erDoc = ExceptionReportDocument.Factory.parse(doc);
|
||||
} catch (XmlException e1) {
|
||||
e1.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", e);
|
||||
throw new WPSClientException("Error occured while parsing executeResponse", e);
|
||||
|
||||
}
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", erDoc);
|
||||
throw new WPSClientException("Error occured while parsing executeResponse", erDoc);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + urlString, e);
|
||||
throw new WPSClientException("Capabilities URL seems to be unvalid: " + urlString, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ urlString, e);
|
||||
throw new WPSClientException("Error occured while retrieving capabilities from url: " + urlString, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String cancelComputation(String url, String computationId)
|
||||
throws WPSClientException {
|
||||
public String cancelComputation(String url, String computationId) throws WPSClientException {
|
||||
|
||||
try {
|
||||
String authString = user + ":" + password;
|
||||
|
@ -759,8 +732,7 @@ public class SClient4WPSSession implements Serializable {
|
|||
|
||||
url += "?id=" + computationId;
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
|
@ -768,13 +740,10 @@ public class SClient4WPSSession implements Serializable {
|
|||
return responseMessage;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + url, e);
|
||||
throw new WPSClientException("Capabilities URL seems to be unvalid: " + url, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ url, e);
|
||||
throw new WPSClientException("Error occured while retrieving capabilities from url: " + url, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,30 +42,32 @@ public class WPS2DM {
|
|||
/**
|
||||
*
|
||||
* @param title
|
||||
* title
|
||||
* @param minOcc
|
||||
* min occurrences
|
||||
* @param maxOcc
|
||||
* max occurrences
|
||||
* @param rangeOccs
|
||||
* range occurrences
|
||||
* @param id
|
||||
* id
|
||||
* @param crs
|
||||
* @return
|
||||
* crs
|
||||
* @return parameter
|
||||
*/
|
||||
public static Parameter manageBoundingBoxInformation(String title,
|
||||
int minOcc, int maxOcc, int rangeOccs, String id, String crs) {
|
||||
public static Parameter manageBoundingBoxInformation(String title, int minOcc, int maxOcc, int rangeOccs, String id,
|
||||
String crs) {
|
||||
Parameter converted = null;
|
||||
title = "Bounding Box Input in OGC 06-121r3 spec. E.g. 102,46,103,47,urn:ogc:def:crs:EPSG:4328 "
|
||||
+ title;
|
||||
title = "Bounding Box Input in OGC 06-121r3 spec. E.g. 102,46,103,47,urn:ogc:def:crs:EPSG:4328 " + title;
|
||||
if (crs != null && crs.length() > 0)
|
||||
title += " Supported CRS " + crs;
|
||||
|
||||
title = buildParameterDescription(title, null, null, minOcc, maxOcc,
|
||||
null);
|
||||
title = buildParameterDescription(title, null, null, minOcc, maxOcc, null);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0))
|
||||
converted = new ObjectParameter(id, title, String.class.getName(),
|
||||
" ");
|
||||
converted = new ObjectParameter(id, title, String.class.getName(), " ");
|
||||
|
||||
else
|
||||
converted = new ListParameter(id, title, String.class.getName(),
|
||||
SEPARATOR);
|
||||
converted = new ListParameter(id, title, String.class.getName(), SEPARATOR);
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
@ -73,18 +75,25 @@ public class WPS2DM {
|
|||
/**
|
||||
*
|
||||
* @param title
|
||||
* title
|
||||
* @param minOcc
|
||||
* min occurrences
|
||||
* @param maxOcc
|
||||
* max occurences
|
||||
* @param rangeOccs
|
||||
* range occurences
|
||||
* @param defaultValue
|
||||
* default value
|
||||
* @param id
|
||||
* id
|
||||
* @param uoms
|
||||
* uoms
|
||||
* @param type
|
||||
* @return
|
||||
* type
|
||||
* @return parameter
|
||||
*/
|
||||
public static Parameter manageLiteral(String title, int minOcc, int maxOcc,
|
||||
int rangeOccs, String defaultValue, String id, String uoms,
|
||||
DomainMetadataType type) {
|
||||
public static Parameter manageLiteral(String title, int minOcc, int maxOcc, int rangeOccs, String defaultValue,
|
||||
String id, String uoms, DomainMetadataType type) {
|
||||
Parameter converted = null;
|
||||
logger.debug("WPS type:" + type.getStringValue());
|
||||
String guessedType = guessWPSLiteralType(type);
|
||||
|
@ -96,8 +105,7 @@ public class WPS2DM {
|
|||
|
||||
logger.debug("Guessed default value: " + defaultValue);
|
||||
|
||||
title = buildParameterDescription(title, null, uoms, minOcc, maxOcc,
|
||||
defaultValue);
|
||||
title = buildParameterDescription(title, null, uoms, minOcc, maxOcc, defaultValue);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0)) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("[a sequence of names of columns from ")) {
|
||||
|
@ -111,72 +119,56 @@ public class WPS2DM {
|
|||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: " + matcher.groupCount());
|
||||
String referredTabularParameterName = matcher.group(1);
|
||||
logger.debug("Matcher referredTabularParameterName: "
|
||||
+ referredTabularParameterName);
|
||||
logger.debug("Matcher referredTabularParameterName: " + referredTabularParameterName);
|
||||
String separator = matcher.group(2);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
|
||||
converted = new ColumnListParameter(id, title,
|
||||
referredTabularParameterName, separator);
|
||||
converted = new ColumnListParameter(id, title, referredTabularParameterName, separator);
|
||||
} else {
|
||||
if (title.contains("[the name of a column from ")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("the name of a column from (\\w+)");
|
||||
Pattern pattern = Pattern.compile("the name of a column from (\\w+)");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + matcher.find());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
logger.debug("Machter Group Count: " + matcher.groupCount());
|
||||
String referredTabularParameterName = matcher.group(1);
|
||||
logger.debug("Matcher referredTabularParameterName: "
|
||||
+ referredTabularParameterName);
|
||||
logger.debug("Matcher referredTabularParameterName: " + referredTabularParameterName);
|
||||
|
||||
converted = new ColumnParameter(id, title,
|
||||
referredTabularParameterName, defaultValue);
|
||||
converted = new ColumnParameter(id, title, referredTabularParameterName, defaultValue);
|
||||
} else {
|
||||
if (title
|
||||
.contains("[a sequence of values separated by ")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("a sequence of values separated by (\\p{ASCII})");
|
||||
if (title.contains("[a sequence of values separated by ")) {
|
||||
Pattern pattern = Pattern.compile("a sequence of values separated by (\\p{ASCII})");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + matcher.find());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
logger.debug("Machter Group Count: " + matcher.groupCount());
|
||||
|
||||
String separator = matcher.group(1);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
|
||||
converted = new ListParameter(id, title,
|
||||
guessedType, separator);
|
||||
converted = new ListParameter(id, title, guessedType, separator);
|
||||
} else {
|
||||
if (title.contains("[WKT_")) {
|
||||
logger.debug("WKT parameter: " + title);
|
||||
converted = retrieveWKTParameter(id, title,
|
||||
defaultValue);
|
||||
converted = retrieveWKTParameter(id, title, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[DATE]")) {
|
||||
logger.debug("DATE parameter: " + title);
|
||||
title = title.replace("[DATE]", "");
|
||||
converted = new DateParameter(id, title,
|
||||
defaultValue);
|
||||
converted = new DateParameter(id, title, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[TIME]")) {
|
||||
logger.debug("TIME parameter: " + title);
|
||||
title = title.replace("[TIME]", "");
|
||||
converted = new TimeParameter(id,
|
||||
title, defaultValue);
|
||||
converted = new TimeParameter(id, title, defaultValue);
|
||||
} else {
|
||||
converted = new ObjectParameter(
|
||||
id,
|
||||
title,
|
||||
guessPrimitiveType(guessedType),
|
||||
converted = new ObjectParameter(id, title, guessPrimitiveType(guessedType),
|
||||
defaultValue);
|
||||
}
|
||||
}
|
||||
|
@ -186,78 +178,59 @@ public class WPS2DM {
|
|||
}
|
||||
|
||||
} else {
|
||||
converted = new ObjectParameter(id, title,
|
||||
guessPrimitiveType(guessedType), defaultValue);
|
||||
converted = new ObjectParameter(id, title, guessPrimitiveType(guessedType), defaultValue);
|
||||
}
|
||||
|
||||
} else {
|
||||
if(guessedType.compareTo(Boolean.class.getName())==0){
|
||||
if (guessedType.compareTo(Boolean.class.getName()) == 0) {
|
||||
converted = new ObjectParameter(id, title, guessedType, defaultValue);
|
||||
} else {
|
||||
converted = new ListParameter(id, title, String.class.getName(),
|
||||
SEPARATOR);
|
||||
converted = new ListParameter(id, title, String.class.getName(), SEPARATOR);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
private static Parameter retrieveWKTParameter(String id, String title,
|
||||
String defaultValue) {
|
||||
private static Parameter retrieveWKTParameter(String id, String title, String defaultValue) {
|
||||
|
||||
if (title.contains("[WKT_POINT]")) {
|
||||
title = title.replace("[WKT_POINT]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Point,
|
||||
defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Point, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_LINESTRING]")) {
|
||||
title = title.replace("[WKT_LINESTRING]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.LineString,
|
||||
defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.LineString, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_POLYGON]")) {
|
||||
title = title.replace("[WKT_POLYGON]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Polygon,
|
||||
defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Polygon, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_CIRCLE]")) {
|
||||
title = title.replace("[WKT_CIRCLE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Circle, defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Circle, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_TRIANGLE]")) {
|
||||
title = title.replace("[WKT_TRIANGLE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Triangle, defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Triangle, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_SQUARE]")) {
|
||||
title = title.replace("[WKT_SQUARE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Square, defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Square, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_PENTAGON]")) {
|
||||
title = title.replace("[WKT_PENTAGON]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Pentagon,
|
||||
defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Pentagon, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_HEXAGON]")) {
|
||||
title = title.replace("[WKT_HEXAGON]",
|
||||
"");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Hexagon,
|
||||
defaultValue);
|
||||
title = title.replace("[WKT_HEXAGON]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Hexagon, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_BOX]")) {
|
||||
title = title.replace("[WKT_BOX]",
|
||||
"");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Box,
|
||||
defaultValue);
|
||||
title = title.replace("[WKT_BOX]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Box, defaultValue);
|
||||
} else {
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Polygon,
|
||||
defaultValue);
|
||||
return new WKTParameter(id, title, WKTGeometryType.Polygon, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,18 +245,25 @@ public class WPS2DM {
|
|||
/**
|
||||
*
|
||||
* @param maxMegaBytes
|
||||
* max mega bytes
|
||||
* @param title
|
||||
* title
|
||||
* @param minOcc
|
||||
* min occurrences
|
||||
* @param maxOcc
|
||||
* max occurrences
|
||||
* @param rangeOccs
|
||||
* range occurrences
|
||||
* @param id
|
||||
* id
|
||||
* @param defaultType
|
||||
* @return
|
||||
* default type
|
||||
* @param supportedTypes
|
||||
* supported type
|
||||
* @return parameter
|
||||
*/
|
||||
public static Parameter manageComplexData(String maxMegaBytes,
|
||||
String title, int minOcc, int maxOcc, int rangeOccs, String id,
|
||||
ComplexDataDescriptionType defaultType,
|
||||
ComplexDataDescriptionType[] supportedTypes) {
|
||||
public static Parameter manageComplexData(String maxMegaBytes, String title, int minOcc, int maxOcc, int rangeOccs,
|
||||
String id, ComplexDataDescriptionType defaultType, ComplexDataDescriptionType[] supportedTypes) {
|
||||
Parameter converted = null;
|
||||
String mimeType = null;
|
||||
String schema = null;
|
||||
|
@ -303,68 +283,56 @@ public class WPS2DM {
|
|||
supportedMimeTypes.add(supported.getMimeType());
|
||||
}
|
||||
// rebuild title
|
||||
title = buildParameterDescription(title, maxMegaBytes, null, minOcc,
|
||||
maxOcc, null);
|
||||
title = buildParameterDescription(title, maxMegaBytes, null, minOcc, maxOcc, null);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0)) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("[a http link to a table")) {
|
||||
converted = new TabularParameter(id, title, " ",
|
||||
new ArrayList<String>(), mimeType,
|
||||
converted = new TabularParameter(id, title, " ", new ArrayList<String>(), mimeType,
|
||||
supportedMimeTypes);
|
||||
} else {
|
||||
if (title.contains("[a http link to a file")) {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
|
||||
} else {
|
||||
if (title.contains("[a sequence of http links")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("\\[a sequence of http links separated by (\\p{ASCII}) , each indicating a table");
|
||||
Pattern pattern = Pattern.compile(
|
||||
"\\[a sequence of http links separated by (\\p{ASCII}) , each indicating a table");
|
||||
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
boolean match = false;
|
||||
if (match = matcher.find()) {
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + match);
|
||||
logger.debug("Machter group: "
|
||||
+ matcher.group());
|
||||
logger.debug("Machter start: "
|
||||
+ matcher.start());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
logger.debug("Machter Group Count: " + matcher.groupCount());
|
||||
String separator = matcher.group(1);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
converted = new TabularListParameter(id, title,
|
||||
separator, mimeType, supportedMimeTypes);
|
||||
converted = new TabularListParameter(id, title, separator, mimeType,
|
||||
supportedMimeTypes);
|
||||
} else {
|
||||
converted = new FileParameter(id, title,
|
||||
mimeType, supportedMimeTypes);
|
||||
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
public static Parameter convert2DMType(InputDescriptionType wpsType)
|
||||
throws ServiceException {
|
||||
public static Parameter convert2DMType(InputDescriptionType wpsType) throws ServiceException {
|
||||
try {
|
||||
|
||||
String id = wpsType.getIdentifier().getStringValue();
|
||||
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle()
|
||||
.getStringValue() : "";
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle().getStringValue() : "";
|
||||
int minOcc = wpsType.getMinOccurs().intValue();
|
||||
int maxOcc = wpsType.getMaxOccurs().intValue();
|
||||
int rangeOccs = maxOcc - minOcc;
|
||||
|
@ -372,30 +340,24 @@ public class WPS2DM {
|
|||
rangeOccs = 1;
|
||||
|
||||
// default
|
||||
Parameter converted = new ObjectParameter(id, title,
|
||||
String.class.getName(), " ");
|
||||
Parameter converted = new ObjectParameter(id, title, String.class.getName(), " ");
|
||||
if (rangeOccs > 1)
|
||||
converted = new ListParameter(id, title,
|
||||
String.class.getName(), SEPARATOR);
|
||||
converted = new ListParameter(id, title, String.class.getName(), SEPARATOR);
|
||||
|
||||
// Bounding Boxes
|
||||
if (wpsType.isSetBoundingBoxData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Bounding Box Input");
|
||||
converted = manageBoundingBoxInformation(title, minOcc, maxOcc,
|
||||
rangeOccs, id, wpsType.getBoundingBoxData()
|
||||
.getDefault().getCRS());
|
||||
logger.debug("Conversion to DM Type->" + id + " is a Bounding Box Input");
|
||||
converted = manageBoundingBoxInformation(title, minOcc, maxOcc, rangeOccs, id,
|
||||
wpsType.getBoundingBoxData().getDefault().getCRS());
|
||||
}
|
||||
// Literals
|
||||
else if (wpsType.isSetLiteralData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Literal Input");
|
||||
logger.debug("Conversion to DM Type->" + id + " is a Literal Input");
|
||||
LiteralInputType literal = wpsType.getLiteralData();
|
||||
String uoms = literal.getUOMs() == null ? "" : literal
|
||||
.getUOMs().getDefault().getUOM().getStringValue();
|
||||
String uoms = literal.getUOMs() == null ? "" : literal.getUOMs().getDefault().getUOM().getStringValue();
|
||||
String defaultValue = literal.getDefaultValue();
|
||||
converted = manageLiteral(title, minOcc, maxOcc, rangeOccs,
|
||||
defaultValue, id, uoms, literal.getDataType());
|
||||
converted = manageLiteral(title, minOcc, maxOcc, rangeOccs, defaultValue, id, uoms,
|
||||
literal.getDataType());
|
||||
AllowedValues allowedValues = literal.getAllowedValues();
|
||||
if (allowedValues != null) {
|
||||
ValueType[] values = allowedValues.getValueArray();
|
||||
|
@ -407,35 +369,27 @@ public class WPS2DM {
|
|||
}
|
||||
if (values.length > 1) {
|
||||
ObjectParameter conv = (ObjectParameter) converted;
|
||||
if (conv.getType() != null
|
||||
&& !conv.getType().isEmpty()
|
||||
&& conv.getType().compareToIgnoreCase(
|
||||
Boolean.class.getName()) != 0){
|
||||
converted = new EnumParameter(conv.getName(),
|
||||
conv.getDescription(), enumValues,
|
||||
if (conv.getType() != null && !conv.getType().isEmpty()
|
||||
&& conv.getType().compareToIgnoreCase(Boolean.class.getName()) != 0) {
|
||||
converted = new EnumParameter(conv.getName(), conv.getDescription(), enumValues,
|
||||
conv.getDefaultValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (wpsType.isSetComplexData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Complex Input");
|
||||
SupportedComplexDataInputType complex = wpsType
|
||||
.getComplexData();
|
||||
String maxMegaBytes = complex.getMaximumMegabytes() != null ? complex
|
||||
.getMaximumMegabytes().toString() : "1";
|
||||
logger.debug("Conversion to DM Type->" + id + " is a Complex Input");
|
||||
SupportedComplexDataInputType complex = wpsType.getComplexData();
|
||||
String maxMegaBytes = complex.getMaximumMegabytes() != null ? complex.getMaximumMegabytes().toString()
|
||||
: "1";
|
||||
logger.debug("Max Megabytes: " + maxMegaBytes);
|
||||
converted = manageComplexData(maxMegaBytes, title, minOcc,
|
||||
maxOcc, rangeOccs, id,
|
||||
complex.getDefault().getFormat(), complex
|
||||
.getSupported().getFormatArray());
|
||||
converted = manageComplexData(maxMegaBytes, title, minOcc, maxOcc, rangeOccs, id,
|
||||
complex.getDefault().getFormat(), complex.getSupported().getFormatArray());
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Conversion to DM Type->Name=" + id);
|
||||
logger.debug("Conversion to DM Type->Title=" + title);
|
||||
logger.debug("Conversion to DM Type->Number of Inputs to Manage="
|
||||
+ rangeOccs);
|
||||
logger.debug("Conversion to DM Type->Number of Inputs to Manage=" + rangeOccs);
|
||||
|
||||
return converted;
|
||||
|
||||
|
@ -449,12 +403,10 @@ public class WPS2DM {
|
|||
public static Parameter convert2DMType(OutputDescriptionType wpsType) {
|
||||
|
||||
String id = wpsType.getIdentifier().getStringValue();
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle()
|
||||
.getStringValue() : "";
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle().getStringValue() : "";
|
||||
|
||||
// default
|
||||
Parameter converted = new ObjectParameter(id, title,
|
||||
String.class.getName(), " ");
|
||||
Parameter converted = new ObjectParameter(id, title, String.class.getName(), " ");
|
||||
|
||||
logger.debug("Conversion to DM Type->Output id:" + id);
|
||||
logger.debug("Conversion to DM Type->Title:" + title);
|
||||
|
@ -468,16 +420,13 @@ public class WPS2DM {
|
|||
else if (wpsType.isSetLiteralOutput()) {
|
||||
logger.debug("Literal Output");
|
||||
LiteralOutputType literal = wpsType.getLiteralOutput();
|
||||
String uoms = literal.getUOMs() == null ? "" : literal.getUOMs()
|
||||
.toString();
|
||||
converted = manageLiteral(title, -1, -1, -1, "", id, uoms,
|
||||
literal.getDataType());
|
||||
String uoms = literal.getUOMs() == null ? "" : literal.getUOMs().toString();
|
||||
converted = manageLiteral(title, -1, -1, -1, "", id, uoms, literal.getDataType());
|
||||
} else if (wpsType.isSetComplexOutput()) {
|
||||
logger.debug("Complex Output");
|
||||
SupportedComplexDataType complex = wpsType.getComplexOutput();
|
||||
converted = manageComplexData("", title, -1, -1, -1, id, complex
|
||||
.getDefault().getFormat(), complex.getSupported()
|
||||
.getFormatArray());
|
||||
converted = manageComplexData("", title, -1, -1, -1, id, complex.getDefault().getFormat(),
|
||||
complex.getSupported().getFormatArray());
|
||||
}
|
||||
|
||||
return converted;
|
||||
|
@ -486,16 +435,21 @@ public class WPS2DM {
|
|||
/**
|
||||
*
|
||||
* @param title
|
||||
* title
|
||||
* @param maxMegabytes
|
||||
* max mega bytes
|
||||
* @param UoM
|
||||
* UoM
|
||||
* @param minElements
|
||||
* min elements
|
||||
* @param maxElements
|
||||
* max elements
|
||||
* @param defaultValue
|
||||
* @return
|
||||
* default value
|
||||
* @return description
|
||||
*/
|
||||
public static String buildParameterDescription(String title,
|
||||
String maxMegabytes, String UoM, int minElements, int maxElements,
|
||||
String defaultValue) {
|
||||
public static String buildParameterDescription(String title, String maxMegabytes, String UoM, int minElements,
|
||||
int maxElements, String defaultValue) {
|
||||
|
||||
String description = title;
|
||||
/*
|
||||
|
@ -527,8 +481,7 @@ public class WPS2DM {
|
|||
String typeS = type.getReference().trim();
|
||||
if (typeS.length() == 0)
|
||||
return String.class.getName();
|
||||
else if (typeS.contains("float") || typeS.contains("double")
|
||||
|| typeS.contains("decimal"))
|
||||
else if (typeS.contains("float") || typeS.contains("double") || typeS.contains("decimal"))
|
||||
return Double.class.getName();
|
||||
else if (typeS.contains("int"))
|
||||
return Integer.class.getName();
|
||||
|
@ -538,7 +491,7 @@ public class WPS2DM {
|
|||
return Short.class.getName();
|
||||
else if (typeS.contains("boolean"))
|
||||
return Boolean.class.getName();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return String.class.getName();
|
||||
|
@ -552,7 +505,7 @@ public class WPS2DM {
|
|||
}
|
||||
|
||||
public static String guessPrimitiveType(String type) {
|
||||
|
||||
|
||||
if (type.equals(Integer.class.getName())) {
|
||||
return Integer.class.getName();
|
||||
} else if (type.equals(String.class.getName())) {
|
||||
|
|
|
@ -35,6 +35,7 @@ public class ComputationValueBuilder {
|
|||
|
||||
/**
|
||||
*
|
||||
* @return map from parameter to computation value
|
||||
*/
|
||||
public LinkedHashMap<String, ComputationValue> create() {
|
||||
computationsValueParameters = new LinkedHashMap<String, ComputationValue>();
|
||||
|
|
|
@ -115,11 +115,12 @@ public class StorageUtil {
|
|||
/**
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* user
|
||||
* @param itemId
|
||||
* Item id
|
||||
* @return Public link
|
||||
* @throws StatAlgoImporterServiceException
|
||||
* item id
|
||||
* @return public link
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static String getPublicLink(String user, String itemId) throws ServiceException {
|
||||
Workspace ws;
|
||||
|
@ -144,9 +145,12 @@ public class StorageUtil {
|
|||
/**
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param folderId
|
||||
* @return
|
||||
* folder id
|
||||
* @return zip folder
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static File zipFolder(String user, String folderId) throws ServiceException {
|
||||
Workspace ws;
|
||||
|
@ -175,9 +179,12 @@ public class StorageUtil {
|
|||
/**
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param itemName
|
||||
* @return
|
||||
* item name
|
||||
* @return workspace item
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static WorkspaceItem getItemInRootFolderOnWorkspace(String user, String itemName) throws ServiceException {
|
||||
Workspace ws;
|
||||
|
@ -197,10 +204,14 @@ public class StorageUtil {
|
|||
/**
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param folderId
|
||||
* folder id
|
||||
* @param itemName
|
||||
* @return
|
||||
* item name
|
||||
* @return workspace item
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static WorkspaceItem getItemInFolderOnWorkspace(String user, String folderId, String itemName)
|
||||
throws ServiceException {
|
||||
|
@ -221,8 +232,11 @@ public class StorageUtil {
|
|||
/**
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param itemId
|
||||
* item id
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static void deleteItem(String user, String itemId) throws ServiceException {
|
||||
Workspace ws;
|
||||
|
@ -241,6 +255,14 @@ public class StorageUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param is
|
||||
* input stream
|
||||
* @return public link
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static String saveOnStorageInTemporalFile(InputStream is) throws ServiceException {
|
||||
try {
|
||||
logger.debug("SaveOnStorageInTemporalFile()");
|
||||
|
|
|
@ -49,8 +49,9 @@ public class ObjectResource extends Resource {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* the url to set
|
||||
*
|
||||
* @param value
|
||||
* value
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
|
|
|
@ -5,16 +5,14 @@ package org.gcube.portlets.user.dataminermanager.shared.exception;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ServiceException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -2255657546267656458L;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -24,15 +22,21 @@ public class ServiceException extends Exception {
|
|||
|
||||
/**
|
||||
* @param message
|
||||
* message
|
||||
*/
|
||||
public ServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public ServiceException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
* message
|
||||
* @param throwable
|
||||
* error
|
||||
*/
|
||||
public ServiceException(String message, Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ package org.gcube.portlets.user.dataminermanager.shared.exception;
|
|||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class SessionExpiredServiceException extends
|
||||
ServiceException {
|
||||
public class SessionExpiredServiceException extends ServiceException {
|
||||
|
||||
private static final long serialVersionUID = -4831171355042165166L;
|
||||
|
||||
|
@ -19,7 +18,9 @@ public class SessionExpiredServiceException extends
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
* message
|
||||
*/
|
||||
public SessionExpiredServiceException(String message) {
|
||||
super(message);
|
||||
|
@ -28,10 +29,12 @@ public class SessionExpiredServiceException extends
|
|||
/**
|
||||
*
|
||||
* @param message
|
||||
* @param t
|
||||
* message
|
||||
* @param throwable
|
||||
* errror
|
||||
*/
|
||||
public SessionExpiredServiceException(String message, Throwable t) {
|
||||
super(message, t);
|
||||
public SessionExpiredServiceException(String message, Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,8 +66,9 @@ public class ColumnParameter extends Parameter {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* the default value to set
|
||||
*
|
||||
* @param defaultColumn
|
||||
* default column
|
||||
*/
|
||||
public void setDefaultColumn(String defaultColumn) {
|
||||
this.defaultColumn = defaultColumn;
|
||||
|
|
|
@ -86,7 +86,7 @@ public abstract class Parameter implements Serializable {
|
|||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
|
@ -95,6 +95,7 @@ public abstract class Parameter implements Serializable {
|
|||
/**
|
||||
*
|
||||
* @param value
|
||||
* value
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
|
|
|
@ -56,11 +56,17 @@ public class Operator implements Serializable, Comparable<Operator> {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param briefDescription
|
||||
* brief description
|
||||
* @param description
|
||||
* description
|
||||
* @param category
|
||||
* category
|
||||
* @param hasImage
|
||||
* true if has image
|
||||
*/
|
||||
public Operator(String id, String briefDescription, String description, OperatorCategory category,
|
||||
boolean hasImage) {
|
||||
|
@ -75,10 +81,17 @@ public class Operator implements Serializable, Comparable<Operator> {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param name
|
||||
* name
|
||||
* @param briefDescription
|
||||
* brief description
|
||||
* @param description
|
||||
* description
|
||||
* @param category
|
||||
* category
|
||||
*/
|
||||
public Operator(String id, String name, String briefDescription, String description, OperatorCategory category) {
|
||||
super();
|
||||
|
@ -91,13 +104,21 @@ public class Operator implements Serializable, Comparable<Operator> {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param name
|
||||
* name
|
||||
* @param briefDescription
|
||||
* brief description
|
||||
* @param description
|
||||
* description
|
||||
* @param category
|
||||
* category
|
||||
* @param operatorParameters
|
||||
* operator parameters
|
||||
* @param hasImage
|
||||
* true if has image
|
||||
*/
|
||||
public Operator(String id, String name, String briefDescription, String description, OperatorCategory category,
|
||||
List<Parameter> operatorParameters, boolean hasImage) {
|
||||
|
|
Loading…
Reference in New Issue