summaryrefslogtreecommitdiffstats
path: root/petascope/src/petascope/wps
diff options
context:
space:
mode:
authorConstantin <jucovschi@gmail.com>2010-06-02 20:09:42 +0200
committerConstantin <jucovschi@gmail.com>2010-06-02 20:09:42 +0200
commit40e12c6af9d05c3413efaf535c35c625b736cbb9 (patch)
tree6a9f6b86b55724e659ca270171496d82362de9cc /petascope/src/petascope/wps
parentfcda34adb1c78d0929778e1324c873552d21ee1d (diff)
downloadrasdaman-upstream-40e12c6af9d05c3413efaf535c35c625b736cbb9.tar.gz
rasdaman-upstream-40e12c6af9d05c3413efaf535c35c625b736cbb9.tar.xz
rasdaman-upstream-40e12c6af9d05c3413efaf535c35c625b736cbb9.zip
preparing for joining with rasdaman open source
Diffstat (limited to 'petascope/src/petascope/wps')
-rw-r--r--petascope/src/petascope/wps/server/WpsServer.java126
-rw-r--r--petascope/src/petascope/wps/templates/DescribeProcess.xml77
-rw-r--r--petascope/src/petascope/wps/templates/GetCapabilities.xml65
3 files changed, 268 insertions, 0 deletions
diff --git a/petascope/src/petascope/wps/server/WpsServer.java b/petascope/src/petascope/wps/server/WpsServer.java
new file mode 100644
index 0000000..ccfb8ca
--- /dev/null
+++ b/petascope/src/petascope/wps/server/WpsServer.java
@@ -0,0 +1,126 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+package petascope.wps.server;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.antlr.runtime.RecognitionException;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import petascope.wcps.server.core.ProcessCoveragesRequest;
+import petascope.wcs.server.exceptions.InputOutputException;
+
+/**
+ *
+ * @author Michael Owonibi
+ */
+public class WpsServer {
+
+ private static Logger LOG = LoggerFactory.getLogger(WpsServer.class);
+ public String request = null;
+
+ public WpsServer(HttpServletResponse httpResponse, HttpServletRequest httpRequest) throws URISyntaxException, IOException, InputOutputException, RecognitionException {
+
+ if ((httpRequest.getParameter("Request") != null) && httpRequest.getParameter("Request").equalsIgnoreCase("GetCapabilities")) {
+ GetCapabilities(httpResponse);
+ }
+
+ if ((((httpRequest.getParameter("version") != null) && httpRequest.getParameter("version").equalsIgnoreCase("1.0.0")) || ((httpRequest.getParameter("Version") != null) && httpRequest.getParameter("Version").equalsIgnoreCase("1.0.0")))) {
+
+ if ((httpRequest.getParameter("Request") != null) && httpRequest.getParameter("Request").equalsIgnoreCase("DescribeProcess") && (httpRequest.getParameter("identifier") != null) && httpRequest.getParameter("identifier").equalsIgnoreCase("ProcessCoverages")) {
+ DescribeProcess(httpResponse);
+ } else if ((httpRequest.getParameter("Request") != null) && httpRequest.getParameter("Request").equalsIgnoreCase("Execute") && (httpRequest.getParameter("identifier") != null) && httpRequest.getParameter("identifier").equalsIgnoreCase("ProcessCoverages")) {
+
+ String wpsRequest = httpRequest.getParameter("DataInputs");
+ wpsRequest = wpsRequest.substring(1, (wpsRequest.length() - 1));
+ int pos = -1;
+ pos = wpsRequest.indexOf("=");
+ if (wpsRequest.substring(0, pos).equalsIgnoreCase("WcpsAbstractSyntax")) {
+ wpsRequest = wpsRequest.substring(pos + 1, wpsRequest.length());
+
+ wpsRequest = ProcessCoveragesRequest.abstractQueryToXmlQuery(wpsRequest);
+ System.out.println("WPS request is :" + wpsRequest);
+ request = wpsRequest;
+ }
+ }
+ }
+ }
+
+ public void GetCapabilities(HttpServletResponse httpResponse) throws URISyntaxException, IOException, InputOutputException {
+ URI GetCapabilitiesURI = this.getClass().getResource("../templates/GetCapabilities.xml").toURI();
+ String GetCapabilitiesResponse = loadFile(GetCapabilitiesURI);
+ LOG.info("Executing operation GetCapabilities...");
+ System.out.println("GetCapabilities Response is " + GetCapabilitiesResponse);
+ PrintWriter out;
+ try {
+ out = httpResponse.getWriter();
+ httpResponse.setContentType("text/xml; charset=utf-8");
+ out.write(GetCapabilitiesResponse);
+ out.flush();
+ out.close();
+ } catch (IOException e) {
+ throw new InputOutputException(e.getMessage(), e);
+ }
+ }
+
+ public void DescribeProcess(HttpServletResponse httpResponse) throws URISyntaxException, IOException, InputOutputException {
+ URI DesribeProcessURI = this.getClass().getResource("../templates/DescribeProcess.xml").toURI();
+ String DescribeProcessResponse = loadFile(DesribeProcessURI);
+ LOG.info("Executing operation DescribeProcess...");
+ System.out.println("DescribeProcess Document is " + DescribeProcessResponse);
+ PrintWriter out;
+ try {
+ out = httpResponse.getWriter();
+ httpResponse.setContentType("text/xml; charset=utf-8");
+ out.write(DescribeProcessResponse);
+ out.flush();
+ out.close();
+ } catch (IOException e) {
+ throw new InputOutputException(e.getMessage(), e);
+ }
+ }
+
+ private String loadFile(URI fileUri) throws IOException {
+ InputStream is = null;
+ String contents = null;
+ try {
+ LOG.debug("Loading file: " + fileUri);
+ File f = new File(fileUri);
+ is = new FileInputStream(f);
+ contents = IOUtils.toString(is);
+ } finally {
+ try {
+ is.close();
+ } catch (IOException ex) {
+ }
+ }
+ return contents;
+ }
+}
diff --git a/petascope/src/petascope/wps/templates/DescribeProcess.xml b/petascope/src/petascope/wps/templates/DescribeProcess.xml
new file mode 100644
index 0000000..ff61fab
--- /dev/null
+++ b/petascope/src/petascope/wps/templates/DescribeProcess.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wps:ProcessDescriptions xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WPS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd">
+ <ProcessDescription wps:processVersion="1"
+ storeSupported="true" statusSupported="false">
+ <ows:Identifier>ProcessCoverages</ows:Identifier>
+ <ows:Title>ProcessCoverages Request</ows:Title>
+ <ows:Abstract> ProcessCoverages is a WPS process that provides a means of specifying server-side extraction and analysis of coverages containing sensor,image, and statistics data
+ </ows:Abstract>
+ <ows:Metadata xlink:title="coverage"/>
+ <ows:Metadata xlink:title="coverage processing"/>
+ <ows:Metadata xlink:title="WCS"/>
+ <wps:Profile>
+ urn:ogc:wps:1.0.0:ProcessCoverages
+ </wps:Profile>
+ <DataInputs>
+ <Input minOccurs="1" maxOccurs="1">
+ <ows:Identifier>
+ AbstractWcpsQuery
+ </ows:Identifier>
+ <ows:Title>
+ WCPS ProcessCoverages Request
+ </ows:Title>
+ <ows:Abstract> WCPS query</ows:Abstract>
+ <LiteralData>
+ <ows:DataType ows:reference=
+ "http://www.w3.org/TR/xmlschema2/#string">
+ string
+ </ows:DataType>
+ <ows:AnyValue/>
+ </LiteralData>
+ </Input>
+ </DataInputs>
+ <ProcessOutputs>
+ <Output>
+ <ows:Identifier>
+ ProcessCoveragesResultList
+ </ows:Identifier>
+ <ows:Title>WCPS Query</ows:Title>
+ <ows:Abstract>WCPS Query</ows:Abstract>
+ <ComplexOutput>
+ <Default>
+ <Format>
+ <MimeType>image/tiff</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ </Default>
+ <Supported>
+ <Format>
+ <MimeType>image/tiff</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ <Format>
+ <MimeType>image/netcdf</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ <Format>
+ <MimeType>image/hdf4.0</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ <Format>
+ <MimeType>image/png</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ <Format>
+ <MimeType>image/nitf</MimeType>
+ <Encoding>base64</Encoding>
+ </Format>
+ <Format>
+ <MimeType>text/plain</MimeType>
+ <Encoding>UTF-8</Encoding>
+ </Format>
+ </Supported>
+ </ComplexOutput>
+ </Output>
+ </ProcessOutputs>
+ </ProcessDescription>
+</wps:ProcessDescriptions>
diff --git a/petascope/src/petascope/wps/templates/GetCapabilities.xml b/petascope/src/petascope/wps/templates/GetCapabilities.xml
new file mode 100644
index 0000000..27a9ac7
--- /dev/null
+++ b/petascope/src/petascope/wps/templates/GetCapabilities.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wps:Capabilities service="WPS" version="1.0.0" xml:lang="en-US" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 ../wpsGetCapabilities_response.xsd" updateSequence="1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <ows:ServiceIdentification>
+ <ows:Title> Coverage Processing in WPS</ows:Title>
+ <ows:Abstract>Coverage Processing using WPS</ows:Abstract>
+ <ows:Keywords>
+ <ows:Keyword>WCPS</ows:Keyword>
+ <ows:Keyword>ProcessCoverages</ows:Keyword>
+ </ows:Keywords>
+ <ows:ServiceType>WPS</ows:ServiceType>
+ <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
+ </ows:ServiceIdentification>
+ <ows:ServiceProvider>
+ <ows:ProviderName>Jacobs University</ows:ProviderName>
+<ows:ProviderSite xlink:href="http://www.jacobs-university.de"/>
+ </ows:ServiceProvider>
+
+ <ows:OperationsMetadata>
+ <ows:Operation name="GetCapabilities">
+ <ows:DCP>
+ <ows:HTTP>
+ <ows:Get xlink:href="http://kahlua.eecs.jacobs-university.de:8080/PetaScope/earthlook"/>
+ </ows:HTTP>
+ </ows:DCP>
+ </ows:Operation>
+ <ows:Operation name="DescribeProcess">
+ <ows:DCP>
+ <ows:HTTP>
+ <ows:Get xlink:href="http://kahlua.eecs.jacobs-university.de:8080/PetaScope/earthlook"/>
+
+ </ows:HTTP>
+ </ows:DCP>
+ </ows:Operation>
+ <ows:Operation name="Execute">
+ <ows:DCP>
+ <ows:HTTP>
+ <ows:Get xlink:href="http://kahlua.eecs.jacobs-university.de:8080/PetaScope/earthlook"/>
+ <ows:Post xlink:href="http://kahlua.eecs.jacobs-university.de:8080/PetaScope/earthlook"/>
+ </ows:HTTP>
+ </ows:DCP>
+ </ows:Operation>
+ </ows:OperationsMetadata>
+
+
+ <wps:ProcessOfferings>
+ <wps:Process wps:processVersion="1.0.0">
+ <ows:Identifier>ProcessCoverages</ows:Identifier>
+ <ows:Title>WCPS Coverage Processing</ows:Title>
+<ows:Abstract>Expression for Server-side Coverage Processing</ows:Abstract>
+ </wps:Process>
+ </wps:ProcessOfferings>
+
+ <wps:Languages>
+ <wps:Default>
+ <ows:Language>en-US</ows:Language>
+ </wps:Default>
+ <wps:Supported>
+ <ows:Language>en-US</ows:Language>
+ </wps:Supported>
+ </wps:Languages>
+
+
+
+</wps:Capabilities>
+