You are previewing Alfresco 3 Web Services.
O'Reilly logo
Alfresco 3 Web Services

Book Description

Build Alfresco applications using Web Services, WebScripts and CMIS

  • Gain a comprehensive overview of the specifications of Web services

  • Implement the Alfresco specific Web Services

  • Get to grips with the Alfresco WebScripts and the Alfresco extensible RESTful API

  • Manipulate contents in Alfresco using different operations and APIs

  • Learn about the CMIS specification and its Alfresco implementation

  • Hands-on approach with examples built over the course of the book

  • In Detail

    Alfresco 3 is the leading open source enterprise content management system that offers powerful features for interacting with the content in its repository from outside the system. These include the support for the Content Management Interoperability Services (CMIS) implementation, reusable web scripts, and a Web Services API.

    This is the first book to show you how to use Web Services in Alfresco. Packed with examples, you'll learn how to build applications using Alfresco remote APIs based on SOAP and REST. You'll see how to use different APIs and bindings such as WebServices, WebScripts, and CMIS.

    Alfresco 3 Web Services starts off by showing you the services exposed by the Alfresco Web Services API, and how the API fits into the Alfresco software architecture.You learn to develop your application firstly by setting up and testing your Java development environment using the Alfresco SDK in Eclipse IDE and secondly by associating the Alfresco source code and Javadocs in Eclipse.

    With the help of real world practical examples, you learn how to do things like create, sort, and call Web Scripts, and invoke remote calls to Alfresco repository. To get the most from the Web Services API, you need to know about the basics of the Content Manipulation Language (CML), and the book takes you through this.

    Examples such as the bookshop application show you how to sign in, change user sessions, get, remove and change public and private associated contents, manage a cart for your e-commerce application, and so on.Next, by implementing a Microsoft .NET application using the Alfresco Web Services API, you see how to perform operations against the repository from your .NET application.The book provides you with REST and SOAP concepts, their comparison, basics of the FreeMarker language, Atom Publishing Protocol, JavaScript controllers, and the Apache Chemistry project.

    By the end of this book, you will be able to put together your knowledge about CMIS and the Apache Chemistry toolkit to develop a complete working application that uses Alfresco, via CMIS, as a back-end storage. Last but not the least, this book also covers the WebServices security profiles— the best practices for Web Services to promote better interoperability.

    A step-by-step guide to implementing the SOAP API, Web Scripts, and CMIS.

    Table of Contents

    1. Alfresco 3 Web Services
      1. Alfresco 3 Web Services
      2. Credits
      3. About the Authors
      4. About the Reviewers
      5. 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. Errata
          2. Piracy
          3. Questions
      6. 1. Introducing the SOAP Web Services API
        1. Web Services
          1. Web Services in Alfresco
          2. Introducing SOAP
            1. SOAP vs. REST
            2. The format of SOAP messages
            3. The Web Services Description Language
        2. Using Alfresco Web Services
          1. Using the Alfresco Web Services client SDK
          2. Setting up the Alfresco SDK
          3. Testing the Web Services client
        3. Summary
      7. 2. Creating and Modifying Content
        1. The Content Manipulation Language (CML)
          1. Setting up the Java classpath
            1. Using the precompiled client
            2. Using third-party frameworks
        2. Authentication
          1. Setting the endpoint address with a properties file
          2. Setting the endpoint address programmatically
        3. Performing operations on nodes
          1. Creating nodes
          2. Creating content
            1. Creating content using the content service
          3. Removing nodes
          4. Moving nodes
          5. Copying nodes
        4. Associations
          1. Adding child nodes
          2. Removing child nodes
        5. Versioning
          1. Updating nodes without versioning
          2. Getting the version history
        6. Aspects
          1. Adding aspects
          2. Removing aspects
        7. Searching the repository
          1. Performing Lucene queries
          2. Querying associated nodes
            1. Association
          3. Querying child nodes
          4. Querying parent nodes
        8. Summary
      8. 3. Collaboration and Administration
        1. Creating collaborative content
          1. Performing a check-out
          2. Check-in
            1. Check-in with versioning
            2. Check-in—importing external content
          3. Cancelling a check-out
        2. Managing versioning explicitly
          1. Creating a new version
          2. Deleting all the versions
          3. Getting the version history
          4. Reverting a version
        3. Managing locking explicitly
          1. Locking
          2. Unlocking
          3. Getting the lock status
        4. Classification and categories
          1. Getting classifications
          2. Describing a classification
          3. Getting categories
          4. Adding categories
          5. Getting child categories
        5. Authorization
          1. Setting owners
          2. Adding permissions
          3. Creating authorities
          4. Managing actions
            1. Getting action definitions
          5. Default actions
            1. Getting an action definition
            2. Executing actions
            3. Saving actions
            4. Getting actions
            5. Removing actions
        6. Managing rules
          1. Default Conditions
          2. Adding rules
        7. Managing users
          1. Adding users
          2. Deleting users
          3. Updating users
          4. Changing passwords
          5. Getting user information
          6. Searching users
        8. Summary
      9. 4. A Complete Example
        1. Setting up the project
        2. The Bookshop model
          1. Sign in page
          2. Home page
          3. Configure the bookshop repository
          4. Book details page
          5. Getting book properties
          6. Checking the cart space
          7. Getting all the associated reviews
        3. Adding a book to the cart
          1. Checking if the cart space exists
          2. Creating the cart space
          3. Adding a book in the cart
        4. Cart page
          1. Removing a book from the cart
          2. Adding a review
        5. Managing reviews page
          1. Accepting reviews
          2. Rejecting reviews
        6. Changing user details
        7. Summary
      10. 5. Using the Alfresco Web Services from .NET
        1. Setting up the project
          1. Testing the .NET sample client
        2. Searching the repository
        3. Performing operations
          1. Authentication
          2. CRUD operations
            1. Creating nodes
            2. Creating content
              1. Creating content using CML
              2. Creating content using ContentService
            3. Updating nodes
              1. Updating nodes without versioning
              2. Updating nodes with versioning
            4. Copying nodes
            5. Moving nodes
            6. Removing nodes
        4. Managing child associations
          1. Adding child nodes
          2. Removing child nodes
        5. Summary
      11. 6. Introducing the Web Scripts Framework
        1. A lightweight alternative to SOAP Web Services
        2. REST concepts
          1. Constraints
          2. Resources
          3. Representations
          4. REST in practice
            1. Use URLs to identify resources
            2. Use HTTP methods properly
              1. GET
              2. PUT
              3. DELETE
              4. POST
          5. Avoiding tight coupling
          6. Use hyperlinks to drive the application state
        3. Your first Web Script
          1. Components of a Web Script
          2. Creating your first Web Script
          3. Invoking your first Web Script
          4. Adding a controller
        4. The Model-View-Controller pattern
        5. URL matching
        6. Authentication
          1. Run as
          2. The Login service
        7. Transactions
        8. Requesting a specific format
          1. Status
        9. Configuring Web Scripts
        10. Cache control
        11. Deployment
        12. Summary
      12. 7. Templating with FreeMarker
        1. FreeMarker concepts
        2. Variable interpolation
          1. FreeMarker expressions
            1. Scalars
              1. Strings
              2. Booleans
              3. Numbers
              4. Dates
            2. Containers
              1. Hashes
              2. Sequences
              3. Collections
            3. Operators
              1. String operators
                1. Concatenation and interpolation
                2. Getting a single character
              2. Sequence operators
                1. Concatenation
                2. Slicing
              3. Hash operators
              4. Arithmetical operators
              5. Comparison operators
              6. Logical operators
            4. Missing values
              1. Specifying default values
              2. Testing for missing values
            5. Built-ins
              1. Built-ins for strings
                1. html, xhtml, xml
                2. js_string
                3. url
                4. trim
              2. Built-ins for dates
                1. string
                2. date, time, datetime
        3. Directives
          1. Assign
          2. If
          3. List
          4. Include
          5. Macro
            1. Nested content
            2. Macros with parameters
        4. Comments
        5. Using FreeMarker in Web Scripts
          1. The TemplateNode API
            1. Searching
              1. childrenByXPath
              2. childByNamePath
              3. childrenByLuceneSearch
              4. childrenBySavedSearch
        6. A simple example
        7. Generating an Atom Categories Document
          1. Atom
          2. The Alfresco Bookshop
          3. Categories in Atom
          4. Categories in Alfresco
          5. Creating the Web Script
            1. The descriptor
            2. The controller
            3. The template
            4. Using the Web Script
          6. Categories as JSON
        8. Summary
      13. 8. Writing a Web Script Controller in JavaScript and Java
        1. Providing a Web Script with a JavaScript controller
        2. Root objects
        3. General scripting techniques
          1. Importing scripts
          2. Logging
          3. Debugging
        4. Searching the repository
          1. Performing a simple Lucene search
            1. A primer on Lucene query syntax
              1. Fields in the Alfresco index
            2. Sorting results
        5. The ScriptNode API
          1. Properties of nodes
            1. Writing properties
          2. Navigating the repository
          3. Performing operations on nodes
            1. Creating new nodes
            2. Deleting nodes
            3. Copying and moving nodes
          4. Manipulating content
        6. A step-by-step example—posting reviews
          1. Requirements
          2. The protocol
          3. Representations
          4. Implementing the first version
            1. Extending the content model
            2. Configuring the Alfresco Explorer
            3. Creating the Web Script descriptor
            4. Creating the controller
              1. Finding the book
              2. Creating the review
              3. Setting the review's properties
              4. Returning the response
            5. Creating the template
            6. Testing the Web Script
          5. Using Atom
            1. Anatomy of an Atom entry
            2. A controller that accepts Atom entries
          6. Checking for duplicate reviews
            1. Finding duplicates
            2. The revised controller
        7. Writing Web Scripts in Java
          1. Types of Java-backed Web Scripts
            1. Declarative Web Scripts
              1. Wiring the class to the Web Script
          2. Posting reviews: The Java version
        8. Summary
      14. 9. Putting it All Together
        1. The Atom Publishing Protocol
          1. A bit of history
            1. Enter AtomPub
          2. AtomPub concepts
            1. Resources and entries
              1. Extensions
            2. Collections and feeds
              1. Paging
          3. The Service Document
          4. Creating resources
            1. Entry and media resources
          5. Updating resources
          6. Deleting resources
        2. Listing books by category
          1. Service URI
          2. Response format
          3. Implementing the service
            1. The descriptor
            2. The controller
            3. The template
          4. Testing the service
            1. Using curl
            2. A simple Java client
              1. Installing Abdera
        3. Creating a new book
          1. Service URI
          2. Request format
          3. Implementing the service
            1. The descriptor
            2. The controller
            3. The template
          4. Uploading content
            1. The descriptor
            2. The controller
            3. The template
          5. Testing the service
            1. Using curl
            2. A simple Java client
              1. Initial set-up
              2. Generating a random ISBN
              3. Setting up the entry
              4. Submitting the entry
              5. Uploading the content
        4. Updating an existing book
          1. The implementation
          2. Testing with curl
          3. Dealing with concurrent edits
            1. Implementation
          4. The Java client
        5. Deleting a book
          1. Testing deletion
        6. Summary
      15. 10. Overview of CMIS
        1. A bit of history
          1. A word of warning
        2. Objectives of CMIS
          1. What CMIS does not include
        3. CMIS vs. JCR
        4. The CMIS domain model
          1. Objects
            1. Documents
              1. Content streams
            2. Folders
            3. Relationships
            4. Policies
            5. Custom object types
          2. Properties
        5. Services
          1. Repository Services
          2. Navigation Services
          3. Object Services
          4. Multi-filing Services
          5. Discovery Services
          6. Versioning Services
          7. Relationship Services
          8. Policy Services
          9. ACL Services
        6. Capabilities
          1. Navigation capabilities
          2. Object capabilities
          3. Filing capabilities
          4. Versioning capabilities
          5. Query capabilities
          6. ACL capabilities
          7. Capabilities supported by Alfresco
        7. Protocol bindings
          1. The AtomPub binding
          2. The Web Services binding
        8. CMIS in action
          1. CMIS-enabled servers
            1. Alfresco
              1. Hosted CMIS AtomPub TCK
              2. The CMIS implementation in Alfresco
            2. Nuxeo
            3. eXo
            4. KnowledgeTree
            5. Sense/Net
            6. The closed-source world
          2. Client toolkits
            1. Apache Chemistry and OpenCMIS
            2. Drupal
        9. Summary
      16. 11. The CMIS AtomPub Binding
        1. The CMIS AtomPub binding
          1. Authenticating
          2. Getting the Service Document
            1. Collections
            2. Repository info and URI templates
          3. Navigating the repository
          4. Reading entries
          5. Reading type information
          6. Creating new objects
            1. Creating a new folder
            2. Creating a new document
          7. Updating a document's metadata
          8. Deleting a document
          9. Performing a search
            1. Paging search results
            2. Queries
              1. Relational view
              2. Statement syntax
              3. Full-text search
        2. Summary
      17. 12. Developing a CMIS Client using Apache Chemistry
        1. Introducing Apache Chemistry
          1. Chemistry, OpenCMIS, and the Alfresco TCK
        2. Downloading and installing Chemistry
          1. Building Chemistry
          2. Importing Chemistry into Eclipse
        3. The modules of the Chemistry client API
          1. The main client classes
        4. Setting up a connection
          1. Setting up a connection with AtomPub
          2. Setting up a connection with Web Services
        5. Code samples
          1. Listing the server's capabilities
          2. Listing repository types
          3. Getting a type definition
          4. Listing the root folder
          5. Creating a new folder
          6. Creating a new text document
          7. Uploading a binary document
          8. Reading a document's content
          9. Updating properties
          10. Deleting a document
          11. Searching
          12. Listing relationships
        6. Summary
      18. 13. The Web Services Binding
        1. Getting at the WSDLs
          1. Setting up the client project
          2. Declaring the CMIS client bean
        2. Some necessary pieces: WS-Security and WS-I Basic Profile
        3. Browsing the repository
        4. Inspecting objects
        5. Acting upon objects
          1. Creating a new text document
          2. Creating a new folder
          3. Updating a text document
          4. Updating properties
          5. Deleting a document
          6. Searching a document
        6. Summary
      19. 14. A Complete CMIS Client Application
        1. CMISWiki—a CMIS-based wiki
          1. Requirements
          2. Software building blocks
            1. The Google Web Toolkit
            2. The Mylyn WikiText parser
        2. Building and running CMISWiki
        3. The user interface
        4. Implementation
          1. Client-side code
            1. The GWT UiBinder
            2. Links and the browser history
          2. Server-side code
          3. Implementation of use cases
            1. Creating a new page
            2. Loading an existing page
            3. Uploading an image
            4. Displaying an image
            5. Searching
        5. Summary
      20. A. The CMIS Query Language
        1. The relational view projection
          1. Hierarchy of types and the relational view
        2. Results of queries
        3. Grammar of queries
          1. The SELECT clause
          2. The FROM clause
            1. Joins
          3. The WHERE clause
          4. Comparison operators
          5. Testing multi-valued properties
          6. Full-text search using CONTAINS
            1. The IN_FOLDER predicate
            2. The IN_TREE predicate
          7. The ORDER BY clause
        4. Escaping special characters