Class NamespaceRegistryModel
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.name.NamespaceRegistryModel
-
public final class NamespaceRegistryModel extends Object
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(Root root)
Applies this namespace registry model to the given repositoryRoot
.static @Nullable NamespaceRegistryModel
create(@NotNull Root root)
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
dump(Writer out)
Set<String>
getDanglingEncodedNamespaceUris()
Namespace uris that are registered, but not mapped to or from a prefix.Set<String>
getDanglingPrefixes()
Prefixes that are registered, but not mapped to or from a namespace uri.Map<String,String>
getRepairedMappings()
Broken mappings completed with the missing prefix or namespace uri.boolean
isConsistent()
boolean
isFixable()
NamespaceRegistryModel
setMappings(@NotNull Map<String,String> additionalPrefixToUrisMappings)
Creates a newNamespaceRegistryModel
with the given mappings.NamespaceRegistryModel
tryRegistryRepair()
Tries to repair the namespace registry model by fixing the mappings from prefixes to namespace URIs and vice versa.
-
-
-
Method Detail
-
create
@Nullable public static @Nullable NamespaceRegistryModel create(@NotNull @NotNull Root root)
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 {@see NamespaceRegistryCommand} 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
public 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
public void apply(Root root) throws RepositoryException, CommitFailedException
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
public Set<String> 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
public Set<String> 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
public Map<String,String> getRepairedMappings()
Broken mappings completed with the missing prefix or namespace uri.
-
dump
public void dump() throws IOException
Write a human-readable analysis of the namespace registry model to System.out.- Throws:
IOException
-
dump
public void dump(OutputStream out) throws IOException
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
public void dump(Writer out) throws IOException
- Throws:
IOException
-
-