@Override public WorkspaceInfo getWorkspace() { return delegate.getWorkspace(); }
LayerGroupInfo check(LayerGroupInfo layerGroup) { if (LocalWorkspace.get() != null) { if (layerGroup.getWorkspace() != null && !LocalWorkspace.get().equals(layerGroup.getWorkspace())) { return null; } } return layerGroup; }
/** * Retrieve a resource in the the configuration directory of a LayerGroup. An empty path will * retrieve the directory itself. This directory is shared by all Layer Groups in a Workspace. * * @param lgi The store * @return A {@link Resource} */ public @Nonnull Resource get(LayerGroupInfo lgi, String... path) { WorkspaceInfo wsi = lgi.getWorkspace(); Resource r = getLayerGroups(wsi, path); assert r != null; return r; }
/** * Checks if the provided layer group is visible in the current context. Note that layer group * contained layer groups will not be filtered. * * @param layerGroup the layer group to check, may be NULL * @return the layer group if visible, otherwise NULL */ private <T extends LayerGroupInfo> T enforceLayerGroupIsolation(T layerGroup) { if (layerGroup == null) { // nothing to do, the layer group is already NULL return null; } WorkspaceInfo workspace = layerGroup.getWorkspace(); // check if the layer group workspace is visible in this context return canSeeWorkspace(workspace) ? layerGroup : null; }
/** * 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()}; } }
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); }
public List<LayerGroupInfo> getLayerGroupsByWorkspace(WorkspaceInfo workspace) { // TODO: support ANY_WORKSPACE? WorkspaceInfo ws; if (workspace == null) { ws = getDefaultWorkspace(); } else { ws = workspace; } Predicate<LayerGroupInfo> predicate; if (workspace == NO_WORKSPACE) { predicate = lg -> lg.getWorkspace() == null; } else { predicate = lg -> ws.equals(lg.getWorkspace()); } List<LayerGroupInfo> matches = layerGroups.list(LayerGroupInfo.class, predicate); return ModificationProxy.createList(matches, LayerGroupInfo.class); }
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 checkLayerGroupResourceIsInWorkspace(LayerGroupInfo layerGroup, WorkspaceInfo ws) { if (layerGroup == null) return; if (layerGroup.getWorkspace() != null && !ws.equals(layerGroup.getWorkspace())) { throw new IllegalArgumentException( "Layer group within a workspace (" + ws.getName() + ") can not contain resources from other workspace: " + layerGroup.getWorkspace().getName()); } checkLayerGroupResourceIsInWorkspace(layerGroup.getRootLayer(), ws); checkLayerGroupResourceIsInWorkspace(layerGroup.getRootLayerStyle(), ws); if (layerGroup.getLayers() != null) { for (PublishedInfo p : layerGroup.getLayers()) { if (p instanceof LayerGroupInfo) { checkLayerGroupResourceIsInWorkspace((LayerGroupInfo) p, ws); } else if (p instanceof LayerInfo) { checkLayerGroupResourceIsInWorkspace((LayerInfo) p, ws); } } } if (layerGroup.getStyles() != null) { for (StyleInfo s : layerGroup.getStyles()) { checkLayerGroupResourceIsInWorkspace(s, ws); } } }
if (layerGroup.getWorkspace() == null) { if (workspaceLayerGroupInherit()) { return hideWorkspace(layerGroup.getWorkspace());
WorkspaceInfo ws = layerGroup.getWorkspace(); LayerGroupInfo existing = getLayerGroupByName(ws, layerGroup.getName()); if (existing != null && !existing.getId().equals(layerGroup.getId())) { WorkspaceInfo ews = existing.getWorkspace(); if ((ws == null && ews == null) || (ws != null && ws.equals(ews))) { String msg = "Layer group named '" + layerGroup.getName() + "' already exists";
result = prime * result + ((lg.getTitle() == null) ? 0 : lg.getTitle().hashCode()); result = prime * result + ((lg.getAbstract() == null) ? 0 : lg.getAbstract().hashCode()); result = prime * result + ((lg.getWorkspace() == null) ? 0 : lg.getWorkspace().hashCode()); result = prime * result + ((lg.getStyles() == null) ? 0 : lg.getStyles().hashCode()); result = prime * result + ((lg.getRootLayer() == null) ? 0 : lg.getRootLayer().hashCode());
if (lg.getWorkspace() == null) { if (other.getWorkspace() != null) return false; } else if (!lg.getWorkspace().equals(other.getWorkspace())) return false;
expect(lg1.getWorkspace()).andReturn(ws1).anyTimes(); replay(lg1); expect(lg2.getWorkspace()).andReturn(ws2).anyTimes(); replay(lg2);
} else { limits = accessManager.getAccessLimits(user, (LayerGroupInfo) info, containers); ws = ((LayerGroupInfo) info).getWorkspace();
public String getWorkspace() { if (layerInfo != null) { return layerInfo.getResource().getStore().getWorkspace().getName(); } else if (groupInfo != null && groupInfo.getWorkspace() != null) { return groupInfo.getWorkspace().getName(); } return null; }
private long getWorkspaceAccessibleGroupSize(String workspaceName) { return catalog.getLayerGroups() .stream() .filter( lg -> lg.getWorkspace() == null || workspaceName.equals(lg.getWorkspace().getName())) .count(); }
@Override protected void onSelectionUpdate(AjaxRequestTarget target) { if (!table.getSelection().isEmpty()) { boolean canRemove = true; if (!isAuthenticatedAsAdmin()) { // if any global layer groups are selected, don't allow // delete for (LayerGroupInfo lg : table.getSelection()) { if (lg.getWorkspace() == null) { canRemove = false; break; } } } removal.setEnabled(canRemove); } else { removal.setEnabled(false); } target.add(removal); } });
private void postInit() { if (!isAuthenticatedAsAdmin() && !isNew) { // global layer groups only editable by full admin if (getPublishedInfo().getWorkspace() == null) { // disable all form components but cancel setInputEnabled(false); info(new StringResourceModel("globalLayerGroupReadOnly", this, null).getString()); } } }
@Test public void testGetLayerGroup() throws Exception { // create mocks final LayerGroupInfo lg = createNiceMock(LayerGroupInfo.class); expect(lg.getWorkspace()).andReturn(null); final ArrayList<PublishedInfo> layers = new ArrayList<PublishedInfo>(); expect(lg.getLayers()).andReturn(layers); replay(lg); final Catalog catalog = createNiceMock(Catalog.class); expect(catalog.getLayerGroup("lg")).andReturn(lg); replay(catalog); // tests final Catalog secureCatalog = new SecureCatalogImpl(catalog); final LayerGroupInfo layerGroup = secureCatalog.getLayerGroup("lg"); assertTrue(layerGroup instanceof SecuredLayerGroupInfo); assertTrue(((SecuredLayerGroupInfo) layerGroup).unwrap(LayerGroupInfo.class) == lg); }