/** * Gets current request extension (dxf or zip). * * @param operation * @return */ public String getDxfExtension(Operation operation) { GetFeatureRequest request = GetFeatureRequest.adapt(operation .getParameters()[0]); String outputFormat = request.getOutputFormat().toUpperCase(); // DXF if (outputFormat.equals("DXF")) return "dxf"; // DXF-ZIP return "zip"; }
@Override public String getAttachmentFileName(Object value, Operation operation) { GetFeatureRequest request = GetFeatureRequest.adapt(operation.getParameters()[0]); String outputFormat = request.getOutputFormat(); Format format = formats.get(outputFormat); List<Query> queries = request.getQueries(); if (format == null) { throw new WFSException("Unknown output format " + outputFormat); } else { String outputFileName = queries.get(0).getTypeNames().get(0).getLocalPart(); if (!format.isSingleFile() || queries.size() > 1) { return outputFileName + ".zip"; } else { return outputFileName + format.getFileExtension(); } } }
@Override public String getPreferredDisposition(Object value, Operation operation) { GetFeatureRequest request = GetFeatureRequest.adapt(operation.getParameters()[0]); String outputFormat = request.getOutputFormat(); Format format = formats.get(outputFormat); List<Query> queries = request.getQueries(); if (format == null) { throw new WFSException("Unknown output format " + outputFormat); } else if (format.getType() == OutputType.BINARY || queries.size() > 1) { return DISPOSITION_ATTACH; } else { return DISPOSITION_INLINE; } }
protected void write( FeatureCollectionResponse featureCollection, OutputStream output, Operation getFeature) throws IOException, ServiceException { GetFeatureRequest request = GetFeatureRequest.adapt(getFeature.getParameters()[0]); prepare(request.getOutputFormat(), featureCollection, request); encode(output, featureCollection, request); }
/** @see WFSGetFeatureOutputFormat#getMimeType(Object, Operation) */ public String getMimeType(Object value, Operation operation) throws ServiceException { GetFeatureRequest request = GetFeatureRequest.adapt(operation.getParameters()[0]); String outputFormat = request.getOutputFormat(); String mimeType = ""; Format format = formats.get(outputFormat); if (format == null) { throw new WFSException("Unknown output format " + outputFormat); } else if (format.isSingleFile() && request.getQueries().size() <= 1) { if (format.getMimeType() != null) { mimeType = format.getMimeType(); } else { // use a default binary blob mimeType = "application/octet-stream"; } } else { mimeType = "application/zip"; } return mimeType; }
kvp.put("OUTPUTFORMAT", request.getOutputFormat()); kvp.put( "RESULTTYPE",
String outputFormat = request.getOutputFormat();
private TransformInfo locateTransformation(FeatureCollectionResponse collections, Operation operation) throws IOException { GetFeatureRequest req = GetFeatureRequest.adapt(operation.getParameters()[0]); String outputFormat = req.getOutputFormat(); // locate the transformation, and make sure it's the same for all feature types Set<FeatureType> featureTypes = getFeatureTypes(collections); TransformInfo result = null; FeatureType reference = null; for (FeatureType ft : featureTypes) { TransformInfo curr = locateTransform(outputFormat, ft); if (curr == null) { throw new WFSException("Could not find a XSLT transformation generating " + outputFormat + " for feature type " + ft.getName(), "InvalidParameterValue", "typeName"); } else if (result == null) { reference = ft; result = curr; } else if (!result.equals(curr)) { throw new WFSException( "Multiple feature types are mapped to different XLST transformations, cannot proceed: " + result.getXslt() + ", " + curr.getXslt(), "InvalidParameterValue", "typeName"); } } return result; }