Thursday, September 9, 2010

Links to official standards

Adding links for most common standards which need to be referred while development
1. CLick on link below for email standards
Email Standards
Example : Sample 1

2. W3C's easy-to-use markup validation service, based on SGML and XML parsers.
http://validator.w3.org/

3. JSR-000286 Portlet Specification 2.0
Final release
JSR 168 final specifications

4. Scripting
ecma-international standards

5. Code Conventions for the Java Programming Language
Conventions

Tuesday, September 7, 2010

Quick Workaround & Temporary fixes

Theme > Change in portlet.vm for requirement to remove portlet title showing text "web content diplay"

Summary : #if( $portlet_title =='Web Content Display')
#else
$theme.iconPortlet() $portlet_title
#end

2>
Change is custom.css to acomdate tab space for 'BiggerNameTab' tab in navigation

Summary:
#navigation ul li.parent-nav-item {
text-align:center;
width:109px;

Wednesday, September 1, 2010

Enable user creation with duplicate email id

To enable user creation with duplicate email -id

If you don't have ant ext environment and still want to add this functionality leave me a note and I will send you steps for creating a separate jar and configurations to make your custom code work for your custom application.

For extension environment -- Write a new class in ext-environment

public class AbhishekUserLocalServiceImpl extends UserLocalServiceImpl
Now override two validate methods and make following changes

1. For method with signature
protected void validate(long userId, String screenName, String emailAddress, String firstName, String lastName, String smsSn)

remove ----> throw new DuplicateUserEmailAddressException();

from
if (userPersistence.fetchByC_EA(
user.getCompanyId(), emailAddress) != null) {

throw new DuplicateUserEmailAddressException();
}


2.
For method with signature

protected void validate(long companyId, long userId, boolean autoPassword, String password1,String password2, boolean autoScreenName, String screenName, String emailAddress, String firstName, String lastName, long[] organizationIds)

remove --->throw new DuplicateUserEmailAddressException();

from

if (Validator.isNotNull(emailAddress)) {
User user = userPersistence.fetchByC_EA(companyId, emailAddress);

if (user != null) {
throw new DuplicateUserEmailAddressException();
}
}

Monday, August 30, 2010

Change existing context 'ROOT' with your chosen context

I have come across many instance in which developers want to change the existing context 'ROOT'

Steps mentioned below is one easy way of doing it , however I have tried this on versions prior to 6.X . I will update post once I do it successfully on ver 6.X

1. Download tomcat bundle

Using the tomcat bundles saves you from making unwanted changes ,if you start fresh portal installation over tomcat and then try to change the 'ROOT' context , you will have to change many files .

2. Change the name of the existing context ROOT

liferay-portal-5.2.3\tomcat-5.5.27\webapps\ROOT
to
liferay-portal-5.2.3\tomcat-5.5.27\webapps\MyChosenContext

MyChosenContext is the context name you want to use

2b . Change the name of config file
\liferay-portal-5.2.3\tomcat-5.5.27\conf\Catalina\localhost\ROOT.xml
to
\liferay-portal-5.2.3\tomcat-5.5.27\conf\Catalina\localhost\MyChosenContext.xml

3. create a new file named portal-ext.properties which will override portal.properties

location -- liferay-portal-5.2.3\tomcat-5.5.27\webapps\ROOT\WEB-INF\classes\portal-ext.properties

3b. Change portal.ctx property or add in case of new installation
portal.ctx=/MyChosenContext

Snipet of property to be added to portal-ext.properties

## Portal Context
##
#
# Set this property if you deploy the portal to another path besides root.
#
portal.ctx=/

Monday, July 19, 2010

Quick Tips

Tips
For using Liferay services in Web Content portlet Previously known as journal content portlet , we use LR services in templates
e.g. #set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))

However at first attempt we encounter null which happens when we forget to update the property in portal-ext.properties.
Use of LR services are restricted by default in templates.
Following property has list of restricted variables
so change property from journal.template.velocity.restricted.variables=serviceLocator
journal.template.velocity.restricted.variables=
Once serviceLocator is available we can invoke the services to achieve desired results.
===================================================
Get httpRequest within the portlet
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(actionReq);

===================================================
CMS Template VM code for finding user and roles

This code has been used by developers time and again I have used some different methods than existing approach to make it simpler.

#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($roleLocalService = $serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))
#set ($user_id = $request.getAttribute("USER_ID"))
#set ($user = $userLocalService.getUserById($user_id))
#set ($role = $roleLocalService.getRole($user.getCompanyId(),"sponsor"))
#set ($hasUserRole = $roleLocalService.hasUserRole($user.getUserId(),$role.getRoleId()))

======================================================

Tuesday, June 22, 2010

Using newly launched Liferay IDE 1.0

IDE is awesome , it rocks .I was able to configure the IDE by following the instructions on IDE release wiki Installation Guide, its easy to configure and if you have the resource downloaded you will be able to start developing portlets in no time.
Follow the getting started tutorial Getting started
Watch demos if you need some help around creating portlets rely on demo videos Portlet development video demo

Feature like auto deployment ,hot sync are very helpful changes are reflected as soon as a change is made in the code , gone are the days when you needed to redeploy manually .GUI based wizard options are available for selecting portlet mode and Liferay portlet mode, choose category for portlets choose file location resource location etc. Truly wonderful.
I haven't encountered any bug yet , I will update the post once I use more features and encounter bugs.

Wednesday, June 16, 2010

Liferay IDE 1.0.0 Released

For all Liferay enthusiast First version of IDE has been release based on Eclipse Galileo SR2.
Click here to get IDE

I will use it today and post some of the capabilities and reviews

Monday, May 24, 2010

Liferay IDE 1.0

I have seen the video demos and the IDE rocks, it has all the features a developer would love to see in first version

The IDE has not been released yet. Once the next release candidate LR portal(6.0RC2) is released, then IDE will be rolled out as it will support version 6.0RC2 onwards

In my next post I will detail the features once IDE is available for general use.

I also plan for a post with detailed usage of OOB(out of the box) portlets and their configuration.

Tuesday, April 27, 2010

Liferay 5.2.3 and solr integration

I thought of writing this blog while I was trying to implement search indexing in clustered environment for liferay 5.2.3. I faced couple of problems and for resolution I had to read on way too many articles and blog to reach out to final implementation, so I though it would be nice to have everything in one place
Solr provides search indexing option for clustered Liferay environment.

version:
solr-web-5.2.0.1.war --solr plugin
Solr 1.4 --- Solr server

Follow the steps provided

1. Installing Solr

1. Solr is a standalone search engine thus it will be installed separately from liferay create a directory named solr which will be called as SOLR_HOME going forward.
2. Copy the content in solr folder from the downloaded solr installation bundle from http://lucene.apache.org/solr
3. Create an environment variable SOLR_HOME which points to the solr installation directory.
4. Once you have created the environment variable, you then can use it in your application server's start up configuration as a parameter to your JVM. This is configured differently per application server, but again, if you are using Tomcat, you would edit catalina.sh or catalina.bat and append the following to the $JAVA_OPTS variable:

-Dsolr.solr.home=$SOLR_HOME

5. Edit solrconfig.xml available at \solr\conf

${solr.data.dir:C:\TomcatA\webapps\example\solr\data}

change directory path for unix , I have given a windows path
This data folder will contain all the index files (try not to delete these index files manually if you don't get proper result after first run, reindex again)

Provide the path to a newly created directory which you want to hold the indexing data, after indexing files will be generated in this folder.


2. Deploy solr war
1. Copy solr.war to deploy folder of liferay from resource packet or download it directly from http://lucene.apache.org/solr


3. Installing the Solr Plug-in

Download plugin link

1. Update the solr-spring.xml file available at \WEB-INF\classes\META-INF

Change server URL e.g. http://{domain}:8181/solr/


2. Copy the update archive file in deploy folder of liferay

2b(IMP). Extract the file schema.xml from the plug-in. This xml file describes how the fields will be indexed to the Solr index and it should be located in the docroot/WEB-INF/conf folder. Copy this file to $SOLR_HOME/conf


3. Go to the Admin Portlet in Liferay 5.1 or Control panel in higher versions. Click the Server tab and then click the Execute button next to Reindex all search indexes. It may take a while, but Liferay will begin sending indexing requests to Solr for execution. When the process is complete, Solr will have a complete search index of your site, and will be running independently of all of your Liferay nodes.

References:

Solr > http://lucene.apache.org/solr

Liferay: Liferay.com

Tip: To check if Solr server is working perfectly hit the following URL after restart
To check if indexing is working fine check the data folder in Solr server new
index files must have formed there.

http://{domain}/{port}/solr/admin

Change Log: Changes have been made in LuceneUtil class for making it compatible to search users in control panel. If you have older version you need to delete a line and add a snippet and repackage you portalutil jar, check out the below mentioned link for changes.

For overcoming the issue in user search in control panel