Understanding web scripts
In order to understand web scripts in Alfresco, let's begin with finding out the answer to the question "What is a web script?" from multiple perspectives.
In simple words, web scripts can be explained as follows:
- Web scripts are powerful and extremely useful services supported by Alfresco
- They are a way to interact with the Alfresco repository securely
- They are reusable across different platforms
- Web scripts provide uniform access of the content to a wide range of client applications
In technical terms, web scripts can be defined as follows:
- They are RESTful web services
Note
What is RESTful?
REST stands for REpresentational State Transfer, which is basically an architectural style. Well-defined and uniform access to the resources through HTTP request methods, uniquely identified resources through the URI, and representation of these resources are the key principles of REST. Any implementation following this architectural style is known as RESTful.
- They are bound to a specific Uniform Resource Identifier (URI)
- They respond to HTTP methods such as GET, POST, PUT, and DELETE
- They are a lightweight implementation
From a developer's point of view, web scripts have the following properties:
- They are easy to understand and learn
- They are easy to develop
- They are easy to debug
- They are easy to maintain
- They are easy to deploy
- They are faster to implement
- They would be the first choice when it comes to accessing the Alfresco repository securely from external applications
From a business user's point of view, web scripts are useful as follows:
- They bridge the gap between the business requirement and technical implementation for building up business solutions with Alfresco
- They empower Alfresco in its integration capabilities to develop useful Alfresco integration solutions with external systems
- They are a unique way to implement the integration solutions on top of the Alfresco repository
- They are the backbone of the integration solution implementation with the Alfresco repository
In essence, web scripts can be talked about as follows:
- Web scripts are built on the idea of URL addressability
- Web scripts are simply a service, mapped to a human-readable form, and developed using a piece of code as their backend implementation
- For example, in a contract management system built using Alfresco as the backend repository, you can have a web script to retrieve all the draft agreements from the repository and then display them on the custom frontend application. This repository web script to get all the draft agreements will simply be accessed through its URL. This web script will also have a piece of code in the backend to retrieve the data from the Alfresco repository to produce the results in the formats as required. The URL for this web script might look like the following:
/alfresco/service/contract/get_draft_agreements