public DefaultGeoServerFacade(GeoServer geoServer) { this.geoServer = geoServer; this.global = geoServer.getFactory().createGlobal(); this.logging = geoServer.getFactory().createLogging(); }
GeoServerFactory factory = geoServer.getFactory();
@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()); }
SettingsInfo settings = gs.getFactory().createSettings(); settings.setLocalWorkspaceIncludesPrefix(true); settings.setWorkspace(workspace);
@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(); }
@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); }
SettingsInfo settings = ws != null ? geoServer.getSettings(ws) : global.getSettings(); if (settings == null) { settings = geoServer.getFactory().createSettings();
ServiceInfo create() { // create it GeoServer gs = GeoServerApplication.get().getGeoServer(); ServiceInfo newService = gs.getFactory().create(serviceClass); // initialize from global service ServiceInfo global = gs.getService(serviceClass); OwsUtils.copy(global, newService, serviceClass); newService.setWorkspace(wsModel.getObject()); // hack, but need id to be null so its considered unattached ((ServiceInfoImpl) newService).setId(null); return newService; } }
ServiceInfo create() { //create it GeoServer gs = GeoServerApplication.get().getGeoServer(); ServiceInfo newService = gs.getFactory().create(serviceClass); //initialize from global service ServiceInfo global = gs.getService(serviceClass); OwsUtils.copy(global,newService, serviceClass); newService.setWorkspace(wsModel.getObject()); //hack, but need id to be null so its considered unattached ((ServiceInfoImpl)newService).setId(null); return newService; } }
@Override public SettingsInfo getObject() { if (info == null) { GeoServer gs = GeoServerApplication.get().getGeoServer(); info = gs.getFactory().createSettings(); // initialize from global settings SettingsInfo global = gs.getGlobal().getSettings(); // hack, we need to copy out composite objects separately to get around proxying // madness ContactInfo contact = gs.getFactory().createContact(); OwsUtils.copy(global.getContact(), contact, ContactInfo.class); OwsUtils.copy(global, info, SettingsInfo.class); info.setContact(contact); info.setWorkspace(wsModel.getObject()); } return info; } }
@Override public SettingsInfo getObject() { if (info == null) { GeoServer gs = GeoServerApplication.get().getGeoServer(); info = gs.getFactory().createSettings(); //initialize from global settings SettingsInfo global = gs.getGlobal().getSettings(); //hack, we need to copy out composite objects separately to get around proxying // madness ContactInfo contact = gs.getFactory().createContact(); OwsUtils.copy(global.getContact(), contact, ContactInfo.class); OwsUtils.copy(global, info, SettingsInfo.class); info.setContact(contact); info.setWorkspace(wsModel.getObject()); } return info; } }
@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); }