Java Script Web Scripts overview

Module objectives

Web Scripts Overview

Overview

Web scripts provide a means to access the Alfresco content repository through HTTP commands allowing users to:

 

  • Manage, access and cross-link content
  • Integrate with 3rd party applications
  • Customize search
  • Develop UI services such as portlets
  • Customize Alfresco Share

Types of Web Scripts

Types of Web Scripts

Web Scripts fall into two categories:

 

  • Data Web Scripts
    • Provide a repository interface for client applications
  • Presentation Web Scripts
    • Allow users to create custom user interfaces

Framework

Web Script framework

Web scripts use a lightweight Model View Controller (MVC) style framework.

Developing

Developing

To create a Web Script you will need to:

 

  • Create the required files
    • Descriptor
    • Controller
    • Template
  • Name the files correctly
  • Deploy the files
  • Register the Web Script

 

 

Naming

Naming

Web Script components follow a standard convention:

  • <script id>.<http method>.<component type>.<file type>
    • HelloWorld.get.desc.xml
    • HelloWorld.get.js
    • HelloWorld.get.html.ftl

Installing

Installing

Place the Web Script components in the correct location:

 

 

  • Repository
    • Data Dictionary/Web Scripts Extensions
    • Data Dictionary/Web Scripts*
  • Classpath
    • /alfresco/extension/templates/webscripts
    • /alfresco/templates/webscripts

 

 

 

 

 

Managing and Registering

Managing/Registering

Web Scripts must be registered with Alfresco through the UI:

  • Repository
    • http://localhost:8080/alfresco/service/index
  • Share
    • http://localhost:8080/share/service/index

Running

Running

Web Scripts can be run multiple ways:

For our demonstration we will simulate you using a browser and various URLs.

First test the web script:

    - Demonstration URL: http://localhost:8080/alfresco/service/dir/Company%20Home

    - Outcome: The contents of the Company Home folder should be listed

Second check the verbose flag:

    - Demonstration URL: http://localhost:8080/alfresco/service/dir/Company%20Home?verbose=true.

 

    - Outcome: you should see is the content of the Company Home folder listed in verbose form.

Last check for "Error Handling":

   - Demonstration URL: http://localhost:8080/alfresco/service/dir/doesnotexist.

   - Outcome: you should see is an error page detailing a 404 status response indicating that your web script is working

Module Summary

What we learned:

  • The basic concepts of Alfresco web scripts

  • The components of a web script

  • The correct naming convention

  •  Where to store web scripts in Alfresco

  •  How to install, manage, register and run web scripts.