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; }
public WebMapServer getWebMapServer(ProgressListener listener) throws IOException { return delegate.getWebMapServer(listener); }
/** * @param source * @param target */ private void setConnectionParameters(final WMSStoreInfo source, WMSStoreInfo target) { target.setCapabilitiesURL(source.getCapabilitiesURL()); target.setUsername(source.getUsername()); target.setPassword(source.getPassword()); target.setUseConnectionPooling(source.isUseConnectionPooling()); target.setMaxConnections(source.getMaxConnections()); target.setConnectTimeout(source.getConnectTimeout()); target.setReadTimeout(source.getReadTimeout()); }
EntityResolver entityResolver = getEntityResolver(); String id = info.getId(); WebMapServer wms = wmsCache.get(id); if (wms == null) { HTTPClient client = getHTTPClient(expandedStore); String capabilitiesURL = expandedStore.getCapabilitiesURL(); URL serverURL = new URL(capabilitiesURL); Map<String, Object> hints = new HashMap<>();
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 testWMSStore() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms1 = cFactory.createWebMapServer(); wms1.setName("bar"); wms1.setWorkspace(ws); wms1.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); ByteArrayOutputStream out = out(); persister.save(wms1, out); WMSStoreInfo wms2 = persister.load(in(out), WMSStoreInfo.class); assertEquals("bar", wms2.getName()); assertEquals(WMSStoreInfoImpl.DEFAULT_MAX_CONNECTIONS, wms2.getMaxConnections()); assertEquals(WMSStoreInfoImpl.DEFAULT_CONNECT_TIMEOUT, wms2.getConnectTimeout()); assertEquals(WMSStoreInfoImpl.DEFAULT_READ_TIMEOUT, wms2.getReadTimeout()); assertNotNull(wms2.getWorkspace()); assertEquals("foo", wms2.getWorkspace().getId()); Document dom = dom(in(out)); assertEquals("wmsStore", dom.getDocumentElement().getNodeName()); }
wmsStore.setEnabled(false); wmsStore.setName("wmsStore-Name"); wmsStore.setWorkspace(workspace); wmsStore.setType("wmsStore-Type"); wmsStore.setDescription("wmsStore-Description"); wmsStore.setCapabilitiesURL("wmsStore-CapabilitiesURL"); wmsStore.setUseConnectionPooling(false); wmsStore.setUsername("wmsStore-Username"); wmsStore.setPassword("wmsStore-Password"); wmsStore.setMaxConnections(0); wmsStore.setReadTimeout(0); wmsStore.setConnectTimeout(0); catalog.add(wmsStore);
/** * Check maxConnections, connectTimeout, and readTimeout, stored as metadata properties in a * 2.1.3+ configuration are read back as actual properties. */ @Test public void testWMSStoreBackwardsCompatibility() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms1 = cFactory.createWebMapServer(); wms1.setName("bar"); wms1.setWorkspace(ws); wms1.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); wms1.getMetadata().put("maxConnections", Integer.valueOf(18)); wms1.getMetadata().put("connectTimeout", Integer.valueOf(25)); wms1.getMetadata().put("readTimeout", Integer.valueOf(78)); ByteArrayOutputStream out = out(); persister.save(wms1, out); WMSStoreInfo wms2 = persister.load(in(out), WMSStoreInfo.class); assertEquals("bar", wms2.getName()); assertEquals(18, wms2.getMaxConnections()); assertEquals(25, wms2.getConnectTimeout()); assertEquals(78, wms2.getReadTimeout()); assertNull(wms2.getMetadata().get("maxConnections")); assertNull(wms2.getMetadata().get("connectTimeout")); assertNull(wms2.getMetadata().get("readTimeout")); }
@Override protected String handleObjectPost(Object object) throws Exception { String workspace = getAttribute( "workspace" ); WMSStoreInfo wms = (WMSStoreInfo) object; if ( wms.getWorkspace() != null ) { //ensure the specifried workspace matches the one dictated by the uri WorkspaceInfo ws = (WorkspaceInfo) wms.getWorkspace(); if ( !workspace.equals( ws.getName() ) ) { throw new RestletException( "Expected workspace " + workspace + " but client specified " + ws.getName(), Status.CLIENT_ERROR_FORBIDDEN ); } } else { wms.setWorkspace( catalog.getWorkspaceByName( workspace ) ); } wms.setEnabled(true); catalog.add( wms ); LOGGER.info( "POST WSM store " + wms.getName() ); return wms.getName(); }
@Override protected void handleObjectPut(Object object) throws Exception { String workspace = getAttribute("workspace"); String wmsstore = getAttribute("wmsstore"); WMSStoreInfo wms = (WMSStoreInfo) object; WMSStoreInfo original = catalog.getStoreByName(workspace, wmsstore, WMSStoreInfo.class); //ensure this is not a name or workspace change if ( wms.getName() != null && !wms.getName().equals( original.getName() ) ) { throw new RestletException( "Can't change name of data store.", Status.CLIENT_ERROR_FORBIDDEN ); } if ( wms.getWorkspace() != null && !wms.getWorkspace().equals( original.getWorkspace() ) ) { throw new RestletException( "Can't change workspace of data store.", Status.CLIENT_ERROR_FORBIDDEN ); } new CatalogBuilder( catalog ).updateWMSStore( original, wms ); catalog.save( original ); LOGGER.info( "PUT wms store " + workspace + "," + wmsstore ); }
@Override public void visit(WMSStoreInfo wmsStore) { WMSStoreInfo otherWmsStore = otherCatalog.getStore(wmsStore.getId(), WMSStoreInfo.class); if (!(Objects.equals(wmsStore, otherWmsStore) && Objects.equals(wmsStore.getType(), otherWmsStore.getType()) && Objects.equals(wmsStore.getCapabilitiesURL(), otherWmsStore.getCapabilitiesURL()) && Objects.equals(wmsStore.getUsername(), otherWmsStore.getUsername()) && Objects.equals(wmsStore.getPassword(), otherWmsStore.getPassword()) && Objects.equals(wmsStore.getMaxConnections(), otherWmsStore.getMaxConnections()) && Objects.equals(wmsStore.getReadTimeout(), otherWmsStore.getReadTimeout()) && Objects.equals(wmsStore.getConnectTimeout(), otherWmsStore.getConnectTimeout()) && checkEquals(wmsStore.getMetadata(), otherWmsStore.getMetadata()) && checkEquals( wmsStore.getConnectionParameters(), otherWmsStore.getConnectionParameters()))) { differences.add(new InfoDiff(wmsStore, otherWmsStore)); } }
public static WMSStoreInfo localizeWMSStore(final WMSStoreInfo info, final Catalog catalog) throws IllegalAccessException, InvocationTargetException { if (info==null || catalog==null) throw new NullArgumentException("Arguments may never be null"); final WMSStoreInfo localObject=catalog.getStoreByName(info.getWorkspace(), info.getName(), WMSStoreInfo.class); final CatalogBuilder builder = new CatalogBuilder(catalog); if (localObject !=null){ return localObject; } final WMSStoreInfo createdObject = catalog.getFactory().createWebMapServer(); // let's using the created object (see getGridCoverageReader) BeanUtils.copyProperties(createdObject, info); createdObject.setWorkspace(localizeWorkspace(info.getWorkspace(), catalog)); builder.attach(createdObject); return createdObject; }
private WMSStoreInfo buildWmsStore() { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms = cFactory.createWebMapServer(); wms.setName("bar"); wms.setWorkspace(ws); wms.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); wms.setUsername("user"); wms.setPassword("password"); return wms; } }
@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()); }
MetadataMap metadata = wmsStore.getMetadata(); Integer maxConnections = null; Integer connectTimeout = null; metadata.remove("readTimeout"); if (wmsStore.getMaxConnections() <= 0) { wmsStore.setMaxConnections( maxConnections != null && maxConnections.intValue() > 0 ? maxConnections : WMSStoreInfoImpl.DEFAULT_MAX_CONNECTIONS); if (wmsStore.getConnectTimeout() <= 0) { wmsStore.setConnectTimeout( connectTimeout != null && connectTimeout.intValue() > 0 ? connectTimeout : WMSStoreInfoImpl.DEFAULT_CONNECT_TIMEOUT); if (wmsStore.getReadTimeout() <= 0) { wmsStore.setReadTimeout( readTimeout != null && readTimeout.intValue() > 0 ? readTimeout
public String getName() { return delegate.getName(); }
public void setCapabilitiesURL(String url) { delegate.setCapabilitiesURL(url); }
wms.setName("wmsName"); wms.setType("WMS"); wms.setCapabilitiesURL("http://fake.url"); wms.setWorkspace(ws);
wms.setWorkspace(ws); wms.setName("foo"); wms.setCapabilitiesURL("http://fake.host/wms?request=getCapabilities"); catalog.add(wms);
info.setCapabilitiesURL(url.toExternalForm()); info.setEnabled(true); info.setUseConnectionPooling(false); try { rp.getWebMapServer(info);