Pages

Thursday, March 29, 2012

Liferay Portal Architecture


Before we dive into the user interface for adding and maintaining various portal resources, we should survey the concepts Liferay uses to organize a portal. Portals are accessed by users. Users can be collected into user groups. Users can belong to organizations. Organizations can be grouped into hierarchies, such as Home Office → Regional Office → Satellite Office. Sites can be created independently or can be attached to users or organizations. Within sites, users can belong to teams, which are groupings of users for specific functions within a site




A simple way to think about this is that your portal has users and various ways to group them together. Some of these groupings may be organized hierarchically by an administrator. These are called organizations. An administrator can also create more ad hoc groupings of users called user groups. User groups can be composed of users who do not fit into a particular hierarchy or who belong to different organizations. Other groupings may be created by the users themselves. For example, users from different organizations could create a site called "Dog Lovers" and allow anyone to join. The site would not fit into an organizational hierarchy; it would just serve a common interest in dogs. Administrators can create teams within sites. The following figure illustrates how users can be grouped in Liferay Portal: users can belong to sites, organizations, and user groups and user groups can belong to sites and organizations.

More Visit Here

Tricks for Debugging Liferay


  Here are a few tricks that I have come across that have proven to be pretty useful.

1. Monitoring Memory and CPU usage

This is pretty basic and is quite helpful in performance tests.  Monitoring these aspects will help determine if a system is memory-bound or CPU-bound.  For the memory bit, Sun provides a nice set of tools called jvmstat to watch how garbage collection is doing on your system.  If you see the GC running too often or collecting huge amounts of memory at a time, that probably means you need to fix your 
JVM parameters.  For the CPU bit, your operating system usually comes bundled with some kind of CPU usage monitor.  In the case of the Mac OS X/Linux/Unix breed, you can use iostat or vmstat.  For Windows, you can use the bundled administration tool called Performance Monitor.

2. Getting Thread Dumps

Now, if you think you are deadlocking somewhere or spending way too much time in certain blocks of code under load, a pretty useful test is to gather thread dumps of the JVM.  This will tell you what every thread on the portal is doing at a given point in time.  Not sure how to do this on Windows, but under Mac OS X/Linux/Unix, you can do a 
kill -3 <pid> and your portal's log file will now have a bunch of information on what each thread was doing at the moment in time.  Don't be afraid of this command -- it will not kill your server (unless, of course, you do a kill -9 <pid> or something like that... so don't http://www.liferay.com/html/js/editor/fckeditor/editor/images/smiley/msn/teeth_smile.gif).



3. Remote Debugging

So in this scenario, you are running your portal on server X and you have all your debugging tools on laptop Y.  Well, if using Tomcat, you can start your portal with the command 
catalina.sh jpda start and it will enable remote debugging.  Then, using Eclipse or another IDE on laptop Y, you can start the debugger and hook it into a remote Java application on localhost port 8000.  You can then step through code and set breakpoints as though you were debugging code on your own laptop.

Hope that helps.  And if all else fails, search the Internet -- it never lies.s

Liferay Logging System


Liferay uses Log4j extensively to implement logging for nearly every class in the portal. If you need to debug something specific while the system is running, you can use the control panel to set logging levels by class dynamically.
To view the log levels, go to the control panel, click Server Administration in the Server section, and then click the Log Levels tab.
A paginated list of logging categories appears. These categories correspond to Liferay classes that have log messages in them. By default, all categories are set to display messages only if there is an error that occurs in the class. This is why you see ERROR displayed in all of the drop-down list boxes on the right side of the portlet.
Each category is filtered by its place in the class hierarchy. For example, if you wanted to see logging for a specific class that is registered in Liferay, you would browse to that specific class and change its log level to something that is more descriptive, such as DEBUG. Once you click the Save button at the bottom of the list, you'll start seeing DEBUG messages from that class in your application server's log file.
If you're not sure which class you want to see log messages for, you can find a place higher up in the hierarchy and select the package name instead of an individual class name. If you do this, messages for every class lower in the hierarchy will be displayed in your application server's log file.


maintaining-log-levels.png
Figure 16.2: Log levels can be dynamically changed at runtime, whenever you need to debug an issue.
Be careful when you do this. If you set the log level to DEBUG somewhere near the top of the hierarchy (such as com.liferay, for example), you may wind up with a lot of messages in your log file. This could make it difficult to find the one you were looking for, and causes the server to do more work writing messages to the log.
If you want to set the log level for one of your own classes in a deployed plugin, you can register that class with Liferay so that you can control the log levels more easily, so long as your class uses Log4J to do its logging.
You will first need to implement Log4J logging in your class, with a statement such as the following (taken from Liferay's JCRStore class):
private static Log _log = LogFactory.getLog(JCRStore.class);
You would then use this _log variable to create log messages in your code for the various logging levels:
_log.error("Reindexing " + node.getName(), e1);
To enable your logging messages to appear in your server's log file via the control panel, click the Add Category tab on the same Log Levels page.
maintaining-add-log-category.png
Figure 16.3: Adding your own logging classes is as simple as specifying it in this field.
You'll see that you can add a logging category. Put in the fully qualified name of your class or of the package that contains the classes whose log messages you want to view, choose a log level, and then click the Save button. You will now start to see log messages from your own class or classes in the server's log file.
Logs are great for figuring out issues in production. But what if Liferay contacts you via its support channel with a bug fix or a security enhancement? Read on to learn how to patch Liferay.

Liferay Blogs Portlet


Configure email notification settings.
blogs.email.from.name=
blogs.email.from.address=
 
blogs.email.entry.added.enabled=true
blogs.email.entry.added.subject=com/liferay/portlet/blogs/dependencies/email_entry_added_subject.tmpl
blogs.email.entry.added.body=com/liferay/portlet/blogs/dependencies/email_entry_added_body.tmpl
 
blogs.email.entry.updated.enabled=true
blogs.email.entry.updated.subject=com/liferay/portlet/blogs/dependencies/email_entry_updated_subject.tmpl
blogs.email.entry.updated.body=com/liferay/portlet/blogs/dependencies/email_entry_updated_body.tmpl
 



blogs.page.abstract.length=400
 
blogs.rss.abstract.length=200
Set the excerpt length for linkbacks.
blogs.linkback.excerpt.length=200
Set the interval on which the LinkbackMessageListener will run. The value is set in one minute increments.
blogs.linkback.job.interval=5
Set this to true to enable pingbacks.
blogs.pingback.enabled=true
Set this to true to enable trackbacks.
blogs.trackback.enabled=true
Set this to true to enable pinging Google on new and updated blog entries.
blogs.ping.google.enabled=true
Set this to true to enable comments for blogs entries.
blogs.entry.comments.enabled=true
Set this to true to enable previous and next navigation for blogs entries.
blogs.entry.previous.and.next.navigation.enabled=true
Set the maximum file size and valid file extensions for images. A value of 0 for the maximum file size can be used to indicate unlimited file size. However, the maximum file size allowed is set in the property com.liferay.portal.upload.UploadServletRequestImpl.max.size.
blogs.image.small.max.size=51200
A file extension of * will permit all file extensions.
blogs.image.extensions=.gif,.jpeg,.jpg,.png
Set this to true if blogs should be published to live by default.
blogs.publish.to.live.by.default=false

Liferay Shopping Portlet


Set this to true if cart quantities must be a multiple of the item's minimum quantity.
shopping.cart.min.qty.multiple=true
Set this to true to forward to the cart page when adding an item from the category page. The item must not have dynamic fields. All items with dynamic fields will forward to the item's details page regardless of the following setting.


shopping.category.forward.to.cart=false
Set this to true to show special items when browsing a category.
shopping.category.show.special.items=false
Set this to true to show availability when viewing an item.
shopping.item.show.availability=true
Set the maximum file size and valid file extensions for images. A value of 0 for the maximum file size can be used to indicate unlimited file size. However, the maximum file size allowed is set in the property com.liferay.portal.upload.UploadServletRequestImpl.max.size.
shopping.image.small.max.size=51200
shopping.image.medium.max.size=153600
shopping.image.large.max.size=307200
A file extension of * will permit all file extensions.
shopping.image.extensions=.gif,.jpeg,.jpg,.png
Configure email notification settings.
shopping.email.from.name=
shopping.email.from.address=
 
shopping.email.order.confirmation.enabled=true
shopping.email.order.confirmation.subject=com/liferay/portlet/shopping/dependencies/email_order_confirmation_subject.tmpl
shopping.email.order.confirmation.body=com/liferay/portlet/shopping/dependencies/email_order_confirmation_body.tmpl
 
shopping.email.order.shipping.enabled=true
shopping.email.order.shipping.subject=com/liferay/portlet/shopping/dependencies/email_order_shipping_subject.tmpl
shopping.email.order.shipping.body=com/liferay/portlet/shopping/dependencies/email_order_shipping_body.tmpl
Set this to true to enable comments for shopping orders.
shopping.order.comments.enabled=true

Captcha in Liferay


Set the maximum number of captcha checks per portlet session. Set this value to 0 to always check. Set this value to a number less than 0 to never check. Unauthenticated users will always be checked on every request if captcha checks is enabled.



captcha.max.challenges=1
Set whether or not to use captcha checks for the following actions.
captcha.check.portal.create_account=true
captcha.check.portal.send_password=true
captcha.check.portlet.message_boards.edit_category=false
captcha.check.portlet.message_boards.edit_message=false
Set the engine used to generate captchas. reCAPTCHA uses an external service that must be configured independently but provides an audible alternative which makes the captcha accessible to the visually impaired.
Examples:
captcha.engine.impl=com.liferay.portal.captcha.recaptcha.ReCaptchaImpl
captcha.engine.impl=com.liferay.portal.captcha.simplecaptcha.SimpleCaptchaImpl
reCAPTCHA
captcha.engine.recaptcha.key.private=
captcha.engine.recaptcha.key.public=
captcha.engine.recaptcha.url.script=http://api.recaptcha.net/challenge?k=
captcha.engine.recaptcha.url.noscript=http://api.recaptcha.net/noscript?k=
captcha.engine.recaptcha.url.verify=http://api-verify.recaptcha.net/verify
SimpleCaptcha
Set the height and width for captcha images generated by SimpleCaptcha.
captcha.engine.simplecaptcha.height=50
captcha.engine.simplecaptcha.width=150
Input a list of comma delimited class names that implement nl.captcha.backgrounds.BackgroundProducer. These classes will be randomly used by SimpleCaptcha to generate a background for a captcha image.
captcha.engine.simplecaptcha.background.producers=nl.captcha.backgrounds.FlatColorBackgroundProducer,nl.captcha.backgrounds.GradiatedBackgroundProducer,nl.captcha.backgrounds.SquigglesBackgroundProducer,nl.captcha.backgrounds.TransparentBackgroundProducer
Input a list of comma delimited class names that implement nl.captcha.gimpy.GimpyRenderer. These classes will be randomly used by SimpleCaptcha to gimp a captcha image.
Examples:
captcha.engine.simplecaptcha.gimpy.renderers=nl.captcha.gimpy.RippleGimpyRenderer
captcha.engine.simplecaptcha.gimpy.renderers=nl.captcha.gimpy.BlockGimpyRenderer,nl.captcha.gimpy.DropShadowGimpyRenderer,nl.captcha.gimpy.FishEyeGimpyRenderer,nl.captcha.gimpy.RippleGimpyRenderer,nl.captcha.gimpy.ShearGimpyRenderer
Input a list of comma delimited class names that implement nl.captcha.noise.NoiseProducer. These classes will be randomly used by SimpleCaptcha to add noise to a captcha image.
Examples:
captcha.engine.simplecaptcha.noise.producers=nl.captcha.noise.CurvedLineNoiseProducer captcha.engine.simplecaptcha.noise.producers=nl.captcha.noise.CurvedLineNoiseProducer,nl.captcha.noise.StraightLineNoiseProducer
Input a list of comma delimited class names that implement nl.captcha.text.producer.TextProducer. These classes will be randomly used by SimpleCaptcha to generate text for a captcha image.
Examples:
captcha.engine.simplecaptcha.text.producers=com.liferay.portal.captcha.simplecaptcha.PinNumberTextProducer
captcha.engine.simplecaptcha.text.producers=com.liferay.portal.captcha.simplecaptcha.DictionaryWordTextProducer,com.liferay.portal.captcha.simplecaptcha.PinNumberTextProducer,nl.captcha.text.producer.DefaultTextProducer,nl.captcha.text.producer.FiveLetterFirstNameTextProducer
Input a list of comma delimited class names that implement nl.captcha.text.renderer.WordRenderer. These classes will be randomly used by SimpleCaptcha to render text for a captcha image.
Examples:
captcha.engine.simplecaptcha.word.renderers=nl.captcha.text.renderer.DefaultWordRenderer
captcha.engine.simplecaptcha.word.renderers=nl.captcha.text.renderer.ColoredEdgesWordRenderer,nl.captcha.text.renderer.DefaultWordRenderer

Facebook integration in Liferay


Facebook is currently the number one social network in the world with somewhere in the neighborhood of 750 million active users. If you're trying to build a community on your portal, you don't want to neglect a bridge to nearly a billion possible users. With that in mind, Liferay provides a few easy ways that you can integrate your portal with Facebook.

Facebook sign on

Like many web sites that you may visit, any portal running on Liferay can be set up to use Facebook for sign in. This makes it easier for users to sign in to your site, since they won't need to remember another user name and password, For more information on setting up Facebook sign on, see chapter 12.


Using your portlets as Facebook applications

You can add any Liferay portlet as an application on Facebook. To do this, you must first get a developer key. A link for doing this is provided to you in the Facebook tab in any portlet's Configuration screen. You will have to create the application on Facebook and get the key and canvas page URL from Facebook. Once you've done this, you can copy and paste their values into the Facebook tab. Your portlet is now available on Facebook.
This integration enables you to make things like Message Boards, Calendars, Wikis, and other content on your portal available to a much larger audience (unless you already have in billion users on your site, in which case, kudos to you).