The official documentation is at: http://docs.alfresco.com
Back to Web Scripts.
Table of Contents
- 1 FAQ
- 1.1 Q: Are web scripts easy to use?
- 1.2 Q: Are there web scripts in Alfresco?
- 1.3 Q: Can I access Alfresco from other applications?
- 1.4 Q: Can I use web scripts on any platform?
- 1.5 Q: How do I make my scripts JSR-168 compliant?
- 1.6 Q: Are web scripts scalable?
- 1.7 Q: Are web scripts easy to install?
- 1.8 Q: How can I test my scripts?
- 1.9 Q: Do you provide any script examples?
- 1.10 Q: How do I run a script?
- 1.11 Q: I have a web script which takes a file path on the url. The framework gets confused with my filename and says 'Web Script Format is not registered'
- 1.12 Q: How do I return data from a PUT or POST webscript with a return status other than 200, O.K.
Q: Are web scripts easy to use?
The Web Script framework for constructing REST-style interfaces will simplify mashups. For example, content that is authored and managed within Alf can be mashed up with applications such as Google map. So map data can be working in conjunction with Alfresco-managed content.
Q: Are there web scripts in Alfresco?
A: Web scripts is the enabling technology for many of the new capabilities in Alfresco 2.1.
If you look in the latest version of Alfresco, you will see new dashlets such as:
All these dashlets were built using the core web scripts capability. The dashlets use Ajax UI capabilities, such as dynamic preview.
In addition, Alfresco's v2.1 OpenSearch has been rehosted as a series of web scripts.
Q: Can I access Alfresco from other applications?
A: By using web scripts, you can access Alfresco from within Alfresco, from within your own applications, and from within third-party applications.
Currently, Alfresco can be accessed from:
- Microsoft Office
- Web sites
- Other Web 2.0 applications
Q: Can I use web scripts on any platform?
A: Web scripts are called using simple URLs. This means that they are cross-platform, and cross-language. You are not locked in to any programming language or development environment.
Q: How do I make my scripts JSR-168 compliant?
A: You do not need to do anything special. Any web scripts that you create are automatically available as JSR-168-compliant portlets. Simply use them within a JSR-168-compliant portlet environment.
Q: Are web scripts scalable?
A: Web scripts provide massive scalability using web-oriented architecture.
Q: Are web scripts easy to install?
A: Simply upload your scripts to an Alfresco space (or create them inline), then use 1-click registration. As a bonus, you do not need to restart the Alfresco server.
Q: How can I test my scripts?
Q: Do you provide any script examples?
A: Alfresco provides examples at:
Company Home > Data Dictionary > Web Scripts > Examples
Company Home > Data Dictionary > Web Scripts > org > alfresco > sample
Q: How do I run a script?
A: If it is a GET Url, enter the script's URL in your web browser address bar in one of the following ways:
- Type the URL manually
- Click on a link to the URL
If it is a POST, PUT or DELETE URL then you will need to call it from a framework that can submit these HTTP messages.
Q: I have a web script which takes a file path on the url. The framework gets confused with my filename and says 'Web Script Format is not registered'
A: The web script framework performs content negotiation to determine which format to return data.
By default the content negotiation is 'any' which means that the required content-type may be declared via the URI extension. This is what is causing problems.
In the script's description specify
Q: How do I return data from a PUT or POST webscript with a return status other than 200, O.K.
You are probably using script code along the lines of
status.setCode(status.STATUS_CREATED, 'New Thing created');
This setCode method has an implicit redirect to the return status formatting template which, by default, does not have a 201 format so uses the existing error return template.
Use the following code in your script instead
status.code = status.STATUS_CREATED