Skip to content

Commit

Permalink
[GEOS-11390] Replace TestWfsPost with Javascript Demo Page (#7672)
Browse files Browse the repository at this point in the history
* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
  • Loading branch information
davidblasby authored and jodygarnett committed May 31, 2024
1 parent a32031a commit ca42f73
Show file tree
Hide file tree
Showing 44 changed files with 847 additions and 1,093 deletions.
2 changes: 1 addition & 1 deletion data/release/demo/WCS_getCoverage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
</rangeSubset>
<output>
<crs>EPSG:32633</crs>
<format>GeoTIFF</format>
<format>image/png</format>
</output>
</GetCoverage>
Binary file modified doc/en/user/source/configuration/demos/img/demos_requests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions doc/en/user/source/configuration/demos/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,37 @@ Both :ref:`wfs` as well as :ref:`wcs` requests will display the request URL and

.. figure:: img/demos_requests_WFS.png

WFS 1.1 DescribeFeatureType sample request
WFS 1.1 DescribeFeatureType sample request (Demo Request :guilabel:`WFS_describeFeatureType-1.1.xml`)

Click :guilabel:`Submit` to send the request to GeoServer. For WFS and WCS requests, GeoServer will automatically generate an XML response.
Click :guilabel:`Show Result` or :guilabel:`Show Result in New Page` to send the request to GeoServer. For WFS and WCS requests, GeoServer will automatically generate an XML response.

:guilabel:`Show Result` will show GeoServer's response - both the response headers and the XML/image result - below the :guilabel:`Show Result` button.
If GeoServer's response is XML and you have ticked :guilabel:`Pretty Print XML`, GeoServer's response will be shown with an easy to read styled formatting.

:guilabel:`Show Result in New Page` will show GeoServer's result in a new page (your browser will render the result).

.. figure:: img/demos_requests_schema.png

XML response from a WFS 1.1 DescribeFeatureType sample request
Headers and XML response from a WFS 1.1 DescribeFeatureType sample request after pressing :guilabel:`Show Result`. (Demo Request :guilabel:`WFS_describeFeatureType-1.1.xml`)

Submitting a WMS GetMap request displays an image based on the provided geographic data.

.. figure:: img/demos_requests_WMS_map.png

OpenLayers WMS GetMap request
Headers and image response for a WMS GetMap request after pressing :guilabel:`Show Result`. (Demo Request :guilabel:`WMS_getMap_multilayer.url`)

WMS GetFeatureInfo requests retrieve information regarding a particular feature on the map image.
WMS GetFeatureInfo requests retrieve information regarding a particular feature on the map image.

.. figure:: img/demos_requests_WMS_feature.png

WMS GetFeatureInfo request
Plain text WMS GetFeatureInfo request after pressing :guilabel:`Show Result`. (Demo Request :guilabel:`WMS_featureInfo.url`)

.. figure:: img/demos_requests_transaction.png

WFS Transaction result after pressing :guilabel:`Show Result in New Page` (Your browser may render this differently). (Demo Request :guilabel:`WFS_transactionInsert.xml`)




.. _srs_list:

Expand Down
Binary file modified doc/en/user/source/services/wcs/img/wcsrequestbuilder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/en/user/source/services/wcs/img/wcsrequestbuilder_100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/en/user/source/services/wcs/img/wcsrequestbuilder_111.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/en/user/source/services/wcs/img/wcsrequestbuilder_xml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions doc/en/user/source/services/wcs/requestbuilder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ Once selected, the remainder of the form will be displayed. The following option

There is also a link for :guilabel:`Describe coverage` next to the :guilabel:`Coverage name` which will execute a :ref:`WCS DescribeCoverage <wcs_describecoverage>` request for the particular layer.

At the bottom of the form are two buttons for form submission:
At the bottom of the form are three buttons for form submission:

* :guilabel:`Get Coverage`—Executes a GetCoverage request using the parameters in the form. This will usually result in a file which can be downloaded.
* :guilabel:`Get Coverage in Demo Requests`—Opens the :ref:`demos_demorequests` page with the URL and XML Request filled out.

* :guilabel:`Generate GetCoverage XML`—Generates the GetCoverage request using the parameters in the form and then, instead of executing it, outputs the request itself to the screen.
* :guilabel:`Get Coverage in New Page`—Executes a GetCoverage request using the parameters in the form. This will usually result in a file which can be displayed or downloaded.

* :guilabel:`Generate GetCoverage XML`—Generates the GetCoverage XML request using the parameters in the form and then, instead of executing it, outputs the request itself to the screen.

.. figure:: img/wcsrequestbuilder_demo.png

Get Coverage request in Demo Requests

.. figure:: img/wcsrequestbuilder_xml.png

WCS request builder showing GetCoverage XML

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/en/user/source/services/wps/images/requestbuilderblank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/en/user/source/services/wps/images/requestbuilderrequest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 68 additions & 1 deletion doc/en/user/source/services/wps/requestbuilder.rst
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
.. _wps_request_builder:WPS Request Builder===================The GeoServer WPS extension includes a request builder for testing out WPS processes through the :ref:`web_admin`. This tool can also be used to demonstrate processes, and construct your own examples.Accessing the request builder---------------------------------To access the WPS Request Builder:#. Navigate to the main :ref:`web_admin`.#. Click on the :guilabel:`Demos` link on the left side.#. Select :guilabel:`WPS Request Builder` from the list of demos... figure:: images/demospage.png :align: center *WPS request builder in the list of demos*Using the request builder-------------------------The WPS Request Builder primarily consists of a selection box listing all of the available processes, and two buttons, one to submit the WPS request, and another to display what the POST request looks like... figure:: images/requestbuilderblank.png :align: center *Blank WPS request builder form*The display changes depending on the process and input selected. JTS processes have available as inputs any of a GML/WKT-based feature collection, URL reference, or subprocess. GeoServer-specific processes have all these as options and also includes the ability to choose a GeoServer layer as input.For each process, a form will display based on the required and optional parameters associated with that process, if any... figure:: images/requestbuildertoppstates.png :align: center *WPS request builder form to determine the bounds of topp:states*To see the process as a POST request, click the :guilabel:`Generate XML from process inputs/outputs` button... figure:: images/requestbuilderrequest.png :align: center *Raw WPS POST request for the above process*To execute the process, click the :guilabel:`Execute Process` button. The response will be displayed in a window or.. figure:: images/requestbuilderresponse.png :align: center *WPS server response*
.. _wps_request_builder:

WPS Request Builder
===================

The GeoServer WPS extension includes a request builder for testing out WPS processes through the :ref:`web_admin`. This tool can also be used to demonstrate processes, and construct your own examples.

Accessing the request builder
---------------------------------

To access the WPS Request Builder:

#. Navigate to the main :ref:`web_admin`.

#. Click on the :guilabel:`Demos` link on the left side.


#. Select :guilabel:`WPS Request Builder` from the list of demos.

.. figure:: images/demospage.png
:align: center

*WPS request builder in the list of demos*

Using the request builder
-------------------------

The WPS Request Builder primarily consists of a selection box listing all of the available processes, and two buttons, one to submit the WPS request, and another to display what the POST request looks like.

.. figure:: images/requestbuilderblank.png
:align: center

*Blank WPS request builder form*

The display changes depending on the process and input selected. JTS processes have available as inputs any of a GML/WKT-based feature collection, URL reference, or subprocess. GeoServer-specific processes have all these as options and also includes the ability to choose a GeoServer layer as input.

For each process, a form will display based on the required and optional parameters associated with that process, if any.

.. figure:: images/requestbuildertoppstates.png
:align: center

*WPS request builder form to determine the bounds of topp:states*

To see the process as a POST request, click the :guilabel:`Generate XML from process inputs/outputs` button.

.. figure:: images/requestbuilderrequest.png
:align: center

*Raw WPS POST request for the above process*

To execute the process, click the :guilabel:`Execute Process in New Page` button. The response will be displayed in the window.

.. figure:: images/requestbuilderresponse.png
:align: center

*WPS server response (Browsers may render differently)*

To see and execute the request in :ref:`demos_demorequests`, click the :guilabel:`Execute Process in Demo Requests` button.


.. figure:: images/requestbuilder_demo.png
:align: center

*Request and Response shown in Demo Requests*




Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<body>
<wicket:extend>
<form wicket:id="form">
<div wicket:id="requestBuilder"></div>
<input type="text" wicket:id="xml" id="xml" name="xml" style="display: none"></input>

<div wicket:id="requestBuilder"></div>
<ul>
<li class="button-group selfclear">
<button wicket:id="execute" type="submit"><wicket:message key="execute">execute</wicket:message></button>
<button wicket:id="executeXML" type="submit"><wicket:message key="showXML">show xml</wicket:message></button>
<button wicket:id="execute" type="submit"><wicket:message key="requestBuilder">requestBuilder</wicket:message></button>
<button wicket:id="setXml" type="submit"><wicket:message key="execute">execute</wicket:message></button>
<button wicket:id="executeXML" type="submit"><wicket:message key="showXML">show xml</wicket:message></button>
</li>
</ul>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
package org.geoserver.wps.web;

import java.io.ByteArrayOutputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest;
import javax.xml.transform.TransformerException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptContentHeaderItem;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.geoserver.ows.URLMangler.URLType;
import org.geoserver.ows.util.ResponseUtils;
import org.geoserver.web.GeoServerApplication;
import org.geoserver.web.GeoServerBasePage;
import org.geoserver.web.demo.DemoRequest;
import org.geoserver.web.demo.DemoRequestResponse;
import org.geoserver.web.demo.DemoRequestsPage;
import org.geoserver.web.demo.PlainCodePage;

/**
Expand All @@ -44,6 +51,8 @@ public class WPSRequestBuilder extends GeoServerBasePage {
ModalWindow responseWindow;
WPSRequestBuilderPanel builder;

TextField<String> xml;

public WPSRequestBuilder(PageParameters parameters) {
this(parameters.get(PARAM_NAME).toOptionalString());
}
Expand All @@ -57,6 +66,13 @@ public WPSRequestBuilder(String procName) {
Form form = new Form("form");
add(form);

var model = new Model<>(new WPSRequestModel());
form.setDefaultModel(model);

xml = new TextField<>("xml", new PropertyModel<>(model, "xml"));
xml.setOutputMarkupId(true);
form.add(xml);

// the actual request builder component
ExecuteRequest execRequest = new ExecuteRequest();
if (procName != null) execRequest.processName = procName;
Expand Down Expand Up @@ -97,14 +113,49 @@ public WPSRequestBuilder(String procName) {
return new DemoRequestResponse(new Model<>(request));
});

form.add(
new AjaxSubmitLink("setXml") {

@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
try {
var xmlText = getRequestXML();
xml.setModelObject(xmlText);
target.add(xml);
} catch (Exception e) {
error(e.getMessage());
addFeedbackPanels(target);
}
target.appendJavaScript("executeWPS()");
}

@Override
protected void onError(AjaxRequestTarget target, Form form) {
addFeedbackPanels(target);
}
});

form.add(
new AjaxSubmitLink("execute") {

@SuppressWarnings("unchecked")
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
responseWindow.setDefaultModel(new Model(getRequestXML()));
responseWindow.show(target);
HttpServletRequest http = GeoServerApplication.get().servletRequest();

String url =
ResponseUtils.buildURL(
ResponseUtils.baseURL(http),
"ows",
Collections.singletonMap("strict", "true"),
URLType.SERVICE);
var xml = getRequestXML();

PageParameters parameters = new PageParameters();
parameters.add("url", url);
parameters.add("xml", xml);

getRequestCycle().setResponsePage(DemoRequestsPage.class, parameters);
}

@Override
Expand Down Expand Up @@ -150,4 +201,23 @@ String getRequestXML() {
}
return out.toString();
}

@Override
public void renderHead(IHeaderResponse response) {
response.render(
JavaScriptContentHeaderItem.forScript(
DemoRequestsPage.demoRequestsJavascript, null));
}

public class WPSRequestModel implements Serializable {
public String xml;

public String getXml() {
return xml;
}

public void setXml(String xml) {
this.xml = xml;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@
<legend><span><wicket:message key="authentication">authentication</wicket:message></span></legend>
<ul>
<li class="choiceItem">
<input type="checkbox" wicket:id="authenticate"/>
<input type="checkbox" wicket:id="authenticate" id="authenticate"/>
<label for="authenticate"><wicket:message key="authenticate">authenticate</wicket:message></label>
</li>
<li wicket:id="userpwdContainer">
<ul>
<li>
<label><wicket:message key="username">username</wicket:message></label>
<input type="text" size="30" name="username" wicket:id="username" class="text"/>
<input type="text" size="30" name="username" wicket:id="username" id="WPSusername" class="text"/>
</li>
<li>
<label><wicket:message key="password">password</wicket:message></label>
<input type="password" size="30" name="password" wicket:id="password" class="text"/>
<input type="password" size="30" name="password" wicket:id="password" id="WPSpassword" class="text"/>
</li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,12 @@ protected void populateItem(ListItem item) {
protected void onClick(AjaxRequestTarget target, Form form) {
processChoice.processInput();
if (execute.processName != null) {
responseWindow.setDefaultModel(
new Model<>(getDescribeXML(execute.processName)));
responseWindow.show(target);

var xmlText = getDescribeXML(execute.processName);
var xml = (TextField) form.get("xml");
xml.setModelObject(xmlText);
target.add(xml);
target.appendJavaScript("executeWPS()");
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ ProcessSelectionPage.edit=Edit...
WPSRequestBuilder.title=WPS request builder
WPSRequestBuilder.description=Step by step WPS request builder.
WPSRequestBuilder.shortDescription=Step by step WPS request builder
WPSRequestBuilder.execute=Execute process
WPSRequestBuilder.execute=Execute process in New Page
WPSRequestBuilder.requestBuilder=Execute in Demo Requests
WPSRequestBuilder.showXML=Generate XML from process inputs/outputs

WPSRequestBuilderPanel.describe=WPS DescribeProcess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
Expand All @@ -22,6 +23,8 @@
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.tester.FormTester;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.web.demo.DemoRequest;
import org.geoserver.web.demo.DemoRequestsPage;
import org.geoserver.wps.ProcessGroupInfo;
import org.geoserver.wps.WPSInfo;
import org.geoserver.wps.process.GeoServerProcessors;
Expand Down Expand Up @@ -103,14 +106,27 @@ public void testFirstProcessWorkflow() throws Exception {
"requestBuilder:inputContainer:inputs:0:paramValue:editor:textarea",
"POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))");
form.submit();

tester.clickLink("form:execute", true);

// print(tester.getLastRenderedPage(), true, true);
var model = (DemoRequest) tester.getLastRenderedPage().getDefaultModel().getObject();

assertEquals("http://localhost/context/ows?strict=true", model.getRequestUrl());
assertTrue(model.getRequestBody().contains("wps:Execute"));

assertEquals(DemoRequestsPage.class, tester.getLastRenderedPage().getClass());
assertEquals(2, tester.getLastRenderedPage().getPageParameters().getAllNamed().size());
assertEquals(
"http://localhost/context/ows?strict=true",
tester.getLastRenderedPage().getPageParameters().get("url").toString());
assertTrue(
tester.getComponentFromLastRenderedPage("responseWindow")
.getDefaultModelObjectAsString()
.contains("wps:Execute"));
(tester.getLastRenderedPage()
.getPageParameters()
.get("xml")
.toString()
.contains("wps:Execute")));

// print(tester.getLastRenderedPage(), true, true);

// unfortunately the wicket tester does not allow us to get work with the popup window
// contents,
Expand Down
Loading

0 comments on commit ca42f73

Please sign in to comment.