public List<String> getWmsOutputFormats() { // get beans of type GetMapOutputFormat List<GetMapOutputFormat> formats = GeoServerExtensions.extensions(GetMapOutputFormat.class); return formats.stream().map(f -> f.getMimeType()).collect(Collectors.toList()); } }
outputFormats = application.getBeansOfType(GetMapOutputFormat.class); for (GetMapOutputFormat producer : outputFormats) { Set<String> producerFormats = new HashSet<String>(producer.getOutputFormatNames()); producerFormats.add(producer.getMimeType()); String knownFormat = producer.getMimeType(); for (String formatName : producerFormats) { String translatedFormatName = translateFormat("format.wms.", formatName);
/** @return {@link GetMapOutputFormat} for the requested outputFormat, or {@code null} */ public static GetMapOutputFormat findMapProducer( String outputFormat, Collection<GetMapOutputFormat> producers) { Set<String> producerFormats; for (GetMapOutputFormat producer : producers) { producerFormats = producer.getOutputFormatNames(); Set<String> caseInsensitiveFormats = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); caseInsensitiveFormats.addAll(producerFormats); if (caseInsensitiveFormats.contains(outputFormat)) { return producer; } } return null; }
WebMap map = delegate.produceMap(mapContent);
final MapProducerCapabilities cap = delegate.getCapabilities(request.getFormat());
/** * Grabs the list of allowed MIME-Types for the GetMap operation from the set of {@link * GetMapOutputFormat}s registered in the application context. * * @param applicationContext The application context where to grab the GetMapOutputFormats from. * @see GetMapOutputFormat#getContentType() */ public Set<String> getAvailableMapFormatNames() { final Collection<GetMapOutputFormat> producers; producers = WMSExtensions.findMapProducers(applicationContext); final Set<String> formats = new HashSet<String>(); for (GetMapOutputFormat producer : producers) { formats.addAll(producer.getOutputFormatNames()); } return formats; }
/** * Checks is a getMap mime type is allowed * * @param format */ public boolean isAllowedGetMapFormat(GetMapOutputFormat format) { if (getServiceInfo().isGetMapMimeTypeCheckingEnabled() == false) return true; Set<String> mimeTypes = getServiceInfo().getGetMapMimeTypes(); return mimeTypes.contains(format.getMimeType()); }
@Test public void testSetOutputFormat() { List<GetMapOutputFormat> producers = WMSExtensions.findMapProducers(applicationContext); for (GetMapOutputFormat producer : producers) { assertNotNull(producer.getMimeType()); assertNotNull(producer.getOutputFormatNames()); assertTrue(producer.getOutputFormatNames().size() > 0); } } }
/** @return all allowed GetMap format names */ public Set<String> getAllowedMapFormatNames() { final Collection<GetMapOutputFormat> producers; producers = WMSExtensions.findMapProducers(applicationContext); final Set<String> formats = new HashSet<String>(); for (GetMapOutputFormat producer : producers) { if (isAllowedGetMapFormat(producer) == false) { continue; // skip this producer, its mime type is not allowed } formats.addAll(producer.getOutputFormatNames()); } return formats; }
@Test public void testGetOutputFormat() { List<GetMapOutputFormat> producers = WMSExtensions.findMapProducers(applicationContext); for (GetMapOutputFormat producer : producers) { assertNotNull(producer.getMimeType()); } }
if (format.getOutputFormatNames().contains(format.getMimeType())) { formats.add(format.getMimeType()); } else { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "Map output format " + format.getMimeType() + " (" + format.getClass()
testFormatNames.add("image/dummy"); expect(mockProducer.getOutputFormatNames()).andReturn(testFormatNames).anyTimes();
void addMimeTypes() { getMapFormat = new RenderedImageMapOutputFormat(getWMS()); getInfoFormat = new TextFeatureInfoOutputFormat(getWMS()); WMSInfo wms = getWMS().getServiceInfo(); wms.getGetMapMimeTypes().add(getMapFormat.getMimeType()); wms.getGetFeatureInfoMimeTypes().add(getInfoFormat.getContentType()); wms.setGetMapMimeTypeCheckingEnabled(true); wms.setGetFeatureInfoMimeTypeCheckingEnabled(true); getGeoServer().save(wms); }
@Test public void testGetOutputFormatNames() { List<GetMapOutputFormat> producers = WMSExtensions.findMapProducers(applicationContext); for (GetMapOutputFormat producer : producers) { Set<String> outputFormats = producer.getOutputFormatNames(); assertNotNull(outputFormats); assertTrue(outputFormats.size() > 0); for (String oformat : outputFormats) { assertNotNull(oformat); } } }
void addMimeTypes() { getMapFormat = new RenderedImageMapOutputFormat(getWMS()); getInfoFormat = new TextFeatureInfoOutputFormat(getWMS()); WMSInfo wms = getWMS().getServiceInfo(); wms.getGetMapMimeTypes().add(getMapFormat.getMimeType()); wms.getGetFeatureInfoMimeTypes().add(getInfoFormat.getContentType()); wms.setGetMapMimeTypeCheckingEnabled(true); wms.setGetFeatureInfoMimeTypeCheckingEnabled(true); getGeoServer().save(wms); }
doc); Assert.assertEquals(1, formatNodes.getLength()); Assert.assertEquals(getMapFormat.getMimeType(), formatNodes.item(0).getTextContent());
"/WMT_MS_Capabilities/Capability/Request/GetMap/Format", doc); Assert.assertEquals(1, formatNodes.getLength()); Assert.assertEquals(getMapFormat.getMimeType(), formatNodes.item(0).getTextContent());
wms.getGetMapMimeTypes().add(format.getMimeType()); wms.setGetMapMimeTypeCheckingEnabled(true);
wms.getGetMapMimeTypes().add(format.getMimeType()); wms.setGetMapMimeTypeCheckingEnabled(true); getGeoServer().save(wms);