Liferay Portal 6.2 Extension Plugins

Community Blogs 24. Februar 2014 Von Jamie L Sammons

Overview

Liferay Ext Plugins are often considered a last resort in the Liferay Plugin world due to the complexity and the lack of hot deploy as well as the inability to remove them once they are deployed.  These difficulties come from the fact that they are as close as you can get to customizing the core Liferay code without actually doing it.  The difference being it keep's your customizations separate from the Liferay code which helps at upgrade time or when the customization can be removed which is often the case when modifying the upgrade process.

I would like to cover two scenarios where Ext plugins were very useful for me and provide examples that can be of use to other people.  The first is customizing the Liferay upgrade process and the other is customizing the LDAP import process.

Customizing the Liferay Upgrade Process

This section covers how to customize the Liferay Upgrade Process.  I ran into a problem during my upgrade process with the following error showing up 1000's of times.  Its trying to add new Social Activity for each of my Wiki Pages.  However it says that more than one Wiki page was updated at exactly the same time/day/second which according to the SocialActivity table (and reality) is not possible.  

UpgradeSocial:79] Unable to add activity 3072565     [java] com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: 
Duplicate entry '542302-16697-1276032958000-10129-561166-2-0' for key 'IX_8F32DEC9'

So how do we fix it?  By customizing the upgrade process!

  1. Create a new Liferay Extension plugin and copy com.custom.portal.upgrade.UpgradeProcess_6_2_0 and com.liferay.portal.upgrade.v6_2_0.UpgradeSocial to ext-impl in the new plugin.  Rename both classes so they start with Custom.
  2. Modify CustomUpgradeProcess_6_2_0 to include your new CustomUpgradeSocial.  Change upgrade(UpgradeSocial.class); to upgrade(CustomUpgradeSocial.class);
  3. Modify CustomUpgradeSocial to check for the existence of duplicate time stamps to avoid the problem from above.
  4. Modify the portal-ext.properties file to include the custom upgrade process as opposed to the default one:
    upgrade.processes.master=\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_0\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_1\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_2\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_3\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_5\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_0_6\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_1_0\,\
        com.liferay.portal.upgrade.UpgradeProcess_6_1_1\,\
        com.custom.portal.upgrade.CustomUpgradeProcess_6_2_0

During the upgrade process the log should display the custom upgrade process being ran: 

Upgrading com.custom.portal.upgrade.v6_2_0.CustomUpgradeSocial

The source for this project can be found here.

There is also example for customizing the verify process with a fix for LPS-42839 included.  

Make sure to add the following to the portal-ext.properties file:

verify.processes=com.custom.portal.verify.CustomVerifyProcessSuite

If all goes well the upgrade process should show:

Verifying com.custom.portal.verify.CustomVerifyDocumentLibrary

Customizing the LDAP Import Process

I wanted to customize the LDAP import process to import the Address and Phone number from LDAP.  I know that you can import them as custom attributes today but I wanted them to actually show up in the Phone and Address section in the user profile.  That way I could populate the Contacts Center in Social Office with data that was already in LDAP.

A while back Michael Han wrote a nice article explaining that the LDAP export/import process could be overridden using Spring.  I went ahead and implemented a custom LDAP import process using the ext-spring.xml file found in an extension plugin and was able to customize the LDAP import process.  

The source for the project can be found here

Make sure to add the following to the portal-ext.properties file to enable import for the custom attributes:

ldap.contact.mappings.0=phone=telephoneNumber\ncity=city\nzip=postalCode\nstreet1=street

 

Customizing Social Office 3.0 using plugins

Community Blogs 17. Februar 2014 Von Jamie L Sammons

 In the Liferay Developers Guide there is a nice little tidbit titled "Creating Plugins to Extend Plugins" found here. This basically allows a lot of the same principles used with hook plugins when customizing Liferay.  The difference here is that it allows you to customize portlet plugins with plugins.  As with hook plugins this allows a degree of separation between your customization's and the default application.

This same concept can also be used to customize Social Office plugins (including Social Office EE plugins).  The name of the new plugin must match the name of the original plugin since the so-hook expects the original name.

We had a need to hide the two public Site types in Social Office (Open and Public Restricted) since we share our Portal instance with our Clients.  

Do the following to customize the so-portlet:

  1. In Liferay IDE create a new Liferay Portlet Plugin project called: so-portlet
  2. Expand the new so-portlet project and delete everything below docroot
  3. Copy the original so-portlet WAR file into the root directory of the new so-portlet project in eclipse:

  4. Edit the build.xml ANT script and add the following property to the script:
        <property
            name="original.war.file"
            value="so-portlet-6.2.0.2-ce-ga1-20140210151141114.war"
        />
    
  5. Run the all Ant task.  A new tmp directory will show up at the root of the so-portlet project (may need to refresh).  At this point this is the contents of the original war file.  
  6. Copy tmp/WEB-INF/liferay-plugin-package.properties to docroot/WEB-INF in the so-portlet project (Create WEB-INF if it doesn't already exist).
  7. Modify liferay-plugin-package.properties and change module-incremental-version to 10.  This will cause your custom so-portlet to always take priority over the default so-portlet.
  8. Copy tmp/sites/edit_site.jsp to docroot/sites
  9. Modify docroot/sites/edit_site.jsp and remove the lines that define Public and Public Restricted Sites (Search for TYPE_SITE_OPEN and TYPE_SITE_PUBLIC_RESTRICTED).
  10. Run the all Ant task again and now tmp will be a combination of the default war file and your cusomizations.  This also generates a custom war file in the plugins SDK dist folder that can be deployed to a Liferay server

That's pretty much it.  This procedure can be used with pretty much any portlet project including EE versions.

Help CDS Global Win a Forrester Groundswell Award!

Community Blogs 4. September 2013 Von Jamie L Sammons

Forrester Groundswell Awards honors initiatives that represent excellent and effective use of social technologies to advance an organizational or corporate goal.

CDS Global choose Liferay Portal 6.1 EE GA2 for implmenting our new Share Chain. Liferay's Open Source roots such as the power to take control of the software and customize it to our needs allowed us to quickly and easily implement the new requirements.

The Share Chain uses Liferay's Message Board componement to allow employees to request collective support for spreading important news across an individuals' social networks.

Harnassing the power of a customized Asset Publisher along with Tags and Catergories we can easily aggregate many types of content into a centrailized Social Business Hub page in Liferay including the entries from the Share Chain Message Board.

A Forrester Groundswell award would be very benficial for both Liferay and CDS Global as a whole. Please take a moment and vote by clicking the link below and looking for "My rating: " below the screenshot in the right-hand column.

Our submission: CDS Global's Social Business Hub: Share Chain (http://groundswelldiscussion.com/groundswell/awards/detail.php?id=1007)

Social Business Showcase: http://cdsglobalgroundswell.tumblr.com/

Building the Social Office Trunk using the Liferay IDE

Community Blogs 4. Oktober 2010 Von Jamie L Sammons

With the release of the Liferay IDE 1.1 I got to thinking it would be really cool to try and build the Social Office Trunk using the Liferay IDE.  I thought I could get a way with using Liferay Portal nightly builds and then build Social Office on top of that.  As it turns out its still easier to check out the Portal trunk and build it manually and then add Social Office on top of that.

In the end I was able to convert all of the components that make up Social Office into Liferay IDE projects and deploy them to a Liferay 6.1 trunk build.

The procedure for building SO Trunk using the Liferay IDE can be found in the Wiki Article: Building the Social Office Trunk using the Liferay IDE

The article assumes that the following Wiki Article was used to setup the initial development environment: Liferay 6.0 Development on Ubuntu Maverick 10.10, but they can be adapted to the platform of your choice.

Zeige 4 Ergebnisse.