Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #252 from bpross-52n/wps-4.0
Browse files Browse the repository at this point in the history
Enhancements/bugfixes
  • Loading branch information
bpross-52n authored May 19, 2017
2 parents d783471 + 6918020 commit d1d1971
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 96 deletions.
4 changes: 4 additions & 0 deletions 52n-wps-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
<groupId>org.n52.sensorweb</groupId>
<artifactId>52n-xml-ows-v110</artifactId>
</dependency>
<dependency>
<groupId>org.n52.wps</groupId>
<artifactId>52n-xml-wps-v20</artifactId>
</dependency>
<dependency>
<groupId>org.n52.sensorweb</groupId>
<artifactId>52n-xml-ows-v20</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
/*
* Copyright (C) 2007-2017 52°North Initiative for Geospatial Open Source
* Copyright (C) 2006-2017 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
* http://www.apache.org/licenses/LICENSE-2.0
*
* • Apache License, version 2.0
* • Apache Software License, version 1.0
* • GNU Lesser General Public License, version 3
* • Mozilla Public License, versions 1.0, 1.1 and 2.0
* • Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.n52.wps.util;
package org.n52.wps.commons;

import java.util.concurrent.ConcurrentMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.apache.xmlbeans.XmlObject;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;

import net.opengis.ows.x11.ExceptionReportDocument;
import net.opengis.ows.x11.ExceptionType;
Expand Down Expand Up @@ -111,6 +112,7 @@ private net.opengis.ows.x20.ExceptionReportDocument createExceptionReportV200(){

// Printing service Exception
net.opengis.ows.x20.ExceptionReportDocument reportV200 = net.opengis.ows.x20.ExceptionReportDocument.Factory.newInstance();
XMLBeansHelper.addSchemaLocationToXMLObject(reportV200, "http://www.opengis.net/ows/2.0 http://schemas.opengis.net/ows/2.0/owsAll.xsd");
net.opengis.ows.x20.ExceptionReportDocument.ExceptionReport exceptionReportV200 = reportV200.addNewExceptionReport();
exceptionReportV200.setVersion(WPSConfig.VERSION_200);
net.opengis.ows.x20.ExceptionType exV200 = exceptionReportV200.addNewException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public class Server implements ConfigurationModule {
"Maximum time that excess idle threads are kept alive", true, 1000);
private ConfigurationEntry<Integer> maxQueuedTasksEntry = new IntegerConfigurationEntry("max_queued_tasks", "Maximum queued tasks",
"Maximum queued tasks of the work queue", true, 100);
private ConfigurationEntry<Boolean> addProcessDescriptionLinkToProcessSummaryEntry = new BooleanConfigurationEntry("add_process_description_Link_to_process_summary",
"Add ProcessDescriptionl ink to ProcessSummary", "Add ProcessDescriptionl ink to ProcessSummary in the Capabilities", false, true);

private List<? extends ConfigurationEntry<?>> configurationEntries = Arrays.asList(protocolEntry, hostnameEntry, hostportEntry,
computationTimeoutEntry, weppappPathEntry, repoReloadIntervalEntry, includeDataInputsInResponseEntry,
cacheCapabilitesEntry, responseURLFilterEnabledEntry, minPoolSizeEntry, maxPoolSizeEntry, keepAliveSecondsEntry, maxQueuedTasksEntry);
cacheCapabilitesEntry, responseURLFilterEnabledEntry, minPoolSizeEntry, maxPoolSizeEntry, keepAliveSecondsEntry, maxQueuedTasksEntry, addProcessDescriptionLinkToProcessSummaryEntry);

private String hostname;
private String protocol;
Expand All @@ -91,6 +93,7 @@ public class Server implements ConfigurationModule {
private int maxPoolSize;
private int keepAliveSeconds;
private int maxQueuedTasks;
private boolean addProcessDescriptionLinkToProcessSummary;

public Server() {
//
Expand Down Expand Up @@ -257,4 +260,13 @@ public void setMaxQueuedTasks(int maxQueuedTasks) {
this.maxQueuedTasks = maxQueuedTasks;
}

public boolean getAddProcessDescriptionLinkToProcessSummary() {
return addProcessDescriptionLinkToProcessSummary;
}

@ConfigurationKey(key = "add_process_description_Link_to_process_summary")
public void setAddProcessDescriptionLinkToProcessSummary(boolean addProcessDescriptionLinkToProcessSummary) {
this.addProcessDescriptionLinkToProcessSummary = addProcessDescriptionLinkToProcessSummary;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

import net.opengis.ows.x11.CodeType;
import net.opengis.ows.x11.DCPDocument.DCP;
import net.opengis.ows.x11.LanguageStringType;
import net.opengis.ows.x11.OperationDocument.Operation;
import net.opengis.ows.x11.RequestMethodType;
import net.opengis.wps.x100.CapabilitiesDocument;
import net.opengis.wps.x100.ProcessBriefType;
import net.opengis.wps.x100.ProcessDescriptionType;
import net.opengis.wps.x100.ProcessOfferingsDocument.ProcessOfferings;

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.n52.wps.commons.WPSConfig;
Expand All @@ -56,6 +46,17 @@

import com.google.common.base.Preconditions;

import net.opengis.ows.x11.CodeType;
import net.opengis.ows.x11.DCPDocument.DCP;
import net.opengis.ows.x11.LanguageStringType;
import net.opengis.ows.x11.MetadataType;
import net.opengis.ows.x11.OperationDocument.Operation;
import net.opengis.ows.x11.RequestMethodType;
import net.opengis.wps.x100.CapabilitiesDocument;
import net.opengis.wps.x100.ProcessBriefType;
import net.opengis.wps.x100.ProcessDescriptionType;
import net.opengis.wps.x100.ProcessOfferingsDocument.ProcessOfferings;

/**
* Encapsulation of the WPS Capabilities document. This class has to be initialized with either a
* {@linkplain #getInstance(java.io.File) file}, {@linkplain #getInstance(java.net.URL) URL},
Expand Down Expand Up @@ -259,6 +260,7 @@ private static void initProcessOfferings(CapabilitiesDocument skel) {
ProcessOfferings processes = skel.getCapabilities()
.addNewProcessOfferings();
RepositoryManager rm = RepositoryManagerSingletonWrapper.getInstance();
boolean addProcessDescriptionLinkToProcessSummary = WPSConfig.getInstance().getWPSConfig().getServerConfigurationModule().getAddProcessDescriptionLinkToProcessSummary();
List<String> algorithms = rm.getAlgorithms();
if (algorithms.isEmpty()){
LOG.warn("No algorithms found in repository manager.");
Expand All @@ -276,6 +278,24 @@ private static void initProcessOfferings(CapabilitiesDocument skel) {
String processVersion = description.getProcessVersion();
process.setProcessVersion(processVersion);
process.setTitle(title);

if (addProcessDescriptionLinkToProcessSummary) {

MetadataType metadataType = process.addNewMetadata();

metadataType.setRole("Process description");

String describeProcessHref = "";

try {
describeProcessHref = getEndpointURL()
+ "?service=WPS&request=DescribeProcess&version=1.0.0&identifier=" + algorithmName;
} catch (UnknownHostException e) {
LOG.error("Could not create describeProcessURL.");
}

metadataType.setHref(describeProcessHref);
}
LOG.trace("Added algorithm to process offerings: {}\n\t\t{}", algorithmName, process);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.opengis.ows.x20.HTTPDocument.HTTP;
import net.opengis.ows.x20.KeywordsType;
import net.opengis.ows.x20.LanguageStringType;
import net.opengis.ows.x20.MetadataType;
import net.opengis.ows.x20.OperationDocument.Operation;
import net.opengis.ows.x20.OperationsMetadataDocument.OperationsMetadata;
import net.opengis.ows.x20.RequestMethodType;
Expand Down Expand Up @@ -276,6 +277,7 @@ private static void initSkeleton(CapabilitiesDocument skel) throws UnknownHostEx
private static void initProcessOfferings(CapabilitiesDocument skel) {
Contents contents = skel.getCapabilities()
.addNewContents();
boolean addProcessDescriptionLinkToProcessSummary = WPSConfig.getInstance().getWPSConfig().getServerConfigurationModule().getAddProcessDescriptionLinkToProcessSummary();
for (String algorithmName : RepositoryManagerSingletonWrapper.getInstance()
.getAlgorithms()) {
try {
Expand Down Expand Up @@ -304,6 +306,23 @@ private static void initProcessOfferings(CapabilitiesDocument skel) {

process.addNewTitle().setStringValue(title.getStringValue());

if (addProcessDescriptionLinkToProcessSummary) {

MetadataType metadataType = process.addNewMetadata();

metadataType.setRole("Process description");

String describeProcessHref = "";

try {
describeProcessHref = getEndpointURL()
+ "?service=WPS&request=DescribeProcess&version=2.0.0&identifier=" + algorithmName;
} catch (UnknownHostException e) {
LOG.error("Could not create describeProcessURL.");
}

metadataType.setHref(describeProcessHref);
}
LOG.trace("Added algorithm to process offerings: {}\n\t\t{}", algorithmName, process);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@

import org.apache.xmlbeans.XmlException;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.io.GeneratorFactory;
import org.n52.wps.io.ParserFactory;
import org.n52.wps.server.database.DatabaseFactory;
import org.n52.wps.server.database.IDatabase;
import org.n52.wps.server.handler.RequestHandler;
import org.n52.wps.util.XMLBeansHelper;
import org.n52.wps.webapp.api.ConfigurationCategory;
import org.n52.wps.webapp.api.ConfigurationManager;
import org.n52.wps.webapp.api.ConfigurationModule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.io.IOUtils;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.request.CapabilitiesRequest;
import org.n52.wps.server.request.DescribeProcessRequest;
Expand All @@ -54,7 +55,6 @@
import org.n52.wps.server.request.RetrieveResultRequest;
import org.n52.wps.server.response.ExecuteResponse;
import org.n52.wps.server.response.Response;
import org.n52.wps.util.XMLBeansHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.xmlbeans.XmlCursor;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.RepositoryManagerSingletonWrapper;
import org.n52.wps.server.response.DescribeProcessResponse;
Expand Down Expand Up @@ -136,10 +137,8 @@ public Response call() throws ExceptionReport {

document = ProcessOfferingsDocument.Factory.newInstance();
document.addNewProcessOfferings();
XmlCursor c = document.newCursor();
c.toFirstChild();
c.toLastAttribute();
c.setAttributeText(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation"), "http://www.opengis.net/wps/2.0 http://schemas.opengis.net/wps/2.0/wps.xsd");

XMLBeansHelper.addSchemaLocationToXMLObject(document, "http://www.opengis.net/wps/2.0 http://schemas.opengis.net/wps/2.0/wps.xsd");

String[] identifiers = getMapValue("identifier", true).split(",");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.commons.context.ExecutionContext;
import org.n52.wps.commons.context.ExecutionContextFactory;
import org.n52.wps.io.data.IComplexData;
Expand All @@ -82,7 +83,6 @@
import org.n52.wps.server.response.ExecuteResponse;
import org.n52.wps.server.response.ExecuteResponseBuilderV100;
import org.n52.wps.server.response.Response;
import org.n52.wps.util.XMLBeansHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.xmlbeans.XmlException;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.commons.XMLUtil;
import org.n52.wps.io.BasicXMLTypeFactory;
import org.n52.wps.io.IOHandler;
Expand All @@ -67,7 +68,6 @@
import org.n52.wps.server.handler.DataInputInterceptors.InterceptorInstance;
import org.n52.wps.server.request.strategy.ReferenceInputStream;
import org.n52.wps.server.request.strategy.ReferenceStrategyRegister;
import org.n52.wps.util.XMLBeansHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

import org.apache.xmlbeans.XmlException;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.server.CapabilitiesConfiguration;
import org.n52.wps.server.CapabilitiesConfigurationV200;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.request.CapabilitiesRequest;
import org.n52.wps.util.XMLBeansHelper;

/**
* A Response to the Request "GetCapabilities"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import net.opengis.wps.x20.ProcessOfferingsDocument;

import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.request.Request;
import org.n52.wps.util.XMLBeansHelper;


public class DescribeProcessResponse extends Response{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.io.data.IBBOXData;
import org.n52.wps.io.data.IData;
import org.n52.wps.server.RepositoryManagerSingletonWrapper;
Expand All @@ -57,7 +58,6 @@
import org.n52.wps.server.WebProcessingService;
import org.n52.wps.server.database.DatabaseFactory;
import org.n52.wps.server.request.ExecuteRequestV100;
import org.n52.wps.util.XMLBeansHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

import org.apache.xmlbeans.XmlObject;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.io.data.IBBOXData;
import org.n52.wps.io.data.IData;
import org.n52.wps.server.RepositoryManagerSingletonWrapper;
Expand All @@ -56,7 +57,6 @@
import org.n52.wps.server.RepositoryManager;
import org.n52.wps.server.database.DatabaseFactory;
import org.n52.wps.server.request.ExecuteRequestV200;
import org.n52.wps.util.XMLBeansHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -290,6 +290,12 @@ public InputStream getAsStream() throws ExceptionReport{
}

if(request.getExecute().getMode().equals(ExecuteRequestType.Mode.SYNC)){

//if an error occurred, the status was set to failed and the exception report was written to the database
if(statusInfoDoc != null && statusInfoDoc.getStatusInfo().getStatus().equals(Status.Failed.toString())){
return DatabaseFactory.getDatabase().lookupResponse(request.getUniqueId().toString());
}

return resultDoc.newInputStream(XMLBeansHelper.getXmlOptions());
}else if(statusInfoDoc.getStatusInfo().getStatus().equals(Status.Succeeded.toString())){
//save last status info and return result document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
import java.io.IOException;
import java.io.InputStream;

import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.io.IOHandler;
import org.n52.wps.io.data.IBBOXData;
import org.n52.wps.io.data.IComplexData;
import org.n52.wps.io.data.IData;
import org.n52.wps.io.data.ILiteralData;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.ProcessDescription;
import org.n52.wps.util.XMLBeansHelper;

import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
import org.junit.Before;
import org.junit.Test;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.commons.XMLBeansHelper;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.RepositoryManager;
import org.n52.wps.server.RepositoryManagerSingletonWrapper;
import org.n52.wps.server.handler.DataInputInterceptors.InterceptorInstance;
import org.n52.wps.util.XMLBeansHelper;
import org.n52.wps.webapp.common.AbstractITClass;

/**
Expand Down
Loading

0 comments on commit d1d1971

Please sign in to comment.