In this chapter, we will introduce you to the world's most popular open source portal product. You will get an overview of Liferay's architecture, features, and running environments. You will also learn to prepare the infrastructure for the installation of a Liferay Portal instance.
People use Liferay Portal to set up websites. You can see examples of Liferay Portal in action at the following sites:
Cisco site (http://developer.cisco.com/web/cdc/home)
Sesame Street site (http://www.sesamestreet.org/)
AutoZone site (http://www.autozone.com/autozone/)
By mid-2011, Liferay Portal had been deployed 250,000 times all around the world.
In this book, we will walk through Liferay's functionalities by setting up a website using Liferay Portal. You will learn how Liferay Portal works and how you can take advantage of its features.
In the following sections, we will do some preparation for that website. We will talk about the following topics:
Liferay Portal concepts
Liferay architecture
Pre-requisites for Liferay Portal installation
Liferay Portal features
Let us get familiar with our chessboard first and then place the king, queen, rooks, and other pieces, before we start the game.
Liferay Portal is a Java web application. In a web application, a user types in a Uniform Resource Locator (URL) string in a browser address box and fires it. The browser sends the URL as a request to a corresponding application server and waits. The application server receives the request and processes data according to parameter values in the received URL. It sends a Hypertext Markup Language (HTML) format file to the requesting browser as a response. The browser interprets the HTML file and renders a webpage to the user. All the typical characteristics of a web application apply to the Liferay Portal.
The following is a deployment diagram for a Liferay Portal instance:

In this deployment diagram, a user accesses a Liferay Portal site with a web browser. Liferay receives the request and sends a request to the Single Sign On (SSO) server for authentication. The SSO server goes to the Lightweight Directory Access Protocol (LDAP) server to check the user's credentials. When that is successful, the SSO server tells Liferay Portal that the user is authenticated. Liferay Portal responds to the user request with a home landing page.
Note
Please note that not all Liferay Portal installations run with SSO. Some Liferay Portal installations are much simpler.
The Liferay Portal also runs portlet artifacts (please read on for an explanation of portlets). It relies on a database server to store data. It uses the mail server to send mails to the portal users. Optionally, Liferay Portal may also use other servers for additional functionalities.
The Liferay Inc. company site (http://www.liferay.com/) is based on Liferay Portal. Go to the Liferay company site and notice the Liferay logo, and the blue hue of the page, as shown in the following screenshot:

Now, go to the http://www.sesamestreet.org/ site of Sesame Street. (Turn on your speakers to get the full experience of this site)

This is a very interesting site. I want to stay at the site for a while, even though I am no longer a child! Have you seen any traits of Liferay Portal there? You may not; the design of Liferay's look-and-feel is so flexible that it can be easily customized.
Liferay Portal adopts an architecture that is flexible. It divides a webpage into a theme, a layout template, and portlets. The look-and-feel of Liferay Portal can be completely customized.
In our context, a portal is a web portal. A web portal refers to a website that provides a broad array of resources and services, which typically include e-mail, forum, searching, and online shopping. Yahoo! was one of the first portals.
There are also web portals for enterprise use. These portals are called enterprise portals. An enterprise portal provides content and collaboration for the employees of an enterprise. It is set up as an intranet application. Liferay Portal is often customized into an enterprise portal.
Most content at a Liferay Portal site comes from its portlets. A Liferay Portal contains portlets, as a window contains panes. A portlet is different from a pane, in that it consists of text and images.
A portlet works like a servlet. A portal URL request to the application server will invoke one or more portlets. The portlets run and produce HTML markup. Liferay Portal assembles the HTML markup into an HTML file. It returns the HTML file to the requesting browser.
Liferay Portal was named a leader in the Magic Quadrant for Horizontal Portals report of Gartner in 2010 (http://www.gartner.com/technology/media-products/reprints/liferay/206214.html). What is a horizontal portal? A horizontal portal covers many areas. It can be used as a platform for multiple social and collaborative purposes. It can also be used by more than one company in the same industry. Liferay Portal is a horizontal portal, because it has a collaborative suite of blogs, wiki, mail, and calendar portlets. Its message board and chat portlets can be used for social activities.
A vertical portal focuses on one functional area. It is a specialized entry point to a specific market, industry, or subject area.
Do you have a Yahoo e-mail account? Yahoo was one of the earliest portals on the Internet. Many users are still using the e-mail service provided by Yahoo.
Go to the http://www.yahoo.com/ site. You will find Mail, Autos, Dating, Finance, Games, Health, and Jobs links there. They cover various kinds of fields and industries, as is shown in the following screenshot:

Sometimes, I like watching videos on YouTube for a break. YouTube is a well-known site for videos. Now, go to the site at http://www.youtube.com/. What do you find there? You may have found Browse, Movies, video Upload links, and advertisements. You can also create an account at the YouTube site, as shown in the following screenshot:

You can do a lot of things and get a lot of services at the Yahoo site, while do every video-related thing at the YouTube site.
The Yahoo site is a horizontal portal. It is a platform for multiple social and collaborative purposes. The YouTube site is a specialized entry point for video fans: it is a vertical portal.
A user uses an open source portal product, free of charge. He/she can modify and extend its source code. Liferay Portal is an open source portal. It is distributed under the GNU, Lesser General Public License (LGPL) (http://www.gnu.org/copyleft/lesser.html).
Liferay Portal is available in two versions: Community Edition (CE) and Enterprise Edition (EE). A client can use its community edition, free of charge. If a client wants support from Liferay, Inc., they can buy the Enterprise Edition.
You can study the source code of an open source portal to learn portal technologies (Refer to https://github.com/liferay for the source code of Liferay Portal). A commercial portal product is more expensive than the enterprise version of an open source portal. IBM WebSphere portal and Microsoft SharePoint portal are commercial portal products.
This book is based on Liferay Portal Version 6.0. We will use this CE version to illustrate the features of Liferay Portal and set up a sample website.
Liferay, Inc. hosts its community edition source code at the SourceForge site (http://sourceforge.net/projects/lportal/).

It also hosts its latest version of source code at its own site at http://www.liferay.com/downloads/liferay-portal/available-releases.
Now, paste the previously-mentioned URL in your browser address box, click on the Enter key, and take a look at those packages.
Every release of Liferay Portal comes with the source code. You can compile and build the portal from the source code, if you choose to do so. You can study the source code to learn how Spring and Hibernate are used. You can modify the source code and re-build the portal if you like.
Note
Please note that Liferay Portal is also bundled in popular open source servlet containers or application servers in every release. It is easier to directly install with these bundles.
These are only some of the advantages of using an open source portal product.
The popularity of Liferay Portal largely comes from its adaptable architecture. There are three aspects to it.
Liferay Portal adopts a Service Oriented Architecture (SOA). Its architectural diagram is as follows:

In this diagram, Liferay Portal handles Hypertext Transfer Protocol (HTTP) requests from a user. The request will first be received by the Struts servlet. This servlet runs and renders portlets. During the process, the code invokes singletons, configured with Spring Application Programming Interface (API) and plain Java objects. It uses the Hibernate API to get data from or enter data into the database. Optionally, it may use the Java Messaging Service (JMS) to send out messages.
On the other hand, Liferay Portal also provides web services for programs running on other servers. The portal uses Apache Axis specification to generate web services. The Axis configuration is specified in the server-config.wsdd
file under the portal/tunnel-web/docroot/WEB-INF/
folder. These are a list of Simple Object Access Protocol (SOAP) services. When an external program asks for a web service from the Liferay Portal, the Axis servlet in Liferay Portal will answer it. It will also call singletons initialized through Spring framework and call the plain Java objects. These plain Java objects will use Hibernate API to access the database.
The architecture of Liferay Portal allows it to run on all major application servers and servlet containers, databases, and operating systems. It can be deployed on over 700 infrastructure combinations. For example, you can use MySQL or Oracle; you can run Liferay Portal in Tomcat or WebSphere.
You can plug in Solr for searching and Kaleo for workflow to Liferay Portal.
The portal administrator can apply different themes on different Liferay Portal pages. He can change the layout template of every portal page. By drag-and-drop, he can add portlets onto a portal page.
Liferay Portal has award-winning features. It's hot-deployable themes, draggable-and-droppable portlets, and fine-grained permissions system, among others, make it an optimal choice among other portal products on the market.
Liferay Portal themes take care of most of the look-and-feel of a Liferay Portal application. A theme usually contains a company logo, a navigation bar, footer, Cascading Style Sheet (CSS) code, and JavaScript code. A Liferay Portal site can have multiple themes. In this way, a user with proper permissions can dynamically apply a different theme to each portal page, if he/she chooses to do so.
Liferay Portal divides a page area into smaller sections with a layout template. Liferay Portal comes with 10 layout templates. A portal administrator will drag-and-drop one or more portlets into one such smaller section.
The theme and layout template makes a Liferay Portal site flexible. It is easy to change the look-and-feel of a Liferay site with the theme and layout template.
Liferay Portal provides communities and organizations for administering users and the sites. A user can belong to communities and/or organizations.
A community is a collection of users with similar characteristics and interests. The portal administrator can create a sub-site with each community.
An organization is a hierarchical collection of users. A user can be a member of multiple organizations.
Either a community or an organization can have public and private web pages. Any user at the Liferay Portal site can access the public pages, while only a member of a community or organization can browse the private pages of his/her community and/or organization.
Liferay Portal has rich content management features.
The content displayed at a Liferay Portal site can be dynamic or static. The dynamic content can be updated by multiple users at any time. It usually comes from data saved in database tables and is presented with custom portlets. The static content is the files uploaded through the Document library portlet and web content created with the web content portlet.
The following portlets are part of the Content Management System (CMS) of Liferay Portal:
The following portlets take care of Web Content Management (WCM) in Liferay Portal:
Web content portlet
Web content display portlet
Web content list portlet
Web content search portlet
The asset publisher portlet displays documents, images, blogs, wikis, message board entries, bookmarks, and web content.
The Liferay, Inc. company site is built on Liferay Portal. Now, go to http://www.liferay.com/ and find a portal page similar to the following screenshot:

What are the parts in the rectangles made of? They are all made of the web content display portlet.
The static content at the Liferay, Inc. site is created with the web content portlet (or web content display portlet). It is displayed with the web content display portlet.
The Liferay forum site at http://www.liferay.com/community/forums is made of the messages board portlet, while the Liferay blogs site at http://www.liferay.com/community/blogs is set up with the blogs aggregator portlet and the blogs portlet.
Liferay Portal runs on all major application servers and servlet containers. It works with all the important database servers on the market. Its requirements are minimal on hardware and software.
In this section, we will talk about the running environment for Liferay Portal. We will also install Java Development Kit (JDK), which is the infrastructure for Liferay Portal to operate. We will install MySQL database for Liferay Portal to connect to. This is the preparation for the installation of a Liferay Portal site in Chapter 2, Installing a Liferay Portal Instance.
To install Liferay Portal, you need more than 300 MB of disk space and at least 1 GB of Random Access Memory (RAM). The application server or servlet container that houses Liferay Portal runs at a port. You should make sure that other applications on your computer are not using that port.
Liferay Portal is written in Java. It runs on any computer where you can install the Java Runtime Environment (JRE) and an application server or a servlet container. It runs on computers that support either 32-bit JVM or 64-bit JVM.
Some features of Liferay Portal also need a mail server for support.
Assuming that you are using a laptop computer that runs the Windows 7 operating system, carry out the following steps to get the information about RAM:
Click on the Windows icon at the bottom corner on the left-hand side.
Right-click on the Computer link and then click on the Properties link.
Find the RAM information, as shown in the following screenshot:
This machine has 4.00 gigabytes of RAM installed, of which 3.24 gigabytes are available. Because the available memory is larger than is required for running a Liferay Portal instance, we can install a Liferay Portal instance on this laptop computer.
Liferay Portal can be combined with multiple kinds of database servers and application servers.
As a web application, the running environment of Liferay Portal involves a browser, Java Virtual Machine (JVM), a database server, and a mail server.
Note
The Liferay Portal Tomcat bundle comes with a default database called hypersonic , which is an in-memory database. This database is good for non-production use. This means that a reader does not have to install a database server for Liferay Portal, if he/she is running Liferay Portal purely for study purposes.
Liferay Portal can be installed on multiple operating systems. In this book, we will install a Liferay Portal instance in a Windows operating system. The sample site is installed in a Linux operating system.
Carry out the following procedure to install the latest version of JDK on your machine:
Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html and find a page with the content, as shown in the following screenshot:
Click on the jdk-6u26-windows-i586.exe link. When a window pops up, click on Run.
Click on Next in the next pop-up window.
Accept the default installation folder and click on Next.
Accept the default installation directory for JRE and click on Next.
When the installation is done, click on Finish.
Now that the JDK is installed, we set the
JAVA_HOME
variable and put Java commands on the path. The following is the procedure:Click on the Windows icon at the bottom corner on the left-hand side of the screen.
Right-click on Computer. Click on Properties | Advanced system settings | Environment variables.
Click on New in the System variables section. Define a
JAVA_HOME
variable and set its value toC:\Program Files\Java\jdk1.6.0_26
:Edit the Path variable in the System variables section. Add
%JAVA_HOME%\bin
as a value in the Path variable. It should be separated from other values by a semi-colon. A sample value for thePath
variable is as follows:%JAVA_HOME%\bin;%ANT_HOME%\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files\Intel\DMIX;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;c:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\Wave Systems Corp\Gemalto\Access Client\v5\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin
Click on OK to save the settings.
Open a Disk Operating System (DOS) interface. On the command line, enter
java-version
and press Enter.
You can download an application server or servlet container from its website and install the Liferay Portal Web Application Archive (WAR) file and dependency Java Archive (JAR) files in it. Alternatively, if Liferay has already bundled Liferay Portal with an application server or servlet container, you can download that bundle, unzip it, and install it.
Liferay Portal supports the following application servers:
Apache Geronimo
Borland ES
JBoss
JonAs
Jrun
OracleAS
Orion
Pramati
RexIP
Sun GlassFish
Sun JSAS
WebLogic
WebSphere
Liferay Portal also runs in the following servlet containers:
Jetty
Resin
Tomcat
For every release, Liferay, Inc. installs Liferay Portal in some open source servlet containers and application servers. The resulting packages are called Liferay Portal bundles, which are ZIP files. A user can download one such bundle, unzip it, and install it. The presently-available bundles are as follows:
We can connect Liferay Portal to the following database servers:
Apache Derby
IBM DB2
Firebird
Hypersonic
Informix
InterBase
JdataStore
MySQL
Oracle
PostgreSQL
SAP
SQL Server
Sybase
In this book, and at the sample site, we will run Liferay Portal with MySQL database. MySQL is the world's most popular open source database. The current version of Liferay Portal requires MySQL version 5.0 or above.
If you have not already installed the MySQL database, follow these steps to install the latest version of MySQL Community Server on your computer:
Go to http://dev.mysql.com/downloads/ to download the MySQL database installation package. You will find the page similar to the following screenshot:
Download a mysql-5.5.14-win32.msi file to a local directory. That file is Microsoft Installer (MSI) for MySQL database server.
Double-click on the mysql-5.5.14-win32.msi file. A window pops up. Click on Run.
Click on Next. Check the I accept the terms in the License Agreement and click on Next.
For the setup type, choose Custom and click on Next.
For the installation folder, browse to C:\mysql and click on Next:
Click on Next. Click on Install.
When the installation is done, leave Launch the MySQL Instance Configuration Wizard checked and click on Finish.
Click on Next to configure the MySQL server.
Select Standard Configuration and click on Next.
Click on Execute to perform configuration.
When the configuration is done, click on Finish.
Add C:\mysql\bin as a value in the Path system variable, as we did for Java.
In a DOS window, type mysql –uroot –p on the command line. Press Enter.
The previous screenshot confirms that the MySQL database server has been installed successfully.
You can use Firefox (3.0 and above), Internet Explorer (IE) (7.0 and above), Chrome, Safari, and Opera to browse a Liferay Portal site.
The ability of a web browser to access a website depends on the user interface (UI) technologies used in the development of that website. Because Liferay Portal is highly customizable, you may be able to interact with a customized Liferay Portal site with more varieties of browsers on the market.
A Liferay Portal theme decides most of the look-and-feel of a Liferay Portal site. In almost all situations, a client will develop a custom theme for their site. The user interface technologies that they use for their custom theme decide the accessibility of their site.
Liferay 6.0 CE uses Alloy user interface (Alloy UI). Alloy UI has combined the following technologies:
Hyper Text Markup Language 5 (HTML5)
Cascading Style Sheets Level 3 (CSS3)
Yahoo! User Interface Version 3 (YUI3)
HTML 5 defines the HTML elements in a webpage. It is used for the structure of a portal page. CSS3 is used to add styles to document object models (DOM). YUI3, which includes JavaScript API, is used to make the HTML elements dynamic.
HTML 5 is the latest revision of the HTML standard. HTML 5 is still a work in progress. However, Safari, Chrome, Firefox, and Opera already support some of its features in their latest versions. IE 9 will also be available to support some HTML 5 features.
Liferay Portal has a feature to support browsing in iPad and smart phones in its 6.1 CE version. This is achieved by detecting the screen layout of the device with JavaScript code. When the computer screen layout is 960px wide, Liferay Portal knows that it is a desktop computer or iPad in landscape mode; when the screen layout is 320px wide, Liferay Portal knows it is a smart phone in portrait mode. Liferay Portal will apply a corresponding Cascading Style Sheet (CSS) class, and thus adjust the dimensions of an image and other content on the portal page.
Liferay Portal has a feature to convert web content, wiki articles, and message board content into PDF files and files of other formats. This feature relies on the integration of the OpenOffice application. OpenOffice is an open source office software that consists of a word processor, a spreadsheet program, a drawing tool, and a math program.
We install OpenOffice on our computer by carrying out the following steps:
Go to http://www.openoffice.org/ and download the latest version of OpenOffice.org for Windows.
Save the OOo_${VERSION}_Win_x86_install-wJRE_en-US.exe file in a chosen folder.
Double-click on the OOo_${VERSION}_Win_x86_install-wJRE_en-US.exe filename; this triggers the installation process.
Click on Next, when you see the following pop-up window:
Accept the default folder for unpacking and click on Unpack.
Click on Next when a new installation window shows.
Input username and organization and click on Next.
Use the Typical setup type and click on Next.
Click on Install.
Click on Finish, when the installation wizard is completed.
To start the OpenOffice service, do the following:
Enter DOS mode.
Go to the C:\Program Files\OpenOffice.org 3\program directory; this is where OpenOffice is installed by default.
Run the following command:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
A screenshot of the DOS window is as follows:

The previous command means that OpenOffice has started a service with the headless option. Now, this service will accept a request at port 8100. It is waiting for the request from a server, whose Internet Protocol (IP) address is 127.0.0.1, which means the local host.
We can check to see how the OpenOffice service is running.
To confirm that the OpenOffice service is running, perform the following steps:
Right-click the Windows task bar.
Click on Start Task Manager, and you will find a window similar to the following screenshot:
You can see that the OpenOffice service is shown in the list of running processes in Windows.
In the DOS window, run the
netstat -anptcp
command, which will show the network activities on the computer. The DOS window will show content similar to the following screenshot:
As you can see, a service is listening at port 8100 for a request from 127.0.0.1.
If you reboot your computer, this service will be stopped and gone, because you started it manually. So, a better choice is to set up this service as a Windows service, which will be started whenever your machine is rebooted.
You may install Liferay Portal in a bundle, such as liferay-portal-tomcat-${version}.zip
, on your computer. If it is a Linux machine, you can run the unzip liferay-portal-tomcat-${version}.zip
command to extract the files. On a Windows machine, an unzip tool may be already available, or you can download WinRAR at http://download.cnet.com/WinRAR-32-bit/3000-2250_4-10007677.html and install it to explode the ZIP file.
In this chapter, we have learned what Liferay Portal is. We now know the following facts about Liferay Portal:
Liferay Portal is a Java web application
Liferay Portal is a horizontal portal
Liferay Portal has award-winning features
In addition, we have talked about the environment for Liferay Portal to run, including hardware and software. We have also installed JDK, MySQL database server, and the OpenOffice application.
Now that the infrastructure is set, we are ready to install a Liferay Portal instance on our computer, which is the topic of Chapter 2,Installing a Liferay Portal Instance.