Book Image

Learning Alfresco Web Scripts

By : Ramesh Chauhan
Book Image

Learning Alfresco Web Scripts

By: Ramesh Chauhan

Overview of this book

Table of Contents (18 chapters)
Learning Alfresco Web Scripts
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a response template


As a rule of thumb for a web script, we have to follow the naming convention as expected by the web script framework in Alfresco. As the web script is supposed to return the response in the JSON and XML formats, we need to create two response templates for the web script. Following the naming conventions, there are two files to be created—contentlocation.get.json.ftl and contentlocation.get.xml.ftl as response templates. Return filesystem_location and size in the response as follows:

  1. To create a JSON response template, create a file named contentlocation.get.json.ftl that has the following content:

    {
      "content" :
      {
        "filesystem_location" : "${contentFSLocation}",
        "size" : ${contentSize}
      }
    }
  2. To create an XML response template, create a file named contentlocation.get.xml.ftl that has the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <content>
      <filesystem_location>${contentFSLocation}
      </filesystem_location>
      <size...