O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Alfresco Developer Guide

Book Description

Customizing Alfresco with actions, web scripts, web forms, workflows, and more

  • Learn to customize the entire Alfresco platform, including both Document Management and Web Content Management

  • Jam-packed with real-world, step-by-step examples to jump start your development

  • Content modeling, custom actions, Java API, RESTful web scripts, advanced workflow

  • This book covers Alfresco Enterprise Edition version 2.2

In Detail

Alfresco is an open source platform for Enterprise Content Management (ECM) solutions. ECM includes things like Document Management, Web Content Management, Collaboration/Enterprise 2.0, Digital Asset Management, Records Management, and Imaging. At its core is a repository for rich content like documents, web assets, XML, and multimedia. The repository is surrounded by a services layer (supporting both SOAP and REST) that makes getting content into and out of the repository a breeze, which is why so many next generation Internet solutions are built on Alfresco.

Implementing Alfresco usually involves extending the repository to accommodate your business-specific metadata and business logic. These extensions are done using some combination of Java, JavaScript, XML, and FreeMarker.

This book takes you through a set of exercises as if you were rolling out and customizing the platform for a fictional organization called SomeCo, which wants to roll out Alfresco enterprise-wide. Each department has a set of requirements that need addressed. We will show you how to extend Alfresco to meet these requirements. By the time you've worked through the entire book, you will be familiar with the entire platform. You'll be prepared to make your own customizations whether they are part of a Document Management solution, a web site that uses Alfresco for content storage, or an entire custom application built on Alfresco's REST API. This book will give you the knowledge and confidence you need to make Alfresco do what you need it to do

Alfresco Developer Guide walks you through the customizations made as part of an enterprise-wide rollout of Alfresco; from custom actions to RESTful web scripts and everything in between.

Jeff Potts, Optaros' ECM Practice Director, blogger, and Alfresco's Community Contributor of the Year, takes you step-by-step through advanced customization examples. Whether it is customizing Alfresco's web client or creating your own application that interact with Alfresco via RESTful web scripts, it is all covered here.

Table of Contents

  1. Alfresco Developer Guide
  2. Credits
  3. About the Author
  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. Downloading the Example Code for the Book
      2. Errata
      3. Piracy
      4. Questions
  6. 1. The Alfresco Platform
    1. Alfresco in the Real World
      1. Basic Document Management
      2. Web Content Management
        1. Content Authoring Tools
        2. Separation of Presentation from Content
        3. Systematic Publication or Deployment
        4. Alfresco WCM Example
      3. Custom Content-Centric Applications
    2. Example Used throughout This Book
    3. Alfresco Architecture
      1. High-Level Architecture
        1. Add-Ons
      2. Open Source Components
      3. Major Standards and Protocols Supported
    4. Customizing Alfresco
      1. Basic Customization
        1. Dashlets
        2. Custom Views
        3. Rules and Rule Actions
        4. Simple Workflow
      2. Advanced Customization
        1. Examples of Advanced Customizations
        2. Extend the Content Model
        3. Perform Automatic Operations on Content
        4. Customize the Web Client
        5. Create a RESTful API
        6. Streamline Complex Business Processes with Advanced Workflows
        7. Get Your Web sites under Control
        8. Integrate with Other Systems
    5. Dusting Off Your Toolbox
      1. What about Adobe Flex?
    6. Understanding Alfresco's Editions
      1. Significant Feature Differences
      2. What's Used in This Book
    7. Summary
  7. 2. Getting Started with Alfresco
    1. Obtaining the SDK
      1. Step-by-Step: Building Alfresco from Source
    2. Setting up the SDK in Eclipse
      1. Step-by-Step: Importing the SDK into Eclipse
    3. Extending Alfresco
      1. Understanding the Extension Mechanism
        1. Standard Java Web Application Files
        2. Framework Files
          1. Spring Configuration Files
          2. JavaServer Faces Configuration Files
          3. Alfresco Configuration Files
          4. Solution-Specific Files
          5. Avoid Modifying Alfresco Code and Configuration
    4. Packaging and Deploying Customizations
      1. Separating Server-Specific Customizations
      2. Step-by-Step: Packaging and Deploying a Simple Customization
        1. Taking a Look at the Build File
    5. Troubleshooting
      1. Log4j
      2. Step-by-Step: Debugging from within Eclipse
      3. Node Browser
    6. Starting Over
    7. Summary
  8. 3. Working with Content Models
    1. Defining SomeCo's Content Model
      1. Step-by-Step: Starting the Custom Content Model with Custom Types
        1. Types
      2. Step-by-Step: Adding Properties to Types
        1. Properties and Property Types
        2. Constraints
      3. Step-by-Step: Relating Types with Associations
        1. Associations
      4. Step-by-Step: Adding Aspects to the Content Model
        1. Aspects
      5. Step-by-Step: Finishing up the Model
    2. Modeling Summary
      1. Custom Behavior
    3. Modeling Best Practices
      1. Out of the Box Models
    4. Configuring the UI
      1. Step-by-Step: Adding Properties to the Property Sheet
        1. Externalizing Display Labels
        2. Making Properties Read-Only
      2. Step-by-Step: Adding Types and Aspects to WebClient Dropdowns
      3. Step-by-Step: Adding Properties and Types to Advanced Search
      4. Step-by-Step: Setting Externalized Label Values
        1. Setting up Additional Locales
    5. Working with Content Programmatically
      1. Step-by-Step: Creating Content with JavaScript
        1. Leveraging Root Objects
        2. Knowing When to Save Documents
        3. Using JavaScript for Batch Manipulation
        4. Writing Content to the Content Property
      2. Creating Content with Java Web Services
        1. Step-by-Step: Run SomeCoDataCreator Class to Create Content
      3. Creating Content with PHP Web Services
      4. Creating Associations
          1. Step-by-Step: Run SomeCoDataRelater Class to Create Association
      5. Searching for Content
        1. Step-by-Step: Run SomeCoDataQueries Class to See Lucene Example
      6. Deleting Content
        1. Step-by-Step: Running SomeCoDataCleaner Class to Delete Content
    6. Summary
  9. 4. Handling Content Automatically with Actions, Behaviors, Transformers, and Extractors
    1. Encapsulating Content Operations in Actions
      1. Step-by-Step: Creating a Basic Action
      2. Hiding the Action from End Users
      3. Creating Actions that Require User-Specified Parameters
        1. Step-by-Step: Creating an Action that Accepts Parameters
      4. Incorporating Parameter Values in the Action Description
      5. Specifying Parameters when Code Executes an Action
    2. Binding Logic to Custom Types with Behaviors
      1. Step-by-Step: Writing a Simple Behavior in Java
      2. Binding to Multiple Types/Aspects
      3. Frequency
      4. Figuring Out to Which Policies to Bind
      5. Step-by-Step: Writing a Simple Behavior in JavaScript
      6. Binding Behavior to Child Types
        1. Step-by-Step: Writing a User Ratings Calculator
        2. Step-by-Step: Testing the New Rating Behavior
      7. Handling Deleted Ratings
    3. Extracting Metadata from Files
      1. Customizing Metadata Extractors
        1. Step-by-step: Customizing the Metadata Mapping
      2. Overriding the Default Mapping
      3. Leveraging Out of the box Metadata Extractors
      4. Digging into an Extractor Class
        1. Step-by-Step: Customizing a Metadata Extractor Class
    4. Transforming Content from One Format to Another
      1. Step-by-Step: Writing a Custom Transformer
    5. Summary
  10. 5. Customizing the Web Client User Interface
    1. Knowing When to Customize Alfresco's Web Client and When to Write Your Own
    2. Adding New Menu Items with UI Actions
      1. Step-by-Step: Adding a Simple UI Action
      2. Showing/Hiding the Label
      3. Leveraging Out of the Box Examples
      4. Using Other Types of UI Actions
      5. Step-by-Step: Adding a UI Action to Set the Web Flag
      6. Restricting the UI Action by Permission
    3. Writing Action Evaluators to Show/Hide UI Actions
      1. Step-by-Step: Evaluating Whether or Not to Show the Set Web Flag UI Actions
    4. Changing How the Web Client Renders Data with Custom Component Renderers
      1. Step-by-Step: Making a Text Field a Specific Size
      2. What Just Happened
      3. Overriding the Generator for All Properties
      4. Step-by-Step: Changing the Status Field on the Details Page to Display as a Stoplight Indicator
      5. Overriding and Customizing Components
    5. Creating Custom Dialogs
      1. Step-by-Step: Creating a Dialog to Execute Scripts
      2. Passing the Context to the Dialog
      3. Understanding the JSP
      4. Enabling and Disabling the OK Button
    6. Creating Custom Wizards
      1. Step-by-Step: Stubbing Out the Wizard
      2. Step-by-Step: Finishing Out the Wizard
      3. Adding Conditions to Wizard Step Pages
      4. Receiving Interview Feedback via Email
      5. Persisting Interviewer Choices
      6. Copying Alfresco's Code into Your Customizations
    7. Customizing Web Client JSP Pages
      1. Overriding Navigation Rules with Type-specific Settings
    8. Summary
  11. 6. Exposing Content through a RESTful API with Web Scripts
    1. Introducing the Web Script Framework
      1. Step-by-Step: Hello World Web Script
      2. What Just Happened?
      3. Following the Model-View-Controller Pattern
      4. Adding Controller Logic
      5. Configuring the Web Script
        1. Specifying the HTTP Method
        2. Specifying Arguments
        3. Specifying the Response Format
      6. Deploying Web Scripts
      7. Building Solutions with the Web Script Framework
    2. Planning the SomeCo Whitepapers and Ratings API
    3. Retrieving Data with Web Scripts
      1. Step-by-Step: Writing a Web Script to List Whitepapers
      2. Debugging
      3. Fast Facts
      4. Organizing Web Scripts
      5. Overriding Web Scripts
      6. Choosing a URL
      7. Choosing between the Repository and the File System
      8. Step-by-Step: Retrieving the Rating for a Whitepaper
      9. Specifying Optional Arguments
      10. Handling Errors
    4. Writing Java-Backed Web Scripts
      1. Step-by-Step: Writing a Java-Backed Web Script to Handle Ratings Posts
      2. Using the Correct ID for Web Script Beans
      3. Using both Java and JavaScript for Controller Logic
    5. Wiring a Web Script to UI Widgets
      1. Step-by-Step: Using a Widget to Post Ratings
      2. Implementing the Delete Ratings Link
      3. Adding the Web Script Calls to SomeCo's Whitepaper Web Page
      4. Making Other Types of Content "Rateable"
      5. Dealing with the Cross-Domain Scripting Limitation
    6. Handling Form Data
      1. Step-by-Step: Implementing a Form-Based Hello World
      2. Step-by-Step: Using File Upload in a Multipart Request
    7. Customizing the Web Client with Web Scripts
      1. Step-by-Step: Running a Web Script as a Dashlet
      2. Understanding Web Script Runtimes
    8. Advanced Web Scripts
      1. Running Web Scripts as JSR-168 Portlets
      2. Dealing with Web Script Authentication
      3. Controlling Web Script Cache
      4. Executing Remote Web Scripts
        1. Refactoring the Rating Service
    9. Summary
  12. 7. Advanced Workflow
    1. What is a Workflow?
      1. Workflow Options
    2. Creating Process Definitions
      1. Step-by-Step: Creating a Hello World Process Definition
      2. Organizing Processes
    3. Using the jBPM Graphical Process Designer
      1. Step-by-Step: Using jBPM Process Designer to Create and Deploy Processes
        1. Tokens
        2. Node Types
        3. Versioning Process Definitions
        4. Deploying Dependencies
        5. Using Alternative Deployment Methods
    4. Wiring a Process to the Alfresco UI
      1. Step-by-Step: Grabbing the Hello World Argument from the User
        1. Understanding Workflow-Specific Content Models
    5. Assigning Tasks to Users and Groups
      1. Step-by-Step: Creating the Initial Whitepaper Submission Workflow
      2. Controlling What Actions Can Be Taken from the Task Management Dialog
      3. Enabling the Workflow Initiator to Select Users and Groups
    6. Adding Logic to Workflows with Actions and Process Variables
      1. Storing Data in Process Variables
      2. Step-by-Step: Adding Logic to the Whitepaper Submission Workflow
      3. Using Java Classes for Decisions
      4. Getting Access to the Content in the Workflow
      5. Selecting the Right Event for Your Logic
      6. Using ForEachFork
    7. Using the Workflow API
      1. Step-by-Step: Implementing Third-Party Review
      2. Using a Task-Node Instead of a State
      3. Making the Third-Party Review More Robust
    8. Using Timers
      1. Step-by-Step: Adding a Timer to the Third-Party Review
      2. Understanding Timer Syntax
    9. Debugging Workflows
    10. Comparing Alfresco Workflow Options
    11. Summary
  13. 8. Web Content Management
    1. Understanding the Difference between Alfresco DM and Alfresco WCM
    2. Obtaining Alfresco WCM
      1. Step-by-Step: Installing Alfresco WCM
    3. Creating Web Projects
      1. Step-by-Step: Creating the SomeCo Web Project
      2. What Just Happened
      3. Playing Nicely in the Sandbox
      4. Inviting Users
      5. Mounting Sandboxes via CIFS
      6. Virtualization and Layering
    4. Creating Web Forms
      1. Step-by-Step: Creating a SomeCo Press Release Web Form
      2. Mapping XML Schema Types to Web Form Controls
        1. Localizing Web Forms with Labels and Alerts
      3. Generating XSD Dynamically
      4. Step-by-Step: Creating a Press Release Index Page
      5. Making Changes to an Existing Web Form
      6. Using Web Forms Outside the WCM User Interface
    5. Deploying Content
      1. Step-by-Step: Deploying Content Using the File System Receiver (FSR)
            1. Running Multiple FSR Hosts and Multiple FSR Targets
      2. Setting the FSR Target User and Password
      3. Viewing Deployment Reports
      4. Deploying to Test Servers
      5. Enabling Deployment Targets for Auto Deploy
      6. Step-by-Step: Deploying to an Alfresco System Receiver (ASR)
    6. Performing Post-Deployment Processing
      1. Step-by-Step: Running Post-Deployment Code in an FSR Deployment
      2. Handling Deletes
      3. Step-by-Step: Implementing ASR Deployment Callbacks
    7. Modifying and Creating WCM Workflows
      1. Using Launch Dates, Expiration Dates, and Link Checking
        1. Launch Dates
        2. Expiration Dates
        3. Link Checking
      2. Step-by-Step: Creating a No-Approval Workflow for Job Postings
    8. Working with the AVM API
      1. Step-by-Step: Writing a Web Script to Query AVMNodes
      2. Step-by-Step: Writing a Web Script to Trigger Deployments
        1. Implementing a Web Script for Submit
    9. Using the AVM Console
    10. Summary
  14. 9. Security
    1. Authenticating and Synchronizing with LDAP
      1. Step-by-Step: Setting Up a Local OpenLDAP Server
      2. Step-by-Step: Configuring Alfresco to Authenticate against LDAP
      3. Step-by-Step: Configuring Chaining
      4. Step-by-Step: Synchronizing LDAP with Alfresco
        1. Handling Large Directories
    2. Setting Up Single Sign-On (SSO)
      1. Step-by-Step: Implementing SSO
        1. Logging Out
      2. Step-by-Step: Configuring CAS to Use LDAP for Authentication
    3. Working with Security Services
      1. Securing the Admin User
      2. Granting Additional Users Admin Rights
        1. Step-by-Step: Making tpublisher1 an Admin
      3. Creating Users and Groups Programmatically
        1. Step-by-Step: Creating Users and Groups through the API
      4. Understanding Permission Definitions
        1. Permission Groups
        2. Permissions
        3. Permission Sets
        4. Step-by-Step: Setting Up A Portal Publisher Custom Role
        5. Global Permissions
        6. Mapping Permissions to Methods
    4. Summary
  15. A. API Reference and Examples
    1. Foundation API Public Services
      1. ActionService
      2. ActivityService (3.0 Labs)
      3. AttributeService
      4. AuditService
      5. AuthenticationService
      6. AuthorityService
      7. AVMService
      8. AVMLockingService
      9. AVMSyncService
      10. CategoryService
      11. CheckOutCheckInService
      12. ConfigurableService
      13. ContentUsageService (3.0 Labs)
      14. ContentService
      15. CopyService
      16. CrossRepositoryCopyService
      17. DeploymentService
      18. DescriptorService
      19. DictionaryService
      20. EditionService
      21. EmailService
      22. ExporterService
      23. FileFolderService
      24. ImporterService
      25. LinkValidationService
      26. LockService
      27. MailService
      28. MimetypeService
      29. ModuleService
      30. MultilingualContentService
      31. NamespaceService
      32. NodeService
      33. OwnableService
      34. PermissionService
      35. PersonService
      36. RegistryService
      37. RepoAdminService (3.0 Labs)
      38. RepositoryExporterService
      39. RuleService
      40. SearchService
      41. ScriptService
      42. SiteService (3.0 Labs)
      43. TaggingService (3.0 Labs)
      44. TemplateService
      45. ThumbnailService (3.0 Labs)
      46. TransactionService
      47. VersionService
      48. WorkflowService
    2. Lucene Queries
      1. Basic Lucene Syntax
      2. Property Search
      3. Proximity Search
      4. Range Search
      5. Field Search
        1. TYPE and ASPECT
        2. ID
        3. PARENT
        4. PATH
        5. QNAME
        6. TEXT
        7. Category
        8. Using Saved Searches as Examples
    3. JavaScript
      1. Root Objects
      2. JavaScript API
        1. General
          1. Association
          2. ChildAssociation
          3. ScriptNode
          4. ScriptUtils
          5. Root object: cache
          6. Root object: crossRepoCopy
          7. Root object: logger
          8. Root object: status
        2. Actions API
          1. Root object: actions
          2. ScriptAction
        3. AVM API
          1. Root object: avm
          2. AVMNode (extends ScriptNode)
          3. AVMScriptStore
        4. Classification API
          1. Root node: classification
          2. CategoryNode (extends ScriptNode)
        5. People API
          1. Root node: people
        6. Presence API (3.0 Labs)
          1. presence
        7. Search API
          1. search
    4. API Examples
      1. Create a Node
        1. Foundation
        2. JavaScript
        3. Web Services
      2. Perform a Search
        1. Foundation
        2. JavaScript
        3. Web Services
      3. Persist Content
        1. Foundation
        2. JavaScript
        3. Web Services
      4. Add an Aspect
        1. Foundation
        2. JavaScript
        3. Web Services
      5. Set a Property
        1. Foundation
        2. JavaScript
        3. Web Services
      6. Set Permissions
        1. Foundation
        2. JavaScript
        3. Web Services
      7. Start a Workflow
        1. Foundation
        2. JavaScript
        3. Web Services
  16. B. Alfresco Configuration Reference
    1. Actions
      1. Actions Available in both Enterprise and Labs
      2. Actions Available in Labs Only
    2. Web Client Config Elements
      1. Conditional Configuration Elements
      2. Unconditional Configuration Elements
    3. Action Groups
      1. Core Web Client Action Groups
      2. Forums-Related UI Action Groups
      3. Workflow-Related Action Groups
      4. WCM-Related Action Groups
    4. Metadata Extractors
    5. Transformers
    6. Graphical View of the Alfresco Content Model
      1. System Model
      2. User Model
      3. Content Model
      4. App Model
      5. BPM Model
      6. Workflow Model
      7. WCM Model
      8. WCM App Model
      9. WCM Workflow Model