2.1 Web Scripts Framework

Document created by resplin Employee on Jun 6, 2015
Version 1Show Document
  • View in full screen mode

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Web Scripts
Web Scripts Framework
Back to 2.1 RESTful API.



NOTE: This document describes features to be found in Alfresco v2.1. (Newer versions: v3)




Introduction


The framework for supporting Web Scripts provides some configuration points.  These are described below.


Authentication


Alfresco is a secure server requiring authenticated access.

The Web Script framework defers authentication to a plug-in Authenticator. By default, Basic HTTP Authentication is activated.  See Web Script Runtimes for information on how to change the authentication mechanism in each runtime.

Other forms of authentication will also be considered:


  1. ATOM authentication mechanism (such as http://www.xml.com/pub/a/2003/12/17/dive.html)
  2. WSSE
  3. OpenID

HTTP Basic Authentication


(id: webscripts.authenticator.basic)

This authenticator supports HTTP Basic Authentication.  The authorisation header must contain either:


  • username & password
  • ticket

For restricted environments that do not allow the setting of HTTP Request Headers, a ticket may be passed via the URL argument 'alf_ticket' or 'ticket'.


Alfresco Web Client Authentication


(id: webscripts.authenticator.webclient)

This authenticator relies on the authentication mechanism configured into the Alfresco Web Client.  If login is required, a redirect to the Alfresco Web Client login page is made.


JSR-168 Authentication


(id: webscripts.authenticator.jsr168)

This authenticator relies on the user name setup by the JSR-168 runtime.  It assumes the user has already been authenticated by the Portal.  The Alfresco Repository executes in the context of the Portal user.


JSR-168 Authentication with Alfresco Web Client support


(id: webscripts.authenticator.jsr168.webclient)

This authenticator ensures that the Alfresco Web Client user context is kept in sync with the Portal user.  This allows Web Scripts that depend on Alfresco Web Client functionality to be used within the Portal.


Logging


Web Scripts framework logging is controlled by the following log4j entry:

log4j.logger.org.alfresco.web.scripts=debug

HTTP Response Formats


All Web Script URLs support the format argument for specifying the response type.

Formats available 'out-of-the-box' are:


  • html  => text/html
  • text => text/plain
  • xml  => text/xml
  • atom  => application/atom+xml
  • rss  => application/rss+xml
  • json  => application/json
  • opensearchdescription  => application/opensearchdescription+xml
  • mediawiki  => text/plain  (Media Wiki markup)
  • portlet => text/html  (head & tail chopped)

e.g.

GET http://<host>:<port>/service/search/keyword?q=alfresco&format=atom
GET http://<host>:<port>/service/search/keyword.atom?q=alfresco</b>

Adding new Formats


New response formats may be supported by declaring a 'Format Map' Spring Bean as follows where format short names are mapped to mimetypes

<bean parent='webscripts.formatmap'>
  <property name='formats'>
    <props>
      <prop key='wav'>audio/x-wav</prop>
    </props>
  </property>
</bean>

Multiple beans may be declared.

A custom 'Format Map' may be provided for a given user agent

<bean parent='webscripts.formatmap'>
  <property name='agent'><value>MSIE</value></property>
  <property name='formats'>
    <props>
      <prop key='atom'>text/xml</prop>
    </props>
  </property>
</bean>

Valid agent values are (currently):


  • MSIE  (Micrsoft Internet Explorer)

Configuring Web Server Host


To execute Web Scripts behind a firewall or proxy, you must first provide your public Web Server address, so that any links generated by Web Scripts refer back to the public server.

This is achieved by editing (or providing a custom):

web-client-config.xml

and providing the host details in the following:

<config evaluator='string-compare' condition='Server'>
  <server>
     <scheme>http</scheme>
     <hostname>anexample</hostname>
     <port>8080</port>
  </server>
</config>

Attachments

    Outcomes