@Override public String getName() { return delegate.getName(); }
public String getLoopAsString(Stack<LayerGroupInfo> path) { if (path == null) { return ""; } StringBuilder s = new StringBuilder(); for (LayerGroupInfo g : path) { s.append("/").append(g.getName()); } return s.toString(); }
/** * Retrieve the layer group configuration XML as a Resource * * @param lgi The layer group * @return A {@link Resource} */ public @Nonnull Resource config(LayerGroupInfo lgi) { Resource r = get(lgi, String.format("%s.xml", lgi.getName())); assert r != null; return r; }
private void renameLayerGroup(LayerGroupInfo lg, String newName) throws IOException { LOGGER.fine("Renaming layer group " + lg.getName() + " to " + newName); Resource xml = dd.config(lg); renameRes(xml, String.format("%s.xml", newName)); }
private void addLayerGroup(LayerGroupInfo lg) throws IOException { LOGGER.fine("Persisting layer group " + lg.getName()); Resource xml = dd.config(lg); persist(lg, xml); }
private void modifyLayerGroup(LayerGroupInfo lg) throws IOException { LOGGER.fine("Persisting layer group " + lg.getName()); Resource xml = dd.config(lg); persist(lg, xml); }
private void removeLayerGroup(LayerGroupInfo lg) throws IOException { LOGGER.fine("Removing layer group " + lg.getName()); Resource xml = dd.config(lg); rmRes(xml); }
/** * Returns the possible location of the group in the secured tree based on name and workspace * * @param layerGroup * @return */ private String[] getLayerGroupPath(LayerGroupInfo layerGroup) { if (layerGroup.getWorkspace() == null) { return new String[] {layerGroup.getName()}; } else { return new String[] {layerGroup.getWorkspace().getName(), layerGroup.getName()}; } }
public void remove(LayerInfo layer) { // ensure no references to the layer for (LayerGroupInfo lg : facade.getLayerGroups()) { if (lg.getLayers().contains(layer) || layer.equals(lg.getRootLayer())) { String msg = "Unable to delete layer referenced by layer group '" + lg.getName() + "'"; throw new IllegalArgumentException(msg); } } facade.remove(layer); removed(layer); }
public void remove(LayerGroupInfo layerGroup) { // ensure no references to the layer group for (LayerGroupInfo lg : facade.getLayerGroups()) { if (lg.getLayers().contains(layerGroup) || layerGroup.equals(lg.getRootLayer())) { String msg = "Unable to delete layer group referenced by layer group '" + lg.getName() + "'"; throw new IllegalArgumentException(msg); } } facade.remove(layerGroup); removed(layerGroup); }
void loadLayerGroups(Resource layerGroups, Catalog catalog, XStreamPersister xp) { try (AsynchResourceIterator<byte[]> it = new AsynchResourceIterator<>(layerGroups, XML_FILTER, r -> r.getContents())) { while (it.hasNext()) { try { LayerGroupInfo lg = depersist(xp, it.next(), LayerGroupInfo.class); if (lg.getLayers() == null || lg.getLayers().size() == 0) { LOGGER.warning( "Skipping empty layer group '" + lg.getName() + "', it is invalid"); continue; } catalog.add(lg); LOGGER.info("Loaded layer group '" + lg.getName() + "'"); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load layer group", e); } } } }
LayerGroupSummary(LayerGroupInfo lg) { this.id = lg.getId(); this.workspace = lg.getWorkspace() != null ? lg.getWorkspace().getName() : null; this.name = lg.getName(); this.mode = lg.getMode(); containerGroups = CONCURRENT_SET_BUILDER.apply(null); }
@Override public PublishedInfo visitNamedLayerInternal(StyledLayer namedLayer) { // If this group hasn't been added to the catalog yet, make sure it is // not referenced by a NamedLayer if (namedLayer.getName() != null && namedLayer.getName().equals(group.getName())) { throw recursionException; } LayerGroupInfo child = catalog.getLayerGroupByName(namedLayer.getName()); if (child != null) { if (isGroupInStack(child, path)) { path.push(child); throw recursionException; } else if (checkLoops(child, path)) { throw recursionException; } return child; } return null; } });
private SecureTreeNode getNodeForGroup(LayerGroupInfo lg) { SecureTreeNode node; if (lg.getWorkspace() == null) { node = root.getNode(lg.getName()); } else { String[] path = getLayerGroupPath(lg); node = root.getNode(path); } return node; }
private void cleanupGroupByName(String name) { for (LayerGroupInfo lg : new ArrayList<>(catalog.getLayerGroups())) { if (lg.getName().equals(name)) { catalog.remove(lg); } } }
public void remove(StyleInfo style) { // ensure no references to the style for (LayerInfo l : facade.getLayers(style)) { throw new IllegalArgumentException( "Unable to delete style referenced by '" + l.getName() + "'"); } for (LayerGroupInfo lg : facade.getLayerGroups()) { if (lg.getStyles().contains(style) || style.equals(lg.getRootLayerStyle())) { String msg = "Unable to delete style referenced by layer group '" + lg.getName() + "'"; throw new IllegalArgumentException(msg); } } if (isDefaultStyle(style)) { throw new IllegalArgumentException("Unable to delete a default style"); } facade.remove(style); removed(style); }
@Override public LayerGroupInfo getLayerGroupByName(WorkspaceInfo workspace, String name) { LayerGroupInfo match; if (workspace == NO_WORKSPACE) { match = layerGroups.findByName(new NameImpl(null, name), LayerGroupInfo.class); } else if (ANY_WORKSPACE == workspace) { match = layerGroups.findFirst(LayerGroupInfo.class, lg -> name.equals(lg.getName())); } else { match = layerGroups.findByName( new NameImpl(workspace.getId(), name), LayerGroupInfo.class); } return wrapInModificationProxy(match, LayerGroupInfo.class); }
if (catalog.getLayerGroupByName(LocalWorkspace.get(), layerGroup.getName()) != null) { return true;
private void testSerializationWithMode(Mode mode) throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); LayerGroupInfo group1 = cFactory.createLayerGroup(); group1.setName("foo"); group1.setTitle("foo title"); group1.setAbstract("foo abstract"); group1.setMode(mode); ByteArrayOutputStream out = out(); persister.save(group1, out); // print(in(out)); ByteArrayInputStream in = in(out); LayerGroupInfo group2 = persister.load(in, LayerGroupInfo.class); assertEquals(group1.getName(), group2.getName()); assertEquals(group1.getTitle(), group2.getTitle()); assertEquals(group1.getAbstract(), group2.getAbstract()); assertEquals(group1.getMode(), group2.getMode()); Document dom = dom(in(out)); assertEquals("layerGroup", dom.getDocumentElement().getNodeName()); }
assertNull(catalog.getWorkspaceByName(ws.getName())); assertNull(catalog.getStyleByName(style.getName())); assertNull(catalog.getLayerGroupByName(lg.getName()));