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 Details

    • create

      @Nullable public static @Nullable NamespaceRegistryModel create(@NotNull @NotNull Root root)
      Creates a new NamespaceRegistryModel from the namespace registry stored in the system tree under the given repository Root.
      Parameters:
      root - the root of the repository
      Returns:
      a new NamespaceRegistryModel or null if the namespace registry does not exist
    • setMappings

      public NamespaceRegistryModel setMappings(@NotNull @NotNull Map<String,String> additionalPrefixToUrisMappings)
      Creates a new NamespaceRegistryModel 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

      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 repository Root.
      Parameters:
      root - the root of the repository
      Throws:
      RepositoryException - if an error occurs while applying the changes
      CommitFailedException - 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 the setMappings(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 the setMappings(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 given OutputStream.
      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