mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Action/Rule decoupling work
- Updated web services, SDK and web client where appropraite - Patch added to migrate existing rules - Entire rule service can now be disabled programmatically - Rule service is now disabled during the patching process - StoreEnum and languageEnum types removed from web service interfaces - Multiple rule types now supported in the repo (but not in the UI) - Removed owning node ref from action and rule .. now calculated from methods on the rule service git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3464 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -72,3 +72,6 @@ patch.topLevelGroupParentChildAssociationTypePatch.description=Ensure top level
|
|||||||
patch.topLevelGroupParentChildAssociationTypePatch.result=Fixed {0} top level groups child association types.
|
patch.topLevelGroupParentChildAssociationTypePatch.result=Fixed {0} top level groups child association types.
|
||||||
patch.topLevelGroupParentChildAssociationTypePatch.err.sys_path_not_found=Required authority system path not found: {0}
|
patch.topLevelGroupParentChildAssociationTypePatch.err.sys_path_not_found=Required authority system path not found: {0}
|
||||||
patch.topLevelGroupParentChildAssociationTypePatch.err.auth_path_not_found=Required authority path not found: {0}
|
patch.topLevelGroupParentChildAssociationTypePatch.err.auth_path_not_found=Required authority path not found: {0}
|
||||||
|
|
||||||
|
patch.actionRuleDecouplingPatch.description=Migrate existing rules to the updated model where rules are decoupled from actions.
|
||||||
|
patch.actionRuleDecouplingPatch.result=Updated {0} rules.
|
@@ -37,6 +37,9 @@
|
|||||||
<property name="descriptorService">
|
<property name="descriptorService">
|
||||||
<ref bean="descriptorComponent" />
|
<ref bean="descriptorComponent" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="ruleService">
|
||||||
|
<ref bean="ruleService" />
|
||||||
|
</property>
|
||||||
<property name="patchDaoService">
|
<property name="patchDaoService">
|
||||||
<ref bean="patchDaoComponent" />
|
<ref bean="patchDaoComponent" />
|
||||||
</property>
|
</property>
|
||||||
@@ -360,7 +363,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<bean id="patch.topLevelGroupParentChildAssociationTypePatch" class="org.alfresco.repo.admin.patch.impl.TopLevelGroupParentChildAssociationTypePatch" parent="basePatch">
|
<bean id="patch.topLevelGroupParentChildAssociationTypePatch" class="org.alfresco.repo.admin.patch.impl.TopLevelGroupParentChildAssociationTypePatch" parent="basePatch">
|
||||||
<property name="id"><value>patch.topLevelGroupParentChildAssociationTypePatch</value></property>
|
<property name="id"><value>patch.topLevelGroupParentChildAssociationTypePatch</value></property>
|
||||||
<property name="description"><value>patch.topLevelGroupParentChildAssociationTypePatch.description</value></property>
|
<property name="description"><value>patch.topLevelGroupParentChildAssociationTypePatch.description</value></property>
|
||||||
@@ -369,4 +371,12 @@
|
|||||||
<property name="targetSchema"><value>14</value></property>
|
<property name="targetSchema"><value>14</value></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="patch.actionRuleDecouplingPatch" class="org.alfresco.repo.admin.patch.impl.ActionRuleDecouplingPatch" parent="basePatch">
|
||||||
|
<property name="id"><value>patch.actionRuleDecouplingPatch</value></property>
|
||||||
|
<property name="description"><value>patch.actionRuleDecouplingPatch.description</value></property>
|
||||||
|
<property name="fixesFromSchema"><value>0</value></property>
|
||||||
|
<property name="fixesToSchema"><value>14</value></property>
|
||||||
|
<property name="targetSchema"><value>15</value></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -56,9 +56,6 @@
|
|||||||
<property name="ruleService">
|
<property name="ruleService">
|
||||||
<ref bean="ruleService"/>
|
<ref bean="ruleService"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="actionService">
|
|
||||||
<ref bean="actionService"/>
|
|
||||||
</property>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="inbound" class="org.alfresco.repo.rule.RuleTypeImpl" parent="rule-type-base">
|
<bean id="inbound" class="org.alfresco.repo.rule.RuleTypeImpl" parent="rule-type-base">
|
||||||
|
@@ -19,4 +19,4 @@ version.build=@build-number@
|
|||||||
|
|
||||||
# Schema number
|
# Schema number
|
||||||
|
|
||||||
version.schema=14
|
version.schema=15
|
||||||
|
@@ -40,6 +40,9 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3258135760426186548L;
|
private static final long serialVersionUID = 3258135760426186548L;
|
||||||
|
|
||||||
|
/** The node reference for the action */
|
||||||
|
private NodeRef nodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The title
|
* The title
|
||||||
*/
|
*/
|
||||||
@@ -90,11 +93,6 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
*/
|
*/
|
||||||
private String runAsUserName;
|
private String runAsUserName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The owning node reference
|
|
||||||
*/
|
|
||||||
private NodeRef owningNodeRef;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The chain of actions that have lead to this action
|
* The chain of actions that have lead to this action
|
||||||
*/
|
*/
|
||||||
@@ -108,30 +106,32 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
* @param nodeRef the action node reference (null if not saved)
|
||||||
* @param id the action id
|
* @param id the action id
|
||||||
* @param actionDefinitionName the name of the action definition
|
* @param actionDefinitionName the name of the action definition
|
||||||
*/
|
*/
|
||||||
public ActionImpl(String id, String actionDefinitionName, NodeRef owningNodeRef)
|
public ActionImpl(NodeRef nodeRef, String id, String actionDefinitionName)
|
||||||
{
|
{
|
||||||
this(id, actionDefinitionName, owningNodeRef, null);
|
this(nodeRef, id, actionDefinitionName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
* @param nodeRef the action node reference (null if not saved)
|
||||||
* @param id the action id
|
* @param id the action id
|
||||||
* @param actionDefinitionName the action definition name
|
* @param actionDefinitionName the action definition name
|
||||||
* @param parameterValues the parameter values
|
* @param parameterValues the parameter values
|
||||||
*/
|
*/
|
||||||
public ActionImpl(
|
public ActionImpl(
|
||||||
|
NodeRef nodeRef,
|
||||||
String id,
|
String id,
|
||||||
String actionDefinitionName,
|
String actionDefinitionName,
|
||||||
NodeRef owningNodeRef,
|
|
||||||
Map<String, Serializable> parameterValues)
|
Map<String, Serializable> parameterValues)
|
||||||
{
|
{
|
||||||
super(id, parameterValues);
|
super(id, parameterValues);
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
this.actionDefinitionName = actionDefinitionName;
|
this.actionDefinitionName = actionDefinitionName;
|
||||||
this.owningNodeRef = owningNodeRef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,19 +166,6 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.service.cmr.action.Action#getOwningNodeRef()
|
|
||||||
*/
|
|
||||||
public NodeRef getOwningNodeRef()
|
|
||||||
{
|
|
||||||
return this.owningNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOwningNodeRef(NodeRef owningNodeRef)
|
|
||||||
{
|
|
||||||
this.owningNodeRef = owningNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.action.Action#getExecuteAsychronously()
|
* @see org.alfresco.service.cmr.action.Action#getExecuteAsychronously()
|
||||||
*/
|
*/
|
||||||
@@ -392,4 +379,22 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
{
|
{
|
||||||
this.runAsUserName = runAsUserName;
|
this.runAsUserName = runAsUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.action.Action#getNodeRef()
|
||||||
|
*/
|
||||||
|
public NodeRef getNodeRef()
|
||||||
|
{
|
||||||
|
return this.nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the node reference
|
||||||
|
*
|
||||||
|
* @param nodeRef the node reference
|
||||||
|
*/
|
||||||
|
public void setNodeRef(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,9 +41,9 @@ public class ActionImplTest extends BaseParameterizedItemImplTest
|
|||||||
protected ParameterizedItemImpl create()
|
protected ParameterizedItemImpl create()
|
||||||
{
|
{
|
||||||
return new ActionImpl(
|
return new ActionImpl(
|
||||||
|
null,
|
||||||
ID,
|
ID,
|
||||||
NAME,
|
NAME,
|
||||||
null,
|
|
||||||
this.paramValues);
|
this.paramValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class ActionImplTest extends BaseParameterizedItemImplTest
|
|||||||
action.setTitle("title");
|
action.setTitle("title");
|
||||||
action.setDescription("description");
|
action.setDescription("description");
|
||||||
action.setExecuteAsynchronously(true);
|
action.setExecuteAsynchronously(true);
|
||||||
Action compensatingAction = new ActionImpl(GUID.generate(), "actionDefintionName", null);
|
Action compensatingAction = new ActionImpl(null, GUID.generate(), "actionDefintionName", null);
|
||||||
action.setCompensatingAction(compensatingAction);
|
action.setCompensatingAction(compensatingAction);
|
||||||
|
|
||||||
// Check the values have been set
|
// Check the values have been set
|
||||||
|
@@ -309,7 +309,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
*/
|
*/
|
||||||
public Action createAction(String name)
|
public Action createAction(String name)
|
||||||
{
|
{
|
||||||
return new ActionImpl(GUID.generate(),name, null);
|
return new ActionImpl(null, GUID.generate(),name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +327,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
*/
|
*/
|
||||||
public CompositeAction createCompositeAction()
|
public CompositeAction createCompositeAction()
|
||||||
{
|
{
|
||||||
return new CompositeActionImpl(GUID.generate(), null);
|
return new CompositeActionImpl(null, GUID.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,6 +595,18 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
this.nodeService.addAspect(nodeRef, ActionModel.ASPECT_ACTIONS, null);
|
this.nodeService.addAspect(nodeRef, ActionModel.ASPECT_ACTIONS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the action nod reference
|
||||||
|
actionNodeRef = createActionNodeRef(action,
|
||||||
|
getSavedActionFolderRef(nodeRef),
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
ASSOC_NAME_ACTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveActionImpl(actionNodeRef, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeRef createActionNodeRef(Action action, NodeRef parentNodeRef, QName assocTypeName, QName assocName)
|
||||||
|
{
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
||||||
props.put(ActionModel.PROP_DEFINITION_NAME, action.getActionDefinitionName());
|
props.put(ActionModel.PROP_DEFINITION_NAME, action.getActionDefinitionName());
|
||||||
props.put(ContentModel.PROP_NODE_UUID, action.getId());
|
props.put(ContentModel.PROP_NODE_UUID, action.getId());
|
||||||
@@ -606,29 +618,26 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the action node
|
// Create the action node
|
||||||
actionNodeRef = this.nodeService.createNode(
|
NodeRef actionNodeRef = this.nodeService.createNode(
|
||||||
getSavedActionFolderRef(nodeRef),
|
parentNodeRef,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
assocTypeName,
|
||||||
ASSOC_NAME_ACTIONS,
|
assocName,
|
||||||
actionType,
|
actionType,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
|
|
||||||
// Update the created details
|
// Update the created details and the node reference
|
||||||
((ActionImpl)action).setCreator((String)this.nodeService.getProperty(actionNodeRef, ContentModel.PROP_CREATOR));
|
((ActionImpl)action).setCreator((String)this.nodeService.getProperty(actionNodeRef, ContentModel.PROP_CREATOR));
|
||||||
((ActionImpl)action).setCreatedDate((Date)this.nodeService.getProperty(actionNodeRef, ContentModel.PROP_CREATED));
|
((ActionImpl)action).setCreatedDate((Date)this.nodeService.getProperty(actionNodeRef, ContentModel.PROP_CREATED));
|
||||||
}
|
((ActionImpl)action).setNodeRef(actionNodeRef);
|
||||||
|
|
||||||
saveActionImpl(nodeRef, actionNodeRef, action);
|
return actionNodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.action.RuntimeActionService#saveActionImpl(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.action.Action)
|
* @see org.alfresco.repo.action.RuntimeActionService#saveActionImpl(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.action.Action)
|
||||||
*/
|
*/
|
||||||
public void saveActionImpl(NodeRef owningNodeRef, NodeRef actionNodeRef, Action action)
|
public void saveActionImpl(NodeRef actionNodeRef, Action action)
|
||||||
{
|
{
|
||||||
// Set the owning node ref
|
|
||||||
((ActionImpl)action).setOwningNodeRef(owningNodeRef);
|
|
||||||
|
|
||||||
// Save action properties
|
// Save action properties
|
||||||
saveActionProperties(actionNodeRef, action);
|
saveActionProperties(actionNodeRef, action);
|
||||||
|
|
||||||
@@ -671,18 +680,20 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
{
|
{
|
||||||
if (compensatingAction != null)
|
if (compensatingAction != null)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props2 = new HashMap<QName, Serializable>(2);
|
//Map<QName, Serializable> props2 = new HashMap<QName, Serializable>(2);
|
||||||
props2.put(ActionModel.PROP_DEFINITION_NAME, compensatingAction.getActionDefinitionName());
|
//props2.put(ActionModel.PROP_DEFINITION_NAME, compensatingAction.getActionDefinitionName());
|
||||||
props2.put(ContentModel.PROP_NODE_UUID, compensatingAction.getId());
|
//props2.put(ContentModel.PROP_NODE_UUID, compensatingAction.getId());
|
||||||
|
|
||||||
NodeRef compensatingActionNodeRef = this.nodeService.createNode(
|
//NodeRef compensatingActionNodeRef = this.nodeService.createNode(
|
||||||
actionNodeRef,
|
/// actionNodeRef,
|
||||||
ActionModel.ASSOC_COMPENSATING_ACTION,
|
// ActionModel.ASSOC_COMPENSATING_ACTION,
|
||||||
ActionModel.ASSOC_COMPENSATING_ACTION,
|
// ActionModel.ASSOC_COMPENSATING_ACTION,
|
||||||
ActionModel.TYPE_ACTION,
|
// ActionModel.TYPE_ACTION,
|
||||||
props2).getChildRef();
|
// props2).getChildRef();
|
||||||
|
|
||||||
saveActionImpl(compensatingAction.getOwningNodeRef(), compensatingActionNodeRef, compensatingAction);
|
// Create the compensating node reference
|
||||||
|
NodeRef compensatingActionNodeRef = createActionNodeRef(compensatingAction, actionNodeRef, ActionModel.ASSOC_COMPENSATING_ACTION, ActionModel.ASSOC_COMPENSATING_ACTION);
|
||||||
|
saveActionImpl(compensatingActionNodeRef, compensatingAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -694,7 +705,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
saveActionImpl(compensatingAction.getOwningNodeRef(), assoc.getChildRef(), compensatingAction);
|
saveActionImpl(assoc.getChildRef(), compensatingAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,7 +741,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
{
|
{
|
||||||
// Update the action
|
// Update the action
|
||||||
Action action = idToAction.get(actionNodeRef.getId());
|
Action action = idToAction.get(actionNodeRef.getId());
|
||||||
saveActionImpl(action.getOwningNodeRef(), actionNodeRef, action);
|
saveActionImpl(actionNodeRef, action);
|
||||||
orderedIds.remove(actionNodeRef.getId());
|
orderedIds.remove(actionNodeRef.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +763,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
ActionModel.TYPE_ACTION,
|
ActionModel.TYPE_ACTION,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
|
|
||||||
saveActionImpl(action.getOwningNodeRef(), actionNodeRef, action);
|
saveActionImpl(actionNodeRef, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,7 +900,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
for (ChildAssociationRef action : actions)
|
for (ChildAssociationRef action : actions)
|
||||||
{
|
{
|
||||||
NodeRef actionNodeRef = action.getChildRef();
|
NodeRef actionNodeRef = action.getChildRef();
|
||||||
result.add(createAction(nodeRef, actionNodeRef));
|
result.add(createAction(actionNodeRef));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,7 +913,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
* @param actionNodeRef the action node reference
|
* @param actionNodeRef the action node reference
|
||||||
* @return the action
|
* @return the action
|
||||||
*/
|
*/
|
||||||
private Action createAction(NodeRef owningNodeRef, NodeRef actionNodeRef)
|
public Action createAction(NodeRef actionNodeRef)
|
||||||
{
|
{
|
||||||
Action result = null;
|
Action result = null;
|
||||||
|
|
||||||
@@ -912,13 +923,13 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
if (ActionModel.TYPE_COMPOSITE_ACTION.equals(actionType) == true)
|
if (ActionModel.TYPE_COMPOSITE_ACTION.equals(actionType) == true)
|
||||||
{
|
{
|
||||||
// Create a composite action
|
// Create a composite action
|
||||||
result = new CompositeActionImpl(actionNodeRef.getId(), owningNodeRef);
|
result = new CompositeActionImpl(actionNodeRef, actionNodeRef.getId());
|
||||||
populateCompositeAction(actionNodeRef, (CompositeAction)result);
|
populateCompositeAction(actionNodeRef, (CompositeAction)result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create an action
|
// Create an action
|
||||||
result = new ActionImpl(actionNodeRef.getId(), (String)properties.get(ActionModel.PROP_DEFINITION_NAME), owningNodeRef);
|
result = new ActionImpl(actionNodeRef, actionNodeRef.getId(), (String)properties.get(ActionModel.PROP_DEFINITION_NAME));
|
||||||
populateAction(actionNodeRef, result);
|
populateAction(actionNodeRef, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,7 +989,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(actionNodeRef, RegexQNamePattern.MATCH_ALL, ActionModel.ASSOC_COMPENSATING_ACTION);
|
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(actionNodeRef, RegexQNamePattern.MATCH_ALL, ActionModel.ASSOC_COMPENSATING_ACTION);
|
||||||
if (assocs.size() != 0)
|
if (assocs.size() != 0)
|
||||||
{
|
{
|
||||||
Action compensatingAction = createAction(action.getOwningNodeRef(), assocs.get(0).getChildRef());
|
Action compensatingAction = createAction(assocs.get(0).getChildRef());
|
||||||
action.setCompensatingAction(compensatingAction);
|
action.setCompensatingAction(compensatingAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1050,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
for (ChildAssociationRef action : actions)
|
for (ChildAssociationRef action : actions)
|
||||||
{
|
{
|
||||||
NodeRef actionNodeRef = action.getChildRef();
|
NodeRef actionNodeRef = action.getChildRef();
|
||||||
compositeAction.addAction(createAction(compositeAction.getOwningNodeRef(), actionNodeRef));
|
compositeAction.addAction(createAction(actionNodeRef));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1056,7 +1067,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
NodeRef actionNodeRef = getActionNodeRefFromId(nodeRef, actionId);
|
NodeRef actionNodeRef = getActionNodeRefFromId(nodeRef, actionId);
|
||||||
if (actionNodeRef != null)
|
if (actionNodeRef != null)
|
||||||
{
|
{
|
||||||
result = createAction(nodeRef, actionNodeRef);
|
result = createAction(actionNodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -388,19 +388,19 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
action.setExecuteAsynchronously(true);
|
action.setExecuteAsynchronously(true);
|
||||||
|
|
||||||
// Check the owning node ref
|
// Check the owning node ref
|
||||||
assertNull(action.getOwningNodeRef());
|
//assertNull(action.getOwningNodeRef());
|
||||||
|
|
||||||
// Save the action
|
// Save the action
|
||||||
this.actionService.saveAction(this.nodeRef, action);
|
this.actionService.saveAction(this.nodeRef, action);
|
||||||
|
|
||||||
// Check the owning node ref
|
// Check the owning node ref
|
||||||
assertEquals(this.nodeRef, action.getOwningNodeRef());
|
//assertEquals(this.nodeRef, action.getOwningNodeRef());
|
||||||
|
|
||||||
// Get the action
|
// Get the action
|
||||||
Action savedAction = this.actionService.getAction(this.nodeRef, actionId);
|
Action savedAction = this.actionService.getAction(this.nodeRef, actionId);
|
||||||
|
|
||||||
// Check the owning node ref
|
// Check the owning node ref
|
||||||
assertEquals(this.nodeRef, savedAction.getOwningNodeRef());;
|
//assertEquals(this.nodeRef, savedAction.getOwningNodeRef());;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -46,9 +46,9 @@ public class CompositeActionImpl extends ActionImpl implements CompositeAction
|
|||||||
*
|
*
|
||||||
* @param id the action id
|
* @param id the action id
|
||||||
*/
|
*/
|
||||||
public CompositeActionImpl(String id, NodeRef owningNodeRef)
|
public CompositeActionImpl(NodeRef nodeRef, String id)
|
||||||
{
|
{
|
||||||
super(id, CompositeActionExecuter.NAME, owningNodeRef);
|
super(nodeRef, id, CompositeActionExecuter.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -37,11 +37,11 @@ public class CompositeActionImplTest extends ActionImplTest
|
|||||||
|
|
||||||
public void testActions()
|
public void testActions()
|
||||||
{
|
{
|
||||||
Action action1 = new ActionImpl(ACTION1_ID, ACTION1_NAME, null);
|
Action action1 = new ActionImpl(null, ACTION1_ID, ACTION1_NAME, null);
|
||||||
Action action2 = new ActionImpl(ACTION2_ID, ACTION2_NAME, null);
|
Action action2 = new ActionImpl(null, ACTION2_ID, ACTION2_NAME, null);
|
||||||
Action action3 = new ActionImpl(ACTION3_ID, ACTION3_NAME, null);
|
Action action3 = new ActionImpl(null, ACTION3_ID, ACTION3_NAME, null);
|
||||||
|
|
||||||
CompositeAction compositeAction = new CompositeActionImpl(ID, null);
|
CompositeAction compositeAction = new CompositeActionImpl(null, ID);
|
||||||
|
|
||||||
// Check has no action
|
// Check has no action
|
||||||
assertFalse(compositeAction.hasActions());
|
assertFalse(compositeAction.hasActions());
|
||||||
|
@@ -23,21 +23,38 @@ import org.alfresco.repo.action.ActionServiceImpl.PendingAction;
|
|||||||
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
|
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
|
||||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.CompositeAction;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public interface RuntimeActionService
|
public interface RuntimeActionService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get the asynchronous action queue.
|
||||||
|
*
|
||||||
|
* @return the asynchronous action queue
|
||||||
|
*/
|
||||||
AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue();
|
AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an action condition evaluator
|
||||||
|
*
|
||||||
|
* @param actionConditionEvaluator action condition evaluator
|
||||||
|
*/
|
||||||
void registerActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator);
|
void registerActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an action executer
|
||||||
|
*
|
||||||
|
* @param actionExecuter action executer
|
||||||
|
*/
|
||||||
void registerActionExecuter(ActionExecuter actionExecuter);
|
void registerActionExecuter(ActionExecuter actionExecuter);
|
||||||
|
|
||||||
void populateCompositeAction(NodeRef compositeNodeRef, CompositeAction compositeAction);
|
Action createAction(NodeRef actionNodeRef);
|
||||||
|
|
||||||
|
NodeRef createActionNodeRef(Action action, NodeRef parentNodeRef, QName assocTypeName, QName assocName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save action, used internally to store the details of an action on the aciton node.
|
* Save action, used internally to store the details of an action on the aciton node.
|
||||||
@@ -45,7 +62,7 @@ public interface RuntimeActionService
|
|||||||
* @param actionNodeRef the action node reference
|
* @param actionNodeRef the action node reference
|
||||||
* @param action the action
|
* @param action the action
|
||||||
*/
|
*/
|
||||||
void saveActionImpl(NodeRef owningNodeRef, NodeRef actionNodeRef, Action action);
|
void saveActionImpl(NodeRef actionNodeRef, Action action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -60,7 +77,18 @@ public interface RuntimeActionService
|
|||||||
boolean executedAsynchronously,
|
boolean executedAsynchronously,
|
||||||
Set<String> actionChain);
|
Set<String> actionChain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute an action directly
|
||||||
|
*
|
||||||
|
* @param action the action
|
||||||
|
* @param actionedUponNodeRef the actioned upon node reference
|
||||||
|
*/
|
||||||
public void directActionExecution(Action action, NodeRef actionedUponNodeRef);
|
public void directActionExecution(Action action, NodeRef actionedUponNodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of the actions that are pending post transaction
|
||||||
|
*
|
||||||
|
* @return list of pending actions
|
||||||
|
*/
|
||||||
public List<PendingAction> getPostTransactionPendingActions();
|
public List<PendingAction> getPostTransactionPendingActions();
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,7 @@ public class AddFeaturesActionExecuterTest extends BaseSpringTest
|
|||||||
assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, AddFeaturesActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, AddFeaturesActionExecuter.NAME, null);
|
||||||
action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen M<>ller
|
* Copyright (C) 2005 Jesper Steen M<>ller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
@@ -37,7 +37,7 @@ import org.alfresco.util.GUID;
|
|||||||
* Test of the ActionExecuter for extracting metadata. Note: This test makes
|
* Test of the ActionExecuter for extracting metadata. Note: This test makes
|
||||||
* assumptions about the PDF test data for PdfBoxExtracter.
|
* assumptions about the PDF test data for PdfBoxExtracter.
|
||||||
*
|
*
|
||||||
* @author Jesper Steen M<>ller
|
* @author Jesper Steen M<>ller
|
||||||
*/
|
*/
|
||||||
public class ContentMetadataExtracterTest extends BaseSpringTest
|
public class ContentMetadataExtracterTest extends BaseSpringTest
|
||||||
{
|
{
|
||||||
@@ -102,7 +102,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
|
|||||||
this.nodeService.setProperties(this.nodeRef, props);
|
this.nodeService.setProperties(this.nodeRef, props);
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, SetPropertyValueActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, SetPropertyValueActionExecuter.NAME, null);
|
||||||
|
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
|
|||||||
this.nodeService.setProperties(this.nodeRef, props);
|
this.nodeService.setProperties(this.nodeRef, props);
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, SetPropertyValueActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, SetPropertyValueActionExecuter.NAME, null);
|
||||||
|
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
|
||||||
|
@@ -133,8 +133,11 @@ public class ExecuteAllRulesActionExecuter extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
for (Rule rule : rules)
|
for (Rule rule : rules)
|
||||||
{
|
{
|
||||||
// Apply the rule to the child node
|
Action action = rule.getAction();
|
||||||
this.actionService.executeAction(rule, child);
|
if (action != null)
|
||||||
|
{
|
||||||
|
this.actionService.executeAction(action, child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -105,15 +105,18 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest
|
|||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
|
|
||||||
// Add a couple of rules to the folder
|
// Add a couple of rules to the folder
|
||||||
Rule rule1 = this.ruleService.createRule(RuleType.INBOUND);
|
Rule rule1 = new Rule();
|
||||||
|
rule1.setRuleType(RuleType.INBOUND);
|
||||||
Action action1 = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
Action action1 = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
||||||
action1.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
action1.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||||
rule1.addAction(action1);
|
rule1.setAction(action1);
|
||||||
this.ruleService.saveRule(folder, rule1);
|
this.ruleService.saveRule(folder, rule1);
|
||||||
Rule rule2 = this.ruleService.createRule(RuleType.INBOUND);
|
|
||||||
|
Rule rule2 = new Rule();
|
||||||
|
rule2.setRuleType(RuleType.INBOUND);
|
||||||
Action action2 = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
Action action2 = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
||||||
action2.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
action2.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
||||||
rule2.addAction(action2);
|
rule2.setAction(action2);
|
||||||
this.ruleService.saveRule(folder, rule2);
|
this.ruleService.saveRule(folder, rule2);
|
||||||
|
|
||||||
// Check the the docs don't have the aspects yet
|
// Check the the docs don't have the aspects yet
|
||||||
@@ -125,7 +128,7 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest
|
|||||||
assertTrue(this.nodeService.exists(folder));
|
assertTrue(this.nodeService.exists(folder));
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, ExecuteAllRulesActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, ExecuteAllRulesActionExecuter.NAME, null);
|
||||||
this.executer.execute(action, folder);
|
this.executer.execute(action, folder);
|
||||||
|
|
||||||
assertTrue(this.nodeService.hasAspect(doc1, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(doc1, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
@@ -101,7 +101,7 @@ public class RemoveFeaturesActionExecuterTest extends BaseSpringTest
|
|||||||
assertTrue(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
assertTrue(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, RemoveFeaturesActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, RemoveFeaturesActionExecuter.NAME, null);
|
||||||
action.setParameterValue(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
action.setParameterValue(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class RemoveFeaturesActionExecuterTest extends BaseSpringTest
|
|||||||
assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CLASSIFIABLE));
|
||||||
|
|
||||||
// Now try and remove an aspect that is not present
|
// Now try and remove an aspect that is not present
|
||||||
ActionImpl action2 = new ActionImpl(ID, RemoveFeaturesActionExecuter.NAME, null);
|
ActionImpl action2 = new ActionImpl(null, ID, RemoveFeaturesActionExecuter.NAME, null);
|
||||||
action2.setParameterValue(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
action2.setParameterValue(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||||
this.executer.execute(action2, this.nodeRef);
|
this.executer.execute(action2, this.nodeRef);
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ public class ScriptActionExecutor extends ActionExecuterAbstractBase
|
|||||||
if (nodeService.exists(actionedUponNodeRef))
|
if (nodeService.exists(actionedUponNodeRef))
|
||||||
{
|
{
|
||||||
NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
|
NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
|
||||||
NodeRef spaceRef = (NodeRef)action.getOwningNodeRef();
|
NodeRef spaceRef = this.serviceRegistry.getRuleService().getOwningNodeRef(action);
|
||||||
|
|
||||||
if (nodeService.exists(scriptRef))
|
if (nodeService.exists(scriptRef))
|
||||||
{
|
{
|
||||||
|
@@ -74,7 +74,7 @@ public class SetPropertyValueActionExecuterTest extends BaseSpringTest
|
|||||||
public void testExecution()
|
public void testExecution()
|
||||||
{
|
{
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, SetPropertyValueActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, SetPropertyValueActionExecuter.NAME, null);
|
||||||
action.setParameterValue(SetPropertyValueActionExecuter.PARAM_PROPERTY, ContentModel.PROP_NAME);
|
action.setParameterValue(SetPropertyValueActionExecuter.PARAM_PROPERTY, ContentModel.PROP_NAME);
|
||||||
action.setParameterValue(SetPropertyValueActionExecuter.PARAM_VALUE, TEST_VALUE);
|
action.setParameterValue(SetPropertyValueActionExecuter.PARAM_VALUE, TEST_VALUE);
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
@@ -73,7 +73,7 @@ public class SpecialiseTypeActionExecuterTest extends BaseAlfrescoSpringTest
|
|||||||
assertEquals(ContentModel.TYPE_CONTENT, this.nodeService.getType(this.nodeRef));
|
assertEquals(ContentModel.TYPE_CONTENT, this.nodeService.getType(this.nodeRef));
|
||||||
|
|
||||||
// Execute the action
|
// Execute the action
|
||||||
ActionImpl action = new ActionImpl(ID, SpecialiseTypeActionExecuter.NAME, null);
|
ActionImpl action = new ActionImpl(null, ID, SpecialiseTypeActionExecuter.NAME, null);
|
||||||
action.setParameterValue(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, ContentModel.TYPE_FOLDER);
|
action.setParameterValue(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, ContentModel.TYPE_FOLDER);
|
||||||
this.executer.execute(action, this.nodeRef);
|
this.executer.execute(action, this.nodeRef);
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.Map;
|
|||||||
import org.alfresco.i18n.I18NUtil;
|
import org.alfresco.i18n.I18NUtil;
|
||||||
import org.alfresco.repo.domain.AppliedPatch;
|
import org.alfresco.repo.domain.AppliedPatch;
|
||||||
import org.alfresco.service.cmr.admin.PatchException;
|
import org.alfresco.service.cmr.admin.PatchException;
|
||||||
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.descriptor.Descriptor;
|
import org.alfresco.service.descriptor.Descriptor;
|
||||||
import org.alfresco.service.descriptor.DescriptorService;
|
import org.alfresco.service.descriptor.DescriptorService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -50,6 +51,7 @@ public class PatchServiceImpl implements PatchService
|
|||||||
private static Log logger = LogFactory.getLog(PatchServiceImpl.class);
|
private static Log logger = LogFactory.getLog(PatchServiceImpl.class);
|
||||||
|
|
||||||
private DescriptorService descriptorService;
|
private DescriptorService descriptorService;
|
||||||
|
private RuleService ruleService;
|
||||||
private PatchDaoService patchDaoService;
|
private PatchDaoService patchDaoService;
|
||||||
private List<Patch> patches;
|
private List<Patch> patches;
|
||||||
|
|
||||||
@@ -68,12 +70,25 @@ public class PatchServiceImpl implements PatchService
|
|||||||
this.patchDaoService = patchDaoService;
|
this.patchDaoService = patchDaoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRuleService(RuleService ruleService)
|
||||||
|
{
|
||||||
|
this.ruleService = ruleService;
|
||||||
|
}
|
||||||
|
|
||||||
public void registerPatch(Patch patch)
|
public void registerPatch(Patch patch)
|
||||||
{
|
{
|
||||||
patches.add(patch);
|
patches.add(patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applyOutstandingPatches()
|
public boolean applyOutstandingPatches()
|
||||||
|
{
|
||||||
|
boolean success = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Diable rules whilst processing the patches
|
||||||
|
this.ruleService.disableRules();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// construct a map of all known patches by ID
|
// construct a map of all known patches by ID
|
||||||
Map<String, Patch> allPatchesById = new HashMap<String, Patch>(23);
|
Map<String, Patch> allPatchesById = new HashMap<String, Patch>(23);
|
||||||
@@ -88,8 +103,8 @@ public class PatchServiceImpl implements PatchService
|
|||||||
{
|
{
|
||||||
appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
|
appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// go through all the patches and apply them where necessary
|
// go through all the patches and apply them where necessary
|
||||||
boolean success = true;
|
|
||||||
for (Patch patch : allPatchesById.values())
|
for (Patch patch : allPatchesById.values())
|
||||||
{
|
{
|
||||||
// apply the patch
|
// apply the patch
|
||||||
@@ -100,6 +115,17 @@ public class PatchServiceImpl implements PatchService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this.ruleService.enableRules();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.admin.patch.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.i18n.I18NUtil;
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.action.ActionModel;
|
||||||
|
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||||
|
import org.alfresco.repo.rule.RuleModel;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch to apply the model changes made when decoupling actions from rules.
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
*/
|
||||||
|
public class ActionRuleDecouplingPatch extends AbstractPatch
|
||||||
|
{
|
||||||
|
private static final String MSG_RESULT = "patch.actionRuleDecouplingPatch.result";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String applyInternal() throws Exception
|
||||||
|
{
|
||||||
|
// Get a reference to the spaces store
|
||||||
|
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||||
|
|
||||||
|
// Get all the node's of type rule in the store
|
||||||
|
int updateCount = 0;
|
||||||
|
ResultSet resultSet = this.searchService.query(storeRef, "lucene", "TYPE:\"" + RuleModel.TYPE_RULE + "\"");
|
||||||
|
for (NodeRef origRuleNodeRef : resultSet.getNodeRefs())
|
||||||
|
{
|
||||||
|
// Check that this rule need updated
|
||||||
|
Map<QName, Serializable> origProperties = this.nodeService.getProperties(origRuleNodeRef);
|
||||||
|
if (origProperties.containsKey(RuleModel.PROP_EXECUTE_ASYNC) == false)
|
||||||
|
{
|
||||||
|
// 1) Change the type of the rule to be a composite action
|
||||||
|
this.nodeService.setType(origRuleNodeRef, ActionModel.TYPE_COMPOSITE_ACTION);
|
||||||
|
|
||||||
|
// 2) Create a new rule node
|
||||||
|
ChildAssociationRef parentRef = this.nodeService.getPrimaryParent(origRuleNodeRef);
|
||||||
|
NodeRef newRuleNodeRef = this.nodeService.createNode(
|
||||||
|
parentRef.getParentRef(),
|
||||||
|
parentRef.getTypeQName(),
|
||||||
|
parentRef.getQName(),
|
||||||
|
RuleModel.TYPE_RULE).getChildRef();
|
||||||
|
|
||||||
|
// 3) Move the origional rule under the new rule
|
||||||
|
this.nodeService.moveNode(
|
||||||
|
origRuleNodeRef,
|
||||||
|
newRuleNodeRef,
|
||||||
|
RuleModel.ASSOC_ACTION,
|
||||||
|
RuleModel.ASSOC_ACTION);
|
||||||
|
|
||||||
|
// 4) Move the various properties from the origional, onto the new rule
|
||||||
|
Map<QName, Serializable> newProperties = this.nodeService.getProperties(newRuleNodeRef);
|
||||||
|
|
||||||
|
// Set the rule type, execute async and applyToChildren properties on the rule
|
||||||
|
String ruleType = (String)origProperties.get(RuleModel.PROP_RULE_TYPE);
|
||||||
|
origProperties.remove(RuleModel.PROP_RULE_TYPE);
|
||||||
|
newProperties.put(RuleModel.PROP_RULE_TYPE, ruleType);
|
||||||
|
Boolean executeAsync = (Boolean)origProperties.get(ActionModel.PROP_EXECUTE_ASYNCHRONOUSLY);
|
||||||
|
origProperties.remove(ActionModel.PROP_EXECUTE_ASYNCHRONOUSLY);
|
||||||
|
newProperties.put(RuleModel.PROP_EXECUTE_ASYNC, executeAsync);
|
||||||
|
Boolean applyToChildren = (Boolean)origProperties.get(RuleModel.PROP_APPLY_TO_CHILDREN);
|
||||||
|
origProperties.remove(RuleModel.PROP_APPLY_TO_CHILDREN);
|
||||||
|
newProperties.put(RuleModel.PROP_APPLY_TO_CHILDREN, applyToChildren);
|
||||||
|
origProperties.remove(QName.createQName(RuleModel.RULE_MODEL_URI, "owningNodeRef"));
|
||||||
|
|
||||||
|
// Move the action and description values from the composite action onto the rule
|
||||||
|
String title = (String)origProperties.get(ActionModel.PROP_ACTION_TITLE);
|
||||||
|
origProperties.remove(ActionModel.PROP_ACTION_TITLE);
|
||||||
|
String description = (String)origProperties.get(ActionModel.PROP_ACTION_DESCRIPTION);
|
||||||
|
origProperties.remove(ActionModel.PROP_ACTION_DESCRIPTION);
|
||||||
|
newProperties.put(ContentModel.PROP_TITLE, title);
|
||||||
|
newProperties.put(ContentModel.PROP_DESCRIPTION, description);
|
||||||
|
|
||||||
|
// Set the updated property values
|
||||||
|
this.nodeService.setProperties(origRuleNodeRef, origProperties);
|
||||||
|
this.nodeService.setProperties(newRuleNodeRef, newProperties);
|
||||||
|
|
||||||
|
// Increment the update count
|
||||||
|
updateCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done
|
||||||
|
String msg = I18NUtil.getMessage(MSG_RESULT, updateCount);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -376,17 +376,20 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
public void testCopyNodeWithRules()
|
public void testCopyNodeWithRules()
|
||||||
{
|
{
|
||||||
// Create a new rule and add it to the source noderef
|
// Create a new rule and add it to the source noderef
|
||||||
Rule rule = this.ruleService.createRule(RuleType.INBOUND);
|
Rule rule = new Rule();
|
||||||
|
rule.setRuleType(RuleType.INBOUND);
|
||||||
|
|
||||||
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
||||||
props.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
props.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||||
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME, props);
|
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME, props);
|
||||||
rule.addAction(action);
|
rule.setAction(action);
|
||||||
|
|
||||||
ActionCondition actionCondition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
ActionCondition actionCondition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
||||||
rule.addActionCondition(actionCondition);
|
action.addActionCondition(actionCondition);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.sourceNodeRef, rule);
|
this.ruleService.saveRule(this.sourceNodeRef, rule);
|
||||||
|
assertNotNull(rule.getNodeRef());
|
||||||
|
assertEquals(this.sourceNodeRef, this.ruleService.getOwningNodeRef(rule));
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
||||||
@@ -405,18 +408,20 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
checkCopiedNode(this.sourceNodeRef, copy, true, true, true);
|
checkCopiedNode(this.sourceNodeRef, copy, true, true, true);
|
||||||
|
|
||||||
//assertTrue(this.configurableService.isConfigurable(copy));
|
|
||||||
//assertNotNull(this.configurableService.getConfigurationFolder(copy));
|
|
||||||
//assertFalse(this.configurableService.getConfigurationFolder(this.sourceNodeRef) == this.configurableService.getConfigurationFolder(copy));
|
|
||||||
|
|
||||||
assertTrue(this.nodeService.hasAspect(copy, RuleModel.ASPECT_RULES));
|
assertTrue(this.nodeService.hasAspect(copy, RuleModel.ASPECT_RULES));
|
||||||
assertTrue(this.ruleService.hasRules(copy));
|
assertTrue(this.ruleService.hasRules(copy));
|
||||||
assertTrue(this.ruleService.rulesEnabled(copy));
|
assertTrue(this.ruleService.rulesEnabled(copy));
|
||||||
|
|
||||||
List<Rule> copiedRules = this.ruleService.getRules(copy);
|
List<Rule> copiedRules = this.ruleService.getRules(copy);
|
||||||
assertEquals(1, copiedRules.size());
|
assertEquals(1, copiedRules.size());
|
||||||
Rule copiedRule = copiedRules.get(0);
|
Rule copiedRule = copiedRules.get(0);
|
||||||
assertFalse(rule.getId() == copiedRule.getId());
|
|
||||||
assertEquals(rule.getAction(0).getActionDefinitionName(), copiedRule.getAction(0).getActionDefinitionName());
|
assertNotNull(copiedRule.getNodeRef());
|
||||||
|
assertFalse(copiedRule.getNodeRef().equals(rule.getNodeRef()));
|
||||||
|
assertEquals(rule.getTitle(), copiedRule.getTitle());
|
||||||
|
assertEquals(rule.getDescription(), copiedRule.getDescription());
|
||||||
|
assertEquals(copy, this.ruleService.getOwningNodeRef(copiedRule));
|
||||||
|
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule.getAction().getActionDefinitionName());
|
||||||
|
|
||||||
// Now copy the node without copying the children and check that the rules have been copied
|
// Now copy the node without copying the children and check that the rules have been copied
|
||||||
NodeRef copy2 = this.copyService.copy(
|
NodeRef copy2 = this.copyService.copy(
|
||||||
@@ -441,8 +446,11 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
List<Rule> copiedRules2 = this.ruleService.getRules(copy2);
|
List<Rule> copiedRules2 = this.ruleService.getRules(copy2);
|
||||||
assertEquals(1, copiedRules.size());
|
assertEquals(1, copiedRules.size());
|
||||||
Rule copiedRule2 = copiedRules2.get(0);
|
Rule copiedRule2 = copiedRules2.get(0);
|
||||||
assertFalse(rule.getId() == copiedRule2.getId());
|
assertFalse(rule.getNodeRef().equals(copiedRule2.getNodeRef()));
|
||||||
assertEquals(rule.getAction(0).getActionDefinitionName(), copiedRule2.getAction(0).getActionDefinitionName());
|
assertEquals(rule.getTitle(), copiedRule2.getTitle());
|
||||||
|
assertEquals(rule.getDescription(), copiedRule2.getDescription());
|
||||||
|
assertEquals(this.ruleService.getOwningNodeRef(copiedRule2), copy2);
|
||||||
|
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule2.getAction().getActionDefinitionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyToExistingNode()
|
public void testCopyToExistingNode()
|
||||||
@@ -531,11 +539,12 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
params.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, nodeTwo);
|
params.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, nodeTwo);
|
||||||
params.put(MoveActionExecuter.PARAM_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_TYPE_QNAME);
|
params.put(MoveActionExecuter.PARAM_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_TYPE_QNAME);
|
||||||
params.put(MoveActionExecuter.PARAM_ASSOC_QNAME, QName.createQName("{test}ruleCopy"));
|
params.put(MoveActionExecuter.PARAM_ASSOC_QNAME, QName.createQName("{test}ruleCopy"));
|
||||||
Rule rule = this.ruleService.createRule(RuleType.INBOUND);
|
Rule rule = new Rule();
|
||||||
ActionCondition condition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
rule.setRuleType(RuleType.INBOUND);
|
||||||
rule.addActionCondition(condition);
|
|
||||||
Action action = this.actionService.createAction(CopyActionExecuter.NAME, params);
|
Action action = this.actionService.createAction(CopyActionExecuter.NAME, params);
|
||||||
rule.addAction(action);
|
ActionCondition condition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
||||||
|
action.addActionCondition(condition);
|
||||||
|
rule.setAction(action);
|
||||||
this.ruleService.saveRule(nodeOne, rule);
|
this.ruleService.saveRule(nodeOne, rule);
|
||||||
|
|
||||||
// Do a deep copy
|
// Do a deep copy
|
||||||
@@ -609,10 +618,8 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertEquals(1, rules.size());
|
assertEquals(1, rules.size());
|
||||||
Rule copiedRule = rules.get(0);
|
Rule copiedRule = rules.get(0);
|
||||||
assertNotNull(copiedRule);
|
assertNotNull(copiedRule);
|
||||||
List<Action> ruleActions = copiedRule.getActions();
|
Action ruleAction = copiedRule.getAction();
|
||||||
assertNotNull(ruleActions);
|
assertNotNull(ruleAction);
|
||||||
assertEquals(1, ruleActions.size());
|
|
||||||
Action ruleAction = ruleActions.get(0);
|
|
||||||
NodeRef value = (NodeRef)ruleAction.getParameterValue(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
|
NodeRef value = (NodeRef)ruleAction.getParameterValue(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||||
assertNotNull(value);
|
assertNotNull(value);
|
||||||
assertEquals(nodeTwoCopy, value);
|
assertEquals(nodeTwoCopy, value);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package org.alfresco.repo.rule;
|
package org.alfresco.repo.rule;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -163,33 +164,40 @@ public class BaseRuleTest extends BaseSpringTest
|
|||||||
Map<String, Serializable> actionProps = new HashMap<String, Serializable>();
|
Map<String, Serializable> actionProps = new HashMap<String, Serializable>();
|
||||||
actionProps.put(ACTION_PROP_NAME_1, ACTION_PROP_VALUE_1);
|
actionProps.put(ACTION_PROP_NAME_1, ACTION_PROP_VALUE_1);
|
||||||
|
|
||||||
// Create the rule
|
List<String> ruleTypes = new ArrayList<String>(1);
|
||||||
Rule rule = this.ruleService.createRule(this.ruleType.getName());
|
ruleTypes.add(this.ruleType.getName());
|
||||||
rule.setTitle(TITLE);
|
|
||||||
rule.setDescription(DESCRIPTION);
|
// Create the action
|
||||||
rule.applyToChildren(isAppliedToChildren);
|
Action action = this.actionService.createAction(CONDITION_DEF_NAME);
|
||||||
|
action.setParameterValues(conditionProps);
|
||||||
|
|
||||||
ActionCondition actionCondition = this.actionService.createActionCondition(CONDITION_DEF_NAME);
|
ActionCondition actionCondition = this.actionService.createActionCondition(CONDITION_DEF_NAME);
|
||||||
actionCondition.setParameterValues(conditionProps);
|
actionCondition.setParameterValues(conditionProps);
|
||||||
rule.addActionCondition(actionCondition);
|
action.addActionCondition(actionCondition);
|
||||||
|
|
||||||
Action action = this.actionService.createAction(CONDITION_DEF_NAME);
|
// Create the rule
|
||||||
action.setParameterValues(conditionProps);
|
Rule rule = new Rule();
|
||||||
rule.addAction(action);
|
rule.setRuleTypes(ruleTypes);
|
||||||
|
rule.setTitle(TITLE);
|
||||||
|
rule.setDescription(DESCRIPTION);
|
||||||
|
rule.applyToChildren(isAppliedToChildren);
|
||||||
|
rule.setAction(action);
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkRule(RuleImpl rule, String id)
|
protected void checkRule(Rule rule)
|
||||||
{
|
{
|
||||||
// Check the basic details of the rule
|
// Check the basic details of the rule
|
||||||
assertEquals(id, rule.getId());
|
assertEquals(this.ruleType.getName(), rule.getRuleTypes().get(0));
|
||||||
assertEquals(this.ruleType.getName(), rule.getRuleTypeName());
|
|
||||||
assertEquals(TITLE, rule.getTitle());
|
assertEquals(TITLE, rule.getTitle());
|
||||||
assertEquals(DESCRIPTION, rule.getDescription());
|
assertEquals(DESCRIPTION, rule.getDescription());
|
||||||
|
|
||||||
|
Action ruleAction = rule.getAction();
|
||||||
|
assertNotNull(ruleAction);
|
||||||
|
|
||||||
// Check conditions
|
// Check conditions
|
||||||
List<ActionCondition> ruleConditions = rule.getActionConditions();
|
List<ActionCondition> ruleConditions = ruleAction.getActionConditions();
|
||||||
assertNotNull(ruleConditions);
|
assertNotNull(ruleConditions);
|
||||||
assertEquals(1, ruleConditions.size());
|
assertEquals(1, ruleConditions.size());
|
||||||
assertEquals(CONDITION_DEF_NAME, ruleConditions.get(0)
|
assertEquals(CONDITION_DEF_NAME, ruleConditions.get(0)
|
||||||
@@ -202,11 +210,8 @@ public class BaseRuleTest extends BaseSpringTest
|
|||||||
assertEquals(COND_PROP_VALUE_1, condParams.get(COND_PROP_NAME_1));
|
assertEquals(COND_PROP_VALUE_1, condParams.get(COND_PROP_NAME_1));
|
||||||
|
|
||||||
// Check the actions
|
// Check the actions
|
||||||
List<Action> ruleActions = rule.getActions();
|
assertEquals(ACTION_DEF_NAME, ruleAction.getActionDefinitionName());
|
||||||
assertNotNull(ruleActions);
|
Map<String, Serializable> actionParams = ruleAction.getParameterValues();
|
||||||
assertEquals(1, ruleActions.size());
|
|
||||||
assertEquals(ACTION_DEF_NAME, ruleActions.get(0).getActionDefinitionName());
|
|
||||||
Map<String, Serializable> actionParams = ruleActions.get(0).getParameterValues();
|
|
||||||
assertNotNull(actionParams);
|
assertNotNull(actionParams);
|
||||||
assertEquals(1, actionParams.size());
|
assertEquals(1, actionParams.size());
|
||||||
assertTrue(actionParams.containsKey(ACTION_PROP_NAME_1));
|
assertTrue(actionParams.containsKey(ACTION_PROP_NAME_1));
|
||||||
|
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005 Alfresco, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
|
||||||
* with a permitted attribution clause. You may obtain a
|
|
||||||
* copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.alfresco.org/legal/license.txt
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
||||||
* either express or implied. See the License for the specific
|
|
||||||
* language governing permissions and limitations under the
|
|
||||||
* License.
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.rule;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.alfresco.repo.action.CompositeActionImpl;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.rule.Rule;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule implementation class.
|
|
||||||
* <p>
|
|
||||||
* Encapsulates all the information about a rule. Can be creted or editied and
|
|
||||||
* then passed to the rule service to create/update a rule instance.
|
|
||||||
*
|
|
||||||
* @author Roy Wetherall
|
|
||||||
*/
|
|
||||||
public class RuleImpl extends CompositeActionImpl implements Serializable, Rule
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Serial version UID
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 3544385898889097524L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The rule type name
|
|
||||||
*/
|
|
||||||
private String ruleTypeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the rule is applied to all the children of the associated node
|
|
||||||
* rather than just the node itself.
|
|
||||||
*/
|
|
||||||
private boolean isAppliedToChildren = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param ruleTypeName the rule type name
|
|
||||||
*/
|
|
||||||
public RuleImpl(String id, String ruleTypeName, NodeRef owningNodeRef)
|
|
||||||
{
|
|
||||||
super(id, owningNodeRef);
|
|
||||||
ParameterCheck.mandatory("ruleTypeName", ruleTypeName);
|
|
||||||
|
|
||||||
this.ruleTypeName = ruleTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.service.cmr.rule.Rule#isAppliedToChildren()
|
|
||||||
*/
|
|
||||||
public boolean isAppliedToChildren()
|
|
||||||
{
|
|
||||||
return this.isAppliedToChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@see org.alfresco.service.cmr.rule.Rule#applyToChildren(boolean)
|
|
||||||
*/
|
|
||||||
public void applyToChildren(boolean isAppliedToChildren)
|
|
||||||
{
|
|
||||||
this.isAppliedToChildren = isAppliedToChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.service.cmr.rule.Rule#getRuleTypeName()
|
|
||||||
*/
|
|
||||||
public String getRuleTypeName()
|
|
||||||
{
|
|
||||||
return this.ruleTypeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -12,10 +12,13 @@ public interface RuleModel
|
|||||||
/** Rule model constants */
|
/** Rule model constants */
|
||||||
static final String RULE_MODEL_URI = "http://www.alfresco.org/model/rule/1.0";
|
static final String RULE_MODEL_URI = "http://www.alfresco.org/model/rule/1.0";
|
||||||
static final String RULE_MODEL_PREFIX = "rule";
|
static final String RULE_MODEL_PREFIX = "rule";
|
||||||
|
|
||||||
static final QName TYPE_RULE = QName.createQName(RULE_MODEL_URI, "rule");
|
static final QName TYPE_RULE = QName.createQName(RULE_MODEL_URI, "rule");
|
||||||
static final QName PROP_RULE_TYPE = QName.createQName(RULE_MODEL_URI, "ruleType");
|
static final QName PROP_RULE_TYPE = QName.createQName(RULE_MODEL_URI, "ruleType");
|
||||||
static final QName TYPE_RULE_CONTENT = QName.createQName(RULE_MODEL_URI, "rulecontent");
|
|
||||||
static final QName PROP_APPLY_TO_CHILDREN = QName.createQName(RULE_MODEL_URI, "applyToChildren");
|
static final QName PROP_APPLY_TO_CHILDREN = QName.createQName(RULE_MODEL_URI, "applyToChildren");
|
||||||
|
static final QName PROP_EXECUTE_ASYNC = QName.createQName(RULE_MODEL_URI, "executeAsynchronously");
|
||||||
|
static final QName ASSOC_ACTION = QName.createQName(RULE_MODEL_URI, "action");
|
||||||
|
|
||||||
static final QName ASPECT_RULES = QName.createQName(RULE_MODEL_URI, "rules");
|
static final QName ASPECT_RULES = QName.createQName(RULE_MODEL_URI, "rules");
|
||||||
static final QName ASSOC_RULE_FOLDER = QName.createQName(RULE_MODEL_URI, "ruleFolder");
|
static final QName ASSOC_RULE_FOLDER = QName.createQName(RULE_MODEL_URI, "ruleFolder");
|
||||||
}
|
}
|
@@ -109,6 +109,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
private ContentTransformerRegistry transformerRegistry;
|
private ContentTransformerRegistry transformerRegistry;
|
||||||
private CopyService copyService;
|
private CopyService copyService;
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category related values
|
* Category related values
|
||||||
@@ -147,9 +148,10 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
this.actionService = serviceRegistry.getActionService();
|
this.actionService = serviceRegistry.getActionService();
|
||||||
this.transactionService = serviceRegistry.getTransactionService();
|
this.transactionService = serviceRegistry.getTransactionService();
|
||||||
this.transformerRegistry = (ContentTransformerRegistry)applicationContext.getBean("contentTransformerRegistry");
|
this.transformerRegistry = (ContentTransformerRegistry)applicationContext.getBean("contentTransformerRegistry");
|
||||||
|
this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||||
|
|
||||||
AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
||||||
this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
|
this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
|
||||||
@@ -160,10 +162,6 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.TYPE_CONTAINER).getChildRef();
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
||||||
|
|
||||||
// Create and authenticate the user used in the tests
|
|
||||||
//TestWithUserUtils.createUser(USER_NAME, PWD, this.rootNodeRef, this.nodeService, this.authenticationService);
|
|
||||||
//TestWithUserUtils.authenticateUser(USER_NAME, PWD, this.rootNodeRef, this.authenticationService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rule createRule(
|
private Rule createRule(
|
||||||
@@ -173,11 +171,14 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
String conditionName,
|
String conditionName,
|
||||||
Map<String, Serializable> conditionParams)
|
Map<String, Serializable> conditionParams)
|
||||||
{
|
{
|
||||||
Rule rule = this.ruleService.createRule(ruleTypeName);
|
Rule rule = new Rule();
|
||||||
ActionCondition condition = this.actionService.createActionCondition(conditionName, conditionParams);
|
rule.setRuleType(ruleTypeName);
|
||||||
rule.addActionCondition(condition);
|
|
||||||
Action action = this.actionService.createAction(actionName, actionParams);
|
Action action = this.actionService.createAction(actionName, actionParams);
|
||||||
rule.addAction(action);
|
ActionCondition condition = this.actionService.createActionCondition(conditionName, conditionParams);
|
||||||
|
action.addActionCondition(condition);
|
||||||
|
rule.setAction(action);
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,9 +324,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
params2.put(ContentModel.PROP_APPROVE_MOVE.toString(), false);
|
params2.put(ContentModel.PROP_APPROVE_MOVE.toString(), false);
|
||||||
|
|
||||||
// Test that rule can be updated and execute correctly
|
// Test that rule can be updated and execute correctly
|
||||||
rule.removeAllActions();
|
//rule.removeAllActions();
|
||||||
Action action2 = this.actionService.createAction(AddFeaturesActionExecuter.NAME, params2);
|
Action action2 = this.actionService.createAction(AddFeaturesActionExecuter.NAME, params2);
|
||||||
rule.addAction(action2);
|
rule.setAction(action2);
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
|
|
||||||
NodeRef newNodeRef2 = this.nodeService.createNode(
|
NodeRef newNodeRef2 = this.nodeService.createNode(
|
||||||
@@ -427,9 +428,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(contentToCopy);
|
addContentToNode(contentToCopy);
|
||||||
|
|
||||||
// Create the rule and add to folder
|
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put("aspect-name", ContentModel.ASPECT_TEMPLATABLE);
|
params.put("aspect-name", ContentModel.ASPECT_TEMPLATABLE);
|
||||||
|
|
||||||
Rule rule = createRule(
|
Rule rule = createRule(
|
||||||
RuleType.INBOUND,
|
RuleType.INBOUND,
|
||||||
AddFeaturesActionExecuter.NAME,
|
AddFeaturesActionExecuter.NAME,
|
||||||
@@ -1232,9 +1233,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
// Test begins with
|
// Test begins with
|
||||||
Map<String, Serializable> condParamsBegins = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> condParamsBegins = new HashMap<String, Serializable>(1);
|
||||||
condParamsBegins.put(ComparePropertyValueEvaluator.PARAM_VALUE, "bob*");
|
condParamsBegins.put(ComparePropertyValueEvaluator.PARAM_VALUE, "bob*");
|
||||||
rule.removeAllActionConditions();
|
rule.getAction().removeAllActionConditions();
|
||||||
ActionCondition condition1 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME, condParamsBegins);
|
ActionCondition condition1 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME, condParamsBegins);
|
||||||
rule.addActionCondition(condition1);
|
rule.getAction().addActionCondition(condition1);
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
Map<QName, Serializable> propsx = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> propsx = new HashMap<QName, Serializable>();
|
||||||
propsx.put(ContentModel.PROP_NAME, "mybobbins.doc");
|
propsx.put(ContentModel.PROP_NAME, "mybobbins.doc");
|
||||||
@@ -1264,9 +1265,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
// Test ends with
|
// Test ends with
|
||||||
Map<String, Serializable> condParamsEnds = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> condParamsEnds = new HashMap<String, Serializable>(1);
|
||||||
condParamsEnds.put(ComparePropertyValueEvaluator.PARAM_VALUE, "*s.doc");
|
condParamsEnds.put(ComparePropertyValueEvaluator.PARAM_VALUE, "*s.doc");
|
||||||
rule.removeAllActionConditions();
|
rule.getAction().removeAllActionConditions();
|
||||||
ActionCondition condition2 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME, condParamsEnds);
|
ActionCondition condition2 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME, condParamsEnds);
|
||||||
rule.addActionCondition(condition2);
|
rule.getAction().addActionCondition(condition2);
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
Map<QName, Serializable> propsa = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> propsa = new HashMap<QName, Serializable>();
|
||||||
propsa.put(ContentModel.PROP_NAME, "bobbins.document");
|
propsa.put(ContentModel.PROP_NAME, "bobbins.document");
|
||||||
|
@@ -18,7 +18,6 @@ package org.alfresco.repo.rule;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,6 +29,7 @@ import org.alfresco.repo.action.ActionModel;
|
|||||||
import org.alfresco.repo.action.RuntimeActionService;
|
import org.alfresco.repo.action.RuntimeActionService;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.TransactionListener;
|
import org.alfresco.repo.transaction.TransactionListener;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
import org.alfresco.service.cmr.action.ActionServiceException;
|
import org.alfresco.service.cmr.action.ActionServiceException;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
@@ -41,8 +41,6 @@ import org.alfresco.service.cmr.rule.RuleService;
|
|||||||
import org.alfresco.service.cmr.rule.RuleServiceException;
|
import org.alfresco.service.cmr.rule.RuleServiceException;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
@@ -127,6 +125,11 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
*/
|
*/
|
||||||
private TransactionListener ruleTransactionListener = new RuleTransactionListener(this);
|
private TransactionListener ruleTransactionListener = new RuleTransactionListener(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the rules are disabled for the curren thread
|
||||||
|
*/
|
||||||
|
private ThreadLocal<Boolean> rulesDisabled = new ThreadLocal<Boolean>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the permission-safe node service
|
* Set the permission-safe node service
|
||||||
*
|
*
|
||||||
@@ -229,6 +232,30 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
return this.ruleTypes.get(name);
|
return this.ruleTypes.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.rule.RuleService#enableRules()
|
||||||
|
*/
|
||||||
|
public void enableRules()
|
||||||
|
{
|
||||||
|
this.rulesDisabled.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.rule.RuleService#disableRules()
|
||||||
|
*/
|
||||||
|
public void disableRules()
|
||||||
|
{
|
||||||
|
this.rulesDisabled.set(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.rule.RuleService#isEnabled()
|
||||||
|
*/
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return (this.rulesDisabled.get() == null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.rule.RuleService#rulesEnabled(NodeRef)
|
* @see org.alfresco.service.cmr.rule.RuleService#rulesEnabled(NodeRef)
|
||||||
*/
|
*/
|
||||||
@@ -331,7 +358,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
{
|
{
|
||||||
// Create the rule and add to the list
|
// Create the rule and add to the list
|
||||||
NodeRef ruleNodeRef = ruleChildAssocRef.getChildRef();
|
NodeRef ruleNodeRef = ruleChildAssocRef.getChildRef();
|
||||||
Rule rule = createRule(nodeRef, ruleNodeRef);
|
Rule rule = getRule(ruleNodeRef);
|
||||||
allRules.add(rule);
|
allRules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,7 +366,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
for (Rule rule : allRules)
|
for (Rule rule : allRules)
|
||||||
{
|
{
|
||||||
if ((rules.contains(rule) == false) &&
|
if ((rules.contains(rule) == false) &&
|
||||||
(ruleTypeName == null || ruleTypeName.equals(rule.getRuleTypeName()) == true))
|
(ruleTypeName == null || rule.getRuleTypes().contains(ruleTypeName) == true))
|
||||||
{
|
{
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
@@ -459,7 +486,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
// Filter the rule list by rule type
|
// Filter the rule list by rule type
|
||||||
for (Rule rule : allInheritedRules)
|
for (Rule rule : allInheritedRules)
|
||||||
{
|
{
|
||||||
if (rule.getRuleTypeName().equals(ruleTypeName) == true)
|
if (rule.getRuleTypes().contains(ruleTypeName) == true)
|
||||||
{
|
{
|
||||||
inheritedRules.add(rule);
|
inheritedRules.add(rule);
|
||||||
}
|
}
|
||||||
@@ -470,75 +497,31 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
return inheritedRules;
|
return inheritedRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.repo.rule.RuleService#getRule(String)
|
|
||||||
*/
|
|
||||||
public Rule getRule(NodeRef nodeRef, String ruleId)
|
|
||||||
{
|
|
||||||
Rule rule = null;
|
|
||||||
|
|
||||||
if (this.runtimeNodeService.exists(nodeRef) == true)
|
|
||||||
{
|
|
||||||
NodeRef ruleNodeRef = getRuleNodeRefFromId(nodeRef, ruleId);
|
|
||||||
if (ruleNodeRef != null)
|
|
||||||
{
|
|
||||||
rule = createRule(nodeRef, ruleNodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the rule node ref from the action id
|
|
||||||
*
|
|
||||||
* @param nodeRef the node reference
|
|
||||||
* @param actionId the rule id
|
|
||||||
* @return the rule node reference
|
|
||||||
*/
|
|
||||||
private NodeRef getRuleNodeRefFromId(NodeRef nodeRef, String ruleId)
|
|
||||||
{
|
|
||||||
NodeRef result = null;
|
|
||||||
if (this.runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == true)
|
|
||||||
{
|
|
||||||
NodeRef ruleFolder = getSavedRuleFolderRef(nodeRef);
|
|
||||||
if (ruleFolder != null)
|
|
||||||
{
|
|
||||||
DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver();
|
|
||||||
namespacePrefixResolver.registerNamespace(NamespaceService.SYSTEM_MODEL_PREFIX, NamespaceService.SYSTEM_MODEL_1_0_URI);
|
|
||||||
|
|
||||||
List<NodeRef> nodeRefs = searchService.selectNodes(
|
|
||||||
ruleFolder,
|
|
||||||
"*[@sys:" + ContentModel.PROP_NODE_UUID.getLocalName() + "='" + ruleId + "']",
|
|
||||||
null,
|
|
||||||
namespacePrefixResolver,
|
|
||||||
false);
|
|
||||||
if (nodeRefs.size() != 0)
|
|
||||||
{
|
|
||||||
result = nodeRefs.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the rule object from the rule node reference
|
* Create the rule object from the rule node reference
|
||||||
*
|
*
|
||||||
* @param ruleNodeRef the rule node reference
|
* @param ruleNodeRef the rule node reference
|
||||||
* @return the rule
|
* @return the rule
|
||||||
*/
|
*/
|
||||||
private Rule createRule(NodeRef owningNodeRef, NodeRef ruleNodeRef)
|
public Rule getRule(NodeRef ruleNodeRef)
|
||||||
{
|
{
|
||||||
// Get the rule properties
|
// Get the rule properties
|
||||||
Map<QName, Serializable> props = this.runtimeNodeService.getProperties(ruleNodeRef);
|
Map<QName, Serializable> props = this.runtimeNodeService.getProperties(ruleNodeRef);
|
||||||
|
|
||||||
// Create the rule
|
// Create the rule
|
||||||
String ruleTypeName = (String)props.get(RuleModel.PROP_RULE_TYPE);
|
Rule rule = new Rule(ruleNodeRef);
|
||||||
Rule rule = new RuleImpl(ruleNodeRef.getId(), ruleTypeName, owningNodeRef);
|
|
||||||
|
|
||||||
// Set the other rule properties
|
// Set the owning node ref
|
||||||
|
//rule.setOwningNodeRef((NodeRef)props.get(RuleModel.PROP_OWNING_NODEREF));
|
||||||
|
|
||||||
|
// Set the title and description
|
||||||
|
rule.setTitle((String)props.get(ContentModel.PROP_TITLE));
|
||||||
|
rule.setDescription((String)props.get(ContentModel.PROP_DESCRIPTION));
|
||||||
|
|
||||||
|
// Set the rule types
|
||||||
|
rule.setRuleTypes((List<String>)props.get(RuleModel.PROP_RULE_TYPE));
|
||||||
|
|
||||||
|
// Set the applied to children value
|
||||||
boolean isAppliedToChildren = false;
|
boolean isAppliedToChildren = false;
|
||||||
Boolean value = (Boolean)props.get(RuleModel.PROP_APPLY_TO_CHILDREN);
|
Boolean value = (Boolean)props.get(RuleModel.PROP_APPLY_TO_CHILDREN);
|
||||||
if (value != null)
|
if (value != null)
|
||||||
@@ -547,33 +530,48 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
}
|
}
|
||||||
rule.applyToChildren(isAppliedToChildren);
|
rule.applyToChildren(isAppliedToChildren);
|
||||||
|
|
||||||
// Populate the composite action details
|
// Set the execute asynchronously value
|
||||||
runtimeActionService.populateCompositeAction(ruleNodeRef, rule);
|
boolean executeAsync = false;
|
||||||
|
Boolean value2 = (Boolean)props.get(RuleModel.PROP_EXECUTE_ASYNC);
|
||||||
|
if (value2 != null)
|
||||||
|
{
|
||||||
|
executeAsync = value2.booleanValue();
|
||||||
|
}
|
||||||
|
rule.setExecuteAsynchronously(executeAsync);
|
||||||
|
|
||||||
|
// Get the action node reference
|
||||||
|
List<ChildAssociationRef> actions = this.nodeService.getChildAssocs(ruleNodeRef, RuleModel.ASSOC_ACTION, RuleModel.ASSOC_ACTION);
|
||||||
|
if (actions.size() == 0)
|
||||||
|
{
|
||||||
|
throw new RuleServiceException("Rule exists without a specified action");
|
||||||
|
}
|
||||||
|
else if (actions.size() > 1)
|
||||||
|
{
|
||||||
|
throw new RuleServiceException("Rule exists with more than one specified action");
|
||||||
|
}
|
||||||
|
NodeRef actionNodeRef = actions.get(0).getChildRef();
|
||||||
|
|
||||||
|
// Here we need to create the action from the action node reference
|
||||||
|
Action action = runtimeActionService.createAction(actionNodeRef);
|
||||||
|
rule.setAction(action);
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.repo.rule.RuleService#createRule(org.alfresco.repo.rule.RuleType)
|
|
||||||
*/
|
|
||||||
public Rule createRule(String ruleTypeName)
|
|
||||||
{
|
|
||||||
// Create the new rule, giving it a unique rule id
|
|
||||||
String id = GUID.generate();
|
|
||||||
return new RuleImpl(id, ruleTypeName, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.rule.RuleService#saveRule(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.rule.Rule)
|
* @see org.alfresco.repo.rule.RuleService#saveRule(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.rule.Rule)
|
||||||
*/
|
*/
|
||||||
public void saveRule(NodeRef nodeRef, Rule rule)
|
public void saveRule(NodeRef nodeRef, Rule rule)
|
||||||
|
{
|
||||||
|
disableRules();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (this.nodeService.exists(nodeRef) == false)
|
if (this.nodeService.exists(nodeRef) == false)
|
||||||
{
|
{
|
||||||
throw new RuleServiceException("The node does not exist.");
|
throw new RuleServiceException("The node does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef ruleNodeRef = getRuleNodeRefFromId(nodeRef, rule.getId());
|
NodeRef ruleNodeRef = rule.getNodeRef();
|
||||||
if (ruleNodeRef == null)
|
if (ruleNodeRef == null)
|
||||||
{
|
{
|
||||||
if (this.nodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == false)
|
if (this.nodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == false)
|
||||||
@@ -582,33 +580,74 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
this.nodeService.addAspect(nodeRef, RuleModel.ASPECT_RULES, null);
|
this.nodeService.addAspect(nodeRef, RuleModel.ASPECT_RULES, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(3);
|
|
||||||
props.put(RuleModel.PROP_RULE_TYPE, rule.getRuleTypeName());
|
|
||||||
props.put(ActionModel.PROP_DEFINITION_NAME, rule.getActionDefinitionName());
|
|
||||||
props.put(ContentModel.PROP_NODE_UUID, rule.getId());
|
|
||||||
|
|
||||||
// Create the action node
|
// Create the action node
|
||||||
ruleNodeRef = this.nodeService.createNode(
|
ruleNodeRef = this.nodeService.createNode(
|
||||||
getSavedRuleFolderRef(nodeRef),
|
getSavedRuleFolderRef(nodeRef),
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName(RuleModel.RULE_MODEL_URI, ASSOC_NAME_RULES_PREFIX + GUID.generate()),
|
QName.createQName(RuleModel.RULE_MODEL_URI, ASSOC_NAME_RULES_PREFIX + GUID.generate()),
|
||||||
RuleModel.TYPE_RULE,
|
RuleModel.TYPE_RULE).getChildRef();
|
||||||
props).getChildRef();
|
|
||||||
|
|
||||||
// Update the created details
|
// Set the rule node reference and the owning node reference
|
||||||
((RuleImpl)rule).setCreator((String)this.nodeService.getProperty(ruleNodeRef, ContentModel.PROP_CREATOR));
|
rule.setNodeRef(ruleNodeRef);
|
||||||
((RuleImpl)rule).setCreatedDate((Date)this.nodeService.getProperty(ruleNodeRef, ContentModel.PROP_CREATED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the properties of the rule
|
// Update the properties of the rule
|
||||||
|
this.nodeService.setProperty(ruleNodeRef, ContentModel.PROP_TITLE, rule.getTitle());
|
||||||
|
this.nodeService.setProperty(ruleNodeRef, ContentModel.PROP_DESCRIPTION, rule.getDescription());
|
||||||
|
this.nodeService.setProperty(ruleNodeRef, RuleModel.PROP_RULE_TYPE, (Serializable)rule.getRuleTypes());
|
||||||
this.nodeService.setProperty(ruleNodeRef, RuleModel.PROP_APPLY_TO_CHILDREN, rule.isAppliedToChildren());
|
this.nodeService.setProperty(ruleNodeRef, RuleModel.PROP_APPLY_TO_CHILDREN, rule.isAppliedToChildren());
|
||||||
|
this.nodeService.setProperty(ruleNodeRef, RuleModel.PROP_EXECUTE_ASYNC, rule.getExecuteAsynchronously());
|
||||||
|
|
||||||
|
// Save the rule's action
|
||||||
|
saveAction(ruleNodeRef, rule);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
enableRules();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveAction(NodeRef ruleNodeRef, Rule rule)
|
||||||
|
{
|
||||||
|
// Get the action definition from the rule
|
||||||
|
Action action = rule.getAction();
|
||||||
|
if (action == null)
|
||||||
|
{
|
||||||
|
throw new RuleServiceException("An action must be specified when defining a rule.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current action node reference
|
||||||
|
NodeRef actionNodeRef = null;
|
||||||
|
List<ChildAssociationRef> actions = this.nodeService.getChildAssocs(ruleNodeRef, RuleModel.ASSOC_ACTION, RuleModel.ASSOC_ACTION);
|
||||||
|
if (actions.size() == 1)
|
||||||
|
{
|
||||||
|
// We need to check that the action is the same
|
||||||
|
actionNodeRef = actions.get(0).getChildRef();
|
||||||
|
if (actionNodeRef.getId().equals(action.getId()) == false)
|
||||||
|
{
|
||||||
|
// Delete the old action
|
||||||
|
this.nodeService.deleteNode(actionNodeRef);
|
||||||
|
actionNodeRef = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (actions.size() > 1)
|
||||||
|
{
|
||||||
|
throw new RuleServiceException("The rule has become corrupt. More than one action is associated with the rule.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the new action node reference
|
||||||
|
if (actionNodeRef == null)
|
||||||
|
{
|
||||||
|
actionNodeRef = this.runtimeActionService.createActionNodeRef(action, ruleNodeRef, RuleModel.ASSOC_ACTION, RuleModel.ASSOC_ACTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the action node
|
||||||
|
this.runtimeActionService.saveActionImpl(actionNodeRef, action);
|
||||||
|
|
||||||
// Save the remainder of the rule as a composite action
|
|
||||||
runtimeActionService.saveActionImpl(nodeRef, ruleNodeRef, rule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.rule.RuleService#removeRule(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.rule.RuleImpl)
|
* @see org.alfresco.repo.rule.RuleService#removeRule(org.alfresco.repo.ref.NodeRef, org.alfresco.service.cmr.rule.Rule)
|
||||||
*/
|
*/
|
||||||
public void removeRule(NodeRef nodeRef, Rule rule)
|
public void removeRule(NodeRef nodeRef, Rule rule)
|
||||||
{
|
{
|
||||||
@@ -618,7 +657,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
disableRules(nodeRef);
|
disableRules(nodeRef);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NodeRef ruleNodeRef = getRuleNodeRefFromId(nodeRef, rule.getId());
|
NodeRef ruleNodeRef = rule.getNodeRef();
|
||||||
if (ruleNodeRef != null)
|
if (ruleNodeRef != null)
|
||||||
{
|
{
|
||||||
this.nodeService.removeChild(getSavedRuleFolderRef(nodeRef), ruleNodeRef);
|
this.nodeService.removeChild(getSavedRuleFolderRef(nodeRef), ruleNodeRef);
|
||||||
@@ -669,7 +708,8 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
|
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
|
||||||
{
|
{
|
||||||
// First check to see if the node has been disabled
|
// First check to see if the node has been disabled
|
||||||
if (this.disabledNodeRefs.contains(rule.getOwningNodeRef()) == false &&
|
if (this.rulesDisabled.get() == null &&
|
||||||
|
this.disabledNodeRefs.contains(this.getOwningNodeRef(rule)) == false &&
|
||||||
this.disabledRules.contains(rule) == false)
|
this.disabledRules.contains(rule) == false)
|
||||||
{
|
{
|
||||||
PendingRuleData pendingRuleData = new PendingRuleData(actionableNodeRef, actionedUponNodeRef, rule, executeAtEnd);
|
PendingRuleData pendingRuleData = new PendingRuleData(actionableNodeRef, actionedUponNodeRef, rule, executeAtEnd);
|
||||||
@@ -697,7 +737,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
{
|
{
|
||||||
if (logger.isDebugEnabled() == true)
|
if (logger.isDebugEnabled() == true)
|
||||||
{
|
{
|
||||||
logger.debug("The rule '" + rule.getTitle() + "' or the node '" + rule.getOwningNodeRef().getId() + "' has been disabled.");
|
logger.debug("The rule '" + rule.getTitle() + "' or the node '" + this.getOwningNodeRef(rule).getId() + "' has been disabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -717,8 +757,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
{
|
{
|
||||||
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>();
|
List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>();
|
||||||
executePendingRulesImpl(executeAtEndRules);
|
executePendingRulesImpl(executeAtEndRules);
|
||||||
for (PendingRuleData data : executeAtEndRules)
|
for (PendingRuleData data : executeAtEndRules)
|
||||||
@@ -726,15 +765,6 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
executePendingRule(data);
|
executePendingRule(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
//AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
|
|
||||||
//if (logger.isDebugEnabled() == true)
|
|
||||||
//{
|
|
||||||
// logger.debug("Unbinding resource");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the pending rules, iterating until all pending rules have been executed
|
* Executes the pending rules, iterating until all pending rules have been executed
|
||||||
@@ -785,8 +815,14 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
|
|
||||||
if (executedRules == null || canExecuteRule(executedRules, actionedUponNodeRef, rule) == true)
|
if (executedRules == null || canExecuteRule(executedRules, actionedUponNodeRef, rule) == true)
|
||||||
{
|
{
|
||||||
|
Action action = rule.getAction();
|
||||||
|
if (action == null)
|
||||||
|
{
|
||||||
|
throw new RuleServiceException("Attempting to execute a rule that does not have a rule specified.");
|
||||||
|
}
|
||||||
|
|
||||||
// Evaluate the condition
|
// Evaluate the condition
|
||||||
if (this.actionService.evaluateAction(rule, actionedUponNodeRef) == true)
|
if (this.actionService.evaluateAction(action, actionedUponNodeRef) == true)
|
||||||
{
|
{
|
||||||
// Add the rule to the executed rule list
|
// Add the rule to the executed rule list
|
||||||
// (do this before this is executed to prevent rules being added to the pending list)
|
// (do this before this is executed to prevent rules being added to the pending list)
|
||||||
@@ -797,7 +833,8 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute the rule
|
// Execute the rule
|
||||||
this.actionService.executeAction(rule, actionedUponNodeRef);
|
boolean executeAsync = rule.getExecuteAsynchronously();
|
||||||
|
this.actionService.executeAction(action, actionedUponNodeRef, true, executeAsync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1014,4 +1051,70 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.rule.RuleService#getOwningNodeRef(org.alfresco.service.cmr.rule.Rule)
|
||||||
|
*/
|
||||||
|
public NodeRef getOwningNodeRef(Rule rule)
|
||||||
|
{
|
||||||
|
NodeRef result = null;
|
||||||
|
|
||||||
|
NodeRef ruleNodeRef = rule.getNodeRef();
|
||||||
|
if (ruleNodeRef != null)
|
||||||
|
{
|
||||||
|
result = getOwningNodeRefRuleImpl(ruleNodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ruleNodeRef
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private NodeRef getOwningNodeRefRuleImpl(NodeRef ruleNodeRef)
|
||||||
|
{
|
||||||
|
// Get the system folder parent
|
||||||
|
NodeRef systemFolder = this.nodeService.getPrimaryParent(ruleNodeRef).getParentRef();
|
||||||
|
|
||||||
|
// Get the owning node ref
|
||||||
|
return this.nodeService.getPrimaryParent(systemFolder).getParentRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.rule.RuleService#getOwningNodeRef(org.alfresco.service.cmr.action.Action)
|
||||||
|
*/
|
||||||
|
public NodeRef getOwningNodeRef(Action action)
|
||||||
|
{
|
||||||
|
NodeRef result = null;
|
||||||
|
NodeRef actionNodeRef = action.getNodeRef();
|
||||||
|
if (actionNodeRef != null)
|
||||||
|
{
|
||||||
|
result = getOwningNodeRefActionImpl(actionNodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param actionNodeRef
|
||||||
|
*/
|
||||||
|
private NodeRef getOwningNodeRefActionImpl(NodeRef actionNodeRef)
|
||||||
|
{
|
||||||
|
NodeRef result = null;
|
||||||
|
NodeRef parentNodeRef = this.nodeService.getPrimaryParent(actionNodeRef).getParentRef();
|
||||||
|
if (parentNodeRef != null)
|
||||||
|
{
|
||||||
|
QName parentType = this.nodeService.getType(parentNodeRef);
|
||||||
|
if (RuleModel.TYPE_RULE.equals(parentType) == true)
|
||||||
|
{
|
||||||
|
result = getOwningNodeRefRuleImpl(parentNodeRef);
|
||||||
|
}
|
||||||
|
else if (ActionModel.TYPE_COMPOSITE_ACTION.equals(parentType) == true)
|
||||||
|
{
|
||||||
|
result = getOwningNodeRefActionImpl(parentNodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,17 +60,6 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test createRule
|
|
||||||
*/
|
|
||||||
public void testCreateRule()
|
|
||||||
{
|
|
||||||
Rule newRule = this.ruleService.createRule("ruleType1");
|
|
||||||
assertNotNull(newRule);
|
|
||||||
assertNotNull(newRule.getId());
|
|
||||||
assertEquals("ruleType1", newRule.getRuleTypeName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test addRule
|
* Test addRule
|
||||||
*
|
*
|
||||||
@@ -78,17 +67,21 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
public void testAddRule()
|
public void testAddRule()
|
||||||
{
|
{
|
||||||
Rule newRule = createTestRule();
|
Rule newRule = createTestRule();
|
||||||
String ruleId = newRule.getId();
|
|
||||||
this.ruleService.saveRule(this.nodeRef, newRule);
|
this.ruleService.saveRule(this.nodeRef, newRule);
|
||||||
|
assertNotNull(newRule.getNodeRef());
|
||||||
|
|
||||||
Rule savedRule = this.ruleService.getRule(this.nodeRef, ruleId);
|
// Check the owning node reference
|
||||||
|
assertNotNull(this.ruleService.getOwningNodeRef(newRule));
|
||||||
|
assertEquals(this.nodeRef, this.ruleService.getOwningNodeRef(newRule));
|
||||||
|
|
||||||
|
Rule savedRule = this.ruleService.getRule(newRule.getNodeRef());
|
||||||
assertNotNull(savedRule);
|
assertNotNull(savedRule);
|
||||||
assertFalse(savedRule.isAppliedToChildren());
|
assertFalse(savedRule.isAppliedToChildren());
|
||||||
|
|
||||||
savedRule.applyToChildren(true);
|
savedRule.applyToChildren(true);
|
||||||
this.ruleService.saveRule(this.nodeRef, savedRule);
|
this.ruleService.saveRule(this.nodeRef, savedRule);
|
||||||
|
|
||||||
Rule savedRule2 = this.ruleService.getRule(this.nodeRef, ruleId);
|
Rule savedRule2 = this.ruleService.getRule(savedRule.getNodeRef());
|
||||||
assertNotNull(savedRule2);
|
assertNotNull(savedRule2);
|
||||||
assertTrue(savedRule2.isAppliedToChildren());
|
assertTrue(savedRule2.isAppliedToChildren());
|
||||||
}
|
}
|
||||||
@@ -100,9 +93,9 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
assertNotNull(rules1);
|
assertNotNull(rules1);
|
||||||
assertEquals(0, rules1.size());
|
assertEquals(0, rules1.size());
|
||||||
|
|
||||||
Rule newRule = this.ruleService.createRule(ruleType.getName());
|
Rule newRule = createTestRule(); //this.ruleService.createRule(ruleType.getName());
|
||||||
this.ruleService.saveRule(this.nodeRef, newRule);
|
this.ruleService.saveRule(this.nodeRef, newRule);
|
||||||
Rule newRule2 = this.ruleService.createRule(ruleType.getName());
|
Rule newRule2 = createTestRule(); //this.ruleService.createRule(ruleType.getName());
|
||||||
this.ruleService.saveRule(this.nodeRef, newRule2);
|
this.ruleService.saveRule(this.nodeRef, newRule2);
|
||||||
|
|
||||||
List<Rule> rules2 = this.ruleService.getRules(this.nodeRef);
|
List<Rule> rules2 = this.ruleService.getRules(this.nodeRef);
|
||||||
@@ -114,7 +107,6 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
List<Rule> rules3 = this.ruleService.getRules(this.nodeRef);
|
List<Rule> rules3 = this.ruleService.getRules(this.nodeRef);
|
||||||
assertNotNull(rules3);
|
assertNotNull(rules3);
|
||||||
assertEquals(0, rules3.size());
|
assertEquals(0, rules3.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,16 +137,15 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
Rule rule = rules.get(0);
|
Rule rule = rules.get(0);
|
||||||
assertEquals("title", rule.getTitle());
|
assertEquals("title", rule.getTitle());
|
||||||
assertEquals("description", rule.getDescription());
|
assertEquals("description", rule.getDescription());
|
||||||
assertNotNull(rule.getCreatedDate());
|
assertNotNull(this.nodeService.getProperty(rule.getNodeRef(), ContentModel.PROP_CREATED));
|
||||||
assertNotNull(rule.getModifiedDate());
|
assertNotNull(this.nodeService.getProperty(rule.getNodeRef(), ContentModel.PROP_CREATOR));
|
||||||
|
|
||||||
// Check that the condition action have been retireved correctly
|
// Check that the condition action have been retireved correctly
|
||||||
List<ActionCondition> conditions = rule.getActionConditions();
|
Action action = rule.getAction();
|
||||||
|
assertNotNull(action);
|
||||||
|
List<ActionCondition> conditions = action.getActionConditions();
|
||||||
assertNotNull(conditions);
|
assertNotNull(conditions);
|
||||||
assertEquals(1, conditions.size());
|
assertEquals(1, conditions.size());
|
||||||
List<Action> actions = rule.getActions();
|
|
||||||
assertNotNull(actions);
|
|
||||||
assertEquals(1, actions.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,7 +223,9 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (Rule rule : allRules)
|
for (Rule rule : allRules)
|
||||||
{
|
{
|
||||||
if (rule.getOwningNodeRef() == childWithRules)
|
NodeRef owningNodeRef = this.ruleService.getOwningNodeRef(rule);
|
||||||
|
assertNotNull(owningNodeRef);
|
||||||
|
if (owningNodeRef.equals(childWithRules) == true)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@@ -547,17 +540,19 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
actionProps.put(ImageTransformActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CHILDREN);
|
actionProps.put(ImageTransformActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CHILDREN);
|
||||||
actionProps.put(ImageTransformActionExecuter.PARAM_ASSOC_QNAME, ContentModel.ASSOC_CHILDREN);
|
actionProps.put(ImageTransformActionExecuter.PARAM_ASSOC_QNAME, ContentModel.ASSOC_CHILDREN);
|
||||||
|
|
||||||
Rule rule = this.ruleService.createRule(this.ruleType.getName());
|
Rule rule = new Rule();
|
||||||
|
rule.setRuleType(this.ruleType.getName());
|
||||||
rule.setTitle("Convert from *.jpg to *.gif");
|
rule.setTitle("Convert from *.jpg to *.gif");
|
||||||
rule.setExecuteAsynchronously(true);
|
rule.setExecuteAsynchronously(true);
|
||||||
|
|
||||||
ActionCondition actionCondition = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
|
|
||||||
actionCondition.setParameterValues(conditionProps);
|
|
||||||
rule.addActionCondition(actionCondition);
|
|
||||||
|
|
||||||
Action action = this.actionService.createAction(ImageTransformActionExecuter.NAME);
|
Action action = this.actionService.createAction(ImageTransformActionExecuter.NAME);
|
||||||
action.setParameterValues(actionProps);
|
action.setParameterValues(actionProps);
|
||||||
rule.addAction(action);
|
|
||||||
|
ActionCondition actionCondition = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
|
||||||
|
actionCondition.setParameterValues(conditionProps);
|
||||||
|
action.addActionCondition(actionCondition);
|
||||||
|
|
||||||
|
rule.setAction(action);
|
||||||
|
|
||||||
// Create the next rule
|
// Create the next rule
|
||||||
|
|
||||||
@@ -569,17 +564,19 @@ public class RuleServiceImplTest extends BaseRuleTest
|
|||||||
actionProps2.put(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER, nodeRef);
|
actionProps2.put(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER, nodeRef);
|
||||||
actionProps2.put(ImageTransformActionExecuter.PARAM_ASSOC_QNAME, ContentModel.ASSOC_CHILDREN);
|
actionProps2.put(ImageTransformActionExecuter.PARAM_ASSOC_QNAME, ContentModel.ASSOC_CHILDREN);
|
||||||
|
|
||||||
Rule rule2 = this.ruleService.createRule(this.ruleType.getName());
|
Rule rule2 = new Rule();
|
||||||
|
rule2.setRuleType(this.ruleType.getName());
|
||||||
rule2.setTitle("Convert from *.gif to *.jpg");
|
rule2.setTitle("Convert from *.gif to *.jpg");
|
||||||
rule2.setExecuteAsynchronously(true);
|
rule2.setExecuteAsynchronously(true);
|
||||||
|
|
||||||
ActionCondition actionCondition2 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
|
|
||||||
actionCondition2.setParameterValues(conditionProps2);
|
|
||||||
rule2.addActionCondition(actionCondition2);
|
|
||||||
|
|
||||||
Action action2 = this.actionService.createAction(ImageTransformActionExecuter.NAME);
|
Action action2 = this.actionService.createAction(ImageTransformActionExecuter.NAME);
|
||||||
action2.setParameterValues(actionProps2);
|
action2.setParameterValues(actionProps2);
|
||||||
rule2.addAction(action2);
|
|
||||||
|
ActionCondition actionCondition2 = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
|
||||||
|
actionCondition2.setParameterValues(conditionProps2);
|
||||||
|
action2.addActionCondition(actionCondition2);
|
||||||
|
|
||||||
|
rule2.setAction(action2);
|
||||||
|
|
||||||
// Save the rules
|
// Save the rules
|
||||||
this.ruleService.saveRule(nodeRef, rule);
|
this.ruleService.saveRule(nodeRef, rule);
|
||||||
|
@@ -41,11 +41,6 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType
|
|||||||
*/
|
*/
|
||||||
private static Log logger = LogFactory.getLog(RuleTypeImpl.class);
|
private static Log logger = LogFactory.getLog(RuleTypeImpl.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* The action service
|
|
||||||
*/
|
|
||||||
private ActionService actionService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rule service
|
* The rule service
|
||||||
*/
|
*/
|
||||||
@@ -67,16 +62,6 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the action service
|
|
||||||
*
|
|
||||||
* @param actionService the action service
|
|
||||||
*/
|
|
||||||
public void setActionService(ActionService actionService)
|
|
||||||
{
|
|
||||||
this.actionService = actionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rule service
|
* Set the rule service
|
||||||
*
|
*
|
||||||
@@ -115,6 +100,8 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType
|
|||||||
* @see org.alfresco.service.cmr.rule.RuleType#triggerRuleType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.rule.RuleType#triggerRuleType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public void triggerRuleType(NodeRef nodeRef, NodeRef actionedUponNodeRef)
|
public void triggerRuleType(NodeRef nodeRef, NodeRef actionedUponNodeRef)
|
||||||
|
{
|
||||||
|
if (this.ruleService.isEnabled() == true)
|
||||||
{
|
{
|
||||||
if (this.ruleService.hasRules(nodeRef) == true)
|
if (this.ruleService.hasRules(nodeRef) == true)
|
||||||
{
|
{
|
||||||
@@ -127,7 +114,11 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType
|
|||||||
{
|
{
|
||||||
if (logger.isDebugEnabled() == true)
|
if (logger.isDebugEnabled() == true)
|
||||||
{
|
{
|
||||||
logger.debug("Triggering rule " + rule.getId());
|
NodeRef ruleNodeRef = rule.getNodeRef();
|
||||||
|
if (nodeRef != null)
|
||||||
|
{
|
||||||
|
logger.debug("Triggering rule " + ruleNodeRef.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue the rule to be executed at the end of the transaction (but still in the transaction)
|
// Queue the rule to be executed at the end of the transaction (but still in the transaction)
|
||||||
@@ -142,6 +133,7 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
||||||
<import uri="http://www.alfresco.org/model/action/1.0" prefix="act"/>
|
<import uri="http://www.alfresco.org/model/action/1.0" prefix="act"/>
|
||||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
|
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
|
||||||
|
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
|
||||||
</imports>
|
</imports>
|
||||||
|
|
||||||
<namespaces>
|
<namespaces>
|
||||||
@@ -20,17 +21,35 @@
|
|||||||
|
|
||||||
<type name="rule:rule">
|
<type name="rule:rule">
|
||||||
<title>Rule</title>
|
<title>Rule</title>
|
||||||
<parent>act:compositeaction</parent>
|
<parent>sys:base</parent>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="rule:ruleType">
|
<property name="rule:ruleType">
|
||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
<mandatory>true</mandatory>
|
<mandatory>true</mandatory>
|
||||||
|
<multiple>true</multiple>
|
||||||
</property>
|
</property>
|
||||||
<property name="rule:applyToChildren">
|
<property name="rule:applyToChildren">
|
||||||
<type>d:boolean</type>
|
<type>d:boolean</type>
|
||||||
<mandatory>true</mandatory>
|
<mandatory>true</mandatory>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="rule:executeAsynchronously">
|
||||||
|
<type>d:boolean</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
|
<associations>
|
||||||
|
<child-association name="rule:action">
|
||||||
|
<target>
|
||||||
|
<class>act:action</class>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<many>false</many>
|
||||||
|
</target>
|
||||||
|
</child-association>
|
||||||
|
</associations>
|
||||||
|
<mandatory-aspects>
|
||||||
|
<aspect>cm:titled</aspect>
|
||||||
|
<aspect>cm:auditable</aspect>
|
||||||
|
</mandatory-aspects>
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
</types>
|
</types>
|
||||||
|
@@ -29,6 +29,14 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*/
|
*/
|
||||||
public interface Action extends ParameterizedItem
|
public interface Action extends ParameterizedItem
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Gets the node ref that represents the saved action node.
|
||||||
|
* Returns null id unsaved.
|
||||||
|
*
|
||||||
|
* @return the action node reference
|
||||||
|
*/
|
||||||
|
NodeRef getNodeRef();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the action definition that relates to this action
|
* Get the name of the action definition that relates to this action
|
||||||
*
|
*
|
||||||
@@ -64,16 +72,6 @@ public interface Action extends ParameterizedItem
|
|||||||
*/
|
*/
|
||||||
void setDescription(String description);
|
void setDescription(String description);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the node reference of the node that 'owns' this action.
|
|
||||||
* <p>
|
|
||||||
* The node that 'owns' the action is th one that stores it via its
|
|
||||||
* actionable aspect association.
|
|
||||||
*
|
|
||||||
* @return node reference
|
|
||||||
*/
|
|
||||||
NodeRef getOwningNodeRef();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a value indicating whether the action should be executed asychronously or not.
|
* Gets a value indicating whether the action should be executed asychronously or not.
|
||||||
* <p>
|
* <p>
|
||||||
|
@@ -14,43 +14,186 @@
|
|||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.service.cmr.rule;
|
package org.alfresco.service.cmr.rule;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.action.CompositeAction;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule Interface
|
* Rule class.
|
||||||
|
* <p>
|
||||||
|
* Encapsulates all the information about a rule. Can be creted or editied and
|
||||||
|
* then passed to the rule service to create/update a rule instance.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public interface Rule extends CompositeAction
|
public class Rule implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates that the rule is applied to the children of the associated
|
* Serial version UID
|
||||||
* node, not just the node itself.
|
|
||||||
* <p>
|
|
||||||
* By default this will be set to false.
|
|
||||||
*
|
|
||||||
* @return true if the rule is applied to the children of the associated node,
|
|
||||||
* false otherwise
|
|
||||||
*/
|
*/
|
||||||
boolean isAppliedToChildren();
|
private static final long serialVersionUID = 3544385898889097524L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the rule is applied to all children of the associated node
|
* The rule node reference
|
||||||
|
*/
|
||||||
|
private NodeRef nodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The title of the rule
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the rule
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rule types
|
||||||
|
*/
|
||||||
|
private List<String> ruleTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The associated action
|
||||||
|
*/
|
||||||
|
private Action action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the rule should execute the action asynchronously or not
|
||||||
|
*/
|
||||||
|
private boolean executeAsynchronously = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the rule is applied to all the children of the associated node
|
||||||
* rather than just the node itself.
|
* rather than just the node itself.
|
||||||
*
|
|
||||||
* @param isAppliedToChildren true if the rule should be applied to the children, false
|
|
||||||
* otherwise
|
|
||||||
*/
|
*/
|
||||||
void applyToChildren(boolean isAppliedToChildren);
|
private boolean isAppliedToChildren = false;
|
||||||
|
|
||||||
|
public Rule()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rule(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(Action action)
|
||||||
|
{
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action getAction()
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeRef(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeRef getNodeRef()
|
||||||
|
{
|
||||||
|
return nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description)
|
||||||
|
{
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription()
|
||||||
|
{
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the rule type name
|
* @see org.alfresco.service.cmr.rule.Rule#isAppliedToChildren()
|
||||||
*
|
|
||||||
* @return the rule type name
|
|
||||||
*/
|
*/
|
||||||
String getRuleTypeName();
|
public boolean isAppliedToChildren()
|
||||||
|
{
|
||||||
|
return this.isAppliedToChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@see org.alfresco.service.cmr.rule.Rule#applyToChildren(boolean)
|
||||||
|
*/
|
||||||
|
public void applyToChildren(boolean isAppliedToChildren)
|
||||||
|
{
|
||||||
|
this.isAppliedToChildren = isAppliedToChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuleType(String ruleType)
|
||||||
|
{
|
||||||
|
List<String> ruleTypes = new ArrayList<String>(1);
|
||||||
|
ruleTypes.add(ruleType);
|
||||||
|
this.ruleTypes = ruleTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuleTypes(List<String> ruleTypes)
|
||||||
|
{
|
||||||
|
this.ruleTypes = ruleTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getRuleTypes()
|
||||||
|
{
|
||||||
|
return ruleTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExecuteAsynchronously(boolean executeAsynchronously)
|
||||||
|
{
|
||||||
|
this.executeAsynchronously = executeAsynchronously;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getExecuteAsynchronously()
|
||||||
|
{
|
||||||
|
return this.executeAsynchronously;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash code implementation
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.nodeRef.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equals implementation
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if (this == obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof Rule)
|
||||||
|
{
|
||||||
|
Rule that = (Rule) obj;
|
||||||
|
return (this.nodeRef.equals(that.nodeRef));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ package org.alfresco.service.cmr.rule;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +46,26 @@ public interface RuleService
|
|||||||
@Auditable(parameters = {"name"})
|
@Auditable(parameters = {"name"})
|
||||||
public RuleType getRuleType(String name);
|
public RuleType getRuleType(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable rules for the current thread
|
||||||
|
*/
|
||||||
|
@Auditable
|
||||||
|
public void enableRules();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diable rules for the current thread
|
||||||
|
*/
|
||||||
|
@Auditable
|
||||||
|
public void disableRules();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether rules are currently enabled or not
|
||||||
|
*
|
||||||
|
* @return true if rules are enabled, false otherwise
|
||||||
|
*/
|
||||||
|
@Auditable
|
||||||
|
public boolean isEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates wether the rules for a given node are enabled or not. If the
|
* Indicates wether the rules for a given node are enabled or not. If the
|
||||||
* rules are not enabled then they will not be executed.
|
* rules are not enabled then they will not be executed.
|
||||||
@@ -150,26 +171,13 @@ public interface RuleService
|
|||||||
public int countRules(NodeRef nodeRef);
|
public int countRules(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the rule given its id.
|
* Get the rule given its node reference
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param ruleId the rule id
|
* @return the rule corresponding to the node reference
|
||||||
* @return the rule corresponding ot the id
|
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "ruleId"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public Rule getRule(NodeRef nodeRef, String ruleId);
|
public Rule getRule(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to create a new rule.
|
|
||||||
* <p>
|
|
||||||
* Call add rule once the details of the rule have been specified in order
|
|
||||||
* to associate the rule with a node reference.
|
|
||||||
*
|
|
||||||
* @param ruleTypeName the name of the rule type
|
|
||||||
* @return the created rule
|
|
||||||
*/
|
|
||||||
@Auditable(parameters = {"ruleTypeName"})
|
|
||||||
public Rule createRule(String ruleTypeName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the details of the rule to the specified node reference.
|
* Saves the details of the rule to the specified node reference.
|
||||||
@@ -198,4 +206,25 @@ public interface RuleService
|
|||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public void removeAllRules(NodeRef nodeRef);
|
public void removeAllRules(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the owning node reference for a rule.
|
||||||
|
*
|
||||||
|
* @param rule the rule
|
||||||
|
* @return the owning node reference
|
||||||
|
*/
|
||||||
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"rule"})
|
||||||
|
public NodeRef getOwningNodeRef(Rule rule);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the owning node reference for an action. Returns null for an unsaved action or one that is not
|
||||||
|
* parented by a rule.
|
||||||
|
*
|
||||||
|
* NOTE: this method is temporary and will be removed in future versions. It should only be used with good reason.
|
||||||
|
*
|
||||||
|
* @param action the action
|
||||||
|
* @return the owning node reference
|
||||||
|
*/
|
||||||
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"action"})
|
||||||
|
public NodeRef getOwningNodeRef(Action action);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user