Class DefaultWorkspaceFilter

java.lang.Object
org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter
All Implemented Interfaces:
Dumpable, WorkspaceFilter
Direct Known Subclasses:
ScopedWorkspaceFilter

public class DefaultWorkspaceFilter extends Object implements Dumpable, WorkspaceFilter
Holds a list of PathFilterSets.
  • Field Details

  • Constructor Details

    • DefaultWorkspaceFilter

      public DefaultWorkspaceFilter()
  • Method Details

    • add

      public void add(PathFilterSet set)
      Add a #PathFilterSet for nodes items.
      Parameters:
      set - the set of filters to add.
    • add

      public void add(PathFilterSet nodeFilter, PathFilterSet propFilter)
      Add a #PathFilterSet for node and property items.
      Parameters:
      nodeFilter - the set of filters to add.
      propFilter - the set of filters to add.
    • addPropertyFilterSet

      @Deprecated public void addPropertyFilterSet(PathFilterSet set)
      Deprecated.
      Add a #PathFilterSet for properties items.
      Parameters:
      set - the set of filters to add.
    • getFilterSets

      public List<PathFilterSet> getFilterSets()
      Returns a list of path filter sets for node items.
      Specified by:
      getFilterSets in interface WorkspaceFilter
      Returns:
      the list of path filter sets.
    • getPropertyFilterSets

      public List<PathFilterSet> getPropertyFilterSets()
      Returns a list of path filter sets for property items.
      Specified by:
      getPropertyFilterSets in interface WorkspaceFilter
      Returns:
      the list of path filter sets.
    • getCoveringFilterSet

      public PathFilterSet getCoveringFilterSet(String path)
      Returns the filter set that covers the respective node path
      Specified by:
      getCoveringFilterSet in interface WorkspaceFilter
      Parameters:
      path - the path
      Returns:
      the filter set or null
    • getImportMode

      public ImportMode getImportMode(String path)
      Returns the import mode for the given node path.
      Specified by:
      getImportMode in interface WorkspaceFilter
      Parameters:
      path - path to check
      Returns:
      the import mode or ImportMode.REPLACE if the given path is not covered by this filter.
    • setImportMode

      public void setImportMode(ImportMode importMode)
    • contains

      public boolean contains(String path)
      Checks if the given node path is contained (and by that also covered) in this workspace filter. It returns true if any of the filter sets contain the path and it's not globally ignored.

      If WorkspaceFilter.contains(String) returns true for one path, also WorkspaceFilter.covers(String) would return true for the same path, but not vice-versa.

      Specified by:
      contains in interface WorkspaceFilter
      Parameters:
      path - to check
      Returns:
      true if the given path is included in this filter.
    • covers

      public boolean covers(String path)
      Checks if the given node path is covered in this workspace filter. It only returns true if at least one of the sets covers the path and is not globally ignored.

      Still WorkspaceFilter.contains(String) might return false for the same path in case there is some exclusion patterns matching the given path.

      Specified by:
      covers in interface WorkspaceFilter
      Parameters:
      path - the path to check
      Returns:
      true if the given path is covered by this filter.
    • includesProperty

      public boolean includesProperty(String propertyPath)
      Description copied from interface: WorkspaceFilter
      Tests if the given workspace filter includes the given property. If the filter does not cover the property, it returns true.
      Specified by:
      includesProperty in interface WorkspaceFilter
      Parameters:
      propertyPath - the path to the property
      Returns:
      true if the property is included in the filter
    • isAncestor

      public boolean isAncestor(String path)
      Checks if the given node path is an ancestor of any of the filter sets.
      Specified by:
      isAncestor in interface WorkspaceFilter
      Parameters:
      path - the item to check
      Returns:
      true if the given item is an ancestor
    • isGloballyIgnored

      public boolean isGloballyIgnored(String path)
      Checks if the given node path is globally ignored.
      Specified by:
      isGloballyIgnored in interface WorkspaceFilter
      Parameters:
      path - the path to check.
      Returns:
      true if the item is globally ignored.
    • translate

      public WorkspaceFilter translate(PathMapping mapping)
      Translates this workspace filter using the given path mapping.
      Specified by:
      translate in interface WorkspaceFilter
      Parameters:
      mapping - the path mapping
      Returns:
      a new workspace filter
    • load

      public void load(File file) throws IOException, ConfigurationException
      Loads the workspace filter from the given file
      Parameters:
      file - source
      Throws:
      ConfigurationException - if the source is not valid
      IOException - if an I/O error occurs
    • getSource

      public InputStream getSource()
      Returns the source xml that constructs this filter It is the obligation of the caller to close the returned input stream.
      Specified by:
      getSource in interface WorkspaceFilter
      Returns:
      the source xml
    • getSourceAsString

      public String getSourceAsString()
      Returns the source xml that constructs this filter
      Specified by:
      getSourceAsString in interface WorkspaceFilter
      Returns:
      the source xml
    • load

      public void load(InputStream in) throws IOException, ConfigurationException
      Loads the workspace filter from the given input source.

      The specified stream remains open after this method returns.

      Parameters:
      in - source
      Throws:
      ConfigurationException - if the source is not valid
      IOException - if an I/O error occurs
    • load

      public void load(Element doc) throws ConfigurationException
      Throws:
      ConfigurationException
    • dump

      public void dump(DumpContext ctx, boolean isLast)
      Dumps some human readable information using the given context.
      Specified by:
      dump in interface Dumpable
      Parameters:
      ctx - the dump context
      isLast - specifies if this is the last element to dump on this level
    • resetSource

      public void resetSource()
      Resets the source content to a null state. This leads to generating the source from scratch if necessary. Is called implicitly for every modifying operation (add(PathFilterSet), add(PathFilterSet, PathFilterSet), addPropertyFilterSet(PathFilterSet), load(Element), load(InputStream) and load(File)).
    • setGlobalIgnored

      public void setGlobalIgnored(PathFilter ignored)
    • dumpCoverage

      public void dumpCoverage(Node rootNode, ProgressTrackerListener listener) throws RepositoryException
      Dumps the coverage of this filter against the given node to the listener.
      Specified by:
      dumpCoverage in interface WorkspaceFilter
      Parameters:
      rootNode - root node
      listener - listener which receives coverage information
      Throws:
      RepositoryException - if an error occurs
    • dumpCoverage

      public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) throws RepositoryException
      Dumps the coverage of this filter using the given session. If skipJcrContent is true the jcr:content nodes are excluded from traversal and reporting.
      Specified by:
      dumpCoverage in interface WorkspaceFilter
      Parameters:
      session - session
      listener - listener which receives coverage information
      skipJcrContent - true to skip jcr:content nodes
      Throws:
      RepositoryException - if an error occurs
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object