Alfresco uses RESTful web services, bound to specific Uniform Resource Identifiers (URI) and it facilitates response to HTML methods. These web services are easy to develop, debug, maintain and deploy, and provide secure access to the Alfresco repository through external applications. The use of web scripts help in connecting a particular set of business requirements to apt technical implementation. It also forms the basis of robust ECM integration.
The web scripts allow generic implementation of ECM systems with basic functionalities through Content Management Interoperability Services or CMIS. It offers multiple advantages over SOAP web services. A key benefit is the availability of all features for accessing and interacting with Alfresco repository. Also unlike SOAP web services, it is lightweight, scalable and supports multiple formats.
The web scripts are commonly used in -
- HTTP client such as web browser and client HTTP APIs
- Easy to access in JSF pages
- JSR-168 Portals
- Alfresco SURF platforms
It follows the Model-View-Controller (MVC) architecture, where
- Model is an object passed between Controller and View
- View is the Freemarker template which renders response
- Controller server side Java Script or Java class or both
There are 2 types of Alfresco web scripts as given below:
1. Data Web Scripts
- Provide an interface to the repository for the client applications to create, retrieve, update, and delete content/data in the repository
- Send the response in formats such as XML and JSON and client applications will have to parse it
- It uses Alfresco repository server as the host
2. Presentation Web Scripts
- Use to build User interfaces such as dashlets, portlets for a JSR-168 portal, a UI component within Alfresco SURF, or a custom application
- Generally render HTML responses
- It uses a separate presentation server or Alfresco repository server as the host
A Sample Alfresco Web Script
The basic ’Hello World’ script is programmed as
<webscript>
<shortname>Hello World</shortname>
<description>First webscript Hello world</description>
<url>/helloworld?name={argumentName}</url>
<authentication>user</authentication>
</webscript>
model.email=“info@cignex.com";
<html>
<body>
<p>Hello! ${args.name}.</p>
<p>email address: ${email}</p>
</body>
</html>
The key building blocks of web scripts are
- Description document
- Response Templates
- Java backed controller implementation (optional)
- 118N Resource bundle (optional)
- Configuration document (optional)
Invoke Methods
The scripts can be invoked as
- Web browser
- REST client Web browser plugins
- Standalone Java program
- Services deployed using Spring
- Alfresco Share Components
- Command Line
- JSF pages
Scripting Best Practices
Some of the good programming practices below help you extract the maximum from your Alfresco ECM integration
- Identify and use appropriate HTTP method for web script
- Must follow proper naming standards
- Keep description document up-to-date
- Check if any OOTB web script you can leverage
- Check if the JavaScript APIs meet your business need
- Identify the different types of responses your web script should send back
- Maintain web scripts as part of your coding
Web Script Integration
On the frontend, the web script can be used to integrate with Portal Management Systems (Liferay), WCMs (Drupal), e-commerce solutions (Magento) or Learning Management Systems (Moodle). On the backend, it can be used to drive Document Management, Workflow Activiti/BPM, Collaboration, Versioning, and Role Based Access.
Knowledge Resource for Alfresco Web Scripts
The vast domain of Alfresco Web Scripts remains mostly untapped. The book “Learning Alfresco Web scripts” by Ramesh Chauhan (Packt Publishing) is a comprehensive knowledge resource that helps developers to extend the core components of web script framework in Alfresco and helps in solving frequent issues of deployment, debugging and troubleshooting encountered by enterprise IT teams.
Case Study of Alfresco Web Scripts for ECM Integrations
1. Managing RoI with Real Time Visibility
Need – A 90-year old entertainment conglomerate needed to manage promotions with worldwide network of distributors and channel partners
Solution – We built a Movie Promotion Approval System upon the Grails Web Application Framework and used Web scripts to integrate with Alfresco Content Management System. This system drove external integration with Apache Solr, Image Magick, Currency Converter and Jasper Reports.
Features –
- Easy to use & Secured - Support for various content types to provide role & profile-based access
- Collaborative - Workflow for review and approval
- Dashboard/Reports – on marketing, budget and spending
Advantages – The system provided real time visibility on status of various spends on promotions and its RoI
2. Enhancing Business Traction
Need – An event and marketing services company needed a robust and scalable Content Management & Publishing Platform to manage 100+ events and publication site
Solution – Drupal based WCM made use of advanced themes and analytics to integrate CMIS and other APIs with Alfresco ECM. The web scripts allowed Alfresco Share to manage content on the ECM. Together the system could interact with external systems such as Calais (content tagging) and Business Process Management Engine.
Features –
- Scalability – Integrated DM & WCM
- Speed – Content approval & publishing
- Superior User Experience – Single window to manage all sites
- Security – Metadata level security
Benefits –
- Faster and well-managed content creation, approval and publishing
- Increased business visibility & operational efficiency
- Scalable and cloud ready solution with content control in the hands of marketing team