class="bi x0 y0 w0 h1"
Liferay
Beginner's Guide
Quick and easy techniques to build, deploy, and maintain
your own Liferay Portal
Robert Chen
Gaurav Barot
Samir Bha
Sandeep Nair
Mahipalsinh Rana
BIRMINGHAM - MUMBAI
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >
Liferay
Beginner's Guide
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmied in any form or by any means, without the prior wrien permission of the
publisher, except in the case of brief quotaons embedded in crical arcles or reviews.
Every eort has been made in the preparaon of this book to ensure the accuracy of the
informaon presented. However, the informaon 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 informaon about all of the
companies and products menoned in this book by the appropriate use of capitals. However,
Packt Publishing cannot guarantee the accuracy of this informaon.
First published: December 2011
Producon Reference: 1241111
Published by Packt Publishing Ltd.
Livery Place
Aaron Nash
Indexer
Monica Ajmera Mehta
Graphics
Valenna D'silva
Conidon Miranda
Producon Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade
About the Authors
Robert Chen is an Architect for Liferay Portal projects. He was a computer game developer
and a soware tesng engineer. He holds an MS degree in Computer Science from California
State University, San Bernardino. His focus was on online banking applicaons. He also has
a bachelor's degree from Wuhan University, China. Mr. Chen was a QA engineer at VMware,
Inc. He later led a team in developing four educaonal computer games for a Florida school
district. He worked on Geographical Informaon Systems (GIS). Mr. Chen has rich experience
in J2EE technologies. He has extensive experience in Content Management Systems (CMS)
including Alfreso. He is an expert in web portal technologies. Mr. Chen has hands-on
experience in 10 Liferay Portal projects.
I would sincerely thank Sarah Cullington (Acquision Editor), Zainab
Bagasrawala (Project Coordinator), Shreerang Deshpande (Development
Editor) at Packt Publishing. Thank you for reviewing my chapters. I
appreciate your invaluable advice – it has helped me improve the quality of
my wring. Thanks also go to Eleanor Duy, Lata Basantani, and the team
at Packt Publishing. It has been a happy experience working together
with you!
I would also thank Dr. Munwar Shari and Dr. Jonas X. Yuan for their
support and encouragement along the way.
encouraging me to write this book.
I appreciate the whole Packt Publishing team for providing connuous
support throughout this project.
Lastly, I want to thank my parents for their encouragement. I specially
thank my wife Hetal and my lile daughter Shreeya for their support
and love.
Sandeep Nair has been working on Liferay for more than two years and has overall
more than ve years of experience in Java and Java EE technologies. He has executed
projects using Liferay in various domains such as Construcon, Financial, and Medical elds
providing soluons such as Collaboraon, Enterprise Content Management, Web Content
Management systems. He has created a free and open source Google Chartlet plugin
for Liferay which has been downloaded and used by people across 90 countries as per
Sourceforge stascs. Besides development, consulng, and implemenng soluons, he has
also been involved in giving trainings in Liferay in other countries. Before he jumped into
Liferay, he has had experience in Java and Java EE plaorms and had worked in EJB, Spring,
Struts, Hibernate, Servicemix. He also has experience in using JierBit, which is an ETL tool.
When he is not coding, he loves to read books and write blogs.
I would like to thank Munwar Shari and Manish Sheladia who trusted in
me and thought me worthy enough to write this book. I would like to thank
Robert Chen for being so supporve from the beginning of the book and
leading the team that too very eciently. I would also like to thank rest
of the co-authors Samir Bha, Mahipalsinh Rana, and Gaurav Barot, who
were there to review and discuss each other's work and make sure we give
quality book to the readers. I am also very grateful to Zainab Bagasrawala,
who took the pains to co-ordinate the chapters and making sure we
deliver the chapter in me, Sarah Cullington and Shreerang Deshpande
for reviewing my work and giving right advice as to what should or should
not be there in the book. Last but not the least, I would like to thank my
enterprise soware soluons. Albert has studied Informaon Technology Engineering and
has a Master in Economic and Financial Management of companies.
Albert is currently working as a freelance soware developer, trainer, and consultant for
internaonal customers. Albert is an open source soware contributor and has released
dierent applicaons for Liferay and Android.
Albert lives in Girona(Spain) and maintains a blog at
.
Aritz Galdos Otermin studied Computer Engineering at UPV / EHU (Euskal Herriko
Unibertsitatea) and Coventry University. Aritz has been working as programmer and soware
architect since 2005 and has specialized in portal development and deployment.
He is especially interested in open source and enjoys developing portlets and integraon
tools for Liferay with other open source projects, such as video conferencing tools and
Android mobile plaorms. He releases his developments in his personal projects page
.
I want to thank every single person that has ever contributed to open
source in any way.
Jordi Carbonell i Soler aer more than eight years working with JEE technologies is
currently a JEE Architect specialized in portal environments. His relaon with Liferay started
in 2007. Since then, he's been working on many Liferay-based portals along all of those
projects' stages: from presales and conceptualizaon to development and installaon;
usually, integrang them with a wide range of third-party tools, such as Alfresco ECM,
Atlassian products, or BPM Engines. Currently, he's working at IN2, one of the rst Spanish IT
companies who bet on Liferay and Alfresco as trending technologies.
www.PacktPub.com
Support les, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support les and downloads related to your book.
Did you know that Packt oers eBook versions of every book published, with PDF and ePub les available?
You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are
entled to a discount on the eBook copy. Get in touch with us at for more
details.
Horizontal vs. vercal portals 10
Time for acon – comparing Yahoo! and YouTube 10
Open source vs. commercial portals 12
Time for acon – nding the source code of Liferay Portal 12
Liferay Portal architecture 14
Web service provider 14
Liferay is exible 15
Liferay is standard compliant 15
Main Liferay Portal features 16
Theme and layout 16
Communies and organizaons 16
Content Management System and Web Content Management 16
Time for acon – watching Liferay Portal portlets in acon 17
Preparaon for Liferay Portal installaon 18
Hardware requirements 18
Time for acon – nding RAM informaon 19
Soware requirements 19
Operang systems 20
Java Development Kit 20
Time for acon – installing JDK 20
Applicaon servers and servlet containers 22
Database servers 23
Time for acon – installing MySQL database server 24
Web browser 26
Table of Contents
[ ii ]
Installing OpenOce 27
Time for acon – installing OpenOce 27
Time for acon – starng OpenOce service 29
Time for acon – checking the OpenOce service 29
Geng an overview of Liferay Portal Architecture 79
Understanding the Liferay building blocks 79
User 81
User group 82
Role 82
Community 83
Organizaon 84
Table of Contents
[ iii ]
Teams 85
Basics of the Control Panel 87
Vising the Control Panel 87
Time for acon – creang a new user 91
Changing Portal's look and feel with themes 93
Time for acon – installing a new theme and applying it to the portal 94
Summary 96
Chapter 4: Tips and Tricks-Advanced Conguraon 97
Renaming our portal 98
Time for acon – changing our portal name 98
SSO with OpenID 99
Time for acon – using OpenID for authencaon 100
Ask users to accept terms before accessing Liferay 102
Time for acon – enabling Terms of Use 103
Time for acon – changing Terms of Use 104
E-mail nocaons 107
Time for acon – enable nocaon for account creaon 107
Adding custom aributes for User 109
Time for acon – giving the opon to add a user's favorite sport 109
OpenOce integraon 112
Time for acon – enabling OpenOce integraon 112
Time for acon – understanding the acons associated with the group 144
User group and page templates 145
Time for acon – creang a page template for the Bowlers user group 145
Summary 149
Chapter 6: Managing Pages, Users, and Permissions 151
Checklist 152
Creang pages for the Neighborhood site 152
Creang pages for Neighborhood communies 153
Time for acon – creang pages for Neighborhood communies 153
Seng page-level aributes to dene page characteriscs 158
Time for acon – providing a HTML tle and friendly URL for a page 159
Exploring the User secon 162
Conguraon for user pages' default porltets 162
Creang an administrator user to manage the Neighborhood site 163
Time for acon – creang a user and assigning an administrator role 163
Eding the user prole 168
Time for acon – modifying user details 168
Assigning users to Neighborhood communies and organizaons 171
Time for acon – assigning a user to communies and organizaons 171
Disabling the opon to register for the site for guest users 174
Time for acon – disabling the Register opon for a guest user 175
Exploring role/permission management in Liferay 176
Creang a role to manage pages of the Neighborhood site 177
Time for acon – creang a role to manage pages 178
Portal scoped roles 181
Community/Organizaon roles 182
Assigning users to community/organizaon administrator role 183
Time for acon – assigning community/organizaon 183
Administrator role 183
More on permissions 187
Time for acon – uploading a video le 214
Time for acon – uploading a PDF le 215
Showing a PDF le link in web content 217
Time for acon – embedding a link for a PDF le 217
Enabling comments for web content 219
Time for acon – enabling comments for content 219
Disclosing decrypted Congress documents 221
Time for acon – displaying documents 221
Managing content 222
Reviewing web content 222
Time for acon – using the web content list portlet 223
Monitoring other content 224
Table of Contents
[ vi ]
Time for acon – adding the asset publisher portlet 225
Converng web content to formaed les 226
Time for acon – adding a le conversion feature 226
Summary 228
Chapter 8: Exploring Communies 229
Prerequisite 230
Seng up an online game using Flash Portlet 230
Time for acon – seng up an online game using Flash Portlet 230
Adding Web Content Display to announce a cricket match 233
Time for acon – announcing a cricket match 234
Using Video Portlet to share Neighborhood videos 236
Time for acon – sharing Neighborhood videos 236
Sharing Neighborhood photos using Image Gallery 239
Time for acon – sharing Neighborhood photos 239
Exploring chat funconality to enable chat between Neighborhood members 243
Time for acon – exploring chat funconality 243
What about payment with credit cards? 276
Shipping cost conguraon 276
Time for acon – conguring the shipping cost 277
Percentage formula for shipping cost calculaon 278
Insurance cost conguraon 278
Time for acon – conguring the insurance cost 278
E-mail conguraon 279
Time for acon – conguring the e-mail templates 280
Shopping items 283
Item categories 283
Time for acon – item category creaon 283
Changing the Parent Category 285
Shopping items 286
Time for acon – item creaon 286
Basic aributes 290
Fields secon aributes 290
Prices secon aributes 291
Images secon aributes 292
Shopping cart 295
Let's do shopping 295
Time for acon – adding items to the shopping cart 295
Item lisng view (category lisng view) 297
Item details view 298
Checkout process 302
Time for acon – making a payment 302
Address details 306
Order conrmaon 306
Order management 308
Time for acon – processing the order 308
Order lisng 309
Implemenng the staging environment 340
Time for acon – conguring staging environments 340
Staging conguraon 344
Publish to Live Now 346
Scheduled publicaon 346
Time for acon – scheduling publicaon of portal changes 347
Summary 350
Appendix A: PayPal Test Account Conguraon 351
Appendix B: Pop Quiz Answers 355
Index 361
Preface
Liferay Portal is a leading horizontal portal product, wrien in Java. It has the power to
provide the Intranets and Extranets of large corporaons. Liferay will allow you to build
your company's portal quickly, eciently, and in a custom way to suit the needs of
your corporaon.
Liferay Beginner's Guide will show you how to set up your own site from scratch. Most
books assume that you have knowledge of portals before working with Liferay and so include
more theory than pracce. However, only enthusiasm is required for reading this book as
the step-by-step instrucons, which follow the creaon of a sample community site, will
make it easy to install and congure Liferay, set up a Liferay Portal instance, and use the
out-of-the-box portlets of Liferay.
By following the logical ow of the chapters and the creaon of the sample site, you will
set up your Liferay site in several quick and easy stages. You will start by installing Liferay in
your applicaon server or servlet container of choice. You will learn how to customize the
look-and-feel of the portal, change the URL of the site, and create your own communies
and organizaons within the portal, then add users to them. By the end of the book, you will
have a fully operaonal Liferay Portal and the condence to maintain and customize it to
meet your needs.
What this book covers
Chapter 1, Planning Your Portal, gives an overview of Liferay Portal– the most popular open
Bookmark, Chat, OpensSocial, Language, Polls, Search. It also covers some of the custom
portlets such as YouTube, SlideShow.
Chapter 9, Seng up an Online Shop, talks about how to set up online shop using the
shopping portlet. It instructs reader on how to congure payment terms, shopping items,
stock, and so on. It also instructs reader on how to manage orders and discounts. It also talks
about end-to-end shopping workow.
Chapter 10, Liferay Server Administraon, instructs reader on how to user liferay's server
administraon features to maintain Liferay Portal server. It talks about server resource
management, logging conguraon, virtual host conguraon, and so on. It also talks
about how to congure staging environment.
Appendix A, PayPal Test Account Conguraon, provides step-by-step guide to set up test
accounts on PayPal’s sandbox environment.