47,99 €
Alfresco is the renowned and multiple award winning open source Enterprise content management system which allows you to build, design, and implement your very own ECM solutions.You have read a number of tutorials, blogs, and books on Alfresco. Now you're in the real world, trying to use Alfresco, but you’re running into problems with it. This is the book you want. Packed full of solutions that can be instantly applied, this cookbook with its practical based recipes and minimal explanation meets that demand.This Alfresco 3 cookbook boasts a comprehensive selection of recipes covering everything from the basics to the advanced. The book has recipes for quickly installing Alfresco in Windows and Linux and helping you use custom content model, rules, and search. There is also a collection of recipes focused on creating Scripts, Freemarker templates, Web Scripts, and new workflow definitions. Steps to integrate Alfresco with other systems like MS-Office are also included. You will be able to use Alfresco’s File and Email servers. Finally, step-by-step recipes are presented to create an Alfresco build environment and compile the source code. This Alfresco 3 Cookbook is perfect for developers looking to start working on Alfresco quickly, gain complete understanding, write custom implementations, and achieve expertise very easily.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Veröffentlichungsjahr: 2011
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2011
Production Reference: 1180711
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-849511-08-7
www.packtpub.com
Cover Image by Duraid Fatouhi (<[email protected]>)
Author
Snig Bhaumik
Reviewers
Piergiorgio Lucidi
Adit Patel
Khazret Sapenov
Snehal Shah
Acquisition Editor
Steven Wilding
Development Editor
Alina Lewis
Technical Editor
Gauri Iyer
Copy Editor
Leonard D'Silva
Project Coordinator
Shubhanjan Chatterjee
Proofreader
Mario Cecere
Indexer
Tejal Daruwale
Graphics
Nilesh.R.Mohite
Production Coordinators
Adline Swetha Jesuthas
Arvindkumar Gupta
Cover Work
Adline Swetha Jesuthas
Arvindkumar Gupta
Snig Bhaumik is the Technical Director at InfoAxon Technologies Ltd, based in India. He is also the Director of Open Source Innovation and heads the Knowledge Management Practice at InfoAxon—India's first and pioneer Open Source Integration Company.
A computer engineer by education and developer at heart, Snigdhendu has in total ten years of experience in various technologies such as Alfresco, Liferay, Pentaho, and Microsoft .NET. An open source enthusiast and regular community participant, Snigdhendu was the original contributor of Alfresco Calendar component. He specializes in Knowledge Management and Business Intelligence domains, and is responsible for designing and architecting KM and BI solution offerings.
My sweet wife Chaitali was so patient with my late nights, and I want to thank her for her faithful support while writing this book.
I would also like to thank my mother for everything. She has always been the guiding force for me.
Writing of this book could not have been possible but for the ungrudging support from my colleagues at InfoAxon.
Finally, I sincerely thank Packt Publishing for giving me the opportunity to write this book.
Piergiorgio Lucidi is an Open Source Product Specialist and a certified Alfresco Trainer at Sourcesense. Sourcesense is a European Open Source systems integrator providing consultancy, support, and services around key open source technologies.
He works as a software engineer and has seven years of experience in the areas of Enterprise Content Management (ECM), system integrations, and web and mobile applications.
He is an expert in integrating ECM solutions in web and portal applications. He regularly contributes to the Alfresco Community Forum supporting newbie and expert users.
He is a project leader and committer of the JBoss Community; he contributes to some of the projects of the JBoss portal platform. He is a speaker at conferences dedicated to Java, Spring Framework, open source products, and technologies.
He is an author and an affiliate partner at Packt Publishing, he has written the technical book Alfresco 3 Web Services in collaboration with Ugo Cei. He also writes and publishes book reviews on his website Open4Dev (http://www.open4dev.com/).
I would like to thank Packt Publishing for this great opportunity to work again in a very interesting project about Alfresco.
Adit Patel has done his Master's in Computer Applications. He started his career with CIGNEX Technologies in the year 2004. He has successfully handled complex projects for enterprise customers for implementing enterprise content management systems. He has helped many enterprise customers migrate from proprietary content management systems to more efficient and scalable content management systems—like Alfresco. He holds in-depth knowledge and experience of Alfresco architecture and implementations.
I would like to thank and dedicate my contribution to this book to my guru H.D.H. Pramukh Swami Maharaj.
Khazret Sapenov, a 20-year veteran of ICT, is the founder and chief technology officer of Cloudcor, which serves hundreds of enterprise clients and works closely with a set of managed partners and independent software vendors. In this role, Sapenov is responsible for leading overall strategy and technology direction across the United States and Canada, including employees in IT, partner, marketing, operations, and vertical industry teams.
Sapenov previously served as the corporate director of research and development at Enomaly, where he was responsible for growing the company's virtualization solutions business, including development and service delivery.
Prior to working with Enomaly, Sapenov held positions in technology solutions development in various Fortune 100 companies where he was responsible for global network, data centers, and information security, help desk, core IT services, and enterprise line-of-business applications.
Cloudcor's organizations under Sapenov's leadership have developed into one market and gained wide recognition as thought leader in cloud computing.
Sapenov founded Cloudcor in 2008. Before that, he was in corporate and academic research roles, covering oil and gas resources prospecting and development. Sapenov is a graduate of the University of Karaganda, where he received his Master's degree in Applied Mathematics.
I'd like to thank my parents for giving me life and supporting all my initiatives, my wife Saule and sons Asan and Aidos for being tactful and quiet when working on this book.
Snehal Shah has served as the manager and architect of the engineering teams for seven years in the area of internet applications, system software, and legal applications for customers in the United States, UK, and India.
He is an expert in Content Management Systems (CMS). At CIGNEX, he has successfully delivered various CMS applications using various open source technologies. Snehal earned his Bachelor's degree in Computer Engineering from DDIT, India.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Alfresco is the renowned and multiple award-winning open source Enterprise content management system which allows you to build, design, and implement your very own ECM solutions.
You have read a number of tutorials, blogs, and books on Alfresco. Now you're in the real world, trying to use Alfresco, but you're running into problems with it. This is the book you want, packed full of solutions that can be instantly applied to this cookbook with its practical-based recipes and minimal explanation meets that demand.
This Alfresco 3 Cookbook boasts a comprehensive selection of recipes covering everything from the basics to the advanced. The book has recipes for quickly installing Alfresco in Windows and Linux and helping you use custom content model, rules, and search. There is also a collection of recipes focused on creating Scripts, Freemarker templates, Web Scripts, and new workflow definitions. Steps to integrate Alfresco with other systems like MS-Office are also included. You will be able to use Alfresco's File and e-mail servers. Finally, step-by-step recipes are presented to create an Alfresco build environment and compile the source code. This Alfresco 3 Cookbook is perfect for developers looking to start working on Alfresco quickly, gain complete understanding, write custom implementations, and achieve expertise very easily.
Chapter 1, Getting Started: It introduces Alfresco with brief demonstration of the Alfresco Explorer application. Get Alfresco downloaded and installed on your machine, and finally be acquainted with the default distribution and architecture of Alfresco.
Chapter 2, Creating and Organizing Contents: It explains how to use Alfresco as Content Management System, how to upload or create contents, how to apply tagging or categorization of content, understand content metadata, use the document versioning capability of Alfresco.
Chapter 3, Securing and Searching Contents: It is about another important aspect of the Content Management System—Security. It helps you understand how to secure your contents and folders. How to create users and user groups—and assign permissions for who can do what. You will also know about the search capabilities offered by Alfresco, how to search contents and how search works in Alfresco.
Chapter 4, Rules—the Smart Spaces: It will help you learn how to make your Alfresco repository dynamic, how to implement your business requirements that works automatically in the repository. You will understand how to create and apply rules in the repository; you will also be familiar with different actions that can be performed via a rule.
Chapter 5, Administering Alfresco: It contains recipes for administering Alfresco, demonstrating how to manage users, user groups, create taxonomies, manage content categories. You will also be aware of how to use the Alfresco Node Browser to view and search contents stored in the repository. You will also know how to manage your Alfresco explorer dashboard.
Chapter 6, Customizing Alfresco Web Client: Alfresco offers customization of the Web Client application via a number of XML configuration files. This chapter elaborates various recipes for changing the view and appearance of the web client, customizing the application as per your requirements, and so on.
Chapter 7, Alfresco Content Model: Designing and modeling the content properties and architecture is one of the most important requirements in a content management system. Alfresco offers dynamic capabilities for designing the content models. Using these recipes you will be able to understand the core architecture of Alfresco content models, create your own custom content models, use your custom models in the Alfresco explorer application.
Chapter 8, Alfresco JavaScript API: Alfresco offers the repository functionalities in form of JavaScript APIs. In this chapter, you will understand the API structure and features offered. Several example recipes help you implement various functionalities. You will also learn how to write, execute, and debug scripts written using the APIs.
Chapter 9, Freemarker Templates: Freemarker Template is the presentation layer technology used in Alfresco applications. The recipes of this chapter would help you understand the technologies and model behind the Freemarker templates in Alfresco. Several template examples are included for commonly-used functions such as displaying folder contents, showing workflow tasks, showing contents recursively, displaying content properties and details, and so on.
Chapter 10, Web Scripts : Alfresco Web Scripts provide RESTful APIs of the repository services and functions. The chapter elaborates all related concepts, knowledge and how-to do it recipes that would help you write, deploy and debug web scripts. You will also understand the usage of default web scripts library that come with Alfresco. Several sample web scripts are included, for example sending e-mails using templates, searching and displaying documents, and so on.
Chapter 11, Working with Workflows: Workflow implementation is one of the major requirements in a content management system in a business. This chapter would help you understand the Alfresco business process engine in detail. You will understand how the workflows are implemented in Alfresco repository along with various components of the workflow engine. Several detailed examples and recipes are included to guide you create custom workflows, custom task models, specific resource bundles, customizing the web client to render the custom tasks and workflows properly. You will also be able to use the Alfresco workflow console interface which is useful for debugging the task execution within the BPM engine.
Chapter 12, Integrating with MS Outlook and MS Office : Alfresco can be used from several other applications and interfaces. Being a content management system, it is quite important to have the Alfresco repository accessibility from some popular content authoring applications such as Microsoft Office. This chapter helps you integrate the Alfresco repository with MS Word, Excel, and PowerPoint. Recipes are also included for communicating with repository directly from any standard e-mail client application such as MS Outlook.
Chapter 13, Configuring Alfresco E-mail and File Servers: The Alfresco repository can act has file servers as well and you can expose the repository using several other standard protocols such as FTP, CIFS, WebDAV, and so on. These recipes are a step-by-step guide to configure these protocols and using the content repository from different systems. From this chapter, you will also be able to use Alfresco as e-mail server, and e-mails sent to some specific address will land directly into the repository.
Chapter 14, Building Alfresco: Until now you have used Alfresco as the binary bundle provided and downloaded. Now you can compile and build Alfresco source code also. Recipes in this chapter will guide you to get the source from Alfresco source code repository, compile and build the source code. You can modify Alfresco source code as your will; of course as per Alfresco license, you should contribute your changes back to Alfresco community.
The software list for this book is as follows:
If you are a software developer interested in content management systems, who wants to work with Alfresco or is already experienced in Alfresco, this cookbook will get you up and running quickly. If you want rapid implementation of Alfresco's most important and effective features then this is the cookbook for you.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "We choose our InfoAxon folder for this operation."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Go to Company Home and try to add a new Content.".
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
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.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, we will cover the following:
This chapter will demonstrate how to install Alfresco, introduce Alfresco Explorer—the web client interface for managing the repository, and the applications that are bundled with Alfresco standard distribution.
Towards the end, you will understand how Alfresco stores and organizes the uploaded contents. We will also be acquainted with the default spaces that come with the Alfresco repository.
Today, Alfresco is the leading Open Source alternative to Enterprise Content Management—alternative to Microsoft SharePoint®, Documentum®, Open Text®, and so on. Alfresco is developed using best-of-breed Open Source technologies such as Spring, Hibernate, Lucene, modern standards such as JSR-168, JSR-170, Level 2 Web Services, Java Server Faces, and so on. Alfresco manages almost all types of content within an—enterprise documents, records, web pages, images, XML documents, or any other files.
Some of the most important capabilities and features of Alfresco are:
Alfresco offers several integrated products and services in the ECM suite.
The core component in the architecture of Alfresco is the Repository. The Alfresco repository is a collection of services and components. These interact with the Alfresco storage that consists of the contents and indexes stored in binary format, the RDBMS to store the transaction data, tasks and business process information, audit statistics, user and group records, and so on.
On top of the Repository, the Content Platform serves as the podium of all content management operations. Alfresco Content Platform is one of the most scalable Java Content Repository (JCR). The Content Repository API for Java (JCR) is a specification for Java application APIs to access the repositories in a standard and unified manner. The REST-based lightweight mash up architecture enables Rapid Application Development and other applications to integrate with the content repository easily.
REST, stands for Representational State Transfer, it is a software architecture which client programs and server services can interact with on any standard protocol such as HTTP.
A RESTful web service or RESTful web API is a collection of resources with three well-defined aspects.
A base URL of the service.
The Internet media type of the data supported and returned by the service, such as JSON, XML, HTML, and so on.
The set of operations supported by the service using HTTP methods such as GET, POST, PUT, DELETE, and so on.
We will explore how Alfresco APIs can be exposed as RESTful services in later chapters.
Using the flexible Content Platform, several products and services have been exposed such as the Web Client (Alfresco Explorer), Collaboration (Share), and Web Content Management system.
Earlier called Alfresco Web Client, this application is developed using Java Server Faces (JSF). Using Alfresco Explorer, you can explore the full repository of the current installation of Alfresco and perform most of the activities. In future, this application can be phased out in favor of Alfresco Share. However, Explorer has very wide capabilities for managing the repository and can be considered as a system administrator tool.
Java Server Faces (JSF) is an MVC structured web application framework based on Java. It is created to simplify the development of web-based user interfaces.
For more information on JSF, please see http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html.
If you are using Alfresco with Tomcat, you can invoke the web client in your web browser by the URL http://localhost:8080/alfresco, or if you are using Alfresco with JBoss, use the URL http://localhost:8080/portal.
We are here assuming that the Alfresco server is running in your local machine and the web server is running on port 8080—this is the default port where the Tomcat or JBoss servers run, unless you manually change the ports.
A few operations for which you can use the Alfresco Explorer are:
We will be discussing how to install and run Alfresco in the next few sections of this chapter.
Share is the Web 2.0 collaboration-based platform providing content management capabilities with simple user interfaces. It provides users with tools for searching and browsing the content, displays thumbnails, and onscreen flash previews of standard documents, enables collaboration between a community of users by various Web 2.0 collaboration tools such as Wikis, Blogs, and Discussion Forums.
Share provides highly-collaborative content management-controlled around sites and activities. End users can easily create collaborative sites for projects, departments, locations, or organization branches. They can invite users to collaborate and participate on contents, approve and publish contents using rich content modeling and lifecycle management of the underlying repository.
The Share application is accessible at http://localhost:8080/share.
All users have their private dashboard available in the Share platform. A dashboard is a collection of dashlets—a dashlet is a miniature view of an application or of functionality or some information. For example, the Tasks dashlet shows all the pending tasks of the current users with information and controls to manage each of the tasks.
Share enables a collaborative environment in an organization where the participation and involvement of the users happens around sites. A site can be viewed as a community or group of users, a department, a branch, or a location of an organization. The most common usage of site can be project, for example, when you start a new project, you start a site, invite the members into the site, collaborate amongst yourselves, and produce knowledge and content.
Share normally offers four types of sites—Collaboration Site, Meeting Workspace, Document Workspace, and Record Management Site. While Collaborative Site is the default type of site created in Share, Document Workspace is usually created via MS Office®.
Similar to user dashboard, each site also has a dashboard with dashlets such as:
Collaboration Site is preconfigured with a set of default pages. Each page offers different collaboration tools around the site.
Alfresco uses Hibernate as the Object Relational Mapping (ORM) layer. Thus, it is capable of plugging into any of the popular relational databases such as MySQL, PostgreSQL, Oracle, MS SQL Server, and so on.
In this book, we will be demonstrating examples using the MySQL database.
In order to set up your MySQL database for Alfresco, you would need a MySQL database server and an optional MySQL client. A MySQL client could be handy if you are working on Windows.
The listed setups are available in the form of Microsoft Installers (.MSI files). If you do not require Documentations and Development Components (in our case, for running Alfresco in a Developer Machine, we do not need these), you can download the installers without the essentials. Choose the installer that suits you and download.
If you are running a 64-bit Operating System environment, you can download the 64-bit version of the server from http://dev.mysql.com/downloads/mirror.php?id=390238#mirrors. Otherwise, go for a 32-bit installation from http://dev.mysql.com/downloads/mirror.php?id=390237#mirrors
Note that the MySQL Workbench requires .NET Framework 3.5 to be installed in the machine, in case it is not, there is your machine; you can use MySQL GUI tools or SQLYog. The following are some of the clients available for MySQL:
MySQL Workbench
http://dev.mysql.com/downloads/workbench/
GUI tools for MySQL 5.0
http://dev.mysql.com/downloads/gui-tools/5.0.html
SQLYog
http://www.webyog.com/en/downloads.php
MySQL client applications are not mandatory for Alfresco server setup. However, it is sometimes handy to get a client application of the database server in order to view, create, and configure the database and the database users. In case you do not have any client application installed, you can still use the MySQL server command prompt from your localhost.
After you have installed the server and the client application, let's create a database for Alfresco. By default, Alfresco stack uses the name 'Alfresco' for MySQL database as well as for the username and password. Though you can change these settings, we will go with these default settings for now.
Using UTF-8 encoding and collation is recommended by Alfresco.
With this, we have set up a blank database for our Alfresco server and created a user. We will now give permissions to this user for using the database schema.
Alfresco's Tomcat bundle contains database creation, user creation script, and grant right script on that database under "<<ALFRESCO_INSTALLATION_DIR>>\extras\databases\mysql\db_setup.sql". This allows the creation of a database with a single click only.
In the previous steps, we have created a blank database for Alfresco and created a user and granted it permissions to manage the database. Now when Alfresco Tomcat or JBoss bundle runs for the first time, it will create all the database objects (tables, and so on) automatically.
The Alfresco bundle uses MySQL as the database by default, thus you don't have to perform any changes for that.
We have created a database with the name alfresco. We have also created a user with the name alfresco with the same password. This is because the default setting of Alfresco bundle is configured in this way. Thus, you don't have to change any settings in the default bundle.
Default configurations are mentioned under "ALF_HOME>>\tomcat\shared\classes\alfresco-global.properties". If needed, you can change this setting as per the database configuration.
There are two methods to install Alfresco on a Windows platform.
The first approach will install Alfresco in Windows along with JDK (optionally), create the Alfresco database automatically, and can configure and start Alfresco as a Windows Service. It will inject the relevant shortcuts in your Start Menu just like any other application installed in your machine. You can start/stop the server using the Start Menu option or a Windows Service. This is a fully-automated and smooth approach to install Alfresco.
The second approach is more manual. You will have the downloaded Tomcat or JBoss bundle of Alfresco. Manually configure a few things, and you are ready to go. However, you cannot have Alfresco as a service in Windows very easily, in this case, and won't have the Start Menu shortcuts ready for you. But in this case, as a developer and explorer of Alfresco, you can have a number of Alfresco bundles deployed and running on your machine.
