private void renameStore(StoreInfo s, String newName) throws IOException { LOGGER.fine("Renaming store " + s.getName() + "to " + newName); Resource directory = dd.get(s); renameRes(directory, newName); }
@Deprecated private String path(StoreInfo store) { WorkspaceInfo workspace = store.getWorkspace(); return Paths.path("workspaces", workspace.getName(), store.getName()); }
/** * Retrieve a resource in the the configuration directory of a Store. An empty path will * retrieve the directory itself. * * @param store The store * @return A {@link Resource} */ public @Nonnull Resource get(StoreInfo store, String... path) { Resource r = get(store.getWorkspace(), store.getName(), Paths.path(path)); assert r != null; return r; }
public ValidationResult validate(StoreInfo store, boolean isNew) { if (isNull(store.getName())) { throw new IllegalArgumentException("Store name must not be null"); } if (store.getWorkspace() == null) { throw new IllegalArgumentException("Store must be part of a workspace"); } WorkspaceInfo workspace = store.getWorkspace(); StoreInfo existing = getStoreByName(workspace, store.getName(), StoreInfo.class); if (existing != null && (isNew || !existing.getId().equals(store.getId()))) { String msg = "Store '" + store.getName() + "' already exists in workspace '" + workspace.getName() + "'"; throw new IllegalArgumentException(msg); } return postValidate(store, isNew); }
/** * Given a store and a user, returns it back if the user can access its workspace in read mode, * null otherwise */ protected <T extends StoreInfo> T checkAccess( Authentication user, T store, MixedModeBehavior mixedModeBehavior) { if (store == null) return null; WrapperPolicy policy = buildWrapperPolicy(user, store.getWorkspace(), store.getName(), mixedModeBehavior); // handle the modes that do not require wrapping if (policy.level == AccessLevel.HIDDEN) return null; else if (policy.level == AccessLevel.READ_WRITE || (policy.level == AccessLevel.READ_ONLY && store instanceof CoverageStoreInfo)) return store; // otherwise we are in a mixed case where the user can read but not // write, or // cannot read but is allowed by the operation mode to access the // metadata if (store instanceof DataStoreInfo || store instanceof CoverageStoreInfo || store instanceof WMSStoreInfo || store instanceof WMTSStoreInfo) { return (T) SecuredObjects.secure(store, policy); } else { throw new RuntimeException("Unknown store type " + store.getClass()); } }
public <T extends StoreInfo> T getStoreByName( WorkspaceInfo workspace, String name, Class<T> clazz) { T result; if (workspace == ANY_WORKSPACE) { result = stores.findFirst(clazz, s -> name.equals(s.getName())); } else { Name qname = new NameImpl((workspace != null) ? workspace.getId() : null, name); result = stores.findByName(qname, clazz); } return wrapInModificationProxy(result, clazz); }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof StoreInfo)) { return false; } final StoreInfo other = (StoreInfo) obj; if (connectionParameters == null) { if (other.getConnectionParameters() != null) return false; } else if (!connectionParameters.equals(other.getConnectionParameters())) return false; if (description == null) { if (other.getDescription() != null) return false; } else if (!description.equals(other.getDescription())) return false; if (enabled != other.isEnabled()) return false; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; if (workspace == null) { if (other.getWorkspace() != null) return false; } else if (!workspace.equals(other.getWorkspace())) return false; return true; } }
protected void resolve(StoreInfo store) { setId(store); StoreInfoImpl s = (StoreInfoImpl) store; // resolve the workspace WorkspaceInfo resolved = ResolvingProxy.resolve(getCatalog(), s.getWorkspace()); if (resolved != null) { resolved = unwrap(resolved); s.setWorkspace(resolved); } else { LOGGER.log( Level.INFO, "Failed to resolve workspace for store \"" + store.getName() + "\". This means the workspace has not yet been added to the catalog, keep the proxy around"); } }
/** * Finds the directory for the resource assuming a 1.x style data directory. * * <p>Something like: * * <pre> * featureTypes/states_shapefile_states * coverages/sfdem_dem * </pre> * * @param resource The resource. * @return The directory for the resource, or null if it could not be found. */ public File findLegacyResourceDir(ResourceInfo resource) throws IOException { StoreInfo store = resource.getStore(); String dirname = store.getName() + "_" + resource.getName(); File dir = null; if (resource instanceof FeatureTypeInfo) { dir = resourceLoader.find("featureTypes", dirname); } else if (resource instanceof CoverageInfo) { dir = resourceLoader.find("coverages", dirname); } return dir != null ? dir : null; }
<T extends StoreInfo> void initStore( T s, Class<T> clazz, String sId, String name, WorkspaceInfo ws) { expect(s.getId()).andReturn(sId).anyTimes(); expect(s.getName()).andReturn(name).anyTimes(); expect(s.getWorkspace()).andReturn(ws).anyTimes(); expect(s.getCatalog()).andReturn(catalog).anyTimes(); expect(s.isEnabled()).andReturn(true).anyTimes(); expect(catalog.getStore(sId, clazz)).andReturn(s).anyTimes(); expect(catalog.getStore(sId, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(name, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws.getName(), name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws.getName(), name, StoreInfo.class)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws, name, clazz)).andReturn(s).anyTimes(); expect(catalog.getStoreByName(ws, name, StoreInfo.class)).andReturn(s).anyTimes(); }
+ resource.getName() + "' already exists in store: '" + store.getName() + "'"; throw new IllegalArgumentException(msg);
.put( "dirName", new StringBuilder(store.getName()) .append("_") .append(nativeCoverageName)
user, ((StoreInfo) info).getWorkspace(), ((StoreInfo) info).getName(), mixedModeBehavior);
public Object getPropertyValue(LayerInfo x) { return x.getResource().getStore().getName(); } };
public void setObject(T object) { super.setObject(object); if (object != null) { workspace = new WorkspaceDetachableModel(object.getWorkspace()); name = object.getName(); } else { name = null; } };
public void setObject(T object) { super.setObject(object); if (object != null) { workspace = new WorkspaceDetachableModel(object.getWorkspace()); name = object.getName(); } else { name = null; } };
@Test public void testGetAsHTML() throws Exception { List<StoreInfo> stores = catalog.getStoresByWorkspace("sf", StoreInfo.class); Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces/sf.html"); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(stores.size(), links.getLength()); for (int i = 0; i < stores.size(); i++) { StoreInfo store = stores.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(store.getName() + ".html")); } }
@After public void cleanCatalog() throws IOException { for (StoreInfo s : getCatalog().getStores(StoreInfo.class)) { removeStore(s.getWorkspace().getName(), s.getName()); } for (StyleInfo s : getCatalog().getStyles()) { String styleName = s.getName(); if (!DEFAULT_STYLEs.contains(styleName)) { removeStyle(null, styleName); } } }