Wednesday, 31 July 2013

Communities in Liferay Portal


Communities in Liferay Portal



Community is the group of users who shares the same interests. Each community have its own private and public pages in liferay portal.

Types of Communities:

There are 3 types of communities Liferay Portal. These are as follows-

   1. Open: Open Community allows users to join and leave a Community whenever they want to.
   2. Restricted: In Restricted Community user first have to make request for the membership. It means Restricted Community requires administrator or owner approval to add users to the community or to remove users from the community but users have the ability to leave the community.
   3. Private: In case of Private Community there is no way to join or make request for membership.Both  Community Owner and Community administrator can assign a user to the Community.

So basic difference between Restricted and Private Community is that, in case of Restricted Community membership is subject to administrator approval but in case of Private Community there is no way of joining the Community.

What we can do with System.properties

What we can do with System.properties


The system.properties file is provided for a  convenient way to set all properties for the JVM machine and related system settings. Start your application server with the system property “system.properties.load = true” to load it.

 When the server starts, the portal will load system.properties and then system-ext.properties.
Start your application server with the system property “system.properties.final=true” if the properties of 
system.properties override all similar command line properties.
If set to false, the properties of system.properties will be set if and only if those properties are not currently set.
Some application servers require you to set the file.encoding and user.timezone on startup regardless of system.properties because the application server reads these properties before
system.properties is ever loaded.
Following  are the default values of the 
system.properties properties are shown:
##
## Java
##

    #
    # The file encoding must be set to UTF-8 in order for the
    # internationalization to work correctly.
    #
    file.encoding=UTF-8

    #
    # Java uses the underlying operating system to generate images. If you are
    # using Unix and do not start the portal in a X Windows session, then Java
    # will not know how to generate images and you'll get lots of nasty
    # exceptions. Setting this property to true will fix that. Sometimes this
    # property cannot be set dynamically when the server starts and you'll need
    # to edit your start script to include this as a system property.
    #
    java.awt.headless=true

    #
    # Set the default language.
    #
    user.country=US
    user.language=en

    #
    # The time zone must be set GMT so that the portal knows how to properly
    # translate time across time zones.
    #
    user.timezone=GMT

##
## Servlet Filters
##

    #
    # If the user can unzip compressed HTTP content, the compression filter will
    # zip up the HTTP content before sending it to the user. This will speed up
    # page rendering for users that are on dial up.
    #
    com.liferay.filters.compression.CompressionFilter=true
    com.liferay.filters.compression.CompressionFilter.encoding=UTF-8

    #
    # The strip filter will remove blank lines from the outputted content. This
    # will speed up page rendering for users that are on dial up.
    #
    com.liferay.filters.strip.StripFilter=true
    com.liferay.filters.strip.StripFilter.encoding=UTF-8

    #
    # The layout cache filter will cache pages to speed up page rendering for
    # guest users. Set the refresh time in milliseconds on how often the cache
    # should refresh. Set it to 0 if the cache never times out. Default time out
    # is set to one hour.
    #
   com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter=true
   com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.encoding=UTF-8
   com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.refresh.time=3600000

    #
    # The virtual host filter maps hosts to public and private pages. For
    # example, if the public virtual host is www.helloworld.com and the friendly
    # URL is /helloworld, then http://www.helloworld.com is mapped to
    # http://localhost:8080/web/helloworld.
    #
   com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter=true

    #
    # The CAS filter will redirect the user to the CAS login page for SSO. See
    # http://www.ja-sig.org/products/cas for more information.
    #
    com.liferay.filters.sso.cas.CASFilter=false

##
## Logging
##

    #
    # Set any logger that implements org.apache.commons.logging.Log.
    #
   #org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

    #
    # Set the following to true if Log4j complains that it was not properly
    # configured.
    #
    log4j.configure.on.startup=true

##
## Encryptor
##

    #
    # Set the security provider class.
    #
   com.liferay.util.Encryptor.provider.class=com.sun.crypto.provider.SunJCE

##
## HTTP
##

    #
    # Set the location of the HTTP proxy that the portal will use to fetch
    # external content.
    #
    #http.proxyHost=192.168.0.200
    #http.proxyPort=4480

    #
    # These are read for backwards compatibility and only used if the
    # "http.proxyHost" and "http.proxyPort" settings are not specified.
    #
    #com.liferay.util.Http.proxy.host=192.168.0.200
    #com.liferay.util.Http.proxy.port=4480

    #
    # Set the proxy authentication type.
    #
    #com.liferay.util.Http.proxy.auth.type=username-password
    #com.liferay.util.Http.proxy.auth.type=ntlm

    #
    # Set user name and password used for HTTP proxy authentication.
    #
    #com.liferay.util.Http.proxy.username=
    #com.liferay.util.Http.proxy.password=

    #
    # Set additional properties for NTLM authentication.
    #
    #com.liferay.util.Http.proxy.ntlm.domain=
    #com.liferay.util.Http.proxy.ntlm.host=

    #
    # Set the connection timeout when fetching HTTP content.
    #
    com.liferay.util.Http.timeout=5000

##
## Format
##

    #
    # Set the location of the class that implements
    # com.liferay.format.PhoneNumberFormat. This class will format phone
    # numbers.
    #
   com.liferay.util.format.PhoneNumberFormat=com.liferay.util.format.USAPhoneNumberFormat
   #com.liferay.util.format.PhoneNumberFormat=com.liferay.util.format.IdenticalPhoneNumberFormat

##
## Axis
##

    #
    # Urls that match the specified pattern will use the SimpleHTTPSender. Urls
    # that do not match the specified pattern will use Axis' default HTTPSender.
    #
   com.liferay.util.axis.SimpleHTTPSender.regexp.pattern=.*mappoint\.net.*

##
## XSS (Cross Site Scripting)
##

    #
    # Set the pattern to strip text of XSS hacks.
    #
    com.liferay.util.XSSUtil.regexp.pattern=(?i)<[\\s]*/?script.*?>|<[\\s]*/?embed.*?>|<[\\s]*/?object.*?>|<[\\s]*a[\\s]*href[^>]*javascript[\\s]*:[^(^)^>]*[(][^)]*[)][^>]*>[^<]*(<[\\s]*/[\\s]*a[^>]*>)*

##
## Upload Servlet Request
##

    #
    # Set the maximum file size. Default is 1024 * 1024 * 1000.
    #
    com.liferay.util.servlet.UploadServletRequest.max.size=104857600

    #
    # Set the temp directory for uploaded files.
    #
    #com.liferay.util.servlet.UploadServletRequest.temp.dir=C:/Temp

##
## Session Parameters
##

    #
    # Encrypt session parameters so that browsers cannot remember them.
    #
    com.liferay.util.servlet.SessionParameters=true

##
## Lucene
##

    #
    # Set a timeout to avoid lock errors.
    #
    #org.apache.lucene.writeLockTimeout=30000

##
## Quartz
##

    #
    # Make threads daemon so the JVM exits cleanly.
    #
    org.quartz.threadPool.makeThreadsDaemons=true

##
## Velocity Engine
##

    #
    # Input a list of comma delimited class names that extend
    # com.liferay.util.velocity.VelocityResourceListener. These classes will
    # run in sequence to allow you to find the applicable ResourceLoader
    # to load a Velocity template.
    #
   com.liferay.util.velocity.VelocityResourceListener=com.liferay.portal.velocity.ServletVelocityResourceListener,\
com.liferay.portal.velocity.JournalTemplateVelocityResourceListener,\
com.liferay.portal.velocity.DefaultVelocityResourceListener

Configure any database to the liferay

Configure any database to the liferay


configure any database to the liferay
 
Important files & locations:-
portal-impl.jar :- Liferay_Home\tomcat-6.0.29\webapps\ROOT\WEB-INF\lib
Portal.properties:- Present in servelet-impl.jar (Jar files can be open by WinZip or use java decompiler). Contain all the portlet related properties.
Portal-ext.properties:- Create and place at
Liferay_Home\tomcat-6.0.29\webapps\ROOT\WEB-INF\classes (or) Liferay_Home
Before configure any database to the liferay:-
When liferay Tomcat is started, it reads portal.properties file and database related name value pairs has the following data is uncommented and it configure hypersonic as db.
# Hypersonic
jdbc.default.driverClassName=org.hsqldb.jdbcDriver
jdbc.default.url=jdbc:hsqldb:${liferay.home}/data/hsql/lportal
jdbc.default.username=sa
jdbc.default.password=
Steps to configure MySQL to liferay:-
1)      Install MySQL database server and MySQL gui.
2)      Open MySQL gui and Create one schema named as liferay_db(No tables are created)
3)      Create portal-ext.properties file with the following data and place in the above specified location.(Note:- File name should be portal-ext.propeties otherwise tomcat is unable to read)
# MySQL
     jdbc.default.driverClassName=com.mysql.jdbc.Driver   
jdbc.default.url=jdbc:mysql://localhost/liferay_db?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root
After configuring MySQL database to the liferay following things happen:-
1)      Start the tomcat
2)      Tomcat read portal.properties file form portal-impl.jar, and assumed as hypersonic is the database
3)      Then tomcat read portal-ext.properties file, in which database name value pairs are overridden.
4)      Database is determined as MySQL.
5)      Create tables and populate with default data.

Creating a Portlet in 6.1 CE

Creating a Portlet in 6.1 CE


How do you develop a portlet for liferay? Since often asked and being ridiculously easy, I wrote down the steps here:
In this work-through, I assume you have successfully installed Liferay 6.1 CE as well as Eclipse Indigo and the Liferay SDK IDE.
Then you can start the standard eclipse "New... wizard" and chose to create a "Liferay project":
Give it a name and chose "Portlet" as the plugin type:
Of course, we will use the simpliest possible approach and thus choose Liferay MVC, the standard framework for creating portlets:
The IDE is now creating an empty Web-Project, complete with /docroot/WEB-INF and so forth.
Time to include the portlet. Start the "New Liferay portlet"-wizard available in the "New"-menu. Choose a meaningful name and let it subclass Liferay's "MVCPortlet". This will save you a lot of tedious work later on:
In the next dialog, you decide which modes (only view for the moment) your portlet will implement and whether JSPs and I18N-files are created. Click "Create resource bundle file":
The next dialog deals which CSS and JavaScript resources (leave untouched) and categorization. I chose to display hte portlet in the "Collaboration" section as well as in the Control Panel:
The last dialog page can be skipped. Finish the wizard. Your new project becomes populated with some default files now. Feel free to browse them:






  • Language.properties will hold the I18N messages.
  • Task.java is the Portlet itself - more on it below.
  • main.css - will hold your style classes - its empty now.
  • view.jsp of course is the user interface.
  • main.js may be included to use javascript code.
  • WEB-INF holds a lot of configuration code - lets take a look at it later.
  • build.xml is the ant build script.








Ok! Lets deploy this portlet. Use the context menu on the project to bring up the liferay build menu:
Hit "all" or "deploy" will fire up the Plugin SDK an deploy the project into your liferay. As usual, tail -f tomcat/logs/catalina.out is your friend for controlling deployment. If all runs well - and it should - you see the new portlet in the add menu of your page (don't be confused - I have deployed Social Office also and thus there is a Tasks portlet. But ours was called Task. Also, in a german installation like mine "collaboration" is called "Zusammenarbeit" ;-)
The output "This is the Task portlet in View mode" is generated from /docroot/html/task/view.jsp:


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

This is the <b>Task</b> portlet in View mode.
 
This JSP is in turn speified as an init-parameter to the portlet in /docroot/WEB-INF/portlet.xml. Liferays MVCPortlet the uses this init-parameter to render to view mode jsp.
 
So congrats! We just deployed a portlet successfully!