if (!global && s.getWorkspace() == null) continue; geoServer.add(s);
try { SettingsInfo settings = depersist(xp, f, SettingsInfo.class); geoServer.add(settings); } catch (Exception e) { LOGGER.log(
if (service != null) { LOGGER.info("Loading service '" + service.getId() + "'"); geoServer.add(service);
@Test public void testAddWorkspaceLocalService() throws Exception { File dataDirRoot = getTestData().getDataDirectoryRoot(); WorkspaceInfo ws = getCatalog().getDefaultWorkspace(); ServiceInfo s = geoServer.getFactory().createService(); s.setName("foo"); s.setWorkspace(ws); File f = new File(dataDirRoot, "workspaces" + "/" + ws.getName() + "/service.xml"); assertFalse(f.exists()); geoServer.add(s); assertTrue(f.exists()); }
geoServer.add(created);
settings.setLocalWorkspaceIncludesPrefix(true); settings.setWorkspace(workspace); gs.add(settings); assertEquals("sf:localGroup", catalog.getLayerGroupByName("localGroup").prefixedName()); assertEquals("sf:localGroup", catalog.getLayerGroups().get(0).prefixedName());
@Test public void testAddSettings() throws Exception { testAddWorkspace(); WorkspaceInfo ws = catalog.getWorkspaceByName("acme"); SettingsInfo settings = getGeoServer().getFactory().createSettings(); settings.setTitle("ACME"); settings.setWorkspace(ws); File f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml"); assertNull(f); getGeoServer().add(settings); f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml"); assertNotNull(f); Document dom = dom(f); assertXpathEvaluatesTo("ACME", "/settings/title", dom); }
@Test public void testReloadWithLocalServices() throws Exception { // setup a non default workspace WorkspaceInfo ws = getCatalog().getFactory().createWorkspace(); ws.setName("nonDefault"); NamespaceInfo ni = getCatalog().getFactory().createNamespace(); ni.setPrefix("nonDefault"); ni.setURI("http://www.geoserver.org/nonDefault"); getCatalog().add(ws); getCatalog().add(ni); // create a ws specific setting SettingsInfo s = geoServer.getFactory().createSettings(); s.setWorkspace(ws); geoServer.add(s); getGeoServer().reload(); }
geoServer.save(settings); } else { geoServer.add(settings);
@PostMapping( consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypeExtensions.TEXT_JSON_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE } ) @ResponseStatus(HttpStatus.CREATED) public String localSettingsCreate( @PathVariable String workspaceName, @RequestBody SettingsInfo settingsInfo) { String name = ""; if (workspaceName != null) { Catalog catalog = geoServer.getCatalog(); WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspaceName); settingsInfo.setWorkspace(workspaceInfo); geoServer.add(settingsInfo); geoServer.save(geoServer.getSettings(workspaceInfo)); name = settingsInfo.getWorkspace().getName(); } return name; }
@PutMapping( consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypeExtensions.TEXT_JSON_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE } ) public void localSettingsPut( @PathVariable String workspaceName, @RequestBody SettingsInfo settingsInfo) { if (workspaceName != null) { WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspaceName); SettingsInfo original = geoServer.getSettings(workspaceInfo); if (original == null) { settingsInfo.setWorkspace(workspaceInfo); geoServer.add(settingsInfo); geoServer.save(geoServer.getSettings(workspaceInfo)); } else { OwsUtils.copy(settingsInfo, original, SettingsInfo.class); original.setWorkspace(workspaceInfo); geoServer.save(original); } } }
public void serviceSettingsPut(ServiceInfo info, String workspaceName) { WorkspaceInfo ws = null; if (workspaceName != null) ws = geoServer.getCatalog().getWorkspaceByName(workspaceName); ServiceInfo originalInfo; if (ws != null) { originalInfo = geoServer.getService(ws, clazz); } else { originalInfo = geoServer.getService(clazz); } if (originalInfo != null) { OwsUtils.copy(info, originalInfo, clazz); geoServer.save(originalInfo); } else { if (ws != null) { info.setWorkspace(ws); } geoServer.add(info); } }
@Override protected String handleObjectPost(Object obj) throws Exception { String name = ""; String workspace = getAttribute("workspace"); if (workspace != null) { Catalog catalog = geoServer.getCatalog(); WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspace); SettingsInfo settings = (SettingsInfo) obj; settings.setWorkspace(workspaceInfo); geoServer.add(settings); geoServer.save(geoServer.getSettings(workspaceInfo)); name = settings.getWorkspace().getName(); } return name; }
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); }
@Override protected void handleObjectPut(Object obj) throws Exception { String workspace = getAttribute("workspace"); if (workspace != null) { WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspace); SettingsInfo settingsInfo = (SettingsInfo) obj; SettingsInfo original = geoServer.getSettings(workspaceInfo); if (original == null) { settingsInfo.setWorkspace(workspaceInfo); geoServer.add(settingsInfo); geoServer.save(geoServer.getSettings(workspaceInfo)); } else { OwsUtils.copy(settingsInfo, original, SettingsInfo.class); original.setWorkspace(workspaceInfo); geoServer.save(original); } } }
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 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); } }
public void testAllowDynamicStyles() throws Exception { GetMapRequest request = (GetMapRequest) reader.createRequest(); BufferedReader input = getResourceInputStream("WMSPostLayerGroupNonDefaultStyle.xml"); 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); GetMapXmlReader reader = new GetMapXmlReader(wms); boolean error = false; try { request = (GetMapRequest) reader.read(request, input, new HashMap()); } catch (ServiceException e) { error = true; } getGeoServer().remove(info); getGeoServer().add(oldInfo); assertTrue(error); }
@Before public void initLocalWMS() throws Exception { GeoServer geoServer = getGeoServer(); WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName("sf"); WMSInfo wmsInfo = geoServer.getService(ws, WMSInfo.class); if (wmsInfo != null) { geoServer.remove(wmsInfo); } wmsInfo = geoServer.getFactory().create(WMSInfo.class); wmsInfo.setName("WMS"); wmsInfo.setWorkspace(ws); geoServer.add(wmsInfo); }