@Override public Collection<String> getPrefixes(String namespaceURI) throws NamespaceException { if (uris.contains(namespaceURI)) { return prefixes; } else { throw new NamespaceException("Unrecognised namespace: " + namespaceURI); } }
@Override public String getNamespaceURI(String prefix) throws NamespaceException { if (prefixes.contains(prefix)) { return "http://www.alfresco.org/model/foo/1.0"; } else { throw new NamespaceException("Unrecognised prefix: " + prefix); } } };
throw new NamespaceException("Unregistrered prefix " + components[0]);
throw new NamespaceException("Unregistrered prefix " + components[0]);
static NamespacePrefixResolver mockNamespacePrefixResolver() { NamespacePrefixResolver mockNamespacePrefixResolver = Mockito.mock(NamespacePrefixResolver.class, new ThrowsException(new NamespaceException("Mock exception "))); Mockito.doReturn(Arrays.<String> asList(SiteModel.SITE_MODEL_PREFIX)).when(mockNamespacePrefixResolver).getPrefixes(SiteModel.SITE_MODEL_URL); Mockito.doReturn(SiteModel.SITE_MODEL_URL).when(mockNamespacePrefixResolver).getNamespaceURI(SiteModel.SITE_MODEL_PREFIX); Mockito.doReturn(Arrays.<String> asList(NamespaceService.CONTENT_MODEL_PREFIX)).when(mockNamespacePrefixResolver) .getPrefixes(NamespaceService.CONTENT_MODEL_1_0_URI); Mockito.doReturn(NamespaceService.CONTENT_MODEL_1_0_URI).when(mockNamespacePrefixResolver) .getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX); Mockito.doReturn("mock(NamespacePrefixResolver)@" + TypeVirtualizationMethod.class.toString()).when(mockNamespacePrefixResolver).toString(); return mockNamespacePrefixResolver; }
/** * {@inheritDoc} */ public void addProperty(RegistryKey key, Serializable value) { if (key.getProperty() == null) { throw new IllegalArgumentException("Registry values must be added using paths that contain property names: " + key); } // Check the namespace being used in the key String namespaceUri = key.getNamespaceUri(); if (!namespaceService.getURIs().contains(namespaceUri)) { throw new NamespaceException("Unable to add a registry value with an unregistered namespace: " + namespaceUri); } // Get the path, with creation support Pair<NodeRef, QName> keyPair = getPath(key, true); // We know that the node exists, so just set the value nodeService.setProperty(keyPair.getFirst(), keyPair.getSecond(), value); // Done if (logger.isDebugEnabled()) { logger.debug("Added value to registry: \n" + " Key: " + key + "\n" + " Value: " + value); } }
/** * {@inheritDoc} */ public void addProperty(RegistryKey key, Serializable value) { if (key.getProperty() == null) { throw new IllegalArgumentException("Registry values must be added using paths that contain property names: " + key); } // Check the namespace being used in the key String namespaceUri = key.getNamespaceUri(); if (!namespaceService.getURIs().contains(namespaceUri)) { throw new NamespaceException("Unable to add a registry value with an unregistered namespace: " + namespaceUri); } // Get the path, with creation support Pair<NodeRef, QName> keyPair = getPath(key, true); // We know that the node exists, so just set the value nodeService.setProperty(keyPair.getFirst(), keyPair.getSecond(), value); // Done if (logger.isDebugEnabled()) { logger.debug("Added value to registry: \n" + " Key: " + key + "\n" + " Value: " + value); } }