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