Chapter 10. Integrating WCM Using Web Scripts

In this chapter, we will learn about web scripts and integration of WCM with external systems using web scripts. In previous chapters, you got an idea about why to use WCM, how to create web projects, and how to produce content in Alfresco WCM along with deployments to a different server. So far we discussed how we use Alfresco as a content production and delivery system and for serving the content. You may have your own application and may want to use Alfresco purely for web content management, which will just produce the content in Alfresco. But the presentation part of the application will not be handled by Alfresco. Here you can have your frontend application in any technology and you can use Alfresco WCM as the backend, which will serve the content to your application. Web script's RESTful service is one of the most easily available and widely used solutions to integrate the Alfresco WCM with any external system or application.

By the end of this chapter, you will have learned about:

  • REST architecture
  • Web script framework in Alfresco
  • Components of web scripts
  • WCM-specific JavaScript and template APIs
  • Implementing web scripts in Alfresco
  • Using web scripts to integrate Alfresco WCM with any external system or application

Concepts of WCM web scripts

In this section, you will get an overview of web scripts in WCM. We will talk about the REST architecture and web script framework in Alfresco. We will also talk about the new features introduced for web scripts in Alfresco 3. At the end of this section, you will have a very good idea about the architectural benefits of using RESTful web services, how it helps in providing solutions with the Alfresco WCM, and also how easy it is to integrate WCM with an external system.

Overview of REST architecture

In this section, we will discuss about the REST architecture and RESTful web services. You will also get an idea about how RESTful web services are different than our traditional SOAP-based web services and the advantages of using this approach over a traditional SOAP-based approach.

What is REST

REST (Representational State Transfer) is used to describe a Web Oriented Architecture rather than a Service-Oriented Architecture. It is an architectural style following the principles referred to as "RESTful". RESTful web services are resource-oriented services. You can identify and locate resources by a Uniform Resource Identifier (URI). By making everything URL (URI)-based, you can access everything via that URL and use standard web commands such as Get and Post to access and update those things, something we call resources.

REST's main principles

  • Resource-oriented states and functionalities that are abstracted into resources
  • Unique way of identifying resources
  • The idea of how operations on these resources are defined in terms of a single protocol for interacting with resources
  • A protocol that is client-server, stateless, cacheable, and layered
  • REST-oriented system design leads to systems that are open, scalable, extensible, and easy to understand

This URL-based update of information contrasts with a very Remote Procedure Call-like interface of SOAP. The following points give an idea about how RESTful web services differ from SOAP-based web services:

  • Design approach: REST focuses on resources, whereas web services focus on messages, which are operations.
  • Less dependencies as there is no SOAP required.
  • Cacheable representation leads to improved response time and reduced server load.
  • No need for a separate resource directory due to the use of hyperlinks in representations.
  • Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session.

Alfresco web scripts overview

Alfresco provides a web script framework based on REST architecture, which was described in the earlier section. RESTful web scripts provide a very suitable and flexible solution to integrate Alfresco with any other application, and is usually the best solution out of all of the available options. With the help of web scripts, you can easily access the Alfresco repository and perform operations such as content searching, retrieval, manipulation, and so on with the help of services available in Alfresco, even from outside Alfresco.

What is a web script

A REST web script is simply a service bound to a URI and based on HTTP. So the technology that the external application is implemented on is irrelevant, that is, they are cross platform and cross language. You are not locked into any programming language or development environment.

The web script framework lets you roll your own APIs, thereby allowing you to fine-tune the remote APIs that you expose to the external application. REST provides a convenient bridge between any native application and the content management. This allows you to place controls on your enterprise content to manage it and at the same time provide uniform access for a wide variety of client applications and services, such as browser, portal, search engine, or custom application.

Why to use web scripts

The advantages of using a web script for integrating external applications with Alfresco WCM are:

  • Build custom URI-identified and HTTP-accessible content management web services
  • Turn your Alfresco repository into a content management-powered HTTP server
  • Instead of having a single, monolithic system responsible for all aspects of a content-centric web application, this provides a design of loosely coupled sub-systems that are being integrated to create more agile solutions
  • This approach allows your content management system (Alfresco WCM) to have a flexible and lightweight interface
  • Provides the flexibility of not being locked into a presentation approach based on the content repository
  • Uses lightweight scripting technologies such as JavaScript and FreeMarker
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset