jsr-333
  1. jsr-333
  2. JSR_333-17

Provide a Node#setMixins(String[] mixinNames) method

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: api
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      17

      Description

      assume the following scenario:

      • mixin A declares the mandatory property p
      • mixin A' extends from A
      • node n has mixin A'
      • we'd like to migrate/downgrade node n from mixin A' to A

      with an implementation where addMixin/removeMixin take effect
      immediately, there's no easy way of replacing the assigned mixins.

      assigning A first results in a NOP since A would be redundant.
      removing A' first removes the mandatory property p.

      a new method Node.setMixins(String[]) would allow to migrate
      a node from mixin A' to A while preserving 'shared' content.
      the semantics of Node.setMixins(String[]) would be similar to
      Node.setPrimaryType(String).

      related Apache Jackrabbit issues:

      https://issues.apache.org/jira/browse/JCR-2011
      https://issues.apache.org/jira/browse/JCR-2772

        Activity

        Hide
        stefan_guggisberg added a comment -

        corresponding Apache Jackrabbit issue:
        https://issues.apache.org/jira/browse/JCR-2788

        Show
        stefan_guggisberg added a comment - corresponding Apache Jackrabbit issue: https://issues.apache.org/jira/browse/JCR-2788
        Hide
        Peeter Piegaze added a comment -

        Added the following method to Node:

        /**

        • Sets this node's mixin node types to those named in <code>mixinNames</code> and sets the
        • this node's <code>jcr:mixinTypes</code> property accordingly. Any previous mixins are removed.
        • <p>
        • Semantically, the new node type <i>may</i> take effect immediately, on
        • dispatch or on persist. The behavior adopted must be the same as the
        • behavior adopted for {@link #setPrimaryType}

          and the behavior that occurs

        • when a node is first created.
        • <p>
        • This method adds (and if necessary removes) mixins in a single atomic step, avoiding
        • constraint violations that might occur if the steps were done individually. This can be
        • useful when changing node types while preserving existing content.
        • <p>
        • A <code>ConstraintViolationException</code> is thrown either immediately,
        • on dispatch or on persist, if a conflict occurs within set of assigned mixins or
        • the primary node type or for an implementation-specific reason.
        • Implementations may differ on when this validation is done.
        • <p>
        • In some implementations it may only be possible to set mixin types before
        • a a node is persisted <i>for the first time</i>. In such cases any later
        • calls to <code>setMixin</code> will throw a <code>ConstraintViolationException</code>
        • either immediately, on dispatch or on persist.
        • <p>
        • A <code>NoSuchNodeTypeException</code> is thrown either immediately, on
        • dispatch or on persist, if one or more of the specified <code>mixinNames</code> are not
        • recognized. Implementations may differ on when this validation is done.
        • <p>
        • A <code>VersionException</code> is thrown either immediately, on dispatch
        • or on persist, if this node is read-only due to a checked-in node.
        • Implementations may differ on when this validation is done.
        • <p>
        • A <code>LockException</code> is thrown either immediately, on dispatch or
        • on persist, if a lock prevents the addition of the mixin. Implementations
        • may differ on when this validation is done.
          *
        • @param mixinNames the names of the mixin node types to be set
        • @throws NoSuchNodeTypeException If one or more of the specified <code>mixinNames</code>
        • are not recognized and this implementation performs this validation
        • immediately.
        • @throws ConstraintViolationException if the specified mixin node types
        • create a conflict and this implementation performs this validation
        • immediately.
        • @throws VersionException if this node is read-only due to a checked-in
        • node and this implementation performs this validation immediately.
        • @throws LockException if a lock prevents the addition of the mixins and
        • this implementation performs this validation immediately.
        • @throws RepositoryException if another error occurs.
        • @since JCR 2.1
          */
          public void setMixins(String[] mixinNames) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException;
        Show
        Peeter Piegaze added a comment - Added the following method to Node: /** Sets this node's mixin node types to those named in <code>mixinNames</code> and sets the this node's <code>jcr:mixinTypes</code> property accordingly. Any previous mixins are removed. <p> Semantically, the new node type <i>may</i> take effect immediately, on dispatch or on persist. The behavior adopted must be the same as the behavior adopted for {@link #setPrimaryType} and the behavior that occurs when a node is first created. <p> This method adds (and if necessary removes) mixins in a single atomic step, avoiding constraint violations that might occur if the steps were done individually. This can be useful when changing node types while preserving existing content. <p> A <code>ConstraintViolationException</code> is thrown either immediately, on dispatch or on persist, if a conflict occurs within set of assigned mixins or the primary node type or for an implementation-specific reason. Implementations may differ on when this validation is done. <p> In some implementations it may only be possible to set mixin types before a a node is persisted <i>for the first time</i>. In such cases any later calls to <code>setMixin</code> will throw a <code>ConstraintViolationException</code> either immediately, on dispatch or on persist. <p> A <code>NoSuchNodeTypeException</code> is thrown either immediately, on dispatch or on persist, if one or more of the specified <code>mixinNames</code> are not recognized. Implementations may differ on when this validation is done. <p> A <code>VersionException</code> is thrown either immediately, on dispatch or on persist, if this node is read-only due to a checked-in node. Implementations may differ on when this validation is done. <p> A <code>LockException</code> is thrown either immediately, on dispatch or on persist, if a lock prevents the addition of the mixin. Implementations may differ on when this validation is done. * @param mixinNames the names of the mixin node types to be set @throws NoSuchNodeTypeException If one or more of the specified <code>mixinNames</code> are not recognized and this implementation performs this validation immediately. @throws ConstraintViolationException if the specified mixin node types create a conflict and this implementation performs this validation immediately. @throws VersionException if this node is read-only due to a checked-in node and this implementation performs this validation immediately. @throws LockException if a lock prevents the addition of the mixins and this implementation performs this validation immediately. @throws RepositoryException if another error occurs. @since JCR 2.1 */ public void setMixins(String[] mixinNames) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException;

          People

          • Assignee:
            Peeter Piegaze
            Reporter:
            stefan_guggisberg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: