Search in sources :

Example 1 with DescribeProcess

use of org.geotoolkit.wps.xml.v200.DescribeProcess in project geotoolkit by Geomatys.

the class WebProcessingClient method createDescribeProcess.

/**
 * Create a describe process request
 *
 * @return DescribeProcessRequest : describe process request.
 */
public DescribeProcessRequest createDescribeProcess() {
    final WPSVersion version = ensureVersionSet();
    final DescribeProcessRequest request = new DescribeProcessRequest(serverURL.toString(), getClientSecurity(), forceGET, getTimeOutValue());
    DescribeProcess content = new DescribeProcess();
    content.setService("WPS");
    content.setVersion(version.getCode());
    request.setContent(content);
    return request;
}
Also used : DescribeProcess(org.geotoolkit.wps.xml.v200.DescribeProcess)

Example 2 with DescribeProcess

use of org.geotoolkit.wps.xml.v200.DescribeProcess in project geotoolkit by Geomatys.

the class DescribeProcessTest method testRequestAndMarshall.

@Test
public void testRequestAndMarshall() throws Exception {
    final WebProcessingClient client = new WebProcessingClient(new URL("http://test.com"), null, WPSVersion.v100);
    final DescribeProcessRequest request = client.createDescribeProcess();
    final DescribeProcess content = request.getContent();
    content.setIdentifier(Arrays.asList("identifier1", "identifier2", "identifier3"));
    final StringWriter stringWriter = new StringWriter();
    final Marshaller marshaller = WPSMarshallerPool.getInstance().acquireMarshaller();
    marshaller.marshal(content, stringWriter);
    String result = stringWriter.toString();
    final String expectedMarshalledRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<wps:DescribeProcess version=\"1.0.0\" service=\"WPS\"" + " xmlns:wps=\"http://www.opengis.net/wps/1.0.0\"" + " xmlns:ows=\"http://www.opengis.net/ows/1.1\">\n" + "    <ows:Identifier>identifier1</ows:Identifier>\n" + "    <ows:Identifier>identifier2</ows:Identifier>\n" + "    <ows:Identifier>identifier3</ows:Identifier>\n" + "</wps:DescribeProcess>\n";
    assertXmlEquals(expectedMarshalledRequest, result, "xmlns:*");
    WPSMarshallerPool.getInstance().recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) DescribeProcess(org.geotoolkit.wps.xml.v200.DescribeProcess) WebProcessingClient(org.geotoolkit.wps.client.WebProcessingClient) DescribeProcessRequest(org.geotoolkit.wps.client.DescribeProcessRequest) URL(java.net.URL) Test(org.junit.Test)

Example 3 with DescribeProcess

use of org.geotoolkit.wps.xml.v200.DescribeProcess in project geotoolkit by Geomatys.

the class DescribeProcessTest method testDescribeProcess110.

/**
 * Ensures the {@link DescribeProcess#getURL()} method returns a well-built url,
 * with the parameters given.
 */
@Test
public void testDescribeProcess110() throws MalformedURLException {
    final WebProcessingClient client = new WebProcessingClient(new URL("http://test.com"), null, WPSVersion.v100);
    final DescribeProcessRequest request = client.createDescribeProcess();
    final DescribeProcess content = request.getContent();
    content.setIdentifier(Arrays.asList("identifier1", "identifier2", "identifier3"));
    final URL url;
    try {
        url = request.getURL();
    } catch (MalformedURLException ex) {
        fail(ex.getLocalizedMessage());
        return;
    }
    final String strUrl = url.toString();
    // final String expectedURL = "http://test.com?VERSION=1.0.0&SERVICE=WPS&REQUEST=DescribeProcess&IDENTIFIER=identifier1,identifier2,identifier3";
    assertTrue(strUrl.contains("VERSION=1.0.0"));
    assertTrue(strUrl.contains("SERVICE=WPS"));
    assertTrue(strUrl.contains("REQUEST=DescribeProcess"));
    assertTrue(strUrl.contains("IDENTIFIER=identifier1%2Cidentifier2%2Cidentifier3"));
}
Also used : MalformedURLException(java.net.MalformedURLException) DescribeProcess(org.geotoolkit.wps.xml.v200.DescribeProcess) WebProcessingClient(org.geotoolkit.wps.client.WebProcessingClient) DescribeProcessRequest(org.geotoolkit.wps.client.DescribeProcessRequest) URL(java.net.URL) Test(org.junit.Test)

Example 4 with DescribeProcess

use of org.geotoolkit.wps.xml.v200.DescribeProcess in project geo-platform by geosdi.

the class WPSDescribeProcessRequestV100 method createRequest.

/**
 * @return {@link DescribeProcess}
 * @throws Exception
 */
@Override
protected DescribeProcess createRequest() throws Exception {
    checkArgument(this.isSetProcessIdentifiers(), "The Parameter ProcessIdentifiers must not be null or Empty.");
    List<CodeType> processCodeTypes = this.processIdentifiers.stream().filter(value -> ((value != null) && !(value.trim().isEmpty()))).map(PROCESS_IDENTIFIER).collect(toList());
    checkArgument((processCodeTypes != null) && !(processCodeTypes.isEmpty()), "The Parameter ProcessCodeTypes must not be null or an Empty List.");
    DescribeProcess describeProcess = new DescribeProcess();
    describeProcess.setIdentifier(processCodeTypes);
    if (this.isLanguageSet())
        describeProcess.setLanguage(this.language);
    return describeProcess;
}
Also used : CodeType(org.geosdi.geoplatform.xml.ows.v110.CodeType) DescribeProcess(org.geosdi.geoplatform.xml.wps.v100.DescribeProcess)

Example 5 with DescribeProcess

use of org.geotoolkit.wps.xml.v200.DescribeProcess in project geotoolkit by Geomatys.

the class WebProcessingClient method getDescribeProcess.

/**
 * Perform a DescribeProcess request on the specified identifiers.
 *
 * @param processIDs List of process Identifiers
 * @return ProcessDescriptions : WPS process description
 */
public ProcessOfferings getDescribeProcess(final List<String> processIDs) throws Exception {
    ProcessOfferings description;
    // Thread to prevent infinite request on a server
    final DescribeProcessRequest describe = createDescribeProcess();
    describe.setTimeout(getTimeOutValue());
    describe.getContent().setIdentifier(processIDs);
    try (final InputStream request = describe.getResponseStream()) {
        final Unmarshaller unmarshaller = WPSMarshallerPool.getInstance().acquireUnmarshaller();
        Object response = unmarshaller.unmarshal(request);
        WPSMarshallerPool.getInstance().recycle(unmarshaller);
        if (response instanceof ProcessOfferings) {
            description = (ProcessOfferings) response;
        } else if (response instanceof ExceptionResponse) {
            ExceptionResponse report = (ExceptionResponse) response;
            throw report.toException();
        } else {
            throw new Exception("Unexpected response type from the WPS server: " + (response == null ? "null" : response.getClass()));
        }
    }
    return description;
}
Also used : ExceptionResponse(org.geotoolkit.ows.xml.ExceptionResponse) ProcessOfferings(org.geotoolkit.wps.xml.v200.ProcessOfferings) Unmarshaller(javax.xml.bind.Unmarshaller) CapabilitiesException(org.geotoolkit.client.CapabilitiesException)

Aggregations

DescribeProcess (org.geotoolkit.wps.xml.v200.DescribeProcess)4 URL (java.net.URL)2 Marshaller (javax.xml.bind.Marshaller)2 DescribeProcessRequest (org.geotoolkit.wps.client.DescribeProcessRequest)2 WebProcessingClient (org.geotoolkit.wps.client.WebProcessingClient)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 MalformedURLException (java.net.MalformedURLException)1 URLConnection (java.net.URLConnection)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 CodeType (org.geosdi.geoplatform.xml.ows.v110.CodeType)1 DescribeProcess (org.geosdi.geoplatform.xml.wps.v100.DescribeProcess)1 CapabilitiesException (org.geotoolkit.client.CapabilitiesException)1 ExceptionResponse (org.geotoolkit.ows.xml.ExceptionResponse)1 ProcessOfferings (org.geotoolkit.wps.xml.v200.ProcessOfferings)1