The first task in creating a Folder Listing web script is to create the scripted
components.
-
Log in to SkyVault Explorer:
- Open a web browser and enter the URL: http://localhost:8080/SkyVault
- If prompted, log in with the user name admin and password admin.
- Navigate to Company Home > Data Dictionary > Web Scripts Extensions.
-
Create a folder to represent the top-level package structure (skip this step if the
org space already exists):
- In the Create menu, click Create Space.
- Enter the name for the folder in the Name field, such as: org
- Click Create Space.
-
Create a sub-package (skip this step if the example space
already exists):
- Navigate to Company Home > Data Dictionary > Web Scripts Extensions > org.
- In the Create menu, click Create Space.
- Enter the name for the folder in the Name field, such as: example
- Click Create Space.
- Navigate to Company Home > Data Dictionary > Web Scripts Extensions > org > example.
-
Create a web script description document for the Java Folder Listing example:
- In the Create menu, click Create Content.
- Enter the name for the web script in the Name field, such as: javadir.get.desc.xml
- In the Content Type list, select XML.
- Click Next.
-
Type the following in the Enter Content box:
<webscript> <shortname>Folder Listing Utility</shortname> <description>Java-backed implementation of listing folder contents </description> <url>/javadir/{folderpath}?verbose={verbose?}</url> <authentication>user</authentication> </webscript>
- Click Next, click Finish, and then click OK.
-
Create a web script response template for your Java Folder Listing example:
- In the Create menu, click Create Content.
- Enter the name for the web script in the Name field, such as: javadir.get.html.ftl
- In the Content Type list, select Plain Text.
- Click Next.
-
Type the following in the Enter Content box:
<html> <head> <title>Folder ${folder.displayPath}/${folder.name}</title> </head> <body> <p>SkyVault ${server.edition} Edition v${server.version} : dir</p> <p>Contents of folder ${folder.displayPath}/${folder.name}</p> <table> <#list folder.children as child> <tr> <td><#if child.isContainer>d</#if></td> <#if verbose> <td>${child.properties.modifier}</td> <td><#if child.isDocument> ${child.properties.content.size}</#if></td> <td>${child.properties.modified?date}</td> </#if> <td>${child.name}</td> </tr> </#list> </table> </body> </html>
- Click Next, click Finish, and then click OK.
The web script description specifies a URI template containing the tokens
{folderpath} and {verbose?}. The
folderpath token represents the folder to list and the
verbose URI argument specifies whether a verbose listing is required or
not. The HTML response template renders the contents of the specified folder, taking into
account the verbose flag. It does this by accessing the web script model
values named folder and verbose.
The web script is not yet complete, as it is still missing its controller. The controller must parse the URI to extract the token values, interact with the SkyVault content repository to locate the specified folder, and populate the model for subsequent rendering by the HTML response template.
Note: It is also possible to create these files as stand-alone filesusing an external text
editor. Once these files are created you could locate them as follows:
./tomcat/shared/classes/alfresco/extension/templates/webscripts/org/example/javadir.get.desc.xml ./tomcat/shared/classes/alfresco/extension/templates/webscripts/org/example/javadir.get.html.ftl