/** * Removes a store from the catalog. * * <p>The <tt>recursive</tt> flag controls whether objects linked to the store such as resources * should also be deleted. */ public void removeStore(StoreInfo store, boolean recursive) { if (recursive) { store.accept(new CascadeDeleteVisitor(catalog)); } else { catalog.remove(store); } }
public void visit(WorkspaceInfo workspace) { // drill down on stores List<StoreInfo> stores = catalog.getStoresByWorkspace(workspace, StoreInfo.class); for (StoreInfo storeInfo : stores) { storeInfo.accept(this); } // drill into namespaces // catalog.getNamespaceByPrefix(workspace.getName()).accept(this); // drill down into styles for (StyleInfo style : catalog.getStylesByWorkspace(workspace)) { style.accept(this); } // drill down into groups for (LayerGroupInfo group : catalog.getLayerGroupsByWorkspace(workspace)) { group.accept(this); } // add self add(workspace, ModificationType.DELETE); }
public void visit(WorkspaceInfo workspace) { // remove owned stores for (StoreInfo s : catalog.getStoresByWorkspace(workspace, StoreInfo.class)) { s.accept(this); } // remove any linked namespaces NamespaceInfo ns = catalog.getNamespaceByPrefix(workspace.getName()); if (ns != null) { ns.accept(this); } // remove styles contained in this workspace for (StyleInfo style : catalog.getStylesByWorkspace(workspace)) { style.accept(this); } // remove layer groups contained in this workspace for (LayerGroupInfo group : catalog.getLayerGroupsByWorkspace(workspace)) { group.accept(this); } catalog.remove(workspace); }
/** * Recursively deletes a store and everything under it. * * <p>If the store does not exist, this method will do nothing rather than fail. * * <p>This method is intended to be called after system startup. Typically from {@link * #onSetUp(SystemTestData)} or a {@literal @}Before hook. * * @param workspaceName Name of the workspace of the store. * @param name Name of the store. */ protected void removeStore(String workspaceName, String name) { Catalog cat = getCatalog(); StoreInfo store = cat.getStoreByName(workspaceName, name, StoreInfo.class); if (store == null) { return; } CascadeDeleteVisitor v = new CascadeDeleteVisitor(getCatalog()); store.accept(v); }
@Test public void testDeleteAllOneByOne() throws Exception { for (WorkspaceInfo ws : getCatalog().getWorkspaces()) { // empty the workspace otherwise we can't remove it CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(getCatalog()); for (StoreInfo store : getCatalog().getStoresByWorkspace(ws, StoreInfo.class)) { store.accept(visitor); } // actually go and remove the store String resource = RestBaseController.ROOT_PATH + "/workspaces/" + ws.getName(); assertEquals(200, deleteAsServletResponse(resource).getStatus()); assertEquals(404, getAsServletResponse(resource).getStatus()); } Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces.xml"); assertEquals(0, dom.getElementsByTagName("workspace").getLength()); }
if (si != null) si.accept(deleteVisitor);