@Override public NamespaceInfo getNamespaceByURI(String uri) { NamespaceInfo localNamespace = getLocalNamespace(); if (localNamespace != null && Objects.equals(localNamespace.getURI(), uri)) { // local workspace namespace URI is equal to the provided URI return localNamespace; } // let's see if there is any global namespace matching the provided uri for (NamespaceInfo namespace : facade.getNamespacesByURI(uri)) { if (!namespace.isIsolated()) { // we found a global namespace return namespace; } } // no global namespace found return null; }
/** * 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); } } }
public ValidationResult validate(NamespaceInfo namespace, boolean isNew) { if (namespace.isIsolated() && !getCatalogCapabilities().supportsIsolatedWorkspaces()) { if (!namespace.isIsolated()) {
/** Helper method that checks that the provided namespace has the expected content. */ protected void checkNamespace( NamespaceInfo namespace, String expectedPrefix, String expectedNamespaceUri, boolean expectedIsolation) { assertThat(namespace, notNullValue()); assertThat(namespace.getPrefix(), is(expectedPrefix)); assertThat(namespace.getName(), is(expectedPrefix)); assertThat(namespace.getURI(), is(expectedNamespaceUri)); assertThat(namespace.isIsolated(), is(expectedIsolation)); }
/** * 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); } }
assertThat(foundNamespace1.getPrefix(), is("isolated_namespace_1")); assertThat(foundNamespace1.getURI(), is("http://www.isolated_namespace.com")); assertThat(foundNamespace1.isIsolated(), is(false)); assertThat(foundNamespace2.isIsolated(), is(true)); assertThat(foundNamespace3.getPrefix(), is("isolated_namespace_1")); assertThat(foundNamespace3.getURI(), is("http://www.isolated_namespace.com")); assertThat(foundNamespace3.isIsolated(), is(false));
@PostMapping( consumes = { MediaType.TEXT_XML_VALUE, MediaType.APPLICATION_XML_VALUE, MediaTypeExtensions.TEXT_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE } ) @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<String> namespacePost( @RequestBody NamespaceInfo namespace, UriComponentsBuilder builder) { catalog.add(namespace); String name = namespace.getName(); LOGGER.info("Added namespace " + name); // JD: we need to keep namespace and workspace in sync, so create a worksapce // if one does not already exists, we can remove this once we get to a point // where namespace is just an attribute on a layer, and not a containing element if (catalog.getWorkspaceByName(namespace.getPrefix()) == null) { WorkspaceInfo ws = catalog.getFactory().createWorkspace(); ws.setName(namespace.getPrefix()); ws.setIsolated(namespace.isIsolated()); catalog.add(ws); } // build the new path UriComponents uriComponents = getUriComponents(name, builder); HttpHeaders headers = new HttpHeaders(); headers.setLocation(uriComponents.toUri()); return new ResponseEntity<>(name, headers, HttpStatus.CREATED); }
assertThat(namespace.isIsolated(), is(true)); assertThat(namespace.isIsolated(), is(false));
assertThat(namespace.isIsolated(), is(true)); assertThat(namespace.isIsolated(), is(false));