Download - Custom Action Framework
1
Custom Action Framework
Neil Mc Erlean Ph.D.Senior Engineer, Alfresco
twitter: @neilmcer
2
Custom Action Framework
Agenda
Introduction• features, capabilities• recipe for custom action development
Demo I - Dev
Alfresco 3.4 action enhancements
Demo II – ActionTrackingService
Questions
3
Custom Action Framework
Introduction
What is an action?
Built-in actions.• check-out• create-thumbnail
Parameters & conditions
Composite actions
[A]synchronous, persistable.
Building blocks for app dev (e.g. RM module)
4
Action triggers
Programmatically from Java, JavaScript or over REST
Action javaAction = actionService.createAction(name);javaAction.setParameterValue(“magicNumber”, 42);actionService.executeAction(javaAction, nodeRef);
var jsAction = actions.create(name);jsAction.parameters[“magicNumber”] = 42;
jsAction.execute(node);POST /api/actionQueue?async=true
5
The Action Services
• Get• Action Definitions• Action Condition Definitions• Parameter Constraints
• Create• Action• Action Condition
• Evaluate, Execute Actions
ActionService
• Save Action• Create Action (from saved
node)
public-services-context.xml
action-services-context.xml
RuntimeActionService
6
actionModel.xml (very abridged)
<type name="act:actionbase"> <associations> <child-association name="act:parameters”/> </associations> </type> <type name="act:action"> <parent>act:actionbase</parent> <properties> <property name="act:actionTitle”/> <property name="act:actionDescription”/> <property name="act:executeAsynchronously”/> <property name="act:runAsUser”/> </properties> <associations> <child-association name="act:conditions”/> <child-association name="act:compensatingAction”/> </associations></type>
7
Writing a custom action
3 basic components
8
The Action Executer
abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstractBase implements ActionExecuter{ protected abstract void executeImpl(Action action,
NodeRef actionedUponNodeRef);}
public abstract class ParameterizedItemAbstractBase{ protected abstract void addParameterDefinitions(List<ParameterDefinition> paramList);}
9
The resource file(s)config/alfresco/messages/foo-config.properties
{a}.title=My title
{a}.description=My desc.
{a}.{param-name}.display-label=My display label
{a} is action bean name
10
Spring configuration
<beans> <bean id="imageWatermarkActionBase” class="org.alfresco.repo.watermarks.ImageWatermarkingAction"
parent="action-executer"></bean>
<bean id="watermarkResourceBundles" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
<property name="resourceBundles"> <list> <value>alfresco.messages.watermark-config</value> </list> </property> </bean></beans>
11
Custom Action Framework
Demo I – Watermarks and QR codes
?
12
What are QR codes?
QR codes
2-d barcodeTM Denso Wave, Inc.
ISO’d & license-free
iPhone & Android apps
Popular in Japan
Appearing in Ireland.
Hyperlinks for the physical world?
13
Using QR codes
How to
Launch a “QR Reader” app
Point your phone’s camera at the QR code
Done :)
14
QR codes in the media
15
Demo I
Watermarks and QR codes
16
Architecture
17
Demo I ctd.
• See Eclipse & Share UI watermarks-context.xmlwatermark-config.propertiesWatermarkPositioning.javaImageWatermarkingAction.javabarcodes-context.xmlQrCodeProvider.java
18
19
20
Action enhancements in Alfresco 3.4
ScheduledPersistedActionService & Action Tracking Service
•Requirement driver: Replication & Transfer Service• Long-running actions.• Lists of target nodes
•Action management & monitoring (via Java / REST)• Action Execution Status• Cancellable actions.
•Restrictions (Replication requirements)• persisted actions only• actions without target nodes only• REST API only available to admin
•We can build on this…
21
New act:action properties
<type name="act:action"> <properties> <property name="act:executionStartDate” /> <property name="act:executionEndDate” /> <property name="act:executionActionStatus"> <type>d:text</type> <mandatory>false</mandatory> <constraints> <constraint ref="act:allowedExecutionstatuses”/> </constraints> </property> <property name="act:executionFailureMessage” /> </properties> </type>
22
act:allowedExecutionstatuses
<constraint name="act:allowedExecutionstatuses” type="LIST"> <parameter name="allowedValues"> <list> <value>New</value> <value>Pending</value> <value>Running</value> <value>Completed</value> <value>Cancelled</value> <value>Failed</value> </list> </parameter></constraint>
23
Running actions REST API
GET /api/running-actions? type={type?}&nodeRef={nodeRef?}
GET /api/running-action/{action_tracking_id}
POST /api/running-actions?nodeRef={nodeRef?}
DELETE /api/running-action/{action_tracking_id}
24
Demo II
Action Tracking Service
25
Questions?
wiki.alfresco.comforums.alfresco.comissues.alfresco.com
twitter: @neilmcer
26
Shape & Color Palette
Normal Text
Normal TextNormal Text
27