Liferay 6.x Portal Enterprise Intranets Cookbook - Piotr Filipowicz - E-Book

Liferay 6.x Portal Enterprise Intranets Cookbook E-Book

Piotr Filipowicz

0,0
29,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

If you are a Java developer or administrator with a technical background and want to install and configure Liferay Portal as an enterprise intranet, this is the book for you. In short, reusable recipes help you realize business goals as working features in Liferay. This book will also give you useful hints on how to easily improve the default functionality of the system and its performance.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 344

Veröffentlichungsjahr: 2015

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Liferay 6.x Portal Enterprise Intranets Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Installation and Basic Configuration
Introduction
Quick running Liferay on a Tomcat bundle
Getting ready
How to do it...
How it works...
Loading the configuration descriptor
Loading system properties and portal properties
Detecting the database and database dialect
Starting the autodeploy scanner and deploying plugins
There's more...
See also
The Liferay setup wizard and first login
How to do it…
How it works…
There's more…
See also
Setting up the developer's environment
Getting ready
How to do it...
Import sources to the Eclipse IDE
Override app.server.properties
Compile and deploy
How it works
Clean process
Start process
Deploy process
There's more...
Creating a custom portlet
Getting ready
How to do it…
Generating a new portlet
Compiling the portlet and deploying it
Importing the portlet to the Eclipse IDE
How it works…
See also
2. Authentication and Registration Process
Introduction
Changing the default authentication settings
Getting ready
How to do it…
How it works…
There's more…
See also
Setting up e-mail notifications
Getting ready
How to do it…
How it works…
See also
Customizing the registration form
How to do it…
How it works…
There's more…
See also
Overriding the default login page with the administrator defined page
How to do it…
How it works…
See also
Setting up a password policy
How to do it…
How it works…
Integration with CAS SSO
How to do it…
Installing the CAS system
Configuring the HTTPS connection
Setting the CAS server
Configuring Liferay Portal
How it works…
See also
CAS and the Liferay user's database
Getting ready
How to do it…
How it works…
There's more…
See also
Liferay and the LDAP integration
Getting ready
How to do it…
How it works…
The magic trio: Liferay, CAS, and LDAP
Getting ready
How to do it…
How it works…
See also
3. Working with a Liferay User / User Group / Organization
Introduction
Managing an organization structure
How to do it…
How it works…
Creating an organization
Setting attributes
Customizing an organization functionalities
There's more…
See also
Creating a new user group
How to do it…
How it works…
There's more…
See also
Adding a new user
How to do it…
How it works…
User as a member of organizations, user groups, and sites
User attributes
User site
Customizing users
There's more…
See also
Assigning users to organizations
Getting ready
How to do it…
How it works…
See also
Assigning users to a user group
Getting ready
How to do it…
How it works…
See also
Exporting users
How to do it…
How it works…
See also
4. Liferay Site Configuration
Introduction
Creating an organization and a standalone site
How to do it…
How it works…
Active and inactive sites
Public and private pages and their membership type
Creating an empty site versus creating a site using site templates
Technical view
There's more…
See also
Site configuration
Getting ready
How to do it…
How it works…
See also
Creating and customizing private and public pages for the site
Getting ready
How to do it…
How it works…
Page parameters
Whole-tree parameters
Technical view
There's more…
Using page templates and site templates for quick site and page creation
How to do it…
How it works…
Propagation of changes
Technical view
See also
Enabling local live staging
How to do it…
How it works…
See also
Enabling remote live staging
How to do it…
How it works…
Enabling page versioning
How to do it…
How it works…
See also
5. Roles and Permissions
Introduction
Creating and configuring roles
How to do it…
How it works…
Role parameters
Control Panel, Site Administration, and My Account permissions
There's more…
See also
Assigning user roles
How to do it…
How it works…
See also
Creating a role-dependent portlet
Getting ready…
How to do it…
How it works…
See also
Checking permissions in a custom portlet
Getting ready…
How to do it…
How it works…
See also
6. Documents and Media in Liferay
Introduction
Managing files in Liferay using the Documents and Media portlet
How to do it…
Creating a new folder
Editing a folder
Adding a new document
Uploading multiple documents
Editing documents
Removing folders and documents
How it works…
Types of documents
Permissions
Categories and tags
Related assets
Additional information
There's more…
See also
Managing document types and metadata sets
How to do it…
Creating a new document type using metadata sets
Defining metadata sets
How it works…
See also
Integration with the Amazon S3 cloud
How to do it…
How it works…
There's more…
See also
Data migration between storage hooks
How to do it…
How it works…
See also
7. Working with Content
Introduction
Managing and displaying web contents
How to do it…
Creating a new folder
Editing a folder
Creating a new web content
Displaying web content in the Web Content Display portlet
Editing web content
Adding translation to an existing web content
Expiring web content
Removing folders and web content
How it works…
Permissions
Categorization
Related assets
Placing web content on a page
Display page
See also
Creating a new structure
How to do it…
How it works…
There is more…
Creating a new template
Getting ready…
How to do it…
How it works…
Variables
Fields
Utils
Reserved variables
8. Search and Content Presentation Tools
Introduction
Tagging and categorizing content
How to do it…
How it works…
Categories
Tags
See also
Asset Publisher as a search-based tool for content presentation
Getting ready
How to do it…
How it works…
See also
Defining application display templates for Asset Publisher
How to do it…
How it works…
See also
Search portlet – basic configuration
Getting ready…
How to do it…
How it works…
There's more…
See also
Solr installation and configuration
How to do it…
How it works…
9. Liferay Workflow Capability
Introduction
The Kaleo Web Installation
Getting ready
How to do it...
How it works…
See also
The Single Approver workflow for the user creation process
How to do it…
How it works…
State
Task
Notification
Action
The web content creation and the fork-join workflow
How to do it…
How it works…
The fork element
The join element
There's more…
Join-xor element
See also
Kaleo conditions in a message board example
How to do it…
How it works…
Condition statement
Kaleo timers
How to do it…
How it works…
10. Collaboration Tools
Introduction
Setting up a blog for the intranet
How to do it…
How it works…
See also
Setting up a wiki portlet
How to do it…
How it works…
See also
Setting up a forum for an intranet
How to do it…
How it works…
See also
Banning a user for an inappropriate post
How to do it…
How it works…
See also
Setting up the calendar as a personal tasks management tool
How to do it…
How it works…
Using bookmarks as good container to store favorite links
How to do it…
How it works…
See also
Tracking social activities of site members
How to do it…
How it works…
There's more
Using the announcements portlet for group messaging
How to do it…
How it works…
Announcement management
Portlet configuration
11. Quick Tricks and Advanced Knowledge
Introduction
The language properties hook
How to do it…
How it works…
There's more…
See also
Setting up the portal session time and session policy
How to do it…
How it works…
Configuring Liferay with the SMTP server
How to do it…
How it works…
Intranet protection by the antisamy-hook plugin
How to do it…
How it works…
Migrating content from one database to another database
Getting ready…
How to do it…
How it works…
See also
Using Liferay Service Bus for communication between portlets
How to do it…
How it works…
There's more...
See also
Clustering Liferay Portal
Getting ready…
How to do it…
Check database configuration
Documents and media clustering
Search engine
Cache replication
Multicast
Unicast
How it works…
See also
12. Basic Performance Tuning
Introduction
Scalable infrastructure
How to do it…
Squid cache
Apache web server and software load balancer
Apache Tomcat Application Server
Database server
Solr search engine server
See also
Setting up database access for the master/slave configuration
Getting ready…
How to do it…
How it works…
There's more…
Enabling JS and CSS minification
How to do it…
How it works…
Turning on the CDN host
Getting ready…
How to do it…
How it works...
Disabling unused Liferay features
How to do it…
How it works…
JVM tuning
How to do it…
How it works…
Index

Liferay 6.x Portal Enterprise Intranets Cookbook

Liferay 6.x Portal Enterprise Intranets Cookbook

Copyright © 2015 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 authors, 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: June 2015

Production reference: 1260515

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78216-428-9

www.packtpub.com

Credits

Authors

Piotr Filipowicz

Katarzyna Ziółkowska

Reviewers

Pierpaolo Cira

Zoltán Fiala

Giuseppe Urso

Acquisition Editor

Llewellyn Rozario

Content Development Editor

Merwyn D'souza

Technical Editor

Vijin Boricha

Copy Editors

Relin Hedly

Karuna Narayanan

Project Coordinator

Neha Bhatnagar

Proofreaders

Stephen Copestake

Safis Editing

Indexer

Mariammal Chettiyar

Graphic

Abhinash Sahu

Production Coordinator

Conidon Miranda

Cover Work

Conidon Miranda

About the Authors

Piotr Filipowicz is a Liferay architect and senior developer at eo Networks S.A., Poland. He is an expert in content management systems (CMS). Piotr currently holds the position of team leader in a group involved in developing Liferay-based software. His accomplishments in enhancing and creating various Liferay components are evident from his various successful implementations. His experience and knowledge are supported by certificates such as Liferay Portal Administrator, Sun Certified Web Component Developer for the Java Platform, and Sun Certified Programmer for the Java 2 platform. Piotr is also one of the founders of the www.liferay-guru.com blog, which contains a lot of information on Liferay and the CMS world.

Since 2002, he has created various kinds of IT systems, ranging from desktop applications to CMS applications, supporting large banking and financial systems. His main area of interest is web applications. Piotr uses Java and J2EE technologies on a daily basis, but he is open to learning other technologies and solutions. He holds a master's degree in software systems from Bialystok University of Technology, Poland.

I would like to thank my family for their patience and tolerance during all those hours that I spent in front of my laptop writing this book. Many thanks to my lovely wife, Eliza, for her patience and support towards her always busy husband. This book wouldn't have been possible without her help. I would also like to thank my parents and parents-in-law for their love, understanding, and encouragement.

Last but not least, I sincerely thank all my team members at work for the support and valuable information I got from them. Also, many thanks and appreciation to the entire Packt Publishing team and our reviewers, Giuseppe Urso, Pierpaolo Cira, and Zoltán Fiala, for their constructive criticism and help in enhancing my writing style. It was a great pleasure working with them.

Katarzyna Ziółkowska is employed at eo Networks S.A., Poland, as an IT analyst. She is designated as the head of the analysis section. Her work focuses on government websites and intranets, corporate business applications and websites. Katarzyna is a specialist in content management systems. She has been working with Liferay Portal since 2010 and has designed various products based on this technology using not only its default functionalities, but also expanding them and designing entirely new modules.

Since 2003, her main areas of interest revolved around business process modeling, managing business requirements, understanding user's needs, and designing usable systems. She is also one of the authors who writes on www.liferay-guru.com, where she shares her experience and knowledge on Liferay Portal CMS.

Katarzyna is certified in Prince 2 Foundation, Agile Project Management Foundation, and is a Professional Scrum Master. She is also a member of International Institute of Business Analysis. She holds a master's degree in arts in Russian philology from the University of Warsaw, Faculty of Applied Linguistics, Poland.

I would like to thank Krzyś for his unwavering support and understanding. I would also like to thank Szymon Gołębiewski; he is the reason my adventure with Liferay began.

About the Reviewers

Pierpaolo Cira is a Liferay Certified Professional Developer and has been working as a software developer, software architect, and system integrator since 2001.

He has been involved in many e-business, knowledge management, e-learning e-tourism, brand monitoring, and business intelligence research projects at the University of Salento in collaboration with companies such as Oracle and IBM on several research projects. He also collaborated on the design and development of the first implementation of the OMG SBVR editing tool. He reviewed Android Apps with Eclipse, O. Cinar, Apress 2012. He has been working on several enterprise web applications based on Liferay Portal and Alfresco ECM, such as web portals, intranets, and document management systems, for public administrations and big companies.

Currently, he is a consultant on Liferay Portal and Big Data technologies and solutions.

He can be found on Twitter at @pierpaci.

I would like to thank my family and my wife for their support and patience.

Zoltán Fiala leads a competence center for software development at adesso AG in Hamburg, Germany. He holds a PhD in web engineering from Dresden University of Technology and has worked as a SharePoint and Liferay architect and project manager for several IT consultancy firms in the past. Zoltán has significant experience in the design and development of web content management and portal solutions. For more information on Zoltán, refer to http://www.z-fiala.net.

Giuseppe Urso is a software engineer with 10 years of extensive working experience in the design and agile development of service-oriented applications and distributed systems based on Java SE and Java EE. He works in the IT industry as a senior systems architect and Java developer, handling responsibilities involving architecture design and the implementation of several large-scale projects based on Alfresco ECM and Liferay Portal. His major areas of expertise include Amazon Web Services (AWS), Elastic Compute Cloud (EC2) technologies, and Message-oriented Middleware. Giuseppe earned his master's degree in computer engineering at the University of Salento, Italy. He is a licensed engineer and member of the Professional Engineers Association called "Ordine degli Ingegneri della Provincia di Lecce". He is an Alfresco certified administrator and committer on the Alfresco-SDK project. As an open source enthusiast, he runs a personal blog at www.giuseppeurso.eu, where he writes articles and useful guidelines on Java, Alfresco, Liferay, and practices of GNU/Linux systems administration.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

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.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

Liferay Portal is one of the most popular portal frameworks on the market, offering many out-of-the-box features to build, install, configure, and customize portal or intranet solutions. The main purpose of this book is to help you successfully build the intranet system by providing step-by-step recipes. You will be taken on a tour that covers the most common issues when dealing with Liferay. In every recipe, you will find solutions to real-life problems with many explanations. The chapters are organized and ordered in such a way that they will help you go through the intranet configuration step by step.

What this book covers

Chapter 1, Installation and Basic Configuration, provides you with a basic knowledge on how to install and run Liferay on Apache Tomcat. It also teaches you how to create a new basic portlet.

Chapter 2, Authentication and Registration Process, describes several useful ways to correctly configure authentication. It helps you learn about integration with a popular single sign-on mechanism: CAS and communicate it with LDAP.

Chapter 3, Working with a Liferay User / User Group / Organization, introduces you to the concept of user, user group, and organization management in Liferay. It also explains how to use them together.

Chapter 4, Liferay Site Configuration, offers many useful recipes connected with site configuration, such as creating sites, their templates, and enabling staging and versioning.

Chapter 5, Roles and Permissions, discusses roles and permissions and the possibility to build a scalable grid of roles depending on the user's position in the company.

Chapter 6, Documents and Media in Liferay, introduces you to portlet, which provides media and document file storage. This chapter also offers you advice on how to correctly configure it. You will also learn how to integrate documents and media portlet with Amazon S3 storage.

Chapter 7, Working with Content, talks about the most common CMS feature, that is, web content management.

Chapter 8, Search and Content Presentation Tools, introduces various functionalities connected with the searching and content presentation tool. This chapter also talks about tagging and categorizing assets.

Chapter 9, Liferay Workflow Capability, teaches you how to apply workflow on assets and deploy the Kaleo Web portlet.

Chapter 10, Collaboration Tools, provides recipes in collaboration with Wiki, blogs, message boards, calendars, and so on.

Chapter 11, Quick Tricks and Advanced Knowledge, contains a set of various recipes, which help you to perform specific tasks for your intranet sites. There are many subjects, for example, enabling SMTP, configuring clustered environment, or using the Liferay service bus.

Chapter 12, Basic Performance Tuning, offers information on scalable infrastructure and discusses most common problems associated with performance.

What you need for this book

This book uses Liferay Portal version 6.2 with the following settings:

MySQL database 5.5Java JRE and JDK 7Apache Ant with 1.7 version or laterApache Maven 3.0.5 or laterLiferay Portal 6.2 bundled with Tomcat 7Eclipse IDE Indigo or later

All recipes are based on the Linux operating system, but all of them can be done (with only a little effort) on Windows or iOS.

Who this book is for

If you are a Java developer or administrator with a technical background and want to install and configure Liferay Portal as an enterprise intranet, this is the book for you. In short, reusable recipes help you realize business goals as working features in Liferay. This book will also give you useful hints on how to easily improve the default functionality of the system and its performance.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

<div>$curEntry.getTitle($locale)</div> <div>$curEntry.getDescription($locale)</div> <div> $taglibLiferay.assetTagsSummary( $curEntry.getClassName(), $curEntry.getClassPK(), null, null, $renderResponse.createRenderURL() ) </div>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

</timer-notification> <reassignments> <user> <email-address> [email protected] </email-address> </user> </reassignments> </timer-actions>

Any command-line input or output is written as follows:

$ java -versionjava version "1.7.0_45"Java(TM) SE Runtime Environment (build 1.7.0_45-b18)Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode).

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Control Panel link."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

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 at www.packtpub.com/authors.

Customer support

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.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

Errata

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 could 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/submit-errata, selecting your book, clicking on the ErrataSubmissionForm link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Installation and Basic Configuration

In this chapter, we will cover the following topics:

Quick running Liferay on a Tomcat bundleThe Liferay setup wizard and first loginSetting up the developer's environmentCreating a custom portlet

Introduction

Liferay is the market's leading provider of open source portal solutions. It provides a solid platform to serve our site to all clients. It is difficult to say what Liferay is. On the one hand, Liferay is a great content-management system, but on the other hand, it provides many tools for collaboration and communication between users. It can also be a social platform with many functionalities, such as wall, message board, chat, and many others. Furthermore, it is a portlet container that is JSR-168 and JSR-286 compliant. Java Specification Requests (JSRs) describes final specifications for the Java platform. A portlet is a small web application that produces fragments of HTML code that are aggregated into a portal. JSR-168 and JSR-286 specifications standardize how portlets interact with portlet containers. These specifications also describe a standard application programming interface for Java portlet development. In other words, Liferay is only responsible for aggregating the set of portlets that are to appear on any particular page. This approach gives users a great tool to organize and customize portlets in order to build whole portals, social platforms, or intranets. Within Liferay, a portal is composed of a number of portlets, which are self-contained interactive elements that are written to a particular standard. A number of publications describe Liferay's advantages. In this book, we will try to delve deeper into Liferay's architecture and its functionalities.

The primary purpose of this chapter is to give you an insight about Liferay's installation and management with basic configuration. We realize that there are many ways to download, compile, install, and run Liferay Portal. Our main purpose is to provide some clear and basic information about the starting package on which we will rely and work. This chapter explains the main processes that are performed on every compiling action or on every startup action.

Liferay Portal is distributed in two different editions:

Liferay Portal Community Edition (CE): This is a free and open source version of LiferayLiferay Portal Enterprise Edition (EE): This is a commercial offering that has Liferay engineers, support, and services

This book is based on the Liferay Portal Community Edition (CE) version with the newest release, which is 6.2.

To start the journey with Liferay, there are a few starting points that contain a lot of useful information, which are as follows:

URL

Description

http://www.liferay.com/

Official Liferay site

http://www.liferay.com/downloads/liferay-portal/available-releases

Place with available releases

http://www.liferay.com/documentation/liferay-portal/6.2/user-guide and https://dev.liferay.com/

User guides and documentation

http://svn.liferay.com/repos/public/portal

Old-fashion repository of Liferay code.

Login: Enter guest in this fieldPassword: This field is to be left empty

https://github.com/liferay/liferay-portal/tree/6.2.x

[Recommended] GitHub repository

Tip

Liferay introduced 7.0 version, which will be released on September 2015. Do not check out Liferay sources from the trunk. There are many changes between 6.2 and the trunk version. In the 7.0 version, Liferay will provide OSGi integration and many new features. These new features help users and developers achieve a whole bunch of out-of-the-box functionalities (for instance, Elasticsearch as a search server based on the Lucene framework).

Quick running Liferay on a Tomcat bundle

The simplest way to run Liferay is to download a specific bundle from the Liferay official site. A Liferay bundle is just a compressed archive that contains all that is needed to host the Liferay Portal. A bundle consists of a Java-based application server and the deployed Liferay Portal core application. Liferay provides these bundle runtimes with different application servers (that is, Tomcat, JBoss, Geronimo, and so on) so that you can use any one based on your choice. This method is recommended for people who just want to run Liferay Portal, look at its functionalities, and configure their site using the GUI. In this recipe, you will learn the art of setting up Liferay on Tomcat and the MySQL database engine.

Getting ready

First, make sure that JRE or JDK is properly installed. Type the following command line:

$ java -version

The result should be similar to this:

$ java -versionjava version "1.7.0_45"Java(TM) SE Runtime Environment (build 1.7.0_45-b18)Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode).

Also, check out the Java SDK version. Liferay recommends Java 7 or later.

Moreover, determine whether the MySQL server installation is done:

$ mysql --version

As a result, the actual installed version should be displayed. Here is an example:

mysql Ver 14.14 Distrib 5.5.34, for debian-linux-gnu (x86_64)

Also, check out the MySQL version. We recommend 5.5 version or later.

How to do it...

In order to run Liferay on a Tomcat bundle, follow these steps:

Create a database with the name lportal:
CREATE DATABASE lportal CHARACTER SET utf8 COLLATE utf8_general_ci; grant all privileges on lportal.* to '{USERNAME}'@'%' identified by 'PASSWORD';

Make sure that the MySQL user has permissions to create tables.

Download the correct Liferay version on the Tomcat bundle from http://www.liferay.com/downloads/liferay-portal/available-releases.Unzip the downloaded archive.Go to the extracted folder liferay-portal-6.2-ce-ga2. This path will be called ${liferay.home} folder.Go to the ${liferay.home} folder and create a file called portal-ext.properties.Edit portal-ext.properties and set the database properties:
jdbc.default.driverClassName=com.mysql.jdbc.Driver jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false jdbc.default.username={USERNAME} jdbc.default.password={PASSWORD}
Find the Tomcat folder and go to the tomcat-7.0.42/bin/ location.Run the ./startup.sh script (startup.bat for Windows OS) and look into the tomcat-7.0.42/logs/catalina.out log.In a browser, type http://localhost:8080 location. By default, Tomcat listens on port 8080. It should render the Liferay setup wizard by default. This wizard will ask for basic information, such as, portal name, default language, and administrator user details.

How it works...

Running the Liferay Portal from a prepared bundle is quite an easy task to accomplish. However, it is worth knowing what exactly happens when Tomcat is being started. Take a brief look at the catalina.out log and try to examine it line by line.

Loading the configuration descriptor

The first thing is to deploy ROOT.xml. In our catalina.out file, there is a line present, which is shown as follows:

INFO: Deploying configuration descriptor /home/piotr/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/conf/Catalina/localhost/ROOT.xml

It means that the configuration file turns on the crossContext attribute in Tomcat 7. This setting is required because Liferay is a portlet container. Hence, it is an application that should have access to other applications called portlets. The Apache Tomcat documentation says:

"Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host."

Loading system properties and portal properties

The next few lines of the logfile show portal properties and system properties that are loaded from specific locations:

Loading jar:file:/home/piotr/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties Loading jar:file:/home/piotr/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties Loading jar:file:/home/piotr/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties Loading file:/home/piotr/liferay-portal-6.2-ce-ga2/portal-ext.properties

The main configuration file for Liferay Portal is portal.properties, which contains a detailed explanation about the properties that it defines. There are at least three possible ways to override portal.properties. There is a functionality to put portal-ext.properties in the ext plugin, in the ${liferay.home} directory, or in portal-setup-wizard.properties. But which file is the most important? The answer is placed in portal.properties file. The default read order is portal.properties, portal-bundle.properties, portal-ext.properties, and then portal-setup-wizard.properties:

include-and-override=portal-bundle.properties include-and-override=${liferay.home}/portal-bundle.properties include-and-override=portal-ext.properties include-and-override=${liferay.home}/portal-ext.properties include-and-override=portal-setup-wizard.properties include-and-override=${liferay.home}/portal-setup-wizard.properties

Detecting the database and database dialect

The next step is to recognize the database's dialect:

12:35:47,469 INFO [localhost-startStop-1][DialectDetector:71] Determine dialect for MySQL 5 12:35:47,504 INFO [localhost-startStop-1][DialectDetector:136] Found dialect org.hibernate.dialect.MySQLDialect

Liferay supports many database engines, such as DB2, Derby, Hypersonic, Ingres, MySQL, Oracle, P6Spy, PostgreSQL, and Sybase. The default database is Hypersonic, which stores all data in the ${liferay.home}/data/hsql/lportal directory. This is a good option for developers who want to run JUnit tests, which modify data by testing the persistence layer or business process.

On every restart, Liferay tries to get the build number (Liferay version) from the Release_ table. If this table doesn't exist, it calls ReleaseLocalService.createTablesAndPopulate().

If it is not possible to get the build number, Liferay logs the following information:

WARN [localhost-startStop-1][ReleaseLocalServiceImpl:171] Table 'lportal.Release_' doesn't exist

The createTablesAndPopulate method runs following scripts:

liferay-portal/sql/portal-tables.sql: This creates the required tablesliferay-portal/sql/portal-data-common.sql: This adds the default dataliferay-portal/sql/portal-data-counter.sql: This inits the unique key generatorliferay-portal/sql/portal-data-release.sql: This sets the release dateliferay-portal/sql/indexes.sql: This adds database indexesliferay-portal/sql/sequences.sql: By default, this file is empty.

Apart from creating tables and populating data, Liferay triggers the VerifyProcess mechanism. This process will run on every startup to verify and fix any integrity problems found in the database. This is the perfect place for developers to add custom code to check the integrity of specific cases.

Starting the autodeploy scanner and deploying plugins

The last step is initializing the autodeploy and the hotdeploy listeners. In general, these mechanisms install all the plugins into the Tomcat container and register them as portlets, hooks, themes, and so on. In particular, there are at least three deploying approaches: sandbox deploy, autodeploy, and hotdeploy.

Note

By default, Liferay uses the autodeploy and hotdeploy listeners. In fact, sandbox can currently deploy only themes and portlets.

The autodeploy mechanism is responsible for listening on a specific directory to install on-the-fly new plugins and copying them into the Tomcat hotdeploy process. A definition of that directory is placed in portal.properties, and by default, it is in the deploy folder:

auto.deploy.deploy.dir=${liferay.home}/deploy

Every type of plugin has its own autodeploy mechanism. This mechanism runs all the necessary steps to install it correctly in the Liferay container. In simple terms, the autodeploy mechanism generates the web.xml file and adds the required libraries to specific plugins. Definitions of these classes are placed in the portal.properties file with an auto.deploy.* prefix. Each class extends BaseAutoDeployListener.

The second process, hotdeploy, is responsible for registering plugins in Liferay. There are many steps, such as creating database tables, setting preferences, registering Spring application contexts, and so on. Of course, each step depends on the type of plugin. In portal.properties, there are definitions for each type of class:

hot.deploy.listeners= com.liferay.portal.deploy.hot.PluginPackageHotDeployListener, com.liferay.portal.deploy.hot.SpringHotDeployListener, com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener, com.liferay.portal.deploy.hot.ExtHotDeployListener, com.liferay.portal.deploy.hot.HookHotDeployListener, com.liferay.portal.deploy.hot.JSONWebServiceHotDeployListener, com.liferay.portal.deploy.hot.LayoutTemplateHotDeployListener, com.liferay.portal.deploy.hot.PortletHotDeployListener, com.liferay.portal.deploy.hot.SocialHotDeployListener, com.liferay.portal.deploy.hot.ThemeHotDeployListener, com.liferay.portal.deploy.hot.ThemeLoaderHotDeployListener, com.liferay.portal.deploy.hot.MessagingHotDeployListener

Tip

In the deployment process, the Liferay deployer modifies the web.xml file, adds specific dependencies, and packs it again. Ensure that you do not copy the WAR file directly to the Tomcat webapps folder. If you do so, the plugin will not work.

There's more...

Often, enterprises have an established Java EE infrastructure upon which they would like to install Liferay. You must consider also the enterprise's security policies. These policies sometimes prevent the download and installation of the Tomcat bundle into a location of your choice. In this situation, a bundle will not suffice, and you have to manually install Liferay from its WAR archive into an already existing Apache Tomcat application server.

There are six steps to achieve this goal. They are as follows:

Copy specific JAR files and dependencies to the Tomcat global lib folder, $TOMCAT_HOME/lib/ext.Enable crossContext by adding the ROOT.xml file to the $TOMCAT_HOME/conf/Catalina/localhost folder.Set custom $JAVA_OPTS parameters in the $TOMCAT_HOME/bin/setenv.sh file:
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"
Update the common.loader property located in $TOMCAT_HOME/conf/catalina.properties with the following lines of code:
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/ext,${catalina.home}/lib/ext/*.jar
Specify the URI encoding as UTF-8 in $TOMCAT_HOME/conf/server.xml as follows:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
Deploy Liferay Portal using Tomcat manager or manually put the WAR archive into the $TOMCAT_HOME/webapps folder. The WAR file is available at http://www.liferay.com/downloads/liferay-portal/available-releases#additional-versions.

Note

More detailed instructions of how to install Liferay on the Tomcat server are available on the official Liferay documentation at https://www.liferay.com/documentation/liferay-portal/6.2/user-guide/-/ai/installing-liferay-on-tomcat-3.

See also

For information about running Liferay on the clustered environment, refer to the Clustering Liferay Portal recipe in Chapter 11, Quick Tricks and Advanced Knowledge, and the Scalable infrastructure recipe in Chapter 12, Basic Performance Tuning. For information about setting the developer's environment, refer to the next recipe.

The Liferay setup wizard and first login

After successfully running Liferay on the Apache Tomcat server, the system asks users to fill some necessary information to complete the setup wizard. This is only a single screen with basic fields, such as administrator name or portal name.

How to do it…

After running Liferay for the first time, the Liferay platform displays the basic configuration form, which looks like this:

To finish installation, it is necessary to fill in the preceding form as follows:

Provide details about Portal:
Portal Name: This is the name of the website, for instance, Enterprise IntranetsDefault Language: This helps in choosing the default language of the portalAdd Sample Date: This decides to populate the portal with default data
Provide details about Administrator User:
First Name and Last NameE-mail address
Choose the database engine (optional). In the previous recipe, we set properties with a MySql connection.Confirm the form.Click on the Go to My Portal button.Click on the I agree button on the Terms of Use screen.Fill in the Password Reminder form and confirm the form.

After confirming the Password Reminder form, you will be able to see and use the main Liferay navigation tools.

Follow these steps to navigate to Control Panel:

Click on the Admin button located on the dockbar menu.Click on the Control Panel link.

How it works…

After running Liferay for the first time, Liferay needs basic information about the portal, database, and administrator. The database connection was set in portal-ext.properties, and it was described in the previous recipe.

All data which was provided on the portal wizard was stored in the ${liferay.home}/portal-setup-wizard.properties file. The most important settings are described in the following table:

Property name

Description

admin.email.from.name

This describes the name of the administrator.

admin.email.from.address

This is the e-mail address of the administrator.

liferay.home

This is the path to the ${liferay.home} directory. This property is very important and must be set.

setup.wizard.enabled

This flag disables the setup wizard.

After logging in, the user is able to see navigation tools available for authorized users only. Here are the navigation tools:

The dockbar menu is located under the top screen edge. The dockbar consist of three buttons:
The Admin button that allows us to navigate to the Site Administration and Control Panel sectionsThe My Sites button that lists links to sites that the user is a member ofThe button with user name and surname that allows us to navigate to user's profile (My Profile), user's dashboard (My Dashboard), user's account (My Account), and also allows the user to log out
The fast edition menu is located near the left edge of the screen. The menu consists of the following icons:
The Add icon that allows us to add a new page, a new application to the page, or new contentThe Edit icon that allows us to edit the settings of the currently viewed pageThe Preview icon that allows us to view the currently viewed page in different resolutions and devicesThe Edit Controls icon that allows us to hide or show controls of portlets

There's more…

In internal projects such as intranets, user accounts most often are created and managed in external systems, for instance, LDAP. Therefore, it is unnecessary (and sometimes even unacceptable) to allow users to manage their authentication data (for instance, to set a password-reminder query) or ask them to agree to terms of use directly within Liferay. In Liferay, there are many properties that can help customize the first login action, a few of which are as follows:

Property name

Description

terms.of.use.required=false

This turns off the terms of use

terms.of.use.journal.article.group.id and terms.of.use.journal.article.id

This specifies the group ID and article ID that will be displayed as the terms of use

users.reminder.queries.enabled=false

This disables the reminder query functionality

See also

For