Author: andrew.plotnikov
Date: 2012-01-20 08:24:17 -0500 (Fri, 20 Jan 2012)
New Revision: 5489
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/ActionConfiguration.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionCatalog.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/actions/TestActions.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-146: Allowed to specify properties to an Extension Action
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/ActionConfiguration.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/ActionConfiguration.java 2012-01-19
19:55:28 UTC (rev 5488)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/ActionConfiguration.java 2012-01-20
13:24:17 UTC (rev 5489)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.ext.action;
+import org.exoplatform.services.command.action.Action;
+
/**
* Created by The eXo Platform SAS.
*
@@ -40,20 +42,17 @@
private String workspace;
+ private Action action;
+
public ActionConfiguration()
{
- this.actionClassName = null;
- this.eventTypes = null;
- this.path = null;
- this.isDeep = true;
- this.workspace = null;
- this.nodeTypes = null;
}
public ActionConfiguration(String actionClassName, String eventTypes, String path,
boolean isDeep, String workspace,
- String nodeTypes)
+ String nodeTypes, Action action)
{
this.actionClassName = actionClassName;
+ this.action = action;
this.eventTypes = eventTypes;
this.path = path;
this.isDeep = isDeep;
@@ -61,6 +60,22 @@
this.nodeTypes = nodeTypes;
}
+ /**
+ * @return the action
+ */
+ public Action getAction()
+ {
+ return action;
+ }
+
+ /**
+ * @param action the action to set
+ */
+ public void setAction(Action action)
+ {
+ this.action = action;
+ }
+
public String getActionClassName()
{
return actionClassName;
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionCatalog.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionCatalog.java 2012-01-19
19:55:28 UTC (rev 5488)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/ext/action/SessionActionCatalog.java 2012-01-20
13:24:17 UTC (rev 5489)
@@ -53,7 +53,6 @@
public SessionActionCatalog(RepositoryService repService) throws RepositoryException
{
-
RepositoryImpl rep = (RepositoryImpl)repService.getCurrentRepository();
this.locFactory = rep.getLocationFactory();
this.typeDataManager = rep.getNodeTypeManager().getNodeTypesHolder();
@@ -68,12 +67,14 @@
{
try
{
-
SessionEventMatcher matcher =
new SessionEventMatcher(getEventTypes(ac.getEventTypes()),
getPaths(ac.getPath()), ac.isDeep(),
getWorkspaces(ac.getWorkspace()), getNames(ac.getNodeTypes()),
typeDataManager);
- Action action = (Action)ClassLoading.forName(ac.getActionClassName(),
this).newInstance();
+ Action action =
+ ac.getAction() != null ? ac.getAction() :
(Action)ClassLoading.forName(ac.getActionClassName(), this)
+ .newInstance();
+
addAction(matcher, action);
}
catch (Exception e)
@@ -87,7 +88,9 @@
private InternalQName[] getNames(String names) throws RepositoryException
{
if (names == null)
+ {
return null;
+ }
String[] nameList = names.split(",");
InternalQName[] qnames = new InternalQName[nameList.length];
@@ -101,7 +104,9 @@
private QPath[] getPaths(String paths) throws RepositoryException
{
if (paths == null)
+ {
return null;
+ }
String[] pathList = paths.split(",");
QPath[] qpaths = new QPath[pathList.length];
@@ -115,14 +120,18 @@
private String[] getWorkspaces(String workspaces) throws RepositoryException
{
if (workspaces == null)
+ {
return null;
+ }
return workspaces.split(",");
}
private static int getEventTypes(String names)
{
if (names == null)
+ {
return -1;
+ }
String[] nameList = names.split(",");
int res = 0;
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/actions/TestActions.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/actions/TestActions.java 2012-01-19
19:55:28 UTC (rev 5488)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/actions/TestActions.java 2012-01-20
13:24:17 UTC (rev 5489)
@@ -20,12 +20,8 @@
import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
-import javax.jcr.ItemExistsException;
-import javax.jcr.PathNotFoundException;
+import javax.jcr.Node;
import javax.jcr.RepositoryException;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.version.VersionException;
/**
* @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey
Kabashnyuk</a>
@@ -33,33 +29,12 @@
*/
public class TestActions extends BaseStandaloneTest
{
- public void testReadAction() throws ItemExistsException, PathNotFoundException,
VersionException,
- ConstraintViolationException, LockException, RepositoryException
+
+ public void testAddMyAction() throws RepositoryException
{
- // SessionActionCatalog catalog = (SessionActionCatalog)
- // container.getComponentInstanceOfType(SessionActionCatalog.class);
- // catalog.clear();
- //
- // // test by path
- //
- // Node testNode = root.addNode("testNode");
- // PropertyImpl prop = (PropertyImpl) testNode.setProperty("test",
"test");
- // root.save();
- //
- // SessionEventMatcher matcher = new SessionEventMatcher(ExtendedEvent.READ,
- // new QPath[] { prop.getData().getQPath() },
- // true,
- // null,
- // null,
- // new InternalQName[] { Constants.NT_UNSTRUCTURED });
- // DummyAction dAction = new DummyAction();
- //
- // catalog.addAction(matcher, dAction);
+ Node test = root.addNode("testPath");
- // ???????????????
- // assertEquals(0, dAction.getActionExecuterCount());
- // String val = testNode.getProperty("test").getValue().getString();
- // assertEquals(1, dAction.getActionExecuterCount());
-
+ assertTrue(test.getNode("myActionNode") != null);
+
assertTrue(test.getNode("myActionNode").getProperty("myProperty") !=
null);
}
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-01-19
19:55:28 UTC (rev 5488)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-01-20
13:24:17 UTC (rev 5489)
@@ -465,6 +465,29 @@
</field>
</object>
</value>
+ <value>
+ <object
type="org.exoplatform.services.jcr.impl.ext.action.ActionConfiguration">
+ <field name="eventTypes">
+ <string>addNode</string>
+ </field>
+ <field name="path">
+ <string>/testPath</string>
+ </field>
+ <field name="isDeep">
+ <boolean>false</boolean>
+ </field>
+ <field name="action">
+ <object
type="org.exoplatform.services.jcr.ext.backup.usecase.SetPropertyAction">
+ <field name="addPropertyName">
+ <string>myProperty</string>
+ </field>
+ <field name="addPropertyValue">
+ <string>myValue</string>
+ </field>
+ </object>
+ </field>
+ </object>
+ </value>
</collection>
</field>
</object>