public String getMimeType(Object value, Operation operation) throws ServiceException { return delegate.getMimeType(value, operation); }
/** * Get a name for a Content-Disposition attachment filename. The mimetype should match the file * extension. The default implementation will use the mimetype and operation id to attempt to * build a name. * * @param value The value that will be serialized * @param operation The operation being performed * @return null or a filename such as result.txt or map.tiff */ public String getAttachmentFileName(Object value, Operation operation) { String mimeType = getMimeType(value, operation); String opName = operation.getId(); String name = null; if (mimeType != null) { name = "geoserver"; if (opName != null) { name = name + "-" + opName; } String[] typeParts = mimeType.split(";"); name = name + "." + typeParts[0].split("/")[0]; } return name; }
String mimeType = response.getMimeType(result, opDescriptor);
@Override public Response responseDispatched( Request request, Operation operation, Object result, Response response) { Service service = operation.getService(); if (service == null || service.getId() == null || !service.getId().equalsIgnoreCase("wfs")) { // not a WFS service so we are not interested in it return response; } String responseMimeType = response.getMimeType(result, operation); if (!isGmlBased(responseMimeType)) { // no a GML based response return response; } WFSInfo wfs = geoserver.getService(WFSInfo.class); GMLInfo gmlInfo = wfs.getGML().get(WFSInfo.Version.negotiate(service.getVersion().toString())); if (gmlInfo == null || !gmlInfo.getMimeTypeToForce().isPresent()) { // we don't need to force any specific MIME type return response; } // enforce the configured MIME type String mimeType = gmlInfo.getMimeTypeToForce().get(); LOGGER.info( String.format( "Overriding MIME type '%s' with '%s' for WFS operation '%s'.", responseMimeType, mimeType, operation.getId())); return new ResponseWrapper(response, mimeType); }
@Override public Response responseDispatched( Request request, Operation operation, Object result, Response response) { // is this a feature response we are about to encode? if (result instanceof FeatureCollectionResponse) { HttpServletResponse httpResponse = request.getHttpResponse(); FeatureCollectionResponse fcr = (FeatureCollectionResponse) result; String contentType = response.getMimeType(result, operation); if (fcr.getPrevious() != null) { addLink(httpResponse, "prev", contentType, fcr.getPrevious()); } if (fcr.getNext() != null) { addLink(httpResponse, "next", contentType, fcr.getNext()); } } return response; }