Alfresco WCM

Alfresco is built on state-of-the-art open source components such as Spring, Hibernate, Lucene, and JSF—often the components of choice for website developers today. It offers one repository for the whole team. This repository is a modern platform for Web Content Management 2.0 with a variety of user and technical benefits as described and discussed through the course of this book.

The web development framework comprises:

Java

JSF, Struts, Wicket, among others

Ruby

Ruby on Rails

.NET

ASP.NET

PHP

Zend, CakePHP, Codelgniter

Python

Django

Alfresco can be used by all of the previously mentioned frameworks. Each of them has different capabilities and often requires different implementation strategies. Using Alfresco WCM, you can provide a wealth of flexibility and choices when designing scalable web architecture.

The following diagram shows a possible physical architecture for a WCM solution:

Alfresco WCM

WCM can be recommended to be used when:

  • The authors are comfortable using the Alfresco Web Client and web forms
  • Minimal time should be spent creating a robust presentation tier
  • You need the ability to roll back change sets
  • You only need to link to WCM content and basic URLs
  • You need to have a staging environment where content is reviewed before it is published
  • Simple "submit for approval" workflow is sufficient

Installation option that is suitable for you

Alfresco is a 100 percent open source software developed using open standards. It can be operated on various operating systems, relational databases, application servers, web browsers, portals, and supports various languages. We shall examine all of the choices and determine which option is right for you.

Enterprise and Community Editions

Alfresco currently provides two types of product download options:

  • Alfresco Community Lab Network
  • Alfresco Enterprise Network

The latest release of Alfresco has an Enterprise Edition as well as a Labs edition.

Both the options have the same code base and features, and are 100 percent open source. For both the options, you can use Alfresco documentation (wiki), community support (forums), and community-contributed add-on products. The Alfresco Community Lab Network is free. The Alfresco Enterprise Network includes a per CPU license fee.

The Alfresco Community Labs Network is an unsupported product and is mainly designed for developers and technical enthusiasts. It is designed in non-critical environments. Alfresco Community Lab releases Early and Often and renders a daily build, offering the latest functionality. It doesn't provide scalability and high-availability certifications. I would recommend this to be used as the research vehicle for new features and as the platform for the Alfresco Community. And consider it as a test drive before you install.

If you are implementing Alfresco for a major corporation, financial, insurance, government, or healthcare organization, I would recommend you go for Alfresco Enterprise Network support. The primary benefit is that with the support of Alfresco and its certified partners you will get a stable, reliable, certified, and supported application with warranty and indemnity. Your Alfresco version will be certified on all available stacks such as Linux, Windows, MySQL, Oracle, and many more. You will benefit from Alfresco support, which includes problem resolution, compatibility advice, migration advice, and upgrade support. For mission-critical applications, you will get 24/7 support from Alfresco experts.

Operating Systems: Windows, Linux, Unix, MacOS

Choosing an operating system to run Alfresco will be based on various factors. For some companies it depends on in-house expertise. For example, if you have administrators and IT staff who can easily manage business applications running on a Microsoft Windows platform, then your choice could be to go with a Windows operating system. For some companies it is based on the integration requirements with the existing systems.

If you do not have any preferences, I would recommend you to go with the Linux operating system for production use. Linux source code is freely distributed. Tens of thousands of programmers have reviewed the source code to improve performance, eliminate bugs, and strengthen security. No other operating system has ever undergone this level of review. The key advantages of Linux are listed below:

  • The best technical support available
  • No vendor lock-in
  • Runs on a wide range of hardware
  • Exceptionally stable
  • Supports many tools and applications you need
  • Interoperates with many other types of computer systems
  • Low total cost of ownership

Databases: MySQL, Oracle, MS SQL Server, PostgreSQL

The data access layer of Alfresco is implemented using an open source software component and ORM (Object Relational Mapping) tool called Hibernate. Hibernate abstracts the database layer and provides seamless integration between the Alfresco repository and any relational database.

If the Microsoft Windows operating system is the OS of choice, then the natural choice for you can be MS SQL Server. If you already have an Oracle license, then Oracle database is also an option. Alfresco also supports the PostgreSQL database.

If you do not have any database preference, it is recommended that you go with the MySQL database, which costs nothing if you go with the open source version. The MySQL database has become the world's most popular open source database because of its consistency, fast performance, high reliability, and ease of usability. It's used in more than 10 million installations ranging from large corporations to specialized embedded applications. MySQL runs on more than 20 platforms, including Linux, Windows, OS/X, HP-UX, AIX, and Netware, giving you the kind of flexibility that puts you in control.

Application Servers: Tomcat, JBoss

Alfresco runs on any J2SE 5.0-compliant application server. Hence there are no application server-specific dependencies. However, it is important to make a choice of application server before moving into production.

Alfresco uses the Spring framework and not the Enterprise Java Beans (EJB) framework. So there is no dependency on JBoss or any other application server, which provides EJB container. Spring is an open source application framework for Java/JEE. The Alfresco repository uses the Spring Framework as the core foundation of its architecture. If you are developing a standalone application, then Tomcat might be a good option. Apache Tomcat powers numerous large-scale and mission-critical web applications across a diverse range of industries and organizations. It is the most widely-accepted web application server in the market.

On the other hand you must consider using the JBoss application server, which has the highest market capture (> 35 percent) in J2EE-based application servers in the world. JBoss internally uses Tomcat and hence you get the benefits of Tomcat servlet engine as well.

Alfresco utilizes JBoss cache's ability to distribute and maintain data caches, making it possible to build large-scale systems that outperform traditional enterprise content management systems. Alfresco also utilizes the clustering, failover, and load balancing facilities of the JBoss application server to increase scalability. Alfresco's business process management features are powered by the JBoss jBPM tool.

If you have already invested in JBoss, then Alfresco provides complementary industry-leading enterprise content management technology to the JBoss enterprise middleware system suite.

Portals (optional): JBoss portal, Liferay

It is optional for you to go with a portal of your choice; if you already have an enterprise portal, you can integrate Alfresco with it. If you do not have a portal in place and you would like to leverage the portal framework, then you can consider using either JBoss portal or Liferay portal. Both of these are based on J2EE technology; both of them are open source and open standards-based and both of them have Alfresco built-in support.

JBoss Portal provides an open source platform for hosting and serving a portal's web interface, publishing and managing its content, and customizing its experience. Although most packaged portal frameworks help enterprises launch portals more quickly, only JBoss Portal delivers the benefits of a zero-cost, open source license combined with a flexible and scalable underlying platform.

Liferay is the most downloaded and popular open source portal with 40,000 downloads per month. It runs on top of any J2EE servlet such as Tomcat. So a full installation of JBoss is not required, but it can run against most full application servers out of the box, including JBoss, JRun, BEA, WebLogic, and Orion. It has a full set of web service interfaces to the portal. Liferay supports more than 800 portlets (products) and has a wider adoption in the market.

Choosing a suitable software for your installation

You need to make the best choice of software to install Alfresco. If you do not have any specific requirements, you might consider a complete open source stack for production usage and go with Alfresco Enterprise Edition on the Linux operating system with a MySQL database running on a JBoss application server with Liferay Portal.

The examples in this book were created and tested with the following choice of Alfresco installation:

  • Eclipse
  • Alfresco Community Edition
  • Operating System: Windows XP
  • Database: MySQL 5
  • Application server: Tomcat 6
  • JDK 5
  • Portal: None

Eclipse installation

As we will be using Eclipse as a development tool for this book, in this section we will talk about the installation of Eclipse. Download the Eclipse Europa for Java/J2EE developers from:

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/europa/winter/eclipse-java-europa-winter-win32.zip.

Configuring the project for development

In this section, we will learn to set up the development environment for any Alfresco WCM project. We will see how we can configure a project in Eclipse.

Open Eclipse by double-clicking on the Eclipse icon. It will ask you to select the workspace. Create a new folder called bookworkspace and browse to that folder when asked for the workspace.

Eclipse will now start. Now we need to set up a new project for the book in Eclipse. Go to File | New | Project.

  1. Select Java | Java Project in the New Project wizard. Click on Next.
    Configuring the project for development
  2. In the next screen, provide the Project name as wcmbook and choose the Create new project in workspace option. Click on Next.
    Configuring the project for development
  3. Make sure you have wcmbook/bin in the Default Output folder in the next screen and then click on Finish.
  4. The project named wcmbook will be created with a src folder and the JRE library with the required .jar files attached for this project (if JDK is already installed on your machine). You can check that in the Package Explorer window as shown in the following screenshot:
Configuring the project for development

Configuring the build path

Now you need to configure the build path so that when you create any Java files, it can automatically be compiled by Eclipse. For that, make sure the Project | Build Automatically option is checked. To configure the build path for the project, follow these steps:

  1. Right-click on project name, that is, wcmbook and select Build Path | Add Libraries.
  2. Select User Library and click on Next.
  3. Click on the User Libraries button. In the User Libraries screen, click on the New button.
  4. Provide the name of the library as alfresco_lib and click on OK.
  5. Select that library name and click on Add JARs. Select all the .jar files from the Alfresco installed folder, tomcat/lib, and add those to this library. Also select all the .jar files from the tomcat/webapps/alfresco/WEB-INF/lib folder and add those to this library. Once done, click on OK.
  6. Then click on Finish.

Source code tree

Create the following folder structure for the project to store different types of files:

  • src
    • <Java classes with package>
  • config
    • alfresco
      • extension
        • <configuration files>
      • messages
        • <resource bundle files>
  • web
    • jsp
    • css
    • scripts
    • images
    • ...
  • /src: Put all your source Java classes in this folder with respective package structure.
  • /config/alfresco/extension: Place all your extension configuration files in this folder.
  • /config/alfresco/messages: Put Resource Bundle files (properties file) in this folder.
  • /web/jsp: Place any custom or modified JSPs in this folder. It's a best practice to create an extension folder inside the jsp folder and put all the custom JSPs in that folder.
  • /web/css: Place any custom or modified CSS files in this folder. It's a best practice to create an extension folder inside the css folder and put all the custom CSS files in that folder.
  • /web/images: Place any images that you have modified or newly created in this folder.
  • /web/scripts: Place any custom JavaScript files used by the user interface in this folder.

To create a folder in the Eclipse project:

  1. Select the web project for root-level folder or select the parent-level folder and right-click, then click on New | Folder.
  2. Provide the folder name and click on Finish.

To create a package in the eclipse project:

  1. Select the source folder src, right-click, select New | Package.
  2. In Name, provide the name of package, that is, com.Cignex.web.bean, and so on.

Once you are done with the package and folder structure creation, it will look similar to the following screenshot:

Source code tree

Build process

We will use Apache Ant, which is a Java-based build tool, for building the application from Eclipse.

Why to use a build tool

There are a number of steps required to transform the source into a deployable software solution. In general, a build tool allows developers and build managers to describe the build process. In a build, some steps may need to be executed before others or they may be independent of others. In summary, a build tool provides a mechanism to describe the operations and structure of the build process to deploy the code.

Integrating Ant with Eclipse

As we are using Eclipse as our development environment, we will learn how we can integrate Ant with Eclipse for the build process. First we need to create a new build file in Eclipse.

Creating the build.xml file:

  1. Right-click on project name wcmbook in Package Explorer
  2. Select New | File
  3. In the File Name box, type build.xml
  4. Click on Finish

Enter the targets for Ant Build in this file and save it. You can have build targets for compiling the code, packaging the .jar file, and so on. The build file we will use for our examples throughout the book will look like:

<project name="Cignex AMP Build File" default="package-jar" basedir=".">
<property file="build.properties" />
<target name="clean" description="Cleans Build directory">
<delete dir="${build.dir}" />
<delete dir="${project.dir}/lib" />
</target>
<target name="clean-alfresco" description="Cleans alfresco directory">
<delete dir="${alfresco.work.home}/tomcat/webapps/alfresco" />
</target>
<target name="mkdirs" description="Creates Build directory">
<mkdir dir="${build.dir}/dist" />
<mkdir dir="${project.dir}/lib" />
</target>
<path id="class.path">
<fileset dir="${alfresco.work.home}/tomcat/lib" includes="*.jar"/>
<dirset dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB-INF/classes" />
<fileset dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB-INF/lib" includes="*.jar" excludes="cignex.jar" />
</path>
<target name="compile" depends="clean,mkdirs" description="cmopiles the java source code">
<mkdir dir="${build.dir}/classes" />
<javac classpathref="class.path" srcdir="${project.dir}/src" destdir="${build.dir}/classes" debug="true"/>
</target>
<target name="package-jar" depends="compile" description="Package the classes into jar file">
<jar destfile="${project.dir}/lib/${package.file}">
<fileset dir="${build.dir}/classes" includes="**/*.class" />
</jar>
</target>
<target name="package-amp" depends="package-jar" description="Package the Module">
<zip destfile="${amp.file}" update="true">
<fileset dir="${project.dir}" includes="web/**/*.*" />
<fileset dir="${project.dir}" includes="config/**/*.*" />
<fileset dir="${project.dir}" includes="lib**/*.jar" />
<fileset dir="${project.dir}" includes="ext-lib**/*.jar" />
<fileset dir="${project.dir}" includes="module.properties" />
<fileset dir="${project.dir}" includes="file-mapping.properties" />
</zip>
</target>
<target name="update-war" depends="package-amp,clean-alfresco" description="Update the WAR file.">
<echo>Installing Cignex AMP into WAR</echo>
<java dir="." fork="true" classname="org.alfresco.repo.module. tool.ModuleManagementTool">
<classpath refid="class.path" />
<arg line="install ${amp.file} ${alfresco.war.file} -verbose" />
</java>
</target>
<target name="package-extension" description="Package the extension files into zip file" depends="package-jar">
<zip destfile="${package.file.zip}">
<zipfileset file="${project.dir}/lib/*.jar" prefix="WEB-INF/lib" />
<zipfileset dir="${web.dir}" />
<zipfileset dir="${alfresco.dir}" prefix="WEB-INF/classes/alfresco"/>
</zip>
</target>
<target name="war-backup" description="Package the extension files into zip file" depends="package-extension">
<copy file="${alfresco.war.file}" tofile="${alfresco.war.backup}"/>
</target>
<target name="integrate-extension" description="Integrate the extension files to existing alfresco.war file" depends="war-backup,clean-alfresco">
<available file="${alfresco.war.file}" type="file" property="alfresco.war.present" />
<fail unless="alfresco.war.present"
message="Could not find alfresco.war, please provide the correct path" />
<zip destfile="${alfresco.war.file}" update="true">
<zipfileset file="${package.file.jar}" prefix="WEB-INF/lib" />
<zipfileset dir="${web.dir}" />
<zipfileset dir="${alfresco.dir}" prefix="WEB-INF/classes/alfresco"/>
</zip>
</target>
</project>

Here in this build file, we have used some of the properties that we need to define in the build.properties file.

Creating the build.properties file:

# Property file for ant Build
project.dir=.
build.dir=${project.dir}/build
package.file=cignex.jar
package.file.zip=${build.dir}/dist/cignex.zip
amp.file=${build.dir}/dist/cignex-install.amp
web.dir=${project.dir}/web
alfresco.dir=${project.dir}/config/alfresco
alfresco.work.home=C:/alfresco_3.2r
alfresco.war.file=${alfresco.work.home}/tomcat/webapps/alfresco.war
alfresco.war.backup=${alfresco.war.file}.backup_

In this file, you can change the values for the properties accordingly. The build.xml file will read the properties from this file.

When you create the build.xml file, you can see all of the targets for the build file in the Outline view at the right-hand side in Eclipse.

Integrating Ant with Eclipse

Running the Ant target:

There are three different ways to run a particular build target.

1st Approach:

  1. Right-click on build.xml in the Package Explorer.
  2. Select Run | Ant Build. This will run the default target for the Ant Build and gives you the results in Eclipse's Console view.

2nd Approach:

  1. Right-click on build.xml in the Package Explorer.
  2. Select Run | Ant Build... with ellipsis (three dots).
  3. From the Ant launch configuration dialog screen, choose the target that you want to run from the available list of all targets of the build file and click on Run.

3rd Approach:

  1. Go to Windows | Show View | Ant (if Ant is not available there, click on Other... and select Ant | Ant from there).
  2. You will see the Ant view at the right-hand side in Eclipse.
  3. Drag the build.xml file from Package Explorer to this Ant view.
  4. Double-click on the target you want to run from the Ant view.

Debugging the Alfresco application in an Eclipse environment

We can configure Eclipse and start Alfresco in the debugging mode. This will help us in debugging the code for the Alfresco application. The steps to configure this are as follows:

  1. Modify catalina.bat available at<alfresco_home> omcatin to add the following line for DEBUG_OPTS=:
    set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888
    
  2. Now in Eclipse, navigate to Windows | Open perspective | Other | Debug, which will open the debug perspective.
  3. Click on Run | Open Debug Dialog | Remote Java Application | New configuration.
  4. Browse the project and enter the port number similar to the debug port in the catalina.bat (8888) file as shown in the following screenshot:
    Debugging the Alfresco application in an Eclipse environment
  5. Start the Alfresco server.
  6. Put the breakpoint in the file, which you want to debug or where you want the control to stop.
  7. Start the debug that you have just configured.
  8. Use Alfresco (Web-Client) to get to the debug mode.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset