Class TypeEditor

  • All Implemented Interfaces:
    Editor

    public class TypeEditor
    extends DefaultEditor
    Validator implementation that check JCR node type constraints. TODO: check protected properties and the structure they enforce. some of those checks may have to go into separate validator classes. This class should only perform checks based on node type information. E.g. it cannot and should not check whether the value of the protected jcr:uuid is unique.
    • Method Detail

      • create

        public static TypeEditor create​(@NotNull
                                        @NotNull TypeEditor.ConstraintViolationCallback callback,
                                        java.util.Set<java.lang.String> typesToCheck,
                                        @NotNull
                                        @NotNull NodeState types,
                                        java.lang.String primary,
                                        java.lang.Iterable<java.lang.String> mixins,
                                        @NotNull
                                        @NotNull NodeBuilder builder)
                                 throws CommitFailedException
        Creates a new TypeEditor instance
        Parameters:
        callback - the callback to use when a constraint violation is found. The client must check the results of the callback invocations if the specified callback does not immediately propagate constraint violations as checked exceptions.
        typesToCheck - the types to check for. If null, this node is checked. Otherwise it is checked if its primary type or one of it's mixin types is contained in this parameters
        types - the /jcr:system/jcr:nodeTypes node
        primary - the node's primary type
        mixins - the node's mixins
        builder - a builder containing the current state of the node to check. May be used to set a default primary type if none is set
        Returns:
        a new TypeEditor instance
        Throws:
        CommitFailedException - when the primary type of mixin definition is incorrect
      • enter

        public void enter​(NodeState before,
                          NodeState after)
                   throws CommitFailedException
        Description copied from interface: Editor
        Called before the given before and after states are compared. The implementation can use this method to initialize any internal state needed for processing the results of the comparison. For example an implementation could look up the effective node type of the after state to know what constraints to apply to on the content changes.
        Specified by:
        enter in interface Editor
        Overrides:
        enter in class DefaultEditor
        Parameters:
        before - before state, non-existent if this node was added
        after - after state, non-existent if this node was removed
        Throws:
        CommitFailedException - if this commit should be rejected
      • childNodeChanged

        public TypeEditor childNodeChanged​(java.lang.String name,
                                           NodeState before,
                                           NodeState after)
                                    throws CommitFailedException
        Description copied from interface: Editor
        Processes a changed child node. This method gets called for all child nodes that may contain changes between the before and after states.
        Specified by:
        childNodeChanged in interface Editor
        Overrides:
        childNodeChanged in class DefaultEditor
        Parameters:
        name - name of the changed node
        before - child node before the change
        after - child node after the change
        Returns:
        an editor for processing the subtree below the added node, or null if the subtree does not need processing
        Throws:
        CommitFailedException - if processing failed