public WorkspaceInfo getWorkspace() { return delegate.getWorkspace(); }
@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()); }
@Test public void testWMSStoreReferencedByName() 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"); catalog.detach(wms1); ((WMSStoreInfoImpl) wms1).setId(null); ByteArrayOutputStream out = out(); XStreamPersister persister = new XStreamPersisterFactory().createXMLPersister(); persister.setReferenceByName(true); 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()); }
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 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 ); }
if (info.getWorkspace() != null && !original.getWorkspace().equals(info.getWorkspace())) { throw new RestException( "Attempting to move " + storeName + " from " + original.getWorkspace().getName() + " to " + info.getWorkspace().getName() + " via PUT", HttpStatus.FORBIDDEN);
@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(); }
UriComponentsBuilder builder) { if (wmsStore.getWorkspace() != null) { WorkspaceInfo ws = wmsStore.getWorkspace(); if (!workspaceName.equals(ws.getName())) { throw new RestException(
@Override protected void postEncodeReference(Object obj, String ref, String prefix, HierarchicalStreamWriter writer, MarshallingContext context) { if ( obj instanceof NamespaceInfo ) { NamespaceInfo ns = (NamespaceInfo) obj; encodeLink( "/namespaces/" + ns.getPrefix(), writer); } if ( obj instanceof WMSStoreInfo ) { WMSStoreInfo ds = (WMSStoreInfo) obj; encodeLink( "/workspaces/" + ds.getWorkspace().getName() + "/wmsstores/" + ds.getName(), writer ); } } });
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; }
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; }
@Override protected void postEncodeReference( Object obj, String ref, String prefix, HierarchicalStreamWriter writer, MarshallingContext context) { if (obj instanceof NamespaceInfo) { NamespaceInfo ns = (NamespaceInfo) obj; converter.encodeLink( "/namespaces/" + converter.encode(ns.getPrefix()), writer); } if (obj instanceof WMSStoreInfo) { WMSStoreInfo store = (WMSStoreInfo) obj; converter.encodeLink( "/workspaces/" + converter.encode(store.getWorkspace().getName()) + "/wmsstores/" + converter.encode(store.getName()), writer); } } });
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()); }
store.getWorkspace().getName()).getString());
this, store.getName(), store.getWorkspace().getName()) .getString());