}
try {
if (reference && ppio instanceof ComplexPPIO) {
// encode as reference
OutputReferenceType outputReference = f.createOutputReferenceType();
output.setReference(outputReference);
ComplexPPIO cppio = (ComplexPPIO) ppio;
File file = resourceManager.getOutputFile(executionId, key + "." + cppio.getFileExtension());
// write out the file
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
cppio.encode(o, fos);
} finally {
IOUtils.closeQuietly(fos);
}
// create the link
Map<String, String> kvp = new LinkedHashMap<String, String>();
kvp.put("service", "WPS");
kvp.put("version", "1.0.0");
kvp.put("request", "GetExecutionResult");
kvp.put("executionId", executionId);
kvp.put("outputId", file.getName());
if(o instanceof RawData) {
RawData rawData = (RawData) o;
kvp.put("mimetype", rawData.getMimeType());
} else {
kvp.put("mimetype", cppio.getMimeType());
}
outputReference.setHref(ResponseUtils.buildURL(request.getBaseUrl(), "ows", kvp, URLType.SERVICE));
outputReference.setMimeType(cppio.getMimeType());
} else {
// encode as data
DataType data = f.createDataType();
output.setData(data);