use of org.geotoolkit.wps.xml.v200.ProcessOfferings in project geotoolkit by Geomatys.
the class WPS2ProcessDescriptor method create.
public static ProcessDescriptor create(WPSProcessingRegistry registry, final String processIdentifier) throws Exception {
final ProcessOfferings offerings = registry.getClient().getDescribeProcess(Collections.singletonList(processIdentifier));
final List<ProcessOffering> offeringList = offerings.getProcessOffering();
if (offeringList == null || offeringList.isEmpty()) {
throw new RuntimeException("No process description has been found for identifier " + processIdentifier);
} else if (offeringList.size() != 1) {
throw new RuntimeException(String.format("We asked for exactly one process descriptor (%s), but we've got %d results.", processIdentifier, offeringList.size()));
}
final ProcessOffering offering = offeringList.get(0);
return create(registry, offering);
}
use of org.geotoolkit.wps.xml.v200.ProcessOfferings in project geotoolkit by Geomatys.
the class WPSProcessingRegistry method checkDescriptor.
/**
* Look for a process in the distant WPS server.
* If the process is present in the Capabilities document,
* a new descriptor will be added to the list.
*
* @param name Identifier of the process we search.
*/
private ProcessDescriptor checkDescriptor(String name) throws Exception {
ProcessOfferings processBrief = client.getDescribeProcess(Collections.singletonList(name));
if (processBrief == null || processBrief.getProcessOffering().isEmpty()) {
return null;
}
final ProcessDescriptor processDesc = toProcessDescriptor(name);
descriptors.put(processDesc.getIdentifier().getCode(), processDesc);
return processDesc;
}
use of org.geotoolkit.wps.xml.v200.ProcessOfferings 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;
}
Aggregations