diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
index 86dcfe9..04cfa2c 100644
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -1,10 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
-encoding//src/main/java/org/n52/wps/demo/CopyOfGPDemoFile.java=UTF-8
-encoding//src/main/java/org/n52/wps/demo/GPDemoFile.java=UTF-8
-encoding//src/main/java/org/n52/wps/demo/GPDemoSimple.java=UTF-8
-encoding//src/main/java/org/n52/wps/demo/GPDemoXML.java=UTF-8
-encoding//src/main/java/org/n52/wps/demo/TestIO.java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
diff --git a/pom.xml b/pom.xml
index 9663bdc..4f9a367 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,18 +16,6 @@
https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner
-
-
-
- org.gcube.distribution
- maven-smartgears-bom
- LATEST
- pom
- import
-
-
-
-
Gianpaolo Coro
@@ -54,15 +42,7 @@
-
- org.gcube.core
- common-smartgears
-
-
- org.gcube.core
- common-smartgears-app
-
-
+
javax.servlet
servlet-api
2.5
@@ -135,14 +115,14 @@
4.11
test
-
+
javassist
javassist
@@ -160,11 +140,10 @@
[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)
-
- xml-apis
- xml-apis
- 2.0.2
+ xerces
+ xercesImpl
+ 2.11.0
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/capabilities/GetCapabilitiesBuilder.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/capabilities/GetCapabilitiesBuilder.java
deleted file mode 100644
index f216279..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/capabilities/GetCapabilitiesBuilder.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.capabilities;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.io.IOUtils;
-import org.gcube.dataanalysis.ecoengine.processing.factories.ProcessorsFactory;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.infrastructure.InfrastructureDialoguer;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.ConfigurationManager;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.TokenManager;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.utils.GcubeAlgorithmRepository;
-import org.n52.wps.commons.WPSConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GetCapabilitiesBuilder {
-
- public static String processString = "\n\t#CLASS#\n\t#TITLE#\n";
-
- private static final Logger LOGGER= LoggerFactory.getLogger(GetCapabilitiesBuilder.class);
-
- public String getClassification(String algorithmName, ConfigurationManager configManager) throws Exception{
- //get algorithms classification:
- LOGGER.debug("Searching for a classification of "+algorithmName);
- HashMap> algorithmsClassification = ProcessorsFactory.getAllFeaturesUser(configManager.getConfig());
- String rightClassification = "Others";
- for (String classification:algorithmsClassification.keySet()){
- List algorithms = algorithmsClassification.get(classification);
- if (algorithms.contains(algorithmName)){
- LOGGER.debug("Found classification"+classification);
- return classification;
- }
- }
- LOGGER.debug("No classification found for "+algorithmName);
- return rightClassification;
- }
-
- public String buildGetCapabilities(Map parameters) throws Exception {
-
- LinkedHashMap basicInputs = new LinkedHashMap();
- //DONE get scope and username from SmartGears to build the get capabilities
- /* OLD CODE
- if (parameters != null) {
- if (parameters.get(ConfigurationManager.scopeParameter) != null)
- basicInputs.put(ConfigurationManager.scopeParameter, parameters.get(ConfigurationManager.scopeParameter)[0]);
- if (parameters.get(ConfigurationManager.usernameParameter) != null)
- basicInputs.put(ConfigurationManager.usernameParameter, parameters.get(ConfigurationManager.usernameParameter)[0]);
- } else {// case for testing purposes only
- if (AbstractEcologicalEngineMapper.simulationMode){
- basicInputs.put(ConfigurationManager.scopeParameter, ConfigurationManager.defaultScope);
- basicInputs.put(ConfigurationManager.usernameParameter, ConfigurationManager.defaultUsername);
- }
- }
- */
- ConfigurationManager configManager = new ConfigurationManager();
- TokenManager tokenm = new TokenManager();
- tokenm.getCredentials();
- String scope = tokenm.getScope();
- String username = tokenm.getUserName();
- String token = tokenm.getToken();
- basicInputs.put(ConfigurationManager.scopeParameter, scope);
- basicInputs.put(ConfigurationManager.usernameParameter, username);
- basicInputs.put(ConfigurationManager.tokenParameter, token);
-
- configManager.configAlgorithmEnvironment(basicInputs);
- LOGGER.debug("Initializing Capabilities Skeleton in scope " + configManager.getScope() + " with user " + configManager.getUsername());
- InputStream is = this.getClass().getClassLoader().getResourceAsStream("templates/wpsCapabilitiesSkeleton.xml");
- String stringTemplate = IOUtils.toString(is, "UTF-8");
-
- //TODO: GET HOSTNAME AND PORT from container
- String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
- String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
- stringTemplate = stringTemplate.replace("#HOST#", host).replace("#PORT#", port);
-
- LOGGER.debug("Host: " + host + " Port: " + port);
-
- LinkedHashMap allalgorithms = new LinkedHashMap();
- /*
- String packageS = "org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses";
- List> classes = null;
- try{
- LOGGER.debug("Taking classes from /classes");
- classes = GetCapabilitiesChecker.find(packageS);
- }catch(Exception e){
- LOGGER.debug("Taking classes from the Jar");
- classes=GetCapabilitiesChecker.getClassesInSamePackageFromJar(packageS);
- }*/
-
- LOGGER.info("using classloader class {} ",Thread.currentThread().getContextClassLoader().getClass().getSimpleName());
-
-
- Set> algorithmsClass = GcubeAlgorithmRepository.getAllAlgorithms();
-
- LOGGER.info("class found with annotation Algorithm are {}",algorithmsClass.size());
-
- for (Class> classfind : algorithmsClass) {
- org.n52.wps.algorithm.annotation.Algorithm algorithmInfo = classfind.getAnnotation(org.n52.wps.algorithm.annotation.Algorithm.class);
- if (algorithmInfo != null) {
- LOGGER.debug("Retrieving local declared Algorithm: " + algorithmInfo.title());
- allalgorithms.put(algorithmInfo.title(), classfind.getName());
- }
- }
-
- LOGGER.debug("Getting algorithms from the infrastructure");
- InfrastructureDialoguer dialoguer = new InfrastructureDialoguer(configManager.getScope());
- List algorithmsInScope = dialoguer.getAlgorithmsInScope();
- LOGGER.debug("Found " + algorithmsInScope.size() + " algorithms in scope ");
- StringBuffer capabilities = new StringBuffer();
-
- for (String algorithmInScope : algorithmsInScope) {
- String classAlgorithm = allalgorithms.get(algorithmInScope);
- if (classAlgorithm != null) {
- LOGGER.debug("Approving " + classAlgorithm + " to capabilities ");
- String algorithmTitle = getClassification(algorithmInScope, configManager)+":"+algorithmInScope;
-// String algorithmTitle = algorithmInScope;
- capabilities.append(processString.replace("#TITLE#", algorithmTitle).replace("#CLASS#", classAlgorithm));
- }
- }
-
- stringTemplate = stringTemplate.replace("#PROCESSES#", capabilities.toString());
- LOGGER.debug("Get capabilities built");
- return stringTemplate;
- }
-
-
-
-}
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/infrastructure/InfrastructureDialoguer.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/infrastructure/InfrastructureDialoguer.java
index 6b511fa..c8693da 100644
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/infrastructure/InfrastructureDialoguer.java
+++ b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/infrastructure/InfrastructureDialoguer.java
@@ -70,7 +70,7 @@ public class InfrastructureDialoguer {
throw new Exception("No resource named StatisticalManagerAlgorithm available in scope "+scope);
}
List resourcesNames = new ArrayList();
- LOGGER.debug("Found "+resources.size()+" resources");
+ LOGGER.debug("Found {} algorithms",resources.size());
for (GenericResource resource: resources){
resourcesNames.add(resource.profile().name());
}
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/ConfigurationManager.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/ConfigurationManager.java
index 78129c4..734a940 100644
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/ConfigurationManager.java
+++ b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/ConfigurationManager.java
@@ -2,7 +2,6 @@ package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping;
import java.io.File;
import java.io.InputStream;
-import java.net.Inet4Address;
import java.util.LinkedHashMap;
import java.util.Properties;
import java.util.UUID;
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/utils/GcubeAlgorithmRepository.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/utils/GcubeAlgorithmRepository.java
deleted file mode 100644
index 74a30ae..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/utils/GcubeAlgorithmRepository.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-
-import net.opengis.wps.x100.ProcessDescriptionType;
-
-import org.n52.wps.algorithm.annotation.Algorithm;
-import org.n52.wps.server.IAlgorithm;
-import org.n52.wps.server.IAlgorithmRepository;
-import org.reflections.Reflections;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
-import org.reflections.util.FilterBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GcubeAlgorithmRepository implements IAlgorithmRepository {
-
- private static long UPDATE_TIME_IN_MILLIS = 60000;
-
- private static Logger log = LoggerFactory.getLogger(GcubeAlgorithmRepository.class);
-
- //private static GcubeAlgorithmRepository instance= new GcubeAlgorithmRepository();
-
- private static Long lastUpdate = 0l;
-
- private static Reflections reflection;
-
-
- public GcubeAlgorithmRepository(){
- updateRepository();
- }
-
- public ProcessDescriptionType getProcessDescription(String identifier){
- updateRepository();
- log.info("getProcessDescription with identifier {} ",identifier);
- try{
- Set> classes = reflection.getTypesAnnotatedWith(Algorithm.class);
- for (Class> _class: classes){
- if (_class.getAnnotation(Algorithm.class).identifier().equals(identifier)){
- return ((IAlgorithm)_class.newInstance()).getDescription();
- }
- }
- }catch(Exception e){}
- throw new RuntimeException(String.format("Algorithm with process id %s not found", identifier));
- }
-
- public boolean containsAlgorithm(String identifier) {
- updateRepository();
- log.info("containsAlgorithm with identifier {} ",identifier);
- Set> classes = reflection.getTypesAnnotatedWith(Algorithm.class);
- for (Class> _class: classes){
- if (_class.getAnnotation(Algorithm.class).identifier().equals(identifier)){
- return true;
- }
- }
- return false;
- }
-
- public IAlgorithm getAlgorithm(String identifier){
- updateRepository();
- log.info("getAlgorithm with identifier {} ",identifier);
- try{
- Set> classes = reflection.getTypesAnnotatedWith(Algorithm.class);
- for (Class> _class: classes){
- if (_class.getAnnotation(Algorithm.class).identifier().equals(identifier)){
- if (IAlgorithm.class.isAssignableFrom(_class)){
- return (IAlgorithm)_class.newInstance();
- } else {
- log.warn("found algorothm class {} is no assignable from {}",_class.getName(), IAlgorithm.class.getName());
- break;
- }
- }
- }
- }catch(Exception e){}
- throw new RuntimeException(String.format("Algorithm with id %s not found", identifier));
- }
-
- public static Set> getAllAlgorithms() {
- updateRepository();
- return reflection.getTypesAnnotatedWith(Algorithm.class);
- }
-
- private static synchronized void updateRepository(){
- if ((System.currentTimeMillis()-lastUpdate)>UPDATE_TIME_IN_MILLIS){
- log.info("update time passed, updating repository");
- String packageToFind = "org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses";
- ConfigurationBuilder confBuilder = new ConfigurationBuilder()
- .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packageToFind)))
- .setUrls(ClasspathHelper.forClassLoader());
- reflection = new Reflections(confBuilder);
- lastUpdate = System.currentTimeMillis();
- }
- }
-
- @Override
- public Collection getAlgorithmNames() {
- updateRepository();
- Collection toReturn = new ArrayList();
- Set> classes = reflection.getTypesAnnotatedWith(Algorithm.class);
- for (Class> _class: classes){
- toReturn.add(_class.getAnnotation(Algorithm.class).title());
- }
- return toReturn;
- }
-
- @Override
- public void shutdown() {
-
- }
-}
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/CancelComputation.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/CancelComputation.java
deleted file mode 100644
index 6278613..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/CancelComputation.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.web;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.UUID;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang.StringUtils;
-import org.n52.wps.commons.XMLUtil;
-import org.n52.wps.server.database.DatabaseFactory;
-import org.n52.wps.server.database.IDatabase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CancelComputation extends HttpServlet {
-
- private final static Logger LOGGER = LoggerFactory.getLogger(CancelComputation.class);
- private static final long serialVersionUID = -268198171054599696L;
- // This is required for URL generation for response documents.
- public final static String SERVLET_PATH = "RetrieveResultServlet";
- // in future parameterize
- //private final boolean indentXML = false;
-
- private final int uuid_length = 36;
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
- }
-
- public static String empty = " " +
- " " +
- "";
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
- // id of result to retrieve.
- String id = request.getParameter("id");
-
- LOGGER.debug("CANCEL COMPUTATION -> RETRIEVING ID " + id);
- if (StringUtils.isEmpty(id)) {
- errorResponse("id parameter missing", response);
- } else {
- LOGGER.debug("CANCEL COMPUTATION -> ID RETRIEVED " + id);
- if (!isIDValid(id)) {
- errorResponse("id parameter not valid", response);
- }
- LOGGER.debug("CANCEL COMPUTATION -> ID IS VALID " + id);
- IDatabase db = DatabaseFactory.getDatabase();
- long len = db.getContentLengthForStoreResponse(id);
- LOGGER.debug("CANCEL COMPUTATION -> INITIAL ID RESPONSE LENGTH " + len);
-
- try {
- LOGGER.debug("CANCEL COMPUTATION -> DELETING ID " + id);
-
- try {
-// String empty = "";
- InputStream stream = new ByteArrayInputStream(empty.getBytes("UTF-8"));
- db.updateResponse(id, stream);
- stream.close();
- } catch (Exception e) {
- LOGGER.error("error reading th einput stream",e);
- }
- LOGGER.debug("CANCEL COMPUTATION -> ID DELETED " + id);
- len = db.getContentLengthForStoreResponse(id);
- LOGGER.debug("CANCEL COMPUTATION -> ID RESPONSE LENGTH " + len);
- } catch (Exception e) {
- LOGGER.error("error in do get",e);
- } finally {
- }
- }
- }
-
- protected void errorResponse(String error, HttpServletResponse response) throws IOException {
- response.setContentType("text/html");
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- PrintWriter writer = response.getWriter();
- writer.write("Error" + error + "");
- writer.flush();
- LOGGER.warn("Error processing response: " + error);
- }
-
- protected void copyResponseStream(InputStream inputStream, OutputStream outputStream, String id, long contentLength) throws IOException {
- long contentWritten = 0;
- try {
- byte[] buffer = new byte[8192];
- int bufferRead;
- while ((bufferRead = inputStream.read(buffer)) != -1) {
- outputStream.write(buffer, 0, bufferRead);
- contentWritten += bufferRead;
- }
- } catch (IOException e) {
- String exceptionMessage = contentLength > -1 ? String.format("Error writing response to output stream for id %s, %d of %d bytes written", id, contentWritten, contentLength) : String.format("Error writing response to output stream for id %s, %d bytes written", id, contentWritten);
- throw new IOException(exceptionMessage, e);
- }
- LOGGER.info("{} bytes written in response to id {}", contentWritten, id);
- }
-
- protected void copyResponseAsXML(InputStream inputStream, OutputStream outputStream, boolean indent, String id) throws IOException {
- try {
- XMLUtil.copyXML(inputStream, outputStream, indent);
- } catch (IOException e) {
- throw new IOException("Error writing XML response for id " + id, e);
- }
- }
-
- public static Throwable getRootCause(Throwable t) {
- return t.getCause() == null ? t : getRootCause(t.getCause());
- }
-
- public boolean isIDValid(String id) {
-
- if (id.length() <= uuid_length) {
-
- try {
- UUID checkUUID = UUID.fromString(id);
-
- if (checkUUID.toString().equals(id)) {
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- return false;
- }
-
- } else {
-
- String uuidPartOne = id.substring(0, uuid_length);
- String uuidPartTwo = id.substring(id.length() - uuid_length, id.length());
-
- return isUUIDValid(uuidPartOne) && isUUIDValid(uuidPartTwo);
- }
- }
-
- public boolean isUUIDValid(String uuid) {
-
- // the following can be used to check whether the id is a valid UUID
- try {
- UUID checkUUID = UUID.fromString(uuid);
-
- if (checkUUID.toString().equals(uuid)) {
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- return false;
- }
- }
-}
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/ExecuteResponse.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/ExecuteResponse.java
deleted file mode 100644
index b90b64b..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/ExecuteResponse.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.web;
-
-import java.io.InputStream;
-
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.server.response.ExecuteResponseBuilder;
-import org.n52.wps.server.response.Response;
-
-public class ExecuteResponse extends Response {
-
- private ExecuteResponseBuilder builder;
-
- public ExecuteResponse(ExecuteRequest request) throws ExceptionReport{
- super(request);
- this.builder = ((ExecuteRequest)this.request).getExecuteResponseBuilder();
- }
-
- @Override
- public InputStream getAsStream() throws ExceptionReport{
- return this.builder.getAsStream();
- }
-
- public ExecuteResponseBuilder getExecuteResponseBuilder(){
- return builder;
- }
-
- public String getMimeType(){
- return builder.getMimeType();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/RequestHandler.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/RequestHandler.java
deleted file mode 100644
index 8ef6482..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/RequestHandler.java
+++ /dev/null
@@ -1,430 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.web;
-/**
- * Copyright (C) 2007 - 2014 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.
- *
- * 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:
- *
- * • 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.
-org.gcube.dataanalysis.wps.statisticalmanager.synchserver.weberver.handler;
-*/
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.RejectedExecutionException;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.commons.collections.map.CaseInsensitiveMap;
-import org.apache.commons.io.IOUtils;
-import org.gcube.common.authorization.library.AuthorizedTasks;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.capabilities.GetCapabilitiesBuilder;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.WebProcessingService;
-import org.n52.wps.server.handler.RequestExecutor;
-import org.n52.wps.server.request.CapabilitiesRequest;
-import org.n52.wps.server.request.DescribeProcessRequest;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.server.request.Request;
-import org.n52.wps.server.request.RetrieveResultRequest;
-import org.n52.wps.server.response.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-
-public class RequestHandler {
-
- public static final String VERSION_ATTRIBUTE_NAME = "version";
-
- /** Computation timeout in seconds */
- protected static RequestExecutor pool = new RequestExecutor();
-
- protected OutputStream os;
-
- private static Logger LOGGER = LoggerFactory.getLogger(RequestHandler.class);
-
- protected String responseMimeType;
-
- protected Request req;
-
- // Empty constructor due to classes which extend the RequestHandler
- protected RequestHandler() {
-
- }
- private Map params;
- /**
- * Handles requests of type HTTP_GET (currently capabilities and
- * describeProcess). A Map is used to represent the client input.
- *
- * @param params
- * The client input
- * @param os
- * The OutputStream to write the response to.
- * @throws ExceptionReport
- * If the requested operation is not supported
- */
- public RequestHandler(Map params, OutputStream os)
- throws ExceptionReport {
- this.os = os;
- this.params=params;
- //sleepingTime is 0, by default.
- /*if(WPSConfiguration.getInstance().exists(PROPERTY_NAME_COMPUTATION_TIMEOUT)) {
- this.sleepingTime = Integer.parseInt(WPSConfiguration.getInstance().getProperty(PROPERTY_NAME_COMPUTATION_TIMEOUT));
- }
- String sleepTime = WPSConfig.getInstance().getWPSConfig().getServer().getComputationTimeoutMilliSeconds();
- */
-
-
- Request req;
- CaseInsensitiveMap ciMap = new CaseInsensitiveMap(params);
-
- /*
- * check if service parameter is present and equals "WPS"
- * otherwise an ExceptionReport will be thrown
- */
- String serviceType = Request.getMapValue("service", ciMap, true);
-
- if(!serviceType.equalsIgnoreCase("WPS")){
- throw new ExceptionReport("Parameter is not correct, expected: WPS, got: " + serviceType,
- ExceptionReport.INVALID_PARAMETER_VALUE, "service");
- }
-
- /*
- * check language. if not supported, return ExceptionReport
- * Fix for https://bugzilla.52north.org/show_bug.cgi?id=905
- */
- String language = Request.getMapValue("language", ciMap, false);
-
- if(language != null){
- Request.checkLanguageSupported(language);
- }
-
- // get the request type
- String requestType = Request.getMapValue("request", ciMap, true);
-
- if (requestType.equalsIgnoreCase("GetCapabilities")) {
- req = new CapabilitiesRequest(ciMap);
- }
- else if (requestType.equalsIgnoreCase("DescribeProcess")) {
- req = new DescribeProcessRequest(ciMap);
- }
- else if (requestType.equalsIgnoreCase("Execute")) {
- req = new ExecuteRequest(ciMap);
- setResponseMimeType((ExecuteRequest)req);
- }
- else if (requestType.equalsIgnoreCase("RetrieveResult")) {
- req = new RetrieveResultRequest(ciMap);
- }
- else {
- throw new ExceptionReport(
- "The requested Operation is not supported or not applicable to the specification: "
- + requestType,
- ExceptionReport.OPERATION_NOT_SUPPORTED, requestType);
- }
-
- this.req = req;
- }
-
- /**
- * Handles requests of type HTTP_POST (currently executeProcess). A Document
- * is used to represent the client input. This Document must first be parsed
- * from an InputStream.
- *
- * @param is
- * The client input
- * @param os
- * The OutputStream to write the response to.
- * @throws ExceptionReport
- */
- public RequestHandler(InputStream is, OutputStream os)
- throws ExceptionReport {
- String nodeName, localName, nodeURI, version = null;
- Document doc;
- this.os = os;
-
- boolean isCapabilitiesNode = false;
-
- try {
- LOGGER.trace("Parsing Document...");
- System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-
- DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
- fac.setNamespaceAware(true);
-
- // parse the InputStream to create a Document
- doc = fac.newDocumentBuilder().parse(is);
-
- LOGGER.trace("Document Parsing OK");
- // Get the first non-comment child.
- Node child = doc.getFirstChild();
- while(child.getNodeName().compareTo("#comment")==0) {
- child = child.getNextSibling();
- }
- LOGGER.trace("Skipped comments OK");
- nodeName = child.getNodeName();
- localName = child.getLocalName();
- nodeURI = child.getNamespaceURI();
- Node versionNode = child.getAttributes().getNamedItem("version");
- LOGGER.trace("Version OK");
- /*
- * check for service parameter. this has to be present for all requests
- */
- Node serviceNode = child.getAttributes().getNamedItem("service");
-
- if(serviceNode == null){
- throw new ExceptionReport("Parameter not specified.", ExceptionReport.MISSING_PARAMETER_VALUE, "service");
- }else{
- if(!serviceNode.getNodeValue().equalsIgnoreCase("WPS")){
- throw new ExceptionReport("Parameter not specified.", ExceptionReport.INVALID_PARAMETER_VALUE, "service");
- }
- }
- LOGGER.trace("Service Node OK");
-
- isCapabilitiesNode = nodeName.toLowerCase().contains("capabilities");
- if(versionNode == null && !isCapabilitiesNode) {
- throw new ExceptionReport("Parameter not specified.", ExceptionReport.MISSING_PARAMETER_VALUE, "version");
- }
- if(!isCapabilitiesNode){
-// version = child.getFirstChild().getTextContent();//.getNextSibling().getFirstChild().getNextSibling().getFirstChild().getNodeValue();
- version = child.getAttributes().getNamedItem("version").getNodeValue();
- }
-
- LOGGER.trace("Capabilities Node OK");
- /*
- * check language, if not supported, return ExceptionReport
- * Fix for https://bugzilla.52north.org/show_bug.cgi?id=905
- */
- Node languageNode = child.getAttributes().getNamedItem("language");
- if(languageNode != null){
- String language = languageNode.getNodeValue();
- Request.checkLanguageSupported(language);
- }
-
- LOGGER.trace("Language Node OK "+languageNode);
-
- } catch (SAXException e) {
- throw new ExceptionReport(
- "There went something wrong with parsing the POST data: "
- + e.getMessage(),
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (IOException e) {
- throw new ExceptionReport(
- "There went something wrong with the network connection.",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (ParserConfigurationException e) {
- throw new ExceptionReport(
- "There is a internal parser configuration error",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- }
- //Fix for Bug 904 https://bugzilla.52north.org/show_bug.cgi?id=904
- if(!isCapabilitiesNode && version == null) {
- LOGGER.error("EXCEPTION: Parameter not specified." + ExceptionReport.MISSING_PARAMETER_VALUE + " version");
- throw new ExceptionReport("Parameter not specified." , ExceptionReport.MISSING_PARAMETER_VALUE, "version");
- }
- if(!isCapabilitiesNode && !version.equals(Request.SUPPORTED_VERSION)) {
- LOGGER.error("EXCEPTION: Version not supported." + ExceptionReport.INVALID_PARAMETER_VALUE + "version");
- throw new ExceptionReport("Version not supported." , ExceptionReport.INVALID_PARAMETER_VALUE, "version");
- }
- // get the request type
- if (nodeURI.equals(WebProcessingService.WPS_NAMESPACE) && localName.equals("Execute")) {
- LOGGER.debug("Detected Request to Execute!");
- req = new ExecuteRequest(doc);
- setResponseMimeType((ExecuteRequest)req);
- LOGGER.debug("Request to Execute Configured!");
- }else if (nodeURI.equals(WebProcessingService.WPS_NAMESPACE) && localName.equals("GetCapabilities")){
- LOGGER.debug("Detected GetCapabilities!");
- req = new CapabilitiesRequest(doc);
- this.responseMimeType = "text/xml";
- } else if (nodeURI.equals(WebProcessingService.WPS_NAMESPACE) && localName.equals("DescribeProcess")) {
- LOGGER.debug("Detected DescribeProcess!");
- req = new DescribeProcessRequest(doc);
- this.responseMimeType = "text/xml";
-
- } else if(!localName.equals("Execute")){
- LOGGER.error("EXCEPTION Detected NON-supported Request "+"The requested Operation not supported or not applicable to the specification: "+ nodeName + ExceptionReport.OPERATION_NOT_SUPPORTED + localName);
- throw new ExceptionReport("The requested Operation not supported or not applicable to the specification: "
- + nodeName, ExceptionReport.OPERATION_NOT_SUPPORTED, localName);
- }
- else if(nodeURI.equals(WebProcessingService.WPS_NAMESPACE)) {
- LOGGER.error("specified namespace is not supported: "+ nodeURI + ExceptionReport.INVALID_PARAMETER_VALUE);
- throw new ExceptionReport("specified namespace is not supported: "
- + nodeURI, ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- }
-
- /**
- * Handle a request after its type is determined. The request is scheduled
- * for execution. If the server has enough free resources, the client will
- * be served immediately. If time runs out, the client will be asked to come
- * back later with a reference to the result.
- *
- * @param req The request of the client.
- * @throws ExceptionReport
- */
- public void handle() throws ExceptionReport {
- Response resp = null;
- if(req ==null){
- throw new ExceptionReport("Internal Error","");
- }
- if (req instanceof ExecuteRequest) {
- LOGGER.debug("Request for execution");
- // cast the request to an executerequest
- ExecuteRequest execReq = (ExecuteRequest) req;
- LOGGER.debug("Accepted request for execution");
- execReq.updateStatusAccepted();
- //modification by GP 26-05-2015 to account for multi user and scopes
- Callable execCallable = AuthorizedTasks.bind(execReq);
- ExceptionReport exceptionReport = null;
- try {
- if (execReq.isStoreResponse()) {
- LOGGER.debug("Execution with output storing");
- resp = new ExecuteResponse(execReq);
- InputStream is = resp.getAsStream();
- IOUtils.copy(is, os);
- is.close();
-// pool.submit(execReq);
- pool.submit(execCallable);
- return;
- }
- try {
- LOGGER.debug("Execution without storing output");
- // retrieve status with timeout enabled
- try {
- resp = pool.submit(execCallable).get();
- }
- catch (ExecutionException ee) {
- LOGGER.warn("exception while handling ExecuteRequest.",ee);
- // the computation threw an error
- // probably the client input is not valid
- if (ee.getCause() instanceof ExceptionReport) {
- exceptionReport = (ExceptionReport) ee
- .getCause();
- } else {
- exceptionReport = new ExceptionReport(
- "An error occurred in the computation: "
- + ee.getMessage(),
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- } catch (InterruptedException ie) {
- LOGGER.warn("interrupted while handling ExecuteRequest.",ie);
-
- // interrupted while waiting in the queue
- exceptionReport = new ExceptionReport(
- "The computation in the process was interrupted.",
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- } finally {
- if (exceptionReport != null) {
- LOGGER.warn("ExceptionReport not null",exceptionReport);
- // NOT SURE, if this exceptionReport is also written to the DB, if required... test please!
- throw exceptionReport;
- }
- // send the result to the outputstream of the client.
- /* if(((ExecuteRequest) req).isQuickStatus()) {
- resp = new ExecuteResponse(execReq);
- }*/
- else if(resp == null) {
- LOGGER.warn("null response handling ExecuteRequest.");
- throw new ExceptionReport("Problem with handling threads in RequestHandler", ExceptionReport.NO_APPLICABLE_CODE);
- }
- if(!execReq.isStoreResponse()) {
- InputStream is = resp.getAsStream();
- IOUtils.copy(is, os);
- is.close();
- LOGGER.info("Served ExecuteRequest.");
- }
- }
- } catch (RejectedExecutionException ree) {
- LOGGER.warn("exception handling ExecuteRequest.", ree);
- // server too busy?
- throw new ExceptionReport(
- "The requested process was rejected. Maybe the server is flooded with requests.",
- ExceptionReport.SERVER_BUSY);
- } catch (Exception e) {
- LOGGER.error("exception handling ExecuteRequest.", e);
- if (e instanceof ExceptionReport) {
- throw (ExceptionReport)e;
- }
- throw new ExceptionReport("Could not read from response stream.", ExceptionReport.NO_APPLICABLE_CODE);
- }
- } else {
- // for GetCapabilities and DescribeProcess:
-
- resp = req.call();
-
- try {
- InputStream is = null;
- if (req instanceof CapabilitiesRequest){
- GetCapabilitiesBuilder builder = new GetCapabilitiesBuilder();
- String getCapabilitiesStringFromInfra = "";
- try {
- getCapabilitiesStringFromInfra = builder.buildGetCapabilities(params);
- } catch (Exception e) {
- throw new ExceptionReport("Error in building GetCapabilities","getcapabilities",e);
- }
- is = IOUtils.toInputStream(getCapabilitiesStringFromInfra, "UTF-8");
- }
- else
- is = resp.getAsStream();
-
- IOUtils.copy(is, os);
- is.close();
- } catch (IOException e) {
- throw new ExceptionReport("Could not read from response stream.", ExceptionReport.NO_APPLICABLE_CODE);
- }
-
- }
- }
-
- protected void setResponseMimeType(ExecuteRequest req) {
- if(req.isRawData()){
- responseMimeType = req.getExecuteResponseBuilder().getMimeType();
- }else{
- responseMimeType = "text/xml";
- }
-
-
- }
-
-
-
- public String getResponseMimeType(){
- if(responseMimeType == null){
- return "text/xml";
- }
- return responseMimeType.toLowerCase();
- }
-
-
-}
-
-
-
diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/WebProcessingService.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/WebProcessingService.java
deleted file mode 100644
index 0b43cf4..0000000
--- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/web/WebProcessingService.java
+++ /dev/null
@@ -1,422 +0,0 @@
-package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.web;
-/**
- * Copyright (C) 2007 - 2014 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.
- *
- * 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:
- *
- * • 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.
-org.gcube.dataanalysis.wps.statisticalmanager.synchserver.capabilities52.wps.server;
- */
-// FvK: added Property Change Listener support
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.net.URLDecoder;
-import java.util.Map;
-import java.util.zip.GZIPOutputStream;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.xmlbeans.XmlException;
-import org.gcube.smartgears.ContextProvider;
-import org.gcube.smartgears.context.application.ApplicationContext;
-import org.n52.wps.GeneratorDocument.Generator;
-import org.n52.wps.ParserDocument.Parser;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.GeneratorFactory;
-import org.n52.wps.io.ParserFactory;
-import org.n52.wps.server.CapabilitiesConfiguration;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.database.DatabaseFactory;
-import org.n52.wps.util.XMLBeansHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This WPS supports HTTP GET for describeProcess and getCapabilities and XML-POST for execute.
- *
- * @author foerster
- *
- */
-public class WebProcessingService extends HttpServlet {
-
- // Universal version identifier for a Serializable class.
- // Should be used here, because HttpServlet implements the java.io.Serializable
- private static final long serialVersionUID = 8943233273641771839L;
- public static String PROPERTY_NAME_WEBAPP_PATH = "webappPath";
- public static String BASE_DIR = null;
- public static String WEBAPP_PATH = null;
- public static String SERVLET_PATH = "WebProcessingService";
- public static String WPS_NAMESPACE = "http://www.opengis.net/wps/1.0.0";
- public static String DEFAULT_LANGUAGE = "en-US";
- protected static Logger LOGGER = LoggerFactory.getLogger(WebProcessingService.class);
-
- private ApplicationContext context = ContextProvider.get();
-
- /**
- *
- * Returns a preconfigured OutputStream It takes care of: - caching - content-Encoding
- *
- * @param hsRequest
- * the HttpServletRequest
- * @param hsResponse
- * the HttpServlerResponse
- * @return the preconfigured OutputStream
- * @throws IOException
- * a task of the tomcat
- */
- @SuppressWarnings("unused")
- private static OutputStream getConfiguredOutputStream(HttpServletRequest hsRequest, HttpServletResponse hsResponse) throws IOException {
- /*
- * Forbids clients to cache the response May solve problems with proxies and bad implementations
- */
-
- hsResponse.setHeader("Expires", "0");
- if (hsRequest.getProtocol().equals("HTTP/1.1")) {
- hsResponse.setHeader("Cache-Control", "no-cache");
- } else if (hsRequest.getProtocol().equals("HTTP/1.0")) {
- hsResponse.setHeader("Pragma", "no-cache");
- }
-
- // Enable/disable gzip compression
- if (hsRequest.getHeader("Accept-Encoding") != null
- && hsRequest.getHeader("Accept-Encoding").indexOf("gzip") >= 0) {
- hsResponse.setHeader("Content-Encoding", "gzip");
- LOGGER.info("gzip-Compression for output enabled");
- return new GZIPOutputStream(hsResponse.getOutputStream());
- } // else {
- LOGGER.info("gzip-Compression for output disabled");
- return hsResponse.getOutputStream();
- // }
- }
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
-
- // this is important to set the lon lat support for correct CRS transformation.
-
- System.setProperty("org.geotools.referencing.forceXY", "true");
-
- LOGGER.info("WebProcessingService initializing...");
-
- try {
- if (WPSConfig.getInstance(config) == null) {
- LOGGER.error("Initialization failed! Please look at the properties file!");
- return;
- }
- }
- catch (Exception e) {
- LOGGER.error("Initialization failed! Please look at the properties file!", e);
- return;
- }
- LOGGER.info("Initialization of wps properties successful!");
-
- BASE_DIR = this.getServletContext().getRealPath("");
-
- Parser[] parsers = WPSConfig.getInstance().getActiveRegisteredParser();
- ParserFactory.initialize(parsers);
-
- Generator[] generators = WPSConfig.getInstance().getActiveRegisteredGenerator();
- GeneratorFactory.initialize(generators);
-
- // call RepositoyManager to initialize
- LOGGER.info("Algorithms initialized");
-
- // String customWebappPath = WPSConfiguration.getInstance().getProperty(PROPERTY_NAME_WEBAPP_PATH);
- String customWebappPath = WPSConfig.getInstance().getWPSConfig().getServer().getWebappPath();
- if (customWebappPath != null) {
- WEBAPP_PATH = customWebappPath;
- }
- else {
- WEBAPP_PATH = "wps";
- LOGGER.warn("No custom webapp path found, use default wps");
- }
- LOGGER.info("webappPath is set to: " + customWebappPath);
-
- try {
- CapabilitiesConfiguration.getInstance(BASE_DIR + File.separator + "config"
- + File.separator + "wpsCapabilitiesSkeleton.xml");
- }
- catch (IOException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration", e);
- }
- catch (XmlException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration", e);
- }
-
- // Get an instance of the database for initialization of the database
- DatabaseFactory.getDatabase();
-
- LOGGER.info("WPS up and running!");
-
- // FvK: added Property Change Listener support
- // creates listener and register it to the wpsConfig instance.
- // it will listen to changes of the wpsCapabilities
- WPSConfig.getInstance().addPropertyChangeListener(org.n52.wps.commons.WPSConfig.WPSCAPABILITIES_SKELETON_PROPERTY_EVENT_NAME,
- new PropertyChangeListener() {
- @Override
- public void propertyChange(final PropertyChangeEvent propertyChangeEvent) {
- LOGGER.info(this.getClass().getName()
- + ": Received Property Change Event: "
- + propertyChangeEvent.getPropertyName());
- try {
- CapabilitiesConfiguration.reloadSkeleton();
- }
- catch (IOException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration",
- e);
- }
- catch (XmlException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration",
- e);
- }
- }
- });
-
- // FvK: added Property Change Listener support
- // creates listener and register it to the wpsConfig instance.
- // it will listen to changes of the wpsConfiguration
- WPSConfig.getInstance().addPropertyChangeListener(org.n52.wps.commons.WPSConfig.WPSCONFIG_PROPERTY_EVENT_NAME,
- new PropertyChangeListener() {
- public void propertyChange(final PropertyChangeEvent propertyChangeEvent) {
- LOGGER.info(this.getClass().getName()
- + ": Received Property Change Event: "
- + propertyChangeEvent.getPropertyName());
- try {
- CapabilitiesConfiguration.reloadSkeleton();
- }
- catch (IOException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration",
- e);
- }
- catch (XmlException e) {
- LOGGER.error("error while initializing capabilitiesConfiguration",
- e);
- }
- }
- });
-
- }
-
- protected void setServerParameters(){
- //String endpoint = CapabilitiesConfiguration.ENDPOINT_URL;
-
- String webapp = context.application().getContextPath().replace("//", "");
- WPSConfig.getInstance().getWPSConfig().getServer().setWebappPath(webapp);
-
-
- String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
- String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
-
- if (host==null || host.toLowerCase().equals("localhost")){
- LOGGER.info("resolving hostname and port from container.xml");
- host = context.container().configuration().hostname();
- port = Integer.toString(context.container().configuration().port());
- WPSConfig.getInstance().getWPSConfig().getServer().setHostname(host);
- WPSConfig.getInstance().getWPSConfig().getServer().setHostport(port);
- }
-
-
- LOGGER.debug("Setting server parameters: Host: {}, Port: {} , Webapp: {} ", host, port,webapp);
- //TODO: CHANGE the porotocol to enable https via conainer configuration
- String webPath = "http://" + host + ":" + port + "/" + webapp + "/WebProcessingService";
- if (CapabilitiesConfiguration.ENDPOINT_URL.contains("localhost"))
- CapabilitiesConfiguration.ENDPOINT_URL=webPath;
-
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- try {
- setServerParameters();
- OutputStream out = res.getOutputStream(); // closed by res.flushBuffer();
-
- @SuppressWarnings("unchecked")
- RequestHandler handler = new RequestHandler((Map) req.getParameterMap(), out);
- String mimeType = handler.getResponseMimeType();
- res.setContentType(mimeType);
- handler.handle();
-
- res.setStatus(HttpServletResponse.SC_OK);
- }
- catch (ExceptionReport e) {
- handleException(e, res);
- }
- catch (RuntimeException e) {
- ExceptionReport er = new ExceptionReport("Error handing request: " + e.getMessage(),
- ExceptionReport.NO_APPLICABLE_CODE,
- e);
- handleException(er, res);
- }
- finally {
- if (res != null) {
- res.flushBuffer();
- }
- // out.flush();
- // out.close();
- }
- }
-
- public final static int MAXIMUM_REQUEST_SIZE = 128 << 20;
- public final static String SPECIAL_XML_POST_VARIABLE = "request";
- private static final String XML_CONTENT_TYPE = "text/xml";
-
- protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- setServerParameters();
- BufferedReader reader = null;
- LOGGER.debug("Incoming Post Request");
- try {
- String contentType = req.getContentType();
- String characterEncoding = req.getCharacterEncoding();
- if (characterEncoding == null || characterEncoding.length() == 0) {
- characterEncoding = "UTF-8"; // default character encoding if unspecified
- }
- LOGGER.debug("Set Encoding to {}",characterEncoding);
- int contentLength = req.getContentLength();
- if (contentLength > MAXIMUM_REQUEST_SIZE) {
- LOGGER.warn("POST request rejected, request size of " + contentLength + " too large.");
- ExceptionReport er = new ExceptionReport("Request body too large, limited to " + MAXIMUM_REQUEST_SIZE
- + " bytes", ExceptionReport.NO_APPLICABLE_CODE);
- handleException(er, res);
- }
-
- LOGGER.debug("Received POST: Content-Type = {}, Character-Encoding = {} , Content-Length = {} " , contentType, characterEncoding, contentLength);
-
- int requestSize = 0;
-
- StringWriter writer = contentLength > 0 ? new StringWriter(contentLength) : new StringWriter();
- reader = req.getReader();
- char[] buffer = new char[8192];
- int read;
- while ( (read = reader.read(buffer)) != -1 && requestSize < MAXIMUM_REQUEST_SIZE) {
- writer.write(buffer, 0, read);
- requestSize += read;
- }
-
- LOGGER.debug("POST request contained {} characters", requestSize);
-
- // Protect against denial of service attacks.
- if (requestSize >= MAXIMUM_REQUEST_SIZE && reader.read() > -1) {
- LOGGER.warn("POST request rejected, request size of {} too large.",requestSize);
- ExceptionReport er = new ExceptionReport("Request body too large, limited to " + MAXIMUM_REQUEST_SIZE
- + " bytes", ExceptionReport.NO_APPLICABLE_CODE);
- handleException(er, res);
- }
-
- String documentString = writer.toString();
- // Perform URL decoding, if necessary
- // if ("application/x-www-form-urlencoded".equals(contentType)) {
- if ( (contentType).startsWith("application/x-www-form-urlencoded")) {
- if (documentString.startsWith(SPECIAL_XML_POST_VARIABLE + "=")) {
- // This is a hack to permit xml to be easily submitted via a form POST.
- // By convention, we are allowing users to post xml if they name it
- // with a POST parameter "request" although this is not
- // valid per the specification.
- documentString = documentString.substring(SPECIAL_XML_POST_VARIABLE.length() + 1);
- LOGGER.debug("POST request form variable removed");
- }
- documentString = URLDecoder.decode(documentString, characterEncoding);
- LOGGER.debug("Decoded of POST:\n" + documentString + "\n");
- }
- else
- LOGGER.info("This is a standard xml document");
-
- RequestHandler handler = new RequestHandler(new ByteArrayInputStream(documentString.getBytes("UTF-8")),
- res.getOutputStream());
- LOGGER.debug("POST Request Handler created");
- String mimeType = handler.getResponseMimeType();
- LOGGER.debug("Request mimeType: "+mimeType);
- res.setContentType(mimeType);
- LOGGER.debug("Handling document");
-
- handler.handle();
-
- LOGGER.debug("STATUS OK!");
- res.setStatus(HttpServletResponse.SC_OK);
- }
- catch (ExceptionReport e) {
- handleException(e, res);
- }
- catch (Exception e) {
- ExceptionReport er = new ExceptionReport("Error handing request: " + e.getMessage(), ExceptionReport.NO_APPLICABLE_CODE, e);
- handleException(er, res);
- }
- finally {
- if (res != null) {
- res.flushBuffer();
- }
-
- if (reader != null) {
- reader.close();
- }
- LOGGER.trace("Flushing request");
- }
- }
-
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- if (SERVLET_PATH == null) {
- req.getContextPath();
- }
- super.service(req, res);
- }
-
- private static void handleException(ExceptionReport exception, HttpServletResponse res) {
- res.setContentType(XML_CONTENT_TYPE);
- try {
- LOGGER.debug(exception.toString());
- // DO NOT MIX getWriter and getOuputStream!
- exception.getExceptionDocument().save(res.getOutputStream(),
- XMLBeansHelper.getXmlOptions());
-
- res.setStatus(exception.getHTTPStatusCode());
- }
- catch (IOException e) {
- LOGGER.warn("exception occured while writing ExceptionReport to stream");
- try {
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- "error occured, while writing OWS Exception output");
- }
- catch (IOException ex) {
- LOGGER.error("error while writing error code to client!");
- res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
- }
- }
-
- @Override
- public void destroy() {
- super.destroy();
- DatabaseFactory.getDatabase().shutdown();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/n52/wps/demo/ConvexHullDemo.java b/src/main/java/org/n52/wps/demo/ConvexHullDemo.java
deleted file mode 100644
index 626197f..0000000
--- a/src/main/java/org/n52/wps/demo/ConvexHullDemo.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.n52.wps.demo;
-
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-
-public class ConvexHullDemo {
- /*
-import org.geotools.data.simple.SimpleFeatureCollection;
-import org.geotools.feature.DefaultFeatureCollections;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureIterator;
-import org.n52.wps.io.GTHelper;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-import org.opengis.feature.Feature;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryFactory;
-
-//org.n52.wps.demo.ConvexHullDemo
-
-
-
- @Override
- public Class> getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("FEATURES")) {
- return GTVectorDataBinding.class;
- }
- return null;
- }
-
- @Override
- public Class> getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("polygons")) {
- return GTVectorDataBinding.class;
- }
- return null;
- }
-
-
- @Override
- public Map run(Map> inputData)
- throws ExceptionReport {
- if (inputData == null || !inputData.containsKey("FEATURES")) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List dataList = inputData.get("FEATURES");
- if (dataList == null || dataList.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- IData firstInputData = dataList.get(0);
- FeatureCollection featureCollection = ((GTVectorDataBinding) firstInputData).getPayload();
-
- FeatureIterator iter = featureCollection.features();
- List coordinateList = new ArrayList();
- int counter = 0;
- while (iter.hasNext()) {
- SimpleFeature feature = (SimpleFeature) iter.next();
- if (feature.getDefaultGeometry() == null) {
- throw new NullPointerException("defaultGeometry is null in feature id: "+ feature.getID());
- }
- Geometry geom = (Geometry) feature.getDefaultGeometry();
- Coordinate[] coordinateArray = geom.getCoordinates();
- for(Coordinate coordinate : coordinateArray){
- coordinateList.add(coordinate);
- }
- }
- iter.close();
-
- Coordinate[] coordinateArray = new Coordinate[coordinateList.size()];
- for(int i = 0; i result = new HashMap();
- result.put("polygons", new GTVectorDataBinding(fOut));
- return result;
- }
-
- @Override
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("FEATURES");
- return list;
-
- }
-
- @Override
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("polygons");
- return list;
- }
-*/
-}
diff --git a/src/main/java/org/n52/wps/demo/CopyOfGPDemoFile.java b/src/main/java/org/n52/wps/demo/CopyOfGPDemoFile.java
deleted file mode 100644
index d275649..0000000
--- a/src/main/java/org/n52/wps/demo/CopyOfGPDemoFile.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.n52.wps.demo;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.opengis.ows.x11.impl.MimeTypeImpl;
-
-import org.apache.commons.io.IOUtils;
-import org.n52.wps.io.data.GenericFileData;
-import org.n52.wps.io.data.GenericFileDataConstants;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.FileDataBinding;
-import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-
-//org.n52.wps.demo.GPDemoFile
-
-public class CopyOfGPDemoFile extends AbstractSelfDescribingAlgorithm {
-
- @Override
- public Class> getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("CHECK")) {
- return org.n52.wps.io.data.binding.literal.LiteralStringBinding.class;
- }
- if (identifier.equalsIgnoreCase("FFF")) {
- return GenericFileDataBinding.class;
- }
- return null;
- }
-
- @Override
- public Class> getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("polygons")) {
- return org.n52.wps.io.data.binding.literal.LiteralStringBinding.class;
- }
- if (identifier.equalsIgnoreCase("file")) {
- return GenericFileDataBinding.class;
- }
-
- return null;
- }
-
- @Override
- public Map run(Map> inputData)
- throws ExceptionReport {
- if (inputData == null || !inputData.containsKey("CHECK")) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List dataList = inputData.get("CHECK");
- if (dataList == null || dataList.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- IData data = inputData.get("FFF").get(0);
-
- if(data instanceof FileDataBinding){
- System.out.println("We got a standard File! ");
- FileDataBinding fileDataBinding = (FileDataBinding)data;
- File file = fileDataBinding.getPayload();
- System.out.println("Here ! "+file.getAbsolutePath());
- }
- GenericFileDataBinding fileDataBinding = null;
- if(data instanceof GenericFileDataBinding){
- fileDataBinding = (GenericFileDataBinding)data;
- File file = fileDataBinding.getPayload().getBaseFile(false);
- InputStream is = fileDataBinding.getPayload().getDataStream();
- System.out.println("We got a Generic File! "+file.getAbsolutePath());
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(is, writer, "UTF-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
- String theString = writer.toString();
- System.out.println("Content! "+theString);
- }
-
- GenericFileDataBinding binder=null;
- try {
-// binder = new GenericFileDataBinding(new GenericFileData(new File("c:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"), GenericFileDataConstants.MIME_TYPE_IMAGE_JPEG));
- File of = new File("C:\\Users\\GP\\Desktop\\WorkFolder\\WPS\\WPS.txt");
- System.out.println("File Exists: "+of.exists());
- /*
- if (fileDataBinding!=null)
- binder= fileDataBinding;
- else
- */
- {
- binder = new GenericFileDataBinding(new GenericFileData(of, GenericFileDataConstants.MIME_TYPE_PLAIN_TEXT));
- System.out.println("File mime: "+binder.getPayload().getMimeType());
- System.out.println("File extension: "+binder.getPayload().getFileExtension());
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
-// FileDataBinding binder = new FileDataBinding(new File("c:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"));
-
- HashMap result = new HashMap();
- result.put("polygons", new org.n52.wps.io.data.binding.literal.LiteralStringBinding("hello world"));
- result.put("file", binder);
- return result;
- }
-
- @Override
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("CHECK");
- list.add("FFF");
- return list;
-
- }
-
- @Override
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("polygons");list.add("file");
- return list;
- }
-
-}
diff --git a/src/main/java/org/n52/wps/demo/DummyTestClass.java b/src/main/java/org/n52/wps/demo/DummyTestClass.java
deleted file mode 100644
index f9d2f65..0000000
--- a/src/main/java/org/n52/wps/demo/DummyTestClass.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- *
- * Copyright (C) 2007 - 2014 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.
- *
- * 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:
- *
- * • 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.
- */
-package org.n52.wps.demo;
-
-import java.io.File;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.bbox.BoundingBoxData;
-import org.n52.wps.io.data.binding.complex.FileDataBinding;
-import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-
-public class DummyTestClass extends AbstractSelfDescribingAlgorithm {
- private final String inputID1 = "ComplexInputData";
- private final String inputID2 = "LiteralInputData";
- private final String inputID3 = "BBOXInputData";
- private final String outputID1 = "ComplexOutputData";
- private final String outputID2 = "LiteralOutputData";
- private final String outputID3 = "BBOXOutputData";
-
- private List errors = new ArrayList();
-
- public List getErrors() {
- return errors;
- }
-
- public Class> getInputDataType(String id) {
- if (id.equalsIgnoreCase(inputID1)) {
- return GenericFileDataBinding.class;
- }
- if (id.equalsIgnoreCase(inputID2)) {
- return LiteralStringBinding.class;
- }
- if (id.equalsIgnoreCase(inputID3)) {
- return BoundingBoxData.class;
- }
- return null;
-
- }
-
- @Override
- public BigInteger getMinOccurs(String identifier){
- return new BigInteger("0");
- }
-
-
- public Class> getOutputDataType(String id) {
- if (id.equalsIgnoreCase(outputID1)) {
- return GenericFileDataBinding.class;
- }
- if (id.equalsIgnoreCase(outputID2)) {
- return LiteralStringBinding.class;
- }
- if (id.equalsIgnoreCase(outputID3)) {
- return BoundingBoxData.class;
- }
- return null;
- }
-
- @Override
- public List getInputIdentifiers() {
- List identifierList = new ArrayList();
- identifierList.add(inputID1);
- identifierList.add(inputID2);
- identifierList.add(inputID3);
- return identifierList;
- }
-
- @Override
- public List getOutputIdentifiers() {
- List identifierList = new ArrayList();
- identifierList.add(outputID1);
- identifierList.add(outputID2);
- identifierList.add(outputID3);
- return identifierList;
- }
-
-
- @Override
- public Map run(Map> inputData) {
- HashMap result = new HashMap();
- if(inputData.containsKey(inputID1)){
-
- IData data = inputData.get(inputID1).get(0);
-
- if(data instanceof FileDataBinding){
- FileDataBinding fileDataBinding = (FileDataBinding)data;
- File file = fileDataBinding.getPayload();
- result.put(outputID1, new FileDataBinding(file));
- }else{
- result.put(outputID1, data);
- }
- }
- if(inputData.containsKey(inputID2)){
- result.put(outputID2, inputData.get(inputID2).get(0));
- }
- if(inputData.containsKey(inputID3)){
- result.put(outputID3, inputData.get(inputID3).get(0));
- }
-
- return result;
- }
-
- @Override
- public String[] getSupportedCRSForBBOXInput(String identifier){
- String[] supportedCRS = new String[2];
- supportedCRS[0] = "EPSG:4328";
- supportedCRS[1] = "EPSG:5628";
-
- return supportedCRS;
- }
-
- @Override
- public String[] getSupportedCRSForBBOXOutput(String identifier){
- String[] supportedCRS = new String[2];
- supportedCRS[0] = "EPSG:4328";
- supportedCRS[1] = "EPSG:5628";
-
- return supportedCRS;
- }
-
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/n52/wps/demo/GPDemoFile.java b/src/main/java/org/n52/wps/demo/GPDemoFile.java
deleted file mode 100644
index a927166..0000000
--- a/src/main/java/org/n52/wps/demo/GPDemoFile.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.n52.wps.demo;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-
-import org.apache.commons.io.IOUtils;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.bindings.CsvFileDataBinding;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.bindings.D4ScienceFileDataBinding;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.bindings.GisLinkDataBinding;
-import org.n52.wps.algorithm.annotation.*;
-import org.n52.wps.io.data.*;
-import org.n52.wps.io.data.binding.complex.*;
-import org.n52.wps.io.data.binding.literal.*;
-import org.n52.wps.server.*;
-
-//org.n52.wps.demo.GPDemoFile
-@Algorithm(statusSupported=false, title="title of the A.", abstrakt="hello worlds", identifier="org.n52.wps.demo.GPDemoFile", version = "1.1.0")
-public class GPDemoFile extends AbstractAnnotatedAlgorithm {
-
- private String data;
- private GenericFileData file;
- private GenericFileData gis;
- private GenericFileData outfile;
- private String lout;
- private GenericFileData link;
-
- @LiteralDataInput(allowedValues= {"c","a"},defaultValue="1", identifier = "CHECK", binding = LiteralStringBinding.class)
- public void setLData(String data) {
- this.data = data;
- }
-
- @ComplexDataInput(abstrakt="", title="", maxOccurs=1, minOccurs=1, identifier = "FFF", binding = D4ScienceFileDataBinding.class)
- public void setCDataType(GenericFileData file) {
- this.file=file;
- }
-
- @ComplexDataInput(identifier = "GIS", binding = GisLinkDataBinding.class)
- public void setGisDataType(GenericFileData file) {
- this.gis=file;
- }
-
- @ComplexDataOutput(identifier = "file", binding = D4ScienceFileDataBinding.class)
- public GenericFileData getFile() {
- return outfile;
- }
-
- @LiteralDataOutput(identifier = "lout", binding = LiteralStringBinding.class)
- public String getLiteral() {
- return lout;
- }
-
-
- @ComplexDataOutput(identifier = "link", binding = GisLinkDataBinding.class)
- public GenericFileData getGisLink() {
- return link;
- }
-
- @Execute
- public void run() {
-
- if(file!=null){
- File f = file.getBaseFile(false);
- InputStream is = file.getDataStream();
- System.out.println("We got a Generic File! "+f.getAbsolutePath());
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(is, writer, "UTF-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
- String theString = writer.toString();
- System.out.println("Content: "+theString);
- lout = "OK";
- }
-
- if(gis!=null){
- File f = gis.getBaseFile(false);
- InputStream is = file.getDataStream();
- System.out.println("We got a GIS Link! "+f.getAbsolutePath());
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(is, writer, "UTF-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
- String theString = writer.toString();
- System.out.println("Gis Content: "+theString);
-
- }
-
-// PngFileDataBinding binder=null;
- try {
-// binder = new GenericFileDataBinding(new GenericFileData(new File("c:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"), GenericFileDataConstants.MIME_TYPE_IMAGE_JPEG));
- File of = new File("C:\\Users\\GP\\Desktop\\WorkFolder\\WPS\\WPS.txt");
- System.out.println("File Exists: "+of.exists());
- /*
- if (fileDataBinding!=null)
- binder= fileDataBinding;
- else
- */
- {
-// binder = new PngFileDataBinding(new GenericFileData(of, "image/png"));
-// System.out.println("File mime: "+binder.getPayload().getMimeType());
-// System.out.println("File extension: "+binder.getPayload().getFileExtension());
- outfile=new GenericFileData(of, "image/png");
- System.out.println("Generating GIS Link binding");
- //outfile=new GenericFileData(of, GenericFileDataConstants.MIME_TYPE_PLAIN_TEXT);
- link=new GenericFileData(of, "text/wfs");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
-
- }
-
-}
diff --git a/src/main/java/org/n52/wps/demo/GPDemoSimple.java b/src/main/java/org/n52/wps/demo/GPDemoSimple.java
deleted file mode 100644
index 41b311c..0000000
--- a/src/main/java/org/n52/wps/demo/GPDemoSimple.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.n52.wps.demo;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.bbox.BoundingBoxData;
-import org.n52.wps.io.data.binding.complex.FileDataBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-
-//org.n52.wps.demo.GPDemo
-
-public class GPDemoSimple extends AbstractSelfDescribingAlgorithm {
-
- @Override
- public Class> getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("CHECK")) {
- return org.n52.wps.io.data.binding.literal.LiteralStringBinding.class;
- }
- return null;
- }
-
- @Override
- public Class> getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("polygons")) {
- return org.n52.wps.io.data.binding.literal.LiteralStringBinding.class;
- }
- return null;
- }
-
- @Override
- public Map run(Map> inputData)
- throws ExceptionReport {
- if (inputData == null || !inputData.containsKey("CHECK")) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List dataList = inputData.get("CHECK");
- if (dataList == null || dataList.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
-
-// FileDataBinding binder = new FileDataBinding(new File("C:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"));
-
- HashMap result = new HashMap();
- result.put("polygons", new org.n52.wps.io.data.binding.literal.LiteralStringBinding("hello world"));
- return result;
- }
-
- @Override
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("CHECK");
- return list;
-
- }
-
- @Override
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("polygons");
- return list;
- }
-
-}
diff --git a/src/main/java/org/n52/wps/demo/GPDemoXML.java b/src/main/java/org/n52/wps/demo/GPDemoXML.java
deleted file mode 100644
index 45b4377..0000000
--- a/src/main/java/org/n52/wps/demo/GPDemoXML.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.n52.wps.demo;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.UUID;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.xmlbeans.XmlObject;
-import org.n52.wps.algorithm.annotation.Algorithm;
-import org.n52.wps.algorithm.annotation.ComplexDataInput;
-import org.n52.wps.algorithm.annotation.ComplexDataOutput;
-import org.n52.wps.algorithm.annotation.Execute;
-import org.n52.wps.algorithm.annotation.LiteralDataInput;
-import org.n52.wps.algorithm.annotation.LiteralDataOutput;
-import org.n52.wps.io.data.GenericFileData;
-import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
-import org.n52.wps.io.data.binding.complex.GenericXMLDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractAnnotatedAlgorithm;
-
-//org.n52.wps.demo.GPDemoFile
-@Algorithm(statusSupported=false, title="title of the A.", abstrakt="hello worlds", identifier="org.n52.wps.demo.GPDemoFile", version = "1.1.0")
-public class GPDemoXML extends AbstractAnnotatedAlgorithm {
-
- private String data;
- private GenericFileData file;
- private XmlObject outfile;
- private String lout;
-
- @LiteralDataInput(identifier = "CHECK", binding = LiteralStringBinding.class)
- public void setLData(String data) {
- this.data = data;
- }
-
- @ComplexDataInput(identifier = "FFF", binding = GenericFileDataBinding.class)
- public void setCDataType(GenericFileData file) {
- this.file=file;
- }
-
- @ComplexDataOutput(identifier = "file", binding = GenericXMLDataBinding.class)
- public XmlObject getFile() {
- return outfile;
- }
-
- @LiteralDataOutput(identifier = "lout", binding = LiteralStringBinding.class)
- public String getLiteral() {
- return lout;
- }
-
- @Execute
- public void run() {
-
- if(file!=null){
- File f = file.getBaseFile(false);
- InputStream is = file.getDataStream();
- System.out.println("We got a Generic File! "+f.getAbsolutePath());
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(is, writer, "UTF-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
- String theString = writer.toString();
- System.out.println("Content: "+theString);
- lout = "OK";
- }
-
-// PngFileDataBinding binder=null;
-
-// binder = new GenericFileDataBinding(new GenericFileData(new File("c:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"), GenericFileDataConstants.MIME_TYPE_IMAGE_JPEG));
- File of = new File("C:\\Users\\GP\\Desktop\\WorkFolder\\WPS\\WPS.txt");
- System.out.println("File Exists: "+of.exists());
- /*
- if (fileDataBinding!=null)
- binder= fileDataBinding;
- else
- */
- {
-// binder = new PngFileDataBinding(new GenericFileData(of, "image/png"));
-// System.out.println("File mime: "+binder.getPayload().getMimeType());
-// System.out.println("File extension: "+binder.getPayload().getFileExtension());
-// outfile=new GenericFileData(of, "image/png");
- //String inputXMLString = "testStringValue";
- String out1Name= "generatedimage";
- String out1Payload= "generated image";
- String collectionname = "This is a test image"+" (code:"+UUID.randomUUID()+")";
- String inputXMLString = "\n" +
- " \n" +
- " "+out1Payload+"\n"+
- " \n" +
- "\n";
-
- System.out.println("XML Produced : \n"+inputXMLString);
-
- XmlObject xmlData = XmlObject.Factory.newInstance();
- ByteArrayInputStream xstream = new ByteArrayInputStream(inputXMLString.getBytes());
-
- try {
- xmlData = XmlObject.Factory.parse(xstream);
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Error in parsing xml: "+e.getLocalizedMessage());
- }
- outfile = xmlData;
-
- //outfile=new GenericFileData(of, GenericFileDataConstants.MIME_TYPE_PLAIN_TEXT);
- }
-
-
- }
-
-}
diff --git a/src/main/java/org/n52/wps/demo/TestIO.java b/src/main/java/org/n52/wps/demo/TestIO.java
deleted file mode 100644
index 303501f..0000000
--- a/src/main/java/org/n52/wps/demo/TestIO.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.n52.wps.demo;
-
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.UUID;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.xmlbeans.XmlObject;
-import org.gcube.contentmanagement.lexicalmatcher.utils.FileTools;
-import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.bindings.CsvFileDataBinding;
-import org.n52.wps.algorithm.annotation.Algorithm;
-import org.n52.wps.algorithm.annotation.ComplexDataInput;
-import org.n52.wps.algorithm.annotation.ComplexDataOutput;
-import org.n52.wps.algorithm.annotation.Execute;
-import org.n52.wps.algorithm.annotation.LiteralDataInput;
-import org.n52.wps.algorithm.annotation.LiteralDataOutput;
-import org.n52.wps.io.data.GenericFileData;
-import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
-import org.n52.wps.io.data.binding.complex.GenericXMLDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractAnnotatedAlgorithm;
-
-//org.n52.wps.demo.GPDemoFile
-@Algorithm(statusSupported=false, title="title of the A.", abstrakt="hello worlds", identifier="org.n52.wps.demo.GPDemoFile", version = "1.1.0")
-public class TestIO extends AbstractAnnotatedAlgorithm {
-
- private String data;
- private GenericFileData file;
- private XmlObject outfile;
- private GenericFileData outfile2;
- private String lout;
-
- @LiteralDataInput(identifier = "CHECK", binding = LiteralStringBinding.class)
- public void setLData(String data) {
- this.data = data;
- }
-
- @ComplexDataInput(identifier = "FFF", binding = GenericFileDataBinding.class)
- public void setCDataType(GenericFileData file) {
- this.file=file;
- }
-
- @ComplexDataOutput(identifier = "file", binding = GenericXMLDataBinding.class)
- public XmlObject getFile() {
- return outfile;
- }
-
- @LiteralDataOutput(identifier = "lout", binding = LiteralStringBinding.class)
- public String getLiteral() {
- return lout;
- }
-
- @Execute
- public void run() {
-
- if(file!=null){
- File f = file.getBaseFile(false);
-
- System.out.println("We got a Generic File! "+f.getAbsolutePath());
- try{
- String fileLink = FileTools.loadString(f.getAbsolutePath(), "UTF-8");
- URL url = new URL(fileLink);
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- InputStream is = new BufferedInputStream(urlConnection.getInputStream());
-
-// InputStream is = new FileInputStream(new File(fileLink));
- StringWriter writer = new StringWriter();
- IOUtils.copy(is, writer, "UTF-8");
- String theString = writer.toString();
- System.out.println("Input Content: "+theString);
- is.close();
- urlConnection.disconnect();
- }catch(Exception e){
- e.printStackTrace();
- }
-
- lout = "OK";
- }
-
-// PngFileDataBinding binder=null;
-
-// binder = new GenericFileDataBinding(new GenericFileData(new File("c:\\Users\\GP\\Desktop\\CoelacanthVelin.jpg"), GenericFileDataConstants.MIME_TYPE_IMAGE_JPEG));
- File of = new File("C:\\Users\\GP\\Desktop\\WorkFolder\\WPS\\WPS.txt");
- System.out.println("File Exists: "+of.exists());
- /*
- if (fileDataBinding!=null)
- binder= fileDataBinding;
- else
- */
- {
-// binder = new PngFileDataBinding(new GenericFileData(of, "image/png"));
-// System.out.println("File mime: "+binder.getPayload().getMimeType());
-// System.out.println("File extension: "+binder.getPayload().getFileExtension());
-// outfile=new GenericFileData(of, "image/png");
- //String inputXMLString = "testStringValue";
- String out1Name= "generatedimage";
- String out1Payload= "generated image";
- String collectionname = "This is a test image"+" (code:"+UUID.randomUUID()+")";
- String inputXMLString = "\n" +
- " \n" +
- " "+out1Payload+"\n"+
- " \n" +
- "\n";
-
- System.out.println("XML Produced : \n"+inputXMLString);
-
- XmlObject xmlData = XmlObject.Factory.newInstance();
- ByteArrayInputStream xstream = new ByteArrayInputStream(inputXMLString.getBytes());
-
- try {
- xmlData = XmlObject.Factory.parse(xstream);
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Error in parsing xml: "+e.getLocalizedMessage());
- }
- outfile = xmlData;
-
- //outfile=new GenericFileData(of, GenericFileDataConstants.MIME_TYPE_PLAIN_TEXT);
- }
-
-
- }
-
-}