Thursday, 10 October 2013

How to get Custom Field value in Liferay using liferay API?

This code is done for the Expando of User Model (UserExpando) and the custom filed "userCity"



//////////////////////////////

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
               
                long companyId = liferayFacesContext.getCompanyId();
               
                User user = liferayFacesContext.getUser();
                System.out.println("User info "+user.getUserId()+" --- "+user.getFirstName()+" ---- "+user.getEmailAddress());
                Locale locale = liferayFacesContext.getLocale();
                ExpandoValue val=null;
                ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getDefaultTable(companyId,User.class.getName());
                long expandoTableId=expandoTable.getTableId();
                ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(expandoTableId, UserExpando.USER_CITY.getName());
                 if (column != null) {
                 val = ExpandoValueLocalServiceUtil.getValue(expandoTableId, column.getColumnId(), user.getUserId());
                   if (val != null) {
                     System.out.println("val====================="+ val);
                   }
                  
                }

/////////////////////////////////

How to get logged In User detail in liferay?

How to get logged In User detail in liferay?

These lines of code will give you the user who is logged in from the LiferayFaces Context.

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
                
 long companyId = liferayFacesContext.getCompanyId();
                
 User user = liferayFacesContext.getUser();                       //User is an Model of liferay

Wednesday, 27 February 2013

How to change user authentication Type in Liferay ?

 How to change user Authentication/ login Type in Liferay? If i want to use screen name instead of emailAddress
There  are two ways to change login type in liferay
1)
company.security.auth.type=emailAddress
#company.security.auth.type=screenName
#company.security.auth.type=userId

In the above case , screenName and userId are commented out using #

2)
a)Login as Admin
b)go to Control panel
c)Click on the Portal setting in the left panel under portal tab
d)Click on the Authentication link in the right panel
e)Select the desired login type from the drop down(How do users authenticate? ) under the General tab.

LDAP connection Read timeout in Liferay

LDAP connection Read timeout in Liferay

Put this lines in portal-ext.properties file to avoid this problem

ldap.connection.com.sun.jndi.ldap.connect.timeout=1000
ldap.connection.com.sun.jndi.ldap.read.timeout=2000


Map Ldap Group with Liferay role

Map Ldap Group with Liferay role


Put the following line into portal-ext.properties file

ldap.import.create.role.per.group=true
layout.show.portlet.access.denied=false

Thursday, 31 January 2013

LDAP Configuration with Liferay   through Control Panel for secured connection


LDAP Configuration with Liferay   through Control Panel for secured connection

  • Import the certifcate of ldap server(for secured connection) into your local Jdk.
  • Login as an admin.Default user admin is test and password is test.
  • Hover on Go to then Control Pannel
  • In control panelm page Click Portal Setting of the left Panel
  • Click Authentication link of the  Right panel
  • Select Screen Name for How do users authenticate?  then save -Optional
  • Now click on the LDAP tab and check Enable
  • Then Click on Add button to Add and Cofigure LDAP server .
  •  e.g as an screen shot below

  • Then click save

Wednesday, 31 October 2012

Install liferay easy steps



Install liferay:

 Installation Software Requirements:
 
    1. liferay-portal-tomcat-6.0.6-20110225.zip
    2. liferay-plugins-sdk-6.1.0.zip
    3. eclipse_Liferay_IDE_v201103310222-linux-x86_64.tar.gz
    4. jdk 1.6

 
Follow the steps:
    1. Download Liferay-portal-6.0.6.zip(tomcat bundled) from Liferay's official site.
    2. create a folder as Liferay_home(can use any name) and unzip the liferay-portal within it.
    3. Then create a file as build.username.properties(own operating system username) in Liferay_home and specify the path of the application server.
       (e.g.- I used build.nitesh.properties and specify the server path as(app.server.dir=/home/nitesh/Desktop/LifeRay/liferay-portal-6.0.6/tomcat-6.0.29/))
    4. install jdk 1.6(We are using jdk1.6.0_24 in staging server)
    5. set JAVA_HOME,JRE_HOME.For setting JAVA_HOME and JRE_HOME,go to your superuser(i.e,root) and then follw as given
           below:
                  # cd /etc
                  # vi profile
                    then add export JAVA_HOME=absolute path of jdk 1.6 bin
                    (e.g:- export JAVA_HOME=/home/nitesh/Desktop/jdk1.6.0_24/bin)
            add JRE_HOME in same way.save and logout from the editor.