public boolean isEnabled() { return delegate.isEnabled(); }
private void loadWmsStore( StoreContents storeContents, CatalogImpl catalog, XStreamPersister xp) { final Resource storeResource = storeContents.resource; WMSStoreInfo wms = null; try { wms = depersist(xp, storeContents.contents, WMSStoreInfo.class); catalog.add(wms); LOGGER.info( "Loaded wmsstore '" + wms.getName() + "', " + (wms.isEnabled() ? "enabled" : "disabled")); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load wms store '" + storeResource.name() + "'", e); return; } // load wms layers LayerLoader<WMSLayerInfo> coverageLoader = new LayerLoader<>(WMSLayerInfo.class, xp, catalog); try (AsynchResourceIterator<LayerContents> it = new AsynchResourceIterator<>( storeResource.parent(), Resources.DirectoryFilter.INSTANCE, WMS_LAYER_MAPPER)) { while (it.hasNext()) { LayerContents lc = it.next(); coverageLoader.accept(lc); } } }
public WMSStoreInfo clone(final WMSStoreInfo source, boolean allowEnvParametrization) { WMSStoreInfo target; try { target = (WMSStoreInfo) SerializationUtils.clone(source); if (target instanceof StoreInfoImpl && target.getCatalog() == null) { ((StoreInfoImpl) target).setCatalog(catalog); } } catch (Exception e) { target = catalog.getFactory().createWebMapServer(); target.setDescription(source.getDescription()); target.setEnabled(source.isEnabled()); target.setName(source.getName()); target.setType(source.getType()); target.setWorkspace(source.getWorkspace()); } setConnectionParameters(source, target); if (allowEnvParametrization) { // Resolve GeoServer Environment placeholders final GeoServerEnvironment gsEnvironment = GeoServerExtensions.bean(GeoServerEnvironment.class); if (gsEnvironment != null && GeoServerEnvironment.ALLOW_ENV_PARAMETRIZATION) { target.setCapabilitiesURL( (String) gsEnvironment.resolveValue(source.getCapabilitiesURL())); target.setUsername((String) gsEnvironment.resolveValue(source.getUsername())); target.setPassword((String) gsEnvironment.resolveValue(source.getPassword())); } } return target; }
@Override protected void onSave(WMSStoreInfo info, AjaxRequestTarget target) throws IllegalArgumentException { if (!info.isEnabled()) { doSaveStore(info); } else { try { // try to see if we can connect getCatalog().getResourcePool().clear(info); // do not call info.getWebMapServer cause it ends up calling // resourcepool.getWebMapServer with the unproxied instance (old values) // info.getWebMapServer(null).getCapabilities(); WebMapServer webMapServer = getCatalog().getResourcePool().getWebMapServer(info); webMapServer.getCapabilities(); doSaveStore(info); } catch (Exception e) { confirmSaveOnConnectionFailure(info, target, e); } } }
@Override protected void onSave(WMSStoreInfo info, AjaxRequestTarget target) throws IllegalArgumentException { if(!info.isEnabled()) { doSaveStore(info); } else { try { // try to see if we can connect getCatalog().getResourcePool().clear(info); // do not call info.getWebMapServer cause it ends up calling // resourcepool.getWebMapServer with the unproxied instance (old values) //info.getWebMapServer(null).getCapabilities(); WebMapServer webMapServer = getCatalog().getResourcePool().getWebMapServer(info); webMapServer.getCapabilities(); doSaveStore(info); } catch(Exception e) { confirmSaveOnConnectionFailure(info, target, e); } } }
@Test public void testPut() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces/sf/wmsstores/demo.xml"); assertXpathEvaluatesTo("true", "/wmsStore/enabled", dom); String xml = "<wmsStore>" + "<name>demo</name>" + "<enabled>false</enabled>" + "</wmsStore>"; MockHttpServletResponse response = putAsServletResponse( RestBaseController.ROOT_PATH + "/workspaces/sf/wmsstores/demo", xml, "text/xml"); assertEquals(200, response.getStatus()); dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces/sf/wmsstores/demo.xml"); assertXpathEvaluatesTo("false", "/wmsStore/enabled", dom); assertFalse(catalog.getStoreByName("sf", "demo", WMSStoreInfo.class).isEnabled()); }
protected void clone(final WMSStoreInfo source, WMSStoreInfo target) { target.setDescription(source.getDescription()); target.setEnabled(source.isEnabled()); target.setName(source.getName()); target.setType(source.getType()); target.setCapabilitiesURL(source.getCapabilitiesURL()); target.setWorkspace(source.getWorkspace()); target.setUsername(source.getUsername()); target.setPassword(source.getPassword()); target.setUseConnectionPooling(source.isUseConnectionPooling()); target.setMaxConnections(source.getMaxConnections()); target.setConnectTimeout(source.getConnectTimeout()); target.setReadTimeout(source.getReadTimeout()); }
@Test public void testPutNonDestructive() throws Exception { WMSStoreInfo wsi = catalog.getStoreByName("sf", "demo", WMSStoreInfo.class); wsi.setEnabled(true); catalog.save(wsi); assertTrue(wsi.isEnabled()); int maxConnections = wsi.getMaxConnections(); int readTimeout = wsi.getReadTimeout(); int connectTimeout = wsi.getConnectTimeout(); boolean useConnectionPooling = wsi.isUseConnectionPooling(); String xml = "<wmsStore>" + "<name>demo</name>" + "</wmsStore>"; MockHttpServletResponse response = putAsServletResponse( RestBaseController.ROOT_PATH + "/workspaces/sf/wmsstores/demo", xml, "text/xml"); assertEquals(200, response.getStatus()); wsi = catalog.getStoreByName("sf", "demo", WMSStoreInfo.class); assertTrue(wsi.isEnabled()); assertEquals(maxConnections, wsi.getMaxConnections()); assertEquals(readTimeout, wsi.getReadTimeout()); assertEquals(connectTimeout, wsi.getConnectTimeout()); assertEquals(useConnectionPooling, wsi.isUseConnectionPooling()); }