You are previewing Learning Alfresco Web Scripts.
O'Reilly logo
Learning Alfresco Web Scripts

Book Description

Learn a powerful way to successfully implement unique integration solutions with Alfresco

In Detail

Alfresco web scripts is a key feature of the Alfresco enterprise content management system that enables other applications to interact with the Alfresco repository in a secure way. This book will help you understand everything you need to know about web scripts so that you can practically apply them to your own projects.

You will begin by learning the basics of Alfresco web scripts, giving you a clear idea about how web scripts are a useful solution to your business problems. Moving on, you will delve into the powerful web script framework and then get a complete walk-through of all the components required to build web scripts. Later in this book, you will discover various ways to execute web scripts. You will learn about useful JavaScript APIs in Alfresco that you can leverage when building business solutions with web scripts. Moving further, you will learn about deployment, debugging, and troubleshooting web scripts, and find instructions to develop web scripts in a Maven project that will help you learn how to build web scripts in a real development environment.

What You Will Learn

  • Implement web scripts in Alfresco and learn about their fundamentals
  • Understand the end-to-end execution flow with core details and get an insight into the robust web script framework
  • Gain extensive knowledge about the building components of web scripts
  • Explore different options to invoke Alfresco web scripts
  • Leverage the power of useful JavaScript APIs in web script implementation
  • Understand various deployment options, debugging techniques, and troubleshooting pointers
  • Learn about extension capabilities to extend the web script framework
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Learning Alfresco Web Scripts
      1. Table of Contents
      2. Learning Alfresco Web Scripts
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Getting Familiar with Web Scripts
        1. Understanding web scripts
        2. Reasons to use web scripts
        3. Understanding when to use a web script
        4. Understanding where web scripts can be used
        5. Understanding how web scripts work
          1. MVC in web scripts
          2. Making web scripts work
        6. Types of web scripts
          1. Data web script
          2. Presentation web script
        7. Summary
      10. 2. It's Time for the First Web Script
        1. Creating your first web script in Alfresco
        2. Understanding the web script URI
        3. Adding arguments to a web script
        4. Extending the first web script to use the controller
        5. Behind the scenes of web script execution
          1. A web script without a controller
          2. A web script with a controller
        6. Important things for any web script
          1. HTTP methods supported by a web script
          2. Web script arguments
            1. Explicit arguments
            2. Implicit arguments
            3. Understanding which one to choose
          3. Response formats for a web script
            1. Response formats supported by the web script framework
            2. Specifying the response format
              1. Specifying the response format via URL – extension on web script ID
              2. Specifying the response format via URL – explicit format argument
              3. The default format
        7. Summary
      11. 3. Understanding the Web Script Framework
        1. Execution flow of web scripts
          1. Overall flow for a web script
          2. Behind the scenes implementation
        2. Components of the web script framework
          1. Web Script Runtime
            1. Servlet Runtime
            2. Portlet Runtime
            3. JSF Runtime
            4. Facebook Runtime
            5. SURF Runtime
          2. Web Script Authenticator
            1. HTTP basic authenticator
            2. Alfresco explorer authenticator
            3. JSR-168 Authenticator
            4. JSR-168 Authenticator with Alfresco Explorer support
            5. Facebook Authenticator
          3. Web Script Container
            1. Repository Container
            2. Presentation Container
          4. Other supporting components
            1. Configuration service
            2. Web Script registry
            3. Format registry
            4. Script processor registry
            5. Template processor registry
            6. Search path
          5. Understanding the wiring of web script framework components
        3. Deployment architecture
        4. Summary
      12. 4. Building Blocks of Web Scripts
        1. The description document – it's a must!
          1. Mandatory declarations
            1. The <webscript> tag
            2. The <shortname> tag
            3. The <url> tag
          2. Optional declarations
            1. <format>
              1. argument
              2. extension
              3. any
            2. <authentication>
              1. none
              2. guest
              3. user
              4. admin
            3. <transaction>
              1. none
              2. required
              3. requiresnew
            4. <family>
            5. <cache>
              1. never
              2. public
              3. mustrevalidate
            6. <negotiate>
            7. <lifecycle>
              1. none
              2. sample
              3. draft
              4. public_api
              5. draft_public_api
              6. deprecated
              7. internal
            8. <formdata>
            9. <args>
            10. <requests>
            11. <responses>
            12. kind
        2. Controller implementation – not mandatory!
          1. The JavaScript-backed controller
            1. Understanding when to use the JavaScript controller
          2. The Java-backed controller
            1. Understanding when to use a Java-backed controller
        3. Response templates – yes, they are required!
        4. I18N for a web script – it's optional
          1. Adding a resource bundle for the hello world web script
          2. Modifying the response template to use labels
        5. Configuration document – it's optional
          1. Accessing configuration in a controller
          2. Accessing configuration in a template
        6. Naming conventions – the most important thing
        7. Summary
      13. 5. Invoking Web Scripts
        1. Invoking a web script from a web browser
        2. Executing a web script using web browser plugins
          1. Poster – Firefox add-on
          2. Advanced REST client for Chrome
        3. Executing a web script from standalone Java program
          1. HttpClient
            1. Understanding how to invoke a web script using HttpClient
            2. URLConnection
            3. Apache HTTP components
            4. RestTemplate
        4. Calling web scripts from Spring-based services
        5. Invoking a web script from Alfresco Share
          1. Calling a web script from the presentation web script JavaScript controller
          2. Invoking a web script from client-side JavaScript
          3. Calling a web script from the command line
        6. Calling a web script from JSR-168 portals and the JSF page
          1. Calling a web script from JSR-168 portals
          2. Calling a web script from the JSF page
        7. Dealing with client limitations
        8. Summary
      14. 6. Creating Java-backed Web Scripts
        1. Use case scenario
        2. Web script functionality at a high level
        3. Getting ready
        4. Creating a description document
        5. Creating a response template
        6. Creating a Java controller
          1. Controller logic at a high level
          2. Let's code it!
        7. Configuring the controller for the web script
        8. Deploying the web script
          1. Registering the web script
        9. Testing the web script
          1. Test case 1 – mandatory check
          2. Test case 2 – invalid argument value
          3. Test case 3 – invalid access
          4. Test case 4 – test with valid data
        10. DeclarativeWebScript versus AbstractWebScript
        11. Using controllers smartly
        12. Summary
      15. 7. Understanding JavaScript-based Web Scripts in Detail
        1. Understanding what you can do with the JavaScript API
        2. JavaScript APIs in Alfresco
          1. Identifying JavaScript APIs
          2. Root objects to access JavaScript APIs
          3. Other available root objects
        3. A must-know ScriptNode API
        4. Code examples
          1. Creating a folder
            1. Retrieving explicit arguments
            2. Folder creation under company home
          2. Finding a node
          3. Checking user permissions on a node
          4. Getting the path of a node
          5. Checking the properties of a node
          6. Logging the property value
          7. Modifying property of a node
          8. Getting the current username and e-mail
          9. Returning the guest home node
        5. Creating your own root object
          1. Custom JavaScript extension
        6. Summary
      16. 8. Deployment, Debugging, and Troubleshooting Web Scripts
        1. Deployment options
          1. The repository option
          2. The filesystem option
          3. Understanding deployment locations
          4. Choosing the deployment option
        2. Debugging web scripts
          1. Enable logging
          2. Remote debugging on the server
          3. Other debugging techniques
        3. Troubleshooting pointers
          1. A valid SecureContext error
          2. Web Script format '' is not registered
          3. Cannot locate template processor for template
          4. Script URL does not support the method
        4. Web scripts on a production server
          1. Running web scripts in the background
          2. Logging web script logs separately
          3. Disabling Java-backed web scripts
        5. Summary
      17. 9. Mavenizing Web Scripts
        1. Setting up your environment
          1. Exploring the Alfresco Maven repository
        2. Creating the default project structure for AMP
        3. Generating AMP from the default project
        4. Setting up a development environment with Eclipse
        5. Understanding the default project structure
        6. Extending your default project to create web scripts
        7. Applying AMP to the Alfresco WAR for testing
        8. Summary
      18. 10. Extending the Web Script Framework
        1. Custom implementation of the web script runtime
        2. The custom implementation of a web script container
        3. Custom authenticator implementation
        4. Custom script processor implementation
        5. Custom template processor implementation
        6. Customizing formats
        7. Summary
      19. Index