@Override public <T> T create(Class<T> clazz) { return (T) new WMSInfoImpl(); } }
@Override public Object doUnmarshal( Object result, HierarchicalStreamReader reader, UnmarshallingContext context) { WMSInfoImpl service = (WMSInfoImpl) super.doUnmarshal(result, reader, context); MetadataMap metadata = service.getMetadata(); // for backwards compatibility with 2.1.3+ data directories, check if the auth urls and // identifiers are stored in the metadata map if (service.getAuthorityURLs() == null && metadata != null) { String serialized = metadata.get("authorityURLs", String.class); List<AuthorityURLInfo> authorities; if (serialized == null) { authorities = new ArrayList<AuthorityURLInfo>(1); } else { authorities = AuthorityURLInfoInfoListConverter.fromString(serialized); } service.setAuthorityURLs(authorities); } if (service.getIdentifiers() == null && metadata != null) { String serialized = metadata.get("identifiers", String.class); List<LayerIdentifierInfo> identifiers; if (serialized == null) { identifiers = new ArrayList<LayerIdentifierInfo>(1); } else { identifiers = LayerIdentifierInfoListConverter.fromString(serialized); } service.setIdentifiers(identifiers); } return service; } }
private void addDefaultsIfMissing(ServiceInfo serviceInfo) { if (serviceInfo instanceof WMSInfoImpl) { WMSInfoImpl wmsInfo = (WMSInfoImpl) serviceInfo; if (wmsInfo.getAuthorityURLs() == null) { List<AuthorityURLInfo> authorityURLS = new ArrayList<AuthorityURLInfo>(); wmsInfo.setAuthorityURLs(authorityURLS); } if (wmsInfo.getIdentifiers() == null) { List<LayerIdentifierInfo> identifiers = new ArrayList<LayerIdentifierInfo>(); wmsInfo.setIdentifiers(identifiers); } if (wmsInfo.getSRS() == null) { List<String> srsList = new ArrayList<String>(); wmsInfo.setSRS(srsList); } } else if (serviceInfo instanceof WFSInfoImpl) { WFSInfoImpl wfsInfo = (WFSInfoImpl) serviceInfo; if (wfsInfo.getGML() == null) { GMLInfoImpl gml3Info = new GMLInfoImpl(); gml3Info.setOverrideGMLAttributes(true); Map<WFSInfo.Version, GMLInfo> gml = new HashMap<WFSInfo.Version, GMLInfo>(); wfsInfo.setGML(gml); wfsInfo.getGML().put(WFSInfo.Version.V_11, gml3Info); wfsInfo.getGML().put(WFSInfo.Version.V_10, gml3Info); wfsInfo.getGML().put(WFSInfo.Version.V_20, gml3Info); } } }
@SuppressWarnings("unchecked") public WMSInfo load(LegacyServicesReader reader, GeoServer geoServer) throws Exception { WMSInfoImpl wms = new WMSInfoImpl(); wms.setId("wms"); wm.setTransparency((Integer) props.get("globalWatermarkingTransparency")); wm.setPosition(Position.get((Integer) props.get("globalWatermarkingPosition"))); wms.setWatermark(wm); wms.setDynamicStylingDisabled( props.containsKey("dynamicStylingDisabled") ? (Boolean) props.get("dynamicStylingDisabled") wms.setInterpolation( WMSInterpolation.valueOf((String) props.get("allowInterpolation"))); } catch (Exception e) { wms.setInterpolation(WMSInterpolation.Nearest); wms.getMetadata().put("svgRenderer", (Serializable) props.get("svgRenderer")); wms.getMetadata().put("svgAntiAlias", (Serializable) props.get("svgAntiAlias")); wms.setMaxBuffer((Integer) props.get("maxBuffer")); wms.setMaxRequestMemory((Integer) props.get("maxRequestMemory")); wms.setMaxRenderingTime((Integer) props.get("maxRenderingTime")); wms.setMaxRenderingErrors((Integer) props.get("maxRenderingErrors")); wms.getVersions().add(WMS.VERSION_1_1_1);
public ServiceInfo load(LegacyServicesReader reader, GeoServer geoServer) throws Exception { WMSInfoImpl wms = new WMSInfoImpl(); wms.setId( "wms" ); wm.setTransparency( (Integer) props.get("globalWatermarkingTransparency") ); wm.setPosition( Position.get( (Integer) props.get( "globalWatermarkingPosition" ) ) ); wms.setWatermark( wm ); wms.setInterpolation( (String) props.get( "allowInterpolation" ) ); wms.getMetadata().put( "svgRenderer", (Serializable) props.get( "svgRenderer") ); wms.getMetadata().put( "svgAntiAlias",(Serializable) props.get( "svgAntiAlias") ); wms.getSRS().add(crsArray[i]); } catch(NoSuchAuthorityCodeException nsae) { LOGGER.warning("Unknown CRS " + crsArray[i] + " in getCapabilities CRS list");
@Test public void testAddService() throws Exception { // create a WMS service for the test workspace WMSInfoImpl serviceInfo = new WMSInfoImpl(); serviceInfo.setName("TEST-WMS-NAME"); serviceInfo.setId("TEST-WMS-ID"); serviceInfo.setWorkspace(workspace); serviceInfo.setAbstract("TEST-WMS-ABSTRACT"); // add the new service to GeoServer getGeoServer().add(serviceInfo); // waiting for a service add event List<Message> messages = JmsEventsListener.getMessagesByHandlerKey( 5000, (selected) -> selected.size() >= 1, SERVICE_EVENT_HANDLER_KEY); // let's check if the new added service was correctly published assertThat(messages.size(), is(1)); List<JMSServiceModifyEvent> serviceEvents = getMessagesForHandler(messages, SERVICE_EVENT_HANDLER_KEY, serviceHandler); assertThat(serviceEvents.size(), is(1)); assertThat(serviceEvents.get(0).getEventType(), is(JMSEventType.ADDED)); // check the service content ServiceInfo publishedService = serviceEvents.get(0).getSource(); assertThat(publishedService.getName(), is("TEST-WMS-NAME")); assertThat(publishedService.getId(), is("TEST-WMS-ID")); assertThat(publishedService.getAbstract(), is("TEST-WMS-ABSTRACT")); }
mockGeoServer.setGlobal(geoserverInfo); WMSInfoImpl wmsInfo = new WMSInfoImpl(); wmsInfo.setId("wms"); wmsInfo.setName("WMS"); wmsInfo.setEnabled(true); mockGeoServer.add(wmsInfo);
geoServer.save(wmsService); WMSInfoImpl workspaceWmsService = new WMSInfoImpl(); workspaceWmsService.setName(randomString()); workspaceWmsService.setTitle(randomString()); workspaceWmsService.setWorkspace(workspace); geoServer.add(workspaceWmsService);
public void testUpgradeDirectWMSIntegrationFlag() throws Exception { // no gwc-gs.xml exists, so that initialization runs when(configPersister.findConfigFile()).thenReturn(null); // no catalog layers for this test List<LayerInfo> layers = ImmutableList.of(); List<LayerGroupInfo> groups = ImmutableList.of(); when(rawCatalog.getLayers()).thenReturn(layers); when(rawCatalog.getLayerGroups()).thenReturn(groups); WMSInfoImpl wmsInfo = new WMSInfoImpl(); // initialize wmsInfo with a value for the old direct wms integration flag wmsInfo.getMetadata().put(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY, Boolean.TRUE); // make sure WMSInfo exists when(geoServer.getService(eq(WMSInfo.class))).thenReturn(wmsInfo); ArgumentCaptor<GWCConfig> captor = ArgumentCaptor.forClass(GWCConfig.class); // run layer initialization initializer.initialize(geoServer); verify(configPersister, times(2)).save(captor.capture()); assertTrue(captor.getAllValues().get(0).isDirectWMSIntegrationEnabled()); assertFalse(wmsInfo.getMetadata().containsKey(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY)); verify(geoServer).save(same(wmsInfo)); }
@SuppressWarnings("unchecked") @Test public void testServiceSection() throws Exception { wmsInfo.setTitle("title"); wmsInfo.setAbstract("abstract"); wmsInfo.getKeywords().add(new Keyword("k1")); wmsInfo.getKeywords().add(new Keyword("k2")); wmsInfo.setOnlineResource("http://onlineresource/fake"); contactInfo.setContactFacsimile("fax"); wmsInfo.setFees("fees"); wmsInfo.setAccessConstraints("accessConstraints"); wmsInfo.getOnlineResource(), service + "/OnlineResource/@xlink:href", dom);
public Boolean isBBOXForEachCRS() { if (bboxForEachCRS != null) { return bboxForEachCRS; } // check the metadata map if upgrading from 2.1.x Boolean bool = getMetadata().get("bboxForEachCRS", Boolean.class); return bool != null && bool; }
@Test public void testLimitedCRSList() throws Exception { wmsInfo.getSRS().add("EPSG:3246"); wmsInfo.getSRS().add("EPSG:23030"); GetCapabilitiesTransformer tr; tr = new GetCapabilitiesTransformer(wmsConfig, baseUrl, mapFormats, legendFormats, null); tr.setIndentation(2); Document dom = WMSTestSupport.transform(req, tr); NodeList limitedCrsCodes = XPATH.getMatchingNodes("/WMT_MS_Capabilities/Capability/Layer/SRS", dom); assertEquals(2, limitedCrsCodes.getLength()); }
@Override public WMSInfo getServiceInfo() { return new WMSInfoImpl(); }
protected WMSInfo createServiceFromScratch(GeoServer gs) { WMSInfo wms = new WMSInfoImpl(); wms.setName("WMS"); return wms; }
@Before public void setUp() throws Exception { geoServerImpl = new GeoServerImpl(); geoServerImpl.add(new WMSInfoImpl()); wms = new WMS(geoServerImpl); params = new HashMap<String, String>(); }
public void testSldDisabled() throws Exception { HashMap kvp = new HashMap(); URL url = GetMapKvpRequestReader.class.getResource("BasicPolygonsLibraryDefault.sld"); String decoded = URLDecoder.decode(url.toExternalForm(), "UTF-8"); kvp.put("sld", decoded); kvp.put( "layers", MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart()); WMS wms = new WMS(getGeoServer()); WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class); WMSInfo info = new WMSInfoImpl(); info.setDynamicStylingDisabled(Boolean.TRUE); getGeoServer().remove(oldInfo); getGeoServer().add(info); reader = new GetFeatureInfoKvpReader(wms); GetFeatureInfoRequest request = (GetFeatureInfoRequest) reader.createRequest(); boolean error = false; try { request = (GetFeatureInfoRequest) reader.read(request, parseKvp(kvp), kvp); } catch (ServiceException e) { error = true; } getGeoServer().remove(info); getGeoServer().add(oldInfo); assertTrue(error); }
public void testSldDisabled() throws Exception { HashMap kvp = new HashMap(); URL url = GetMapKvpRequestReader.class.getResource("BasicPolygonsLibraryDefault.sld"); String decoded = URLDecoder.decode(url.toExternalForm(), "UTF-8"); kvp.put("sld", decoded); kvp.put( "layers", MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart()); WMS wms = new WMS(getGeoServer()); WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class); WMSInfo info = new WMSInfoImpl(); info.setDynamicStylingDisabled(Boolean.TRUE); getGeoServer().remove(oldInfo); getGeoServer().add(info); reader = new GetMapKvpRequestReader(wms); GetMapRequest request = (GetMapRequest) reader.createRequest(); boolean error = false; try { request = (GetMapRequest) reader.read(request, parseKvp(kvp), kvp); } catch (ServiceException e) { error = true; } getGeoServer().remove(info); getGeoServer().add(oldInfo); assertTrue(error); }
@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(); }
public void testSldBodyDisabled() throws Exception { HashMap kvp = new HashMap(); kvp.put("sld_body", STATES_SLD); kvp.put( "layers", MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart()); WMS wms = new WMS(getGeoServer()); WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class); WMSInfo info = new WMSInfoImpl(); info.setDynamicStylingDisabled(Boolean.TRUE); getGeoServer().remove(oldInfo); getGeoServer().add(info); reader = new GetMapKvpRequestReader(wms); GetMapRequest request = (GetMapRequest) reader.createRequest(); boolean error = false; try { request = (GetMapRequest) reader.read(request, parseKvp(kvp), kvp); } catch (ServiceException e) { error = true; } getGeoServer().remove(info); getGeoServer().add(oldInfo); assertTrue(error); }
public void testSldBodyDisabled() throws Exception { HashMap kvp = new HashMap(); kvp.put("sld_body", STATES_SLD); kvp.put( "layers", MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart()); WMS wms = new WMS(getGeoServer()); WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class); WMSInfo info = new WMSInfoImpl(); info.setDynamicStylingDisabled(Boolean.TRUE); getGeoServer().remove(oldInfo); getGeoServer().add(info); reader = new GetFeatureInfoKvpReader(wms); GetFeatureInfoRequest request = (GetFeatureInfoRequest) reader.createRequest(); boolean error = false; try { request = (GetFeatureInfoRequest) reader.read(request, parseKvp(kvp), kvp); } catch (ServiceException e) { error = true; } getGeoServer().remove(info); getGeoServer().add(oldInfo); assertTrue(error); } }