/** * If the current request contains a namespace we build a filter using the provided property * and request namespace and adds it to the provided filter. If the request doesn't contain * a namespace the original filter is returned as is. */ private Filter addNameSpaceFilterIfNeed(Filter filter, String nameSpaceProperty) { String nameSpacePrefix = request.getNamespace(); if (nameSpacePrefix == null) { return filter; } Filter equals = Predicates.equal(nameSpaceProperty, nameSpacePrefix); return Predicates.and(filter, equals); }
final Version version = WMS.version(request.getVersion()); if (version == null) { throw new IllegalArgumentException("version not supplied."); if (request.getUpdateSequence() != null && !"".equals(request.getUpdateSequence().trim())) { try { reqUS = Long.parseLong(request.getUpdateSequence()); } catch (NumberFormatException nfe) { throw new ServiceException( String baseUrl = request.getBaseUrl(); if (WMS.VERSION_1_1_1.equals(version)) { Set<String> mapFormats = wms.getAllowedMapFormatNames();
private boolean isTiled(GetCapabilitiesRequest request) { return Boolean.valueOf(request.getRawKvp().get("TILED")).booleanValue(); }
/** * Notes the start of the element and sets version and service tags, as required. * * @param namespaceURI URI for namespace appended to element. * @param localName Local name of element. * @param rawName Raw name of element. * @param atts Element attributes. * @throws SAXException For any standard SAX errors. */ public void startElement( String namespaceURI, String localName, String rawName, Attributes atts) throws SAXException { if (localName.equals("GetCapabilities")) { LOGGER.finer("found capabilities start."); for (int i = 0, n = atts.getLength(); i < n; i++) { if (atts.getLocalName(i).equals("version")) { String version = atts.getValue(i); request.setVersion(version); } else if (atts.getLocalName(i).equals("service")) { // ok WMS is implicit } else if (atts.getLocalName(i).equals("updateSequence")) { request.setUpdateSequence(atts.getValue(i)); } } } } }
public GetCapabilitiesRequest read(Object req, Map kvp, Map rawKvp) throws Exception { GetCapabilitiesRequest request = (GetCapabilitiesRequest) super.read(req, kvp, rawKvp); request.setRawKvp(rawKvp); String version = request.getVersion(); if (null == version || version.length() == 0) { version = (String) rawKvp.get("WMTVER"); request.setVersion(negotiatedVersion.toString());
return; Version version = WMS.version(request.getVersion(), true); if (!WMS.VERSION_1_1_1.equals(version) || !isTiled(request)) { return; final String namespacePrefixFilter = request.getNamespace(); Iterable<? extends TileLayer> tileLayers; tileLayers = gwc.getTileLayersByNamespacePrefix(namespacePrefixFilter);
/** * Retrieves the WMS's capabilities document. * * @param scaleHintUnitsPerDiaPixel true if the scalehint must be in units per diagonal of a * pixel * @return Capabilities as {@link Document} */ private Document findCapabilities(Boolean scaleHintUnitsPerDiaPixel) throws Exception { // set the Scalehint units per diagonal pixel setting. WMS wms = getWMS(); WMSInfo info = wms.getServiceInfo(); MetadataMap mm = info.getMetadata(); mm.put(WMS.SCALEHINT_MAPUNITS_PIXEL, scaleHintUnitsPerDiaPixel); info.getGeoServer().save(info); Capabilities_1_3_0_Transformer tr = new Capabilities_1_3_0_Transformer( wms, BASE_URL, wms.getAllowedMapFormats(), new HashSet<ExtendedCapabilitiesProvider>()); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_3_0.toString()); Document dom = WMSTestSupport.transform(req, tr); Element root = dom.getDocumentElement(); assertEquals(WMS.VERSION_1_3_0.toString(), root.getAttribute("version")); return dom; }
@SuppressWarnings("unchecked") @Test public void testDefault() throws Exception { rawKvp.put("request", "getcapabilities"); kvp.put("request", "getcapabilities"); GetCapabilitiesRequest read = reader.read(reader.createRequest(), kvp, rawKvp); assertNotNull(read); assertEquals("getcapabilities", read.getRequest().toLowerCase()); assertNull(read.getBaseUrl()); assertNull(read.getNamespace()); }
@Test public void testParseXmlGetCapabilities() throws Exception { CapabilitiesXmlReader reader = new CapabilitiesXmlReader(EntityResolverProvider.RESOLVE_DISABLED_PROVIDER); String plainRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" // + "<ogc:GetCapabilities xmlns:ogc=\"http://www.opengis.net/ows\" " // + " xmlns:gml=\"http://www.opengis.net/gml\" " // + " version=\"1.2.0\" updateSequence=\"1\" " // + " service=\"WMS\"> " // + "</ogc:GetCapabilities>"; Reader input = new StringReader(plainRequest); Object read = reader.read(null, input, null); assertTrue(read instanceof GetCapabilitiesRequest); GetCapabilitiesRequest request = (GetCapabilitiesRequest) read; assertEquals("GetCapabilities", request.getRequest()); assertEquals("1.2.0", request.getVersion()); assertEquals("1", request.getUpdateSequence()); } }
final String baseURL = request.getBaseUrl(); String dtdUrl = buildSchemaURL(baseURL, "wms/1.1.1/WMS_MS_Capabilities.dtd");
@SuppressWarnings("unchecked") @Test public void testVersion() throws Exception { kvp.put("Version", "1.1.1"); GetCapabilitiesRequest read = reader.read(reader.createRequest(), kvp, rawKvp); assertNotNull(read); assertEquals("1.1.1", read.getVersion()); }
@Before public void internalSetUp() throws IOException { this.catalog = getCatalog(); geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); wmsConfig.setApplicationContext(applicationContext); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/BasicPolygons.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/BasicPolygons.png"); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/Bridges.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/Bridges.png"); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("wms", "http://www.opengis.net/wms"); namespaces.put("ows", "http://www.opengis.net/ows"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }
@SuppressWarnings("rawtypes") @Override public Object read(Object request, Reader reader, Map kvp) throws Exception { // instantiante parsers and content handlers GetCapabilitiesRequest req = new GetCapabilitiesRequest(); CapabilitiesHandler currentRequest = new CapabilitiesHandler(req); currentRequest.setEntityResolver(resolverProvider.getEntityResolver()); // read in XML file and parse to content handler try { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); ParserAdapter adapter = new ParserAdapter(parser.getParser()); adapter.setEntityResolver(resolverProvider.getEntityResolver()); adapter.setContentHandler(currentRequest); adapter.parse(new InputSource(reader)); } catch (SAXException e) { throw new ServiceException( e, "XML capabilities request parsing error", getClass().getName()); } catch (IOException e) { throw new ServiceException( e, "XML capabilities request input error", getClass().getName()); } catch (ParserConfigurationException e) { throw new ServiceException( e, "Some sort of issue creating parser", getClass().getName()); } return req; }
@SuppressWarnings("unchecked") @Test public void testUpdateSequence() throws Exception { kvp.put("updateSequence", "1000"); GetCapabilitiesRequest read = reader.read(reader.createRequest(), kvp, rawKvp); assertNotNull(read); assertEquals("1000", read.getUpdateSequence()); } }
return; Version version = WMS.version(request.getVersion(), true); if (!WMS.VERSION_1_1_1.equals(version) || !isTiled(request)) { return; final String namespacePrefixFilter = request.getNamespace(); Iterable<? extends TileLayer> tileLayers; tileLayers = gwc.getTileLayersByNamespacePrefix(namespacePrefixFilter);
wms.getAllowedMapFormats(), new HashSet<ExtendedCapabilitiesProvider>()); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_3_0.toString());
/** * Turns the data URL list to XML * * @param keywords */ private void handleDataList(Collection<DataLinkInfo> dataURLs) { if (dataURLs == null) { return; } for (DataLinkInfo link : dataURLs) { start("DataURL"); element("Format", link.getType()); String content = ResponseUtils.proxifyDataLink(link, request.getBaseUrl()); AttributesImpl orAtts = new AttributesImpl(); orAtts.addAttribute("", "xmlns:xlink", "xmlns:xlink", "", XLINK_NS); orAtts.addAttribute(XLINK_NS, "xlink:type", "xlink:type", "", "simple"); orAtts.addAttribute("", "xlink:href", "xlink:href", "", content); element("OnlineResource", null, orAtts); end("DataURL"); } }
/** * 1.0 "WMTVER" parameter supplied instead of "VERSION"? Version negotiation should agree on * 1.1.1 */ @SuppressWarnings("unchecked") @Test public void testWMTVER() throws Exception { rawKvp.put("WMTVER", "1.0"); GetCapabilitiesRequest read = reader.read(reader.createRequest(), kvp, rawKvp); assertNotNull(read); assertEquals("1.1.1", read.getVersion()); }
/** * Sets up the configuration objects with default values. Since they're live, specific tests can * modify their state before running the assertions */ @Before public void setUp() throws Exception { geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); catalog = new CatalogImpl(); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }
/** * Retrieves the WMS's capabilities document. * * @param scaleHintUnitsPerDiaPixel true if the scalehint must be in units per diagonal of a * pixel * @return Capabilities as {@link Document} */ private Document findCapabilities(Boolean scaleHintUnitsPerDiaPixel) throws Exception { // set the Scalehint units per diagonal pixel setting. WMS wms = getWMS(); WMSInfo info = wms.getServiceInfo(); MetadataMap mm = info.getMetadata(); mm.put(WMS.SCALEHINT_MAPUNITS_PIXEL, scaleHintUnitsPerDiaPixel); info.getGeoServer().save(info); GetCapabilitiesTransformer tr = new GetCapabilitiesTransformer(wms, BASE_URL, FORMATS, LEGEND_FORMAT, null); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_1_1.toString()); Document dom = WMSTestSupport.transform(req, tr); Element root = dom.getDocumentElement(); Assert.assertEquals(WMS.VERSION_1_1_1.toString(), root.getAttribute("version")); return dom; }