Download - Custom Action Framework
![Page 1: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/1.jpg)
1
Custom Action Framework
Neil Mc Erlean Ph.D.Senior Engineer, Alfresco
twitter: @neilmcer
![Page 2: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/2.jpg)
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
![Page 3: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/3.jpg)
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)
![Page 4: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/4.jpg)
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
![Page 5: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/5.jpg)
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
![Page 6: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/6.jpg)
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>
![Page 7: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/7.jpg)
7
Writing a custom action
3 basic components
![Page 8: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/8.jpg)
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);}
![Page 9: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/9.jpg)
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
![Page 10: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/10.jpg)
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>
![Page 11: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/11.jpg)
11
Custom Action Framework
Demo I – Watermarks and QR codes
?
![Page 12: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/12.jpg)
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?
![Page 13: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/13.jpg)
13
Using QR codes
How to
Launch a “QR Reader” app
Point your phone’s camera at the QR code
Done :)
![Page 14: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/14.jpg)
14
QR codes in the media
![Page 15: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/15.jpg)
15
Demo I
Watermarks and QR codes
![Page 16: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/16.jpg)
16
Architecture
![Page 17: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/17.jpg)
17
Demo I ctd.
• See Eclipse & Share UI watermarks-context.xmlwatermark-config.propertiesWatermarkPositioning.javaImageWatermarkingAction.javabarcodes-context.xmlQrCodeProvider.java
![Page 18: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/18.jpg)
18
![Page 19: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/19.jpg)
19
![Page 20: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/20.jpg)
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…
![Page 21: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/21.jpg)
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>
![Page 22: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/22.jpg)
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>
![Page 23: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/23.jpg)
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}
![Page 24: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/24.jpg)
24
Demo II
Action Tracking Service
![Page 25: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/25.jpg)
25
Questions?
wiki.alfresco.comforums.alfresco.comissues.alfresco.com
twitter: @neilmcer
![Page 26: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/26.jpg)
26
Shape & Color Palette
Normal Text
Normal TextNormal Text
![Page 27: Custom Action Framework](https://reader033.vdocuments.net/reader033/viewer/2022052412/5589d020d8b42a58578b4650/html5/thumbnails/27.jpg)
27