[exo-jcr-commits] exo-jcr SVN: r2671 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services: jcr/impl/core and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jun 21 10:00:39 EDT 2010


Author: natasha.vakulenko
Date: 2010-06-21 10:00:38 -0400 (Mon, 21 Jun 2010)
New Revision: 2671

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java
Log:
JCR-1078: Was extended interface of postSetProperty() method in class SessionActionInterceptor (added parameter with previous value of property). From the calling of his method doUpdateProperty() (in class ItemImpl) comes previous value of property. In class InvocationContext was added field with previous item.

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java	2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/ext/action/InvocationContext.java	2010-06-21 14:00:38 UTC (rev 2671)
@@ -45,6 +45,11 @@
    public static final String CURRENT_ITEM = "currentItem".intern();
 
    /**
+    * Current item.
+    */
+   public static final String PREVIOUS_ITEM = "previousItem".intern();
+
+   /**
     * Context event.
     */
    public static final String EVENT = "event".intern();
@@ -88,6 +93,14 @@
    }
 
    /**
+    * @return Previous item.
+    */
+   public final Item getPreviousItem()
+   {
+      return (Item)get(PREVIOUS_ITEM);
+   }
+
+   /**
     * @return Context event
     */
    public final int getEventType()

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java	2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java	2010-06-21 14:00:38 UTC (rev 2671)
@@ -111,15 +111,12 @@
    protected ValueFactoryImpl valueFactory;
 
    /**
-   * ItemImpl constructor.
-   * 
-   * @param data
-   *          ItemData object
-   * @param session
-   *          Session object
-   * @throws RepositoryException
-   *           if any Exception is occurred
-   */
+    * ItemImpl constructor.
+    * 
+    * @param data ItemData object
+    * @param session Session object
+    * @throws RepositoryException if any Exception is occurred
+    */
    ItemImpl(ItemData data, SessionImpl session) throws RepositoryException
    {
 
@@ -137,7 +134,8 @@
    }
 
    /**
-    * Return a status of the item state. If the state is invalid the item can't be used anymore.
+    * Return a status of the item state. If the state is invalid the item can't
+    * be used anymore.
     * 
     * @return boolean flag, true if an item is usable in the session.
     */
@@ -147,7 +145,8 @@
    }
 
    /**
-    * Checking if this item has valid item state, i.e. wasn't removed (and saved).
+    * Checking if this item has valid item state, i.e. wasn't removed (and
+    * saved).
     * 
     * @return true or throws an InvalidItemStateException exception otherwise
     * @throws InvalidItemStateException
@@ -353,8 +352,8 @@
    }
 
    /**
-    * Check when it's a Node and is versionable will a version history removed. Case of last version
-    * in version history.
+    * Check when it's a Node and is versionable will a version history removed.
+    * Case of last version in version history.
     * 
     * @throws RepositoryException
     * @throws ConstraintViolationException
@@ -423,6 +422,7 @@
       NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
       NodeData parentData = (NodeData)parentNode.getData();
       boolean isMultiValue = multiValue;
+      PropertyImpl prevProperty = null;
       if (prevItem == null || prevItem.isNode())
       { // new property
          identifier = IdGenerator.generate();
@@ -446,6 +446,7 @@
       {
          // update of the property
          prevProp = (PropertyImpl)prevItem;
+         prevProperty = new PropertyImpl(prevProp.getData(), prevProp.parentData(), prevProp.getSession());
          isMultiValue = prevProp.isMultiValued();
          defs =
             ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
@@ -569,7 +570,7 @@
       PropertyImpl prop;
       if (state != ItemState.DELETED)
       {
-         // add or update
+         // add or update       
          TransientPropertyData newData =
             new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
                multiValue, valueDataList);
@@ -578,7 +579,7 @@
          prop = (PropertyImpl)dataManager.update(itemState, true);
 
          // launch event: post-set 
-         session.getActionHandler().postSetProperty(prop, state);
+         session.getActionHandler().postSetProperty(prevProperty, prop, state);
       }
       else
       {
@@ -734,8 +735,7 @@
     * Get parent node item.
     * 
     * @return parent item
-    * @throws RepositoryException
-    *           if parent item is null
+    * @throws RepositoryException if parent item is null
     */
    protected NodeImpl parent() throws RepositoryException
    {
@@ -753,8 +753,7 @@
     * Get and return parent node data.
     * 
     * @return parent node data
-    * @throws RepositoryException
-    *           if parent item is null
+    * @throws RepositoryException if parent item is null
     */
    public NodeData parentData() throws RepositoryException
    {
@@ -815,29 +814,25 @@
 
    /**
     * Loads data.
-    *
-    * @param data
-    *          source item data
-    * @throws RepositoryException 
-    *          if errors occurs
+    * 
+    * @param data source item data
+    * @throws RepositoryException if errors occurs
     */
    abstract void loadData(ItemData data) throws RepositoryException;
 
    /**
-    * Loads data using existing parent data (used primary and mixin types for Item Definition discovery).
-    *
-    * @param data
-    *          source item data
-    * @param parent NodeData 
-    *          Items's parent
-    * @throws RepositoryException 
-    *          if errors occurs
+    * Loads data using existing parent data (used primary and mixin types for
+    * Item Definition discovery).
+    * 
+    * @param data source item data
+    * @param parent NodeData Items's parent
+    * @throws RepositoryException if errors occurs
     */
    abstract void loadData(ItemData data, NodeData parent) throws RepositoryException;
 
    /**
     * Returns Item definition data.
-    *
+    * 
     * @return
     */
    abstract ItemDefinitionData getItemDefinitionData();
@@ -898,7 +893,7 @@
             ValueData vd;
             if (value instanceof BaseValue || value instanceof ExtendedValue)
             {
-               // create Transient copy 
+               // create Transient copy
                vd = ((BaseValue)getSession().getValueFactory().createValue(value.getStream())).getInternalData();
             }
             else

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java	2010-06-21 12:41:26 UTC (rev 2670)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionInterceptor.java	2010-06-21 14:00:38 UTC (rev 2671)
@@ -254,13 +254,14 @@
       }
    }
 
-   public void postSetProperty(PropertyImpl property, int state) throws RepositoryException
+   public void postSetProperty(PropertyImpl previousProperty, PropertyImpl currentProperty, int state)
+      throws RepositoryException
    {
       if (catalog == null)
          return;
 
       if (activeItem == null)
-         activeItem = property;
+         activeItem = currentProperty;
       else
          return;
 
@@ -284,11 +285,12 @@
 
          Condition conditions = new Condition();
          conditions.put(SessionEventMatcher.EVENTTYPE_KEY, event);
-         conditions.put(SessionEventMatcher.PATH_KEY, property.getInternalPath());
-         conditions.put(SessionEventMatcher.NODETYPES_KEY, readNodeTypeNames(property.parentData()));
+         conditions.put(SessionEventMatcher.PATH_KEY, currentProperty.getInternalPath());
+         conditions.put(SessionEventMatcher.NODETYPES_KEY, readNodeTypeNames(currentProperty.parentData()));
 
          InvocationContext ctx = new InvocationContext();
-         ctx.put(InvocationContext.CURRENT_ITEM, property);
+         ctx.put(InvocationContext.CURRENT_ITEM, currentProperty);
+         ctx.put(InvocationContext.PREVIOUS_ITEM, previousProperty);
          ctx.put(InvocationContext.EXO_CONTAINER, container);
          ctx.put(InvocationContext.EVENT, event);
          launch(conditions, ctx);



More information about the exo-jcr-commits mailing list