configuration for external build dir added

feature/23107
Lucio Lelii 3 years ago
parent a0aa2a30d5
commit 19e2c641d7

@ -6,22 +6,12 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

@ -3,6 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,36 @@
# Changelog
## [v1.1.5] [r4.24.0] - 2020-06-05
### Fixes
- Updated ExecuteResponseBuilder for support protocol option [#19423]
- Updated to Git and Jenkins [#18120]
## [v1.1.3] - 2018-12-13
### Features
- Added https support [#13024]
## [v1.1.0] - 2017-09-24
### Features
- Dynamic adding, removing and updating of algorithms added
- Moved to SocialNetworkingService 2.0
## [v1.0.0] - 2017-09-01
- First Release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

@ -1,11 +1,12 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.data-analysis.wps.1-1-5" <Changeset component="org.gcube.data-analysis.wps.1-1-5"
date="2019-11-21"> date="2020-06-05">
<Change>Updated to Git and Jenkins [ticket #18120]</Change> <Change>Updated ExecuteResponseBuilder for support protocol option [#19129]</Change>
<Change>Updated to Git and Jenkins [#18120]</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.data-analysis.wps.1-1-3" <Changeset component="org.gcube.data-analysis.wps.1-1-3"
date="2018-12-13"> date="2018-12-13">
<Change>Added https support [ticket #13024]</Change> <Change>Added https support [#13024]</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.data-analysis.wps.1-1-0" <Changeset component="org.gcube.data-analysis.wps.1-1-0"
date="2017-09-24"> date="2017-09-24">

@ -14,6 +14,7 @@
<includes> <includes>
<include>README.md</include> <include>README.md</include>
<include>LICENSE.md</include> <include>LICENSE.md</include>
<include>CHANGELOG.md</include>
<include>gcube-app.xml</include> <include>gcube-app.xml</include>
<include>changelog.xml</include> <include>changelog.xml</include>
<include>profile.xml</include> <include>profile.xml</include>

@ -1,4 +1,5 @@
package org.gcube.data.analysis.wps; package org.gcube.data.analysis.wps;
import java.io.InputStream; import java.io.InputStream;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -19,6 +20,7 @@ import net.opengis.wps.x100.ProcessDescriptionType;
import net.opengis.wps.x100.StatusType; import net.opengis.wps.x100.StatusType;
import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor;
import org.n52.wps.ServerDocument.Server;
import org.n52.wps.commons.WPSConfig; import org.n52.wps.commons.WPSConfig;
import org.n52.wps.io.data.IBBOXData; import org.n52.wps.io.data.IBBOXData;
import org.n52.wps.io.data.IData; import org.n52.wps.io.data.IData;
@ -33,10 +35,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* WPS Execute operation response. By default, this XML document is delivered to the client in response to an Execute request. If "status" is "false" in the Execute operation request, this document is normally returned when process execution has been completed. * WPS Execute operation response. By default, this XML document is delivered to
* If "status" in the Execute request is "true", this response shall be returned as soon as the Execute request has been accepted for processing. In this case, the same XML document is also made available as a web-accessible resource from the URL identified in the statusLocation, and the WPS server shall repopulate it once the process has completed. It may repopulate it on an ongoing basis while the process is executing. * the client in response to an Execute request. If "status" is "false" in the
* However, the response to an Execute request will not include this element in the special case where the output is a single complex value result and the Execute request indicates that "store" is "false". * Execute operation request, this document is normally returned when process
* Instead, the server shall return the complex result (e.g., GIF image or GML) directly, without encoding it in the ExecuteResponse. If processing fails in this special case, the normal ExecuteResponse shall be sent, with the error condition indicated. This option is provided to simplify the programming required for simple clients and for service chaining. * execution has been completed. If "status" in the Execute request is "true",
* this response shall be returned as soon as the Execute request has been
* accepted for processing. In this case, the same XML document is also made
* available as a web-accessible resource from the URL identified in the
* statusLocation, and the WPS server shall repopulate it once the process has
* completed. It may repopulate it on an ongoing basis while the process is
* executing. However, the response to an Execute request will not include this
* element in the special case where the output is a single complex value result
* and the Execute request indicates that "store" is "false". Instead, the
* server shall return the complex result (e.g., GIF image or GML) directly,
* without encoding it in the ExecuteResponse. If processing fails in this
* special case, the normal ExecuteResponse shall be sent, with the error
* condition indicated. This option is provided to simplify the programming
* required for simple clients and for service chaining.
*
* @author Timon ter Braak * @author Timon ter Braak
* *
*/ */
@ -44,7 +60,7 @@ public class ExecuteResponseBuilder {
private String identifier; private String identifier;
private DataInputsType dataInputs; private DataInputsType dataInputs;
//private DocumentOutputDefinitionType[] outputDefs; // private DocumentOutputDefinitionType[] outputDefs;
private ExecuteRequest request; private ExecuteRequest request;
private ExecuteResponseDocument doc; private ExecuteResponseDocument doc;
private RawData rawDataHandler = null; private RawData rawDataHandler = null;
@ -53,10 +69,8 @@ public class ExecuteResponseBuilder {
private Calendar creationTime; private Calendar creationTime;
String webPath; String webPath;
String webStatus; String webStatus;
public ExecuteResponseBuilder(ExecuteRequest request) throws ExceptionReport {
public ExecuteResponseBuilder(ExecuteRequest request) throws ExceptionReport{
LOGGER.debug("Building Doc"); LOGGER.debug("Building Doc");
this.request = request; this.request = request;
doc = ExecuteResponseDocument.Factory.newInstance(); doc = ExecuteResponseDocument.Factory.newInstance();
@ -64,46 +78,61 @@ public class ExecuteResponseBuilder {
XmlCursor c = doc.newCursor(); XmlCursor c = doc.newCursor();
c.toFirstChild(); c.toFirstChild();
c.toLastAttribute(); c.toLastAttribute();
c.setAttributeText(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation"), "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd"); c.setAttributeText(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation"),
"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd");
String webapp = WPSConfig.getInstance().getWPSConfig().getServer().getWebappPath();
Server docServer = WPSConfig.getInstance().getWPSConfig().getServer();
String webapp = docServer.getWebappPath();
if (webapp == null) if (webapp == null)
webapp = "wps"; webapp = "wps";
String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname(); String host = docServer.getHostname();
if (host.toLowerCase().equals("localhost")) if (host.toLowerCase().equals("localhost"))
try { try {
host = Inet4Address.getLocalHost().getHostAddress(); host = Inet4Address.getLocalHost().getHostAddress();
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
LOGGER.error("error",e); LOGGER.error("error", e);
} }
String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport(); String port = docServer.getHostport();
LOGGER.debug("Host: " + host + " Port: " + port + " Webapp: " + webapp + " ");
webPath = "http://" + host + ":" + port + "/" + webapp + "/WebProcessingService"; String protocol = docServer.getProtocol();
webStatus = "http://" + host + ":" + port + "/" + webapp + "/RetrieveResultServlet";
if (protocol == null || protocol.isEmpty()) {
//statistical-manager-new.d4science.org:8080/wps/WebProcessingService?Request=GetCapabilities&Service=WPS LOGGER.info("Protocol not found, use https in default mode.");
protocol = "https";
// doc.getExecuteResponse().setServiceInstance(webPath+"?REQUEST=GetCapabilities&SERVICE=WPS"); }
LOGGER.debug("Service Config: [Protocol: {}, Host: {} , Port: {}, Webapp: {} ]", protocol, host, port, webapp);
webPath = protocol + "://" + host + ":" + port + "/" + webapp + "/WebProcessingService";
webStatus = protocol + "://" + host + ":" + port + "/" + webapp + "/RetrieveResultServlet";
LOGGER.debug("WebPath: {}", webPath);
LOGGER.debug("WebStatus: {}", webStatus);
// statistical-manager-new.d4science.org:8080/wps/WebProcessingService?Request=GetCapabilities&Service=WPS
// doc.getExecuteResponse().setServiceInstance(webPath+"?REQUEST=GetCapabilities&SERVICE=WPS");
doc.getExecuteResponse().setServiceInstance(webPath); doc.getExecuteResponse().setServiceInstance(webPath);
doc.getExecuteResponse().setLang(WebProcessingService.DEFAULT_LANGUAGE); doc.getExecuteResponse().setLang(WebProcessingService.DEFAULT_LANGUAGE);
doc.getExecuteResponse().setService("WPS"); doc.getExecuteResponse().setService("WPS");
doc.getExecuteResponse().setVersion(Request.SUPPORTED_VERSION); doc.getExecuteResponse().setVersion(Request.SUPPORTED_VERSION);
LOGGER.debug("Doc attributes set"); LOGGER.debug("Doc attributes set");
this.identifier = request.getExecute().getIdentifier().getStringValue().trim(); this.identifier = request.getExecute().getIdentifier().getStringValue().trim();
LOGGER.debug("Identifier: "+identifier); LOGGER.debug("Identifier: " + identifier);
ExecuteResponse responseElem = doc.getExecuteResponse(); ExecuteResponse responseElem = doc.getExecuteResponse();
responseElem.addNewProcess().addNewIdentifier().setStringValue(identifier); responseElem.addNewProcess().addNewIdentifier().setStringValue(identifier);
LOGGER.debug("Getting description for "+identifier); LOGGER.debug("Getting description for " + identifier);
description = RepositoryManager.getInstance().getProcessDescription(this.identifier); description = RepositoryManager.getInstance().getProcessDescription(this.identifier);
LOGGER.debug("Description "+description); LOGGER.debug("Description " + description);
if(description==null){ if (description == null) {
// throw new RuntimeException("Error while accessing the process description for "+ identifier); // throw new RuntimeException("Error while accessing the process
// description for "+ identifier);
} }
responseElem.getProcess().setTitle(description.getTitle()); responseElem.getProcess().setTitle(description.getTitle());
@ -118,9 +147,11 @@ public class ExecuteResponseBuilder {
// if status succeeded, update reponse with result // if status succeeded, update reponse with result
if (responseElem.getStatus().isSetProcessSucceeded()) { if (responseElem.getStatus().isSetProcessSucceeded()) {
// the response only include dataInputs, if the property is set to true; // the response only include dataInputs, if the property is set to
//if(Boolean.getBoolean(WPSConfiguration.getInstance().getProperty(WebProcessingService.PROPERTY_NAME_INCLUDE_DATAINPUTS_IN_RESPONSE))) { // true;
if(new Boolean(WPSConfig.getInstance().getWPSConfig().getServer().getIncludeDataInputsInResponse())){ // if(Boolean.getBoolean(WPSConfiguration.getInstance().getProperty(WebProcessingService.PROPERTY_NAME_INCLUDE_DATAINPUTS_IN_RESPONSE)))
// {
if (new Boolean(WPSConfig.getInstance().getWPSConfig().getServer().getIncludeDataInputsInResponse())) {
dataInputs = request.getExecute().getDataInputs(); dataInputs = request.getExecute().getDataInputs();
responseElem.setDataInputs(dataInputs); responseElem.setDataInputs(dataInputs);
} }
@ -130,11 +161,11 @@ public class ExecuteResponseBuilder {
// Get the outputdescriptions from the algorithm // Get the outputdescriptions from the algorithm
OutputDescriptionType[] outputDescs = description.getProcessOutputs().getOutputArray(); OutputDescriptionType[] outputDescs = description.getProcessOutputs().getOutputArray();
if(request.isRawData()) { if (request.isRawData()) {
OutputDefinitionType rawDataOutput = request.getExecute().getResponseForm().getRawDataOutput(); OutputDefinitionType rawDataOutput = request.getExecute().getResponseForm().getRawDataOutput();
String id = rawDataOutput.getIdentifier().getStringValue(); String id = rawDataOutput.getIdentifier().getStringValue();
OutputDescriptionType desc = XMLBeansHelper.findOutputByID(id, outputDescs); OutputDescriptionType desc = XMLBeansHelper.findOutputByID(id, outputDescs);
if(desc.isSetComplexOutput()) { if (desc.isSetComplexOutput()) {
String encoding = ExecuteResponseBuilder.getEncoding(desc, rawDataOutput); String encoding = ExecuteResponseBuilder.getEncoding(desc, rawDataOutput);
String schema = ExecuteResponseBuilder.getSchema(desc, rawDataOutput); String schema = ExecuteResponseBuilder.getSchema(desc, rawDataOutput);
String responseMimeType = getMimeType(rawDataOutput); String responseMimeType = getMimeType(rawDataOutput);
@ -147,85 +178,89 @@ public class ExecuteResponseBuilder {
String encoding = null; String encoding = null;
DomainMetadataType dataType = desc.getLiteralOutput().getDataType(); DomainMetadataType dataType = desc.getLiteralOutput().getDataType();
String reference = dataType != null ? dataType.getReference() : null; String reference = dataType != null ? dataType.getReference() : null;
generateLiteralDataOutput(id, doc, true, reference, schema, mimeType, encoding, desc.getTitle()); generateLiteralDataOutput(id, doc, true, reference, schema, mimeType, encoding,
} desc.getTitle());
else if (desc.isSetBoundingBoxOutput()) { } else if (desc.isSetBoundingBoxOutput()) {
generateBBOXOutput(id, doc, true, desc.getTitle()); generateBBOXOutput(id, doc, true, desc.getTitle());
} }
return; return;
} }
// Get the outputdefinitions from the clients request // Get the outputdefinitions from the clients request
// For each request of output // For each request of output
for(int i = 0; i<request.getExecute().getResponseForm().getResponseDocument().getOutputArray().length; i++) { for (int i = 0; i < request.getExecute().getResponseForm().getResponseDocument()
OutputDefinitionType definition = request.getExecute().getResponseForm().getResponseDocument().getOutputArray(i); .getOutputArray().length; i++) {
DocumentOutputDefinitionType documentDef = request.getExecute().getResponseForm().getResponseDocument().getOutputArray(i); OutputDefinitionType definition = request.getExecute().getResponseForm().getResponseDocument()
.getOutputArray(i);
DocumentOutputDefinitionType documentDef = request.getExecute().getResponseForm()
.getResponseDocument().getOutputArray(i);
String responseID = definition.getIdentifier().getStringValue(); String responseID = definition.getIdentifier().getStringValue();
OutputDescriptionType desc = XMLBeansHelper.findOutputByID(responseID, outputDescs); OutputDescriptionType desc = XMLBeansHelper.findOutputByID(responseID, outputDescs);
if(desc==null){ if (desc == null) {
throw new ExceptionReport("Could not find the output id " + responseID, ExceptionReport.INVALID_PARAMETER_VALUE); throw new ExceptionReport("Could not find the output id " + responseID,
ExceptionReport.INVALID_PARAMETER_VALUE);
} }
if(desc.isSetComplexOutput()) { if (desc.isSetComplexOutput()) {
String mimeType = getMimeType(definition); String mimeType = getMimeType(definition);
String schema = ExecuteResponseBuilder.getSchema(desc, definition); String schema = ExecuteResponseBuilder.getSchema(desc, definition);
String encoding = ExecuteResponseBuilder.getEncoding(desc, definition); String encoding = ExecuteResponseBuilder.getEncoding(desc, definition);
generateComplexDataOutput(responseID, documentDef.getAsReference(), false, schema, mimeType, encoding, desc.getTitle()); generateComplexDataOutput(responseID, documentDef.getAsReference(), false, schema, mimeType,
} encoding, desc.getTitle());
else if (desc.isSetLiteralOutput()) { } else if (desc.isSetLiteralOutput()) {
String mimeType = null; String mimeType = null;
String schema = null; String schema = null;
String encoding = null; String encoding = null;
DomainMetadataType dataType = desc.getLiteralOutput().getDataType(); DomainMetadataType dataType = desc.getLiteralOutput().getDataType();
String reference = dataType != null ? dataType.getReference() : null; String reference = dataType != null ? dataType.getReference() : null;
generateLiteralDataOutput(responseID, doc, false, reference, schema, mimeType, encoding, desc.getTitle()); generateLiteralDataOutput(responseID, doc, false, reference, schema, mimeType, encoding,
} desc.getTitle());
else if (desc.isSetBoundingBoxOutput()) { } else if (desc.isSetBoundingBoxOutput()) {
generateBBOXOutput(responseID, doc, false, desc.getTitle()); generateBBOXOutput(responseID, doc, false, desc.getTitle());
} } else {
else{ throw new ExceptionReport("Requested type not supported: BBOX",
throw new ExceptionReport("Requested type not supported: BBOX", ExceptionReport.INVALID_PARAMETER_VALUE); ExceptionReport.INVALID_PARAMETER_VALUE);
} }
} }
} } else {
else {
LOGGER.info("OutputDefinitions are not stated explicitly in request"); LOGGER.info("OutputDefinitions are not stated explicitly in request");
// THIS IS A WORKAROUND AND ACTUALLY NOT COMPLIANT TO THE SPEC. // THIS IS A WORKAROUND AND ACTUALLY NOT COMPLIANT TO THE SPEC.
ProcessDescriptionType description = RepositoryManager.getInstance().getProcessDescription(request.getExecute().getIdentifier().getStringValue()); ProcessDescriptionType description = RepositoryManager.getInstance()
if(description==null){ .getProcessDescription(request.getExecute().getIdentifier().getStringValue());
throw new RuntimeException("Error while accessing the process description for "+ request.getExecute().getIdentifier().getStringValue()); if (description == null) {
throw new RuntimeException("Error while accessing the process description for "
+ request.getExecute().getIdentifier().getStringValue());
} }
OutputDescriptionType [] d = description.getProcessOutputs().getOutputArray(); OutputDescriptionType[] d = description.getProcessOutputs().getOutputArray();
for (int i = 0; i < d.length; i++) for (int i = 0; i < d.length; i++) {
{ if (d[i].isSetComplexOutput()) {
if(d[i].isSetComplexOutput()) {
String schema = d[i].getComplexOutput().getDefault().getFormat().getSchema(); String schema = d[i].getComplexOutput().getDefault().getFormat().getSchema();
String encoding = d[i].getComplexOutput().getDefault().getFormat().getEncoding(); String encoding = d[i].getComplexOutput().getDefault().getFormat().getEncoding();
String mimeType = d[i].getComplexOutput().getDefault().getFormat().getMimeType(); String mimeType = d[i].getComplexOutput().getDefault().getFormat().getMimeType();
generateComplexDataOutput(d[i].getIdentifier().getStringValue(), false, false, schema, mimeType, encoding, d[i].getTitle()); generateComplexDataOutput(d[i].getIdentifier().getStringValue(), false, false, schema, mimeType,
} encoding, d[i].getTitle());
else if(d[i].isSetLiteralOutput()) { } else if (d[i].isSetLiteralOutput()) {
generateLiteralDataOutput(d[i].getIdentifier().getStringValue(), doc, false, d[i].getLiteralOutput().getDataType().getReference(), null, null, null, d[i].getTitle()); generateLiteralDataOutput(d[i].getIdentifier().getStringValue(), doc, false,
d[i].getLiteralOutput().getDataType().getReference(), null, null, null,
d[i].getTitle());
} }
} }
} }
} else if(request.isStoreResponse()) { } else if (request.isStoreResponse()) {
//statusLocation="http://localhost:8080/wps/RetrieveResultServlet?id=e4defcf6-d39f-48bf-8128-5591dca13dcb" // statusLocation="http://localhost:8080/wps/RetrieveResultServlet?id=e4defcf6-d39f-48bf-8128-5591dca13dcb"
// responseElem.setStatusLocation(DatabaseFactory.getDatabase().generateRetrieveResultURL((request.getUniqueId()).toString())); // responseElem.setStatusLocation(DatabaseFactory.getDatabase().generateRetrieveResultURL((request.getUniqueId()).toString()));
responseElem.setStatusLocation(webStatus+"?id="+request.getUniqueId()); responseElem.setStatusLocation(webStatus + "?id=" + request.getUniqueId());
} }
} }
/** /**
* Returns the schema according to the given output description and type. * Returns the schema according to the given output description and type.
*/ */
private static String getSchema(OutputDescriptionType desc, OutputDefinitionType def) { private static String getSchema(OutputDescriptionType desc, OutputDefinitionType def) {
String schema = null; String schema = null;
if(def != null) { if (def != null) {
schema = def.getSchema(); schema = def.getSchema();
} }
@ -234,7 +269,7 @@ public class ExecuteResponseBuilder {
private static String getEncoding(OutputDescriptionType desc, OutputDefinitionType def) { private static String getEncoding(OutputDescriptionType desc, OutputDefinitionType def) {
String encoding = null; String encoding = null;
if(def != null) { if (def != null) {
encoding = def.getEncoding(); encoding = def.getEncoding();
} }
return encoding; return encoding;
@ -247,24 +282,20 @@ public class ExecuteResponseBuilder {
public String getMimeType(OutputDefinitionType def) { public String getMimeType(OutputDefinitionType def) {
String mimeType = ""; String mimeType = "";
OutputDescriptionType[] outputDescs = description.getProcessOutputs() OutputDescriptionType[] outputDescs = description.getProcessOutputs().getOutputArray();
.getOutputArray();
boolean isResponseForm = request.getExecute().isSetResponseForm(); boolean isResponseForm = request.getExecute().isSetResponseForm();
String inputID = ""; String inputID = "";
if(def != null){ if (def != null) {
inputID = def.getIdentifier().getStringValue(); inputID = def.getIdentifier().getStringValue();
}else if(isResponseForm){ } else if (isResponseForm) {
if (request.getExecute().getResponseForm().isSetRawDataOutput()) { if (request.getExecute().getResponseForm().isSetRawDataOutput()) {
inputID = request.getExecute().getResponseForm().getRawDataOutput() inputID = request.getExecute().getResponseForm().getRawDataOutput().getIdentifier().getStringValue();
.getIdentifier().getStringValue(); } else if (request.getExecute().getResponseForm().isSetResponseDocument()) {
} else if (request.getExecute().getResponseForm() inputID = request.getExecute().getResponseForm().getResponseDocument().getOutputArray(0).getIdentifier()
.isSetResponseDocument()) {
inputID = request.getExecute().getResponseForm()
.getResponseDocument().getOutputArray(0).getIdentifier()
.getStringValue(); .getStringValue();
} }
} }
@ -272,8 +303,7 @@ public class ExecuteResponseBuilder {
OutputDescriptionType outputDes = null; OutputDescriptionType outputDes = null;
for (OutputDescriptionType tmpOutputDes : outputDescs) { for (OutputDescriptionType tmpOutputDes : outputDescs) {
if (inputID.equalsIgnoreCase(tmpOutputDes.getIdentifier() if (inputID.equalsIgnoreCase(tmpOutputDes.getIdentifier().getStringValue())) {
.getStringValue())) {
outputDes = tmpOutputDes; outputDes = tmpOutputDes;
break; break;
} }
@ -282,27 +312,22 @@ public class ExecuteResponseBuilder {
if (isResponseForm) { if (isResponseForm) {
// Get the outputdescriptions from the algorithm // Get the outputdescriptions from the algorithm
if (request.isRawData()) { if (request.isRawData()) {
mimeType = request.getExecute().getResponseForm() mimeType = request.getExecute().getResponseForm().getRawDataOutput().getMimeType();
.getRawDataOutput().getMimeType();
} else { } else {
// mimeType = "text/xml"; // mimeType = "text/xml";
// MSS 03/02/2009 defaulting to text/xml doesn't work when the // MSS 03/02/2009 defaulting to text/xml doesn't work when the
// data is a complex raster // data is a complex raster
if (outputDes.isSetLiteralOutput()) { if (outputDes.isSetLiteralOutput()) {
mimeType = "text/plain"; mimeType = "text/plain";
} else if(outputDes.isSetBoundingBoxOutput()){ } else if (outputDes.isSetBoundingBoxOutput()) {
mimeType = "text/xml"; mimeType = "text/xml";
} else { } else {
if (def != null) { if (def != null) {
mimeType = def.getMimeType(); mimeType = def.getMimeType();
} else { } else {
if (outputDes.isSetComplexOutput()) { if (outputDes.isSetComplexOutput()) {
mimeType = outputDes.getComplexOutput() mimeType = outputDes.getComplexOutput().getDefault().getFormat().getMimeType();
.getDefault().getFormat().getMimeType(); LOGGER.warn("Using default mime type: " + mimeType + " for input: " + inputID);
LOGGER.warn("Using default mime type: "
+ mimeType
+ " for input: "
+ inputID);
} }
} }
} }
@ -311,82 +336,84 @@ public class ExecuteResponseBuilder {
if (mimeType == null) { if (mimeType == null) {
if (outputDes.isSetLiteralOutput()) { if (outputDes.isSetLiteralOutput()) {
mimeType = "text/plain"; mimeType = "text/plain";
} else if(outputDes.isSetBoundingBoxOutput()){ } else if (outputDes.isSetBoundingBoxOutput()) {
mimeType = "text/xml"; mimeType = "text/xml";
} else if (outputDes.isSetComplexOutput()) { } else if (outputDes.isSetComplexOutput()) {
mimeType = outputDes.getComplexOutput().getDefault() mimeType = outputDes.getComplexOutput().getDefault().getFormat().getMimeType();
.getFormat().getMimeType(); LOGGER.warn("Using default mime type: " + mimeType + " for input: " + inputID);
LOGGER.warn("Using default mime type: " + mimeType
+ " for input: "
+ inputID);
} }
} }
return mimeType; return mimeType;
} }
private void generateComplexDataOutput(String responseID, boolean asReference, boolean rawData, String schema, String mimeType, String encoding, LanguageStringType title) throws ExceptionReport{ private void generateComplexDataOutput(String responseID, boolean asReference, boolean rawData, String schema,
String mimeType, String encoding, LanguageStringType title) throws ExceptionReport {
IData obj = request.getAttachedResult().get(responseID); IData obj = request.getAttachedResult().get(responseID);
if(rawData) { if (rawData) {
rawDataHandler = new RawData(obj, responseID, schema, encoding, mimeType, this.identifier, description); rawDataHandler = new RawData(obj, responseID, schema, encoding, mimeType, this.identifier, description);
} } else {
else { OutputDataItem handler = new OutputDataItem(obj, responseID, schema, encoding, mimeType, title,
OutputDataItem handler = new OutputDataItem(obj, responseID, schema, encoding, mimeType, title, this.identifier, description); this.identifier, description);
if(asReference) { if (asReference) {
handler.updateResponseAsReference(doc, (request.getUniqueId()).toString(),mimeType); handler.updateResponseAsReference(doc, (request.getUniqueId()).toString(), mimeType);
} } else {
else {
handler.updateResponseForInlineComplexData(doc); handler.updateResponseForInlineComplexData(doc);
} }
} }
} }
private void generateLiteralDataOutput(String responseID, ExecuteResponseDocument res, boolean rawData, String dataTypeReference, String schema, String mimeType, String encoding, LanguageStringType title) throws ExceptionReport { private void generateLiteralDataOutput(String responseID, ExecuteResponseDocument res, boolean rawData,
String dataTypeReference, String schema, String mimeType, String encoding, LanguageStringType title)
throws ExceptionReport {
IData obj = request.getAttachedResult().get(responseID); IData obj = request.getAttachedResult().get(responseID);
if(rawData) { if (rawData) {
rawDataHandler = new RawData(obj, responseID, schema, encoding, mimeType, this.identifier, description); rawDataHandler = new RawData(obj, responseID, schema, encoding, mimeType, this.identifier, description);
}else{ } else {
OutputDataItem handler = new OutputDataItem(obj, responseID, schema, encoding, mimeType, title, this.identifier, description); OutputDataItem handler = new OutputDataItem(obj, responseID, schema, encoding, mimeType, title,
this.identifier, description);
handler.updateResponseForLiteralData(res, dataTypeReference); handler.updateResponseForLiteralData(res, dataTypeReference);
} }
} }
private void generateBBOXOutput(String responseID, ExecuteResponseDocument res, boolean rawData, LanguageStringType title) throws ExceptionReport { private void generateBBOXOutput(String responseID, ExecuteResponseDocument res, boolean rawData,
IBBOXData obj = (IBBOXData) request.getAttachedResult().get(responseID); LanguageStringType title) throws ExceptionReport {
if(rawData) { IBBOXData obj = (IBBOXData) request.getAttachedResult().get(responseID);
if (rawData) {
rawDataHandler = new RawData(obj, responseID, null, null, null, this.identifier, description); rawDataHandler = new RawData(obj, responseID, null, null, null, this.identifier, description);
}else{ } else {
OutputDataItem handler = new OutputDataItem(obj, responseID, null, null, null, title, this.identifier, description); OutputDataItem handler = new OutputDataItem(obj, responseID, null, null, null, title, this.identifier,
description);
handler.updateResponseForBBOXData(res, obj); handler.updateResponseForBBOXData(res, obj);
} }
} }
public InputStream getAsStream() throws ExceptionReport{ public InputStream getAsStream() throws ExceptionReport {
if(request.isRawData() && rawDataHandler != null) { if (request.isRawData() && rawDataHandler != null) {
return rawDataHandler.getAsStream(); return rawDataHandler.getAsStream();
} }
if(request.isStoreResponse()) { if (request.isStoreResponse()) {
String id = request.getUniqueId().toString(); String id = request.getUniqueId().toString();
// String statusLocation = DatabaseFactory.getDatabase().generateRetrieveResultURL(id); // String statusLocation =
String statusLocation = webStatus+"?id="+id; // DatabaseFactory.getDatabase().generateRetrieveResultURL(id);
String statusLocation = webStatus + "?id=" + id;
doc.getExecuteResponse().setStatusLocation(statusLocation); doc.getExecuteResponse().setStatusLocation(statusLocation);
} }
try { try {
return doc.newInputStream(XMLBeansHelper.getXmlOptions()); return doc.newInputStream(XMLBeansHelper.getXmlOptions());
} } catch (Exception e) {
catch(Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public void setStatus(StatusType status) { public void setStatus(StatusType status) {
//workaround, should be generated either at the creation of the document or when the process has been finished. // workaround, should be generated either at the creation of the
// document or when the process has been finished.
status.setCreationTime(creationTime); status.setCreationTime(creationTime);
doc.getExecuteResponse().setStatus(status); doc.getExecuteResponse().setStatus(status);
} }
} }

@ -93,6 +93,7 @@ public class WebProcessingService extends HttpServlet {
private static final String SAVEONSTORAGE_PARAM = "saveOnStorage"; private static final String SAVEONSTORAGE_PARAM = "saveOnStorage";
private static final String SIMULATION_MODE_PARAM = "simulationMode"; private static final String SIMULATION_MODE_PARAM = "simulationMode";
private static final String USER_WIRTE_EXCLUDED_PARAM = "excludeWritesOnSH"; private static final String USER_WIRTE_EXCLUDED_PARAM = "excludeWritesOnSH";
private static final String CONFIG_PATH = "configPath";
private ApplicationContext context = ContextProvider.get(); private ApplicationContext context = ContextProvider.get();
private EnvironmentVariableManager env ; private EnvironmentVariableManager env ;
@ -107,6 +108,7 @@ public class WebProcessingService extends HttpServlet {
int maxComp = Integer.parseInt(context.application().getInitParameter(MAX_COMPUTATION_PARAM)); int maxComp = Integer.parseInt(context.application().getInitParameter(MAX_COMPUTATION_PARAM));
boolean saveOnStorage = Boolean.parseBoolean(context.application().getInitParameter(SAVEONSTORAGE_PARAM)); boolean saveOnStorage = Boolean.parseBoolean(context.application().getInitParameter(SAVEONSTORAGE_PARAM));
boolean simulationMode = Boolean.parseBoolean(context.application().getInitParameter(SIMULATION_MODE_PARAM)); boolean simulationMode = Boolean.parseBoolean(context.application().getInitParameter(SIMULATION_MODE_PARAM));
String configPath = context.application().getInitParameter(CONFIG_PATH);
String userWriteExcludedValue = context.application().getInitParameter(USER_WIRTE_EXCLUDED_PARAM); String userWriteExcludedValue = context.application().getInitParameter(USER_WIRTE_EXCLUDED_PARAM);
@ -123,7 +125,7 @@ public class WebProcessingService extends HttpServlet {
} else } else
LOGGER.debug("all users excluded in write"); LOGGER.debug("all users excluded in write");
env = new EnvironmentVariableManager(maxComp, saveOnStorage, simulationMode, excludedUserForWrite); env = new EnvironmentVariableManager(maxComp, saveOnStorage, simulationMode, excludedUserForWrite, configPath);
LOGGER.info("WPS initialised"); LOGGER.info("WPS initialised");
} }

@ -24,6 +24,12 @@
<param-name>simulationMode</param-name> <param-name>simulationMode</param-name>
<param-value>false</param-value> <param-value>false</param-value>
</context-param> </context-param>
<context-param>
<param-name>configPath</param-name>
<param-value>/home/gcube/wpsconfig</param-value>
</context-param>
<context-param> <context-param>
<param-name>excludeWritesOnSH</param-name> <param-name>excludeWritesOnSH</param-name>
<!-- <!--

Loading…
Cancel
Save