Custom Action Framework

4,388 views
4,150 views

Published on

This session starts with an overview of the custom action framework. Learn how to leverage Alfresco's action services to perform repeatable operations on your content. Understand Alfresco's built-in actions and discover how you can encapsulate your business logic in your own custom actions should you need to. Then you'll see how these software components can be reused on demand from the browser or automatically from folder rules, scheduled jobs and other sources. Finally you'll be brought fully up to date with recent feature development by Alfresco in this area.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,388
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
53
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Custom Action Framework

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

×