Class NamespaceRegistryModel
java.lang.Object
org.apache.jackrabbit.oak.plugins.name.NamespaceRegistryModel
A model of the namespace registry, containing the mappings from prefixes to
namespace URIs and vice versa.
The model is created from the namespace registry stored in the repository. It can be used to check the consistency of the registry, repair it if possible, and apply the changes back to the repository.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies this namespace registry model to the given repositoryRoot
.static @Nullable NamespaceRegistryModel
Creates a newNamespaceRegistryModel
from the namespace registry stored in the system tree under the given repositoryRoot
.void
dump()
Write a human-readable analysis of the namespace registry model to System.out.void
dump
(OutputStream out) Write a human-readable analysis of the namespace registry model to the givenOutputStream
.void
Namespace uris that are registered, but not mapped to or from a prefix.Prefixes that are registered, but not mapped to or from a namespace uri.Broken mappings completed with the missing prefix or namespace uri.boolean
boolean
setMappings
(@NotNull Map<String, String> additionalPrefixToUrisMappings) Creates a newNamespaceRegistryModel
with the given mappings.Tries to repair the namespace registry model by fixing the mappings from prefixes to namespace URIs and vice versa.
-
Method Details
-
create
Creates a newNamespaceRegistryModel
from the namespace registry stored in the system tree under the given repositoryRoot
.- Parameters:
root
- the root of the repository- Returns:
- a new
NamespaceRegistryModel
ornull
if the namespace registry does not exist
-
setMappings
public NamespaceRegistryModel setMappings(@NotNull @NotNull Map<String, String> additionalPrefixToUrisMappings) Creates a newNamespaceRegistryModel
with the given mappings. Used by to repair a namespace registry that cannot be fixed automatically because mapping information is missing.- Parameters:
additionalPrefixToUrisMappings
- a map from prefixes to namespace URIs- Returns:
- a new
NamespaceRegistryModel
-
tryRegistryRepair
Tries to repair the namespace registry model by fixing the mappings from prefixes to namespace URIs and vice versa. If the model is not fixable, it returns the original model.- Returns:
- a new
NamespaceRegistryModel
with fixed mappings or the original model if it cannot be fixed
-
apply
Applies this namespace registry model to the given repositoryRoot
.- Parameters:
root
- the root of the repository- Throws:
RepositoryException
- if an error occurs while applying the changesCommitFailedException
- if the commit fails
-
isConsistent
public boolean isConsistent() -
isFixable
public boolean isFixable() -
getDanglingPrefixes
Prefixes that are registered, but not mapped to or from a namespace uri. This kind of inconsistency cannot be fixed automatically, because the namespace uri corresponding to the prefix is unknown. Apply thesetMappings(Map)
method to create a new model with the missing mappings. -
getDanglingEncodedNamespaceUris
Namespace uris that are registered, but not mapped to or from a prefix. This kind of inconsistency cannot be fixed automatically, because the prefix corresponding to the namespace uri is unknown. Apply thesetMappings(Map)
method to create a new model with the missing mappings. -
getRepairedMappings
Broken mappings completed with the missing prefix or namespace uri. -
dump
Write a human-readable analysis of the namespace registry model to System.out.- Throws:
IOException
-
dump
Write a human-readable analysis of the namespace registry model to the givenOutputStream
.- Parameters:
out
- the output stream to write to- Throws:
IOException
- if an error occurs while writing to the output stream
-
dump
- Throws:
IOException
-