0
Using Web Scripts in a REST-based Architecture Richard Im Solutions Engineer www.alfresco.com See the recorded webinar her...
* What is REST? * What is a Web Script? * Common uses of Web Scripts * Review a Web Script for UI components * Review a We...
Acronym for: Representational State Transfer <ul><li>An architectural style.  Systems following these principles referred ...
Key Rest Principles <ul><li>Application state and functionality are abstracted into resources </li></ul><ul><li>Every reso...
REST v. SOAP WS <ul><li>Cacheable representations, leading to improved response time. </li></ul><ul><li>Less dependencies:...
REST & Alfresco = Web Scripts <ul><li>From 2.1 onward – ideally to open it up to more channels: Office, Portal, Websites <...
Alfresco Web Scripts Web Script REST Dispatcher Web Script REST Infrastructure Content Services Rendition Services FreeMar...
What makes a Web Script? <ul><li>XML Descriptor file: define your resource </li></ul><ul><li>Javascript: Controller with a...
XML Descriptor: docActions.get.desc.xml <ul><li>XML Descriptor file: define your resource and HTTP method (naming conventi...
// Client has requested server-side action /* Inputs */ var runAction = args.a; /* Outputs */ var resultString = &quot;Act...
Alfresco Web Scripts cont... JSON ATOM HTML See the recorded webinar here: http:// snurl .com/ webscripts
OK Great, now how do I apply this in a REST Architecture? <ul><li>Can be applied in a DM or WCM Deployment, in similar fas...
Office Plugin <ul><li>Implemented in mini browser window </li></ul><ul><li>All actions available through REST API </li></u...
Portlets/Gadgets <ul><li>Allow users access through a portal like iGoogle. </li></ul><ul><li>Since Web Scripts are jsr-168...
Sample DM Architecture <ul><li>Client access Alfresco Web Scripts Directly </li></ul><ul><ul><li>UI Web Scripts, Office Pl...
Sample Customer DM Architecture <ul><li>Customer uses Alfresco as DAM </li></ul><ul><li>Manages all contents internally wi...
Sample WCM Architecture <ul><li>Create your content on Alfresco WCM Server (Authoring)‏ </li></ul><ul><li>Content (XML fil...
Links <ul><li>Alfresco Content Community Developer Toolbox: http://tinyurl.com/6yajvj </li></ul><ul><ul><li>http://wiki.al...
Q&A and Resources 03.04.08 <ul><li>Resources: </li></ul><ul><ul><li>Developer Toolbox:  http://tinyurl.com/6yajvj </li></u...
See the recorded webinar 03.04.08 See the recorded webinar here: http:// snurl .com/ webscripts
Upcoming SlideShare
Loading in...5
×

Webscripts in an Alfresco REST Architecture

11,748

Published on

Full webinar with audio: http://tinyurl.com/6zdkjz

Alfresco Web scripts enable you to open up Alfresco, and make it accessible to other tools and applications.

This webinar is all about Web Scripts, and how they empower you to get the most out of Alfresco.

Published in: Technology

Transcript of "Webscripts in an Alfresco REST Architecture"

  1. 1. Using Web Scripts in a REST-based Architecture Richard Im Solutions Engineer www.alfresco.com See the recorded webinar here: http:// snurl .com/ webscripts
  2. 2. * What is REST? * What is a Web Script? * Common uses of Web Scripts * Review a Web Script for UI components * Review a Web Script for data retrieval * Sample. Agenda: See the recorded webinar here: http:// snurl .com/ webscripts
  3. 3. Acronym for: Representational State Transfer <ul><li>An architectural style. Systems following these principles referred to as 'RESTful' </li></ul><ul><li>Resources are URL-Addressable. Easy utilizing HTTP Methods: GET, POST, PUT, DELETE. </li></ul><ul><li>“ REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed. </li></ul><ul><li>The term is often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies.” </li></ul>What is REST? See the recorded webinar here: http:// snurl .com/ webscripts
  4. 4. Key Rest Principles <ul><li>Application state and functionality are abstracted into resources </li></ul><ul><li>Every resource is uniquely addressable using a universal syntax for use in hypermedia links </li></ul><ul><li>All resources share a uniform interface for the transfer of state between client and resource, consisting of </li></ul><ul><ul><li>A constrained set of well-defined operations </li></ul></ul><ul><ul><li>A constrained set of content types, optionally supporting code on demand </li></ul></ul><ul><li>A protocol which is: Client-server, Stateless, Cacheable, Layered </li></ul>The Principles of REST See the recorded webinar here: http:// snurl .com/ webscripts
  5. 5. REST v. SOAP WS <ul><li>Cacheable representations, leading to improved response time. </li></ul><ul><li>Less dependencies: i.e. no SOAP </li></ul><ul><li>No need for a resource directory </li></ul><ul><li>More scalable. No session state maintenance required across servers. </li></ul><ul><li>Exchange of Resources, rather than Methods – Nouns v. Verbs </li></ul>REST Web Services See the recorded webinar here: http:// snurl .com/ webscripts
  6. 6. REST & Alfresco = Web Scripts <ul><li>From 2.1 onward – ideally to open it up to more channels: Office, Portal, Websites </li></ul><ul><li>Ease of use and lightweight: Javascript, Templates </li></ul><ul><li>Multi use: create your own API, new UI components, widgets, expose features. </li></ul><ul><li>Cross language and cross platform data. </li></ul><ul><li>MVC – Alfresco Repository (Model), Javascript (Controller), Freemarker (View). </li></ul>Alfresco Web Scripts See the recorded webinar here: http:// snurl .com/ webscripts
  7. 7. Alfresco Web Scripts Web Script REST Dispatcher Web Script REST Infrastructure Content Services Rendition Services FreeMarker Repository Search Navigation Security HTML, ATOM, RSS, JSON URL JavaScript 2 3 5 4 6 1 <ul><li>Content </li></ul><ul><li>Metadata </li></ul><ul><li>User Interface Components </li></ul><ul><li>Queries </li></ul>See the recorded webinar here: http:// snurl .com/ webscripts
  8. 8. What makes a Web Script? <ul><li>XML Descriptor file: define your resource </li></ul><ul><li>Javascript: Controller with access to various content services </li></ul><ul><ul><li>Search: Search the repository and format the result any way needed. </li></ul></ul><ul><ul><li>Create: Add content into the repository. </li></ul></ul><ul><ul><li>Navigate: See what is in the repository </li></ul></ul><ul><ul><li>Security: Make sure you have the permissions to access </li></ul></ul><ul><li>Freemarker: Representation/Response, format can be XML, JSON, HTML </li></ul>Alfresco Web Scripts cont... See the recorded webinar here: http:// snurl .com/ webscripts
  9. 9. XML Descriptor: docActions.get.desc.xml <ul><li>XML Descriptor file: define your resource and HTTP method (naming convention)‏ </li></ul><ul><li>url: Define your resource and any parameters needed to execute </li></ul><ul><li>Level of authentication required to run </li></ul><ul><li>Optionally define whether a transaction is required. </li></ul><ul><li>Can define a default format to fall back to incase format is not defined when executing. </li></ul>Alfresco Web Scripts Example <webscript> <shortname> Document Actions (Office Add-In) </shortname> <description> Used by the Office Add-In to perform actions on managed documents </description> <url> /office/docActions </url> <authentication> user </authentication> <transaction> required </transaction> </webscript> See the recorded webinar here: http:// snurl .com/ webscripts
  10. 10. // Client has requested server-side action /* Inputs */ var runAction = args.a; /* Outputs */ var resultString = &quot;Action failed&quot;, resultCode = false; // Is this action targetting a document? var docNodeId = args.n; if ((docNodeId != &quot;&quot;) && (docNodeId != null))‏ { var docNode = search.findNode(&quot;workspace://SpacesStore/&quot; + docNodeId); if (docNode != null && docNode.isDocument) { try { if (runAction == &quot;makepdf&quot;) { resultString = &quot;Could not convert document&quot;; var nodeTrans = docNode.transformDocument(&quot;application/pdf&quot;); if (nodeTrans != null) { resultString = &quot;Document converted&quot;; resultCode = true; } }... Javscript Controller: docActions.get.js Alfresco Web Scripts Example See the recorded webinar here: http:// snurl .com/ webscripts
  11. 11. Alfresco Web Scripts cont... JSON ATOM HTML See the recorded webinar here: http:// snurl .com/ webscripts
  12. 12. OK Great, now how do I apply this in a REST Architecture? <ul><li>Can be applied in a DM or WCM Deployment, in similar fashion </li></ul><ul><li>Customize a completely different UI (i.e. Flex, HTML, Portal). (Web Scripts feature, not necessarily REST)‏ </li></ul><ul><li>Use Alfresco in your own app without exposing them to Alfresco. You will get the performance and reliability of all Alfresco services but abstract it from the user's perspective. Data API </li></ul><ul><li>Serve content to users through Alfresco ASRs </li></ul><ul><li>Provide data to other services whether they're written in .NET, PHP, Java, etc. </li></ul>Web Scripts and REST Architecture See the recorded webinar here: http:// snurl .com/ webscripts
  13. 13. Office Plugin <ul><li>Implemented in mini browser window </li></ul><ul><li>All actions available through REST API </li></ul><ul><ul><li>HTML Response for UI </li></ul></ul><ul><ul><li>Other json for responses to update UI and data retrieval. </li></ul></ul><ul><li>Core services accessible through plug-in </li></ul><ul><ul><li>Doc management </li></ul></ul><ul><ul><li>Workflow </li></ul></ul><ul><ul><li>Search </li></ul></ul>RESTful UI See the recorded webinar here: http:// snurl .com/ webscripts
  14. 14. Portlets/Gadgets <ul><li>Allow users access through a portal like iGoogle. </li></ul><ul><li>Since Web Scripts are jsr-168 compliant, just have to make portal aware. </li></ul><ul><li>Popular portals: Jboss Portal, Liferay </li></ul><ul><li>All data transmitted through json, xml, html, through custom REST API </li></ul>RESTful UI See the recorded webinar here: http:// snurl .com/ webscripts
  15. 15. Sample DM Architecture <ul><li>Client access Alfresco Web Scripts Directly </li></ul><ul><ul><li>UI Web Scripts, Office Plugin Web Scripts, etc. </li></ul></ul><ul><li>Or...Layer another application in between. </li></ul><ul><ul><li>Webapp access Alfresco using RESTful API to retrieve data: XML, JSON, HTML </li></ul></ul><ul><li>Can scale and cluster this environment </li></ul><ul><ul><li>Your webapp </li></ul></ul><ul><ul><li>Alfresco ECM server </li></ul></ul>RESTful DM Alfresco ECM Server Your Webapp See the recorded webinar here: http:// snurl .com/ webscripts
  16. 16. Sample Customer DM Architecture <ul><li>Customer uses Alfresco as DAM </li></ul><ul><li>Manages all contents internally with Alfresco with custom UI and actions. </li></ul><ul><li>Same data then pushed out through transfer to serve internet </li></ul><ul><ul><li>Webapp utilizes Web Scripts to get data from DMZ Alfresco </li></ul></ul><ul><ul><li>Able to perform transformations on images </li></ul></ul><ul><ul><li>Can download transformed or original. </li></ul></ul><ul><li>Serves worldwide user base. </li></ul>RESTful DM Alfresco ECM Server Your Webapp Alfresco ECM Server See the recorded webinar here: http:// snurl .com/ webscripts Firewall
  17. 17. Sample WCM Architecture <ul><li>Create your content on Alfresco WCM Server (Authoring)‏ </li></ul><ul><li>Content (XML files, etc.) deployed to runtime </li></ul><ul><li>Web Scripts on the Alfresco Runtime serves your webapp: </li></ul><ul><ul><li>Data Acess API </li></ul></ul><ul><ul><li>HTML, JSON, XML, RSS, ATOM, etc. Your choice </li></ul></ul><ul><ul><li>Supports cached results. </li></ul></ul><ul><ul><li>Use for searching, navigation, or dynamic page assembly. </li></ul></ul><ul><li>Add more runtimes: load balance </li></ul>RESTful WCM Alfresco WCM Server Your Webapp Alfresco Runtime Alfresco Runtime Alfresco Runtime See the recorded webinar here: http:// snurl .com/ webscripts Firewall
  18. 18. Links <ul><li>Alfresco Content Community Developer Toolbox: http://tinyurl.com/6yajvj </li></ul><ul><ul><li>http://wiki.alfresco.com/wiki/RESTful_API </li></ul></ul><ul><ul><li>http://wiki.alfresco.com/wiki/RESTful_API_Reference </li></ul></ul><ul><ul><li>http://wiki.alfresco.com/wiki/Surf_Platform </li></ul></ul><ul><ul><li>http://wiki.alfresco.com/wiki/3.0_REST_API </li></ul></ul>Useful Links See the recorded webinar here: http:// snurl .com/ webscripts
  19. 19. Q&A and Resources 03.04.08 <ul><li>Resources: </li></ul><ul><ul><li>Developer Toolbox: http://tinyurl.com/6yajvj </li></ul></ul><ul><ul><li>RESTful API: wiki .alfresco.com/ wiki / RESTful _API </li></ul></ul><ul><ul><li>RESTful API Ref: wiki .alfresco.com/ wiki / RESTful _API_Reference </li></ul></ul><ul><ul><li>Alfresco SURF: wiki .alfresco.com/ wiki /Surf_Platform </li></ul></ul><ul><ul><li>Alfresco 3.0 REST API: wiki .alfresco.com/wiki/3.0_REST_API </li></ul></ul><ul><ul><li>Join the Content Community: alfresco.com/community/register </li></ul></ul><ul><ul><li>Developer Challenge: alfresco.com/partners/ programme / webscripts / </li></ul></ul><ul><li>Join the Alfresco Facebook Group </li></ul><ul><ul><li>facebook .com/group. php ? gid =6063383762 </li></ul></ul><ul><li>Nominate Alfresco in the Packt CMS Awards </li></ul><ul><ul><li>http:// tinyurl .com/68og3p </li></ul></ul>See the recorded webinar here: http:// snurl .com/ webscripts
  20. 20. See the recorded webinar 03.04.08 See the recorded webinar here: http:// snurl .com/ webscripts
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×