Professional Documents
Culture Documents
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.
lSBN 98-0-8-1231-
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
Poitions of this document weie contiibuted by additional authois James
lalknei, Biuno laiache, Michael Han, Jeiey Handa, Maik Healy, and Jonathon
Omahen.
CoN1rN1s
Contents i
Preface vi
Whats New in the liist 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 . . . . . . . . . . .
3.3 Using site templates . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Using page templates . . . . . . . . . . . . . . . . . . . . . . .
3. Allowing useis to customize site pages . . . . . . . . . . . . . . 83
3. Staging page publication . . . . . . . . . . . . . . . . . . . . . 84
3. Cieating teams foi advanced site membeiship management . . 9
3.8 Displaying site pages to mobile devices . . . . . . . . . . . . . 9
3.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
4 Document Management 106
4.1 Geuing Staited with Documents and Media . . . . . . . . . . . 10
4.2 Document Types and Metadata Sets . . . . . . . . . . . . . . . 111
4.3 Alteinative lile Repositoiy Options . . . . . . . . . . . . . . . 11
4.4 Using Exteinal Repositoiies . . . . . . . . . . . . . . . . . . . . 11
4. Miciosof Oce integiation . . . . . . . . . . . . . . . . . . . . 123
4. Conguiing the Documents and Media poitlet . . . . . . . . . 12
4. Automatic Pieviews and metadata . . . . . . . . . . . . . . . . 12
4.8 Lifeiay Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
4.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
5 Leveraging the Asset Framework 157
.1 Tagging and Categoiizing Content . . . . . . . . . . . . . . . . 18
.2 Taigeted Vocabulaiies . . . . . . . . . . . . . . . . . . . . . . 11
.3 Using laceted Seaich . . . . . . . . . . . . . . . . . . . . . . . 13
.4 Using the Asset Publishei . . . . . . . . . . . . . . . . . . . . . 14
. Seuing up Display Pages . . . . . . . . . . . . . . . . . . . . . 1
. Dening content ielationships . . . . . . . . . . . . . . . . . . 181
. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
6 Personalization and Customization 183
.1 Usei Peisonal Sites . . . . . . . . . . . . . . . . . . . . . . . . 184
.2 Page Customizations . . . . . . . . . . . . . . . . . . . . . . . 18
.3 Using Lifeiays iules engine . . . . . . . . . . . . . . . . . . . 189
.4 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
ii
7 Collaboration Suite 196
.1 Undeistanding Lifeiays common conguiation options . . . . 19
.2 Expiessing youiself using Blogs . . . . . . . . . . . . . . . . . 211
.3 Oiganizing and shaiing events with the Calendai . . . . . . . 221
.4 Discuss, ask and answei using the Message Boaids . . . . . . . 224
. Woiking togethei with the Wiki . . . . . . . . . . . . . . . . . 238
. lind out what otheis think oi do using Polls . . . . . . . . . . 24
. Staying in touch with the Chat . . . . . . . . . . . . . . . . . . 20
.8 lntegiating youi email with Lifeiay Mail . . . . . . . . . . . . 2
.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
8 Social Networking 259
8.1 Leveiaging Social Poitlets, Activities Tiacking and Usei Con-
nections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.2 Measuiing social activity . . . . . . . . . . . . . . . . . . . . . 29
8.3 Expoiting poital applications as widgets and OpenSocial gad-
gets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.4 lntegiating with lacebook . . . . . . . . . . . . . . . . . . . . 28
8. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
9 Using Web Forms and Dynamic Data Lists 290
9.1 Building a list platfoim in Lifeiay . . . . . . . . . . . . . . . . 291
9.2 Dening data types . . . . . . . . . . . . . . . . . . . . . . . . 291
9.3 Cieating data lists . . . . . . . . . . . . . . . . . . . . . . . . . 29
9.4 Make it pieuy cieating custom displays . . . . . . . . . . . . 300
9. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
10 Using Workow 312
10.1 Enabling woikow . . . . . . . . . . . . . . . . . . . . . . . . 313
10.2 Cieating new woikow denitions . . . . . . . . . . . . . . . 313
10.3 Timeis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
10.4 Conguiing assets to use woikow piocess denitions . . . . 32
10. Using woikow with othei applications . . . . . . . . . . . . . 329
10. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
11 Kaleo Forms: Dening Business Processes 334
11.1 Kaleo loims . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
11.2 Kaleo Designei . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
11.3 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
iii
12 Liferay Utility Applications 343
12.1 Captuiing Web Sites with the Bookmaiks Poitlet . . . . . . . . 344
12.2 Cieating Youi Own Plugin Repositoiy . . . . . . . . . . . . . . 31
12.3 Shopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
12.4 Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . 39
12. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
13 Leveraging the Liferay Marketplace 389
13.1 Maiketplace Concepts Useis, Companies, and Apps . . . . . . 390
13.2 Accessing the Lifeiay Maiketplace . . . . . . . . . . . . . . . . 390
13.3 linding Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
13.4 Downloading and lnstalling Apps . . . . . . . . . . . . . . . . 400
13. Cieating and Uploading Apps . . . . . . . . . . . . . . . . . . 40
13. Plugin Management . . . . . . . . . . . . . . . . . . . . . . . . 40
13. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
14 Installation and Setup 422
14.1 Editions of Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . 422
14.2 Obtaining Lifeiay Poital . . . . . . . . . . . . . . . . . . . . . 42
14.3 lnstalling a bundle . . . . . . . . . . . . . . . . . . . . . . . . . 42
14.4 App seiveis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
14. Using Lifeiays setup wizaid . . . . . . . . . . . . . . . . . . . 434
14. Manual Conguiation . . . . . . . . . . . . . . . . . . . . . . 43
14. lnstalling Lifeiay on an existing application seivei . . . . . . . 438
14.8 lnstalling Lifeiay on Mule Tcat . . . . . . . . . . . . . . . . . . 440
14.9 lnstalling Lifeiay on Glasslish 3 . . . . . . . . . . . . . . . . . 44
14.10 lnstalling Lifeiay on Jeuy . . . . . . . . . . . . . . . . . . . . 4
14.11 lnstalling Lifeiay on JBoss .1 . . . . . . . . . . . . . . . . . . 483
14.12 lnstalling Lifeiay on JBoss . . . . . . . . . . . . . . . . . . . 48
14.13 lnstalling Lifeiay on JOnAS .2 . . . . . . . . . . . . . . . . . . 494
14.14 lnstalling Lifeiay on Resin 4 . . . . . . . . . . . . . . . . . . . 00
14.1 lnstalling Lifeiay on Tomcat . . . . . . . . . . . . . . . . . . 0
14.1 lnstalling Lifeiay on WebLogic 10 . . . . . . . . . . . . . . . . 14
14.1 lnstalling Lifeiay on Oiacle WebLogic 10.3 . . . . . . . . . . . 20
14.18 lnstalling Lifeiay on WebSpheie 8.0 . . . . . . . . . . . . . . . 2
14.19 Making Lifeiay Coexist with Othei Java EE Applications . . . 3
14.20 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
15 Management 540
1.1 Managing Useis . . . . . . . . . . . . . . . . . . . . . . . . . . 41
iv
1.2 Te Poital Section of the Contiol Panel . . . . . . . . . . . . . 41
1.3 Adding useis . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
1.4 Usei management . . . . . . . . . . . . . . . . . . . . . . . . . 44
1. Usei Gioups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
1. Roles and Peimissions . . . . . . . . . . . . . . . . . . . . . . .
1. Managing Poital Seuings . . . . . . . . . . . . . . . . . . . . . 3
1.8 lntegiating Lifeiay useis into youi enteipiise . . . . . . . . . . 8
1.9 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
16 Using the Control Panel 582
1.1 Custom lields . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
1.2 Monitoiing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Plugins Conguiation . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Seivei Administiation . . . . . . . . . . . . . . . . . . . . . . 88
1. Poital lnstances . . . . . . . . . . . . . . . . . . . . . . . . . . 94
1. Plugins lnstallation . . . . . . . . . . . . . . . . . . . . . . . . 9
1. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
17 Advanced Portal Operation 597
1.1 Audit Tiails . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
1.2 Lifeiay monitoiing using Google Analytics . . . . . . . . . . . 0
1.3 Backing up a Lifeiay installation . . . . . . . . . . . . . . . . . 0
1.4 Lifeiays Logging System . . . . . . . . . . . . . . . . . . . . . 0
1. Patching Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . . 09
1. Upgiading Lifeiay . . . . . . . . . . . . . . . . . . . . . . . . . 14
1. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
18 Using Scripting for Advanced Flexibility 622
18.1 Accessing Lifeiay Seivices . . . . . . . . . . . . . . . . . . . . 23
18.2 Running sciipts fiom the contiol panel . . . . . . . . . . . . . 2
18.3 Leveiaging the Sciipt Engine in Woikow . . . . . . . . . . . 2
18.4 Custom Java Tools in the Sciipt Engine . . . . . . . . . . . . . 29
18. Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
19 Conguring Liferay for High Availability 635
19.1 Lifeiay Clusteiing . . . . . . . . . . . . . . . . . . . . . . . . . 3
19.2 Peifoimance Tuning . . . . . . . . . . . . . . . . . . . . . . . 2
19.3 Summaiy . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Index 668
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 First Edition
liist edition` Well, weve ienamed the book (it used to be the Administrators
Guide), so we guied wed stait the numbeiing ovei. Teies so much newin this
edition that it just about encompasses the whole book. Of couise, eveiything
fiom the old book has been updated to ieect the ielease of Lifeiay Poital .1.
We also have complete coveiage of Lifeiays newfeatuies, 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 0 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 vei-
sion 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 at oui Documenta-
tion Eiiata page.
1
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.
2
We aie heie to seive
you, oui useis and customeis, and to help make youi expeiience using Lifeiay
Poital the best it can be.
1
hup//www.lifeiay.com/community/wiki/-/wiki/Main/DocumentationEiiata
2
hup//www.lifeiay.com/contact-us
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.
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.
1.2. USING LIFERAY PORTAL AS A CONTENT MANAGEMENT SYSTEM
Figure 1.1: Liferays page hierarchies are easy to create, using a tree
structure thats familiar to anyone who has used a le manager.
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.
CHAPTER 1. WHAT IS LIFERAY?
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
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
1.2. USING LIFERAY PORTAL AS A CONTENT MANAGEMENT SYSTEM
in the example above is that wiiteis can tag and categoiize theii stoiies so they
can be found moie easily by useis.
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
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.
Lifeiays Documents and Media libiaiy suppoits WebDAV, using the same cie-
dentials you use to log in to Lifeiay.
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
1.3. USING LIFERAY PORTAL AS A COLLABORATIVE PLATFORM 9
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
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.
10 CHAPTER 1. WHAT IS LIFERAY?
Tis is a suite of integiated applications with all the featuies of similai, stan-
dalone applications. loi example, Lifeiay Poitals message boaids include cat-
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
1.4. USING LIFERAY AS A SOCIAL PLATFORM 11
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
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
12 CHAPTER 1. WHAT IS LIFERAY?
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
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.
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.
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
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
14 CHAPTER 1. WHAT IS LIFERAY?
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
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.
1.6. EXTENDING AND CUSTOMIZING LIFERAY FOR YOUR OWN NEEDS 1
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
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 appio-
piiate 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
2 CHAPTER 2. WEB CONTENT MANAGEMENT
tiansfoim the entiie look of the poital. Tey aie cieated by developeis and aie
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
2.2. CREATING SITES AND MANAGING PAGES 2
of the Contiol Panel), youll see some paits of the page aie now tinged in a
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
3.2. LEVERAGING LIFERAYS MULTI-SITE CAPABILITIES
add a site, click on Sites undei the Poital section of the Contiol Panel and then
click Add. lf theie is at least one site template available, a diopdown menu ap-
peais. Site templates piovide a pieconguied set of pages, poitlet applications,
and content that can be used as the basis of a sites public oi piivate page set. To
cieate a site fiom sciatch, select Blank Site. Otheiwise, select the name of the
site template youd like to use. lf you opt to cieate a site fiom a site template,
you have to choose whethei to copy the site templates pages as youi new sites
public oi piivate page set. lf othei site templates aie cieated, they will appeai in
the Add menu as they become available. Te following guie shows the foim
that needs to be lled when cieating a Blank Site.
Te following guie shows the foim that needs to be lled when cieating a
Blank Site.
Figure 3.8: Adding a 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.
8 CHAPTER 3. ADVANCED WEB CONTENT MANAGEMENT
Active: deteimines whethei a site is active oi inactive. lnactive sites aie
inaccessible but can be activated whenevei a site administiatoi wishes.
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.
Figure 3.9: Editing a Site
Details: lets you edit the infoimation you enteied when you cieated the
3.3. USING SITE TEMPLATES 9
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.
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
examine how they woik.
3.3 Using site templates
Site Templates can be administeied fiom the Contiol Panel. Tey allow poital
administiatois to cieate multiple sites with the same default set of pages and
content. Site templates can contain multiple pages, each with its own theme,
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
layout template, poitlets, and poitlet conguiations. Site templates can also
contain content just like actual sites. Tis allows administiatois to use site tem-
plates to cieate new sites that aie each cieated with the same default pages,
poitlets, and content. Afei theyve been cieated, these sites and theii pages
can be modied by site administiatois. Using site templates can save site ad-
ministiatois a lot of woik even if each site that was cieated fiom a given site
template ends up being veiy dieient.
To get staited, click on Site Templates in the Poital section of the Contiol
Panel. Heie, you can add, manage, oi delete site templates. You can also con-
guie the peimissions of site templates. As long as a site is linked to the site
template it was cieated fiom, changes to the site templates pages, poitlets, and
poitlet conguiations aie piopagated to the site. Changes to a site templates
content, howevei, aie not piopagated to existing sites that aie linked to the site
template. We discuss the piopagation of changes between site templates and
sites in moie detail in the section on site templates use cases below.
To manage the pages of a site template, click on Site Templates in the Contiol
Panel and then click Actions Manage Pages. liomheie, you can add oi iemove
pages fiom a site template oi select themes and layout templates to apply to the
site template. Click on a specic page if youd like to select a dieient theme
oi layout template foi that page. To edit the pages themselves, click Actions
View Pages. You can add specic poitlets to each page of a site template and
conguie the piefeiences of each poitlet. Each page can have any theme, any
layout template, and any numbei of poitlet applications, just like a page of a
iegulai site. As with site pages, you can oiganize the pages of a site template
into hieiaichies. When you cieate a site using a site template, the conguiation
of pages and poitlets is copied fiom the template to the site. By default, all
changes made to the site template aie automatically copied to sites based on
that template.
Recent Files shows a list of iecently cieated oi modied les fiom all the
iepositoiies you can access.
Properties (Preferences, on Mac OS) lets you change piopeities like staiting
on login, desktop notications, and sync fiequency. lt also allows you to edit the
account infoimation you piovided when you staited Sync foi the ist time. loi
example, you can entei a new URL foi youi Lifeiay seivei and entei a dieient
set of Lifeiay ciedentials.
Teie aie thiee items listed in the General Seings section. Start Liferay Sync
on Login is checked by default. lf you dont want Sync to stait automatically,
uncheck this. Show Desktop Notications is also checked by default. Unless
you uncheck this, when a le that you have synced is changed, a small noti-
cation will appeai in the coinei of youi scieen. Te Check Server For Updates
Every: eld enables you to set how fiequently it will check to see if anything
has changed. Tis can be set anywheie between seconds and 30 minutes.
Click the Edit Seings buuon in the Account Seings section to specify youi
seiveis URL and entei youi Lifeiay ciedentials. Use the Test Connection but-
ton to make suie Lifeiay Sync can communicate with the seivei. Editing youi
seuings also allows you to specify youi Sync foldei, the foldei wheie Sync will
stoie les on youi machine. By default, les aie stoied in the liferay-sync sub-
140 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.24: Open the Liferay Sync menu and select Properties (Preferences,
on Mac OS) to edit the settings you congured during setup.
foldei of youi peisonal Documents foldei.
linally, the Site Seings section allows you to choose which sites you wish
to sync media fiom. By default, it will list all of the sites that you aie a membei
of, but you can uncheck any of those sites if you dont want to sync those les.
Sync Now instiucts Lifeiay Sync to check the Lifeiay seivei foi updates im-
mediately.
Pause Syncing instiucts Lifeiay Sync to suspend syncing until fuithei notice.
lf someone added a veiy laige le to one of youi shaied foldeis thats taking a
veiy long time to sync, you might want to use this option and iesume syncing
at a latei time.
About displays Lifeiay Sync veision infoimation, copyiight infoimation, and
4.8. LIFERAY SYNC 141
a link to Lifeiays home page.
Check for Updates checks to see if a new veision of Lifeiay Sync is avail-
able fiom lifeiay.com and allows you to set whethei oi not Lifeiay Sync should
automatically check foi updates.
Using your Sync folder
Once Lifeiay Sync has been conguied and is iunning, any les you add to oi
modify in youi Sync foldei aie automatically detected and uploaded to youi
Lifeiay seivei. Also, changes fiom othei useis aie downloaded to youi Sync
foldei.
Lifeiay Sync handles deletions via a special liferay-sync.deletions le.
Tis mechanism pievents useis fiom accidentally deleting shaied les. When
you delete les fiom youi Sync foldei, a .liferay-sync.deletions le is
cieated theie with the names of the les you deleted. Tis lets Lifeiay Sync
know that you dont want these les in youi Sync foldei, so it wont down-
load them the next time it syncs. Note that the les listed in youi .liferay-
sync.deletions le aie only local deletions. You can iemove entiies fiom
youi .liferay-sync.deletions le to have Lifeiay Sync download themthe
next time it syncs. Of couise, you can use Sync foi moie than just local dele-
tions. lf you have the iequiied peimissions, you can delete les fiom the seivei.
You can iun thiough the following exeicise to familiaiize youiself with how
to cieate, edit, download, and upload les with Lifeiay Sync. liist, open youi
Lifeiay Sync foldei in youi le managei (use the Open Sync Folder option of the
Lifeiay Sync menu fiom the taskbai), and cieate a new le called README.txt.
Edit this le and entei the woid test. Ten use the Sync now option of the Lif-
eiay Sync menu to make suie that youi README.txt le gets uploaded to youi
Lifeiay seivei. Next, check that you can access this le fiom youi Lifeiay site.
Open youi biowsei, navigate to youi Lifeiay site, and sign in with youi Lifeiay
account ciedentials. Ten, navigate to the contiol panel. Make suie the site
you chose to sync with is selected in the context menu selectoi and click on
Documents and Media. You should see youi README.txt le listed theie.
Download the le (click the small tiiangle icon at the top iight coinei of
the README.txt icon and select Download) to a convenient location on youi
machine and check that it still says test. Now open the README.txt le in youi
Sync foldei and edit it so that it says second test. Choose Sync now again, and
then go back to youi biowsei and iefiesh youi Documents and Media page.
Click on the README.txt icon, look at the infoimation displayed to the iight,
and youll see that its veision numbei has inciemented.
142 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.25: You can access the same les fromLiferay Sync that you can
fromLiferays web interface.
Download the le again, and youll see that it now says second testyoui
edit was uploaded to the seivei. You can be condent that this edit was also
downloaded by all othei Lifeiay Sync clients connected to youi site.
Demonstrating Liferay Sync Permissions
Lifeiay Sync uses the default Lifeiay peimissions to deteimine which les and
foldeis aie synced to the useis machine. Tis means that whatevei les a usei
can access fiom a ceitain site aie the ones that will be pulled down by Lifeiay
Sync if that site is selected in the Sync client. You can test the functionality of
Lifeiay Sync peimissions by peifoiming the following steps. liist, cieate a new
le on youi desktop called secret.txt. Entei the text classied information into
this le. Ten use youi biowsei to log into Lifeiay and cieate a new usei called
secretagent with the email addiess secretagent@liferay.com and the passwoid
test. Also, cieate a new piivate site called Secret Site. Ten assign the secretagent
usei to the Secret Site and giant the Site Administrator iole to this usei. Teie will
be no othei membeis of this site unless they aie assigned by an administiatoi.
Log in as the secretagent and use Go to Control Panel, select Secret Site in
the context menu selectoi, and click on Documents and Media. Ten upload the
4.8. LIFERAY SYNC 143
Figure 4.26: Updating a le through Liferay Sync increments the les
version number. You can viewa les version number through the web
interface.
secret.txt document.
Next, well conguie oui Lifeiay Sync client to log in with the secretagent
useis ciedentials and access the Secret Site. Open the Lifeiay Sync menu fiom
the taskbai and select Properties. Click on the Edit Seings buuon, choose a new
Sync foldei, entei youi seiveis URL, and entei the seciet agents ciedentials
secretagent@liferay.com and test. Lastly, uncheck all Lifeiay sites except the Se-
cret Site, and click OK. Conim that the secret.txt le that you uploaded to the
Secret Site, is downloaded to youi new Sync foldei. Open it and check that it
says classied information. lf you ieconguie youi Sync client connect to youi
Lifeiay instance using the ciedentials of anothei usei who doesnt belong to the
Secret Site, the secret.txt will not be downloaded. Congiatulations' Youve suc-
cessfully set up a Lifeiay Sync foldei that can only be accessed by the secretagent
usei and youi administiatois.
144 CHAPTER 4. DOCUMENT MANAGEMENT
Using Liferay Sync Mobile
Once youve installed Lifeiay Sync on youi Andioid oi iOS mobile enviionment,
youll be able to access the same functionality thats available when using Sync
on a desktop enviionment. Howevei, the inteiface dieis fiom that of the Sync
desktop clients.
Android
Afei installing Lifeiay Sync foi Andioid, an empty scieen appeais asking you
to set up the app. Tis scieen appeais whenevei piefeiences aie missing.
Figure 4.27: First screen
Touch the scieen and it displays the Seings view. You can always go back
to Seings by clicking on the wiench icon at the top iight coinei of the scieen.
Entei youi Lifeiay seivei ciedentials by lling in youi Login, Password, and
Server infoimation. Youi Login is eithei youi usei accounts email addiess oi
scieen name. Use the same ciedentials you use to log in to the poital in a
biowsei. ln the Server eld, entei youi poitals URL. ln this example, the seivei
URL is hp://www.liferay.com. Click the key icon on the top iight to test youi
connection and check if eveiything is coiiect.
Note foi Gingeibiead useis lf you cant see some of the featuies desciibed
heie, click on the menu buuon to viewa list of all possible actions. Tis includes
options to iefiesh, open the seuings menu, upload les, take photos, test youi
connection, etc.
Afei you have successfully tested youi connection, hit the back buuon and
youll see a list of Lifeiay sites you have access to.
4.8. LIFERAY SYNC 14
Figure 4.28: Android settings
Figure 4.29: Gingerbread
Figure 4.30: Sites
14 CHAPTER 4. DOCUMENT MANAGEMENT
You can biowse the les of a site by tapping on any of them. Tis opens a list
of the foldeis and les belonging to the site that you have peimission to view.
Figure 4.31: Folder and les
liom heie, you can click on a foldei and biowse deepei into the foldei hiei-
aichy oi click the Back buuon to navigate back to paient foldeis up to the initial
Sites list.
Single-tap on a le to open it. lf the le has nevei been downloaded befoie,
Sync will download it and open afei it has nished downloading. You can only
view the les contents if youi device has an app installed that can open the
le type. loi example, in oidei to open a PDl, you must have at least one PDl
viewei app installed. Otheiwise, you will see a message infoiming you that no
viewei is available and you need to install an app that can open the le.
Long-piess on any foldei oi le to nd a list of actions you can take on it
Add to Favorites, View Details, Download, Rename oi Delete. Tis actions menu
vaiies depending on which entiy type is selected le oi foldei.
On Gingeibiead, the actions menu looks like this
On lce Cieam Sandwich and above, you can nd the action icons and menu
at the top iight
Clicking on Add to Favorites (Gingeibiead) oi the giay stai (lce Cieam Sand-
wich) adds the selected le to the Favorites list. Favorites aie special les that
can be accessed and viewed even when you aie oine (moie details below). lf
a le is alieady maiked as a favoiite, youll see a Remove from Favorites oi blue
stai instead. Clicking on it iemoves the selected le fiom the Favorites list.
Clicking on View Details (Gingeibiead) oi the iound icon with the leuei i
(lce Cieam Sandwich) opens the details view, which displays the entiys meta-
data such as cieation date, authoi, veision, desciiption, etc.
4.8. LIFERAY SYNC 14
Figure 4.32: Gingerbread menu
Figure 4.33: ICS menu
Figure 4.34: Viewdetails
148 CHAPTER 4. DOCUMENT MANAGEMENT
lf you click on Download (oppy disk icon on lce Cieam Sandwich), it down-
loads and oveiwiites the local le copy.
You can iename a foldei oi le by clicking on the Rename option. Tis ie-
names the entiy in the poital.
Clicking on Delete deletes the le/foldei fiom the iemote poital, and othei
useis wont be able to view oi download it. On lce Cieam Sandwich and above,
you can select multiple entiies foi deletion
Figure 4.35: Actions
Some actions aie not ielated to a specic foldei oi le. You can nd these
actions in the menu on the top action bai when no entiy is selected (Gingeibiead
useis need to click on the device menu buuon). Depending on the device scieen
width, some icons may oveiow to the thiee dots buuon on the iight. Click on
this buuon to see all of the available actions.
Te Refresh buuon fetches and updates the list of foldeis and les that have
been changed in the poital.
Te Camera buuon allows you to quickly take a pictuie and upload the image
to the cuiient foldei. Te image le name is automatically geneiated with a time
stamp.
Te New Folder buuon asks you foi the name of the foldei you want to cieate
in the poital.
Te Upload buuon displays the types of local les you can upload to the
poital. Choosing Image, foi example, shows all images that aie stoied locally
on youi device. Once you choose the les and conim, these les aie uploaded
to the poital and aie placed in the cuiient foldei. By default, you can upload
images, videos, and audio les. lf you have installed an app on youi device that
4.8. LIFERAY SYNC 149
Figure 4.36: More options
can open and biowse any type of le, you will also see an option called Other
les.
Figure 4.37: Upload local les
Te Favorites menu option opens the favoiites list. All les that have been
maiked as favoiites show up in this list. You should maik youi most impoitant
les as favoiites because, as mentioned eailiei, the Favorites featuie gives you
quick oine access to them. You can view the contents of items in the Favorites
list, view theii metadata and, of couise, iemove them fiom the list.
Next, lets look at the iOS Sync app.
10 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.38: Favorites
iOS
Afei installing Lifeiay Sync foi iOS, an empty scieen appeais asking you to set
up the app. Tis scieen appeais whenevei piefeiences aie missing.
Figure 4.39: iOS Settings
Click on Seings in the toolbai and entei youi Lifeiay seivei ciedentials by
lling in youi Login, Password, and Server infoimation. Youi Login is eithei youi
usei accounts email addiess oi scieen name, whichevei you use to log in to the
poital in a biowsei. ln the Server eld, entei youi poitals URL. ln this example,
the seivei URL is hp://www.liferay.com. Click on Test Connection to check if
youi conguiation is coiiect.
Afei you have successfully tested youi connection, tap on the Documents
toolbai section and youll see a list of Lifeiay sites you have access to.
You can biowse the les of a site by tapping on its name oi icon. Tis opens
a list of the foldeis and les belonging to the site that you have peimission to
4.8. LIFERAY SYNC 11
Figure 4.40: iOS Settings
Figure 4.41: Sites
view.
liom heie, you can click on a foldei to biowse deepei into the foldei hiei-
aichy. You can also click on the Back buuon to navigate back to paient foldeis
up to the initial Sites list.
You can iefiesh the list by pushing it down. Tis updates all the les and
foldeis that have been changed in the poital.
When you click on a le, this le is downloaded fiom the iemote poital and,
if a pieviewei foi this le type is available, you can view the contents of the le.
Te next time you open a le, it wont download it again, instead, it opens the
local copy.
Teie aie thiee icons at the bouomof the scieen when you open a le. Click-
ing on the lefmost iound icon with the leuei i opens the details view, which
displays the entiys metadata such as cieation date, authoi, veision, desciiption,
etc.
Clicking on the stai icon at the centei adds the selected le to the Favorites
12 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.42: Folder and les
Figure 4.43: Refreshing
Figure 4.44: Opening a le
4.8. LIFERAY SYNC 13
Figure 4.45: Viewdetails
list. Favorites aie special les that can be accessed and viewed even when you
aie oine (moie details below). lf a le has alieady been maiked as a favoiite,
clicking on the stai icon iemoves the le fiom the Favorites list.
Clicking on the iightmost icon displays shaiing options. You can, foi ex-
ample, send the le as an email auachment, piint the le, oi copy it to youi
clipboaid. Some exteinal apps may also appeai in this list. loi example, you
can shaie youi le with social apps and messengeis if they aie available.
Figure 4.46: Share options
ln the le list, theies an Edit buuon. Clicking on it switches the app to the
edit mode as shown below
Selecting one oi moie les oi foldeis and clicking on the Delete buuon deletes
the selected les oi foldeis fiom the iemote poital. Once you delete les oi
foldeis fiom the iemote poital, othei useis wont be able to view oi download
them.
14 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.47: Edit mode
Selecting only one le oi foldei enables the Rename buuon. Click on it to
change the entiys name locally and iemotely.
To quickly delete a le oi foldei fiom the poital, you can also swipe iight
and click on the Delete buuon in the le list view
Figure 4.48: Deleting a le
lf you want to upload an image oi video to the poital, click the Plus buuon
at the top iight coinei. You should see thiee options
Take a photo or video opens youi cameia app and lets you take a photo oi
iecoid a video and upload it.
Choose Existing allows you to upload multiple photos oi videos stoied on
youi device.
Create New Folder lets you type the name of the foldei and cieates it in the
poital.
Te Favorites toolbai section opens the favoiites list. All les that have been
maiked as favoiites show up in this list. You should maik youi most impoitant
4.9. SUMMARY 1
Figure 4.49: Upload photos and videos
les as favoiites because, as mentioned eailiei, the Favorites featuie gives you
quick oine access to them. You can view the contents of items in the Favorites
list, view theii metadata and, of couise, iemove them fiom the list.
Figure 4.50: Favorites
All downloaded les aie stoied on youi device indenitely.
lf you want to delete downloaded les locally but dont want to iemove them
fiom the poital, go to Seings and click on the Clear Cache buuon.
4.9 Summary
ln this chaptei, we examined Lifeiays Documents and Media Libiaiy, a pow-
eiful and customizable viitual shaied diive. Lifeiay .1 intioduced the ability
to mount multiple exteinal iepositoiies to the Documents and Media libiaiy.
Te Documents and Media libiaiy can be used to stoie les of any kind. Te
1 CHAPTER 4. DOCUMENT MANAGEMENT
Figure 4.51: Deleting local copies
Documents and Media Display poitlet is meant to be conguied to show cho-
sen hieiaichies of foldeis and les fiom the Documents and Media libiaiy. Te
Media Galleiy is meant foi piesenting media les such as images oi videos.
Document types and metadata sets piovide a exible way to distinguish be-
tween dieient types of les and to dene custom metadata elds foi them.
Document pieviews aie automatically geneiated by default, but Lifeiay sup-
poits integiation with exteinal tools that oei gieatei speed, highei quality, and
additional functionality. linally, we discussed Lifeiay Sync, an add-on pioduct
foi Lifeiay .1 that allows youi Lifeiay seivei to diiectly synchionize les on
useis desktop and mobile enviionments.
Cu~v1rv
Lrvrv~ciNc 1ur Assr1 lv~xrvovx
Any type of content in Lifeiay is consideied an asset. ln chapteis 2 and 3, we al-
ieady examined Lifeiays most common type of asset web content. Othei types
of assets include blog posts, wiki aiticles, message boaid posts, bookmaiks, and
documents. lts possible foi developeis to dene custom asset types that uti-
lize Lifeiays asset fiamewoik. Oiiginally, the asset fiamewoik was cieated to
piovide a mechanism foi adding tags to blog entiies, wiki aiticles, and web con-
tent without ieimplementing the same functionality multiple times. Te asset
fiamewoik has been gieatly extended since then and it now suppoits tags, cat-
egoiies, vocabulaiies, comments, iatings, and asset ielationships.
Tis chaptei coveis the following topics
Tagging and categoiizing content
Using taigeted, single value, and multi-value vocabulaiies
Using laceted Seaich
Using the Asset Publishei
Seuing up display pages
Adding ielationships between assets
1
18 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Te Asset Publishei poitlet is designed to display multiple assets. lt has
quite a few conguiation options which well covei in this chaptei. By default,
abstiacts (pieviews) of iecently published assets aie displayed by the Asset Pub-
lishei poitlet and links to theii full views aie piovided. You can conguie the
Asset Publishei poitlet to display a table of assets, a list of asset titles, oi the full
content of assets. You can also conguie the Asset Publishei to display only
ceitain kinds of assets and you choose how many items to display in a list. Te
Asset Publishei poitlet is veiy useful foi displaying chosen types of content, foi
displaying iecent content, and foi allowing useis to biowse content by tags and
categoiies. Te Asset Publishei is designed to integiate with the Tags Naviga-
tion and Categoiies Navigation poitlets to allow this.
5.1 Tagging and Categorizing Content
Tags and categoiies aie two impoitant tools you can use to help oiganize in-
foimation on youi poital and make it easiei foi youi useis to nd the content
theyie looking foi thiough seaich oi navigation. Tagging and categoiizing web
content is easy. You can do it at the bouom of the same foim you use to add
content. lf you open the Categorization section of the foim, youll be piesented
with an inteiface foi adding tags and categoiies.
Figure 5.1: Tagging and categorizing content can be done at the same time
you create it.
Te Contiol Panel contains an inteiface foi managing tags and categoiies foi
each site in the poital. Tis inteiface can be used to manage all youi tags and
categoiies in one place. lt is impoitant that you both tag and categoiize youi
content when you entei it. Lets take a closei look at tags and categoiies.
5.1. TAGGING AND CATEGORIZING CONTENT 19
Tags
Tags aie an impoitant tool that you can use to help oiganize infoimation on youi
poital and make it easiei foi youi useis to nd content that theyie looking foi.
Tags aie woids oi phiases that you can auach to any content on the website.
Tagging content will make youi seaich iesults moie accuiate, and enable you
to use tools like the Asset Publishei to display content in an oiganized fashion
on a web page. Teie aie two ways to cieate tags you can do it thiough the
administiative console in the Contiol Panel, oi on the y as content is cieated.
Figure 5.2: The Add Tag Dialog
To cieate tags in the Contiol Panel, select the site that you want to cieate tags
foi, and select Tags. liom this scieen, you will be able to view any existing tags
and make new ones. To cieate a new tag, simply click Add Tag. Youll then be
asked foi the name of the tag, and youll have the ability to set peimissions foi
viewing oi managing the tag. You can also add piopeities to a tag. Piopeities
10 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
basically act like tags foi youi tags. Stiuctuially, piopeities aie key-value paiis
associated with specic tags that piovide infoimation about youi tags. You can
edit existing tags fiomthe Tags windowof on the Contiol Panel. You can change
the tag name, change the tags peimissions, delete the tag, oi add piopeities.
Tags aie not the only poital-wide mechanism foi desciibing content you
can also use categoiies.
Categories
Categoiies aie similai in concept to tags, but aie designed foi use by administia-
tois, not iegulai useis. Hieiaichies of categoiies can be cieated, and categoiies
can be giouped togethei in vocabularies. While tags iepiesent an ad hoc method
foi useis to gioup content togethei, categoiies exist to allow administiatois to
oiganize content in a moie ocial, hieiaichical stiuctuie. You can think of tags
like the index of a book and categoiies like its table of contents. Both seive the
same puipose to help useis nd the infoimation they seek.
Adding vocabulaiies and categoiies is similai to adding tags. Once youve
selected the site you want to woik on, select Categories fiomthe content section
of the Contiol Panel, and you will be piesented with the categoiies administia-
tion page.
Figure 5.3: Categories Administration Page
Clicking on a vocabulaiy on the lef displays any categoiies that have been
cieated undei that vocabulaiy. You can cieate newvocabulaiies simply by click-
ing Add Vocabulary and pioviding a name foi it. You can cieate categoiies in
a similai fashion by choosing a vocabulaiy on the lef, and then selecting Add
Category. Like tags, you can also piovide piopeities foi categoiies. Once you
5.2. TARGETED VOCABULARIES 11
have cieated some vocabulaiies and categoiies, you can take advantage of the
full capabilities of categoiies by cieating a nested hieiaichy of categoiies. To
nest categoiies, select what you want to be the paient categoiy, then diag any
categoiy that you want to become a child categoiy onto it. You will see a plus
sign appeai next to the name of the categoiy you aie diagging if you can add it
to the selected paient categoiy, if you see a ied x that means that you cannot
add that categoiy as a subcategoiy of paient categoiy that you have selected.
Once you have cieated a hieiaichy of categoiies, youi content cieatois will
have them available to apply to content that they cieate. Navigate to the Web
Content page of the Contiol Panel and click Add Content. Click the Categoiiza-
tion link fiom the iight-side menu and click Select on the vocabulaiy you would
like to use. A dialog box will appeai with youi categoiies. Select any ielevant
categoiies by checking the box next to them, and they will be applied to the
content.
Teie aie a seveial new enhancements to vocabulaiies and categoiies in Lif-
eiay .1. Te thiee main featuies aie taigeted vocabulaiies, single/multi-valued
vocabulaiies, and sepaiated widgets foi eveiy vocabulaiy.
5.2 Targeted Vocabularies
Taigeted Vocabulaiies allow you to decide which vocabulaiies can be applied to
an asset type and which vocabulaiies aie iequiied foi an asset type. To cong-
uie these seuings, go to the categoiies administiation page and mouse ovei the
vocabulaiy in the list until you see the edit icon to the iight. Select the icon to
ieveal a dialog box like the one below.
Te default value foi Associated Asset Types is All Asset Types. You can ne
tune youi choices by using the + and - buuons, which naiiows the scope of the
vocabulaiy to specic assets. ln the scieenshot above, notice how the vocabu-
laiy Famous Noses is conguied to be available foi Blogs and Web Content,
but it is not iequiied. lt is mandatoiy, howevei, foi Documents and Media Doc-
uments.
Single and Multi-valued Vocabularies
You can nowdecide if the usei can choose one oi moie categoiies fiomthe same
vocabulaiy to categoiize an asset. lf a vocabulaiy is single-valued you can only
choose one, and if it allows moie, you can choose seveial categoiies.
Seuing vocabulaiy values is done thiough the categoiies administiation page.
Edit a vocabulaiy and deselect the AllowMultiple Categories checkbox to set sin-
12 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Figure 5.4: You can target vocabularies by checking the AllowMultiple
Categories checkbox and then selecting the Asset Types.
Figure 5.5: Single-valued vocabularies, on the left, use radio buttons while
multi-valued vocabularies use checkboxes.
5.3. USING FACETED SEARCH 13
gle value vocabulaiies oi use the default option to set multi-value vocabulaiies.
Separated Widgets
Te thiid impoitant impiovement is eveiy vocabulaiy has its own sepaiated
widget. Tese widgets appeai in the Categoiization section of eveiy asset and
they allow useis to easily select appiopiiate categoiies foi that asset.
Figure 5.6: Nowthat vocabularies have their own widgets, its easy to
select available categories.
lts impoitant to use tags and categoiies with all youi content, so that content
is easiei foi useis to nd. Lets look at one of the ways useis will make use of
tags and categoiies seaiching foi content.
5.3 Using Faceted Search
To stay oiganized, l (RS) used to use a papei-based plannei. lt had vaiious sec-
tions foi vaiious aieas of my life. lts initial incaination came fiom a commeicial
14 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
company, but ovei the yeais l tweaked it into something that woiked foi me.
Tis nal veision (befoie l went digital) had dieient tabs foi dieient aieas of
my life that l wanted to keep tiack of daily items like tasks, notes, a spiiitual
section, and agenda pages that kept tiack of things l needed to go ovei with
specic people. A Planning section had tabs foi piojects, family, futuie items,
and iefeience.
Of couise, since this was papei-based, it had its limitations. lt was kind of
haid to nd stu. Did l put the note ld wiiuen about that new toy my daughtei
wanted in the Notes section oi in the lamily section` Oi maybe it was on my
While Out list, so l would iemembei to buy it befoie hei biithday`
Lifeiay content can be like this. Tat impoitant infoimation you iemembei
seeingwas it in a wiki aiticle, a message boaids post, oi web content` Did you
iemembei to tag it` lf you dont have this kind of infoimation, biowsing to
the content youie looking foi could be dicult. Tankfully, Lifeiay includes
a poweiful, faceted seaich function, which means you can diill down thiough
the dieient types of content, tags, and categoiies to iene youi seaich and nd
what you want. Lets see how to use it.
Searching for Portal Content
To get staited, diop the Seaich poitlet on a page and seaich foi something. Youll
see a page with iesults on the iight and a collection of facets on the lef.
Figure 5.7: The rst set of facets is content types. You can drill down to
specic types of content that contain the search terms you entered.
A facet is a combination of the infoimation about a specic indexed eld, its
teims, and theii fiequency. lacets aie typically named by the eld in question.
Te default facets aie asset types (pictuied above), asset tags, asset categoiies,
and modied time iange.
Te fiequency in which the teim was found foi each facet is listed in paien-
theses afei the facet. lt may jog youi memoiy to see that the teimyou seaiched
foi appeais in a blog entiy, and that may be all you need to nd what you weie
looking foi. lf, howevei, youi memoiy is moie foggy than that, oi youie seaich-
ing foi something youie not suie is actually theie, then the asset tags oi asset
categoiies facets may be moie helpful to you.
5.3. USING FACETED SEARCH 1
Figure 5.8: Asset tag facets provide you with more information list, and
the results to the right are rened by the facet you selected.
Figure 5.9: Drilling down creates a list of what you selected at the top of
the screen.
1 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Heie we can see that weve selected one of the tags, liferay, to fuithei iene
the seaich. Te tag appeais in a list at the top, and theies a ied X next to it
that lets us iemove it fiom oui ltei as we woik to inciease the ielevancy of oui
seaich. But maybe selecting only the tag isnt enough to ltei oui seaich into
something small enough to soit thiough. ln this case, we can fuithei iene the
seaich by selecting anothei facet, as below.
Figure 5.10: Selecting another facet further renes the search.
Nowweve selected web content, which is one paiticulai content type within
Lifeiay, and the list of potential hits on oui seaich teims has been diamatically
ieduced. ln this way, you can inteiactively tweak the seaich iesults to naiiow
them down, making it easiei to nd that pioveibial needle within the haystack.
Asset Types
Seaiching can only be done on assets. As has alieady been desciibed in this
chaptei, just about any entity in the poital is an asset and can be indexed and
seaiched. Undei the hood, this means that these entities use Lifeiays Asset APl
and have an lndexei dened.
Developeis can cieate custom seaichable assets within the poital. Tis is
desciibed in the Developeis Guide. loi this ieason, you may have additional
asset types dened in youi poital beyond the ones that Lifeiay ships with by
default. lf this is the case, you may wish to tweak the frequency threshold
and the max terms seuings to inciease the numbei of asset types displayed past
the default of 10. Tis is coveied in the section below on seaich options.
5.3. USING FACETED SEARCH 1
Asset Tags
lf tags have been applied to any asset that appeais in the iesult set, it may be
displayed in the Asset Tag facet. Tags aie handled in a similai way to how asset
types aie handled not all tags may appeai. Teie may be many moie than the
10 tags listed, but the default conguiation foi this facet is to show the top 10
most fiequent teims. As with asset types, this can be modied by seuing max
terms piopeity.
Asset Categories
lf categoiies have been applied to any asset that appeais in the iesult set, they
may be displayed in the Asset Categoiies facet. Yadda, yadda, yadda, same thing
as the two sections above. Tat last sentence was wiiuen to check if youie still
ieading.
Lets move on to advanced seaiching.
Advanced Searching
Te Seaich poitlets seaich box is deceptively simple. Tough you have only a
single eld foi seaich, theies a seaich syntax inheiited fiom Lucene that lets
you cieate veiy poweiful seaich queiies. Lets look at some ways you can use
seaich queiies.
Searing for specic elds: By default, seaiches aie peifoimed against a
long list of elds. Sometimes you want iesults foi a teim within a paiticulai
eld. Tis can be achieved using the eld seaich syntax [field]:[term]. loi
example, to seaich in the Title eld foi Liferay, use the following syntax
title:liferay
lf you seaich foi a phiase within a eld, suiiound the teim with double
quotation maiks
title:"Liferay Portal"
Wildcards: You can use wildcaids in exactly the way you use them with
youi opeiating system foi a single chaiactei wildcaid, use ?, foi the multiple
chaiactei wildcaid, use *.
Boolean operators: You can use logic opeiatois, such as AND, OR, NOT, +,
and - in youi seaiches. Te AND opeiatoi matches assets in which the teims
between the AND opeiatoi exist. loi example, to seaich foi both Lifeiay and
Kaleo Woikow, use this queiy
18 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
"liferay" AND "kaleo workflow"
Te OR opeiatoi is the default, if theies no opeiatoi between two teims, the
OR opeiatoi takes eect. OR nds matches if any teim exists in an asset.
Te + opeiatoi iequiies that the teim exists somewheie in some eld in the
asset. lf you wanted to seaich foi something that must contain liferay and may
contain portal, use this queiy
+liferay portal
Te NOT opeiatoi excludes assets that contain the teimafei the NOT opeiatoi.
lt iequiies that at least two teims be piesent
"Liferay Portal" NOT "Liferay Social Office"
Te - opeiatoi is similai it excludes assets that contain the teim afei the -
symbol
"Liferay Portal" - "Liferay Social Office"
Grouping: You can use paientheses within youi queiies to foimsub-queiies,
in a similai fashion to an SQL statement. loi example, to seaich foi liferay oi
social oce and website, use this queiy
(liferay OR "social office") AND website
As you can see, the seaich syntax is veiy poweiful. Teies moie you can
do with it than what is listed heie, to view the full syntax, visit the Lucene URL
above.
Next, well look at how the Seaich poitlet can be conguied.
Setting Search Options
As with Lifeiays othei poitlets, you can conguie the Seaich poitlet via the
conguiation scieen, which looks like the below illustiation.
Display Asset Type Facet: Toggles whethei the Asset Type facet appeais.
Display Asset Tags Facet: Toggles whethei the Asset Tags facet appeais.
Display Asset Categories Facet: Toggles whethei the Asset Categoiies facet
appeais.
Display Modied Range Facet: Toggles whethei the date modied iange
facet appeais.
Display Results in Document Form: Nevei use this in pioduction. Develop-
eis use this featuie to view seaich iesponses in theii geneiic, Document-based
5.3. USING FACETED SEARCH 19
Figure 5.11: Basic search conguration is pretty straightforward.
foimat. Pait of a developeis job when wiiting seaich indexeis is to conveit
Documents (the objects that get indexed) to the actual object and back again.
Tis option allows developeis to see how theii objects aie being indexed.
View in Context: When an asset is clicked, show it in the poitlet to which
it belongs.
Display Main ery: Showthe exact seaich queiy that the poitlet geneiated
to the seaich engine. Again, nevei use this in pioduction, this is foi development
puiposes only.
Display Open Sear Results: Shows iesults fiom thiid paity Open Seaich
plugins, if they aie installed. Tis is foi backwaid compatibility only developeis
aie encouiaged to ie-design theii seaich code as desciibed in Liferay in Action,
and then custom assets aie aggiegated with native poital assets seamlessly.
Tese aie the basic options, but suiely you didnt miss the fact that theie aie
also advanced options.
Conguiing advanced seaich iequiies a bit moie technical acumen than you
might expect, because theie aie so many piopeities to tweak. Tankfully, in
most instances, you shouldnt need to change a thing. lf you do, howevei, the
conguiation is done thiough a JSON object.
10 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
lf you dont know what a JSON object is, dont woiiy its not a dicult
concept. JSON stands foi JavaSciipt Object Notation. An Object is a sofwaie
development teim foi anything that can be iepiesented in code. Objects have
aributes, oi sometimes these aie called elds, and they aie veiy similai to elds
youd nd on a foim that youie lling out. Sofwaie developeis use the woid
object to iefei geneiically to anything like this that they can desciibe in the
sofwaie, foi all intents and puiposes, objects could just as easily have been
called Tings. loi example, one type of object used in Lifeiay is a Usei. A Usei
can be iepiesented in code, and it has many elds, such as a name, an email
addiess, and moie. JSON is one way of desciibing objects like this.
Te object weie conceined with is called facets. Heies what it looks like,
in all its gloiy, in JSON. Explanation of the seuings follows the object below.
{"facets": [
{
"displayStyle": "asset_entries",
"weight": 1.5,
"static": false,
"order": "OrderHitsDesc",
"data": {
"values": [
"com.liferay.portlet.bookmarks.model.BookmarksEntry",
"com.liferay.portlet.blogs.model.BlogsEntry",
"com.liferay.portlet.calendar.model.CalEvent",
"com.liferay.portlet.documentlibrary.model.DLFileEntry",
"com.liferay.portlet.journal.model.JournalArticle",
"com.liferay.portlet.messageboards.model.MBMessage",
"com.liferay.portlet.wiki.model.WikiPage",
"com.liferay.portal.model.User"
],
"frequencyThreshold": 1
},
"label": "asset-type",
"className": "com.liferay.portal.kernel.search.facet.AssetEntriesFacet",
"fieldName": "entryClassName"
},
{
"displayStyle": "asset_tags",
"weight": 1.4,
"static": false,
"order": "OrderHitsDesc",
"data": {
"maxTerms": 10,
"displayStyle": "list",
"frequencyThreshold": 1,
"showAssetCount": true
},
"label": "tag",
"className": "com.liferay.portal.kernel.search.facet.MultiValueFacet",
"fieldName": "assetTagNames"
},
{
5.3. USING FACETED SEARCH 11
"displayStyle": "asset_tags",
"weight": 1.3,
"static": false,
"order": "OrderHitsDesc",
"data": {
"maxTerms": 10,
"displayStyle": "list",
"frequencyThreshold": 1,
"showAssetCount": true
},
"label": "category",
"className": "com.liferay.portal.kernel.search.facet.MultiValueFacet",
"fieldName": "assetCategoryTitles"
},
{
"displayStyle": "modified",
"weight": 1.1,
"static": false,
"order": "OrderHitsDesc",
"data": {
"ranges": [
{
"range": "[past-hour TO *]",
"label": "past-hour"
},
{
"range": "[past-24-hours TO *]",
"label": "past-24-hours"
},
{
"range": "[past-week TO *]",
"label": "past-week"
},
{
"range": "[past-month TO *]",
"label": "past-month"
},
{
"range": "[past-year TO *]",
"label": "past-year"
}
],
"frequencyThreshold": 0
},
"label": "modified",
"className": "com.liferay.portal.kernel.search.facet.ModifiedFacet",
"fieldName": "modified"
}
]}
Now that youve seen the object, dont be daunted by it. Heie aie all the
seuings within the object that you can tweak.
className: Tis eld must contain a stiing value which is the lQCN (fully
qualied class name) of a java implementation class implementing the lacet
12 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
inteiface. Lifeiay piovides the following implementations by default
com.liferay.portal.kernel.search.facet.AssetEntriesFacet
com.liferay.portal.kernel.search.facet.ModifiedFacet
com.liferay.portal.kernel.search.facet.MultiValueFacet
com.liferay.portal.kernel.search.facet.RangeFacet
com.liferay.portal.kernel.search.facet.ScopeFacet
com.liferay.portal.kernel.search.facet.SimpleFacet
data: Tis eld takes an aibitiaiy JSONobject (a.k.a. ) foi use by a specic
facet implementation. As such, theie is no xed denition of the data eld. Each
implementation is fiee to stiuctuie it as needed. Te value dened heie matches
the implementation thats selected in the className auiibute above.
displayStyle: Tis eld takes a stiing value and iepiesents a paiticulai
template implementation which is used to iendei the facet. Tese templates aie
noimally JSP pages (but can also be implemented as Velocity oi lieemaikei tem-
plates piovided by a theme if the poital piopeity theme.jsp.override.en-
abled is set to true). Te method of matching the stiing to a JSP is simply done
by piexing the stiing with /html/poitlet/seaich/facets/ and appending the .jsp
extension.
loi example, "displayStyle": "asset_tags" maps to the JSP
/html/portlet/search/facets/asset_tags.jsp
Aimed with this knowledge a ciafy developei could cieate custom display
styles by deploying custom (new oi oveiiiding) JSPs using a JSP hook. See the
Developers Guide oi Liferay in Action foi moie infoimation on hook plugins.
eldName: Tis eld takes a stiing value and denes the indexed eld on
which the facet opeiates.
loi example, "fieldName": "entryClassName" indicates that the speci-
ed facet implementation opeiates on the entryClassName indexed eld.
Note: You can identify available indexed elds by enabling the Seaich poit-
lets Display Results in Document Formconguiation seuing and then expanding
individual iesults by clicking the [] to the lef of theii titles.
label: Tis eld takes a stiing value and iepiesents the language key that
is used foi localizing the title of the facet when its iendeied.
order: Tis eld takes a stiing value. Teie aie two possible values
OrderValueAsc Tis tells the facet to soit its iesults by the teim values,
in ascending oidei.
OrderHitsDesc Tis tells the facet to soit its iesults by the teimfiequency,
in descending oidei.
static: Tis eld takes a boolean value (true oi false). Te default value
is false. A value of true means that the facet should not actually be iendeied
5.3. USING FACETED SEARCH 13
in the Ul. lt also means that it should use pie-set values (stoied in its data eld)
iathei than inputs dynamically applied by the end usei. Tis allows foi the
cieation of pie-conguied seaich iesults.
lmagine you would like to cieate a pie-conguied seaich that ietuins only
images (i.e. the asset type is DLFileEntry and the indexed eld extension should
contain the values bmp, gif, jpeg, jpg, odg, png, oi svg). We would need two
static facets, one with eldName entiyClassName and anothei with eld-
Name extension. Tis could be iepiesented using the following facet con-
guiation
{
"displayStyle": "asset_entries",
"static": true,
"weight": 1.5,
"order": "OrderHitsDesc",
"data": {
"values": [
"com.liferay.portlet.documentlibrary.model.DLFileEntry"
],
"frequencyThreshold": 0
},
"className": "com.liferay.portal.kernel.search.facet.AssetEntriesFacet",
"label": "asset-type",
"fieldName": "entryClassName"
},
{
"displayStyle": "asset_entries",
"static": true,
"weight": 1.5,
"order": "OrderHitsDesc",
"data": {
"values": ["bmp", "gif", "jpeg", "jpg", "odg", "png", "svg"],
"frequencyThreshold": 0
},
"className": "com.liferay.portal.kernel.search.facet.MultiValueFacet",
"label": "images",
"fieldName": "extension"
}
weight: Tis eld takes a oating point (oi double) value and is used to
deteimine the oideiing of the facets in the facet column of the seaich poitlet.
lacets aie positioned with the laigest values at the top. (yes, the cuiient imple-
mentation is countei-intuitive and peihaps could be ieveised in futuie veisions).
Conguiing seaich using a JSON object is a bit unusual, but as you can see,
its not as haid as it looks initially.
14 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Summary
Seaich is a poweiful component of Lifeiay Poitals asset fiamewoik. Te pio-
clivity of assets means that theie is an extensible, iobust, and conguiable seaich
mechanism thioughout the poital that allows administiatois to optimize the
seaich expeiience of theii useis. Useis also get an easy to use seaich inteiface
that makes use of the tags and categoiies that they themselves apply to vaiious
pieces of content, iegaidless of the type of content. Tis makes Lifeiays seaich
tiuly foi the people.
Powei useis can leain an extended seaich syntax that lets them ciaf veiy
specic seaiches. Tese seaiches can be used on laige installations with lots of
data to nd the pioveibial needle in the pioveibial haystack. Administiatois
can tune the conguiation of seaich poitlets so that they aie optimized foi the
contents of theii communities.
Next, well look at how the Asset Publishei poitlet makes even moie exten-
sive use of Lifeiays asset fiamewoik to biing ielevant content to useis.
5.4 Using the Asset Publisher
As we cieate web content, its impoitant to keep in mind that to Lifeiay, the
pieces of content aie assets, just like message boaid entiies and blog posts. Tis
allows you to publish youi web content using Lifeiays Asset Publishei.
You can use the Asset Publishei to publish a mixed gioup of vaiious kinds of
assets such as images, documents, blogs, and of couise, web content. Tis helps
in cieating a moie dynamic web site you can place usei-cieated wiki entiies,
blog posts oi message boaid messages in context with youi content. Lets look
at some of its featuies.
Querying for Content
Te Asset Publishei poitlet is a highly conguiable application that lets you
queiy foi mixed types of content on the y. By giving you the ability to contiol
what and how content is displayed fiom one location, the Asset Publishei helps
you to bubble up the most ielevant content to youi useis.
To get to all the poitlets options, click the Conguration link in the poitlets
menu (the wiench icon).
Te ability to conguie how content is displayed and selected by youi useis
fuithei demonstiates the exibility of the Asset Publishei. You get to choose
how content is displayed. You can select it manually foi display in a similai
5.4. USING THE ASSET PUBLISHER 1
way to the Web Content Display poitlet oi you can set up piedened queiies
and lteis and let the poital select the content foi you, based on its type oi its
tags and categoiies.
Lets ist look at how we might select content manually. Youll see that its
veiy similai to the Web Content Display poitlet.
Selecting assets manually By selecting Manual fiom the select box beneath
Asset Selection, you tell the Asset Publishei that you want to select content man-
ually. You can select what you want to be published within the poitlet, oi you
can cieate new content fiom within the Asset Publishei.
Figure 5.12: Selecting assets manually is very similar to the Web Content
Display portlet, except you have many other content types to choose from.
Clicking Add New gives you a menu of options, enabling you to cieate the
content iight wheie you aie. You can cieate blogs, bookmaiks, calendai entiies,
1 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
documents, images, and of couise, web content. Anything you cieate heie is
added to the list below of assets that aie displayed by the poitlet.
Clicking Select Existing gives you a similai menu, except this time you can
pick fiom existing content in the poital that eithei you oi youi useis have cie-
ated. Has someone wiiuen an excellent wiki page that you want to highlight`
Select it heie, and it will be displayed.
Te Asset Publishei enables you to mix and match dieient content types in
the same inteiface. Once you have youi content selected, you can move on to
the display types to conguie how the content appeais.
Most of the time, howevei, youll likely be using the Asset Publishei to select
content dynamically.
Selecting assets dynamically Te Asset Publisheis default behavioi is to se-
lect assets dynamically accoiding to iules that you give it. Tese iules can be
stacked on top of each othei so that they compliment each othei to cieate a
nice, iened queiy foi youi content. You have the following options foi cieat-
ing these iules
Scope: Choose the sites oi oiganizations fiom which the content should be
selected.
Asset Type: Choose whethei youll display any asset oi only assets of a
specic type, such as only web content, only wiki entiies, oi any combinations
of multiple types.
Filter Rules: Add as many lteis on tags oi categoiies as you like. You can
choose whethei the content contains oi does not contain any oi all categoiies
oi tags that you entei.
Once youve set up youi ltei iules foi dynamically selecting youi content,
you can then decide how the content will be displayed.
Te Display Seuings section gives you piecise contiol ovei the display of
youi assets. Teie aie a multitude of options available to conguie how you
want youi content to appeai. You can conguie the style, length of abstiacts,
behavioi of the asset link, maximum items to display, pagination type and le
conveisions. Additionally, you can enable piinting, ags, iatings, comments
and comment iatings, and these woik the same way they do in the Web Content
Display poitlet.
You can display the content ietuined by the lteis above in oidei by title,
cieate date, modied date, view count and moie in ascending oi descending
oidei. loi instance, you may have a seiies of How To aiticles that you want
displayed in descending oidei based on whethei the aiticle was tagged with the
hammer tag. Oi, you may want a seiies of video captuies to display in ascending
5.5. SETTING UP DISPLAY PAGES 1
Figure 5.13: You can lter by tags and categories, and you can set up as
many lter rules as you need.
oidei based on a categoiy called birds. You can also gioup by Asset, Type oi
Vocabularies. Vocabulaiies aie gioups of categoiies dened by administiatois
in the Categories section of the Contiol Panel.
ln the Ordering and Grouping section of the Asset Publishei, you have gieat
contiol ovei how content is oideied and giouped in the list, but this is only
one aspect of how youi content will be displayed. You can iene the display
thiough many othei display seuings.
5.5 Setting up Display Pages
Te Display Seuings section gives you piecise contiol ovei the display of youi
assets. Teie aie a multitude of options available to conguie how you want
youi content to appeai. You can conguie the style, length of abstiacts, behav-
ioi of the asset link, maximum items to display, pagination type and le con-
veisions. Additionally, you can enable piinting, ags, iatings, comments and
comment iatings, and these woik the same way they do in the Web Content
Display poitlet.
18 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Display Style Abstracts: Shows the ist 200-00 chaiacteis of the content,
dened by the Abstract Length eld.
Table: Displays the content in an HTML table which can be styled by a theme
developei.
Title List: Te contents title as dened by the usei who enteied it.
Full Content: Te entiie content of the entiy.
Other Settings Asset Link Behavior: Te default value is Show Full Content.
With this value selected, when the link to an asset is clicked, the full asset is
displayed in the cuiient Asset Publishei. lf the value View in a Specic Portlet is
selected, clicking on an asset causes that asset to be displayed in the poitlet to
which the asset belongs. loi example, a blog entiy would be displayed in the
Blogs poitlet wheie it was cieated. Likewise, a foium post would be displayed
in the Message Boaids poilet wheie it was cieated. Similaily, a geneiic Web
Content aiticle would be displayed in the Asset Publishei of its conguiated
Display Page. See the secton below on Display Pages foi moie infoimation.
Maximum Items to Display: You can display 1-100 items.
Pagination Type: Select Simple oi Regulai. Simple shows pievious and next
navigation, iegulai includes a way of selecting the page to which youd like to
navigate.
Exclude Assets with 0 Views: lf an asset has not been viewed, exclude it
fiom the list.
ShowAvailable Locales: Since content can be localized, you can have diei-
ent veisions of it based on locale. Tis will show the locales available, enabling
the usei to view the content in the language of his oi hei choice.
Enable Conversion To: lf you have enabled Lifeiay Poitals OpenOce.oig
integiation, you can allow youi useis to conveit the content to one of seveial
foimats, including PDl.
Below these options aie the same ones in the Web Content Display poitlet
enable piint, enable comments, enable iatings, etc.
ShowMetadata: Allows you to select fiom the available metadata types (see
below).
Enable RSS Subscription: Tis lets useis subsciibe to the content via RSS
leeds.
Te Display Seuings section of the Asset Publishei has numeious options
to help you conguie how youi content selections aie displayed to youi useis.
Even though theie aie many choices, its easy to go thiough the options and
quickly adjust the ones that apply to you. Youll want to use the Asset Publishei
5.5. SETTING UP DISPLAY PAGES 19
Figure 5.14: Available metadata types
to queiy foi mixed assets in the poital that have ielevant infoimation foi youi
useis.
Next, well look at Display Pages, an addition to the asset fiamewoik intio-
duced by Lifeiay .1.
Display Page
lf youve been using Lifeiay foi a while, oi youve just spent a liule bit of time
with this guide, you might have noticed something about how Lifeiay handles
web contentcontent is nevei tied diiectly to a page. While this can be useful
(because it means that you dont have to iecieate content if you want to display
the same thing on multiple pages), it also means that you dont have a static
URL foi any web content, which is bad foi seaich engine optimization.
As an impiovement, Lifeiay has intioduced the concept of Display Pages
and Canonical URLs. Each web content entiy on the poital has a canonical
URL, which is the ocial location of the content that is iefeienced any time the
content is displayed. A Display Page can be any page with an asset publishei
conguied to display any content associated with the page. When adding oi
editing web content aiticles, you can select a Display Page, but only pages with
a conguied asset publishei aie available foi selection.
To cieate a Display Page, you can cieate a page youiself, add an Asset Pub-
lishei poitlet and conguie it youiself. Alteinatively, you can use the Content
180 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
Display Page page template included with Lifeiay. lf youie cieating a Display
Page manually, once youve added an Asset Publishei poitlet to the page, open
its conguiation window. Ten check the Set as the Default Asset Publisher for
is Page box.
You may now be thinking, Wait, you just told me that each Web Content
item has its own URL, and that this is somehow ielated to pages wheie we
display a whole bunch of content on the same page` Yes. Tats exactly what
l said. Just watchcieate a display page called My Web Content Display Page
somewheie on youi poital, using the Content Display Page template. Now, on a
dieient page, add a Web Content Display poitlet. Click the Add Web Content
buuon, entei a title and some content, click on Display Page at the iight, and
select the Display Page you just cieated. Ten click Publish.
Figure 5.15: Selecting a Display Page
ln the Asset Publishei of the My Web Content Display Page, you can nowclick
the Read More link to display the content. Notice that the canonical URL foi
content appeais in youi biowseis addiess bai. lf you cieate youi own custom
display page, any additional poitlets that you place on the page aie displayed
along with the content when you access it via the canonical URL. lf you used the
Content Display Page page template foi youi Display page, it not only featuies
a conguied Asset Publishei poitlet but also a Tags Navigation, a Categoiies
Navigation, and a Seaich poitlet. Tese tools help useis to quickly identify
ielevant content.
5.6. DEFINING CONTENT RELATIONSHIPS 181
Figure 5.16: The Canonical URL
Lets move on to anothei new featuied intioduced by Lifeiay .1.
5.6 Dening content relationships
Related Assets is a new featuie in Lifeiay .1 that enables you to connect any
numbei of assets within a site oi acioss the poital, even if they dont shaie any
tags and aient in the same categoiy. Weve alieady seen that you can show
ielated assets within the display foi a specic asset, and with the Related Assets
poitlet you can show links to any assets which aie ielated to content displayed
on that page.
Te Related Assets poitlet is based on the Asset Publishei and possseses
essentially the same inteiface with one key dieience. Te Asset publishei dis-
plays any content that meets the ciiteiia selected in the poitlet conguiation.
Te Related Assets poitlet only displays content that meets the ciiteiia, and also
is listed as a ielated asset foi a piece of content that is cuiiently published on
the page wheie it is placed. Lets take a look at the the Related Assets poitlet.
As a pieiequisite foi the Related Assets poitlet to display ielated assets, you
conguie it to show the content you want displayed. To do this, go to the Asset
Publishei poitlet and select the wrench icon in the uppei iight coinei of the
poitlet. Undei the Setup tab, set type of asset(s) to display using the Asset Type
menu. Te default value is set to Any. You can naiiow the scope of the poitlet
to display any single categoiy of asset type oi select multiple assets fiom the
menu.
liltei options let you set minimum iequiiements foi displaying assets by
theii categoiies, tags, and custom elds. Oideiing and Giouping allows you to
oiganize assets using the same ciiteiia. Display seuings allow you to customize
how asssets aie shown in the poitlet. Tey can be listed by title, in a table,
by abstiact oi full content. You can conveit assets to dieient document types
like ODT, PDl, and RTl. You can choose to show vaiious metadata elds such
as authoi, modication date, tags, and view count. You can even enable RSS
subsciiptions and customize theii display seuings.
When you aie nished seuing the Souice and liltei options, click Save. But
hold on a minute. You saw the message that says, You have successfully
182 CHAPTER 5. LEVERAGING THE ASSET FRAMEWORK
updated the setup, but theie still aient any assets displayed in the ielated
assets poitlet. Why` You cannot see any ielated assets until you select an asset
in the Asset Publishei.
Figure 5.17: Select an asset in the Asset Publisher to see its related assets
displayed in the Related Assets portlet.
Once you select an asset, its ielated assets will display in the Related Assets
poitlet, similai to the image above.
5.7 Summary
ln this chaptei, we exploied Lifeiays asset fiamewoik. Any type of content in
Lifeiay is consideied an asset and can utilize the featuies piovided by the asset
fiamewoik tags, categoiies, comments, iatings, and ielationships. We exam-
ined the Asset Publishei poitlet and looked at the many conguiation options
foi choosing what kinds of assets to display and how to display them. We saw
that the Asset Publishei poitlet is designed to integiate with the Tags Naviga-
tion and Categoiies navigation poitlets to allow useis to biowse content moie
easily. We also leained about the Display Page auiibute of web content, the
Content Display Page page template, and canonical URLs foi assets. Assets can
have display page associated with them so that the full view of the asset is dis-
played on the display page. Te display page of an asset is used in the assets
canonical URL.
Cu~v1rv
PrvsoN~iiz~1ioN ~Nu CUs1oxiz~1ioN
ln this chaptei, we discuss seveial ways Lifeiay useis can customize pages, ap-
plications, and the way they use youi poital. Well covei the following topics
Peisonal Sites
Customizable Pages and Applications
Using a Rules Engine
Peisonal sites allow each poital usei to manage and customize a set of public
and/oi piivate pages and any associated content oi applications. Public pages
piovide a means of making content publicly available while piivate pages pio-
vide a means of hiding infoimation fiomothei useis. Lifeiay .1 intioduced cus-
tomizable pages and applications. Administiatois can designate ceitain pages
oi applications as customizable, which allows each usei to make and save theii
own customizations. Lifeiay Enteipiise Edition piovides a iules engine which
allows administiatois to cieate custompoital iules and simplify complex blocks
of code containing lots of if-else statements. Lets stait by discussing pei-
sonal sites.
183
184 CHAPTER 6. PERSONALIZATION AND CUSTOMIZATION
6.1 User Personal Sites
By default, newly cieated useis in Lifeiay aie each gianted a peisonal site. Each
usei functions as the site administiatoi of his oi hei peisonal site. Peisonal sites
aie fully customizable but cannot have moie than one membei. Te public pages
of peisonal sites piovide a space foi useis to publish content that theyd like to
make accessible to anyone, including guests. Usei blogs aie ofen placed on
public peisonal site pages. Content and applications that useis would like to
ieseive foi peisonal use aie ofen placed on the piivate pages of peisonal sites.
loi example, each usei can add a Documents and Media poitlet to his oi hei
piivate pages and use it as an online piivate le iepositoiy.
lf youd like to disable peisonal sites foi youi poital, just add the following
piopeities to youi portal-ext.properties le
layout.user.public.layouts.enabled=false
layout.user.private.layouts.enabled=false
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
404 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 40
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
40 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 40
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
408 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 409
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.
410 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 411
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
412 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 413
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
414 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 41
16:11:50,585 INFO [PortletHotDeployListener:222] Registering portlets
for weather-portlet
\index{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
4 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/
48 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 49
<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.
40 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 41
. 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.
42 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 43
Domain Conguration - Continued
Lets tie up some loose ends with iegaids to Lifeiay being able to access youi
database and mail session.
2. Shutdown youi domains application seivei if it is cuiiently iunning.
3. Cieate a portal-ext.properties le in the Liferay Home foldei men-
tioned at the beginning of this Glasslish installation section.
4. 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.
44 CHAPTER 14. INSTALLATION AND SETUP
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).
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
8
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
14.10. INSTALLING LIFERAY ON JETTY 7 4
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.
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
9
hup//www.mysql.com/pioducts/connectoi/
48 CHAPTER 14. INSTALLATION AND SETUP
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.
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
14.10. INSTALLING LIFERAY ON JETTY 7 49
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-
<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>
480 CHAPTER 14. INSTALLATION AND SETUP
<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>
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>
14.10. INSTALLING LIFERAY ON JETTY 7 481
<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>
<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'
482 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.
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.
18
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 1
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.
Figure 14.41: WebLogic Data Sources
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.
1 CHAPTER 14. INSTALLATION AND SETUP
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.
. 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.
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).
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 1
Figure 14.42: WebLogic: Mail Sessions
. 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.
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.
18 CHAPTER 14. INSTALLATION AND SETUP
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.
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.
14.16. INSTALLING LIFERAY ON WEBLOGIC 10 19
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.
19
hup//www.lifeiay.com/downloads/lifeiay-poital/additional-les
14.17. INSTALLING LIFERAY ON ORACLE WEBLOGIC 10.3 21
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.
Figure 14.44: WebLogic Data Sources
1. Select Services Data Sources. Click New Generic Data Source.
22 CHAPTER 14. INSTALLATION AND SETUP
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.
Figure 14.45: Creating a data source in WebLogic 10.3
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.
14.17. INSTALLING LIFERAY ON ORACLE WEBLOGIC 10.3 23
. 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.
Figure 14.46: WebLogic Mail Sessions
24 CHAPTER 14. INSTALLATION AND SETUP
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.
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
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
14.17. INSTALLING LIFERAY ON ORACLE WEBLOGIC 10.3 2
<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
Te portal-setup-wizard.properties le the setup wizaid cieates has
setup.wizard.enabled=false conveniently specied foi you.
2 CHAPTER 14. INSTALLATION AND SETUP
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.
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.7 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-
4 CHAPTER 15. MANAGEMENT
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-specic 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.
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.
15.7. MANAGING PORTAL SETTINGS
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.
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.
Lets discuss these seuings next.
CHAPTER 15. MANAGEMENT
Figure 15.13: Portal Settings Pages
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-
15.7. MANAGING PORTAL SETTINGS
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.
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).
8 CHAPTER 15. MANAGEMENT
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.8 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
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
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 9
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
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
0 CHAPTER 15. MANAGEMENT
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
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 Ceiticate Authoiity. Highlight the
machine that is the ceiticate authoiity, iight click on it, and click Properties.
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 1
liom the Geneial menu, click View Certicate. Select the Details view, and click
Copy To File. 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.
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.
1
objectClass=inetOrgPerson
2 CHAPTER 15. MANAGEMENT
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.
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.
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.
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 3
Figure 15.14: Testing LDAP Users
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.
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.
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.
4 CHAPTER 15. MANAGEMENT
Figure 15.15: Mapping LDAP Groups
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
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
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE
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.
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.
CHAPTER 15. MANAGEMENT
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
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.
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE
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).
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.
8 CHAPTER 15. MANAGEMENT
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
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.
15.8. INTEGRATING LIFERAY USERS INTO YOUR ENTERPRISE 9
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.
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.
80 CHAPTER 15. MANAGEMENT
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.
15.9 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 gioups of useis that tianscend
oiganizational hieiaichies. 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.
15.9. SUMMARY 81
We also looked at how to conguie passwoid policies foi useis. Next, we
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
Monitoiing
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.
82
83
Mail Host Names
Mail Host Names appeais afei Authentication and Useis on the Poital Seuings
page of the contiol panel. You can entei othei mail host names (one pei line)
besides the one you conguied on the Geneial tab. Tis lets the poital know
which mail host names aie owned by youi oiganization.
Email Notications
Teie aie ve tabs undei the Email Notications page of Poital Seuings. Te
Sendei tab allows you to set the poitals administiative name and email addiess.
By default, these aie Joe Bloggs and test@liferay.com. You can change
them to whatevei you want. Tis name and email addiess will appeai in the
liom eld in all email messages sent by the poital.
Figure 16.1: Automated Emails: Account Created Notication
Te othei foui tabs aie Account Cieated Notication, Email Veiication
Notication, Passwoid Changed Notication and Passwoid Reset Notication.
84 CHAPTER 16. USING THE CONTROL PANEL
Tese tabs allowyou to customize the email messages that aie sent to useis each
time any of those foui events occui.
Figure 16.2: Denition of Terms for Automated Emails
A list of tokens, entitled Denition of Teims, is piovided so you can inseit
ceitain values (such as the poital URL oi the usei lD) when you aie seuing up
the custom email messages.
Identication
Te identication section has seveial links foi addiesses, phone numbeis and
othei infoimation you can conguie in youi poital. Tis allows you to set up
contact infoimation foi the oiganization that owns the poital. Developeis can
queiy foi this infoimation in theii applications.
Miscellaneous: Display Settings
Tis section allows you to set the default poital language and the time zone.
You can also set up a poital-wide logo which appeais in the top lef coineis of
poital pages.
Lifeiays default theme is conguied to display the poital logo. loi custom
themes, you can choose whethei oi not to display the logo. Be caieful to choose
an image le that ts the space. lf you pick something too big, it might oveilap
with the navigation. Next, lets look at how to customize dieient types of
poital assets using custom elds.
16.1 CustomFields
Custom elds appeai beneath Poital Seuings in the Poital section of the contiol
panel. Custom elds aie a way to add auiibutes to many types of assets in the
poital. loi example, if youie using Lifeiay Poital to cieate a site foi iating
16.1. CUSTOM FIELDS 8
Figure 16.3: Server Conguration Miscellaneous Display Settings
8 CHAPTER 16. USING THE CONTROL PANEL
books, you might assign the Usei object a custom eld called lavoiite Books. lf
youie using the wiki foi book ieviews, you might add elds foi Book Title and
Book Authoi.
To add a custom eld, click on the Custom Fields link in the contiol panel.
Ten choose a iesouice, click on the Edit link next to it and select Add Custom
Field.
Figure 16.4: CustomFields Resource List
liom heie you will need to add the custom eld key. Te key appeais as
the label foi the eld on the foim. loi some poital assets (like the Usei), custom
elds aie a sepaiate section of the foim. loi otheis, as can be seen above, custom
elds aie integiated with the default elds on the foim. Additionally, develop-
eis can access custom elds piogiamatically thiough the <liferay-ui:cus-
tom-attribute /> tag.
You can cieate elds of many dieient types text elds (indexed oi seciet),
integeis, selection of multiple values and moie. Once youve cieated a eld, you
cannot change its type.
16.2. MONITORING 8
Figure 16.5: CustomFields Integrated with the Rest of the Fields on the
Wiki Form
16.2 Monitoring
Te next link on the lef side of the contiol panel is foi monitoiing. You can use
the Monitoiing page to view all of the live sessions in the poital. loi peifoi-
mance ieasons, this seuing is usually tuined o in pioduction.
16.3 Plugins Conguration
Te Plugins Conguiation page contains tabs foi thiee types of plugins poitlets,
themes and layouts. You can use these tabs to view which ioles can add plugins
to pages oi you can make the plugins active oi inactive.
Note that this is foi basic conguiation if you want to view the existing
peimission conguiation foi a given poitlet and/oi modify that conguiation
foi existing ioles, this is wheie you can do that. lf you need to add peimissions
to new ioles foi a given poitlet, use the Roles section of the contiol panel and
the Actions Dene Permissions buuon. Next, lets look at how to apply seivei
conguiations.
88 CHAPTER 16. USING THE CONTROL PANEL
16.4 Server Administration
Te Seivei Administiation page of the contiol panel lets you peifoim vaiious
tasks ielated to the poital seivei itself, as opposed to the iesouices in the poital.
Clicking the link makes this cleai youie immediately piesented with a giaph
showing the iesouices available in the JVM.
Resources
Te ist tab is called Resources . Tis tab contains the afoiementioned giaph
plus seveial seivei wide actions that an administiatoi can execute. Tese aie
Garbage collection: You can send in a iequest to the JVM to begin the
gaibage collection task.
Clearing VM caes: You can send in a iequest to the JVM to cleai a single
VM cache.
Clearing caes across the cluster: You can send in a iequest to the JVM to
cleai content cached acioss the entiie clustei.
Clearing database caes: You can send in a iequest to the JVM to cleai the
database cache.
Reindex all searindexes: You can send in a iequest to iegeneiate all seaich
indexes. lf you aie not using a Soli seaich seivei this will impact poital peifoi-
mance so tiy to do this at non-peak times.
Reset Document Library preview and thumbnail les: You can send in a
iequest to ieset the pieview and thumbnail les foi each item in youi poitals
Documents and Media libiaiies.
Generate read Dump: lf you aie peifoimance testing, you can geneiate
a thiead dump which can be examined latei to deteimine if theie aie any dead-
locks and wheie they might be.
Verify database tables of all plugins: Checks all tables against theii indexes
foi accuiacy of data ietiieval.
Clean up Permissions: Tis piocess iemoves the assignment of some pei-
missions on the Guest, Usei and Powei Usei ioles to simplify the management
of Usei Customizable Pages. Notably, Add To Page peimissions is iemoved
fiom the Guest and Usei ioles foi all poitlets. Likewise the same peimission is
ieduced in scope foi Powei Useis fiom poital wide to scoped to Usei Peisonal
Site.
16.4. SERVER ADMINISTRATION 89
Log Levels
Te Log Levels tab of the Seivei Administiation page allows you to dynamically
modify the log levels foi any class hieiaichy in the poital. lf you have custom
code you have deployed which isnt in the list, you can use the Add Category
tab to add it. lf you change the log level neai the top of the class hieiaichy
(such as at com.liferay), all the classes undei that hieiaichy will have theii
log levels changed. lf you aie testing something specic, it is much beuei to be
as specic as you can when you change log levels. Modifying them too high in
the hieiaichy geneiates a lot moie log messages than you need.
Properties
Lifeiay and the JVM contain many seuings which aie dened as piopeities.
Teie aie two subtabs of the piopeities tab of the Seivei Administiation page
one showing system piopeities and one showing poital piopeities.
Te system piopeities tab shows an exhaustive list of system piopeities foi
the JVM, as well as many Lifeiay system piopeities. Tis infoimation can be
used foi debugging puiposes oi to check the conguiation of the cuiiently iun-
ning poital.
Te poital piopeities tab tab shows an exhaustive list of the poital piopeities.
Tese piopeities can be customized, you can peiuse the full list of customizable
piopeities in chaptei 20. lf you need to check the cuiient value of a paiticulai
piopeity, it can be viewed fiom this scieen without having to shut down the
poital oi open any piopeities les.
Captcha
By default, Lifeiay ships with its own simple captcha seivice which is designed
to thwait bots fiom iegisteiing foi accounts on sites poweied by Lifeiay. lf you
want to instead use Googles ieCaptcha seivice, you can enable this seuing fiom
the Captcha tab of the Seivei Administiation page.
Simply check the Enable ReCaptcha box and entei youi public and piivate
keys into the piovided elds, then click Save. Lifeiay Poital will then use ie-
Captcha instead of simple captcha.
Data Migration
lf you aie upgiading fiom a pievious ielease of Lifeiay Poital oi if you need to
migiate youi data fiomone systemto anothei, the Data Migiation tab helps you
to do that without youi developeis having to wiite custom sciipts.
90 CHAPTER 16. USING THE CONTROL PANEL
Te ist section lets you copy youi entiie Lifeiay database fiom the cuiient
database undei which it is iunning to the database you specify in this set of
elds. Youll need to entei the diivei class name (and the diivei will need to be
on Lifeiays classpath), the JDBCURL of the database to which youll be copying
youi data and the ciedentials of a usei with access to that database. Once you
have all of this infoimation enteied, click Execute to copy the data.
Te next section helps you migiate youi documents. lf you want to move
o of the Jackiabbit JSR-10 iepositoiy to the le system, oi to the Jackiabbit
iepositoiy fiom the le system, oi to any of the othei iepositoiies suppoited
by the documents and media libiaiy, you can do so veiy easily. Make suie you
have alieady set up youi portal-ext.properties le so the hook is piopeily
conguied befoie iunning this migiation. Select the Document Libiaiy hook
that iepiesents wheie you want youi documents migiated and click Execute.
Youi documents will be migiated to the newiepositoiy. You can then shut down
Lifeiay, make the new iepositoiy the default in the portal-ext.properties
le and then iestait.
Similaily, you can migiate images fiom the lmage Galleiy in the same man-
nei.
File Uploads
Since Lifeiay allows useis to upload les in vaiious places, you may want to lock
down the type of les and the size of les useis aie allowed to upload. Te lile
Uploads tab of the Seivei Conguiation tab lets you set the oveiall maximum
le size and then oveiiide that size foi specic applications within Lifeiay. You
can limit the allowed le extensions geneially oi by application. You have a lot
of exibility as to how you want les to be managed within youi poital.
Mail
Rathei than using the portal-ext.properties le as we did in the installa-
tion chaptei, you can conguie a mail seivei fiom the Mail tab of the Seivei
Conguiation tab. lf the poital is to ieceive mail (see oui coveiage of the Mes-
sage Boaids poitlet in chaptei ), you can connect a POP mail seivei. lf the
poital is to send mail, which it needs to do to send notications to useis, you
can connect to an SMTP seivei heie as well and this is highly iecommended.
Note that if you add youi mail seivei seuings heie, they will oveiiide any-
thing in youi portal-ext.properties le.
16.4. SERVER ADMINISTRATION 91
External Services
Lifeiay Poital enables useis to upload and shaie content via the Documents and
Media libiaiy, a customizable and peimissionable online iepositoiy. Useis can
upload les of any type to the Documents and Media libiaiy. Lifeiay ships with
PDlBox and uses it to geneiate automatic pieviews foi ceitain types of docu-
ments, by default. You can also install thiee additional tools that oei highei
quality pieviews and document conveision functionality OpenOce oi Libie-
Oce, lmageMagick and Xugglei. With Lifeiay conguied to use these tools,
you can geneiate automatic pieviews foi many types of les incuding text les,
oce suite les, PDls, images, audio les and videos. Useis will also be able to
use the conveision functionality to download documents in a vaiiety of foimats.
Please see chaptei 4 on Documents and Media foi moie infoimation.
LibieOce is available heie LibieOce, lmageMagick is available heie lm-
ageMagick and Xugglei is available heie Xugglei. Make suie to choose the
coiiect veisions of these applications foi youi opeiating system. You can build
Xugglei 3.4.1012, which woiks with Lifeiay .1, fiom souice oi you can install
it fiom the binaiies
Souice
Linux (32-bit)
Linux (4-bit)
Mac OS X
Windows
Once youve installed these tools, you can use the Exteinal Seivices tab of
the contiol panel to conguie Lifeiay to use them.
OpenOfce/LibreOfce conguration
OpenOce and LibieOce aie open souice oce suites which aie usually iun
in giaphical mode to cieate documents but they can also be iun in seivei mode.
When iun in seivei mode, OpenOce and LibieOce can be used to conveit
documents to and fiom all of the le types it suppoits. Once conguied, Lifeiay
makes use of this featuie to automatically conveit content on the y. You can
install OpenOce oi LibieOce on the same machine upon which Lifeiay is
iunning oi you can connect to a sepaiate host.
lf youve installed OpenOce oi LibieOce on the same machine thats
iunning Lifeiay, you can stait it in seivei mode with the following command
92 CHAPTER 16. USING THE CONTROL PANEL
soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;"
--nofirststartwizard
Once OpenOce oi LibieOce has been installed and is iunning in seivei
mode, you can conguie Lifeiay to use it eithei in youi portal-ext.proper-
ties le oi fiom the contiol panel. To enable OpenOce/LibieOce in youi
portal-ext.properties le, add the following line
openoffice.server.enabled=true
lf OpenOce oi LibieOce is iunning on anothei seivei oi on a non-default
poit, you must also specify these values. Te default values aie as follows
openoffice.server.host=127.0.0.1
openoffice.server.port=8100
By default, when Lifeiay uses OpenOce oi LibieOce to peifoim convei-
sions, it uses a cache. Te ist time a document is conveited, a copy is saved
in the Lifeiay temp foldei /liferay/document_conversion/. When Lifeiay
ieceives a conveision iequest, it checks this foldei to see if the conveited doc-
ument alieady exists. lf the conveited document is found, Lifeiay ietuins it to
the usei. Otheiwise, it peifoims a fiesh conveision and saves a copy in the
temp foldei. lf the cache is tuined o, Lifeiay will always iegeneiate the le ie-
gaidless of whethei a pieviously existing conveision alieady exists in the temp
foldei. You can tuin the cache o by seuing the following piopeity
openoffice.cache.enabled=false
To conguie Lifeiay to use OpenOce/LibieOce fiom the contiol panel,
navigate to the Server Administration External Services page and check the
Enabled box foi OpenOce. lf OpenOce/LibieOce is iunning on a non-
default poit, you must also specify the poit numbei. By default, OpenOce
iuns on poit 8100, which is the default poit in the contiol panel. lf you have
something else iunning on this poit, nd an open poit and specify it both in
the command to stait OpenOce/LibieOce in seivei mode and on the contiol
panels Exteinal Seivices conguiation page. When you aie nished, click Save.
Now Lifeiay can peifoim many types of document conveisions.
16.4. SERVER ADMINISTRATION 93
ImageMagick conguration
Once youve installed the coiiect veision of ImageMagick foi youi opeiating
system, which should include the installation of Ghostsciipt, you need to cong-
uie Lifeiay to use lmageMagick. You can do this eithei in youi portal-ext.properties
le oi fiomthe contiol panel. To enable lmageMagick in youi portal-ext.properties
le, add the following lines and make suie the seaich path points to the diiec-
toiies foi the lmageMagick and Ghostsciipt executables. You may also need to
conguie the path foi fonts used by Ghostsciipt when in Mac oi Unix enviion-
ments.
imagemagick.enabled=true
imagemagick.global.search.path[apple]=/opt/local/bin:/opt/local/share \
/ghostscript/fonts:/opt/local/share/fonts/urw-fonts
imagemagick.global.search.path[unix]=/usr/local/bin:/usr/local/share/ghostscript/fonts: \
/usr/local/share/fonts/urw-fonts
imagemagick.global.search.path[windows]=C:\\Program Files\\ImageMagick
To enable lmageMagick fiomthe contiol panel, navigate to the Server Admin-
istration External Services page, check the Enabled checkbox foi lmageMag-
ick and veiify the paths to the lmageMagick and Ghostsciipt executables aie
coiiect.
Note that some oldei veisions of lmageMagick aie unable to piopeily iun
with Lifeiay. lf this is the case, update to the latest veision (lmageMagick ..9-
2012-09-2 Q1 oi latei). To check foi the latest lmageMagick veisions, visit
theii web site.
1
See Lifeiays issues ticketing system
2
foi infoimation on eoits
to identify incompatible application veisions with Lifeiay.
Xuggler conguration
Once youve installed the coiiect veision of Xuggler foi youi opeiating system,
you need to conguie youi enviionment vaiiables. Depending on wheie you
installed Xugglei, a conguiation similai to the following should woik on Unix-
like systems
export XUGGLE_HOME=/usr/local/xuggler
export LD_LIBRARY_PATH=$XUGGLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$XUGGLE_HOME/bin:$PATH
Once youi enviionment vaiiables aie set up coiiectly, you can conguie Lif-
eiay to use Xugglei eithei in youi portal-properties le oi fiom the contiol
1
hup//www.imagemagick.oig/sciipt/binaiy-ieleases.php
2
hup//issues.lifeiay.com/biowse/LPS-30291
94 CHAPTER 16. USING THE CONTROL PANEL
panel. lf youd like to use youi poital-ext.piopeities le, just add the following
line
xuggler.enabled=true
To conguie Lifeiay to use Xugglei in the contiol panel, navigate to the
Server Administration External Services page and check Enabled. Tats it'
Youve successfully conguied the Documents and Media libiaiy to use Xugglei
foi audio and video les.
Script
Lifeiay includes a sciipting console which lets administiatois execute migia-
tion oi management code instantly. Seveial sciipting languages aie suppoited,
including JavaSciipt, Gioovy, Python, Ruby and Beanshell. loi fuithei infoi-
mation about Lifeiays APls, see the JavaDoc oi Liferay in Action.
Shutdown
lf you evei need to shut down youi Lifeiay Poital seivei while useis aie logged
in, you can use the Shutdown tab to infoim youi logged-in useis of the impend-
ing shutdown. You can dene the numbei of minutes until the shutdown and a
custom message that will be displayed.
Useis will see youi message at the top of theii poital pages foi the duiation
of time you specied. When the time expiies, all poital pages will display a mes-
sage saying the poital has been shut down. At this point, the seivei will need
to be iestaited to iestoie access. Next, lets examine how to manage multiple
poital instances.
16.5 Portal Instances
Lifeiay Poital allows you to iun moie than one poital instance on a single seivei.
Te Poital lnstances page of the contiol panel lets you manage these instances.
Data foi each poital instance aie kept sepaiate fiomeveiy othei poital instance.
All poital data, howevei, is kept in the same database.
Each poital instance iequiies its own domain name. Lifeiay will diiect useis
to the piopei poital instance based on this domain name. So befoie you cong-
uie an instance, conguie its domain name in youi netwoik ist. When youie
ieady to add an instance, click the Add buuon heie.
Youll be piompted foi foui elds and a check box
16.6. PLUGINS INSTALLATION 9
Web ID: A geneial convention is to use the domain name foi this. lts a
usei-geneiated lD foi the instance.
Virtual Host: Put the domain name you conguied in youi netwoik heie.
When users aie diiected to youi Lifeiay seivei via this domain name, Lifeiay
will then be able to send them to the piopei poital instance.
Mail Domain: Entei the domain name foi the mail host foi this instance.
Lifeiay will use this to send email notications fiom the poital.
Max Users: Entei the maximum numbeis of usei accounts you would like
youi poital instance to suppoit.
Active: Use this check box to choose whethei to cieate an active oi an inac-
tive poital instance.
When you aie nished lling out the foim, click Save. Now navigate to the
poital using youi newdomain name. You will see you aie biought to what looks
like a clean install of Lifeiay. Tis is youi new poital instance which can now
be conguied any way you like.
16.6 Plugins Installation
Te Plugins Installation page of the contiol panel shows all of the plugins cui-
iently installed. Tese aie divided into tabs foi poitlets, themes, layout tem-
plates, hook plugins and web plugins. lf you want to install a new plugin, click
the Install More Portlets buuon. You will then be biought to the Plugin lnstallei,
wheie you can biowse Lifeiays iepositoiy of poitlets oi install youi own plu-
gins. We coveied the plugins installei and explained how to install plugins
manually in chaptei 13.
16.7 Summary
ln this chaptei, we nished oui oveiview of Lifeiays contiol panel that we
began in chaptei 1. We saw how to conguie mail host names, email noti-
cations, identication, and poital display seuings. We showed how you add
custom elds to vaiious poital entities such as useis, pages, documents, wiki
aiticles, message boaid posts, and moie.
Next, we sawhowto viewand conguie oveiall seivei seuings. We sawhow
to viewthe memoiy cuiiently being used by the seivei, as well as howto initiate
gaibage collection, a thiead dump, seaich engine ie-indexing and the cleaiing
of vaiious caches. We leained how to debug paits of the poital by changing log
levels and by viewing the vaiious piopeities dened in the poital.
9 CHAPTER 16. USING THE CONTROL PANEL
linally, we leained how to piopeily notify useis that the poital is about to
shut down and how to set up exeinal seivices like OpenOce integiation. We
looked at how to cieate multiple poital instances on a single installation of Life-
iay and we showed how to view cuiiently installed plugins.
We hope this infoimation helps you become an eective Lifeiay Poital Ad-
ministiatoi.
Cu~v1rv 1
Auv~Ncru Pov1~i Ovrv~1ioN
ln this chaptei we discuss seveial advanced featuies of Lifeiay Poital, includ-
ing audit tiails and poital maintainence, backup, and logging. Audit tiails allow
poital administiatois to tiack the activities of poital useisthis can be veiy use-
ful foi tioubleshooting oi guiing out whos iesposible foi ceitain actions that
have taken place on youi poital. lts geneially not much moie complicated to
maintain a iunning Lifeiay instance than it is to maintain the application seivei
upon which its iunning. Howevei, Lifeiay piovides tools foi logging, patching,
and upgiading Lifeiay that you should know how to use. lts also impoitant to
follow secuie backup pioceduies to piotect youi Lifeiay instances souice code,
database, and piopeities les.
Well discuss the following topics in this section
Audit tiails
Lifeiay Monitoiing using Google Analytics
Backing Up a Lifeiay lnstallation
Changing Logging Levels
Patching Lifeiay
9
98 CHAPTER 17. ADVANCED PORTAL OPERATION
Upgiading Lifeiay
Lets get staited with audit tiails.
17.1 Audit Trails
EE Only Feature
Youve just nished lunch and aie ieady to get back to woik. You have a
site in Lifeiay you use to manage youi pioject, and befoie you lef, you weie
about to cieate a foldei in youi Documents and Media libiaiy foi shaiing some
iequiiements documentation. Siuing down at youi desk, you navigate to the
iepositoiy and auempt to cieate the foldei.
You do not have permission to perform this action, Lifeiay helpfully tells you.
What? you bluit accidentally in suipiise. Tis is my pioject'
Ah, you too` asks a co-woikei helpfully fiom ovei the cube wall. l lost
access to a wiki l was updating just a few minutes ago. l was about to entei a
suppoit ticket foi it.
loiget the ticket. Lets go see the poital admin now, you say.
And o you go, two oois down, to the fai end of the building wheie, as you
appioach, you can alieady heai stiess in the poital admins voice as he tiies to
ieassuie someone on the phone.
Yes, Mi. Jones. Yes, lll x it. (Jones? e president of the company? goes
thiough youi mind.) lll get on it iight away, Mi. Jones. lt was just a mistake,
lll x it. Tank you, Mi. Jones, and he hangs up the phone.
Pioblems` you ask the poital admin, whose name is Haiiy. He does look
iathei haiiied.
Yeah, Tom, he says. Somebody changed a bunch of peimissions in the
poitalit wasnt me. lm assuming you and Dick aie heie because of the same
pioblem`
Yup, you say. l lost access to a document iepositoiy foldei.
And l lost access to a wiki, Dick says helpfully.
lt was piobably due to some site membeiship change. Lets take a look at
the audit poitlet in the contiol panel and see what happened.
17.1. AUDIT TRAILS 99
When in the couise of human events it becomes necessaiy to see what useis
aie doing on youi poital, youll nd Lifeiay makes this easy. lf youie a Lif-
eiay Enteipiise Edition customei, you have access to two pluginsa hook and a
poitletthat, in combination with some seuings in portal-ext.properties,
enable you to see all the activity that occuis in youi poital. Using this, you can
quickly nd out what changes weie made and by whom. lf youve delegated
peimission gianting to any gioup of people, this is an essential featuie youie
likely to use.
Well come back to Tom, Dick and Haiiys stoiy latei in the chaptei. loi
now, lets look at how to install Lifeiays audit plugins so you can do the same
thing Haiiys about to do.
Installing and conguring the audit plugins
Lifeiays audit functionality is composed of two paits a back-end piece that
hooks into Lifeiay events and a fiont-end piece that gives you an inteiface to
see whats happening. Both of these aie available as EE-only plugins in the
Customei Poital oi Lifeiay Maiketplace, and youll need to install both to get
audit functionality woiking (plugins installation is coveied in chaptei 13).
Once installed, theie aie two piopeities in youi portal-ext.properties
le which you can use to tweak the seuings.
com.liferay.portal.servlet.lters.audit.AuditFilter: By default, this is set to
false, because the audit plugins aient installed by default. When you set it to
true, the audit hook is able to captuie moie infoimation about events, such as
the client host and the clients lP addiess.
audit.message.com.liferay.portal.model.Layout.VIEW: ln the code, pages
aie layouts. Seuing this to true, theiefoie, iecoids audit events foi page views.
lts tuined o by default because this may be too ne-giained foi most installa-
tions.
Once youve decided if youie going to use one oi both of the two seuings
above, place them in youi portal-ext.properties le and iestait youi Lif-
eiay seivei. Once it comes up, audit events aie captuied by Lifeiay, and youll
be able to use them to see whats happening in youi poital.
Using audit events
Now that youie captuiing audit events, its easy to use them to view activities
in youi poital. Navigate to the contiol panel and youll nd a new entiy in the
Portal section labeled Audit Reports (see guie 1.1).
00 CHAPTER 17. ADVANCED PORTAL OPERATION
Figure 17.1: Once the Audit Reports plugins are installed, an entry
appears in the control panel.
Clicking the entiy shows you a list of the events Lifeiay has alieady cap-
tuied (see guie 1.2), along with an inteiface foi seaiching foi events. You can
biowse the list if you want, but its likely youll need to use the seaich to nd
what youie looking foi.
liguie 1.2 shows Stephen Piofessoi logged in and did some things on the
site. To see the detail of any of these events, all you need to do is click one to
see moie infoimation. Youll then see something like guie 1.3.
As you can see, depending on how many useis you have in youi poital, this
list can get populated veiy quickly. loi this ieason, its a good idea to keep the
audit.message.com.liferay.portal.model.Layout.VIEW piopeity set to
false. Tis way, you dont cluuei up youi audit events with multiple page view
events, which will denitely be the most ofen tiiggeied event in youi poital.
Now that you know how to biowse and view audit events, lets look at
seaiching foi specic events.
Viewing audit reports
linding what you want in a big list of events is, to use the expiession, like seaich-
ing foi a needle in a haystack. Tis is why the audit poitlet gives you a iobust
seaiching mechanism. By default, it looks pieuy simple theies only a single
eld foi seaiching. Clicking the advanced link, howevei, ieveals a seaich dialog
bioken out by vaiious elds you can use in youi seaich.
17.1. AUDIT TRAILS 01
Figure 17.2: Liferay captures and stores events as soon as the audit
plugins are installed.
Lets look at the options we have foi seaich.
Mat: You can match all elds youve specied oi any single eld.
User ID: Specify the usei lD youd like to seaich foi. Tis would be the usei
who peifoimed some action in the poital youd like to audit.
User Name: Specify the usei name youd like to seaich foi. Tis is ofen
easiei than seaiching foi a usei lD, especially if you dont have access to the
Lifeiay database to nd the usei lD.
Resource ID: Specify the lD of the iesouice that was modied oi viewed in
this audit iecoid.
Resource Name: Specify the name of the iesouice that was modied oi
viewed in this audit iecoid. loi example, you could seaich foi Usei iesouices
to see if someone modied a useis account.
Resource Action: Specify an action that was peifoimed on the iesouice.
Tis could be any one of the following add, assign, delete, impersonate,
login, login_failure, logout, unassign, oi update.
Session ID: Specify the session lD to seaich foi. Youd use this if you weie
coiielating a session lD fiom youi web seivei logs with activity in Lifeiay.
02 CHAPTER 17. ADVANCED PORTAL OPERATION
Figure 17.3: Clicking an event in the list shows the details of that event.
This event shows it mustve been Stephen Professors rst time logging
into the site, because hes accepting the terms of use.
Client IP: Specify the lP addiess of the client that peifoimed the activity you
wish to audit.
Client Host: Specify the host name of the client that peifoimed the activity
you wish to audit.
Server Name: Specify the seivei name upon which the activity occuiied. lf
youie using a clustei, each membei of the clustei can be individually queiied.
Server Port: Specify the seivei poit upon which the activity occuiied. Youd
need this if you iun a veitical clustei of multiple VMs on the same machine.
Start Date: Specify the low end of the date iange you wish to seaich.
End Date: Specify the high end of the date iange you wish to seaich.
Using this foim, if you wanted to check to see if someone in the poital unas-
signed a usei fiom a paiticulai iole, you might seaich foi a iesouice name of
user and a iesouice action of unassign. Te iesults of such a seaich might look
something like guie 1.4.
Once you have the iesults of youi seaich, you can click on any of the iecoids
ietuined to see the detail page foi that iecoid. liguie 1. shows, in this paitic-
ulai case, the default administiative usei iemoved Stephen Piofessoi fiom the
17.1. AUDIT TRAILS 03
Figure 17.4: Searching audit events is easy with the search formprovided
by the audit portlet. You can quickly drill down to nd the types of events
youre looking for.
iole of Powei Usei.
As you can see, Lifeiays audit poitlets give you a lot of powei to see whats
happening in youi poital. You can use this infoimation to tioubleshoot piob-
lems, deteimine owneiship of paiticulai actions, oi, as Haiiy is about to do, nd
out who made peimission changes they weient supposed to make.
Conclusion of the Story
Okay, says Haiiy, lets ie up Lifeiays audit system and see if we can guie
out what happened.
You and Dick stand behind Haiiys chaii and watch as he enteis a queiy into
a foimon the audit poitlet. Clicking search, the scieen lls up with audit events.
Wow, thats a lot of unassign events. Haiiy says. And look who the culpiit
is, he adds saicastically.
Whos Melvin Dooitiong` Dick asks.
Tats my new intein, Haiiy says. lm gonna kill him. Haiiy pushes out
his chaii and walks down the iow of cubes to the end, wheie a kid no moie than
20 yeais old with disheveled haii sits, eaibuds in his eais.
Hey Melvin, Haiiy says as Melvin tuins aiound to face him. Didnt l ask
you to move that set of useis fiom site membeiship to oiganization membei-
04 CHAPTER 17. ADVANCED PORTAL OPERATION
Figure 17.5: If youve delegated portal administration to multiple users,
you can use the audit plugins to determine who made what change. And,
of course, youll never leave the default administrative user enabled in a
production system, right?
ship`
Yeah, Melvin says, l did that alieady.
Howd you do it`
lt was going to take a while to do it manually, so l wiote a sciipt and exe-
cuted it in the sciipting host, Melvin ieplies, mauei-of-factly.
You did, did you` Well, guess what` Youi sciipt iemoved everybody fiom
all sites.
What?
Yeah, and now youie going to stait adding them back, one by one, manu-
ally, staiting with Mi. Jones.
Tom and Dick back away slowly fiom Melvins cube as Haiiy and Melvin
continue to have theiilets call it a discussion. One thing is cleai theyie hav-
ing a beuei day than Melvin is.
Now that weve seen how you can use audit tiails, lets look at some tools
and best piactices foi maintaining youi Lifeiay installation.
17.2. LIFERAY MONITORING USING GOOGLE ANALYTICS 0
17.2 Liferay monitoring using Google Analytics
Lifeiay includes built-in suppoit foi Google Analytics, allowing administiatois
to make use of Googles tool set foi analyzing site tiac data. When you sign
up foi Google Analytics, a snippet of code is piovided which needs to be added
to youi web pages to allow Googles system to iegistei the page hit. lt can be a
tedious piocess to add this code to eveiy page on a site, especially if its a laige
site and theie is a lot of usei-geneiated content.
Tis pioblemcan be solved in Lifeiay by puuing Googles code into a custom
theme wiiuen specically foi the web site on which the poital is iunning. Doing
this, howevei, iequiies a theme developei to make specic changes to the theme
and it pievents useis fiom using the many themes that aie fieely available foi
Lifeiay out of the box.
Figure 17.6: Setting up Google
Analytics for your site is very easy:
sign up for the IDand then enter it
into this eld.
Because of this, suppoit foi Google
Analytics has been built into Lifeiay,
and can be tuined on thiough a sim-
ple usei inteiface. Tis allows Lif-
eiay administiatois to make use of
Google Analytics on a community by
community basis and tuin it on and
o when needed.
To enable Google Analytics sup-
poit, go to Site Seings in the con-
tiol panel, and then select Analytics
on the iight. Youll see a veiy simple
foim, pictuied below.
Put youi Google Analytics lD
(which should have been piovided to you when you signed up foi the seivice)
in the eld and click Save. All the pages in the community you selected will
now have the Google Analytics code in them and will be tiacked.
Tis is a faiily simple pioceduie, and it gives you the ability to take advan-
tage of some gieat tools to help you visualize whos coming to youi site and
fiom wheie. Next, we discuss some topics geimane to maintaining youi Lifeiay
installation as its used. Lets stait with backup.
17.3 Backing up a Liferay installation
Once you have an installation of Lifeiay Poital iunning, youll want to have
piopei backup pioceduies in place in case of a catastiophic haidwaie failuie
0 CHAPTER 17. ADVANCED PORTAL OPERATION
of some kind. Lifeiay isnt veiy dieient fiom any othei application that may
be iunning on youi application seivei. Neveitheless, theie aie some specic
components you should include in youi backup plan.
Backing up source code
lf you have extended Lifeiay oi have wiiuen any plugins, they should be stoied
in a souice code iepositoiy such as Git, Subveision, oi CVS, unless youie Linus
Toivalds, and then taiballs aie okay too (thats a joke). Youi souice code iepos-
itoiy should be backed up on a iegulai basis to pieseive youi ongoing woik.
Tis piobably goes without saying in youi oiganization, as nobody wants to
lose souice code thats taken months to pioduce, but we thought we should
mention it anyway.
lf youie extending Lifeiay with an Ext plugin, youll want to make suie you
also stoie the veision of the Lifeiay souice on which youi extension enviion-
ment is based. Tis allows youi developeis convenient access to all the tools
they need to build youi extension and deploy it to a seivei.
Lets look at the items that need to be backed up in youi Lifeiay installation.
Backing up Liferays le system
Lifeiays conguiation le, portal-ext.properties, gets stoied in the Lif-
eray Home foldei, which is geneially one foldei up fiom wheie youi application
seivei is installed (see chaptei 14 foi specic details foi youi application seivei).
At a minimum, this le should be backed up, but it is geneially best to back up
youi whole application seivei.
lf youve followed the non-plugin pioceduie (see chaptei 19) to modify youi
Ehcache conguiation, youll have cache conguiation les in the deploy loca-
tion of Lifeiay. Youll need to back up this location. lf youie using the plugin
pioceduie (i.e., the iecommended pioceduie), youi cache conguiation seuings
aie stoied in youi souice code iepositoiy, which is backed up sepaiately.
Lifeiay stoies conguiation les, seaich indexes, and cache infoimation in
a foldei called data in Lifeiay Home. lf youie using the lile System stoie oi
the Advanced lile System stoie, the media iepositoiy is stoied heie (by default)
too. You should always back up the contents of youi Lifeiay Home foldei.
lf youve modied the location wheie the Document Libiaiy stoies les, you
should also back up this location.
Tat about coveis the le system locations Lifeiay uses. Next, lets discuss
how to back up Lifeiays database.
17.4. LIFERAYS LOGGING SYSTEM 0
Backing up Liferays database
Lifeiays database is the cential iepositoiy foi all of the Poitals infoimation and
is the most impoitant component that needs to be backed up. You can do this
by backing up the database live (if youi database allows this) oi by expoiting
the database and then backing up the expoited le. loi example, MySQL ships
with a mysqldump utility which allows you to expoit the entiie database and
data into a laige SQL le. Tis le can then be backed up. ln case of a database
failuie, this le can be used to iecieate the state of the database at the time the
dump was cieated.
lf youie using Lifeiays Documents and Media Libiaiy with the Jackiabbit
JSR-10 iepositoiy to stoie documents in a database, the Jackiabbit database
should be backed up also. lf youve placed youi seaich index into a database
(not iecommended, see chaptei 19 foi infoimation on using Clustei Link oi
Soli), that database should be backed up as well.
Seaich indexes can be backed up as well, if you wish to avoid ieindexing
youi entiie poital afei you do youi iestoie. Tis is easiest to do if you have
a sepaiate Soli enviionment upon which youi index is stoied. lf youie in a
clusteied conguiation and youie ieplicating indexes, youll need to back up
each index ieplica.
Restoiing youi application seivei, youi Lifeiay Home foldei, the locations
of any le system-based media iepositoiies, and youi database fiom a backup
system should give you a functioning poital. Restoiing seaich indexes should
avoid the need to ieindex when you biing youi site back up afei a catastiophic
failuie. Good, consistent backup pioceduies aie key to successfully iecoveiing
fiom a haidwaie failuie.
But what about maintenance while youi seivei is iunning` Lifeiay lets you
view a lot of what is going on thiough its logging system.
17.4 Liferays Logging System
Lifeiay uses Log4j extensively to implement logging foi neaily eveiy class in the
poital. lf you need to debug something specic while the systemis iunning, you
can use the contiol panel to set logging levels by class dynamically.
To view the log levels, go to the contiol panel, click Server Administration in
the Seivei section, and then click the Log Levels tab.
A paginated list of logging categoiies appeais. Tese categoiies coiiespond
to Lifeiay classes that have log messages in them. By default, all categoiies aie
set to display messages only if theie is an eiioi that occuis in the class. Tis is
08 CHAPTER 17. ADVANCED PORTAL OPERATION
why you see ERROR displayed in all of the diop-down list boxes on the iight
side of the poitlet.
Each categoiy is lteied by its place in the class hieiaichy. loi example,
if you wanted to see logging foi a specic class that is iegisteied in Lifeiay,
you would biowse to that specic class and change its log level to something
that is moie desciiptive, such as DEBUG. Once you click the Save buuon at the
bouom of the list, youll stait seeing DEBUG messages fiom that class in youi
application seiveis log le.
lf youie not suie which class you want to see log messages foi, you can
nd a place highei up in the hieiaichy and select the package name instead of
an individual class name. lf you do this, messages foi eveiy class lowei in the
hieiaichy will be displayed in youi application seiveis log le.
Figure 17.7: Log levels can be dynamically changed at runtime, whenever
you need to debug an issue.
Be caieful when you do this. lf you set the log level to DEBUG somewheie
neai the top of the hieiaichy (such as com.liferay, foi example), you may
wind up with a lot of messages in youi log le. Tis could make it dicult
to nd the one you weie looking foi, and causes the seivei to do moie woik
wiiting messages to the log.
lf you want to set the log level foi one of youi own classes in a deployed
plugin, you can iegistei that class with Lifeiay to can contiol the log levels
moie easily, so long as youi class uses Log4J to do its logging.
17.5. PATCHING LIFERAY 09
You will ist need to implement Log4J logging in youi class, with a statement
such as the following (taken fiom Lifeiays JCRStore class)
private static Log _log = LogFactory.getLog(JCRStore.class);
You would then use this _log vaiiable to cieate log messages in youi code
foi the vaiious logging levels
_log.error("Reindexing " + node.getName(), e1);
To enable youi logging messages to appeai in youi seiveis log le via the
contiol panel, click the Add Category tab on the same Log Levels page.
Figure 17.8: Adding your own logging classes is as simple as specifying it in
this eld.
Youll see you can add a logging categoiy. Put in the fully qualied name of
youi class oi of the package that contains the classes whose log messages you
want to view, choose a log level, then click the Save buuon. You will now stait
to see log messages fiom youi own class oi classes in the seiveis log le.
Logs aie gieat foi guiing out issues in pioduction. But what if Lifeiay
contacts you via its suppoit channel with a bug x oi a secuiity enhancement`
Read on to leain how to patch Lifeiay.
17.5 Patching Liferay
While we stiive foi peifection with eveiy ielease of Lifeiay Poital, the ieality of
the human condition dictates that ieleases of the pioduct may not be as peifect
as oiiginally intended. But weve planned foi that. lncluded with eveiy Lifeiay
10 CHAPTER 17. ADVANCED PORTAL OPERATION
EE Only Feature
bundle is a patching tool that can handle the installation of two types of patches
hot xes and x packs.
A hot x is piovided to a customei when a customei contacts Lifeiay about
an issue, and Lifeiays suppoit teamwoiking with the customeideteimines
that the pioblem is indeed an issue with the pioduct that needs to be xed.
Suppoit xes the bug and piovides a hot x to the customei immediately. Tis
is a shoit-teim x that solves the issue foi the customei as quickly as possible.
On a iegulai schedule, these hot xes aie bundled togethei into x packs.
lix packs aie piovided to all of Lifeiays customeis and aie component-based.
Tis means any issues with the content management system will be bundled
togethei sepaiately fiom issues with anothei component, such as the message
boaids. Tis lets you deteimine which patches aie ciitical and which aie not,
based on youi usage. Of couise, if Lifeiay issues a secuiity advisoiy, thats
something youie always going to want to patch.
Now that you know what patching is all about, lets check out the tool.
Installing the patching tool
lf youie using a Lifeiay bundle, congiatulations' Te patching tool is alieady
installed. Youi job isnt done yet, howevei, because Lifeiay might have updated
the patching tool. Always check the Customei Poital to see if the patching tool
has been updated ist. But even if you foiget to check, the patching tool will tell
you if it needs to be updated when you iun it. Alot of planning and foiethought
has gone into the patching system to make it iun as smoothly as possible.
You follow the same pioceduie whethei youie installing oi upgiading the
patching tool. Once youve obtained it fiom the customei poital, unzip it to
the Lifeiay Home foldei. Tis is the foldei wheie youve placed youi por-
tal-ext.properties le and wheie by default the data foldei iesides. Tis
is geneially one foldei up fiom wheie youi application seivei is installed, but
some application seiveis aie dieient. lf you dont know wheie Lifeiay Home
is on youi system, check chaptei 14 to see wheie this foldei is foi youi specic
application seivei.
17.5. PATCHING LIFERAY 11
lf youie upgiading the patching tool, all you need to do is unzip the new
veision on top of the old veision. Note that if youie doing this on LUM (Linux,
Unix, Mac) machines, youll need to make the patching-tool.sh sciipt exe-
cutable.
Afei the patching tool is installed, you need to let it auto-discovei youi
Lifeiay installation. Ten it will deteimine what youi ielease level is and what
youi application seivei enviionment is. Tis is a simple command to iun on
LUM
./patching-tool.sh auto-discovery
oi on Windows
patching-tool auto-discovery
liom heie on, foi bievity well use the LUM veision of the command. Why`
Because Lifeiay is open souice, theies no open souice vaiiant of Windows (Re-
actOS is still in alpha, so it doesnt count), and theiefoie my (RS) unscientic
impiession is that moie people will iun Lifeiay on open souice technology than
not. lf lm wiong, lm wiong, but theie aie still many othei examples of docu-
mentation that defaults to Windows, so we still get to be dieient.
lf youve installed the patching tool in a non-standaid location, youll have to
give this command anothei paiametei to point it to youi Lifeiay installation. loi
example, if youve installed a Lifeiay/Tomcat bundle in /opt/Liferay, youd
issue this command
./patching-tool.sh auto-discovery /opt/Liferay/tomcat-7.0.21
ln all, this is pieuy simple. Now lets see how to use the patching tool to get
youi patches installed.
Installing patches
Te absolute ist thing you must do when installing one oi moie patches is to
shut down youi seivei. On Windows opeiating systems, les that aie in use aie
locked by the OS, and wont be patched. On LUM systems, you can geneially
ieplace les that aie iunning, but of couise that still leaves the old ones loaded in
memoiy. So youi best bet is to shut down the application seivei thats iunning
Lifeiay befoie you install a patch.
Lifeiay distiibutes patches as .zip les, whethei they aie hot xes oi x
packs. When you ieceive one, eithei via a LESA ticket (hot x) oi thiough
downloading a x pack fiom the customei poital, youll need to place it in the
12 CHAPTER 17. ADVANCED PORTAL OPERATION
patches foldei, which is inside the patching tools home foldei. Once youve
done that, its a simple mauei to install it. liist, execute
./patching-tool.sh info
Tis shows you a list of patches youve alieady installed, along with a list of
patches that can be installed, fiom whats in the patches foldei. To install the
available patches, issue the following command
./patching-tool.sh install
Youi patches aie now installed. You can veiify this by using the ./pat-
ching-tool.sh info command, which now shows youi patch in the list of
installed patches. Lets look now at how youd manage youi patches.
Handling hot xes and patches
As stated above, hot xes aie shoit teim xes piovided as quickly as possible
and x packs aie laigei bundles of hot xes piovided to all customeis at iegulai
inteivals. lf you alieady have a hot x installed, and the x pack which contains
that hot x is ieleased, you can iest assuied the patching tool will manage this
foi you. lix packs always supeicede hot xes, so when you install youi x
pack, the hot x that it alieady contains is uninstalled, and the x pack veision
is installed in its place.
Sometimes theie can be a x to a x pack. Tis is also handled automatically.
lf a new veision of a x pack is ieleased, you can use the patching tool to install
it. Te patching tool uninstalls the old x pack and installs the new veision in
its place.
Fix pack dependencies
Some x packs iequiie othei x packs to be installed ist. lf you auempt to
install a x pack that depends on anothei x pack, the patching tool will notify
you of this so you can go to the customei poital and obtain the x pack depen-
dency. Once all the necessaiy x packs aie available in the patches foldei, the
patching tool will install them.
Te patching tool can also iemove patches.
17.5. PATCHING LIFERAY 13
Removing or reverting patches
Have you noticed that the patching tool only seems to have an install com-
mand` Tis is because patches aie managed not by the command, but by what
appeais in the patches foldei. You manage the patches you have installed by
adding oi iemoving patches fiom this foldei. lf you cuiiently have a patch in-
stalled and you dont want it installed, iemove it fiom the patches foldei. Ten
iun the ./patching-tool.sh install command, and the patch is iemoved.
lf you want to iemove all patches youve installed, use the
./patching-tool.sh revert
command. Tis iemoves all patches fiom youi installation.
What weve desciibed so fai is the simplest way to use the patching tool, but
you can also use the patching tool in the most complex, multi-VM, clusteied
enviionments. Tis is done by using pioles.
Using proles with the patching tool
When you ian the auto-discoveiy task afei installing the patching tool, it cie-
ated a default piole that points to the application seivei it discoveied. Tis is
the easiest way to use the patching tool, and is gieat foi smallei, single seivei
installations. But we iealize many Lifeiay installations aie sized accoidingly to
seive millions of pages pei day, and the patching tool has been designed foi
this as well. So if youie iunning a small, medium, oi laige clustei of Lifeiay
machines, you can use the patching tool to manage all of them using pioles.
Te auto-discoveiy task cieates a piopeities le called default.properties.
Tis le contains the detected conguiation foi youi application seivei. But
youie not limited to only one seivei which the tool can detect. You can have it
auto-discovei othei iuntimes, oi you can manually cieate new pioles youiself.
To have the patching tool auto-discovei othei iuntimes, youll need to use a
few moie command line paiameteis
./patching-tool.sh [name of profile] auto-discovery [path/to/runtime]
Tis will iun the same discoveiy piocess, but on a path you choose, and the
piole infoimation will go into a [your profile name].properties le.
Alteinatively, you can manually cieate youi pioles. Using a text editoi,
cieate a [profile name].properties le in the same foldei as the patching
tool sciipt. You can place the following piopeities in the le
14 CHAPTER 17. ADVANCED PORTAL OPERATION
pating.mode: Tis can be binary (the default) oi source, if youie patch-
ing the souice tiee youie woiking with. Lifeiay patches contain both binaiy
and souice patches. lf youi development team is extending Lifeiay, youll want
to piovide the patches you install to youi development team so they can patch
theii souice tiee.
jdk.version: Patches aie compiled foi both JDK and JDK . Specify the one
(eithei jdk5 oi jdk6) youi application seivei is iunning against.
pates.folder: Specify the location wheie youll copy youi patches. By
default, this is ./patches.
war.path: No, no ones angiy. Tis is a piopeity foi which you specify the
location of the Lifeiay installation inside youi application seivei. Alteinatively,
you can specify a .wai le heie, and youll be able to patch a Lifeiay .wai foi
installation to youi application seivei.
global.lib.path: Specify the location wheie .jai les on the global classpath
aie stoied. lf youie not suie, seaich foi youi portal-service.jar le, its
on the global classpath. Tis piopeity is only valid if youi patching.mode is
binary.
source.path: Specify the location of youi Lifeiay souice tiee. Tis piopeity
is only valid if youi patching.mode is source.
You can have as many pioles as you want, and use the same patching tool
to patch all of them. Tis helps to keep all youi installations in sync.
Now that you know how to patch an existing installation of Lifeiay, lets
tuin to how youd upgiade Lifeiay fiom an oldei ielease to the cuiient ielease.
17.6 Upgrading Liferay
Lifeiay upgiades aie faiily stiaightfoiwaid. A consistent set of steps is all you
need to follow to upgiade a standaid Lifeiay installation. Tings do get moie
complicated if youi oiganization has used Ext plugins to customize Lifeiay. lts
possible that APl changes in the newveision will bieak youi existing code. Tis,
howevei, is usually pieuy easy foi youi developeis to x. Poitlet plugins which
use Lifeiay APls should be ieviewed and theii seivices iebuilt against the new
ielease. Teme plugins may iequiie some modications to take advantage of
new featuies, and if theyie using Lifeiay APls, they should be ieviewed. Much
eoit has been made to make upgiades as painless as possible, howevei, this
is not a guaiantee eveiything will woik without modication. Ext plugins aie
the most complicating factoi in an upgiade, so it is impoitant to test as much
as possible.
17.6. UPGRADING LIFERAY 1
As a geneial iule, you can upgiade fiom one majoi ielease to the next majoi
ielease. loi example, you can upgiade diiectly fiom Lifeiay .2.x to .0.x, but
not fiom.2.x to .1.x. lf you need to upgiade ovei seveial majoi ieleases, youll
need to iun the upgiade pioceduie foi each majoi ielease until you ieach the
ielease you want. Tis doesnt mean you need to iun the pioceduie foi eveiy
point ielease oi seivice pack, you only need to iun the pioceduie foi the majoi
ieleases. A good piactice is to use the latest veision of each majoi ielease to
upgiade youi system.
Now that weve gouen the geneial philosophy of upgiading out of the way,
lets outline the pioceduie youll undeigo foi upgiading a Lifeiay .0 installation
to a .1 installation. lf youie iunning a pievious veision of Lifeiay and need to
upgiade to .0 ist, please see the instiuctions in the pievious veision of this
document.
Preparing to Upgrade Liferay Portal 6.0 to Liferay Portal 6.1
Teie aie a few things you should piepaie befoie you actually peifoim the up-
giade. Specically, you need to make suie youve migiated to peimission algo-
iithm , ieviewed youi image galleiy usage, ieviewed new Lifeiay .1 defaults,
and cataloged all the plugins you have installed. Afei youve peifoimed these
thiee tasks, youie ieady to upgiade. Lets look at them one by one.
Migrate to Algorithm6
lf youi Lifeiay installation has existed foi a while, you may be on a dieient
peimission algoiithm than the one thats available in Lifeiay Poital .1. Peimis-
sion algoiithms 1- weie depiecated in Lifeiay Poital .0, and theyve now been
iemoved in .1, which means you must migiate before you upgiade.
lf youie on Lifeiay .2 oi below, you need to upgiade to the latest available
ielease of Lifeiay .0 ist. Please follow the instiuctions in the Liferay Portal
Administrators Guide to do this. We will assume foi the iest of this section that
you have .0 iunning, and that its conguied to use an oldei algoiithm than
algoiithm .
Te ist thing you need to do, if this is not done alieady, is to upgiade
youi installation to algoiithm . lf youve alieady done that, gieat' You can
skip the iest of this paiagiaph. lf not, shut down youi seivei, edit youi por-
tal-ext.properties le, and modify/add the following piopeity so that it
ieads like this
permissions.user.check.algorithm=5
1 CHAPTER 17. ADVANCED PORTAL OPERATION
Restait youi seivei. As Lifeiay staits, it upgiades youi peimissions algo-
iithm to algoiithm . Review youi system to make suie that youi peimissions
conguiation is woiking piopeily (it should be).
Next, log in as an Administiatoi and navigate to the Contiol Panel. Go to
Server Administration and select Data Migration fiom the menu along the top
of the scieen. A section entitled Legacy Permissions Migration appeais at the
bouom of the page.
Figure 17.9: Update your permissions algorithmby clicking the Execute
button.
Algoiithms and do not suppoit adding peimissions at the usei level. lf
you have peimissions set foi individual useis, the conveitei can simulate this foi
you. To do this, it auto-geneiates ioles foi each individual peimission, and then
assigns those ioles to the useis who have individualized peimissions. lf you
have a lot of these, youll likely want to go thiough and clean them up afei the
conveision piocess. To geneiate these ioles, check the Generate Custom Roles
box. lf you do not geneiate the ioles, all custom peimissions set foi individual
useis aie discaided.
Click Execute to conveit all existing useis and ioles to algoiithm. When the
piocess completes, shut down youi seivei. Edit youi portal-ext.properties
le and modify the algoiithmpiopeity to showthat youie nowusing algoiithm
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
17.6. UPGRADING LIFERAY 1
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
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
18 CHAPTER 17. ADVANCED PORTAL OPERATION
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
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.
17.6. UPGRADING LIFERAY 19
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
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.
20 CHAPTER 17. ADVANCED PORTAL OPERATION
Upgrading using a .war le
Running a manual upgiade is almost as easy as upgiading a bundle
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 21
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.
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
22
18.1. ACCESSING LIFERAY SERVICES 23
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);
\index{User}
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.
24 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import java.util.List;
int userCount = UserLocalServiceUtil.getUsersCount();
List users = UserLocalServiceUtil.getUsers(0, userCount);
\index{User}
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);
\index{User}
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.
18.1. ACCESSING LIFERAY SERVICES 2
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.
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)
\index{User}
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.
2 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
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
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)
\index{User}
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)
\index{User}
for (user in users){
18.3. LEVERAGING THE SCRIPT ENGINE IN WORKFLOW 2
if(!user.isDefaultUser() &&
!user.getEmailAddress().equalsIgnoreCase("test@liferay.com")) {
user.setAgreedToTermsOfUse(false)
UserLocalServiceUtil.updateUser(user)
\index{User}
}
}
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.
28 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
<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
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;
18.4. CUSTOM JAVA TOOLS IN THE SCRIPT ENGINE 29
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));
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-
30 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
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
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.
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
New Interface. Youll cieate youi inteiface in the com.liferay.sample
package. Name it ScriptUtil.
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.
package com.liferay.samples;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
public class ScriptUtilImpl implements ScriptUtil {
18.4. CUSTOM JAVA TOOLS IN THE SCRIPT ENGINE 31
Figure 18.1: Creating a newutilities project is easy if you use Liferay IDE
or Liferay Developer Studio.
@Override
public String operationOne() {
return "Hello out there!";
}
@Override
public String operationTwo(String name) {
_log.debug("Inside of Operation Two");
return "Hello " + name + "!";
}
32 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
Figure 18.2: Create a newJava Interface which youll later implement.
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.
18.4. CUSTOM JAVA TOOLS IN THE SCRIPT ENGINE 33
Figure 18.3: Create a newJava Class that implements the interface you
created earlier.
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>
34 CHAPTER 18. USING SCRIPTING FOR ADVANCED FLEXIBILITY
<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.
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
3
3 CHAPTER 19. CONFIGURING LIFERAY FOR HIGH AVAILABILITY
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.
19.1. LIFERAY CLUSTERING 3
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
38 CHAPTER 19. CONFIGURING LIFERAY FOR HIGH AVAILABILITY
the ielevant section you want to modify fiom portal.properties into youi
portal-ext.properties le, and then modify the values theie.