29,99 €
If you are a Java developer or administrator with a technical background and want to install and configure Liferay Portal as an enterprise intranet, this is the book for you. In short, reusable recipes help you realize business goals as working features in Liferay. This book will also give you useful hints on how to easily improve the default functionality of the system and its performance.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 344
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2015
Production reference: 1260515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-428-9
www.packtpub.com
Authors
Piotr Filipowicz
Katarzyna Ziółkowska
Reviewers
Pierpaolo Cira
Zoltán Fiala
Giuseppe Urso
Acquisition Editor
Llewellyn Rozario
Content Development Editor
Merwyn D'souza
Technical Editor
Vijin Boricha
Copy Editors
Relin Hedly
Karuna Narayanan
Project Coordinator
Neha Bhatnagar
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Mariammal Chettiyar
Graphic
Abhinash Sahu
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
Piotr Filipowicz is a Liferay architect and senior developer at eo Networks S.A., Poland. He is an expert in content management systems (CMS). Piotr currently holds the position of team leader in a group involved in developing Liferay-based software. His accomplishments in enhancing and creating various Liferay components are evident from his various successful implementations. His experience and knowledge are supported by certificates such as Liferay Portal Administrator, Sun Certified Web Component Developer for the Java Platform, and Sun Certified Programmer for the Java 2 platform. Piotr is also one of the founders of the www.liferay-guru.com blog, which contains a lot of information on Liferay and the CMS world.
Since 2002, he has created various kinds of IT systems, ranging from desktop applications to CMS applications, supporting large banking and financial systems. His main area of interest is web applications. Piotr uses Java and J2EE technologies on a daily basis, but he is open to learning other technologies and solutions. He holds a master's degree in software systems from Bialystok University of Technology, Poland.
I would like to thank my family for their patience and tolerance during all those hours that I spent in front of my laptop writing this book. Many thanks to my lovely wife, Eliza, for her patience and support towards her always busy husband. This book wouldn't have been possible without her help. I would also like to thank my parents and parents-in-law for their love, understanding, and encouragement.
Last but not least, I sincerely thank all my team members at work for the support and valuable information I got from them. Also, many thanks and appreciation to the entire Packt Publishing team and our reviewers, Giuseppe Urso, Pierpaolo Cira, and Zoltán Fiala, for their constructive criticism and help in enhancing my writing style. It was a great pleasure working with them.
Katarzyna Ziółkowska is employed at eo Networks S.A., Poland, as an IT analyst. She is designated as the head of the analysis section. Her work focuses on government websites and intranets, corporate business applications and websites. Katarzyna is a specialist in content management systems. She has been working with Liferay Portal since 2010 and has designed various products based on this technology using not only its default functionalities, but also expanding them and designing entirely new modules.
Since 2003, her main areas of interest revolved around business process modeling, managing business requirements, understanding user's needs, and designing usable systems. She is also one of the authors who writes on www.liferay-guru.com, where she shares her experience and knowledge on Liferay Portal CMS.
Katarzyna is certified in Prince 2 Foundation, Agile Project Management Foundation, and is a Professional Scrum Master. She is also a member of International Institute of Business Analysis. She holds a master's degree in arts in Russian philology from the University of Warsaw, Faculty of Applied Linguistics, Poland.
I would like to thank Krzyś for his unwavering support and understanding. I would also like to thank Szymon Gołębiewski; he is the reason my adventure with Liferay began.
Pierpaolo Cira is a Liferay Certified Professional Developer and has been working as a software developer, software architect, and system integrator since 2001.
He has been involved in many e-business, knowledge management, e-learning e-tourism, brand monitoring, and business intelligence research projects at the University of Salento in collaboration with companies such as Oracle and IBM on several research projects. He also collaborated on the design and development of the first implementation of the OMG SBVR editing tool. He reviewed Android Apps with Eclipse, O. Cinar, Apress 2012. He has been working on several enterprise web applications based on Liferay Portal and Alfresco ECM, such as web portals, intranets, and document management systems, for public administrations and big companies.
Currently, he is a consultant on Liferay Portal and Big Data technologies and solutions.
He can be found on Twitter at @pierpaci.
I would like to thank my family and my wife for their support and patience.
Zoltán Fiala leads a competence center for software development at adesso AG in Hamburg, Germany. He holds a PhD in web engineering from Dresden University of Technology and has worked as a SharePoint and Liferay architect and project manager for several IT consultancy firms in the past. Zoltán has significant experience in the design and development of web content management and portal solutions. For more information on Zoltán, refer to http://www.z-fiala.net.
Giuseppe Urso is a software engineer with 10 years of extensive working experience in the design and agile development of service-oriented applications and distributed systems based on Java SE and Java EE. He works in the IT industry as a senior systems architect and Java developer, handling responsibilities involving architecture design and the implementation of several large-scale projects based on Alfresco ECM and Liferay Portal. His major areas of expertise include Amazon Web Services (AWS), Elastic Compute Cloud (EC2) technologies, and Message-oriented Middleware. Giuseppe earned his master's degree in computer engineering at the University of Salento, Italy. He is a licensed engineer and member of the Professional Engineers Association called "Ordine degli Ingegneri della Provincia di Lecce". He is an Alfresco certified administrator and committer on the Alfresco-SDK project. As an open source enthusiast, he runs a personal blog at www.giuseppeurso.eu, where he writes articles and useful guidelines on Java, Alfresco, Liferay, and practices of GNU/Linux systems administration.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Liferay Portal is one of the most popular portal frameworks on the market, offering many out-of-the-box features to build, install, configure, and customize portal or intranet solutions. The main purpose of this book is to help you successfully build the intranet system by providing step-by-step recipes. You will be taken on a tour that covers the most common issues when dealing with Liferay. In every recipe, you will find solutions to real-life problems with many explanations. The chapters are organized and ordered in such a way that they will help you go through the intranet configuration step by step.
Chapter 1, Installation and Basic Configuration, provides you with a basic knowledge on how to install and run Liferay on Apache Tomcat. It also teaches you how to create a new basic portlet.
Chapter 2, Authentication and Registration Process, describes several useful ways to correctly configure authentication. It helps you learn about integration with a popular single sign-on mechanism: CAS and communicate it with LDAP.
Chapter 3, Working with a Liferay User / User Group / Organization, introduces you to the concept of user, user group, and organization management in Liferay. It also explains how to use them together.
Chapter 4, Liferay Site Configuration, offers many useful recipes connected with site configuration, such as creating sites, their templates, and enabling staging and versioning.
Chapter 5, Roles and Permissions, discusses roles and permissions and the possibility to build a scalable grid of roles depending on the user's position in the company.
Chapter 6, Documents and Media in Liferay, introduces you to portlet, which provides media and document file storage. This chapter also offers you advice on how to correctly configure it. You will also learn how to integrate documents and media portlet with Amazon S3 storage.
Chapter 7, Working with Content, talks about the most common CMS feature, that is, web content management.
Chapter 8, Search and Content Presentation Tools, introduces various functionalities connected with the searching and content presentation tool. This chapter also talks about tagging and categorizing assets.
Chapter 9, Liferay Workflow Capability, teaches you how to apply workflow on assets and deploy the Kaleo Web portlet.
Chapter 10, Collaboration Tools, provides recipes in collaboration with Wiki, blogs, message boards, calendars, and so on.
Chapter 11, Quick Tricks and Advanced Knowledge, contains a set of various recipes, which help you to perform specific tasks for your intranet sites. There are many subjects, for example, enabling SMTP, configuring clustered environment, or using the Liferay service bus.
Chapter 12, Basic Performance Tuning, offers information on scalable infrastructure and discusses most common problems associated with performance.
This book uses Liferay Portal version 6.2 with the following settings:
All recipes are based on the Linux operating system, but all of them can be done (with only a little effort) on Windows or iOS.
If you are a Java developer or administrator with a technical background and want to install and configure Liferay Portal as an enterprise intranet, this is the book for you. In short, reusable recipes help you realize business goals as working features in Liferay. This book will also give you useful hints on how to easily improve the default functionality of the system and its performance.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Control Panel link."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the ErrataSubmissionForm link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will cover the following topics:
Liferay is the market's leading provider of open source portal solutions. It provides a solid platform to serve our site to all clients. It is difficult to say what Liferay is. On the one hand, Liferay is a great content-management system, but on the other hand, it provides many tools for collaboration and communication between users. It can also be a social platform with many functionalities, such as wall, message board, chat, and many others. Furthermore, it is a portlet container that is JSR-168 and JSR-286 compliant. Java Specification Requests (JSRs) describes final specifications for the Java platform. A portlet is a small web application that produces fragments of HTML code that are aggregated into a portal. JSR-168 and JSR-286 specifications standardize how portlets interact with portlet containers. These specifications also describe a standard application programming interface for Java portlet development. In other words, Liferay is only responsible for aggregating the set of portlets that are to appear on any particular page. This approach gives users a great tool to organize and customize portlets in order to build whole portals, social platforms, or intranets. Within Liferay, a portal is composed of a number of portlets, which are self-contained interactive elements that are written to a particular standard. A number of publications describe Liferay's advantages. In this book, we will try to delve deeper into Liferay's architecture and its functionalities.
The primary purpose of this chapter is to give you an insight about Liferay's installation and management with basic configuration. We realize that there are many ways to download, compile, install, and run Liferay Portal. Our main purpose is to provide some clear and basic information about the starting package on which we will rely and work. This chapter explains the main processes that are performed on every compiling action or on every startup action.
Liferay Portal is distributed in two different editions:
This book is based on the Liferay Portal Community Edition (CE) version with the newest release, which is 6.2.
To start the journey with Liferay, there are a few starting points that contain a lot of useful information, which are as follows:
URL
Description
http://www.liferay.com/
Official Liferay site
http://www.liferay.com/downloads/liferay-portal/available-releases
Place with available releases
http://www.liferay.com/documentation/liferay-portal/6.2/user-guide and https://dev.liferay.com/
User guides and documentation
http://svn.liferay.com/repos/public/portal
Old-fashion repository of Liferay code.
https://github.com/liferay/liferay-portal/tree/6.2.x
[Recommended] GitHub repository
Liferay introduced 7.0 version, which will be released on September 2015. Do not check out Liferay sources from the trunk. There are many changes between 6.2 and the trunk version. In the 7.0 version, Liferay will provide OSGi integration and many new features. These new features help users and developers achieve a whole bunch of out-of-the-box functionalities (for instance, Elasticsearch as a search server based on the Lucene framework).
The simplest way to run Liferay is to download a specific bundle from the Liferay official site. A Liferay bundle is just a compressed archive that contains all that is needed to host the Liferay Portal. A bundle consists of a Java-based application server and the deployed Liferay Portal core application. Liferay provides these bundle runtimes with different application servers (that is, Tomcat, JBoss, Geronimo, and so on) so that you can use any one based on your choice. This method is recommended for people who just want to run Liferay Portal, look at its functionalities, and configure their site using the GUI. In this recipe, you will learn the art of setting up Liferay on Tomcat and the MySQL database engine.
First, make sure that JRE or JDK is properly installed. Type the following command line:
The result should be similar to this:
Also, check out the Java SDK version. Liferay recommends Java 7 or later.
Moreover, determine whether the MySQL server installation is done:
As a result, the actual installed version should be displayed. Here is an example:
Also, check out the MySQL version. We recommend 5.5 version or later.
In order to run Liferay on a Tomcat bundle, follow these steps:
Make sure that the MySQL user has permissions to create tables.
Download the correct Liferay version on the Tomcat bundle from http://www.liferay.com/downloads/liferay-portal/available-releases.Unzip the downloaded archive.Go to the extracted folder liferay-portal-6.2-ce-ga2. This path will be called ${liferay.home} folder.Go to the ${liferay.home} folder and create a file called portal-ext.properties.Edit portal-ext.properties and set the database properties:Running the Liferay Portal from a prepared bundle is quite an easy task to accomplish. However, it is worth knowing what exactly happens when Tomcat is being started. Take a brief look at the catalina.out log and try to examine it line by line.
The first thing is to deploy ROOT.xml. In our catalina.out file, there is a line present, which is shown as follows:
It means that the configuration file turns on the crossContext attribute in Tomcat 7. This setting is required because Liferay is a portlet container. Hence, it is an application that should have access to other applications called portlets. The Apache Tomcat documentation says:
"Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host."
The next few lines of the logfile show portal properties and system properties that are loaded from specific locations:
The main configuration file for Liferay Portal is portal.properties, which contains a detailed explanation about the properties that it defines. There are at least three possible ways to override portal.properties. There is a functionality to put portal-ext.properties in the ext plugin, in the ${liferay.home} directory, or in portal-setup-wizard.properties. But which file is the most important? The answer is placed in portal.properties file. The default read order is portal.properties, portal-bundle.properties, portal-ext.properties, and then portal-setup-wizard.properties:
The next step is to recognize the database's dialect:
Liferay supports many database engines, such as DB2, Derby, Hypersonic, Ingres, MySQL, Oracle, P6Spy, PostgreSQL, and Sybase. The default database is Hypersonic, which stores all data in the ${liferay.home}/data/hsql/lportal directory. This is a good option for developers who want to run JUnit tests, which modify data by testing the persistence layer or business process.
On every restart, Liferay tries to get the build number (Liferay version) from the Release_ table. If this table doesn't exist, it calls ReleaseLocalService.createTablesAndPopulate().
If it is not possible to get the build number, Liferay logs the following information:
The createTablesAndPopulate method runs following scripts:
Apart from creating tables and populating data, Liferay triggers the VerifyProcess mechanism. This process will run on every startup to verify and fix any integrity problems found in the database. This is the perfect place for developers to add custom code to check the integrity of specific cases.
The last step is initializing the autodeploy and the hotdeploy listeners. In general, these mechanisms install all the plugins into the Tomcat container and register them as portlets, hooks, themes, and so on. In particular, there are at least three deploying approaches: sandbox deploy, autodeploy, and hotdeploy.
By default, Liferay uses the autodeploy and hotdeploy listeners. In fact, sandbox can currently deploy only themes and portlets.
The autodeploy mechanism is responsible for listening on a specific directory to install on-the-fly new plugins and copying them into the Tomcat hotdeploy process. A definition of that directory is placed in portal.properties, and by default, it is in the deploy folder:
Every type of plugin has its own autodeploy mechanism. This mechanism runs all the necessary steps to install it correctly in the Liferay container. In simple terms, the autodeploy mechanism generates the web.xml file and adds the required libraries to specific plugins. Definitions of these classes are placed in the portal.properties file with an auto.deploy.* prefix. Each class extends BaseAutoDeployListener.
The second process, hotdeploy, is responsible for registering plugins in Liferay. There are many steps, such as creating database tables, setting preferences, registering Spring application contexts, and so on. Of course, each step depends on the type of plugin. In portal.properties, there are definitions for each type of class:
In the deployment process, the Liferay deployer modifies the web.xml file, adds specific dependencies, and packs it again. Ensure that you do not copy the WAR file directly to the Tomcat webapps folder. If you do so, the plugin will not work.
Often, enterprises have an established Java EE infrastructure upon which they would like to install Liferay. You must consider also the enterprise's security policies. These policies sometimes prevent the download and installation of the Tomcat bundle into a location of your choice. In this situation, a bundle will not suffice, and you have to manually install Liferay from its WAR archive into an already existing Apache Tomcat application server.
There are six steps to achieve this goal. They are as follows:
More detailed instructions of how to install Liferay on the Tomcat server are available on the official Liferay documentation at https://www.liferay.com/documentation/liferay-portal/6.2/user-guide/-/ai/installing-liferay-on-tomcat-3.
For information about running Liferay on the clustered environment, refer to the Clustering Liferay Portal recipe in Chapter 11, Quick Tricks and Advanced Knowledge, and the Scalable infrastructure recipe in Chapter 12, Basic Performance Tuning. For information about setting the developer's environment, refer to the next recipe.
After successfully running Liferay on the Apache Tomcat server, the system asks users to fill some necessary information to complete the setup wizard. This is only a single screen with basic fields, such as administrator name or portal name.
After running Liferay for the first time, the Liferay platform displays the basic configuration form, which looks like this:
To finish installation, it is necessary to fill in the preceding form as follows:
After confirming the Password Reminder form, you will be able to see and use the main Liferay navigation tools.
Follow these steps to navigate to Control Panel:
After running Liferay for the first time, Liferay needs basic information about the portal, database, and administrator. The database connection was set in portal-ext.properties, and it was described in the previous recipe.
All data which was provided on the portal wizard was stored in the ${liferay.home}/portal-setup-wizard.properties file. The most important settings are described in the following table:
Property name
Description
admin.email.from.name
This describes the name of the administrator.
admin.email.from.address
This is the e-mail address of the administrator.
liferay.home
This is the path to the ${liferay.home} directory. This property is very important and must be set.
setup.wizard.enabled
This flag disables the setup wizard.
After logging in, the user is able to see navigation tools available for authorized users only. Here are the navigation tools:
In internal projects such as intranets, user accounts most often are created and managed in external systems, for instance, LDAP. Therefore, it is unnecessary (and sometimes even unacceptable) to allow users to manage their authentication data (for instance, to set a password-reminder query) or ask them to agree to terms of use directly within Liferay. In Liferay, there are many properties that can help customize the first login action, a few of which are as follows:
Property name
Description
terms.of.use.required=false
This turns off the terms of use
terms.of.use.journal.article.group.id and terms.of.use.journal.article.id
This specifies the group ID and article ID that will be displayed as the terms of use
users.reminder.queries.enabled=false
This disables the reminder query functionality