@Test public void testAddService() throws Exception { ServiceInfo service = geoServer.getFactory().createService(); service.setName("foo"); geoServer.add(service); ServiceInfo s2 = geoServer.getFactory().createService(); ((ServiceInfoImpl) s2).setId(service.getId()); try { geoServer.add(s2); fail("adding service with duplicate id should throw exception"); } catch (Exception e) { } ServiceInfo s = geoServer.getServiceByName("foo", ServiceInfo.class); assertTrue(s != service); assertEquals(service, s); }
@Test public void testModifyService() throws Exception { ServiceInfo service = geoServer.getFactory().createService(); ((ServiceInfoImpl) service).setId("id"); service.setName("foo"); service.setTitle("bar"); geoServer.add(service); ServiceInfo s1 = geoServer.getServiceByName("foo", ServiceInfo.class); s1.setTitle("changed"); ServiceInfo s2 = geoServer.getServiceByName("foo", ServiceInfo.class); assertEquals("bar", s2.getTitle()); geoServer.save(s1); s2 = geoServer.getServiceByName("foo", ServiceInfo.class); assertEquals("changed", s2.getTitle()); }
public GwcServiceProxy() { serviceInfo = new ServiceInfoImpl(); serviceInfo.setId("gwc"); serviceInfo.setName("gwc"); serviceInfo.setEnabled(true); serviceInfo.setVersions(ImmutableList.of(new Version("1.0.0"))); gwcDispatcher = GeoWebCacheExtensions.bean(GeoWebCacheDispatcher.class); }
public GwcServiceProxy() { serviceInfo = new ServiceInfoImpl(); serviceInfo.setId("gwc"); serviceInfo.setName("gwc"); serviceInfo.setEnabled(true); serviceInfo.setVersions(ImmutableList.of(new Version("1.0.0"))); gwcDispatcher = GeoWebCacheExtensions.bean(GeoWebCacheDispatcher.class); }
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; } }