mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Added the notion of actions only being applicable for certain node types
- 'Run Action' is now available on folder details page git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2837 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="authenticationComponent">
|
<property name="authenticationComponent">
|
||||||
<ref bean="authenticationComponent" />
|
<ref bean="authenticationComponent" />
|
||||||
|
</property>
|
||||||
|
<property name="dictionaryService">
|
||||||
|
<ref bean="DictionaryService" />
|
||||||
</property>
|
</property>
|
||||||
<property name="asynchronousActionExecutionQueue">
|
<property name="asynchronousActionExecutionQueue">
|
||||||
<ref bean="asynchronousActionExecutionQueue"/>
|
<ref bean="asynchronousActionExecutionQueue"/>
|
||||||
@@ -203,6 +206,11 @@
|
|||||||
<property name="mimetypeService">
|
<property name="mimetypeService">
|
||||||
<ref bean="mimetypeService" />
|
<ref bean="mimetypeService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="applicableTypes">
|
||||||
|
<list>
|
||||||
|
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="transform-image" class="org.alfresco.repo.action.executer.ImageTransformActionExecuter"
|
<bean id="transform-image" class="org.alfresco.repo.action.executer.ImageTransformActionExecuter"
|
||||||
@@ -234,6 +242,11 @@
|
|||||||
<property name="cociService">
|
<property name="cociService">
|
||||||
<ref bean="checkOutCheckInService"></ref>
|
<ref bean="checkOutCheckInService"></ref>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="applicableTypes">
|
||||||
|
<list>
|
||||||
|
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="check-out" class="org.alfresco.repo.action.executer.CheckOutActionExecuter" parent="action-executer">
|
<bean id="check-out" class="org.alfresco.repo.action.executer.CheckOutActionExecuter" parent="action-executer">
|
||||||
@@ -243,6 +256,11 @@
|
|||||||
<property name="cociService">
|
<property name="cociService">
|
||||||
<ref bean="checkOutCheckInService"></ref>
|
<ref bean="checkOutCheckInService"></ref>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="applicableTypes">
|
||||||
|
<list>
|
||||||
|
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="mail" class="org.alfresco.repo.action.executer.MailActionExecuter" parent="action-executer">
|
<bean id="mail" class="org.alfresco.repo.action.executer.MailActionExecuter" parent="action-executer">
|
||||||
@@ -291,6 +309,11 @@
|
|||||||
<property name="metadataExtracterRegistry">
|
<property name="metadataExtracterRegistry">
|
||||||
<ref bean="metadataExtracterRegistry" />
|
<ref bean="metadataExtracterRegistry" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="applicableTypes">
|
||||||
|
<list>
|
||||||
|
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="import" class="org.alfresco.repo.action.executer.ImporterActionExecuter" parent="action-executer">
|
<bean id="import" class="org.alfresco.repo.action.executer.ImporterActionExecuter" parent="action-executer">
|
||||||
|
@@ -16,7 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.action;
|
package org.alfresco.repo.action;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule action implementation class
|
* Rule action implementation class
|
||||||
@@ -36,6 +39,9 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
|
|||||||
*/
|
*/
|
||||||
private String ruleActionExecutor;
|
private String ruleActionExecutor;
|
||||||
|
|
||||||
|
/** List of applicable types */
|
||||||
|
private List<QName> applicableTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -65,4 +71,24 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
|
|||||||
{
|
{
|
||||||
return ruleActionExecutor;
|
return ruleActionExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of applicable types
|
||||||
|
*
|
||||||
|
* @return the list of qnames
|
||||||
|
*/
|
||||||
|
public List<QName> getApplicableTypes()
|
||||||
|
{
|
||||||
|
return this.applicableTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list of applicable types
|
||||||
|
*
|
||||||
|
* @param applicableTypes the applicable types
|
||||||
|
*/
|
||||||
|
public void setApplicableTypes(List<QName> applicableTypes)
|
||||||
|
{
|
||||||
|
this.applicableTypes = applicableTypes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,7 @@ 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.action.CompositeAction;
|
import org.alfresco.service.cmr.action.CompositeAction;
|
||||||
import org.alfresco.service.cmr.action.ParameterizedItem;
|
import org.alfresco.service.cmr.action.ParameterizedItem;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -98,6 +99,9 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
*/
|
*/
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
|
|
||||||
|
/** The dictionary service */
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
/** The authentication component */
|
/** The authentication component */
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
@@ -161,6 +165,16 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
this.authenticationComponent = authenticationComponent;
|
this.authenticationComponent = authenticationComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the dictionary service
|
||||||
|
*
|
||||||
|
* @param dictionaryService the dictionary service
|
||||||
|
*/
|
||||||
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
|
{
|
||||||
|
this.dictionaryService = dictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the asynchronous action execution queue
|
* Set the asynchronous action execution queue
|
||||||
*
|
*
|
||||||
@@ -218,6 +232,44 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
|||||||
return new ArrayList<ActionDefinition>(this.actionDefinitions.values());
|
return new ArrayList<ActionDefinition>(this.actionDefinitions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.action.ActionService#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
if (nodeRef == null)
|
||||||
|
{
|
||||||
|
return getActionDefinitions();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO for now we will only filter by type, we will introduce filtering by aspect later
|
||||||
|
QName nodeType = this.nodeService.getType(nodeRef);
|
||||||
|
List<ActionDefinition> result = new ArrayList<ActionDefinition>();
|
||||||
|
for (ActionDefinition actionDefinition : getActionDefinitions())
|
||||||
|
{
|
||||||
|
List<QName> appliciableTypes = actionDefinition.getApplicableTypes();
|
||||||
|
if (appliciableTypes != null && appliciableTypes.isEmpty() == false)
|
||||||
|
{
|
||||||
|
for (QName applicableType : actionDefinition.getApplicableTypes())
|
||||||
|
{
|
||||||
|
if (this.dictionaryService.isSubClass(nodeType, applicableType))
|
||||||
|
{
|
||||||
|
result.add(actionDefinition);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.add(actionDefinition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.action.ActionService#getActionConditionDefinition(java.lang.String)
|
* @see org.alfresco.service.cmr.action.ActionService#getActionConditionDefinition(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@@ -55,6 +55,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
private static final String BAD_NAME = "badName";
|
private static final String BAD_NAME = "badName";
|
||||||
|
|
||||||
private NodeRef nodeRef;
|
private NodeRef nodeRef;
|
||||||
|
private NodeRef folder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetUpInTransaction() throws Exception
|
protected void onSetUpInTransaction() throws Exception
|
||||||
@@ -71,6 +72,12 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.PROP_CONTENT,
|
ContentModel.PROP_CONTENT,
|
||||||
new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
|
new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
|
||||||
|
this.folder = this.nodeService.createNode(
|
||||||
|
this.rootNodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
QName.createQName("{test}testFolder"),
|
||||||
|
ContentModel.TYPE_FOLDER).getChildRef();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,11 +101,17 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
List<ActionDefinition> defintions = this.actionService.getActionDefinitions();
|
List<ActionDefinition> defintions = this.actionService.getActionDefinitions();
|
||||||
assertNotNull(defintions);
|
assertNotNull(defintions);
|
||||||
assertFalse(defintions.isEmpty());
|
assertFalse(defintions.isEmpty());
|
||||||
|
int totalCount = defintions.size();
|
||||||
|
|
||||||
for (ActionDefinition definition : defintions)
|
for (ActionDefinition definition : defintions)
|
||||||
{
|
{
|
||||||
System.out.println(definition.getTitle());
|
System.out.println(definition.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the action defintions for a folder type (there should be less than the total available)
|
||||||
|
List<ActionDefinition> definitions = this.actionService.getActionDefinitions(this.folder);
|
||||||
|
assertNotNull(definitions);
|
||||||
|
assertTrue(totalCount > definitions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,11 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.action.executer;
|
package org.alfresco.repo.action.executer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.action.ActionDefinitionImpl;
|
import org.alfresco.repo.action.ActionDefinitionImpl;
|
||||||
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
|
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule action executor abstract base.
|
* Rule action executor abstract base.
|
||||||
@@ -39,6 +43,9 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
|||||||
*/
|
*/
|
||||||
protected boolean publicAction = true;
|
protected boolean publicAction = true;
|
||||||
|
|
||||||
|
/** List of types and aspects for which this action is applicable */
|
||||||
|
protected List<QName> applicableTypes = new ArrayList<QName>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init method
|
* Init method
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +67,19 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
|||||||
this.publicAction = publicAction;
|
this.publicAction = publicAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the list of types for which this action is applicable
|
||||||
|
*
|
||||||
|
* @param applicableTypes arry of applicable types
|
||||||
|
*/
|
||||||
|
public void setApplicableTypes(String[] applicableTypes)
|
||||||
|
{
|
||||||
|
for (String type : applicableTypes)
|
||||||
|
{
|
||||||
|
this.applicableTypes.add(QName.createQName(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get rule action definition
|
* Get rule action definition
|
||||||
*
|
*
|
||||||
@@ -75,6 +95,7 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
|||||||
((ActionDefinitionImpl)this.actionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
|
((ActionDefinitionImpl)this.actionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
|
||||||
((ActionDefinitionImpl)this.actionDefinition).setRuleActionExecutor(this.name);
|
((ActionDefinitionImpl)this.actionDefinition).setRuleActionExecutor(this.name);
|
||||||
((ActionDefinitionImpl)this.actionDefinition).setParameterDefinitions(getParameterDefintions());
|
((ActionDefinitionImpl)this.actionDefinition).setParameterDefinitions(getParameterDefintions());
|
||||||
|
((ActionDefinitionImpl)this.actionDefinition).setApplicableTypes(this.applicableTypes);
|
||||||
}
|
}
|
||||||
return this.actionDefinition;
|
return this.actionDefinition;
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.service.cmr.action;
|
package org.alfresco.service.cmr.action;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,5 +29,10 @@ package org.alfresco.service.cmr.action;
|
|||||||
*/
|
*/
|
||||||
public interface ActionDefinition extends ParameterizedItemDefinition
|
public interface ActionDefinition extends ParameterizedItemDefinition
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Gets a list of the types that this action item is applicable for
|
||||||
|
*
|
||||||
|
* @return list of types
|
||||||
|
*/
|
||||||
|
public List<QName> getApplicableTypes();
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,15 @@ public interface ActionService
|
|||||||
*/
|
*/
|
||||||
List<ActionDefinition> getActionDefinitions();
|
List<ActionDefinition> getActionDefinitions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the action definitions that are applicable for the given node, based on
|
||||||
|
* its type and aspects.
|
||||||
|
*
|
||||||
|
* @param nodeRef the node reference
|
||||||
|
* @return a list of applicable action definitions
|
||||||
|
*/
|
||||||
|
List<ActionDefinition> getActionDefinitions(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a named action condition definition
|
* Get a named action condition definition
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user