/** * Helper method that will make sure that the namespace associated to the provided workspace has * the same isolation. * * <p>If the associated namespace doesn't exists nothing will be done. * * @param workspace a catalog workspace */ private void syncNamespaceIsolation(WorkspaceInfo workspace) { // get the namespace associated to the workspace, may be NULL NamespaceInfo namespace = catalog.getNamespaceByPrefix(workspace.getName()); if (namespace != null && workspace.isIsolated() != namespace.isIsolated()) { // update the namespace isolation namespace.setIsolated(workspace.isIsolated()); catalog.save(namespace); } }
/** * Helper method that checks if the provided workspace is visible in the current context. * * <p>This method returns TRUE if the provided workspace is one of the default ones * (NO_WORKSPACE or ANY_WORKSPACE) or if the provided workspace is NULL or is not isolated. If * no OWS service request is in progress TRUE will also be returned. * * <p>If none of the conditions above is satisfied, then if a local workspace exists (i.e. we * are in the context of a virtual service) and if the local workspace matches the provided * workspace TRUE is returned, otherwise FALSE is returned. * * @param workspace the workspace to check for visibility * @return TRUE if the workspace is visible in the current context, otherwise FALSE */ private boolean canSeeWorkspace(WorkspaceInfo workspace) { if (workspace == CatalogFacade.NO_WORKSPACE || workspace == CatalogFacade.ANY_WORKSPACE || workspace == null || !workspace.isIsolated() || Dispatcher.REQUEST.get() == null) { // the workspace content is visible in this context return true; } WorkspaceInfo localWorkspace = getLocalWorkspace(); // the workspace content will be visible only if we are in the context of one // of its virtual services return localWorkspace != null && Objects.equals(localWorkspace.getName(), workspace.getName()); }
public ValidationResult validate(WorkspaceInfo workspace, boolean isNew) { if (workspace.isIsolated() && !getCatalogCapabilities().supportsIsolatedWorkspaces()) { // isolated namespaces \ workspaces are not supported by this catalog throw new IllegalArgumentException( String.format( "Workspace '%s' is isolated but isolated workspaces are not supported by this catalog.", workspace.getName())); } if (isNull(workspace.getName())) { throw new NullPointerException("workspace name must not be null"); } if (workspace.getName().equals(DEFAULT)) { throw new IllegalArgumentException( DEFAULT + " is a reserved keyword, can't be used as the workspace name"); } WorkspaceInfo existing = getWorkspaceByName(workspace.getName()); if (existing != null && !existing.getId().equals(workspace.getId())) { throw new IllegalArgumentException( "Workspace named '" + workspace.getName() + "' already exists."); } return postValidate(workspace, isNew); }
/** Helper method that checks that the provided workspace has the expected content. */ protected void checkWorkspace( WorkspaceInfo workspace, String expectedPrefix, boolean expectedIsolation) { assertThat(workspace, notNullValue()); assertThat(workspace.getName(), is(expectedPrefix)); assertThat(workspace.isIsolated(), is(expectedIsolation)); }
/** * Helper method that will make sure that the workspace associated to the provided namespace has * the same isolation. * * <p>If the associated namespace doesn't exists nothing will be done. * * @param namespace a catalog namespace */ private void syncWorkspaceIsolation(NamespaceInfo namespace) { // get the workspace associated to the namespace, may be NULL WorkspaceInfo workspace = catalog.getWorkspaceByName(namespace.getPrefix()); if (workspace != null && namespace.isIsolated() != workspace.isIsolated()) { // update the workspace isolation workspace.setIsolated(namespace.isIsolated()); catalog.save(workspace); } } }
@Test public void testAddIsolatedWorkspace() { // create isolated workspace WorkspaceInfoImpl workspace = new WorkspaceInfoImpl(); workspace.setName("isolated_workspace"); workspace.setIsolated(true); try { // add it to the catalog catalog.add(workspace); // retrieve the isolated workspace WorkspaceInfo foundWorkspace = catalog.getWorkspaceByName("isolated_workspace"); assertThat(foundWorkspace.isIsolated(), is(true)); } finally { // remove the isolated workspace catalog.remove(workspace); } }
@Override protected Component getComponentForProperty( String id, IModel<WorkspaceInfo> itemModel, Property<WorkspaceInfo> property) { if (property == NAME) { return workspaceLink(id, itemModel); } else if (property == DEFAULT) { if (getCatalog() .getDefaultWorkspace() .equals(itemModel.getObject())) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } else if (property == ISOLATED) { if (itemModel.getObject().isIsolated()) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new IllegalArgumentException( "No such property " + property.getName()); }
namespace.setPrefix(workspace.getName()); namespace.setURI("http://" + workspace.getName()); namespace.setIsolated(workspace.isIsolated()); catalog.add(namespace);
WorkspaceInfo workspaceInfo = (WorkspaceInfo) wsModel.getObject(); namespaceInfo.setIsolated(workspaceInfo.isIsolated());
assertThat(workspace.isIsolated(), is(true)); assertThat(workspace.isIsolated(), is(false));
assertThat(workspace.isIsolated(), is(true)); assertThat(workspace.isIsolated(), is(false));
namespace.setPrefix(workspace.getName()); namespace.setURI(nsUriTextField.getDefaultModelObjectAsString()); namespace.setIsolated(workspace.isIsolated());