Package org.geoserver.wps

Examples of org.geoserver.wps.WPSException


                    } else {
                        builder.addAll(zone.getAttributes());
                        features.add(builder.buildFeature(zone.getID()));
                    }
                } catch (Exception e) {
                    throw new WPSException("Failed to compute statistics on feature " + zone, e);
                }
            }
            // return the first feature in the current buffer
            SimpleFeature f = features.remove(0);
            return f;
View Full Code Here


            @DescribeParameter(name = "first feature collection", description = "First feature collection") SimpleFeatureCollection firstFeatures,
            @DescribeParameter(name = "second feature collection", description = "Second feature collection") SimpleFeatureCollection secondFeatures)
            throws ClassNotFoundException {
        if (!(firstFeatures.features().next().getDefaultGeometry().getClass().equals(secondFeatures
                .features().next().getDefaultGeometry().getClass()))) {
            throw new WPSException("Different default geometries, cannot perform union");
        } else {
            return new UnitedFeatureCollection(firstFeatures, secondFeatures);
        }
    }
View Full Code Here

        String targetSRSCode = null;
        if (srs != null) {
            try {
                Integer code = CRS.lookupEpsgCode(srs, true);
                if (code == null) {
                    throw new WPSException("Could not find a EPSG code for " + srs);
                }
                targetSRSCode = "EPSG:" + code;
            } catch (Exception e) {
                throw new ProcessException("Could not lookup the EPSG code for the provided srs", e);
            }
View Full Code Here

            // try with the typical Oracle mangling
            targetType = ds.getSchema(sourceType.getTypeName().toUpperCase());
        }

        if (targetType == null) {
            throw new WPSException(
                    "The target schema was created, but with a name "
                            + "that we cannot relate to the one we provided the data store. Cannot proceeed further");
        } else {
            // check the layer is not already there
            String newLayerName = storeInfo.getWorkspace().getName() + ":"
View Full Code Here

            } else if (function == AggregationFunction.StdDev) {
                calc = new StandardDeviationVisitor(CommonFactoryFinder.getFilterFactory(null).property(aggAttribute));
            } else if (function == AggregationFunction.Sum) {
                calc = new SumVisitor(attIndex, features.getSchema());
            } else {
                throw new WPSException("Uknown method " + function);
            }
            visitors.add(calc);
        }

        EnumMap<AggregationFunction, Number> results = new EnumMap<AggregationFunction, Number>(AggregationFunction.class);
View Full Code Here

            } else {
                // generic binary output...
                return "application/octet-stream";
            }
        } else {
            throw new WPSException("Trying to get a mime type for a unknown operation, " +
                "we should not have got here in the first place");
        }
    }
View Full Code Here

            } else {
                // we should really never get here, the request should fail before
                return "result.dat";
            }
        } else {
            throw new WPSException("Trying to get a file name for a unknown operation, " +
                    "we should not have got here in the first place");
        }
    }
View Full Code Here

                for (Object object : outputs) {
                    DocumentOutputDefinitionType odt = (DocumentOutputDefinitionType) object;
                    String key = odt.getIdentifier().getValue();
                    Parameter<?> outputParam = resultInfo.get(key);
                    if (outputParam == null) {
                        throw new WPSException("Unknown output " + key + " possible values are: "
                                + resultInfo.keySet());
                    }

                    String mimeType = odt.getMimeType();
                    OutputDataType output = encodeOutput(key, outputParam, mimeType, odt.isAsReference());
View Full Code Here

            mimeType = getOutputMimeType(key);
        }
        ProcessParameterIO ppio = ProcessParameterIO.find(outputParam, context, mimeType);

        if (ppio == null) {
            throw new WPSException("Don't know how to encode output " + key + " in mime type "
                    + mimeType);
        }

        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);

                if (ppio instanceof LiteralPPIO) {
                    LiteralDataType literal = f.createLiteralDataType();
                    data.setLiteralData(literal);

                    literal.setValue(((LiteralPPIO) ppio).encode(o));
                } else if (ppio instanceof BoundingBoxPPIO) {
                    BoundingBoxType bbox = ((BoundingBoxPPIO) ppio).encode(o);
                    data.setBoundingBoxData(bbox);
                } else if (ppio instanceof ComplexPPIO) {
                    ComplexDataType complex = f.createComplexDataType();
                    data.setComplexData(complex);

                    ComplexPPIO cppio = (ComplexPPIO) ppio;
                    complex.setMimeType(cppio.getMimeType());

                    if (cppio instanceof RawDataPPIO) {
                        RawData rawData = (RawData) o;
                        complex.setMimeType(rawData.getMimeType());
                        complex.setEncoding("base64");
                        complex.getData().add(new RawDataEncoderDelegate(rawData));
                    } else if (cppio instanceof XMLPPIO) {
                        // encode directly
                        complex.getData().add(new XMLEncoderDelegate((XMLPPIO) cppio, o));
                    } else if (cppio instanceof CDataPPIO) {
                        complex.getData().add(new CDataEncoderDelegate((CDataPPIO) cppio, o));
                    } else if (cppio instanceof BinaryPPIO) {
                        complex.setEncoding("base64");
                        complex.getData().add(new BinaryEncoderDelegate((BinaryPPIO) cppio, o));
                    } else {
                        throw new WPSException("Don't know how to encode an output whose PPIO is "
                                + cppio);
                    }
                }
            }
        } catch (Exception e) {
            throw new WPSException("Failed to encode the " + key + " output", e);
        }
        return output;
    }
View Full Code Here

        }
    }

    private ServiceException getException(ProcessState phase) {
        if (phase == ProcessState.CANCELLED) {
            return new WPSException("Process was cancelled by the administrator");
        } else {
            return new WPSException("Process failed during execution", exception);
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.wps.WPSException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.