Transcript
Page 1: Custom Action Framework

1

Custom Action Framework

Neil Mc Erlean Ph.D.Senior Engineer, Alfresco

twitter: @neilmcer

Page 2: Custom Action Framework

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

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

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

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

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

7

Writing a custom action

3 basic components

Page 8: Custom Action Framework

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

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

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

11

Custom Action Framework

Demo I – Watermarks and QR codes

?

Page 12: Custom Action Framework

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

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

14

QR codes in the media

Page 15: Custom Action Framework

15

Demo I

Watermarks and QR codes

Page 16: Custom Action Framework

16

Architecture

Page 17: Custom Action Framework

17

Demo I ctd.

• See Eclipse & Share UI watermarks-context.xmlwatermark-config.propertiesWatermarkPositioning.javaImageWatermarkingAction.javabarcodes-context.xmlQrCodeProvider.java

Page 18: Custom Action Framework

18

Page 19: Custom Action Framework

19

Page 20: Custom Action Framework

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

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

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

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

24

Demo II

Action Tracking Service

Page 25: Custom Action Framework

25

Questions?

wiki.alfresco.comforums.alfresco.comissues.alfresco.com

twitter: @neilmcer

Page 26: Custom Action Framework

26

Shape & Color Palette

Normal Text

Normal TextNormal Text

Page 27: Custom Action Framework

27


Top Related