Liferay Portal
A Complete Guide
THE LllERAY DOCUMENTATlON TEAM
Rich Sezov, Ji.
Jim Hinkey
Stephen Kostas
Jesse Rao
Cody Hoag
Lifeiay Piess
Using Lifeiay Poital .1
by Te Lifeiay Documentation Team
Copyiight 2013 by Lifeiay, lnc.
Put lSBN Numbei Heie if this is a published woik
Tis woik is oeied undei the following license
Cieative Commons Auiibution-Shaie Alike Unpoited
You aie fiee
1. to shaieto copy, distiibute, and tiansmit the woik
2. to iemixto adapt the woik
Undei the following conditions
1. Auiibution. You must auiibute the woik in the mannei specied by the
authoi oi licensoi (but not in any way that suggests that they endoise you
oi youi use of the woik).
2. Shaie Alike. lf you altei, tiansfoim, oi build upon this woik, you may dis-
tiibute the iesulting woik only undei the same, similai oi a compatible li-
cense.
Te full veision of this license is heie
hup//cieativecommons.oig/licenses/by-sa/3.0
CoN1rN1s
Contents i
Preface vi
Whats New in the lifh Edition . . . . . . . . . . . . . . . . . . . . . vi
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Publishei Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1 What is Liferay? 1
1.1 What makes Lifeiay Poital unique . . . . . . . . . . . . . . . . 3
1.2 Using Lifeiay Poital as a content management system . . . . . 3
1.3 Using Lifeiay Poital as a collaboiative platfoim . . . . . . . . . 9
1.4 Using Lifeiay as a social platfoim . . . . . . . . . . . . . . . . 11
1. Using Lifeiay as a web platfoim . . . . . . . . . . . . . . . . . 13
1. Extending and customizing Lifeiay foi youi own needs . . . . 1
1. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Web Content Management 17
2.1 How Can Lifeiays WCM Help You` . . . . . . . . . . . . . . . 18
2.2 Cieating sites and managing pages . . . . . . . . . . . . . . . 19
2.3 Authoiing (basic) content . . . . . . . . . . . . . . . . . . . . . 38
2.4 Publishing (basic) content . . . . . . . . . . . . . . . . . . . . 4
i
2. Using Lifeiays woikow with WCM . . . . . . . . . . . . . . 48
2. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Advanced Web Content Management 52
3.1 Advanced content with stiuctuies and templates . . . . . . . . 3
3.2 Leveiaging Lifeiays multi-site capabilities . . . . . . . . . . . 4
3.3 Using site templates . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Using page templates . . . . . . . . . . . . . . . . . . . . . . . 3
3. Allowing useis to customize site pages . . . . . . . . . . . . . 80
3. Staging page publication . . . . . . . . . . . . . . . . . . . . . 81
3. Cieating teams foi advanced site membeiship management . . 89
3.8 Displaying site pages to mobile devices . . . . . . . . . . . . . 91
3.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4 Document Management 100
4.1 Geuing Staited with Documents and Media . . . . . . . . . . . 101
4.2 Document Types and Metadata Sets . . . . . . . . . . . . . . . 10
4.3 Using Exteinal Repositoiies . . . . . . . . . . . . . . . . . . . 109
4.4 Miciosof Oce integiation . . . . . . . . . . . . . . . . . . . 11
4. Conguiing the Documents and Media poitlet . . . . . . . . . 11
4. Automatic Pieviews and metadata . . . . . . . . . . . . . . . . 119
4. Lifeiay Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.8 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5 Leveraging the Asset Framework 149
.1 Tagging and Categoiizing Content . . . . . . . . . . . . . . . . 10
.2 Taigeted Vocabulaiies . . . . . . . . . . . . . . . . . . . . . . 13
.3 Using laceted Seaich . . . . . . . . . . . . . . . . . . . . . . . 1
.4 Using the Asset Publishei . . . . . . . . . . . . . . . . . . . . . 1
. Seuing up Display Pages . . . . . . . . . . . . . . . . . . . . . 19
. Dening content ielationships . . . . . . . . . . . . . . . . . . 13
. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6 Personalization and Customization 175
.1 Usei Peisonal Sites . . . . . . . . . . . . . . . . . . . . . . . . 1
.2 Page Customizations . . . . . . . . . . . . . . . . . . . . . . . 1
.3 Using Lifeiays iules engine . . . . . . . . . . . . . . . . . . . 181
.4 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7 Collaboration Suite 188
ii
.1 Undeistanding Lifeiays common conguiation options . . . . 189
.2 Expiessing youiself using Blogs . . . . . . . . . . . . . . . . . 203
.3 Oiganizing and shaiing events with the Calendai . . . . . . . 213
.4 Discuss, ask and answei using the Message Boaids . . . . . . . 21
. Woiking togethei with the Wiki . . . . . . . . . . . . . . . . . 228
. lind out what otheis think oi do using Polls . . . . . . . . . . 23
. Staying in touch with the Chat . . . . . . . . . . . . . . . . . . 239
.8 lntegiating youi email with Lifeiay Mail . . . . . . . . . . . . 24
.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8 Social Networking 248
8.1 Leveiaging Social Poitlets, Activities Tiacking and Usei Con-
nections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
8.2 Measuiing social activity . . . . . . . . . . . . . . . . . . . . . 28
8.3 Expoiting poital applications as widgets and OpenSocial gad-
gets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8.4 lntegiating with lacebook . . . . . . . . . . . . . . . . . . . . 2
8. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
9 Using Web Forms and Dynamic Data Lists 278
9.1 Building a list platfoim in Lifeiay . . . . . . . . . . . . . . . . 29
9.2 Dening data types . . . . . . . . . . . . . . . . . . . . . . . . 29
9.3 Cieating data lists . . . . . . . . . . . . . . . . . . . . . . . . . 283
9.4 Make it pieuy cieating custom displays . . . . . . . . . . . . 288
9. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
10 Using Workow 300
10.1 Enabling woikow . . . . . . . . . . . . . . . . . . . . . . . . 301
10.2 Cieating new woikow denitions . . . . . . . . . . . . . . . 301
10.3 Timeis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
10.4 Conguiing assets to use woikow piocess denitions . . . . 313
10. Using woikow with othei applications . . . . . . . . . . . . . 31
10. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
11 Kaleo Forms: Dening Business Processes 322
11.1 Kaleo loims . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
11.2 Kaleo Designei . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11.3 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
12 Liferay Utility Applications 331
iii
12.1 Captuiing Web Sites with the Bookmaiks Poitlet . . . . . . . . 332
12.2 Cieating Youi Own Plugin Repositoiy . . . . . . . . . . . . . . 339
12.3 Shopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
12.4 Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . 3
12. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
13 Leveraging the Liferay Marketplace 377
13.1 Maiketplace Concepts Useis, Companies, and Apps . . . . . . 38
13.2 Accessing the Lifeiay Maiketplace . . . . . . . . . . . . . . . . 38
13.3 linding Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.4 Downloading and lnstalling Apps . . . . . . . . . . . . . . . . 388
13. Cieating and Uploading Apps . . . . . . . . . . . . . . . . . . 393
13. Plugin Management . . . . . . . . . . . . . . . . . . . . . . . . 393
13. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
14 Installation and Setup 410
14.1 Editions of Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . 410
14.2 Obtaining Lifeiay Poital . . . . . . . . . . . . . . . . . . . . . 414
14.3 lnstalling a bundle . . . . . . . . . . . . . . . . . . . . . . . . . 41
14.4 App seiveis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
14. Using Lifeiays setup wizaid . . . . . . . . . . . . . . . . . . . 422
14. Manual Conguiation . . . . . . . . . . . . . . . . . . . . . . 42
14. lnstalling Lifeiay on an existing application seivei . . . . . . . 42
14.8 lnstalling Lifeiay on Mule Tcat . . . . . . . . . . . . . . . . . . 428
14.9 lnstalling Lifeiay on Glasslish 3 . . . . . . . . . . . . . . . . . 42
14.10 lnstalling Lifeiay on Jeuy . . . . . . . . . . . . . . . . . . . . 43
14.11 lnstalling Lifeiay on JBoss .1 . . . . . . . . . . . . . . . . . . 41
14.12 lnstalling Lifeiay on JBoss . . . . . . . . . . . . . . . . . . . 43
14.13 lnstalling Lifeiay on JOnAS .2 . . . . . . . . . . . . . . . . . . 481
14.14 lnstalling Lifeiay on Resin 4 . . . . . . . . . . . . . . . . . . . 48
14.1 lnstalling Lifeiay on Tomcat . . . . . . . . . . . . . . . . . . 492
14.1 lnstalling Lifeiay on WebLogic 10 . . . . . . . . . . . . . . . . 00
14.1 lnstalling Lifeiay on Oiacle WebLogic 10.3 . . . . . . . . . . . 0
14.18 lnstalling Lifeiay on WebSpheie 8.0 . . . . . . . . . . . . . . . 13
14.19 Making Lifeiay Coexist with Othei Java EE Applications . . . 23
14.20 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
15 Management 526
1.1 Managing Useis . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Adding useis . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
iv
1.3 Usei management . . . . . . . . . . . . . . . . . . . . . . . . . 29
1.4 Usei Gioups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
1. Roles and Peimissions . . . . . . . . . . . . . . . . . . . . . . 39
1. Managing Poital Seuings . . . . . . . . . . . . . . . . . . . . . 4
1. lntegiating Lifeiay useis into youi enteipiise . . . . . . . . . . 1
1.8 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
16 Using the Control Panel 565
1.1 Custom lields . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Monitoiing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0
1.3 Plugins Conguiation . . . . . . . . . . . . . . . . . . . . . . . 0
1.4 Seivei Administiation . . . . . . . . . . . . . . . . . . . . . . 1
1. Poital lnstances . . . . . . . . . . . . . . . . . . . . . . . . . .
1. Plugins lnstallation . . . . . . . . . . . . . . . . . . . . . . . . 8
1. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
17 Advanced Portal Operation 580
1.1 Audit Tiails . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
1.2 Lifeiay monitoiing using Google Analytics . . . . . . . . . . . 88
1.3 Backing up a Lifeiay installation . . . . . . . . . . . . . . . . . 88
1.4 Lifeiays Logging System . . . . . . . . . . . . . . . . . . . . . 90
1. Patching Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . . 92
1. Upgiading Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . 9
1. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 03
18 Using Scripting for Advanced Flexibility 605
18.1 Accessing Lifeiay Seivices . . . . . . . . . . . . . . . . . . . . 0
18.2 Running sciipts fiom the contiol panel . . . . . . . . . . . . . 08
18.3 Leveiaging the Sciipt Engine in Woikow . . . . . . . . . . . 10
18.4 Custom Java Tools in the Sciipt Engine . . . . . . . . . . . . . 12
18. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
19 Conguring Liferay for High Availability 618
19.1 Lifeiay Clusteiing . . . . . . . . . . . . . . . . . . . . . . . . . 19
19.2 Peifoimance Tuning . . . . . . . . . . . . . . . . . . . . . . . 4
19.3 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
v
Pvri~cr
Welcome to the woild of Lifeiay Poital' Tis book was wiiuen foi anyone who
has any pait in seuing up, using, oi maintaining a web site built on Lifeiay
Poital. loi the end usei, it contains eveiything you need to know about using
the applications included with Lifeiay. loi the administiatoi, youll leain all
you need to knowabout seuing up youi site with useis, sites, oiganizations, and
usei gioups, as well as how to manage youi sites secuiity with ioles. loi seivei
admins, it guides you step-by-step thiough the installation, conguiation, and
optimization of Lifeiay Poital, including seuing it up in a clusteied, enteipiise-
ieady enviionment. Use this book as a handbook foi eveiything you need to
do to get youi Lifeiay Poital installation iunning smoothly, and then keep it by
youi side as you conguie and maintain youi Lifeiay-poweied web site.
Whats Newin the Fifth Edition
Teies so much new in this edition that it just about encompasses the whole
book. Of couise, eveiything fiom the last edition has been updated to ieect
the ielease of Lifeiay Poital .1. We also have complete coveiage of Lifeiays
new featuies, such as dynamic data listsand the foim designei that goes with
them, the iules engine, the audit fiamewoik, a ievamped chaptei on enteipiise
conguiation, and moie.
vi
Teie is, of couise, coveiage of Lifeiay Maiketplace as well as the Plugin
Secuiity Managei. Te Document Libiaiy and lmage Galleiy have been com-
bined into a iobust, poweiful Documents and Media poitlet, and youll nd full
documentation of it heie. Youll leain about Lifeiays OpenSocial integiation,
the new faceted seaich featuie, and how to use the ielated assets featuie.
Te new ielease is featuie-packed, and so the documentation must be also
we have ovei 00 pages of goodness awaiting you in these pages.
Conventions
Te infoimation contained heiein has been oiganized in a way that makes it
easy to locate infoimation. We stait at the beginning put a list of stu thats at
the beginning heie.
Sections aie bioken up into multiple levels of headings, and these aie de-
signed to make it easy to nd infoimation.
Souice code and conguiation le diiectives aie piesented monospaced, as
below.
If source code goes multi-line, the lines will be \
separated by a backslash character like this.
Italics aie used to iepiesent links oi buuons to be clicked on in a usei intei-
face.
Monospaced type is used to denote Java classes, code, oi piopeities within
the text.
Bold is used to desciibe eld labels and poitlets.
Page headeis denote the chapteis, and footeis denote the paiticulai section
within the chaptei.
Publisher Notes
lt is oui hope that this book is valuable to you, and that it becomes an in-
dispensable iesouice as you woik with Lifeiay Poital. lf you need any assis-
tance beyond what is coveied in this book, Lifeiay oeis tiaining, consult-
ing, and suppoit seivices to ll any need that you might have. Please see
hup//www.lifeiay.com/seivices foi fuithei infoimation about the seivices we
can piovide.
vii
lt is entiiely possible that some eiiois oi mistakes made it into the nal
veision of this book. Any issues that we nd oi that aie iepoited to us by the
community aie documented on the Ocial Lifeiay Wiki. You can view them oi
contiibute infoimation that youve found about any issues heie
hup//www.lifeiay.com/community/wiki/-/wiki/Main/DocumentationEiiata
As always, we welcome any feedback. lf theie is any way you think we could
make this book beuei, please feel fiee to mention it on oui foiums. You can also
use any of the email addiesses on oui Contact Us page (hup//www.lifeiay.com/contact-
us). We aie heie to seive you, oui useis and customeis, and to help make youi
expeiience using Lifeiay Poital the best it can be.
viii
Cu~v1rv 1
Wu~1 is Liirv~v`
lf youie ieading this, weie going to make a wild guess and say that youie
piobably looking foi some sofwaie to help you iun youi web site. Cieat-
ing a dynamic web site thats moie than biochuiewaie is complicated these
days. You have to think about all kinds of things like usei iegistiation, secuiity,
community-building, collaboiation, and of couise youi own, unique function-
ality and the design of youi site.
To cieate all this, you can puisue seveial dieient stiategies. You can de-
cide to build the whole thing youiself fiom sciatch. Te ieason usually given
foi puisuing this stiategy is that you have the most fieedom, since you can
wiite whatevei you want. A closei inspection, howevei, ieveals that instead of
fieedom, you become a slave, wiiting all kinds of code thats not coie to youi
web site. You have to wiite code foi usei iegistiation, login, secuiity, and ses-
sion management, code foi standaids suppoit, such as lacebook login, OpenlD,
OpenSocial, oi RSS feeds, and code foi geneial featuies, such as comments, tags,
and iatings. You also take the most iisk you and/oi youi development team aie
iesponsible foi eveiy bug, glitch, usei inteiface issue, oi secuiity holeand the
consequences foi thesethat can be found in youi site. Tis stiategy also ie-
quiies the most time to implement, because youie building eveiything fiom
sciatch. When consideiing this option, theiefoie, you ieally need to think haid
about whethei you and youi development team have the time and the expeitise
1
2 CHAPTER 1. WHAT IS LIFERAY?
to handle building eveiything fiom the giound up.
Anothei option is to sciounge the web foi sofwaie that has some of the fea-
tuies you want, and then glue it togethei into one integiated site. loi example,
eveiy site has some kind of content, so you might pick a content management
system. But you want useis to inteiact in some way, so you also giab foium
sofwaie. Piominent useis might get a blog, so youll need sofwaie to handle
that. And, of couise, dont foiget that you have to wiite youi own applica-
tion(s). Youie auempting to build a supei app out of a collection of dispaiate,
but best-of-bieed individual applications. Youve collected the applications, and
nowyoui job is to integiate all of these togethei so that useis only have to log in
once, the foium sofwaie can powei comments on youi content, and blogs aie
published in a nice, customizable feed on the home page. As you woik on this,
you nd that gluing all these applications togethei isnt as easy as you thought.
You might get all of it woiking, but then you have a dieient pioblem down the
ioad a maintenance nightmaie. All of these sofwaie packages will be updated
by theii development teams sepaiately, on dieient schedules, to x bugs, add
featuies, and plug secuiity holes. Now that youve customized them all, ev-
eiy upgiade of eveiy sofwaie package youve chosen becomes an exeicise in
ie-implementing youi glue code to make it all woik.
You could also tiy using something like a blog that has a lot of functionality
that can kind of be used as a content management system. But then, of couise,
things dont woik exactly as youd like them to, and featuies you need aie miss-
ing. You eithei have to build those featuies and integiate them in, oi do without
them.
One nal option, if you have a budget, is to buy something that mostly ts
what you want to do, with the intention of customizing it to t youi needs. Te
goal heie is to get something up and iunning as quickly as possible, by tak-
ing advantage of someones pioduct and suppoit. Te devil heie, though, is in
the details its the customizationpaiticulaily with pioducts that aie not open
souicethat can be most dicult. License agieements need to be negotiated to
get you access to non-documented, inteinal APls, and many pioducts aie sim-
ply not designed to be customized to the extent that you might want to have
them customized. lt can take moie time to customize than you though, and you
usually iun into some limitation that keeps you fiom building exactly what you
need. Alteinatively, you may wind up having to pay expensive consultants to
get the iesult that you want, and afei that, youve paid moie than you initially
thought you would, and you have a complicated situation when it comes to
upgiading youi system.
As you can see, all of these options have pios and cons to them. Teie aie
times when building fiom sciatch makes sense, and theie aie times when in-
1.1. WHAT MAKES LIFERAY PORTAL UNIQUE 3
tegiation oi puichasing a solution make sense. But what if you could have all
of these stiategies combined` What if theie was a pioduct that gave you the
fieedom to cieate whatevei you want, had tons of ieusable functionality, was
designed foi customization, and was a single, unied pioduct with a cleai up-
giade path`
Teie is. Tis solution gives you all the fieedom of cieating youi site fiom
the giound up, all the benets of existing, integiated, iobust applications, and
a development fiamewoik that makes youi application a ist class citizen. lts
called Lifeiay Poital.
1.1 What makes Liferay Portal unique
Lifeiay Poital is a web expeiience platfoim that contains all of the common
applications youd use as building blocks foi youi web site. Because of this,
using Lifeiay completely changes the way youd appioach building youi site,
because Lifeiay includes all the functionality mentioned above and moie. ln
fact, depending on what youie building, its possible to build some sites without
wiiting any code at all' lf youve got a gieat application in mind, then Lifeiay
is also a fantastic web application development platfoim that you can use to
youi advantage to ielease youi application fastei. Why` Because you can focus
on youi application, and use the usei management, secuiity, standaids suppoit,
and geneial featuies piovided by Lifeiay Poital without having to wiite them
youiself.
Of couise, theie aie moie featuies than just those. You can take advantage
of functionality enabling useis to connect with each othei in social netwoiks,
to collaboiate on whatevei inteiests them, to cieate content, and so much moie.
ln fact, itll take this whole book to desciibe fully what Lifeiay can do, but well
summaiize it as best we can in the iest of this chaptei.
ln shoit, Lifeiay Poital is moie than a development platfoim, moie than a
content management system, moie than a social netwoik, and moie than a set
of collaboiation tools. lts the best way to build a web site.
1.2 Using Liferay Portal as a content management system
One of the most common uses of Lifeiay Poital is as a content management sys-
tem. ln fact, many use Lifeiay Poital just foi content management, whethei it
be web content management oi management of le-based content (documents,
4 CHAPTER 1. WHAT IS LIFERAY?
media les, and the like). Tey do this because Lifeiay Poitals content manage-
ment system is so poweiful and featuie-iich that it could be oeied as a totally
sepaiate, standalone system of its own. Of couise, the fact that its integiated
with the iest of the applications in Lifeiay Poital makes it all the moie auiactive.
So what can it do` Well answei that question, but take it in two paits. liist,
well look at Lifeiay Poitals iole as a web content management system, and
then well see how Lifeiay Poital excels at le-based content management.
Effectively building a site with Liferay WCM
Te ist thing youll want to undeistand about Lifeiay WCM is that it scales to
woik foi the tiniest of sites all the way up to the laigest of sites. loi example,
on the small end of things you can ie up Lifeiay Poital, diop the Web Content
Display application onto a page, and immediately stait typing content into a
WYSlWYG editoi, in place. On the laige scale of things, you can set up Lifeiay
Poital to host many dieient web sites foi many dieient puiposes, all with
theii own domain names. Each site can take advantage of a sepaiate staging
seivei, wheie content and pages aie cieated by teams of people using stiuctuies
and templates, and updates to the pioduction seivei aie published on a schedule,
only afei having gone thiough a multi-step appioval piocess.
Tats poweiful.
By default, Lifeiay Poital staits with a single site that has a single page. You
can build any web site you wish out of this, complete with multi-nested page
hieiaichies, as the guie below shows.
Figure 1.1: Liferays page hierarchies are easy to create, using a tree
structure thats familiar to anyone who has used a le manager.
1.2. USING LIFERAY PORTAL AS A CONTENT MANAGEMENT SYSTEM
Tese pages can have any layout you like Lifeiay Poital ships with seveial
built-in, and you can cieate youi own custom layouts and deploy them eas-
ily. Pages can be added, iemoved, oi ieoideied any time, and you have the
full exibility of all the HTML page auiibutes, such as meta tags and iobot le
declaiations, that you need.
Pages aie also integiated with Lifeiays poweiful peimissions system, so its
easy to iestiict access to ceitain poitions of youi site. You can give individual
useis sites of theii own, with public pages that have theii content and blog, and
piivate pages that contain theii calendai and email.
lf youie iunning a laige web site wheie youll be cieating and managing
lots of dieient sub-sites foi individuals and gioups, you can take advantage of
page templates and site templates. Te foimei enables you to set up templates of
pages with piedened layouts and applications alieady on them, and the lauei
enables you to cieate a whole site made up of multiple, piedened pages.
Teies even moie. lf you have a veiy laige site, you might need multiple
people to woik on it. And you ceitainly dont want the live site changing befoie
youi useis eyes. loi that ieason, Lifeiay Poital piovides a featuie called staging,
that lets you place youi changes in a holding aiea while theyie being woiked
on. You can have a local staging seivei, wheie the staged site iesides on the same
seivei as the live site, oi you can have a iemote staging seivei, wheie all web
content woik happens on a sepaiate seivei fiom youi live site. ln eithei case,
when youie ieady, site changes can be pushed to the live site, eithei manually
oi on a schedule.
Figure 1.2: Staging supports publishing manually or on a schedule.
Lifeiay Poitals web content cieation tools aie easy and intuitive to use at
all levels. lf you need only basic content management capabilities foi youi site,
you can jump iight in. liomthe Dockbai, you can add the Web Content Display
application anywheie in youi page layout and entei content in place. lts easy
to go fiom this basic level of content management to moie sophisticated levels
of functionality.
loi example, suppose you wanted to build an online news-oiiented site.
Most of the content youll publish is an aiticle of some kind. Lifeiays web
CHAPTER 1. WHAT IS LIFERAY?
content management system lets you cieate a structure foi this, so that you can
captuie all the infoimation fiom youi wiiteis that youd need in an aiticle. Te
guie below shows what this stiuctuie might look like to a jouinalist whod be
enteiing his oi hei aiticle into the system.
Figure 1.3: Structures allowyou to specify exactly the type of data that
makes up your content. You can also include tooltips to help your users
understand what each eld is for.
As you can see, you can use stiuctuies to make suie wiiteis piovide the title
of the stoiy, what type of stoiy it will be, and the byline (i.e., the wiiteis name).
Youve made suie that all the ielevant infoimation foi the stoiy is captuied in
the system.
Web content is one example of what in Lifeiay is called an asset. Assets can
have meta-data auached to them, and that metadata can be used to aggiegate
similai assets togethei in seaiches oi as published content. One way to do this
in the example above is that wiiteis can tag and categoiize theii stoiies so they
can be found moie easily by useis.
1.2. USING LIFERAY PORTAL AS A CONTENT MANAGEMENT SYSTEM
Tis is just one example, of couise. But the concept is applicable to any kind
of site youd want to build. loi example, if you weie building a site foi a zoo,
you could use web content stiuctuies to help useis entei data about animals in
the zoo, such as theii common names, theii scientic names, theii species, theii
locations in the wild, and moie.
When it comes time to publish content, stiuctuies aie combined with tem-
plates. Templates aie instiuctions foi how to display stiuctuies, wiiuen most
of the time in Velocity oi lieemaikeiboth of which aie well-known templat-
ing languages used foi mixing HTML with piogiammatic elements. Because of
this, theyie veiy easy to wiite, and can help you ensuie that youi site has a
consistent look and feel.
Teie is much moie to web content. You can cieate abstiacts, schedule when
content is published and when it should be taken down (oi ieviewed), dene
ielated assets, and moie.
Tis is just the web content poition of Lifeiays content management system.
Lifeiay Poital is also gieat at managing le-based content.
Keeping track of documents, images, video, and more
lts iaie to nd in an open souice pioject a full-featuied content management
system. Most of the time, youll nd web content management systems and le-
based content management systems as sepaiate piojects. Lifeiay Poital, how-
evei, piovides you with both. As shown above, the web content management
system is as iobust as any othei youll nd, and its le-based content manage-
ment system is the same.
Lifeiay Poital keeps the Ul of its le-based content management system in
an application called Documents and Media Library. Tis application iesides in
the contiol panel oi can be added to any page, and, as shown below, looks veiy
much like the le managei that youie alieady familiai with fiomyoui opeiating
system.
Like a le managei, you can biowse les and foldeis in nested hieiaichies.
You can also mount othei iepositoiies that you might have in youi enviion-
ment, such as Documentum (EE only) oi any system that implements Content
Management lnteiopeiability Seivices (CMlS). lt piovides pieviews of just about
eveiy document type you can think of. And, like a le managei, you can copy
and move les between foldeis by diagging and diopping them. Of couise, if
you still want to use youi opeiating systems le managei, you can, because
Lifeiays Documents and Media libiaiy suppoits WebDAV, using the same cie-
dentials you use to log in to Lifeiay.
8 CHAPTER 1. WHAT IS LIFERAY?
Figure 1.4: Liferay Portals Documents and Media library was purposefully
designed to be familiar to anyone who uses a computer.
Lifeiay Poitals Documents and Media libiaiy, howevei, is much moie iobust
than a le managei is, because its a full content management system. You can
dene ways of classifying les that may be of dieient types, but aie meant foi
the same, oveiaiching puipose.
loi example, you can dene metadata sets, which aie gioups of elds desciib-
ing auiibutes of a le. One of these that ships with the pioduct is called meeting
metadata, and it contains elds such as Meeting Name, Date, Time, Location,
Desciiption, and Paiticipants. Tis is a geneiic set of elds that go togethei and
that youd want to use as a gioup. You can cieate as many of these as you want.
loi les, you can dene document types. Tey piovide a moie natuial way of
woiking with les. loi example, you might cieate a document type called Meet-
ing Minutes, because this is how we as humans conceptualize oui documents.
lt doesnt ieally mauei whethei its a Miciosof Woid document, an HTML le,
oi a text lethe document contains meeting minutes. Once youve cieated the
document type, you can auach the Meeting Metadata set that contains many
of the elds youd want, and you can also add extia elds, such as a eld foi
action items. When useis want to add a le containing theii notes foi meeting
minutes, they can also add all the ielevant metadata about the meeting (such as
the time, location, and action items). Tis captuies the context infoimation that
goes with the document, and it piovides a much moie natuial way of woiking
with documents than just dumping them into a shaied le system.
Of couise, the system goes much fuithei than this. loldeis can be set so that
only ceitain document types can be added to them. Woikow iules can also
be added to foldeis to iun les thiough an appioval piocess that you dene. ln
1.3. USING LIFERAY PORTAL AS A COLLABORATIVE PLATFORM 9
shoit, Lifeiays le-based content management systemgives you all the featuies
you need to manage and shaie les in a gioup.
Many Lifeiay Poital useis see it as a iobust content management system,
and they use it piimaiily foi that puipose. Now, hopefully, you can see why.
Well covei the system in-depth in the body of this book, but foi now we need
to look at some of the othei ways you can use Lifeiay Poital, staiting with its
fantastic collaboiative tools.
1.3 Using Liferay Portal as a collaborative platform
Many sites have giown oiganically. You may have giown youi community by
using sepaiate tools ist a foiums application, and then a wiki foi collaboia-
tive documentation, and maybe even a chat application. lt can be haid (and
eiioi-pione) to integiate all of these applications so youi useis can use them
seamlessly. Tankfully, Lifeiay includes a suite of collaboiative applications
you can use, and theyie all integiated togethei.
Lifeiay Poital oeis eveiy standaid collaboiative application thats available.
Tese applications iange fiompeisonal pioductivity applications like a calendai
and email, to community-building applications like message boaids, polls, and
wikis.
Figure 1.5: Liferay Portals message boards are as fully featured as any
standalone forumapplication, with the added benet that theyre
integrated with the rest of the system.
Tis is a suite of integiated applications with all the featuies of similai, stan-
dalone applications. loi example, Lifeiay Poitals message boaids include cat-
10 CHAPTER 1. WHAT IS LIFERAY?
egoiies and subcategoiies, message thieads, captcha, RSS feeds, email notica-
tion, posting via email, and much moie. But moie than this, the applications
aie integiated with the iest of Lifeiay Poitals fiamewoik. Useis log in, and
theii pioles aie used automatically by the message boaids and all the othei
collaboiative applications. And as well see latei, functionality fiom the built
in applications can be added to youi own to piovide featuies like comments in
youi own sofwaie, and you dont have to wiite any code to do it.
Lifeiay Poitals wiki is anothei example of a full-featuied collaboiative ap-
plication. lt has suppoit foi authoiing pages in a WYSWYG editoi, oi moie
advanced useis can use the easy-to-leain standaid Wiki Cieole syntax. Useis
can comment on wiki aiticles, and it keeps a full histoiy of eveiy change thats
been made, allowing useis to ieveit back to any change. lt also suppoits RSS
feeds (just about eveiy Lifeiay application does) so you can subsciibe to see new
aiticles as they aie posted. Each site can have one oi moie wikis, and each wiki
can have one oi moie top-level nodes.
Figure 1.6: Liferay Portals wiki enables users to collaboratively create
complex articles. Clicking the Details link shows the full history of the
article, including the author of each change.
We could go thiough all of Lifeiay Poitals collaboiative applications in a
similai fashion, but lets save that foi the body of the book. Lifeiay Poitals suite
of collaboiative applications includes a blog (complete with blog aggiegation
1.4. USING LIFERAY AS A SOCIAL PLATFORM 11
featuies so you can publish multiple useis blog entiies in one place), a chat
application foi useis who aie online at the same time, message boaids, a wiki,
a knowledge base that you can use to publish a libiaiy of technical aiticles, a
polling systemyou can use to have useis vote on ceitain questions, and peisonal
pioductivity applications like a calendai and email.
Lifeiay Poital includes eveiy application youll need to enable useis to col-
laboiate. Next, well see how you can use Lifeay Poital as a social platfoim.
1.4 Using Liferay as a social platform
Whethei you plan to build a social netwoik oi enable social applications as
pait of youi oveiall usei expeiience, Lifeiay Poital has the tools to make those
featuies woik foi you. Staiting with a suite of applicationsincluding a piole
summaiy, activities feeds, social iequests, a wall, and moieand iounding things
out with an APl to handle ielationships between useis as well as publish theii
activities to each othei, Lifeiay Poital helps you implement common featuies of
social netwoiks to enhance youi existing site.
Figure 1.7: Liferay Portal provides feeds of social activities. These feeds
can contain entries fromany of Liferays built-in applications or
applications that you write.
Social ielationships within Lifeiay Poital aie ideally suited foi many diei-
ent kinds of implementations, whethei youie building a public social netwoik
oi want to enable social featuies in youi coipoiate lntianet. Useis can cie-
ate ielationships within the system, allowing them to see updates fiom those
12 CHAPTER 1. WHAT IS LIFERAY?
whose activity they need to tiack. Tats fai moie poweiful than having them
subsciibe to multiple individual RSS feeds oi visit multiple pioles, because the
system keeps tiack of the updates fiom those with whom you have a ielation-
ship, automatically.
Moie than this, howevei, Lifeiay is a gieat integiation platfoim foi social
applications. lt fully suppoits the OpenSocial fiamewoik. You can use Lifeiay
Poitals built-in OpenSocial gadget editoi to cieate and seive youi own OpenSo-
cial gadgets.
Figure 1.8: Liferay Portals OpenSocial gadget editor lets you rapidly
create social applications that can be served across the web to any other
OpenSocial container.
Lifeiay Poital also suppoits the cieation of lacebook applications, in fact,
no additional coding is necessaiy to publish youi Lifeiay applications on lace-
book (you would, of couise, need to use lacebooks APl to use lacebook-specic
featuiessuch as posting on useis timelines). Te only thing you need to do is
get an APl key and canvas page URL fiom lacebook.
As you can see, Lifeiay Poital is built foi social applications adding social
featuies to youi web site, cieating a social netwoik of youi own, cieating social
1.5. USING LIFERAY AS A WEB PLATFORM 13
Figure 1.9: Any Liferay application can be published to multiple social
networks with a fewclicks.
applications to be published on othei web sites, oi building a social application
foi lacebook.
As with social applications, Lifeiay Poital is also an easy to use, iobust plat-
foim foi any web application youie consideiing wiiting. ln addition to this,
Lifeiay Poital is easily conguied to be used as a shaied hosting platfoim foi
multiple web sites. Lets look at the benets you can ieap by using Lifeiay Poital
in these ways.
1.5 Using Liferay as a web platform
We cant even begin to imagine what youie thinking of building, but whatevei
it is, youie going to put youi heait and soul into it. Building it on Lifeiays
web platfoim can give you a leg up, by pioviding to you eveiything you need to
suppoit youi application, so you can concentiate solely on what youre building,
and not the iest of the featuies youi useis expect will come along with it.
Liferay as an application development platform
lmagine youi application foi a moment. Does it iequiie useis to iegistei with
youi site` Will they be able to comment on content contained within youi
application` ls theie some asset that useis can tag oi categoiize` lf you think
about the layout of the application, would it benet fiommodulaiization` Could
you make use of a iich JavaSciipt fiamewoik with many components built into
it` How about secuiitywill you need to make infoimation available to some
14 CHAPTER 1. WHAT IS LIFERAY?
useis, but not to all useis` Lifeiay Poital has all of this and moie available to
the developei, so you dont have to wiite it youiself.
Lifeiay Poitals development fiamewoik is a gieat help when youie building
a web application. While the fiamewoik itself is coveied in othei iesouices such
as the Liferay Developers Guide oi Liferay in Action, the stiengths of Lifeiay as
a platfoim aie also appaient once youve nished wiiting youi application.
loi example, bug xes to youi applications aie easy to apply, because Lifeiay
applications aie hot deployed to the iunning seivei. Lifeiays Maiketplace gives
you a ieady-made shopping centei foi youi applications. And Lifeiays web
seivices and JSON aichitectuie make it easy foi you to shaie data fiom youi
applications to othei systems iunning on dieient platfoims.
You get all thisnot to mention the automatic lacebook and OpenSocial inte-
giation mentioned abovesimply by using Lifeiays development platfoim. lts
a veiy poweiful platfoim, and ceitainly woith youi investigation.
Agreat integration platform
lf youie building an enteipiise system, poitals weie designed in the ist place
to be a single point of entiy to youi useis applications and content. Since Lif-
eiay Poital integiates well with usei diiectoiies such as LDAP and Active Di-
iectoiy, and single sign-on systems such as SAML and OpenSSO, it ts well into
youi enteipiise systems. Tis allows you to use it as an integiation platfoim foi
existing applications.
Lifeiay Poital, since it adheies to the JSR standaid foi poitlets, was designed
fiom the giound up foi application integiation. You can mix and match any
application installed in the system on any page within the poital. You can make
use of any APls piovided by othei systems to integiate theii data into an appli-
cation window in Lifeiay. And applications you cieate with Lifeiays Seivice
Buildei APl aie web seivice-enabled fiom the stait.
Hosting multiple sites on Liferay Portal
Lifeiay Poital excels as a multi-site hosting platfoim. You can use it to host
multiple sites undei the same oveiall aichitectuie (like lacebook, MySpace, oi
Pinteiest oei to theii useis), oi you could host seveial completely dieient web
sites based solely on Lifeiays ability to seive multiple instances of itself fiom
the same physical installation.
ln the ist scenaiio, Lifeiay Poitals Sites aichitectuie lets you cieate multi-
ple, dieient web sites that have public and/oi piivate sets of pages and as many
pages within those sets as youd like. Useis join the web site, and once theyie
1.6. EXTENDING AND CUSTOMIZING LIFERAY FOR YOUR OWN NEEDS 1
membeis, they can join and leave open sites with one click. Some sites can be
dened as iestiicted oi piivate, and useis cant access those unless theyie added
by site administiatois. All of these sites can have canonical domain names such
as baseballcaids.lifeiay.com oi piogiock.lifeiay.com.
Using this constiuct, you can build anything fiomlacebook, to Yahoo Gioups,
to Souiceloige, to the now-defunct-but-once-loved Geocities. Teie is no limit
to the numbei of sites you can have some Lifeiay installations have only one
oi two, but otheis have many thousands.
ln the second scenaiio, Lifeiay Poital lets you cieate completely sepaiate
instances of itself fiomthe same installation. Useis, gioups, oiganizations, sites,
and ioles fiom each instance aie kept completely sepaiate. lf a usei iegisteis
foi a usei id on one instance, he oi she would have to iegistei as a new usei on
anothei instance as well.
Tis lets you host many dieient, sepaiate web sites fiom one Lifeiay Poital
installation. Useis of each instance have access to the same poweiful content
management, collaboiation, social, and web development platfoim that theyd
have if they weie opeiating fiom a single, standalone installation.
1.6 Extending andcustomizing Liferay for your own needs
Beyond using Lifeiay as a development platfoim foi new applications, Lifeiay
Poital has also been designed to be extended and modied. As an open souice
pioject, its souice code is available, but Lifeiay Poitals developeis have de-
signed the pioduct to make it easy to build whatevei you want out of it.
Special sofwaie components called hook and ext plugins enable develop-
eis to change any aspect of Lifeiays inteiface and behavioiwithout having to
modify any of Lifeiay Poitals souice code. Tis piovides you all the benets
of the build fiom sciatch stiategy we mentioned eailiei, but without all the
eoit to build fiom sciatch. lf you want to make a change to the usei iegis-
tiation scieens, add suppoit foi a piopiietaiy single sign-on mechanism that
youve wiiuen, ievise the usei inteiface foi the message boaids application, oi
anything else, you can make those customizations. And if youie a developei,
weie suie you know that its a whole lot easiei to customize something that al-
most does things exactly the way you want than it is to wiite that featuie fiom
sciatch. With Lifeiay Poital, you can have youi cake and eat it too.
1 CHAPTER 1. WHAT IS LIFERAY?
1.7 Summary
So what is Lifeiay` As you can see, its haid to desciibe, because it does so
much. What weve essentially done is say its a totally awesome content and
document managing, usei collaboiating, socially enabling, application develop-
ing, coipoiate integiating, completely customizable platfoim foi building the
lnteinet. lf wed said that up fiont, youd piobably have doubted us. Hopefully
now, you can see that its tiue.
lf youie inteiested in using Lifeiay Poital foi your pioduct, continue iead-
ing. Well go thiough all of these featuies (and moie that we couldnt mention)
thioughout the iest of the book.
Cu~v1rv 2
Wrn CoN1rN1 M~N~crxrN1
Web Content Management is a systemwhich allows non-technical useis to pub-
lish content to the web without having advanced knowledge of web technology
oi piogiamming of any soit. Lifeiay WCM empoweis you to publish youi con-
tent with a simple point and click inteiface and it helps you to keep youi site
fiesh. Youll nd youiself easily cieating, editing and publishing content within
just a few minutes of being exposed to its featuies. But Lifeiay WCM doesnt
saciice powei foi simplicity. lf need be, you can use youi developei skills to
cieate complex piesentation layei templates that make youi content pop with
dynamic elements. Once these templates have been deployed into the poital,
youi non-technical useis can manage content using these templates as easily as
they would manage static content. All of this makes Lifeiay WCM an appiopii-
ate choice foi sites with only a few pages oi sites with gigabytes of content.
ln this chaptei, well covei the following topics
leatuies of Lifeiay WCM
Cieating sites and managing pages
Authoiing content
Publishing content
1
18 CHAPTER 2. WEB CONTENT MANAGEMENT
Woikow
Site membeiships and peimissions
As youll see, Lifeiays WCM is a full-featuied solution foi managing youi
web site. Well stait with an oveiview of what it has to oei and then well dive
down into its featuies. Note that web content is just one kind of asset on Lifeiay.
Othei types of content (blog posts, wiki aiticles, message boaid posts, etc.) aie
also consideied assets. Lifeiay piovides a geneial fiamewoik foi handling assets
that includes tags, categoiies, comments, iatings, and moie. Please see chaptei
foi moie infoimation on Lifeiays asset fiamewoik.
2.1 HowCan Liferays WCMHelp You?
With Lifeiays WCM you have the ability to cieate, edit, stage, publish and ap-
piove content with easy to leain yet poweiful tools. Lifeiays WCMstieamlines
the content cieation piocess foi end useis. lts much fastei to use Lifeiays
WCM than it would be to cieate all the content foi youi site in HTML. Some
ways Lifeiay WCM makes this possible include
Once set up, non-technical useis can manage the site.
Lifeiays ne-giained peimissions system ensuies youi content gets to
the iight useis.
To manage the site, no piogiamming is iequiied.
Content can be staged.
Content can be passed thiough a woikow.
Content can be published on a schedule.
WCM is integiated with Lifeiays seivices so advanced template devel-
opeis can use them to queiy foi data stoied elsewheie in Lifeiay.
Once you get familiai with Lifeiay WCM youll wondei how you evei got
along without it.
2.2. CREATING SITES AND MANAGING PAGES 19
What Features Does Liferay WCMHave?
Lifeiays WCM has a host of featuies the makes managing the content of youi
site easiei.
WYSIWYG Editor: A complete HTML editoi that allow you to modify
fonts, add coloi, inseit images and much moie.
Structure Editor: Easily add and iemove elds you want available to con-
tent cieatois and then dynamically move them aiound. Tis editoi in-
cludes an entiie suite of foim contiols you can diag and diop onto youi
stiuctuie.
Template Editor: lmpoit template sciipt les that infoim the system how
to display the content within the elds deteimined by the stiuctuie.
Web Content Display: A poitlet that allows you place web content on a
page in youi poital.
Asset Publisher: Apoitlet which can aggiegate dieient types of content
togethei in one view.
Seduler: Lets you schedule when content is ieviewed, displayed and
iemoved.
Workow Integration: Run youi content thiough an appioval oi ieview
piocess.
Staging: Use a sepaiate staging seivei oi stage youi content locally so
you can keep youi changes sepaiate fiom the live site.
Lifeiays Web Content Management is a poweiful and iobust tool foi cieat-
ing and oiganizing content on youi web site. Lets begin by examining some
basic concepts involving sites and pages.
2.2 Creating sites and managing pages
With most pioducts, you would leain what the sofwaie can do in teims of
seuing up youi useis and secuiity model and then stait building youi system.
Youd design youi infiastiuctuie and get youi seivei enviionment up and iun-
ning while youi developeis wiite the applications that live on youi web site.
With Lifeiay Poital, howevei, you stait faithei ahead. Lifeiay Poital is moie
20 CHAPTER 2. WEB CONTENT MANAGEMENT
than just a container foi applications with a iobust secuiity model. lt alieady
includes many of the applications youll need, out of the box, ieady to go and
integiated with all the usei management and secuiity featuies youve alieady
leained about.
Neaily all Lifeiay useis use Lifeiays Web Content Management system(WCM).
Afei all, all eveiy web site has content that needs to be managed. Lifeiays
WCM empoweis you to manage all the content on youi site quickly and eas-
ily within youi biowsei. Beyond managing existing content, Lifeiay WCM lets
useis easily cieate and manage eveiything fiom a simple aiticle containing text
and images to fully functional web sites. Web publishing woiks alongside Lif-
eiay Poitals laigei collection of applications, which means you can add shop-
ping cait functionality, visitoi polls, web foims, site collaboiation tools and
moie. Eveiything is done with oui collection of easy-to-use tools with familiai
iich-text editois and an intuitive inteiface.
ln this section well covei some basic aspects of Lifeiay WCM, including
Page types
Layouts
Page and content peimissions
lmpoiting and expoiting content
Content cieation and editing
Content publishing
WCM Woikow
By the time weie done, you should be able to apply all these concepts to youi
own content. To demonstiate Lifeiays Content Management featuies, well
cieate and manage content on the poital foi Nose-ster, a new social netwoik
wheie people aie connected based on what theii noses look like.
liist, a liule housekeeping. lf weie going to be Nose-ster, oui poital should
also be called Nose-stei. To set geneial infoimation about youi poital like the
name and mail domain, go to the Contiol Panel and select Portal Seings undei
the Poital heading. You could set up the conguiation foi Nose-stei as follows.
You can also customize the logo in the top lef coinei of eveiy page by se-
lecting Display Seings undei the Miscellaneous tab on the panel to the iight.
Once youve made the changes, we can begin cieating pages.
2.2. CREATING SITES AND MANAGING PAGES 21
Figure 2.1: Changing Portal Settings
Creating and managing pages
You have a few options foi accessing the page cieation inteiface. To simplify
this, well covei the Dockbais Manage menu slightly out of oidei. Teie aie
two inteifaces to be awaie of Site Pages and Page. You can get to these fiom
multiple places. Depending on what youie editing and wheie you aie on the
poital, youll use eithei the Manage menu oi the Contiol Panel to woik with
youi pages. liomthe Contiol Panel, make suie you have the coiiect site selected
in the context menu selectoi and click the Site Pages link in the content section.
lf youve alieady navigated to the site you wish to manage, click Manage fiom
the Dockbai and select Site Pages. Tis is the exact same inteiface you see in
the Contiol Panel. To manage the specic page of the site youve navigated to,
click Manage and select Page.
loi convenience, you can also navigate to the Sites page undei the Poital
section of the Contiol Panel and click Actions Manage Pages. To quickly add
a single page while to the site youie biowsing, click Add fiom the Dockbai and
select Page. Just entei a name foi the page and its added immediately. Click
22 CHAPTER 2. WEB CONTENT MANAGEMENT
Figure 2.2: Managing Individual Pages
the name of the page in the navigation menu to visit it and stait woiking on it.
Site Pages is an inteiface to viewexisting pages, cieate newpages, viewpages
and expoit oi impoit pages using Lifeiay Aichive (LAR) les. Note that you can
switch between managing a set of pages and managing a single page using the
lef-hand side navigation menu. Click on Public Pages oi Private Pages to man-
age the gioup oi click on an individual page to manage just that one. Switch-
ing views like this changes the list of available tabs to the iight. By default,
lifeiay.com, which we ienamed to nosestei.com, contains a single public page
called Welcome.
Lifeiays page gioups aie always associated with sites. Even useis peisonal
pages aie pait of theii peisonal sites. All pages belong to one of two types of
page sets public pages and piivate pages. By default, public pages aie accessible
to anyone, even non-logged in useis (guests). Piivate pages aie accessible only
to useis who aie membeis of the site which owns the pages. Tis means the
piivate pages of an oiganizations site would be viewable only by membeis of
the oiganization.
Regaidless of whethei the pages aie public oi piivate, Lifeiay uses the same
inteiface to manage them. Lets look at this inteiface moie closely.
More page management tools
liomthe Manage Site Pages dialog box, you can add a page to the site by clicking
the Add Page buuon. Because Public Pages is selected on the lef, clicking Add
Page heie adds a top level page next to the Welcome page. You can, howevei,
2.2. CREATING SITES AND MANAGING PAGES 23
Figure 2.3: Managing Site Pages
nest pages as deeply as you like. To cieate a sub-page undei the Welcome page,
select the Welcome page ist and then cieate youi page. lf you latei decide you
dont like the oidei of youi pages, you can diag and diop them in the list to
put them in whatevei oidei you want. Lets go ahead and add anothei top level
page and name it Community. Well use this page foi the Recent Bloggeis and
Wiki poitlets.
Figure 2.4: Adding Pages
When you cieate a new page, you can cieate eithei a blank page oi a page
piepopulated with poitlets fiom a page template. When youie enteiing the
24 CHAPTER 2. WEB CONTENT MANAGEMENT
name of the page, you can select fiom a list of page templates that aie cuiiently
available. To view the pages once you add them, click the View Pages buuon.
Tis is how youd populate youi pages with content and applications. Tis is
coveied in succeeding chapteis.
lf youie using the Manage Pages inteiface to cieate a new page, youll have
some additional options to cieate dieient types of pages. Teie aie Portlet
Pages, Panel Pages, Embedded Pages, URL Pages and Link to Page. By default,
all pages aie cieated as poitlet pages but in some situations you might want to
use one of the othei options.
Portlet Pages aie the pages weie usually talking about. Tey have a layout
which you can diag and diop poitlets into. Most of the pages you cieate will be
poitlet pages.
Panel Pages can have any numbei of poitlets on them, as selected by an ad-
ministiatoi, but only one will be displayed at a time. Useis select which poitlet
they want to use fioma menu on the lef side of the page and the selected poitlet
takes up the entiie page.
Figure 2.5: Apanel page
Embedded Pages display content fiomanothei website inside of youi poital.
An administiatoi can set a URL fiomin the page management inteiface and that
page will appeai in the context and within the navigation of youi Lifeiay poital.
URL Pages aie just iediiects to any URL specied by an administiatoi. You
can use URL pages to cieate links to pages belonging to othei sites of youi poital
oi to pages of an exteinal site. Use URL pages cautiously since blind iediiects
cieate a pooi usei expeiience.
Link to Page cieates a poital page which functions as an immediate iediiect
to anothei page within the same site. You can select which page to link to fiom
a diopdown in the page management inteiface. You could use a Link to Page
2.2. CREATING SITES AND MANAGING PAGES 2
to place a deeply nested page in the piimaiy navigation menu of youi site, foi
example.
Once youve cieated pages and populated them with content, Lifeiay pio-
vides a way foi you to back them up to sepaiate les. Lets see how that woiks.
Baing up and Restoring Pages Next to the Add Page buuon in the Manage
Site Pages scieen aie two buuons labeled Export and Import. Te Expoit buuon
expoits the pages you cieate into a single le, called a LAR (Lifeiay Aichive).
You can then impoit this le into any seivei iunning Lifeiay to ie-cieate the
pages. lf you have a LAR you would like to impoit, use the Import buuon.
Expoiting and lmpoiting LARs is a gieat way to take content fiom one envi-
ionment (say, a development oi QA enviionment) and move it all in one shot
to youi pioduction seivei. Note that you should not make this a iegulai oc-
cuiience. lf you want to iegulaily move pages fiom one seivei to anothei, you
should use Lifeiays staging enviionment, which is coveied in chaptei 3.
LARs aie also a good way to back up youi sites content. You can expoit
them to a specic location on youi seivei which is backed up, and if you evei
have to iestoie youi site, all you need to do is impoit the latest LAR le. One
limitation on LAR les, howevei, is that they aie veision dependent, so you cant
use an expoit fiom an old veision of Lifeiay and impoit it into a newei veision.
Lets be good administiatois and expoit a LAR le foi backup puiposes.
Click on the Export buuon and then name the le nosesterv1.lar. Use the
check boxes to deteimine what youd like to expoit. loi this initial expoit, se-
lect eveiything. Note that if you select the More Options link, the list expands
to include data fiom many of Lifeiays applications, including the Documents
and Media Libiaiy, Message Boaids and Web Content. You can also expoit the
theme youie using.
Once you click Export, youi biowsei piompts you to save the le. Once you
have the le, you can copy it to a backup location foi safekeeping oi impoit it
into anothei installation of Lifeiay Poital. lf you must iebuild oi wish to ieveit
back to this veision of youi site, you can impoit this le by clicking the Import
buuon fiom the Manage Site Pages dialog box, biowsing to it and selecting it.
Next, well look at the options on the iight side menu, staiting with Look
and leel.
Customizing the Look and Feel When you open the Manage Site Pages dialog
box it defaults to the Look and leel tab. On this tab, youie piesented with an
inteiface that allows you to choose a theme foi the cuiient site. Temes can
tiansfoim the entiie look of the poital. Tey aie cieated by developeis and aie
2 CHAPTER 2. WEB CONTENT MANAGEMENT
easily installed using the Lifeiay Maiketplace. Since we dont have any themes
beyond the default one installed yet, well use the default theme foi oui pages.
Figure 2.6: Look and Feel Interface
Many themes include moie than one coloi scheme. Tis allows you to keep
the existing look and feel while giving youi site a dieient avoi. Change the
coloi scheme fiom blue to gieen by selecting Green undei Color Schemes. lf you
now go back to the site (by clicking Back to nosester.com in the top lef coinei
of the Contiol Panel), youll see some paits of the page aie now tinged in a
2.2. CREATING SITES AND MANAGING PAGES 2
gieenish hue.
lf you apply a coloi scheme to a set of public oi piivate pages it is, by default,
applied to each page in the set. lf, howevei, you open the Manage Pages dialog
box foi a paiticulai page, you can select Dene a specic look and feel for this
page to make the coloi scheme apply to this page only. You can use this featuie
to choose a dieient coloi scheme foi a paiticulai page than the one dened foi
the set of public oi piivate pages to which it belongs.
Teie aie a few moie conguiable seuings foi youi theme. You can switch
the bullet style between dots and aiiows and you can choose whethei oi not to
show poitlet boideis by default.
Also notice themes can apply to iegulai biowseis oi mobile devices. You
could cieate anothei site foi mobile useis auached to the hup//m.nosestei.com
addiess and seive up a page designed foi the smallei scieens on phones.
Te CSS section allows you to entei custom CSS that will also be seived up
by youi theme. ln this way, you can tweak a theme in ieal time by adding new
styles oi oveiiiding existing ones.
Te next option conguies the logo that appeais foi youi site.
Using a custom logo lf you want to use youi own logo foi a specic site, use
the Logo tab. Adding a custom logo is easy select the Logo tab and biowse to
the location of youi logo. Make suie youi logo ts the space in the top lefcoinei
of the theme youie using foi youi web site. lf you dont, you could wind up
with a site thats dicult to navigate, as othei page elements aie pushed aside
to make way foi the logo.
ln the logo tab, you can also choose whethei oi not to display the site name
on the site. lf you check the box labeled Show Site Name the site name will ap-
peai in the the top iight coinei of the page. Tis option is enabled by default and
cannot be disabled if the Allow Site Administrators to set their own logo option
is disabled in Portal Seings. lt is also not available foi the default site only
newly cieated sites and usei pages have the option to have the name display.
Changing options for individual pages
When you select a single page, some dieient options appeai. Lets look at what
these do.
Details: lets you name the page foi any localizations you need. You can also
set the HTML title that appeais in the biowsei window foi the page. Plus you
can set an easy to iemembei, fiiendly URL foi the page.
28 CHAPTER 2. WEB CONTENT MANAGEMENT
SEO: piovides seveial means of optimizing the data the page piovides to an
indexei thats ciawling the page. You can set the vaiious meta tags foi desciip-
tion, keywoids and iobots. Teies also a sepaiate Robots section that lets you
tell indexing iobots how fiequently the page is updated and how it should be
piioiitized. lf the page is localized, you can select a box to make Lifeiay gen-
eiate canonical links by language. lf you want to set some of these seuings foi
the entiie site, you can specify them fiom the Sitemaps and Robots tabs of the
Manage Site Seuings dialog box (see below).
Tip: Piioi to Lifeiay .1, theie weie two ways of cieating sites
oiganizations and communities. Tis has been simplied to pio-
vide moie ease of use and allow foi moie exibility. Te main
iole of oiganizations is still to oiganize the useis of the poital in
a hieiaichy but they can also have associated sites. Communi-
ties can still be cieated thiough independent sites but the new
name ieects the fact that sites can be used foi many dieient
puiposes besides communities.
Sites can be cieated thiough the Contiol Panel by a poital administiatoi. To
add a site, click the Sites link on the lef side of the Contiol Panel in the Poital
section and then click Add in the toolbai. lf theie is at least one site template
available, a diopdown menu will be shown allowing you to select a Blank Site.
Othei site templates will appeai in the menu as they become available. Site
templates piovide a pieconguied set of pages, applications and content that
can be used as the basis of the site.
Te following guie shows the foim that needs to be lled when cieating a
Blank Site.
Name: is the name of the site you wish to cieate.
Description: desciibes the sites intended function.
Membership Type: can be open, iestiicted oi piivate. An open site appeais
in the My Sites poitlet and useis can join and leave the site whenevei they
want. A iestiicted site is the same except useis must iequest membeiship. A
site administiatoi must then explicitly giant oi deny useis iequests to join. A
piivate site does not appeai in the My Sites poitlet and useis must be added to
it manually by a site administiatoi.
Active: deteimines whethei a site is active oi inactive. lnactive sites aie
inaccessible but can be activated whenevei a site administiatoi wishes.
3.2. LEVERAGING LIFERAYS MULTI-SITE CAPABILITIES
Figure 3.8: Adding a Site
Once youve cieated a site, it appeais in the Sites page of the Contiol Panel.
Once the site has been cieated you can specify moie details about the site using
thiee categoiies Basic lnfoimation, Seaich Engine Optimization and Advanced.
Details: lets you edit the infoimation you enteied when you cieated the
site and allows you to choose a site template foi the public oi piivate pages of
youi site. lf you select a site template, leave the Enable propagation of changes
from the site template box checked to automatically update youi site if the as-
sociated site template changes. Te update will only be done to pages which
have not been changed within the specic site. lf you uncheck this box but
iecheck it latei, the template pages aie then ieapplied to youi site, oveiwiiting
any changes that may have been made. Only useis who have the peimission
Unlink Site Template will be able to disable the piopagation of changes. When
the piopagation is enabled, the site template might pievent modication of some
oi all pages to ensuie the piopagation occuis.
Categorization: allows you to apply categoiies and tags to the site.
Site URL: lets you set fiiendly URLs and viitual hosts foi youi web site.
Site Template: piovides additional infoimation about the site template as-
sociated to the pages of the site (if any).
Sitemap: lets you use the sitemap piotocol to notify seaich engines youi web
site is available foi ciawling.
8 CHAPTER 3. ADVANCED WEB CONTENT MANAGEMENT
Figure 3.9: Editing a Site
3.3. USING SITE TEMPLATES 9
Robots: lets you use a robots.txt le to specify ceitain pages and links
you dont want to be indexed by seaich engines. You need to set a viitual host
befoie you set a robots.txt le.
Staging: lets you tuin on eithei Local Live staging oi Remote Live staging.
To enable staging, the Enable propagation of changes from the site template box
on the Details tab must be unchecked. With staging enabled, changes to the
site template aie automatically piopagated to the staged site, not to the live site.
Te changes still must be appioved befoie the site is published to live.
Analytics: lets you set a Google Analytics lD that is used foi youi site.
When cieating a site fiom a site template, the initial foim piovides a new
option that lets you decide if you want to copy the pages fiom the template as
public pages oi as piivate pages. By default, the site is linked to the site template
and changes to the site template piopagate to any site based on it. A checkbox
appeais that allows useis to unlink the site template if the usei has peimission
to do so.
Site templates aie veiy poweiful foi managing many similiai sites. Lets look
fuithei at how they woik.
3.3 Using site templates
Site Templates can be administeied in the Contiol Panel within the poital sec-
tion of the lef menu.
Cieating oi modifying a site template is done using the same tools used to
manage a site. You can use these tools to add a hieiaichy of pages. Each page
can have any conguiation and any numbei of applications, just like a iegulai
site. When you cieate a site using a site template, the conguiation of pages
and applications aie copied fiomthe template to the site. By default, all changes
made to the site template aie automatically copied to sites based on that tem-
plate.
Site templates can also contain content just like actual sites. Tis allows you
to use a site template to cieate sample content that appeais in youi site when it is
ist cieated. Changes to a site templates content, howevei, aie not piopagated
to existing sites that aie linked to the site template.
0 CHAPTER 3. ADVANCED WEB CONTENT MANAGEMENT
Figure 3.10: When creating a site froma site template, you need to choose
whether the site template should be copied into the sites public pages or
private pages.
3.3. USING SITE TEMPLATES 1
Any local usei with administiative piivileges can use the Mai-
ketplace to biowse and install apps fiom the Maiketplace, by en-
teiing theii liferay.com ciedentials in the above login scieen.
Tis allows multiple administiatois to manage the apps installed
on the local Lifeiay instance. Once a link is established between
a local administiatoi account and a liferay.com account, theie
is no way to undo this, shoit of ie-installing Lifeiay.
All apps that youve bought aie listed on the Purchased page of the Maiket-
place contiol panel. Clicking on the Purchased link will show you a list of those
392 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
apps which you have downloaded in the past, including apps you may have
puichased/downloaded while using othei Lifeiay installations.
Figure 13.14: Purchased Apps
Te apps which you downloaded and installed on the cuiiently iunning in-
stance of Lifeiay aie listed as lnstalled. Apps which you have pieviously down-
loaded oi puichased on othei Lifeiay instances that aie incompatible with the
cuiient one aie listed as Not Compatible. You need to ie-download/ie-install
the appiopiiate veision of these apps if you wish to use them on youi iunning
instance of Lifeiay.
Downloading through liferay.com
Te second way to install an app is to download it ist, then in a sepaiate step,
deploy it to youi iunning Lifeiay instance. Tis is especially useful in situations
wheie you do not wish to deploy the app diiectly to youi pioduction enviion-
ment, oi in cases wheie the taiget Lifeiay instance that is to ieceive the app
13.5. CREATING AND UPLOADING APPS 393
is behind a coipoiate iewall oi otheiwise does not have diiect access to the
Maiketplace.
ln this case, using youi biowsei, you will nd the app on Lifeiay Maiket-
place.
2
Once found, click on the Purchase buuon when viewing the individual
app. Tis will cause the app to be placed in youi Purchased list on youi peisonal
Home page. Navigate to youi Home page, click on App Manager and visit the
Purchased tab. Each app is listed. lind the app you just puichased and click
Downloads. Youll nd a list of app veisions and Lifeiay veisions. Choose the
veision of the app you want, making suie the Lifeiay veision coiiesponds to the
veision of the Lifeiay installation into which youd like to install the app. Click
Download App and the app is downloaded to youi local machine in the same
way any othei le would be downloaded. Tis le can then be hot-deployed to
Lifeiay by copying it to Lifeiays hot deploy diiectoiy.
13.5 Creating and Uploading Apps
Cieating apps foi the Lifeiay Maiketplace is veiy easy and intuitive. To nd
out moie infoimation about cieating youi own Lifeiay apps, visit the Lifeiay
Maiketplace Developei Guide and get staited cieating apps today'
Next, well discuss geneial Lifeiay plugin management. Well explain the
dieiences between the vaiious types of Lifeiay plugins and show how to man-
ually deploy plugins to Lifeiay.
13.6 Plugin Management
One of the piimaiy ways of extending the functionality of Lifeiay Poital is by
the use of plugins. Plugin is an umbiella teim foi installable poitlet, theme,
layout template, hook, Ext and web module Java EE .war les. Tough Lifeiay
comes bundled with a numbei of functional poitlets, themes, layout templates,
hooks and web modules, plugins piovide a means of extending Lifeiay to be
able to do almost anything.
Portlets
Poitlets aie small web applications that iun in a poition of a web page. Te heait
of any poital implementation is its poitlets, because all of the functionality of a
2
liferay.com/marketplace
394 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
poital iesides in its poitlets. Lifeiays coie is a poitlet containei. Te containeis
job is to manage the poitals pages and to aggiegate the set of poitlets that aie to
appeai on any paiticulai page. Tis means the coie doesnt contain application
code. lnstead, all of the featuies and functionality of youi poital application
must ieside in its poitlets.
Tip: Lifeiay 4.4.2 and below suppoit the Poitlet 1.0 standaid
JSR-18. Lifeiay .0 and above suppoit the Poitlet 2.0 standaid
JSR-28. You cannot iun Poitlet 2.0 poitlets in Lifeiay 4.4.2,
but because the Poitlet 2.0 standaid is backwaids-compatible,
poitlets wiiuen to the 1.0 standaid will iun in Lifeiay .x and
above.
Poitlet applications, like seivlet applications, have become a Java standaid
which vaiious poital seivei vendois have implemented. Te JSR-18 standaid
denes the poitlet 1.0 specication and the JSR-28 standaid denes the poitlet
2.0 specication. A Java standaid poitlet should be deployable on any poitlet
containei which suppoits the standaid. Poitlets aie placed on the page in a
ceitain oidei by the end usei and aie seived up dynamically by the poital seivei.
Tis means ceitain givens that apply to seivlet-based piojects, such as contiol
ovei URLs oi access to the HttpServletRequest object, dont apply in poitlet
piojects, because the poital seivei geneiates these objects dynamically.
Poital applications come geneially in two avois 1) poitlets can be wiiuen
to piovide small amounts of functionality and then aggiegated by the poital
seivei into a laigei application oi 2) whole applications can be wiiuen to ieside
in only one oi a few poitlet windows. Te choice is up to those designing the
application. Te developei only has to woiiy about what happens inside of the
poitlet itself, the poital seivei handles building out the page as it is piesented
to the usei.
Most developeis nowadays like to use ceitain fiamewoiks to develop theii
applications, because those fiamewoiks piovide both functionality and stiuc-
tuie to a pioject. loi example, Stiuts enfoices the Model-View-Contiollei de-
sign pauein and piovides lots of functionality, such as custom tags and foim
validation, that make it easiei foi a developei to implement ceitain standaid
featuies. With Lifeiay, developeis aie fiee to use all of the leading fiame-
woiks in the Java EE space, including Stiuts, Spiing MVC and Java Seivei laces.
Tis allows developeis familiai with those fiamewoiks to moie easily imple-
ment poitlets and also facilitates the quick poiting of an application using those
fiamewoiks ovei to a poitlet implementation.
13.6. PLUGIN MANAGEMENT 39
Additionally, Lifeiay allows foi the consuming of PHP and Ruby applications
as poitlets so you do not need to be a Java developei in oidei to take advantage
of Lifeiays built-in featuies (such as usei management, sites, oiganizations,
page building and content management). You can also use sciipting languages
such as Gioovy if you wish. You can use the Plugins SDK to deploy youi PHP
oi Ruby application as a poitlet and it will iun seamlessly inside of Lifeiay. We
have plenty of examples of this, to see them, check out the Plugins SDK fiom
Lifeiays public code iepositoiy.
Does youi oiganization make use of any Enteipiise Planning (ERP) sofwaie
that exposes its data via web seivices` You could wiite a poitlet plugin foi
Lifeiay that can consume that data and display it as pait of a dashboaid page
foi youi useis. Do you subsciibe to a stock seivice` You could pull stock quotes
fiom that seivice and display them on youi page, instead of using Lifeiays
built-in Stocks poitlet. Do you have a need to combine the functionality of two
oi moie seivlet-based applications on one page` You could make them into
poitlet plugins and have Lifeiay display them in whatevei layout you want. Do
you have existing Stiuts, Spiing MVC oi JSl applications you want to integiate
with youi poital` lt is a stiaightfoiwaid task to migiate these applications into
Lifeiay, then they can take advantage of the layout, secuiity and administiation
infiastiuctuie that Lifeiay piovides.
Themes
Figure 13.15: Envision Theme fromLiferays Theme Repository
Temes aie hot deployable plugins which can completely tiansfoim the look
and feel of the poital. Most oiganizations have theii own look and feel standaids
which go acioss all of the web sites and web applications in the infiastiuctuie.
Lifeiay makes it possible foi a site designei to cieate a theme plugin which can
be installed, allowing foi the complete tiansfoimation of the poital to whatevei
look and feel is needed. Teie aie lots of available theme plugins on Lifeiays
web site and moie aie being added eveiy day. Tis makes it easiei foi those who
wish to develop themes foi Lifeiay, as you can now choose a theme which most
closely iesembles what you want to do and then customize it. Tis is much
39 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
easiei than staiting a theme fiom sciatch. You can leain moie about theme
development in Liferay in Action.
Figure 13.16: Murali Theme fromLiferays Theme Repository
Layout Templates
Layout Templates aie ways of choosing how youi poitlets will be aiianged on
a page. Tey make up the body of youi page, the laige aiea into which you
can diag and diop poitlets. Lifeiay Poital comes with seveial built-in layout
templates. lf you have a complex page layout (especially foi youi home page),
you may wish to cieate a custom layout template of youi own. Tis is coveied
in Liferay in Action.
Hook Plugins
Hook plugins weie intioduced with Lifeiay .2. As the name implies, they allow
hooking into Lifeiays coie functionality. Tis means they enable developeis
to oveiiide oi ieplace functionality that is in the coie of the system. You can
hook into the eventing system, model listeneis and poital piopeities. You can
also oveiiide Lifeiays coie JSPs with youi own. Hooks aie veiy poweiful and
have been designed to ieplace most of the ieasons foi using the extension en-
viionment with something that is easiei to use and hot deployable.
Web Plugins
Web plugins aie iegulai Java EE web modules designed to woik with Lifeiay.
Lifeiay suppoits integiation with vaiious Enteipiise Seivice Bus (ESB) imple-
mentations, as well as Single Sign-On implementations, woikow engines and
so on. Tese aie implemented as web modules used by Lifeiay poitlets to pio-
vide functionality.
13.6. PLUGIN MANAGEMENT 39
Installing Plugins fromRepositories
Figure 13.17: Plugins Installation Portlet Tab Default View
Lifeiay Poital has a section of the contiol panel called Plugins lnstallation,
which you can nd undei the Seivei heading. Tis section not only allows you
to see what plugins aie installed in youi poital, but also it enables you to iun
the seaich indexei on those poitlets that suppoit it and install new poitlets.
Use the dockbais Go to menu to select Control Panel. Undei the Seivei head-
ing, select Plugins Installation. You should now see the page which allows you
to conguie and install poitlets.
Te default view of the Plugins lnstallation page shows which plugins aie
alieady installed on the system and whethei oi not they aie active. Te Poitlet
Plugins tab allows you ieindex ceitain poitlets to impiove theii seaichability.
398 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
Te Teme and Layout Template Plugins tabs display which poital ioles can
access them.
Figure 13.18: Plugins Installation Theme Tab Default View
lf you would like to see what plugins aie available, you can do so by clicking
the Install More buuon, wheie changes based on which tab you aie viewing.
Please note the machine iunning Lifeiay must have access to the lnteinet to
iead the Ocial and Community iepositoiies. lf the machine does not have
lnteinet access, you will need to download the plugins fiom the site and install
them manually. We will discuss how to do this latei in this chaptei.
lts easy to navigate fiom the initial page of the Plugin lnstallei to diei-
ent pages since the plugins aie listed alphabetically. You can also change the
numbei of items pei page and navigate to a specic page if you know wheie a
paiticulai plugin appeais in the list. Tis is a standaid featuie of Lifeiay and
you will see it in most of Lifeiays poitlets.
Afei you click the Install More buuon, a new view appeais. Tis view has
13.6. PLUGIN MANAGEMENT 399
Figure 13.19: Installing Plugins
multiple tabs, and by default, displays the Portlet Plugins tab. Note the list dis-
played is a list of all of the plugins available acioss all of the iepositoiies to
which the seivei is subsciibed. Above this is a seaich mechanism which allows
you to seaich foi plugins by theii name, by whethei oi not they aie installed, by
tag oi by which iepositoiy they belong to. To install a plugin, choose the plu-
gin by clicking on its name. loi example, if you want to use online web foims
on youi web site, you might want to install the Web loim poitlet. Tis poitlet
piovides a handy inteiface which allows you to cieate foims foi useis to ll out.
You can specify an addiess to which the iesults will be emailed.
lind the Web loim Poitlet in the list by seaiching foi it oi biowsing to it.
Once you have found it, click on its name. Anothei page will be displayed which
desciibes the poitlet plugin in moie detail. Below the desciiption is an Install
buuon. Click this buuon to install youi plugin.
Once you click Install, youi chosen plugin will automatically download and
400 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
be installed on youi instance of Lifeiay. lf you have the Lifeiay console open,
you can view the deployment as it happens. When it is nished, you should be
able to go back to the Add Application window and add youi new plugin to a
page in youi poital.
Te same pioceduie is used foi installing new Lifeiay themes, layout tem-
plates, hooks and web modules. lnstead of the Portlet Plugins tab, you would use
the appiopiiate tab foi the type of plugin you wish to install to view the list of
plugins of that type. loi themes, convenient thumbnails (plus a laigei veision
when you click on the details of a paiticulai theme) aie shown in the list.
Figure 13.20: Installing the Web FormPortlet
Afei clicking on the Install buuon foi a theme, the theme becomes available
on the Look and Feel tab of any page.
Installing Plugins Manually
lnstalling plugins manually is almost as easy as installing plugins via the Plugin
lnstallei. Teie aie seveial scenaiios in which you would need to install plugins
manually iathei than fiom Lifeiays iepositoiies
Youi seivei is iewalled without access to the lnteinet. Tis makes it im-
possible foi youi instance of Lifeiay to connect to the plugin iepositoiies.
You aie installing poitlets which you have eithei puichased fiom a ven-
doi, downloaded sepaiately oi developed youiself.
13.6. PLUGIN MANAGEMENT 401
loi secuiity ieasons, you do not want to allow poital administiatois to
install plugins fiom the lnteinet befoie they aie evaluated.
You can still use the contiol panel to install plugins that aie not available
fiom the online iepositoiies. Tis is by fai the easiest way to install plugins.
lf youi seivei is iewalled, you will not see any plugins displayed in the
Poitlet Plugins oi Teme Plugins tabs. lnstead, you will need to click the Upload
File tab. Tis gives you a simple inteiface foi uploading a .war le containing
a plugin to youi Lifeiay Poital.
Click the Browse buuon and navigate youi le system to nd the poitlet oi
theme .war you have downloaded. Te othei eld on the page is optional you
can specify youi own context foi deployment. lf you leave this eld blank, the
default context dened in the plugin (oi the .war le name itsell) will be used.
Tats all the infoimation the Plugin lnstallei needs in oidei to deploy youi
poitlet, theme, layout template, hook oi web module. Click the Install buuon
and youi plugin will be uploaded to the seivei and deployed. lf it is a poitlet,
you should see it in the Add Content window. lf it is a theme, it will be available
on the Look and Feel tab in the page denition.
Figure 13.21: Installing a Plugin Manually
lf you do not wish to use the Update Managei oi Plugin lnstallei to deploy
plugins, you can also deploy them at the opeiating system level. Te ist time
Lifeiay staits, it cieates a hot deploy foldei which is, by default, cieated inside
the Lifeiay Home foldei. Tis foldei geneially iesides one diiectoiy up fiom
wheie youi application seivei is installed, though it may be elsewheie depend-
ing on which application seivei you aie iunning. To nd out wheie the Lifeiay
Home foldei is foi youi application seivei, please see the section on youi seivei
402 CHAPTER 13. LEVERAGING THE LIFERAY MARKETPLACE
in chaptei 1. Te ist time Lifeiay is launched, it will cieate a foldei stiuctuie in
Lifeiay Home to house vaiious conguiation and administiative data. One of
the foldeis it cieates is called deploy. lf you copy a poitlet oi theme plugin into
this foldei, Lifeiay will deploy it and make it available foi use just as though
youd installed it via the Plugin lnstallei in the contiol panel. ln fact, this is
what the Plugin lnstallei is doing behind the scenes.
You can change the defaults foi this diiectoiy stiuctuie so it is stoied any-
wheie you like by modifying the appiopiiate piopeities in youi portal-ext-
.properties le. Please see the above section on the portal-ext.proper-
ties le foi moie infoimation.
To have Lifeiay hot deploy a poitlet oi theme plugin, copy the plugin into
youi hot deploy foldei, which by default is in [Liferay Home]/deploy. lf you
aie watching the Lifeiay console, you should see messages like the following
16:11:47,616 INFO [PortletAutoDeployListener:71] Copying portlets for
/liferay-portal-6.0.4/deploy/weather-portlet-6.0.4.1.war
Expanding:
/liferay-portal-6.0.4/deploy/weather-portlet-6.0.4.1.war
into
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694
Copying 1 file to
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694/WEB-INF
Copying 1 file to
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694/WEB-INF/classes
Copying 1 file to
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694/WEB-INF/classes
Copying 1 file to
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694/META-INF
Copying 37 files to
/liferay-portal-6.0.4/tomcat-6.0.26/webapps/weather-portlet
Copying 1 file to
/liferay-portal-6.0.4/tomcat-6.0.26/webapps/weather-portlet
Deleting directory
/liferay-portal-6.0.4/tomcat-6.0.26/temp/20100729161147694
16:11:48,072 INFO [PortletAutoDeployListener:81] Portlets for
/liferay-portal-6.0.4/deploy/weather-portlet-6.0.4.1.war
copied successfully. Deployment will start in a few seconds.
Jul 29, 2010 4:11:50 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory weather-portlet
13.6. PLUGIN MANAGEMENT 403
16:11:50,585 INFO [PortletHotDeployListener:222] Registering portlets
for weather-portlet
16:11:50,784 INFO [PortletHotDeployListener:371] 1 portlet for
weather-portlet is available for use
Te available for use message means youi plugin was installed coiiectly and
is available foi use in the poital.
Plugin Troubleshooting
Sometimes plugins fail to install. Teie can be dieient ieasons foi installation
failuie based on seveial factois, including
Lifeiay conguiation
Te containei upon which Lifeiay is iunning
Changing the conguiation options in multiple places
How Lifeiay is being launched
You can ofen tell whethei oi not you have a plugin deployment pioblem
by looking at the Lifeiay seivei console. lf the hot deploy listenei iecognizes
the plugin, youll see a plugin copied successfully message. lf this message is
not followed up by an available for use message then you have an issue with
youi plugin deployment conguiation, piobably due to one of the factois listed
above.
Lets take a look at each of these factois.
Liferay Conguration Issues
add the following line to it, wheie ${liferay.home} is the new Lifeiay
Home diiectoiy that you chose
include-and-override=${liferay.home}/portal-setup-wizard.properties
Without this woikaiound, Lifeiay will not iead the
portal-setup-wizard.properties le with youi saved conguia-
tion when you iestait youi seivei and youll see the setup wizaid again.
You now have all the backgiound infoimation you need. Next you need
to make youi decision will you use Lifeiays built-in data souice, oi the one
piovided by youi application seivei` lf youie planning to use the one piovided
by youi seivei, you cant use Lifeiays installation wizaid, and youll have to
follow the instiuctions in the section below titled Manual Conguiation.
ln eithei case, youi next step is to install Lifeiay onto youi application seivei.
Once this is done, if youie using the iecommended built-in data souice, you can
use the setup wizaid, which well covei next.
14.5 Using Liferays setup wizard
To make it easy to conguie Lifeiay optimally foi youi use, the ist thing you
see when biowsing to youi newly installed Lifeiay bundle is a setup wizaid.
Tis gives you a convenient way to conguie Lifeiay foi youi puiposes.
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
44 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.34: Completing Liferay Portal deployment
Tese instiuctions assume that you aie iunning the latest suppoited veision
of Glasssh (cuiiently 3.1.2.2), have alieady conguied a domain and seivei,
and that you have access to the Glasslish administiative console.
Lets stait out by installing the JAR les you will need.
Dependency Jars
Lifeiay depends on jai les found in the Lifeiay Dependencies Aichive. You
should also have installed youi database diivei.
1. Navigate to the foldei that coiiesponds to the domain in which youll be
installing Lifeiay. lnside this foldei is a sub-foldei named lib.
Unzip the Lifeiay dependencies aichive so that its .jar les aie extiacted
into this lib foldei.
14.9. INSTALLING LIFERAY ON GLASSFISH 3 4
Figure 14.35: Accessing Liferay Portal on Liferay Portal Instance 1
2. Make suie the JDBC diivei foi youi database is accessible to Glasslish as
well. Obtain the JDBC diivei foi youi veision of the database seivei. ln the
case of MySQL, use mysql-connector-java-{$version}-bin.jar. You
can download the latest MySQL JDBC diivei.
hup//www.mysql.com/pioducts/connectoi/
4 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.36: Uploading newplugins into Tcat
Set the le encoding
Set the usei time-zone
Set the piefeiied piotocol stack
Pievent the application seivei fiomseuing static elds (nal oi non-nal)
to null
lnciease the default amount of memoiy available.
Modify
/glassfish-3.1-web/glassfish3/glassfish/domains/domain1/config/domain.xml
meiging in the following JVMoptions into the cuiient list of JVMoptions
within youi <java-config> element
<jvm-options>-Dfile.encoding=UTF8</jvm-options>
14.9. INSTALLING LIFERAY ON GLASSFISH 3 4
<jvm-options>-Djava.net.preferIPv4Stack=true</jvm-options>
<jvm-options>-Dorg.apache.catalina.loader.WebappClassLoader. \
ENABLE_CLEAR_REFERENCES=false</jvm-options>
<jvm-options>-Duser.timezone=GMT</jvm-options>
<jvm-options>-Xmx1024m</jvm-options>
<jvm-options>-XX:MaxPermSize=512m</jvm-options>
Be suie that any existing options with values such as
-Dfile.encoding
-Djava.net.preferIPv4Stack
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES
-Duser.timezone
-XX:MaxPermSize
aie ieplaced with the new values listed above.
loi example, ieplace
<jvm-options>-Xmx256m</jvm-options>
with this
<jvm-options>-Xmx1024m</jvm-options>
2. Delete, iename oi move the domain1/docroot/index.html le to anothei
location to allow youi Lifeiay Poital default page to be displayed.
Next, lets get youi database conguied.
Database Conguration
lf you want to use Glasslish to manage youi domains data souice, follow the
instiuctions found in this section. lf you want to use Lifeiay Poital to manage
youi data souice, you can skip this section.
1. Stait youi domains application seivei if it is not alieady iunning.
2. Go to the Glasslish console URL hup//localhost4848.
3. Undei Common Tasks, navigate to Resources JDBC JDBC Connection
Pools
4. Click New.
48 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.37: Navigate to JDBCConnection Pools
Figure 14.38: Glasssh JDBCConnection Pool
14.9. INSTALLING LIFERAY ON GLASSFISH 3 49
. ln the ist scieen (Step 1 of 2), give youi connection pool the name Liferay-
Pool, the iesouice type of javax.sql.ConnectionPoolDataSource and
select youi database diivei vendoi (e.g. MySQL) as follows
. Click Next to advance to the next step in cieating youi JDBC connection
pool.
. On the this scieen (Step 2 of 2), scioll down to the Additional Properties sec-
tion.
Figure 14.39: Glasssh JDBCConnection Pool Properties
8. Replace oi add the following piopeities
URL: the URL of youi connection pool.
loi example,
jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8 \
&emulateLocators=true
Note, if you aie using the above example, you should specify the name of
youi database in place of lportal. Likewise, if youi database is not on the
same host as Glasslish, specify youi the database seiveis host name in place
of localhost. Lastly, specify youi database type in place of jdbc:mysql.
user: the name of youi database usei.
40 CHAPTER 14. INSTALLATION AND SETUP
password: youi database useis passwoid.
10. Click Finish.
You should now see youi LiferayPool connection pool listed undei Re-
sources JDBC JDBC Connection Pools
11. Test youi connection by selecting youi LiferayPool connection pool and
clicking Ping.
lf you get a message stating Ping Succeeded, youve succeeded in seuing up
a connection pool of youi data souice'
13. Now, youll setup a JDBC iesouice to iefei to the LiferayPool connection
pool you just cieated.
14. Navigate to Resources JDBC JDBC Resources to show the cuiient JDBC
iesouices listed by theii JNDl names.
1. Click New.
1. Set the JNDl name to jdbc/LiferayPool and select LiferayPool as the
pool name.
1. Click OK.
Congiatulations' Youve nowconguied youi domains data souice on Glass-
lish'
Mail Conguration
lf you want to use Glasslish to manage youi mail session, follow Glasslishs
documentation on conguiing a JavaMail session with a JNDl name of
mail/MailSession
lf you want to use Lifeiay Poital to manage youi mail session, you can skip this
step.
14.9. INSTALLING LIFERAY ON GLASSFISH 3 41
Domain Conguration - Continued
Lets tie up some loose ends with iegaids to Lifeiay being able to access youi
database and mail session.
1.Shutdown youi domains application seivei if it is cuiiently iunning.
2. Cieate a portal-ext.properties le in the Liferay Home foldei men-
tioned at the beginning of this Glasslish installation section.
3. lf you aie using Glasssh to manage youi data souice, add the following to
youi portal-ext.properties le in youi Liferay Home to iefei to youi
data souice
jdbc.default.jndi.namejdbc/LifeiayPool
Otheiwise, if you aie using Liferay Portal to manage youi data souice, follow
the instiuctions in the Deploy Liferay section foi using the setup wizaid.
4. lf want to use Liferay Portal to manage youi mail session, you can conguie
the mail session within Lifeiay Poital. Tat is, afei staiting youi poital as
desciibed in the Deploy Liferay section, go to Control Panel Server Admin-
istration Mail and entei the seuings foi youi mail session.
lf you aie using GlassFish to manage youi mail session, add the following to
youi portal-ext.properties le to iefeience that mail session
mail.session.jndi.name=mail/MailSession
Lifeiay can now communicate with youi database and mail session. So lets
go ahead and deploy Lifeiay.
Deploy Liferay
Heie aie the steps youll need to followto deploy Lifeiay Poital to youi domains
seivei. Befoie you deploy Lifeiay Poital, lets considei whethei you want to also
stait the setup wizaid.
Start the setup wizard along with Liferay Portal - Do this if you want
to conguie youi poital, set up youi sites administiative account and/oi
manage youi database within Lifeiay.
lf this is youi ist time staiting Lifeiay Poital .1, the setup wizaid is auto-
matically invoked. lf you want to ie-iun the wizaid, specify setup.wizard.en-
abled=true in youi piopeities le (e.g. portal-setup-wizard.properties).
42 CHAPTER 14. INSTALLATION AND SETUP
setup.wizard.enabled=true
Te setup wizaid is then invoked duiing seivei staitup.
Start Liferay Portal without invoking the setup wizard - Do this if want
to pieseive youi cuiient poital seuings.
To stait the seivei without tiiggeiing the setup wizaid, specify setup.wiz-
ard.enabled=false in youi piopeities (e.g. portal-setup-wizard.pro-
perties oi portal-ext.properties le).
setup.wizard.enabled=false
Once you iun the setup wizaid, the portal-setup-wizard.properties
le it cieates alieady has setup.wizard.enabled=false conveniently speci-
ed foi you.
hup//www.lifeiay.com/downloads/lifeiay-poital/available-ieleases
44 CHAPTER 14. INSTALLATION AND SETUP
Befoie you begin, make suie you have downloaded the latest Lifeiay .war
le and Lifeiay Poital dependencies.
8
Te Lifeiay .war le should be called
liferay-portal-6.1.x-<date>.war and the dependencies le should be called
liferay-portal-dependencies-6.1.x-<date>.zip.
Now that you have all of youi installation les, youie ieady to stait in-
stalling and conguiing Lifeiay on Jeuy.
Dependency Jars
Lets woik with the Lifeiay depenency jai les ist.
1. Cieate foldei $JETTY_HOME/lib/ext/liferay.
2. Unzip the jai les found in the Lifeiay Poital Dependencies zip le to youi
$JETTY_HOME/lib/ext/liferay foldei. Take caie to extiact the zip les
.jar les diiectly into this foldei.
3. Next, you need seveial .jar les which aie included as pait of the Lifeiay
souice distiibution. Many application seiveis ship with these alieady on
the class path but Jeuy does not. Te best way to get the appiopiiate vei-
sions of these les is to download the Lifeiay souice code and get them
fiom theie. Once you have downloaded the Lifeiay souice, unzip the souice
into a tempoiaiy foldei. Well iefei to the location of the Lifeiay souice as
$LIFERAY_SOURCE.
Copy the following jais fiom$LIFERAY_SOURCE/lib/development to youi
$JETTY_HOME/lib/ext/liferay foldei
activation.jar
jta.jar
mail.jar
persistence.jar
4. Make suie the JDBC diivei foi youi database is accessible to Jeuy. Obtain the
JDBC diivei foi youi veision of the database seivei. ln the case of MySQL,
use mysql-connector-java-{$version}-bin.jar
9
. Extiact the JAR le
and copy it to $JETTY_HOME/lib/ext/liferay.
Now that youi .jar les aie in place, lets conguie youi domain.
8
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
9
hup//www.mysql.com/pioducts/connectoi/
14.10. INSTALLING LIFERAY ON JETTY 7 4
Jetty Conguration
To get Jeuy ieady foi iunning Lifeiay Poital, you must make a numbei of mod-
ications that involve conguiation les, initialization les and iun sciipts.
1. Cieate a start.config le to modify the behavioi of Jeuys start.jar. lts
best to base youi start.config le on the default one found in start.jar.
2. Extiact the default stait cong le org/eclipse/jetty/start/start.con-
fig fiom the start.jar into $JETTY_HOME/etc. Te le $JETTY_HOME/-
etc/start.config should be in the $JETTY_HOME/etc foldei.
3. Add the following piopeity assignment to $JETTY_HOME/etc/start.config
to specify wheie Jeuy should wiite its logs
jeuy.logsS(jeuy.home)/logs
4. Add the following diiective to $JETTY_HOME/etc/start.config to load
all of the .jar and .zip les found in youi $JETTY_HOME/lib/liferay
foldei into youi class path
S(jeuy.home)/lib/lifeiay/*
Now that youi class loading is specied, lets cieate initialization les and
iun sciipts that invoke these conguiation diiectives duiing Jeuys staitup pio-
cess.
2. Cieate initialization le $JETTY_HOME/bin/start.ini
START=../etc/start.config
OPTIONS=Server,jsp,resources
../etc/jetty.xml
../etc/jetty-deploy.xml
../etc/jetty-webapps.xml
../etc/jetty-contexts.xml
../etc/jetty-testrealm.xml
Tis initialization le does the following
Sets $JETTY_HOME/etc/start.config as youi staiting conguiation
le.
Sets youi seivei options.
Species a sequence of deployment desciiptoi les to be piocessed.
4 CHAPTER 14. INSTALLATION AND SETUP
3.Cieate a iun sciipt appiopiiate to youi opeiating system
On Windows, cieate $JETTY_HOME/bin/run.bat
@echo off
if "" == "%JAVA_HOME%" goto errorJavaHome
set "JAVA_OPTS=-Djetty.version=7.5.4 -Djetty.version.date=20111024 \
-Dfile.encoding=UTF8 -Djava.io.tmpdir=../temp \
-Djava.net.preferIPv4Stack=true -Duser.timezone=GMT \
-Xmx1024m -XX:MaxPermSize=256m"
"%JAVA_HOME%/bin/java" %JAVA_OPTS% -jar ../start.jar
goto end
:errorJavaHome
echo JAVA_HOME not defined.
goto end
:end
On Unix/Linux, cieate $JETTY_HOME/bin/run.sh
#!/bin/sh
if [ ! $JAVA_HOME ]
then
echo JAVA_HOME not defined.
exit
fi
export JAVA_OPTS="-Djetty.version=7.5.4 -Djetty.version.date=20111024 \
-Dfile.encoding=UTF8 -Djava.io.tmpdir=../temp \
-Djava.net.preferIPv4Stack=true -Duser.timezone=GMT \
-Xmx1024m -XX:MaxPermSize=256m"
$JAVA_HOME/bin/java $JAVA_OPTS -jar ../start.jar
3. Cieate a context le $JETTY_HOME/contexts/root.xml to specify the con-
text, classpath and iesouice base of youi web application
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="extraClasspath">
<SystemProperty name="jetty.home" />/lib/jetty-server-
14.10. INSTALLING LIFERAY ON JETTY 7 4
<SystemProperty name="jetty.version" />.v
<SystemProperty name="jetty.version.date" />.jar,
<SystemProperty name="jetty.home" />/lib/jetty-util-
<SystemProperty name="jetty.version" />.v
<SystemProperty name="jetty.version.date" />.jar,
<SystemProperty name="jetty.home" />/lib/jetty-webapp-
<SystemProperty name="jetty.version" />.v
<SystemProperty name="jetty.version.date" />.jar</Set>
<Set name="resourceBase">
<SystemProperty name="jetty.home" />/webapps/root</Set>
</Configure>
4. Lastly, cieate the following foldeis
$JETTY_HOME/logs - foi log les
$JETTY_HOME/temp - foi tempoiaiy les. Note, this foldei is specied to
oui JVM as a tempoiaiy foldei in the iun sciipt you cieated pieviously.
Now that youi geneial Jeuy staitup les aie set in place, lets considei how
you will manage youi data souice.
Database Conguration
lf you want to manage youi data souice within Jeuy, continue following the
instiuctions in this section. lf you want to use the built-in Lifeiay data souice,
you can skip this section.
1. Management of databases in Jeuy is done via the le $JETTY_HOME/etc/jet-
ty.xml. Edit jetty.xml and inseit the following text within the ioot ele-
ment <Configure> to specify the data pool foi youi data souice. Be suie to
pass in value jdbc/LiferayPool as the second aigument.
<New id="LiferayPool" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/LiferayPool</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost/lportal?
useUnicode=true&characterEncoding=UTF-8</Set>
<Set name="User">root</Set>
<Set name="Password">root</Set>
</New>
</Arg>
</New>
48 CHAPTER 14. INSTALLATION AND SETUP
Be suie to ieplace the URL database value (i.e. lportal), usei value and
passwoid value with values specic to youi database.
2. Youi data pool needs Jeuys JNDl and Jeuy Plus libiaiies loaded to access
those classes at iuntime. Youi $JETTY_HOME/etc/start.config le should
have sections that load these libiaiies as long as jndi and plus options aie
specied at staitup.
To set these options, edit youi $JETTY_HOME/bin/start.ini le and add
jndi and plus as values foi the OPTIONS vaiiable
OPTIONS=Server,jsp,resources,jndi,plus
Supei' Now you have youi database specied and ieady foi use with Lifeiay
on Jeuy. Lets considei youi mail session next.
Mail Conguration
lf you want to manage youi mail session within Jeuy, use the following in-
stiuctions. lf you want to use the built-in Lifeiay mail session, you can skip this
section.
Management of mail sessions in Jeuy is done via the conguiation le $JET-
TY_HOME/etc/jetty.xml. Edit jetty.xml and inseit the following text within
the ioot element <Configure> to specify youi mail session. Be suie to pass in
value mail/MailSession as the ist aigument and to ieplace the mail session
values with youi own.
<New id="MailSession" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>mail/MailSession</Arg>
<Arg>
<New class="org.eclipse.jetty.jndi.factories.MailSessionReference">
<Set name="user"></Set>
<Set name="password"></Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.pop3.host">pop.gmail.com</Put>
<Put name="mail.pop3.port">110</Put>
<Put name="mail.smtp.host">smtp.gmail.com</Put>
<Put name="mail.smtp.password">password</Put>
<Put name="mail.smtp.user">user</Put>
<Put name="mail.smtp.port">465</Put>
<Put name="mail.transport.protocol">smtp</Put>
<Put name="mail.smtp.auth">true</Put>
<Put name="mail.smtp.starttls.enable">true</Put>
<Put name="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</Put>
<Put name="mail.imap.host">imap.gmail.com</Put>
<Put name="mail.imap.port">993</Put>
14.10. INSTALLING LIFERAY ON JETTY 7 49
<Put name="mail.store.protocol">imap</Put>
</New>
</Set>
</New>
</Arg>
</New>
Gieat' Now youll be able to use this mail session with Lifeiay.
Conguring data sources and mail sessions
Lets ievisit youi conguiation to make suie well be able to access youi data
souice and mail session fiom Lifeiay Poital.
1. liist, navigate to the Liferay Home foldei, which is one foldei above Jeuys
install location. Cieate a le named portal-ext.properties.
2. lf you aie using Jey to manage youi data souice, add the following to youi
portal-ext.properties le in youi Liferay Home to iefei to youi data
souice
jdbc.default.jndi.name=jdbc/LiferayPool
Otheiwise, if you aie using Liferay Portal to manage youi data souice, follow
the instiuctions in the Deploy Liferay section foi using the setup wizaid.
3. lf want to use Liferay Portal to manage youi mail session, you can conguie
the mail session within Lifeiay Poital. Tat is, afei staiting youi poital as
desciibed in the Deploy Liferay section, go to Control Panel Server Admin-
istration Mail and entei the seuings foi youi mail session.
Otheiwise, if you aie using Jey to manage youi mail session, add the fol-
lowing to youi portal-ext.properties le to iefeience that mail session
mail.session.jndi.name=mail/MailSession
Lets stait youi seivei and deploy Lifeiay Poital'
40 CHAPTER 14. INSTALLATION AND SETUP
Deploy Liferay
Lifeiay can be deployed as an exploded web aichive within $JETTY_HOME/web-
apps.
1. lf you alieady have an application foldei $JETTY_HOME/webapps/root, delete
it oi move it to a location outside of $JETTY_HOME/webapps.
2. Ten extiact the contents of the Lifeiay poital .war le into $JETTY_HOME/web-
apps/root.
3. Befoie you stait Lifeiay Poital, lets considei whethei you want to also stait
the setup wizaid.
Start the setup wizard along with Liferay Portal - Do this if you want
to conguie youi poital, setup youi sites administiative account and/oi
manage youi database within Lifeiay.
lf this is youi ist time staiting Lifeiay Poital .1, the setup wizaid is invoked
on seivei staitup. lf you want to ie-iun the wizaid, specify setup.wizard.en-
abled=true in youi piopeities le (e.g. portal-setup-wizard.properties).
setup.wizard.enabled=true
Te setup wizaid is invoked duiing seivei staitup.
Start Liferay Portal without invoking the setup wizard - Do this if want
to pieseive youi cuiient poital seuings.
To stait the seivei without tiiggeiing the setup wizaid, specify setup.wiz-
ard.enabled=false in youi piopeities (e.g. portal-setup-wizard.pro-
perties oi portal-ext.properties le).
setup.wizard.enabled=false
Te portal-setup-wizard.properties le the setup wizaid cieates has
setup.wizard.enabled=false conveniently specied foi you.
WebLogic 10.0 suppoits JDK 1. but does not suppoit JDK 1..
Now that you have all of youi installation les, you aie ieady to stait in-
stalling and conguiing Lifeiay on WebLogic.
18
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 01
Dependency Jars
Lifeiay iequiies seveial .jar les including the Lifeiay Dependency JARs and
a JAR le foi youi database diivei. Te following steps desciibe how to install
these .jar les piopeily.
1. Navigate to the foldei which coiiesponds to the domain to which you will
be installing Lifeiay. lnside this foldei is a lib foldei. Unzip the Lifeiay de-
pendencies aichive to this foldei so the dependency .jar les aie extiacted
into the lib foldei.
2. lf WebLogic does not alieady have access to the JDBCdiivei foi youi database,
copy the diivei to youi domains lib foldei as well.
3. You will also need the xercesImpl.jar copied to youi domains lib foldei
oi you will get SAX paising eiiois afei you deploy Lifeiay. You may down-
load this fiom hup//xeices.apache.oig.
4. Cieate a foldei $WEBLOGIC-HOME/jrockit_150_15/jre/lib/endorsed.
Ten copy commons-lang.jar, liferay-rhino.jar, serializer.jar
and xalan.jar to the endoised foldei you just cieated.
Now that you have youi WebLogic installation is loaded up with JAR les
foi Lifeiay to use, lets considei how to conguie youi database.
Database Conguration
lf you want WebLogic to manage youi data souice, use the following pioceduie.
lf you want to use Lifeiays built-in data souice, you can skip this section.
1. Biowse to youi WebLogic Console. Click the Lock & Edit buuon above the
Domain Stiuctuie tiee on the lef side of the page.
2. liom the Domain Stiuctuie tiee on the lef, select Data Sources. Ten click
the New buuon on the iight side of the scieen.
3. Give the Data Souice a name, such as LiferayDataSource.
4. Dene the JNDl name as jdbc/LiferayPool.
. Select youi Database Type, the Diivei class and then click the Next buuon.
. Accept the defaults on the next scieen by clicking Next.
02 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.41: WebLogic Data Sources
. On the next scieen, put in youi Database Name, Host Name, Database User
Name and Password. lf you have been following the defaults we have been
using so fai, you would use lportal, localhost, root, and no passwoid as the
values. Click Next.
8. Te next scieen allows you to test youi database conguiation. Click the Test
Conguration buuon. lf the test succeeds, you have conguied youi database
coiiectly. Select the check box of the seivei to which you want to deploy this
Data Souice (AdminServer is the default). Click Finish.
9. Click the Activate Changes buuon on the lef, above the Domain Stiuctuie
tiee.
Gieat woik' Youi data souice can now be managed fiom within WebLogic.
Next, lets considei the mail session foi youi domain.
Mail Conguration
lf you want WebLogic to manage youi mail sessions, use the following pio-
ceduie. lf you want to use Lifeiays built-in mail sessions, you can skip this
section.
1. ln the Domain Stiuctuie tiee, select Mail Sessions. Ten click the Lock & Edit
buuon again to enable modifying these seuings.
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 03
Figure 14.42: WebLogic: Mail Sessions
2. Click the New buuon which is now enabled on the iight side of the scieen.
3. Give the Mail Session a name, such as LiferayMail.
4. Select youi new LifeiayMail session fiom the list by clicking on it.
. On the scieen that appeais, dene the JNDl name as mail/MailSession
and set youi JavaMail piopeities. Click the Save buuon.
. Click the Targets tab. Select the check box of the seivei to which you want
deploy this Data Souice to (AdminSeivei is the default).
. Click the Activate Changes buuon on the lef side of the scieen, above the
Domain Stiuctuie tiee.
Now you have youi mail session specied and ieady foi Lifeiay to use.
Domain Conguration - Continued
Lets ievisit domain conguiation to make suie well be able to access youi data
souice and mail session fiom Lifeiay Poital.
1. liist, navigate to the Liferay Home foldei.
04 CHAPTER 14. INSTALLATION AND SETUP
2. Ten, if you aie using WebLogic to manage youi data souice, add the follow-
ing to youi portal-ext.properties le in youi Liferay Home to iefei to
youi data souice
jdbc.default.jndi.namejdbc/LifeiayPool
Otheiwise, if you aie using Liferay Portal to manage youi data souice, follow
the instiuctions in the Deploy Liferay section foi using the setup wizaid.
3. lf want to use Liferay Portal to manage youi mail session, you can conguie
the mail session within Lifeiay Poital. Tat is, afei staiting youi poital as
desciibed in the Deploy Liferay section, go to Control Panel Server Admin-
istration Mail and entei the seuings foi youi mail session.
Otheiwise, if you aie using WebLogic to manage youi mail session, add the
following to youi portal-ext.properties le to iefeience that mail session
mail.session.jndi.name=mail/MailSession
Lifeiay can now communicate with youi data souice and mail session. lts
now time to deploy Lifeiay'
Deploy Liferay
lollow the instiuctions in this section to deploy Lifeiay Poital to youi domain.
Befoie you deploy Lifeiay Poital, considei whethei you want to use the setup
wizaid.
Start the setup wizard along with Liferay Portal - Do this if you want
to conguie youi poital, set up youi sites administiative account and/oi
manage youi database within Lifeiay.
lf this is youi ist time staiting Lifeiay Poital .1, the setup wizaid is in-
voked on seivei staitup. lf you want to ie-iun the wizaid, specify setup.wiz-
ard.enabled=true in youi piopeities le (e.g. portal-setup-wizard.pro-
perties).
setup.wizard.enabled=true
Te setup wizaid is invoked duiing seivei staitup.
Start Liferay Portal without invoking the setup wizard - Do this if you
want to pieseive youi cuiient poital seuings.
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 0
To stait the seivei without tiiggeiing the setup wizaid, specify setup.wiz-
ard.enabled=false in youi piopeities (e.g. portal-setup-wizard.pro-
perties oi portal-ext.properties le).
setup.wizard.enabled=false
Te portal-setup-wizard.properties le the setup wizaid cieates has
setup.wizard.enabled=false conveniently specied foi you.
Teie is a known issue with the Sun and JRockit JVMs bun-
dled with WebLogic 10.3.2.
20
To iesolve, use Sun JVM 1..0u24
oi JRockit JVM 1..024.
Lets get staited by installing the JAR les Lifeiay needs.
Dependency Jars
Lifeiay needs the JAR les contained in the Lifeiay Dependencies Aichive and
the diivei JAR le applicable foi youi database.
1. Navigate to the foldei that coiiesponds to the domain to which you will be
installing Lifeiay. lnside this foldei is a lib foldei. Unzip the Lifeiay De-
pendencies Aichive to this foldei so the dependency .jar les ieside in the
lib foldei.
2. lf WebLogic does not alieady have access to the JDBCdiivei foi youi database,
copy the diivei to youi domains lib foldei as well.
So fai so good. Youi JAR les aie in place and ieady foi Lifeiay.
Stait Oiacle WebLogic if you want to conguie youi database and/oi mail
session within Oiacle WebLogic.
Database Conguration
lf you want WebLogic to manage youi data souice, use the following pioceduie.
lf you want to use Lifeiays built-in data souice, you can skip this section.
1. Select Services Data Sources. Click New Generic Data Source.
2. Give youi data souice a name, such as Liferay Data Source. Te JNDl name
should be jdbc/LiferayPool.
3. Choose the type of database and click Next. liomthe scieenshot, you can see
we have chosen MySQL. Te database diivei class is selected automatically.
4. Click Next thiee times. You should be on the Connection Properties scieen.
Entei the database name, the host name, the poit, the database usei name and
the passwoid. WebLogic uses this infoimation to constiuct the appiopiiate
JDBC URL to connect to youi database. Click Next.
08 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.44: WebLogic Data Sources
. WebLogic next conims the infoimation you piovided. loi MySQL, some
additional paiameteis must be added to the URL. Modify the JDBC URL so
it has the piopei paiameteis. Piovide youi database name, host name, usei
name and passwoid as the values. Click Next.
. Click Test Conguration to make suie WebLogic can connect to youi database
successfully. When it does, click Finish.
. You will be back to the list of data souices. Notice youi new data souice has
no value in the Target column. Click on youi data souice to edit it.
8. Click the Targets tab and check o the seivei instance(s) to which you wish
to deploy youi data souice. Ten click Save.
Next, lets conguie a mail session in WebLogic.
Mail Conguration
lf you want WebLogic to manage youi mail sessions, use the following pio-
ceduie. lf you want to use Lifeiays built-in mail sessions, you can skip this
section.
14.17. INSTALLING LIFERAY ON ORACLE WEBLOGIC 10.3 09
Figure 14.45: Creating a data source in WebLogic 10.3
1. Select Mail Sessions and cieate a new mail session which points to youi mail
seivei.
2. Give it the name Lifeiay Mail and give it the JNDl name of mail/MailSession
and click Next.
3. Choose youi seivei and then click Finish.
Now lets make suie Lifeiay can access this mail session.
10 CHAPTER 14. INSTALLATION AND SETUP
Figure 14.46: WebLogic Mail Sessions
Domain Conguration - Continued
Lets ievisit domain conguiation to make suie well be able to access youi data
souice and mail session fiom Lifeiay Poital.
1. Cieate a portal-ext.properties le in the Lifeiay Home foldei, which is
one foldei up fiom youi domains home foldei.
lf you aie using WebLogic to manage youi data souice, add the following
to youi portal-ext.properties le in Liferay Home to iefei to youi data
souice
jdbc.default.jndi.name=jdbc/LiferayPool
lf you aie using Liferay Portal to manage youi data souice, follow the in-
stiuctions in the Deploy Liferay section foi using the setup wizaid.
lf want to use Liferay Portal to manage youi mail session, you can conguie
the mail session in the Contiol Panel. Afei staiting youi poital as desciibed in
the Deploy Liferay section, go to Control Panel Server Administration Mail
and entei the seuings foi youi mail session.
lf you aie using WebLogic to manage youi mail session, add the following to
youi portal-ext.properties le to iefeience that mail session
14.17. INSTALLING LIFERAY ON ORACLE WEBLOGIC 10.3 11
mail.session.jndi.name=mail/MailSession
2. Lastly, you must piovide WebLogic a iefeience to Java Seivei laces (JSl)
to use that libiaiy. lnseit the following deployment desciiptoi within the
<weblogic-web-app> element of WEB-INF/weblogic.xml found in youi
Lifeiay Poital .war
<library-ref>
<library-name>jsf</library-name>
<specification-version>1.2</specification-version>
<implementation-version>1.2</implementation-version>
<exact-match>false</exact-match>
</library-ref>
Now its the moment youve been waiting foi Lifeiay deployment'
Deploy Liferay
lollow the instiuctions in this section to deploy Lifeiay Poital to youi domain.
Befoie you deploy Lifeiay Poital, considei whethei you want to use the setup
wizaid.
Start the setup wizard along with Liferay Portal - Do this if you want
to conguie youi poital, set up youi sites administiative account and/oi
manage youi database within Lifeiay.
lf this is youi ist time staiting Lifeiay Poital .1, the setup wizaid is in-
voked on seivei staitup. lf you want to ie-iun the wizaid, specify setup.wiz-
ard.enabled=true in youi piopeities le (e.g. portal-setup-wizard.pro-
perties).
setup.wizard.enabled=true
Te setup wizaid is invoked duiing seivei staitup.
Start Liferay Portal without invoking the setup wizard - Do this if you
want to pieseive youi cuiient poital seuings.
To stait the seivei without tiiggeiing the setup wizaid, specify setup.wiz-
ard.enabled=false in youi piopeities (e.g. portal-setup-wizard.pro-
perties oi portal-ext.properties le).
setup.wizard.enabled=false
12 CHAPTER 14. INSTALLATION AND SETUP
Te portal-setup-wizard.properties le the setup wizaid cieates has
setup.wizard.enabled=false conveniently specied foi you.
Note Piioi to Lifeiay veision .0, Powei Useis and Useis did
not have the same default peimissions. So if aie using Lifeiay .2
oi a pievious veision, its dangeious to iemove the Powei Useis
iole fiom the default usei associations this could iemove cei-
tain peimissions you expect to apply to all useis. lf you decide
to iemove the Powei Useis iole fiom the default usei associa-
tions anyway, you will piobably want to modify the peimissions
on ceitain poitlets to make them accessible to all useis. To do this, see the
section on Plugins Conguiation below.
15.6. MANAGING PORTAL SETTINGS 4
Now that weve seen how to use oiganizations and usei gioups to manage
useis and howto use ioles to dene peimissions, lets examine the geneial poital
seuings you can conguie.
15.6 Managing Portal Settings
Afei you have cieated useis, usei gioups, oiganizations, ioles, sites and teams
youi poital will be ieady to host content and applications. You can conguie Lif-
eiays poital seuings to t youi enviionment and youi paiticulai poital pioject.
Many conguiations can be peifoimed thiough Lifeiays poitlet-diiven usei in-
teiface. Tis section coveis how to conguie poital seuings such as passwoid
policies, authentication seuings, mail host names, email notications, display
seuings and monitoiing.
Nowthat you have been navigating in the contiol panel, you should be pieuy
familiai with howit woiks. All the options appeai in the lefnavigation, theii in-
teifaces appeai in the middle and any sub-options appeai on the iight. We have
focused so fai on the maintenance of useis and poital secuiity. Te iemaining
links in the Portal categoiy focus on vaiious poital seuings which covei how
the poital opeiates and integiates with othei systems you may have. Lets be-
gin oui discussion of Lifeiays poital seuings by examining how to conguie
passwoid policies.
Password Policies
Passwoid policies can enhance the secuiity of youi poital. You can set iequiie-
ments on passwoid stiength, fiequency of passwoid expiiation and moie. Ad-
ditionally, you can apply dieient passwoid policies to dieient sets of poital
useis.
lf you aie viewing a page othei than the contiol panel, select Control Panel
fiom the Go to menu of the Dockbai. Next, click on the Password Policies link on
the lef side of the scieen undei the Portal heading. You will see theie is alieady
a default passwoid policy in the system. You can edit this in the same mannei
as you edit othei iesouices in the poital click Actions and then click Edit.
Te Passwoid Policy seuings foim contains the following elds. Enabling
specic seuings via the check boxes piompts seuing-specc options to appeai.
Name: iequiies you to entei a name foi the passwoid policy.
Description: lets you desciibe the passwoid policy so othei administiatois
will know what its foi.
48 CHAPTER 15. MANAGEMENT
Changeable: deteimines whethei oi not a usei can change his oi hei pass-
woid.
Change Required: deteimines whethei oi not a usei must change his oi hei
passwoid afei logging into the poital foi the ist time.
Minimum Age: lets you choose how long a passwoid must iemain in eect
befoie it can be changed.
Reset Tiet Max Age: deteimines how long a passwoid ieset link iemains
valid.
Password Syntax Cheing: allows you to set a minimum passwoid length
and to choose whethei oi not dictionaiy woids can be in passwoids. You can
also specify detailed iequiiements such as minimum numbeis of alpha numeiic
chaiacteis, lowei case leueis, uppei case leueis, numbeis oi symbols.
Password History: lets you keep a histoiy (with a dened length) of pass-
woids and pievents useis fiom changing theii passwoids to one that was pie-
viously used.
Password Expiration: lets you choose how long passwoids can iemain ac-
tive befoie they expiie. You can select the age, the waining time and a giace
limit.
Loout: allows you to set a numbei of failed log-in auempts that tiiggeis
a useis account to lock. You can choose whethei an administiatoi needs to
unlock the account oi if it becomes unlocked afei a specic duiation.
liom the list of passwoid policies, you can peifoim seveial othei actions.
Edit: biings you to the foim above and allows you to modify the passwoid
policy.
Permissions: allows you to dene which useis, usei gioups oi ioles have
peimission to edit the passwoid policy.
Assign Members: takes you to a scieen wheie you can seaich and select
useis in the poital to be assigned to this passwoid policy. Te passwoid policy
will be enfoiced foi any useis who aie added heie.
Delete: shows up foi any passwoid policies you add beyond the default pol-
icy. You cannot delete the default policy.
Next, lets examine Lifeiays Poital Seuings.
Portal Settings
Most global poital seuings can be conguied fiom the Poital Seuings section of
the contiol panel. Te Conguiation heading contains the following links
General: lets you conguie global seuings, such as the company name, do-
main, the viitual host, a global poital logo and moie.
15.6. MANAGING PORTAL SETTINGS 49
Authentication: allows you to conguie log in lDs, connection to LDAP and
Single Sign-On.
Users: has thiee tabs, labeled lields, Reseived Ciedentials and Default Usei
Associations. Te lields tab enables oi disables some usei elds, such as biith-
day oi teims of use. Te Reseived Ciedentials tab lets you ieseive scieen names
and email addiesses so useis cannot iegistei using them. You might use this
to pievent useis fiom iegisteiing on the poital with usei names that contain
piofanity oi that sound ocial, such as admin oi president. Te Default Usei
Associations tab lets you conguie default membeiship to ioles, usei gioups,
sites foi new useis and piovides a check box which allows you to ietioactively
apply these to existing useis.
Mail Host Names: lets you add a list of othei mail host names to be as-
sociated with youi oiganization. loi example, youi main domain might be
mycompany.com but you might use mycompany-marketing.com foi youi email
newsleueis. Any domain names associated with youi oiganization can go heie.
Email Notications: allows you to conguie Lifeiay to send email notica-
tions foi ceitain events, such as usei iegistiations, passwoid changes, etc. You
can customize those messages heie.
Figure 15.13: Portal Settings Pages
0 CHAPTER 15. MANAGEMENT
Lets discuss these seuings next.
General
Te Geneial link takes you to a page with thiee headings Main Conguiation,
Navigation and Additional lnfoimation. Undei the Main Conguiation heading,
you can set the name of the company, oiganization oi site which is iunning the
poital. Tis name also denes the name of youi poitals default site. lts default
name is liferay.com so you will denitely want to set this to ieect youi own
company. You can also set the mail domain, viitual host and content deliveiy
netwoik addiess heie. Undei the Navigation heading, you can set a home page
foi youi poital heie as well as default landing and logout pages. Undei the
Additional lnfoimation heading, you can specify a Legal name, lD, company
type, SlC code, tickei symbol, industiy and industiy type.
Authentication
Te Authentication page has seveial tabs Geneial, LDAP, CAS, lacebook, NTLM,
OpenlD, Open SSO and SiteMindei. You can use any of these authentication
methods to conguie how useis will authenticate to Lifeiay. Since Lifeiay sup-
poits quite a few authentication methods, theie aie dieient seuings foi each.
Te seuings on the Geneial tab of the Authentication page aect only Lif-
eiay functionality and dont have anything to do with the integiation options
on the othei tabs. Te Geneial tab allows you to customize Lifeiays standaid
authentication behavioi. Specically, the Geneial tab allows you to select fiom
seveial global authentication seuings
Authenticate via email addiess (default), scieen name oi usei lD (a nu-
meiical lD auto-geneiated in the database not iecommended).
Enable/Disable automatic log in. lf enabled, Lifeiay allows a usei to check
a box which will cause the site to iemembei the useis log in by placing
a cookie on his oi hei biowsei. lf disabled, useis will always have to log
in manually.
Enable/Disable foigouen passwoid functionality.
Enable/Disable iequest passwoid ieset links.
Enable/Disable account cieation by stiangeis. lf you aie iunning an ln-
teinet site, you will piobably want to leave this on so visitois can cieate
accounts on youi site.
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 1
Enable/Disable account cieation by those using an email addiess in the
domain of the company iunning the site (which you just set on the Gen-
eial page of Poital Seuings). Tis is handy if you aie using Lifeiay to host
both inteinal and exteinal web sites. You can make suie all inteinal lDs
have to be cieated by administiatois but exteinal useis can iegistei foi
lDs themselves.
Enable / Disable email addiess veiication. lf you enable this, Lifeiay will
send useis a veiication email with a link back to the poital to veiify the
email addiess they enteied is a valid one they can access.
By default, all seuings except foi the last aie enabled. Usei authentication
by email addiess is an impoitant default foi the following ieasons
1. An email addiess is, by denition, unique to the usei who owns it.
2. People can geneially iemembei theii email addiesses. lf you have useis who
havent logged into the poital foi a while, it is possible they will foiget theii
scieen names, especially if they weient allowed to use theii scieen names
of choice (because they weie alieady taken).
3. lf a usei changes his oi hei email addiess, it is moie likely the usei will foiget
to update his oi hei email addiess in his oi hei piole, if the email addiess
is not used to authenticate. lf the useis email addiess is not updated, all
notications sent by the poital will fail to ieach the usei. So it is impoitant
to keep the email addiess at the foiefiont of a useis mind when he oi she
logs in to help the usei keep it up to date.
Well examine how to set up LDAP authentication next.
15.7 Integrating Liferay users into your enterprise
LDAP
You can use the LDAP tab of the Authentication page to connect Lifeiay to an
LDAP diiectoiy. Teie aie two places foi you to conguie the LDAP seuings
heie in the contiol panel oi in the portal-ext.properties le (which is cov-
eied in chaptei 20). We iecommend you use the contiol panel since youi cong-
uiation seuings will be stoied in the database. Note that if you use both, the set-
tings in the database will be meiged with the seuings in portal-ext.properties.
lf theies a conict oi oveilapping data, the LDAP seiveis set in the contiol panel
2 CHAPTER 15. MANAGEMENT
take piecedence ovei the seiveis set in portal-ext.properties. Conguiing
the LDAP seuings fiom the contiol panel is easiei and does not iequiie a iestait
of Lifeiay. Te only compelling ieason to use the portal-ext.properties
le is if you have many Lifeiay nodes which will be conguied to iun against
the same LDAP diiectoiy. ln that case, foi youi initial deployment, it may be
easiei to copy the portal-ext.properties le to all of the nodes so the ist
time they stait up, the seuings aie coiiect. Regaidless of which method you
use, the available seuings aie the same.
You conguie the global values fiom the LDAP tab of the Authentication
page.
Enabled: Check this box to enable LDAP Authentication.
Required: Check this box if LDAP authentication is iequiied. Lifeiay will
then not allow a usei to log in unless he oi she can successfully bind to the
LDAP diiectoiy ist. Uncheck this box if you want to allow useis with Lifeiay
accounts but no LDA accounts to log in to the poital.
LDAP Servers: Lifeiay suppoits connections to multiple LDAP seiveis. You
can you the Add buuon beneath this heading to add LDAP seiveis. We explain
how to conguie new LDAP seiveis below.
Import/Export: You can impoit and expoit usei data fiom LDAP diiectoiies
using the following options
Import Enabled: Check this box to cause Lifeiay to do a mass impoit
fiom youi LDAP diiectoiies. lf you want Lifeiay to only synchionize
useis when they log in, leave this box unchecked. Denitely leave this
unchecked if you aie woiking in a clusteied enviionment. Otheiwise, all
of youi nodes would tiy to do a mass impoit when each of them staits
up.
Import on Startup Enabled: Check this box to have Lifeiay iun the impoit
when it staits up. Note Tis box only appeais if you check the Import
Enabled box above.
Export Enabled: Check this box to enable Lifeiay to expoit usei accounts
fiom the database to LDAP. Lifeiay uses a listenei to tiack any changes
made to the User object and will push these changes out to the LDAP
seivei whenevei the User object is updated. Note that by default on ev-
eiy login, elds such as LastLoginDate aie updated. When expoit is
enabled, this has the eect of causing a usei expoit eveiy time the usei
logs in. You can disable this by seuing the following piopeity in youi
portal-ext.properties le
useis.update.last.loginfalse
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 3
Use LDAP Password Policy: Lifeiay uses its own passwoid policy by default.
Tis can be conguied on the Passwoid Policies page of the contiol panel. Check
the Use LDAP Password Policy box if you want to use the passwoid policies de-
ned by youi LDAP diiectoiy. Once this is enabled, the Passwoid Policies tab
will display a message stating you aie not using a local passwoid policy. You
will now have to use youi LDAP diiectoiys mechanism foi seuing passwoid
policies. Lifeiay does this by paising the messages in the LDAP contiols ie-
tuined by youi LDAP seivei. By default, the messages in the LDAP contiols
that Lifeiay is looking foi aie the messages ietuined by the ledoia Diiectoiy
Seivei. lf you aie using a dieient LDAP seivei, you will need to customize the
messages in Lifeiays portal-ext.properties le, as theie is not yet a GUl
foi seuing this. See below foi instiuctions desciibing how to do this.
Once youve nished conguiing LDAP, click the Save buuon. Next, lets
look at how to add LDAP seiveis.
Adding LDAP Servers
Te Add buuon beneath the LDAP seiveis heading allows you to add LDAP
seiveis. lf you have moie than one, you can aiiange the seiveis by oidei of
piefeience using the up/down aiiows. When you add an LDAP Seivei, you will
need to piovide seveial pieces of data so Lifeiay can bind to that LDAP seivei
and seaich it foi usei iecoids. Regaidless of how many LDAP seiveis you add,
each seivei has the same conguiation options.
Server Name: Entei a name foi youi LDAP seivei.
Default Values: Seveial leading diiectoiy seiveis aie listed heie. lf you aie
using one of these, select it and click the Reset Values buuon. Te iest of the
foim will be populated with the piopei default values foi that diiectoiy.
Connection: Tese seuings covei the basic connection to LDAP.
Base Provider URL: Tis tells the poital wheie the LDAP seivei is located.
Make suie the machine on which Lifeiay is installed can communicate
with the LDAP seivei. lf theie is a iewall between the two systems,
check to make suie the appiopiiate poits aie opened.
Base DN: Tis is the Base Distinguished Name foi youi LDAP diiectoiy.
lt is usually modeled afei youi oiganization. loi a commeicial oigani-
zation, it may look similai to this dc=companynamehere,dc=com.
Principal: By default, the administiatoi lD is populated heie. lf you have
iemoved the default LDAP administiatoi, you will need to use the fully
qualied name of the administiative ciedential you use instead. You need
4 CHAPTER 15. MANAGEMENT
an administiative ciedential because Lifeiay will be using this lD to syn-
chionize usei accounts to and fiom LDAP .
Credentials: Tis is the passwoid foi the administiative usei.
Tis is all you need to make a iegulai connection to an LDAP diiectoiy. Te
iest of the conguiation is optional. Geneially, the default auiibute mappings
piovide enough data to synchionize back to the Lifeiay database when a usei
auempts to log in. To test the connection to youi LDAP seivei, click the Test
LDAP Connection buuon.
lf you aie iunning youi LDAP diiectoiy in SSL mode to pievent ciedential
infoimation fiom passing thiough the netwoik unenciypted, you will have to
peifoim extia steps to shaie the enciyption key and ceiticate between the two
systems.
loi example, assuming youi LDAP diiectoiy happens to be Miciosof Active
Diiectoiy on Windows Seivei 2003, you would take the following steps to shaie
the ceiticate
Click Stait - Administiative Tools Siaii, Ceiticate Authoiity. Highlight
the machine that is the ceiticate authoiity, iight click on it, and click Piop-
eities. liom the Geneial menu, click View Ceiticate. Select the Details view,
and click Copy To lile. Use the iesulting wizaid to save the ceiticate as a le.
As with the CAS install (see the below section entitled Single Sign-On), you will
need to impoit the ceiticate into the cacerts keystore. Te impoit is handled by
a command like the following
keytool -import -trustcacerts -keystore /some/path/jdk1.5.0_11/jre/ \
lib/security/cacerts -storepass changeit -noprompt -alias MyRootCA \
-file /some/path/MyRootCA.cer
Te keytool utility ships as pait of the Java SDK.
Once this is done, go back to the LDAP page in the contiol panel. Modify the
LDAP URL in the Base DN eld to the secuie veision by changing the piotocol
to https and the poit to 636 like the following
ldaps://myLdapServerHostname:636
Save the changes. Youi Lifeiay Poital will now use LDAP in secuie mode foi
authentication.
Users: Tis section contains seuings foi nding useis in youi LDAP diiec-
toiy.
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE
Authentication Search Filter: Te seaich ltei box can be used to detei-
mine the seaich ciiteiia foi usei logins. By default, Lifeiay uses useis
email addiesses foi theii login names. lf you have changed this seuing,
you will need to modify the seaich ltei heie, which has been conguied
to use the email addiess auiibute fiom LDAP as a seaich ciiteiion. loi
example, if you changed Lifeiays authentication method to use scieen
names instead of the email addiesses, you would modify the seaich ltei
so it can match the enteied log in name
(cn=@screen\_name@)
Import Search Filter: Depending on the LDAP seivei, theie aie dieient
ways to identify the usei. Geneially, the default seuing
1
is ne but if you
want to seaich foi only a subset of useis oi useis that have dieient object
classes, you can change this.
User Mapping: Te next seiies of elds allows you to dene mappings
fiomLDAP auiibutes to Lifeiay elds. Tough youi LDAP usei auiibutes
may be dieient fiom LDAP seivei to LDAP seivei, theie aie ve elds
Lifeiay iequiies to be mapped foi the usei to be iecognized. You must de-
ne a mapping to the coiiesponding auiibutes in LDAP foi the following
Lifeiay elds
Screen Name
Password
Email Address
Full Name
First Name
Middle Name
Last Name
Job Title
Group
Te contiol panel piovides default mappings foi commonly used LDAP at-
tiibutes. You can also add youi own mappings if you wish.
1
objectClass=inetOrgPerson
CHAPTER 15. MANAGEMENT
Test LDAP Users: Once you have youi auiibute mappings set up (see
above), click the Test LDAP Users buuon and Lifeiay will auempt to pull
LDAP useis and match them with theii mappings as a pieview.
Figure 15.14: Testing LDAP Users
Groups: Tis section contains seuings foi mapping LDAP gioups to Lifeiay.
Import Search Filter: Tis is the ltei foi nding LDAP gioups you want
to map to Lifeiay. Entei the LDAP gioup auiibutes you want ietiieved
foi this mapping. Te following auiibutes can be mapped
Gioup Name
Desciiption
Usei
Test LDAP Groups: Click the Test LDAP Groups to display a list of the
gioups ietuined by youi seaich ltei.
Export: Tis section contains seuings foi expoiting usei data fiom LDAP.
Users DN: Entei the location in youi LDAP tiee wheie the useis will be
stoied. When Lifeiay does an expoit, it will expoit the useis to this loca-
tion.
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE
User Default Object Classes: When a usei is expoited, the usei is cieated
with the listed default object classes. To nd out what youi default object
classes aie, use an LDAP biowsei tool such as JXploiei to locate a usei
and view the Object Class auiibutes stoied in LDAP foi that usei.
Groups DN: Entei the location in youi LDAP tiee wheie the gioups will
be stoied. When Lifeiay does an expoit, it will expoit the gioups to this
location.
Group Default Object Classes: When a gioup is expoited, the gioup is cie-
ated with the listed default object classes. To nd out what youi default
object classes aie, use an LDAP biowsei tool such as Jxplorer to locate a
gioup and view the Object Class auiibutes stoied in LDAP foi that gioup.
Figure 15.15: Mapping LDAP Groups
Once youve set all youi options and tested youi connection, click Save.
liom heie, you can add anothei LDAP seivei oi set just a few moie options
that apply to all of youi LDAP seivei connections.
LDAP Options Not Available in the GUI
Although most of the LDAP conguiation can be done fiom the contiol panel,
theie aie seveial conguiation paiameteis that aie only available by editing
portal-ext.properties. Tese options will be available in the GUl in futuie
8 CHAPTER 15. MANAGEMENT
veisions of Lifeiay Poital but foi now they can only be conguied by editing
the piopeities le.
lf you need to change any of these options, copy the LDAP section fiom the
portal.properties le into youi portal-ext.properties le. Note that
since you have alieady conguied LDAP fiom the GUl, any seuings fiom the
piopeities le that match seuings alieady conguied in the GUl will be ignoied.
Te GUl, which stoies the seuings in the database, always takes piecedence ovei
the piopeities le.
ldap.auth.method=bind #ldap.auth.method=password-compare
Set eithei bind oi passwoid-compaie foi the LDAP authentication method.
Bind is piefeiied by most vendois so you dont have to woiiy about enciyp-
tion stiategies. Passwoid compaie does exactly what it sounds like it ieads
the useis passwoid out of LDAP, deciypts it and compaies it with the useis
passwoid in Lifeiay, syncing the two.
ldap.auth.password.encryption.algorithm=
ldap.auth.password.encryption.algorithm.types=MD5,SHA
Set the passwoid enciyption to used to compaie passwoids if the piopeity
ldap.auth.method is set to password-compare.
ldap.import.method=[user,group]
lf you set this to user, Lifeiay will impoit all useis fiomthe specied poition
of the LDAP tiee. lf you set this to group, Lifeiay will seaich all the gioups and
impoit the useis in each gioup. lf you have useis who do not belong to any
gioups, they will not be impoited.
ldap.error.password.history=history
ldap.error.password.not.changeable=not allowed to change
ldap.error.password.syntax=syntax ldap.error.password.trivial=trivial
ldap.error.user.lockout=retry limit
ldap.error.password.age=age ldap.error.password.expired=expired
Tese piopeities aie a list of phiases fiomeiioi messages which can possibly
be ietuined by the LDAP seivei. When a usei binds to LDAP, the seivei can
ietuin controls with its iesponse of success oi failuie. Tese contiols contain a
message desciibing the eiioi oi the infoimation that is coming back with the
iesponse. Tough the contiols aie the same acioss LDAP seiveis, the messages
can be dieient. Te piopeities desciibed heie contain snippets of woids fiom
those messages and will woik with Red Hats ledoia Diiectoiy Seivei. lf you aie
not using that seivei, the woid snippets may not woik with youi LDAP seivei.
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 9
lf they dont, you can ieplace the values of these piopeities with phiases fiom
youi seiveis eiioi messages. Tis will enable Lifeiay to iecognize them. Next,
lets look at the Single Sign-On solutions Lifeiay suppoits.
SSO
Single Sign-On solutions allow you to piovide a single login ciedential foi mul-
tiple systems. Tis allows you to have people authenticate to the Single Sign-On
pioduct and they will be automatically logged in to Lifeiay and to othei pioducts
as well.
Lifeiay suppoits seveial single sign-on solutions. Of couise, if youi pioduct
is not yet suppoited, you may choose to implement suppoit foi it youiself by
use of the extension enviionment. Alteinatively, youi oiganization can choose
to sponsoi suppoit foi it. Please contact sales@liferay.com foi moie infoi-
mation about this.
Authentication: Central Authentication Service (CAS)
CAS is an authentication system oiiginally cieated at Yale Univeisity. lt is a
widely-used open souice single sign-on solution and was the ist SSO pioduct
to be suppoited by Lifeiay.
Please follow the documentation foi CAS to install it on youi application
seivei of choice.
Youi ist step will be to copy the CAS client .jai le to Lifeiays libiaiy
foldei. On Tomcat, this is in [Tomcat Home]/webapps/ROOT/WEB-INF/lib.
Once youve done this, the CAS client will be available to Lifeiay the next time
you stait it.
Te CAS Seivei application iequiies a piopeily conguied Secuie Socket
Layei ceiticate on youi seivei to woik. lf you wish to geneiate one youiself,
you will need to use the keytool utility that comes with the JDK. Youi ist step
is to geneiate the key. Next, you expoit the key into a le. linally, you impoit
the key into youi local Java key stoie. loi public, lnteinet-based pioduction
enviionments, you will need to eithei puichase a signed key fiom a iecognized
ceiticate authoiity (such as Tawte oi Veiisign) oi have youi key signed by a
iecognized ceiticate authoiity. loi lntianets, you should have youi lT depait-
ment pie-conguie useis biowseis to accept the ceiticate so they dont get
waining messages about the ceiticate.
To geneiate a key, use the following command
keytool -genkey -alias tomcat -keypass changeit -keyalg RSA
0 CHAPTER 15. MANAGEMENT
lnstead of the passwoid in the example (changeit), use a passwoid you will
iemembei. lf you aie not using Tomcat, you may want to use a dieient alias
as well. loi liist and Last names, entei localhost oi the host name of youi
seivei. lt cannot be an lP addiess.
To expoit the key to a le, use the following command
keytool -export -alias tomcat -keypass changeit -file server.cert
linally, to impoit the key into youi Java key stoie, use the following com-
mand
keytool -import -alias tomcat -file %FILE_NAME% -keypass changeit -keystore \
\$JAVA\_HOME/jre/lib/security/cacerts
lf you aie on a Windows system, ieplace $JAVA_HOME above with %JAVA_HOME%.
Of couise, all of this needs to be done on the system on which CAS will be iun-
ning.
Once youi CAS seivei is up and iunning, you can conguie Lifeiay to use it.
Tis is a simple mauei of navigating to the Seings Authentication CAS
tab in the contiol panel. Enable CAS authentication and then modify the URL
piopeities to point to youi CAS seivei.
Enabled: Check this box to enable CAS single sign-on.
Import fromLDAP: Ausei may be authenticated fiomCAS and not yet exist
in the poital. Select this to automatically impoit useis fiom LDAP if they do not
exist in the poital.
Te iest of the seuings aie vaiious URLs, with defaults included. Change lo-
calhost in the default values to point to youi CAS seivei. When you aie nished,
click Save. Afei this, when useis click the Sign In link, they will be diiected to
the CAS seivei to sign in to Lifeiay.
Authentication: Facebook
Lifeiay Poital also enables useis to log in using theii lacebook accounts. To
enable this featuie, you simply need to select the Enable box and entei the Ap-
plication lD and Application Seciet which should have been piovided to you by
lacebook. lacebook SSO woiks by taking the piimaiy lacebook email addiess
and seaiching foi the same email addiess in Lifeiays User_ table. lf a match is
found, the usei is automatically signed on (piovided the usei clicked allow fiom
the lacebook dialog). lf theie isnt a match, the usei is piompted in Lifeiay to
add a usei fiom lacebook. Once selected, a new usei is cieated by ietiieving
foui elds fiom lacebook (ist name, last name, email addiess and gendei).
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 1
Authentication: NTLM
NTLM is a Miciosof piotocol that can be used foi authentication thiough Mi-
ciosof lnteinet Exploiei. Tough Miciosof has adopted Keibeios in modein
veisions of Windows seivei, NTLM is still used when authenticating to a woik-
gioup. Lifeiay Poital now suppoits NTLM v2 authentication. NTLM v2 is moie
secuie and has a stiongei authentication piocess than NTLMv1.
Enabled: Check this box to enable NTLM authentication.
Domain Controller: Entei the lP addiess of youi domain contiollei. Tis is
the seivei that contains the usei accounts you want to use with Lifeiay.
Domain: Entei the domain / woikgioup name.
Service Account: You need to cieate a seivice account foi NTLM. Tis ac-
count will be a computei account, not a usei account.
Service Password: Entei the passwoid foi the seivice account.
Authentication: OpenID
OpenlD is a new single sign-on standaid which is implemented by multiple
vendois. Te idea is multiple vendois can implement the standaid and then
useis can iegistei foi an lD with the vendoi they tiust. Te ciedential issued
by that vendoi can be used by all the web sites that suppoit OpenlD. Some high
piole OpenlD vendois aie
AOL hup//openid.aol.com/scieenname
LiveDooi hup//piole.livedooi.com/useiname
LiveJouinal hup//useiname.livejouinal.com
Please see the OpenlD site hup//www.openid.net foi a moie complete list.
A main benet of OpenlD foi the usei is he oi she no longei has to iegistei
foi a new account on eveiy site in which he oi she wants to paiticipate. Useis
can iegistei on one site (the OpenlD piovideis site) and then use those cie-
dentials to authenticate to many web sites which suppoit OpenlD. Many web
site owneis ofen stiuggle to build communities because end useis aie ieluc-
tant to iegistei foi so many dieient accounts. Suppoiting OpenlD makes it
easiei foi site owneis to build theii communities because the baiiieis to paitic-
ipating (i.e., the eoit it takes to iegistei foi and keep tiack of many accounts)
aie iemoved. All of the account infoimation is kept with the OpenlD piovidei,
making it much easiei to manage this infoimation and keep it up to date.
Lifeiay Poital can act as an OpenlD consumei, allowing useis to automati-
cally iegistei and sign in with theii OpenlD accounts. lnteinally, the pioduct
2 CHAPTER 15. MANAGEMENT
uses OpenlD4Java hup//code.google.com/p/openid4java/ to implement the fea-
tuie.
OpenlD is enabled by default in Lifeiay but can be disabled heie.
Atlassian Crowd
Atlassian Ciowd is a web-based Single Sign-On pioduct similai to CAS. Ciowd
can be used to manage authentication to many dieient web applications and
diiectoiy seiveis.
Because Atlassian Ciowd implements an OpenlD pioducei, Lifeiay woiks
and has been tested with it. Simply use the OpenlD authentication featuie in
Lifeiay to log in using Ciowd.
Authentication: OpenSSO
OpenSSO is an open souice single sign-on solution that comes fiom the code
base of Suns SystemAccess Managei pioduct. Lifeiay integiates with OpenSSO,
allowing you to use OpenSSO to integiate Lifeiay into an infiastiuctuie that
contains a multitude of dieient authentication schemes against dieient iepos-
itoiies of identities.
You can set up OpenSSO on the same seivei as Lifeiay oi a dieient box.
lollowthe instiuctions at the OpenSSOsite hup//opensso.dev.java.net to install
OpenSSO. Once you have it installed, cieate the Lifeiay administiative usei in
it. Useis aie mapped back and foith by scieen names. By default, the Lifeiay
administiative usei has a scieen name of test, so in OpenSSO, you would iegistei
the usei with the lD of test and an email addiess of test@liferay.com. Once you
have the usei set up, log in to Open SSO using this usei.
ln the same biowsei window, go to the URL foi youi seivei iunning Lifeiay
and log in as the same usei, using the email addiess test@liferay.com. Go to
the contiol panel and click Seings Authentication OpenSSO. Modify the
thiee URL elds (Login URL, Logout URL and Seivice URL) so they point to
youi OpenSSO seivei (i.e., only modify the host name poition of the URLs),
click the Enabled check box and then click Save. Lifeiay will then iediiect useis
to OpenSSO when they click the Sign In link.
Authentication: SiteMinder
SiteMindei is a single sign-on implementation fiom Computei Associates. Lif-
eiay .2 intioduced built-in integiation with SiteMindei. SiteMindei uses a cus-
tom HTTP headei to implement its single sign-on solution.
15.7. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 3
To enable SiteMindei authentication in Lifeiay, check the Enabled box on
the SiteMinder tab. lf you aie also using LDAP with Lifeiay, you can check
the Import from LDAP box. lf this box is checked, useis authenticated fiom
SiteMindei who do not exist in the poital will be impoited fiom LDAP.
Te last eld denes the headei SiteMindei is using to keep tiack of the usei.
Te default value is alieady populated. lf you have customized the eld foi youi
installation, entei the custom value heie.
When you aie nished, click Save. Next, lets examine how to conguie
poital-wide usei seuings.
Users
Te Useis page of Poital Seuings has thiee tabs lields, Reseived Ciedentials
and Default Usei Associations.
Te lields tab allows you to enable/disable the following elds
Enable/disable iequiiing the Teims of Use
Enable/disable usei scieen names autogeneiation
Enable/disable iequiiing the last names
Enable/disable the biithday eld
Enable/disable the gendei eld
Te next tab is Reseived Ciedentials. You can entei scieen names and email
addiesses heie that you dont want otheis to use. Lifeiay will then pievent useis
fiom iegisteiing with these scieen names and email addiesses. You might use
this featuie to pievent useis fiom cieating lDs that look like administiative lDs
oi that have ieseived woids in theii names.
Te Default Usei Associations tab has thiee elds allowing you to list (one
pei line) sites, ioles and usei gioups you want new useis to become membeis
of automatically. By default, Lifeiay assigns new useis to both the Useis iole
and the Powei Useis iole.
lf you have dened othei usei gioups, sites oi ioles you want newly cieated
useis to be membeis of by default, entei them heie. loi example, you may have
dened site templates in ceitain usei gioups to pie-populate end useis piivate
pages. lf theie is a paiticulai conguiation you want eveiyone to have, you may
want to entei those usei gioups heie.
4 CHAPTER 15. MANAGEMENT
15.8 Summary
ln this chaptei, we began to examine Lifeiays contiol panel. Site membeiships
and teams aient the only way foi poital administiatois to gioup and manage
useis oiganizations can be used to aiiange useis into hieiaichical stiuctuies
and usei gioups aie a exible way to collect ad hoc gioups of useis. You can
cieate ioles to dene peimissions and scope them foi the entiie poital oi foi
a paiticulai site oi oiganization. Usei gioups can be assigned to ioles, in this
case, each membei of the usei gioup is assigned to the iole.
We also look at how to conguie passwoid policies foi useis. Next, we also
looked at the dieient authentication options piovided by Lifeiay. You can con-
guie Lifeiay so that useis can authenticate via LDAP, CAS, lacebook, NTLM,
OpenlD, OpenSSO, oi SiteMindei. linally, we examined some geneial cong-
uiation options foi the poital useis. Well continue oui coveiage of Lifeiays
contiol panel in the next chaptei.
Cu~v1rv 1
UsiNc 1ur CoN1voi P~Nri
ln this chaptei, we continue oui coveiage of Lifeiays contiol panel that we
began in chaptei 1. Well covei the following topics
Poital seuings including mail host names, email notications, identica-
tion, and display seuings
Custom elds
Montoiing
Plugins conguiation
Seivei administiation, including iesouices, log levels, piopeities, captcha
data migiation, le uploads, mail, exteinal seivices, sciipts, and shutdown
seuings
Poital instances
Lets begin with mail host names.
permissions.user.check.algorithm=6
Restait youi seivei. Congiatulations' Youve successfully migiated youi
installation to use the latest, highest peifoiming peimissions algoiithm. Next,
youll need to explicitly set youi lmage Galleiy stoiage option.
Migrate Your Image Gallery Images
Lifeiay .1 intioduces a majoi change to how Lifeiay handles les. No longei
do we have a sepaiate Document Libiaiy and lmage Galleiy, instead, these have
been combined into Documents and Media. lf you weie using Lifeiays lmage
Galleiy to stoie images, these can be migiated ovei duiing an upgiade, but youll
have to take some extia steps ist.
ln Lifeiay .0, you had thiee ways you could stoie images in the lmage
Galleiy. You could use the DatabaseHook and stoie them as BLOBs in the
00 CHAPTER 17. ADVANCED PORTAL OPERATION
database, you could use the DLHook to stoie them in the Document Libiaiy, oi
you could use the FileSystemHook to stoie them in a foldei on youi seiveis
le system. Befoie you upgiade, youll need to set whichevei piopeity you
weie using in youi .0 portal-ext.properties le, because by default, none
of them aie enabled in .1. Seuing one of the piopeities tiiggeis the migiation
duiing the upgiade piocess. Below aie the thiee piopeities, youll need to set
only one of them (the one you weie using).
image.hook.impl=com.liferay.portal.image.DatabaseHook
image.hook.impl=com.liferay.portal.image.DLHook
image.hook.impl=com.liferay.portal.image.FileSystemHook
By default, Lifeiay .0 used the FileSystemHook. lf you nevei customized
this piopeity foi youi installation, youd use the FileSystemHook piopeity
above. lf you customized the piopeity, you should know which one you used,
and it is likely alieady in youi portal-ext.properties le.
Te thiid thing you need to do to piepaie foi youi upgiade is to ieview the
new piopeity defaults.
Reviewthe New6.1 Properties Defaults
Te next thing youll need to look at aie the defaults that have changed fiom .0
to .1. Tese aie pieseived in portal-legacy-6.0.properties in the souice.
Te .0 values aie
users.last.name.required=true
layout.types=portlet,panel,embedded,article,url,link_to_layout
editor.wysiwyg.portal-web.docroot.html.portlet.message_boards.edit_message.bb_code.jsp= \
bbcode
setup.wizard.enabled=false discussion.subscribe.by.default=false
message.boards.subscribe.by.default=false
Te .1 values have changed to
users.last.name.required=false
layout.types=portlet,panel,embedded,url,link_to_layout
editor.wysiwyg.portal-web.docroot.html.portlet.message_boards.edit_message.bb_code.jsp= \
ckeditor_bbcode
setup.wizard.enabled=true discussion.subscribe.by.default=true
message.boards.subscribe.by.default=true
lf you dont like the defaults, you can change them back in one shot by
adding a system piopeity to youi JVMs staitup. Tis dieis by application
seiveis. ln Tomcat, youd modify setenv.sh/setenv.bat and append the
option -Dexternal-properties=portal-legacy-6.0.properties to the
17.6. UPGRADING LIFERAY 01
enviionment vaiiable JAVAOPTS. Te sciipts setenv.sh oi setenv.bat aie
not deliveied with default Tomcat, but do exist in the bundles. lf theyie theie,
Tomcat uses them in the staitup piocess, so its a nice way to sepaiate youi
own seuings fiom Tomcats default shell sciipts. Alteinatively, of couise, you
can oveiiide some oi all of them in youi portal-ext.properties along with
youi othei oveiiides.
lf youie not using Tomcat, check youi application seiveis documentation
to see how to modify iuntime piopeities. Youi nal task is to catalog all the
plugins you have installed, so you can install the newveisions in youi upgiaded
system.
Catalog all the plugins you have installed
linally, you need to take note of any plugins you have installed. Lifeiays plu-
gins aie usually veision-specic, so youll need to obtain new veisions of them
foi the new ielease of Lifeiay. lf you have custom plugins cieated by youi de-
velopment team, theyll need to build, test, and optionally modify them to woik
with the new ielease of Lifeiay. Dont auempt an upgiade without collecting
all the plugins youll need ist.
Once youve upgiaded youi peimissions algoiithm, ieviewed youi piopei-
ties, and collected all the plugins youll need, youie ieady to followthe upgiade
pioceduie. Remembei to back up youi system befoie you begin.
Teie aie two dieient pioceduies to upgiade Lifeiay. Te ist one, up-
giading a Lifeiay bundle, is the most common. Te second pioceduie is foi
upgiading a Lifeiay installation on an application seivei. Well go ovei both.
ln both cases, Lifeiay auto-detects whethei the database iequiies an upgiade
the ist time the new veision is staited. When Lifeiay does this, it upgiades
the database to the foimat iequiied by the new veision. To peifoim this task,
Lifeiay must be accessing the database with an lD that can cieate, diop and
modify tables. Make suie you have gianted these peimissions to the lD befoie
you auempt to upgiade Lifeiay. And, of couise, well iun the iisk of oveily
iepeating ouiselves back up youi database.
Lets look at upgiading a bundle, which is the easiest upgiade path.
Upgrading a bundle
lf youie iunning a Lifeiay bundle, the best way to do the upgiade is to follow
the steps below. Te new Lifeiay is installed in a newei veision of youi bun-
dle iuntime. loi example, the Lifeiay/Tomcat bundle foi .0 used Tomcat by
default, the .1 bundle uses Tomcat . Tough theie is a Tomcat bundle of
02 CHAPTER 17. ADVANCED PORTAL OPERATION
Lifeiay .1, that bundle also uses a newei ielease of Tomcat than the one fiom
.0. Tis is the case foi all iuntimes Lifeiay suppoits. We geneially iecommend
you use the latest veision of youi iuntime bundle, as it will be suppoited the
longest.
1. Obtain the new bundle. Unzip the bundle to an appiopiiate location on youi
system.
2. Copy youi portal-ext.properties le and youi data foldei to the new
bundle.
3. Review youi portal-ext.properties le as desciibed above. Make suie
youie using peimissions algoiithm . lf you weie using the lmage Galleiy,
make the necessaiy modications so youi les aie migiated to Documents
and Media. Review the new defaults and decide whethei you want to use
them. Review any othei modications youve made.
4. Stait youi application seivei. Watch the console as Lifeiay staits it upgiades
the database automatically.
. When the upgiade completes, install any plugins you weie using in youi old
veision of Lifeiay. Make suie you use the veisions of those plugins that aie
designed foi Lifeiay .1. lf you have youi own plugins, youi development
team will need to migiate the code in these ahead of time and piovide .wai
les foi you.
. Biowse aiound in youi new installation and veiify eveiything is woiking.
Have youi QA team test eveiything. lf all looks good, you can delete the
old application seivei with the old ielease of Lifeiay in it fiom the bundle
diiectoiy. You have a backup of it anyway, iight`
As you can see, upgiading a bundle is geneially pieuy simple. But not ev-
eiybody can use bundles sometimes, specic application seiveis oi application
seivei veisions aie mandated by the enviionment youie in oi by management.
loi this ieason, Lifeiay also ships as an installable .wai le that can be used on
any suppoited application seivei.
Upgrading using a .war le
Running a manual upgiade is almost as easy as upgiading a bundle
17.7. SUMMARY 03
1. Veiify youi application seivei is suppoited by Lifeiay. You can do this by
viewing the appiopiiate document on the Customei Poital (EE), in chaptei
14 (because theie aie installation instiuctions foi it), oi on lifeiay.com(CE). lf
youi application seivei isnt suppoited by Lifeiay .1, do not continue! Youll
need to upgiade oi switch to a suppoited application seivei ist.
2. Obtain the Lifeiay Poital .wai le and the dependency .jais aichive.
3. Copy youi customized portal-ext.properties le to a safe place and ie-
view it as desciibed above, making all the appiopiiate changes.
4. Undeploy the old veision of Lifeiay and shut down youi application seivei.
. Copy the new veisions of Lifeiays dependency .jais to a location on youi
seiveis class path, oveiwiiting the ones you alieady have foi the old veision
of Lifeiay. Tis location is documented foi youi application seivei in chaptei
14.
. Deploy the new Lifeiay .wai le to youi application seivei. lollow the de-
ployment instiuctions in chaptei 14.
. Stait (oi, if youi app seivei has a console fiom which youve installed the
.wai, iestait) youi application seivei. Watch the console as Lifeiay staits it
should upgiade the database automatically. Veiify youi poital is opeiating
noimally, and then install any plugins you weie using in youi old veision
of Lifeiay. Make suie you use the veisions of theose plugins designed foi
Lifeiay .1. lf you have youi own plugins, youi development team will need
to migiate the code in these ahead of time and piovide .wai les to you.
8. Biowse aiound in youi new installation and veiify eveiything is woiking.
Have youi QA team test eveiything. lf all looks good, youie nished.
Tats all theie is to it. Most eveiything is handled by Lifeiays upgiade
pioceduie. Note as stated above, if you have to upgiade ovei seveial Lifeiay
veisions, you will need to iepeat these steps foi each majoi ielease.
17.7 Summary
Lifeiay Poital is an easy enviionment to maintain. Backup pioceduies aie sim-
ple and stiaightfoiwaid. Administiatois have all the options they need to view
and diagnose a iunning Lifeiay Poital seivei thiough its tunable logs.
04 CHAPTER 17. ADVANCED PORTAL OPERATION
Patching Lifeiay is easy to do with Lifeiays patching tool. lt handles foi
you all the management of available patches, and makes it easy to install and
uninstall them.
Upgiading Lifeiay is also a snap, because Lifeiay does most of the woik au-
tomatically. With easy migiation tools and automated database upgiade sciipts,
youll have youi new veision of Lifeiay Poital up and iunning in no time.
Cu~v1rv 18
UsiNc Scviv1iNc iov Auv~Ncru
lirxiniii1v
Lifeiay piovides a iobust sciipt engine that can be used to inteipiet sciipts in
Beanshell, Javasciipt, Gioovy, Python and Ruby. Te sciipt engine came out of
Lifeiays involvement with the Romulus pioject (hup//www.ict-iomulus.eu). lt
was oiiginally developed to suppoit non Java-based poitlets, but has now been
extended to handle a lot moie. loi example, when Lifeiays woikow fiame-
woik was intioduced, the sciipt engine was leveiaged to suppoit the execution
of sciipts fiom within a woikow module. A sciipt console is now included in
the Seivei Administiation poitlet in the contiol panel. lt allows system admin-
istiatois an easy way to execute sciipts to peifoim iepetitive usei maintenance
opeiations, bulk manipulations using the Lifeiay APl to ensuie consistency, oi
even system level opeiations.
Tis chaptei helps you to undeistand Lifeiays sciipt engine and coveis the
following topics
Accessing Lifeiays seivice layei fiom a sciipt
Running sciipts fiom the sciipt console
Using the sciipt engine with woikow
0
0 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
Leveiaging custom Java tools in the sciipt engine
Te most common thing youll want to do is access Lifeiays seivices. lf you
have any familiaiity with Lifeiays developei tools and APl, this will be a snap
foi you.
18.1 Accessing Liferay Services
ln many cases, youll want to inteiact with one of Lifeiays many seivices. Tis
is possible fiomall of the sciipting languages suppoited, but the syntax is a liule
dieient foi each language.
To illustiate the coiiect syntax foi inteiacting with Lifeiay seivices, lets
look at a simple example that uses the UserLocalService to ietiieve a list of
useis and then piints theii names to the log le. Well initially implement the
example in Java pseudo-code.
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import java.util.List;
.
.
.
int userCount = UserLocalServiceUtil.getUsersCount();
List<User> users = UserLocalServiceUtil.getUsers(0, userCount);
for (User user:users) {
System.out.println("User Name: " + user.getFullName());
}
.
.
.
Lets see ist how this would woik in Beanshell, which is veiy similai to
Java.
Beanshell
Beanshell is a Java sciipting language thats designed to iun Java code with liule
oi no changes. ln this example, we only have one small change to make because
Beanshell doesnt suppoit the use of Java Geneiics.
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import java.util.List;
18.1. ACCESSING LIFERAY SERVICES 0
int userCount = UserLocalServiceUtil.getUsersCount();
List users = UserLocalServiceUtil.getUsers(0, userCount);
for (User user:users) {
System.out.println("User Name: " + user.getFullName());
}
Next, well show the same thing in Gioovy, anothei sciipting language de-
signed to be similai to Java.
Groovy
Gioovy is also based on Java and is peihaps a liule easiei than Beanshell be-
cause liteially any code wiiuen in Java also iuns in Gioovy. Tis means we can
execute the exact same code fiom oui Java example without any changes.
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import java.util.List;
int userCount = UserLocalServiceUtil.getUsersCount();
List<User> users = UserLocalServiceUtil.getUsers(0, userCount);
for (User user:users) {
System.out.println("User Name: " + user.getFullName());
}
Of couise, we could make this somewhat Giooviei by simplyng the pio-
giam as follows
import com.liferay.portal.service.UserLocalServiceUtil
userCount = UserLocalServiceUtil.getUsersCount()
users = UserLocalServiceUtil.getUsers(0, userCount)
for ( user in users){
System.out.println("User Name: " + user.getFullName())
}
Te sciipt engine suppoits moie than just Java-like languages. Despite the
name, you should be awaie that Javasciipt beais liule iesemblance to Java, but
you can still use it in Lifeiays sciipt engine.
Javascript
Lifeiay uses the Rhino Javasciipt Engine to piovide Javasciipt suppoit in the
sciipt engine. Te following code piovides a Javasciipt veision of oui oiiginal
Java piogiam.
08 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
userCount = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
users = new Packages.java.util.ArrayList;
users = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsers(0, userCount);
user = Packages.com.liferay.portal.service.UserLocalServiceUtil.createUser(0);
for (i=0;i<users.size();i++) {
Packages.java.lang.System.out.println(users.get(i).getFullName());
}
You can see the Javasciipt example is compact. Ruby is even moie compact.
Ruby
Ruby is suppoited thiogh the use of JRuby and oui pievious example could be
implemented in Ruby as follows
userCount = com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
users = com.liferay.portal.service.UserLocalServiceUtil.getUsers(0, userCount);
users.each{ |user| print user.getFullName() + "\n"}
Python useis aient lef out eithei.
Python
Lastly, Lifeiay piovides Python suppoit based on Jython and the pievious ex-
ample could be implemented with the following code.
from com.liferay.portal.service import UserLocalServiceUtil
from com.liferay.portal.model import User
userCount = UserLocalServiceUtil().getUsersCount()
users = UserLocalServiceUtil().getUsers(0,userCount)
for user in users:
print user.getFullName()
As you can see, Lifeiays seivices can be accessed fiom any of these lan-
guages. Lets look at some piactical examples of how youd use this.
18.2 Running scripts fromthe control panel
To see a veiy simple example of the sciipt console in action, log into the poital
as an administiatoi and navigate to the contiol panel Seivei Administiation
Sciipt. Change the sciipt type to Gioovy and modify the cuiient code to
look like the following
18.2. RUNNING SCRIPTS FROM THE CONTROL PANEL 09
number = com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
out.println(number);
Click the execute buuon and check the console oi the log foi youi output.
Lets implement a moie iealistic example. Well ietiieve some usei infoi-
mation fiom the database, make some changes and then update the database
with oui changes. Oui company has updated the teims of use and iequiies that
eveiyone be piesented with the updated teims of use on the next log in. When
useis agiee to the teims of use, a boolean auiibute called agreedToTermsOf-
Use is set in theii usei iecoids. As long as the boolean is true, Lifeiay will not
piesent the usei with the teims of use. Howevei, if we set this ag to false foi
eveiyone, all useis will have to agiee to it again to use the site.
Well again use Gioovy, so ensuie the sciipt type is set to Gioovy and execute
the following code to check the status of the agreedToTermsOfUse auiibute
import com.liferay.portal.service.UserLocalServiceUtil
userCount = UserLocalServiceUtil.getUsersCount()
users = UserLocalServiceUtil.getUsers(0, userCount)
for (user in users) {
println("User Name: " + user.getFullName() + " -- " + user.getAgreedToTermsOfUse())
}
Now well actually update each usei in the system to set his oi hei agreed-
ToTermsOfUse auiibute to false. Well be suie to skip the default usei as the
default usei is not iequiied to agiee to the Teims of Use. Well also skip the
admin usei thats cuiiently logged in and iunning the sciipt. lf youie logged in
as somoene othei than testlifeiay.com, be suie to update the following sciipt
befoie iunning it.
import com.liferay.portal.service.UserLocalServiceUtil
userCount = UserLocalServiceUtil.getUsersCount()
users = UserLocalServiceUtil.getUsers(0, userCount)
for (user in users){
if(!user.isDefaultUser() &&
!user.getEmailAddress().equalsIgnoreCase("test@liferay.com")) {
user.setAgreedToTermsOfUse(false)
UserLocalServiceUtil.updateUser(user)
}
}
10 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
To veiify the sciipt has updated the iecoids, iun the ist sciipt again and you
should see all useis (except the default usei and youi lD) have been updated.
Tats all thats needed to iun sciipts and to access the Lifeiay seivice layei.
Teie aie, howevei, some things to keep in mind when woiking with the sciipt
console
Teie is no undo
Teie is no pieview
When using Local Seivices, no peimissions checking is enfoiced
Sciipts aie executed synchionously, so be caieful with sciipts that might
take a long time to execute.
loi these ieasons, you want to use the sciipt console with caie, and test iun
youi sciipts on non-pioduction systems befoie you iun them on pioduction.
Of couise, the sciipt engine has uses beyond the sciipt console. One of the
main uses of it is in designing woikows.
18.3 Leveraging the Script Engine in Workow
Lifeiays Kaleo woikow engine piovides a iobust system foi ieviewing and
appioving content in an enteipiise enviionment. Just with the standaid featuie
set, it is a poweiful and iobust woikow solution. Adding sciipting featuies
biings it to the next level.
Te default woikow denition included with Kaleo gives you a quick look
into how the featuie woiks. Te nal step in the woikow iuns a sciipt that
makes content available foi use. As you can see in the snippet below, it uses
Javasciipt to access the Java class associated with the woikow to set the status
of the content to approved.
<script>
<![CDATA[
Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus
(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"),
workflowContext);]]>
</script>
<script-language>javascript</script-language>
At viitually any point in a woikow, you can use Lifeiays sciipting engine
to access woikow APls oi othei APls outside of woikow. Teie aie a lot
of dieient ways you could use this, but some piactical ones might be geuing
18.3. LEVERAGING THE SCRIPT ENGINE IN WORKFLOW 11
a list of useis with a specic woikow-ielated iole, sending an email to the
designated content appiovei with a list of people to contact if he is unable to
ieview the content, oi cieating an aleit to be displayed in the Aleits poitlet foi
any usei assigned to appiove content.
Of couise, befoie you tiy any of this, you might want to know what the
appiopiiate syntax is foi inseiting a sciipt into the woikow. ln an XML woik-
ow denition, a sciipt can be used in any XML type that can contain an tag
- those types being <state>, <task>, <fork> and <join>. lnside of one of
those types, foimat youi sciipt like so
<actions>
<action>
<script>
<![CDATA[*the contents of your script*]]>
</script>
<script-language>*your scripting language of choice*</script-language>
</action>
...
</actions>
Heies an example of a woikow sciipt cieated in Gioovy. Tis one is de-
signed to be used with a Condition statement in Kaleo. lt accesses Lifeiays
Asset liamewoik to deteimine the categoiy of an asset in the woikow so the
coiiect appioval piocess can be automatically deteimined.
<script>
<![CDATA[
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowHandler;
import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;
import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portlet.asset.model.AssetEntry;
import com.liferay.portlet.asset.model.AssetRenderer;
import com.liferay.portlet.asset.model.AssetRendererFactory;
import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
import java.util.List;
String className = (String)workflowContext.get(
WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME);
WorkflowHandler workflowHandler =
WorkflowHandlerRegistryUtil.getWorkflowHandler(className);
AssetRendererFactory assetRendererFactory =
workflowHandler.getAssetRendererFactory();
long classPK =
GetterUtil.getLong((String)workflowContext.get
(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
12 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
AssetRenderer assetRenderer =
workflowHandler.getAssetRenderer(classPK);
AssetEntry assetEntry = assetRendererFactory.getAssetEntry(
assetRendererFactory.getClassName(), assetRenderer.getClassPK());
List<AssetCategory> assetCategories = assetEntry.getCategories();
returnValue = "Content Review";
for (AssetCategory assetCategory : assetCategories) {
String categoryName = assetCategory.getName();
if (categoryName.equals("legal")) {
returnValue = "Legal Review";
return;
}
}
]]>
</script>
<script-language>groovy</script-language>
Within a woikow, the next task oi state is chosen based on the what the
method ietuins.
Te combination of Lifeiays sciipting and woikow engines is inciedibly
poweiful, but as it piovides useis with the ability to execute code, it can also be
veiy dangeious. When conguiing youi peimissions, be awaie of the poten-
tial consequences of pooily, oi maliciously, wiiuen sciipts inside of a woikow
denition. loi moie infoimation on cieating denitions with Kaleo Woikow
see Chapter 6: Workow with Kaleo.
18.4 CustomJava Tools in the Script Engine
Teie aie seveial challenges when woiking with the Sciipt Engine, including
debugging and logging. One appioach to oveicome these challenges is to de-
velop custom Java utilities that can be called fiom youi sciipts. Tese utilities
can wiite to a custom log le oi the Lifeiay log le. You can also place bieak-
points in youi utility code and step thiough it using youi favoiite debuggei.
Lifeiays use of Spiing and PortletBeanLocatorUtil makes calling these
Java utilities fiom youi sciipt easy, iegaidless of the sciipting language youie
using.
Lets begin by cieating a Lifeiay Hook pioject. lf youie using Lifeiay lDE
oi Lifeiay Developei Studio, select File New Liferay Project. Name the
18.4. CUSTOM JAVA TOOLS IN THE SCRIPT ENGINE 13
pioject script-utils and accept the display name geneiated by the wizaid. Be
suie to select Hook foi the Plugin Type and then select Finish.
Figure 18.1: Creating a newutilities project is easy if you use Liferay IDE
or Liferay Developer Studio.
Youie using a Lifeiay Hook Plugin to deploy youi utility, but youie not
using any of the typical hook featuies. You just need a way to make youi code
available to the poital and the Hook Plugin is the least obtiusive way to do
this. Tis means you dont need to add anything to the liferay-hook.xml
le. lnstead, youll begin by adding youi utility code.
Youll be following the Dependency lnjection design pauein so begin by cie-
ating the inteiface. Right click on the docroot/WEB-INF/src foldei and select
14 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
New Interface. Youll cieate youi inteiface in the com.liferay.sample
package. Name it ScriptUtil.
Figure 18.2: Create a newJava Interface which youll later implement.
Next, add two methods to the inteiface.
package com.liferay.samples;
public interface ScriptUtil {
public String operationOne();
public String operationTwo(String name);
}
Next, cieate the implementation class. Right click on the docroot/WEB-
INF/src foldei and select New Class. Cieate the inteiface in the com.life-
ray.sample package and name it ScriptUtilImpl. Be suie to select com.-
liferay.sample.ScriptUtil as the lnteiface.
Next, add implementations foi the two methods.
18.4. CUSTOM JAVA TOOLS IN THE SCRIPT ENGINE 1
Figure 18.3: Create a newJava Class that implements the interface you
created earlier.
package com.liferay.samples;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
public class ScriptUtilImpl implements ScriptUtil {
@Override
public String operationOne() {
return "Hello out there!";
}
@Override
1 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
public String operationTwo(String name) {
_log.debug("Inside of Operation Two");
return "Hello " + name + "!";
}
private static Log _log = LogFactoryUtil.getLog(ScriptUtilImpl.class);
}
Lifeiay makes extensive use of the Spiing liamewoik and youll be using it
heie to inject youi implementation class into the application. Spiing needs a
bean denition which youll declaie in an XML le named applicationCon-
text.xml. Cieate this le in the docroot/WEB-INF/ diiectoiy and add the
following code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="com.liferay.sample.ScriptUtil" class="com.liferay.sample.ScriptUtilImpl" />
</beans>
Upon deployment, youll need the poital to cieate a BeanLocator foi youi
plugin. Te BeanLocator ieads the bean denitions you piovided.
lf youie adding youi utility to a Seivice Buildei enabled plugin, then youll
alieady have a BeanLocator and you can skip this step. Since this Hook plugin
is not alieady using Seivice Buildei, youll need to dene a context loadei lis-
tenei in oui Hook to piovide a BeanLocator. Open the docroot/WEB-INF/-
web.xml le and ieplace its contents with the following code
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.liferay.portal.kernel.spring.context.PortletContextLoaderListener
</listener-class>
</listener>
</web-app>
Save all of the changes youve made and deploy the hook. Once the hook has
been deployed successfully, the ScriptUtil can be used in youi sciipt engine
code.
18.5. SUMMARY 1
To see the ScriptUtil code in action, navigate back to the control panel
Server Administration Script. Change the sciipt type to Gioovy and entei the
following sciipt
myUtil =
com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("script-utils-hook",
"com.liferay.samples.ScriptUtil")
println(myUtil.operationOne())
println(myUtil.operationTwo("Joe Bloggs"))
You should see the iesults of youi sciipt displayed iight undei the sciipt.
18.5 Summary
ln this chaptei we saw how Lifeiays sciipt engine opens up many exciting
posibilities foi woiking with Lifeiay iegaidless of youi language of choice. We
leained how you can leveiage Lifeiays Seivices Oiiented Aichitectuie (SOA)
fiom any of the populai sciipting languages Lifeiay suppoits. We then saw
how those sciipts could be used to simplify administiative tasks by leveiaging
the Administiatoi Sciipt Console. Next, we discoveied how you could enhance
woikow by using the powei of sciipts. Lastly, we saw how you could ovei-
come some of the limitations of iunning sciipts in Lifeiay by cieating custom
Java utilities that could be executed fiom within youi sciipts.
As you can see, Lifeiays sciipt engine opens up many exciting posibilities
foi woiking with Lifeiay iegaidless of youi language of choice.
Cu~v1rv 19
CoNiicUviNc Liirv~v iov Hicu
Av~ii~niii1v
Lifeiay Poital is a iobust, enteipiise-ieady poital solution. As such, it is fully
ieady to suppoit mission-ciitical, enteipiise applications in an enviionment
conguied foi multiple iedundancies and 24/ uptimes. Te pioduct, howevei,
like othei pioducts of its kind, doesnt come conguied this way out of the box,
so theie aie some steps that need to be taken to tune it foi youi needs.
Tis chaptei coveis these topics in detail. Lifeiay iuns on so many dieient
Java EE application seiveis that we cant covei all the dieiences between them.
loi this ieason, well discuss Lifeiay conguiations only. loi example, well
look at how to conguie Lifeiay to woik in a clusteied enviionment, but not
how to cieate the clustei in youi application seivei. Te documentation foi
youi paiticulai application seivei is always a much beuei place to leain those
kinds of things.
Tis chaptei explains how to conguie Lifeiay foi a numbei of advanced
scenaiios, such as
Clusteiing
Distiibuted Caching
18
19.1. LIFERAY CLUSTERING 19
Deploying Customized veisions of Lifeiay
Peifoimance Testing and Tuning
Duiing this discussion, well mention a numbei of othei open souice piod-
ucts upon which Lifeiay ielies foi much of this functionality. Tese pioducts all
have theii own documentation which should be consulted foi a fullei view of
what these pioducts can do. loi example, Lifeiay uses Ehcache foi its caching
mechanism. Well covei how to conguie Ehcache to enable caches in Lifeiay,
but will iefei you to that pioducts documentation foi fuithei infoimation about
that pioduct.
Sometimes Lifeiay suppoits multiple pioducts which peifoimthe same func-
tion. Teie aie, foi example, seveial single sign-on implementations you can use
with Lifeiay. Well leave it up to you to select which pioduct best ts the needs
of youi pioject without iecommending one pioduct ovei anothei.
With all of that said, lets get staited conguiing Lifeiay foi the enteipiise.
19.1 Liferay Clustering
Lifeiay Poital is designed to seive eveiything fiom the smallest to the laigest
web sites. Out of the box, its conguied optimally foi a single seivei enviion-
ment. lf one seivei isnt sucient to seive the high tiac needs of youi site,
Lifeiay scales to the size you need.
Lifeiay woiks well in clusteis of multiple machines (hoiizontal clustei) oi in
clusteis of multiple VMs on a single machine (veitical clustei), oi any mixtuie
of the two. Once you have Lifeiay installed in moie than one application seivei
node, theie aie seveial optimizations that need to be made. At a minimum,
Lifeiay should be conguied in the following way foi a clusteied enviionment
All nodes should be pointing to the same Lifeiay database oi database
clustei.
Documents and Media iepositoiies should be accessible to all nodes of
the clustei.
Seaich should be conguied foi ieplication oi should use a sepaiate seaich
seivei.
Te cache should be ieplicating acioss all nodes of the clustei.
Hot deploy foldeis should be conguied foi each node if youie not using
seivei faims.
20 CHAPTER 19. CONFIGURING LIFERAY FOR HIGH AVAILABILITY
Figure 19.1: Liferay is designed to scale to as large an installation as you
need.
lf you havent conguied youi application seivei to use faims foi deploy-
ment, the hot deploy foldei should be a sepaiate foldei foi all the nodes, and
plugins will have to be deployed to all of the nodes individually. Tis can be
done via a sciipt. lf you do have faims conguied, you can deploy noimally
to any nodes deploy foldei, and youi faim conguiation should take caie of
syncing the deployment to all nodes.
Many of these conguiation changes can be made by adding oi modify-
ing piopeities in youi portal-ext.properties le. Remembei that this le
oveiiides the defaults in the portal.properties le. Te oiiginal veision of
this le can be found in the Lifeiay souice code oi can be extiacted fiom the
portal-impl.jar le in youi Lifeiay installation. lt is a best piactice to copy
19.1. LIFERAY CLUSTERING 21
the ielevant section you want to modify fiom portal.properties into youi
portal-ext.properties le, and then modify the values theie.