SlideShare a Scribd company logo
Webscripts2Roy WetherallSenior Software Engineer, Alfrescotwitter: @rwetherall
Agenda3Where to start?
Nuts and Bolts
Building a Webscript Data API
QuestionsWhere to start?4At the beginning ...
What is a Webscript?5In no more than 140 characters ...
What can Webscripts be used for?6Presentation
Data
Integration“Webscripts unlock content”
Fundamental Concepts7GEThttp://myserver/A/XWaitRequestResponseHTTPProcess200<x>My Content</x>AXY
Webscript Execution Flow8
Webscript Architecture9
Nuts and Bolts ...10... of a Webscript
Webscript Files11Description document
Controller
Response template
Configuration
Message bundles
Response status template“Place files on the classpath or in the repository”
Document Description12DocumentationURL templates (JSR-331)Response format detailsAuthenticationTransactionLifecycle and family“Webscripts are declarative”
Controller13OptionalAccess to modelCan read/write to repositoryRemoves complexity from response templateImplemented in JavaScript or JavaRoot objects set based on container“Controllers handle the request, gather information and populate the model.”
Response Template14Build web script responseImplemented in FreemarkerMany response templates per WebscriptAccess to modelRoot objects set based on container“Response templates format the response to a Webscript request.”
Simple Webscript Example 15
Building a Webscript Data API16
Alfresco Service API Architecture17Webscript APIJavascript APIJava Service API
Java Service API18StatelessConciseProvides all functionalityExtendableAdaptable“The Java service layer is where all the ‘real’ code should go”
Java Script API19Object basedAvailable in the repositoryDeveloper friendlyImplemented in Java“The Java Script API helps rapid adoption and development of Alfresco applications”
Webscript Data API20REST(ful)Resource basedRepresentations delivering dataHTTP methods mapped to APISimple integrationPublic and remote“Webscript Data APIs unlock content.”
Design Example – Candy Store21“I want to create a Share customisation that allows me to manage the stock in my Candy Store.  I should be able to see what stock is available, add/edit/remove the details of the stocked candy and review the stock levels.”
Design Example – Candy Store22Content Model and Java API
Design Considerations23Resources are referencableThey have stateThe “things” in your APICollectionsComposite resources“Identifying resources in your API is key.”Resources
Design Example – Candy Store24CandyA candy bar that is currently stocked in the candy store.CandiesA collection of all the candies currently stocked in the candy store.Candy StoreThe candy store it’s self.Candy ManagerManages the stock levels in the candy store.Usually use /api/actionQueue and custom actions instead.Resources
Design Considerations25HTTP methods should map logically to the APIURLs should be composed of resourcesParameters should be parametersConsistency is importantNo hard and fast rules“Simple always works best.”Methods & URLs

More Related Content

ODP
Introduction of Html/css/js
PPTX
Alfresco tuning part1
PDF
Alfresco Content Modelling and Policy Behaviours
 
PPTX
Alfresco tuning part1
PPTX
CSS Transitions, Transforms, Animations
PDF
Exceptions are the Norm: Dealing with Bad Actors in ETL
PPTX
Bootstrap
PDF
Alfresco Transform Core 3.0.0
Introduction of Html/css/js
Alfresco tuning part1
Alfresco Content Modelling and Policy Behaviours
 
Alfresco tuning part1
CSS Transitions, Transforms, Animations
Exceptions are the Norm: Dealing with Bad Actors in ETL
Bootstrap
Alfresco Transform Core 3.0.0

What's hot (20)

PDF
Alfresco 5.2 REST API
 
PDF
Introduction to CSS3
PPTX
Alfresco tuning part2
PPTX
Php gd library
PDF
Exciting New Alfresco REST APIs
 
PPTX
Upgrading to Alfresco 6
PPTX
PDF
Deep dive into stateful stream processing in structured streaming by Tathaga...
PPTX
Fetch API Talk
PDF
Hive tuning
PPTX
Intro to WebSockets
PDF
Laravel Introduction
PDF
Sass - Getting Started with Sass!
PDF
Bootstrap 5 basic
PPTX
Why your Spark Job is Failing
PPTX
Intro to React
PPTX
Integrating Alfresco with MS Dynamics
PPTX
Alfresco CMIS
PPTX
Spring Security 5
PDF
JavaScript Programming
Alfresco 5.2 REST API
 
Introduction to CSS3
Alfresco tuning part2
Php gd library
Exciting New Alfresco REST APIs
 
Upgrading to Alfresco 6
Deep dive into stateful stream processing in structured streaming by Tathaga...
Fetch API Talk
Hive tuning
Intro to WebSockets
Laravel Introduction
Sass - Getting Started with Sass!
Bootstrap 5 basic
Why your Spark Job is Failing
Intro to React
Integrating Alfresco with MS Dynamics
Alfresco CMIS
Spring Security 5
JavaScript Programming
Ad

Similar to Webscripts (20)

PPTX
Public API
PPTX
Will the Real Public API Please Stand Up? Amir Zuker
PDF
Why your APIs should fly first class
PPTX
POST/CON 2019 Workshop: Design, Develop, and Mock APIs with Postman
PDF
Api design best practice
PDF
ITT Flisol 2013
PPTX
Oscon2014 Netflix API - Top 10 Lessons Learned
PDF
Consumer centric api design v0.4.0
PDF
Design & Deploy a data-driven Web API in 2 hours
PDF
Session 8 Android Web Services - Part 1.pdf
PPTX
Api Design
PDF
Build, Test, Deploy: The Ultimate Handbook for Modern API Development
PDF
PLAT-8 Spring Web Scripts and Spring Surf
PDF
Building A Great API - Evan Cooke, Cloudstock, December 2010
PDF
Be My API How to Implement an API Strategy Everyone will Love
PPTX
Top 10 Lessons Learned from the Netflix API - OSCON 2014
PDF
Reaching Out To Developers
PDF
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
PDF
Opendelight reference-guide
PDF
Creating a RESTful api without losing too much sleep
Public API
Will the Real Public API Please Stand Up? Amir Zuker
Why your APIs should fly first class
POST/CON 2019 Workshop: Design, Develop, and Mock APIs with Postman
Api design best practice
ITT Flisol 2013
Oscon2014 Netflix API - Top 10 Lessons Learned
Consumer centric api design v0.4.0
Design & Deploy a data-driven Web API in 2 hours
Session 8 Android Web Services - Part 1.pdf
Api Design
Build, Test, Deploy: The Ultimate Handbook for Modern API Development
PLAT-8 Spring Web Scripts and Spring Surf
Building A Great API - Evan Cooke, Cloudstock, December 2010
Be My API How to Implement an API Strategy Everyone will Love
Top 10 Lessons Learned from the Netflix API - OSCON 2014
Reaching Out To Developers
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
Opendelight reference-guide
Creating a RESTful api without losing too much sleep
Ad

More from Alfresco Software (20)

PPTX
Alfresco Day Benelux Inholland studentendossier
PPTX
Alfresco Day Benelux Hogeschool Inholland Records Management application
PPTX
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
PPTX
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
PPTX
Alfresco Day BeNelux: The success of Alfresco
PDF
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
PDF
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
PDF
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
PDF
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
PDF
Alfresco Day Vienna 2016: Alfrescos neue Rest API
PDF
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
PDF
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
PDF
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
PDF
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
PDF
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
PDF
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
PDF
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
PDF
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
PDF
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
PDF
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Day Benelux Inholland studentendossier
Alfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Day BeNelux: The success of Alfresco
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Assigned Numbers - 2025 - Bluetooth® Document
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25-Week II
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
A comparative analysis of optical character recognition models for extracting...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MIND Revenue Release Quarter 2 2025 Press Release
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Webscripts

Editor's Notes

  • #5: Where do we start? At the begining.Why do we have WebScripts?What are WebScripts used for?What is a WebScript?How do I use a WebScript?Where can I use a WebScript?
  • #8: URL – unique resource locator.HTTP Methods – action to be performed on the resource (GET, PUT, POST and DELETE)HTTP Response Status – tells the client what’s happened (success, fail, event, action)Response types – the type of content being returned from the server (XML, HTML, JSON, ATOM)REST – Representational State TransferTODO – summarise the following into readable notes ...TODO – Diagram showing flow ... URL (method) -&gt; Resource -&gt; response (status) .. Transfer of representation .. Rest state .. REST-style architectures consist of clients and servers. Clients initiate requests to servers; servers process requests and return appropriate responses. Requests and responses are built around the transfer of &quot;representations&quot; of &quot;resources&quot;. A resource can be essentially any coherent and meaningful concept that may be addressed. A representation of a resource is typically a document that captures the current or intended state of a resource.At any particular time, a client can either be in transition between application states or &quot;at rest&quot;. A client in a rest state is able to interact with its user, but creates no load and consumes no per-client storage on the set of servers or on the network.The client begins sending requests when it is ready to make the transition to a new state. While one or more requests are outstanding, the client is considered to be in transition. The representation of each application state contains links that may be used next time the client chooses to initiate a new state transition.[4]REST was initially described in the context of HTTP, but is not limited to that protocol. RESTful architectures can be based on other Application Layer protocols if they already provide a rich and uniform vocabulary for applications based on the transfer of meaningful representational state. RESTful applications maximize the use of the pre-existing, well-defined interface and other built-in capabilities provided by the chosen network protocol, and minimize the addition of new application-specific features on top of it.
  • #9: Web Script Runtime:A typical deployment includes an Alfresco Repository server hosting data Web Scripts with one or more Alfresco clients hosting presentation Web Scripts where communication between the two is over HTTP. The Alfresco Repository utilises the Servlet Run-time whereas a remote Web Client utilises the SURF Run-time for hosting Web Scripts. However, this is just one of many options given the following available Web Script Runtimes:Servlet Runtime (HTTP accessible)SURF Runtime (embed Web Script UI components in web-tier UI pages)JSR-168 Runtime (adapter between JSR-168 portlet API and Web Script)JSF Runtime (JSF tag to include Web Script)Facebook Runtime (access to Facebook API and Repository API within Web Script)We&apos;ve already seen there are several types of Runtime available out-of-the-box. These Runtimes can be setup in conjunction with one the following out-of-the-box Containers:Presentation - a light-weight container for rendering User Interface components that can make service calls to remote data sources.Repository - a container for embedded use in the Alfresco Repository providing integration with transactions and direct access to content held in the Repository and services provided by the Repository.Flow:1. A request for a given URI arrives at the Web Script Runtime.2. The Runtime finds the appropriate Web Script for the URI. If one is found, the Runtime executes the Web Script but only after successfully authenticating first, if required. The first step of execution is to invoke the JavaScript bound into the Web Script.3. With JavaScript, you have access to a set of Alfresco services. When hosted within the Repository server you can search for information, navigate around the repository, modify information, create new documents, set properties on those documents, move data around, and delete data, plus access to all other Repository services. Outside of the Repository you can invoke remote services such as those by the Repository server.4. The results from the JavaScript are rendered using FreeMarker response templates. The response format may be one of HTML, ATOM, XML, RSS, JSON, CSV, or any combination of these. You must provide the appropriate templates.5. The Web Script Runtime sends the rendered results back via a response using the same protocol as the URI request.6. The Web Script client receives the response in the requested format.
  • #12: Optional files – Controller, Configuration, Message Bundles, Response Status TemplateIn Alfresco repository or on JAVA classpath.4 predefined locations.Subfolders can be used to organise.Use refresh link on the /alfresco/service/ page to load new Web Scripts.