Keeping user password secure with LDAP integration

General Blogs November 24, 2010 By Jonas Yuan

Liferay 5.2 EE and 6 improved the capabilities of LDAP integration in many areas (refer to blogs post LDAP Enhancements by Michael C. Han):

  • synchronize user custom attributes between Liferay and LDAP
  • support LDAP chains and LDAP pagination
  • create a role for each LDAP group
  • override LDAP import and export processes via Spring

When importing users from LDAP, user’s info and password got imported. Of course, all passwords stored in Liferay are secure. Especially, the LDAP password mapping field is optional. In some use cases, the fact Liferay stores users’ password is against some companies’ security policy rules.

Liferay should not import user's password from LDAP when required (LPS-13933). That is, an improvement would be nice to allow the portal admin to choose whether to save the user's LDAP password when they login or not. How to implement this? This article will address how to make this feature happening in Liferay 5.2 and 6.

Solution overview

The following diagram shows solution overview.  LDAP contains a lot of users’ info (plus user’s password) and groups’ info. Liferay portal provides users (and contacts), user groups and roles in place with following mappings

LDAP user info <==> Liferay user info (and contact, password is not included)

LDAP groups (and users membership) <==> Liferay user groups and roles (and users membership)

In addition, the portal will use user’s password to authenticate only. When users login, the portal will import (add or update) user’s info, and then, the portal will add default passwords (such as user screen name, user id, email address, or plain text) as temporal and secure passwords.

When LDAP was enabled, the portal will use LDAP user and its password to authenticate. Once LDAP was disabled (or disconnected), the portal will activate “forgot password” process to reset user’s password and send new auto-generated password by email; or the portal will activate “required reset password” password policy to update user’s password after first-time login.

Implementation

This feature could be implemented in two steps.

1) Adding following properties in portal.properties - especially in LDAP section.

# Set this to true if the portal does import LDAP user's password.
# Set this to false if the portal does not import LDAP user's password;

ldap.import.user.password.enabled=false

# Set this to false if LDAP user's password is not auto-generated;
# This property is in use only if the property ldap.import.user.password.enabled is set to false.

ldap.import.user.password.autogenerated=false

# use default password as LDAP user's password: $SCREENNAME$, $USERID$, $EMAILADDRESS$, or plain text.
# This property is in use only if the property ldap.import.user.password.enabled is set to false
# and the property ldap.import.user.password.auto-generated is set to false, too.

ldap.import.user.password.default=test

2) updating methods addUser and updateUser with above settings in Portal LDAP importer.

Results

This feature was tested in 5.2 EE and 6.0 CE / EE. Three testing use cases were included as follows.

Use case A

Set following property to true, LDAP integration was resumed to default behavior; that is, all users’ passwords got imported and stored in secure in Liferay database. This is Liferay default behavior  - nice way to revert back easily.

ldap.import.user.password.enabled=true

Use case B

Set following properties, LDAP integration will not import users' password; instead, random password will be auto-generated for users.

ldap.import.user.password.enabled=false
ldap.import.user.password.autogenerated=true

Use case C

Set following properties, LDAP integration will not import users' password; instead, pre-defined password will be assigned to users.

ldap.import.user.password.enabled=false
ldap.import.user.password.autogenerated=false
ldap.import.user.password.default=test

This feature will be available at 6.1 and 6.0 EE SP1. This is good news.

Is this feature useful? Your comments or suggestions?

Organization hierarchy, virtual host and friendly URL

General Blogs November 18, 2010 By Jonas Yuan

Liferay portal provides a lot of cool features, for example, Organization hierarchy, virtual host and SEO (Search engine optimization) friendly URL. Web sites can be built based on organizations and organization hierarchy. Each organization can have public pages and private pages.  Each organization can have friendly URL, like /my-org, where only one slash is allowed, while each page can have friendly URL, like /home, /flickr/home, where multiple slashes got supported. In addition, organization public pages can have public virtual host; organization private pages can have private virtual host. (Abstracted from the book: Liferay Portal 6 Enterprise Intranets).

Indeed, these are powerful features to build and manage website. In some use cases, these would not be sufficient. For example, here is a custom model: each brand can have many destinations, while each destination can have many hotels. Each Brand, destination or hotel will have its own public pages and private pages.

 

As shown in the preceding diagram, each brand will have public virtual host – domain name and SEO friendly URL:

Use case A) http://www.${brand.name}.com[/${locale}]

where ${brand.name} should be brand (presented as a root organization) friendly URL. While destination and hotel do not need virtual host, but they need SEO friendly URL like 

Use case B) http://www.${brand.name}.com[/${locale}]/${destination.name} for destination

Use case C) http://www.${brand.name}.com[/${locale}]/${destination.name}/${hotel.name} for hotel

Where ${destination.name} should be destination (presented as a 1st level organization) SEO friendly URL; ${hotel.name} should be hotel (presented as a 2nd level organization) SEO friendly URL.

How to implement these use cases A), B) and C)? This article will show what organization hierarchy, virtual host and SEO friendly URL are and how to extend these features.

Organization hierarchy

Regular organization can be a root, having no parent organization, like Fiesta Americana; or regular organization can have a parent organization, like Cancun, Mexico City, and many child organizations or locations, like Fiesta-Americana Villas Cancun, Fiesta Americana Reforma, and Fiesta Americana Santa Fe. Location must have a regular organization as parent, and have no child organizations. Therefore, organizations and locations form a hierarchical structure: regular organizations form root and trunk; while locations form leaves, as shown in following screenshot.  

 Virtual host

Suppose that you have virtual domain (or real domain): demo.fiestamericana.com.
You can set public virtual host for the organization Fiesta Americana to demo.fiestamericana.com as follows.

Then you can view any pages of the organization Fiesta Americana.
http://demo.fiestamericana.com/${layout.friendly.url}

You can also view any pages in different languages.
http://demo.fiestamericana.com[/${locale}]/${layout.friendly.url}

As you can see, use case A) can be implemented by group public or private virtual host settings.

Friendly URL

Both Group and Layout can have friend URL.

As Brian Chan mentioned earlier, Group friendly URL should have one and only slash. As shown in the preceding screenshot, the organization Fiesta Americana has friendly URL "/fiesta-ammericana" - there is one and only slash.

Layout can have friendly URL with multiple slashes. As shown in following screenshot, layout "Test" has friendly URL "/home/test". 

Customizing virtual host and friendly URL

As you can see, using liferay default features, use cases B) and C) can not be satisfied with.

Thus Here I suggest a new feature: customizing group friendly URL and virtual host.

How?

1) first provide properties - adding following properties in portal-ext.properties.

##
## custom organization friendly URLs
##
## enabling custom organization friendly URLs,
## set custom.organization.friendly.url.enabled to true;
## otherwise set it to false

custom.organization.friendly.url.enabled=true

2) Then customize group friendly URL and virtual host in Virtual Host Filter

3) Definitely keep Liferay portal default features (group friendly URL and virtual host) 100% AS IS; and add customized group friendly URL and virtual host on top of default features.

Results

After applying the new feature, both use case B) and use case C) got supported.

Use case B)

http://demo.fiestamericana.com/cancun for default language, that is, US English;

http://demo.fiestamericana.com/de/cancun for German.

Of course, Liferay default features are working well AS IS. Suppose that layout.friendly.url.public.servlet.mapping is set by default as /web.

http://demo.fiestamericana.com/web/cancun for default language, that is, US English;

http://demo.fiestamericana.com/de/web/cancun for German.

Use case C)

http://demo.fiestamericana.com/es/cancun/fiesta-americana-villas-cancun for Spanish.

http://demo.fiestamericana.com/de/cancun/fiesta-americana-villas-cancun for German.

 http://demo.fiestamericana.com/cancun/fiesta-americana-villas-cancun for default locale, that is, US English

Sure, Liferay default features are working well 100% AS IS.

http://demo.fiestamericana.com/es/web/fiesta-americana-villas-cancun for Spanish.

http://demo.fiestamericana.com/de/web/fiesta-americana-villas-cancun for German.

http://demo.fiestamericana.com/web/fiesta-americana-villas-cancun for default locale, that is, US English

By the way, to disable this customized feature, you can simply set the property custom.organization.friendly.url.enabled to false. Then what you have are Liferay default features - 100%, of course.

In addition, you can apply same friendly URLs in Language portlet. Thus when clicking on the icons in Language portlet, you would be able to get same friendly URLs.

Is this feature useful? Your suggestions?

What's next?

As you can see, there are a few limitations:

1) Root Organization has been set up virtual host, either public virtual host or private virtual host, or both. What's happening if virtual host was not set properly?

2) Currently destination and hotel friendly URL have been mapped to 1st level organization and 2nd level organization, respectively.

3) All brands have been managed as root organizations in a portal instance. What's happening if one brand has been managed as root organization in one portal instance while another brand has been managed as root organization in another portal instance?

Liferay book: Liferay User Interface Development

General Blogs October 29, 2010 By Jonas Yuan

Liferay User Interface Development

Develop a powerful and rich user interface with Liferay Portal 6

Sample chapter, Table of contents, Download code

An Overview:

  • Design usable and great-looking user interfaces for Liferay portals
  • Get familiar with major theme development tools to help you create a striking new look for your Liferay portal
  • Learn the techniques and tools to help you improve the look and feel of any Liferay portal
  • A practical guide with lots of sample code included from real Liferay Portal Projects free for use for developing your own projects

Details

Liferay employs a specialized theming system, which allows you to change the look and feel of the user interfaces. As a developer, by using the right tools to create and manipulate themes with Liferay Portal, you can get your site to look any way you want it to; but the Liferay theming system can be difficult to get started with. This practical guide provides you with a well organized manual for working with Liferay as a programmer to help you get started.

Liferay User Interface Development is a pioneer in explaining Liferay's powerful theming system by taking you through examples to get you to create your own themes as quickly as possible. It focuses on how portal pages are created and styled and also discusses some simple configuration and customization to change the look and feel of a portal page. Its explicit instructions are accompanied by plenty of source code. With the open source nature of Liferay, you will find a user-friendly environment to design themes with the latest user interface technologies.

Liferay User Interface Development unlocks the potential of using Liferay as a framework to develop a rich user interface.

The book starts off with how you should go about structuring a Liferay Portal web page. It identifies the components of a portal page: theme, layout, and portlets. This hands-on tutorial explains themes, portlets, and Alloy UI, which is the latest output from the Alloy Project of Liferay, in an easy-to-understand way. It covers all aspects of a theme from its inception and rendering through its consumption by an end user, with in-depth discussion.

By the end of this book, you will clearly understand themes, layouts, and the Alloy API. Most importantly you will obtain the skills to write a theme and layout templates, apply them to a portal, and also control the portlet UI through different mechanisms.

This clear, concise, and practical tutorial will ensure that you have developed skills to become a competent Liferay themer. The detailed text is accompanied with source code that allows you to play with the examples, update the code, and add custom features.

A practical guide to customizing the look and feel of Liferay-based portal applications

What you will learn from this book :

  • Learn Liferay themes inside out in a procedural way with real project example code
  • Develop variations of a theme through its color schemes by getting familiar with major theme development tools
  • Customize the Dockbar using Velocity templates, CSS, and the Alloy API
  • Upgrade a theme from an older Liferay version to Liferay Portal 6 and change the default theme in Liferay
  • Use AJAX to change page content and generate PDF and Excel reports
  • Take advantage of Liferay portlet UI tags to save development time
  • Use Velocity templates to control different parts of a Liferay Portal web page
  • Get introduced to the latest Liferay user interface – Alloy UI
  • Get acquainted with Liferay Alloy form tags and become a fan of the Alloy API
  • Use UI tag libraries in your pages or portlets including CKEditor, reCAPTCHA, and more
  • Design themes in WAP and production including jQuery, Workflow, Custom Attributes, Social Activities and Social Equity, WAP theme, Friendly URLs, data migration and portal upgrade, deployment, and performance tuning, etc.

Approach

This is a basic tutorial that teaches you how to use the tools provided by Liferay to create your own applications. It covers a lot of the material that has API references and documentation of the architecture and illustrates its key concepts with examples.

Who this book is written for

If you have basic knowledge of Java Web applications, know the basic operational functionality of Liferay, and have written a servlet or JSP file, you are ready to get the most out of this book. Whether you are a web portal engineer or an experienced Liferay Portal developer, you can benefit from this book. You are not expected to have prior knowledge of Liferay theming.

Acknowledgements

I would like to thank all team members at Liferay, specially Raymond Auge, Brian Chan, Bryan Cheung, Jorge Ferrer, Michael Young, Jerry Niu, Ed Shin, Craig Kaneko, Brian Kim, Bruno Farache,Thiago Moreira, Amos Fong, Scott Lee, David Truong, Alexander Chow, Mika Koivisto, Julio Camarero, Douglas Wong, Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Michael Han, Samuel Kong, Nate Cavanaugh, Arcko Duan, Richard Sezov, Joshua Asbury, Shuyang Zhou, and Juan Fernández for providing all the support and valuable information. Much thanks to all the friends in the Liferay community.

 

Applying jQuery and its custom UI in Liferay 6 plugins

General Blogs October 15, 2010 By Jonas Yuan

As you have been noticed, jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

Starting from Liferay 6, the portal uses Alloy UI (which is built on top of YUI3) instead of jQuery. That is, jQuery is no longer included by default. Therefore, you can use any version of jQuery as you need for your custom plugins. Refer to blogs posts Building jQuery based plugins in Liferay 6, Using jQuery (or any Javascript library) in Liferay 6.0, etc.

This article will address what jQuery UI looks like in Liferay 6 plugins and how to apply it in portlets. Here I use jQuery 1.4.3 and custom UI 1.8.5 as an example. Liferay portal version is CE 6.0.5 GA 3.

Introduction

jQuery UI provides abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets, built on top of the jQuery JavaScript Library, that you can use to build highly interactive web applications.

The following are sample screenshots.

Slider

DatePicker - Display multiple months

Accordion

 Tabs and Progress Bar

 Auto Complete

 Resizable and Draggable

Animate

Building jQuery custom UI plugin

Abstracted from the book: Liferay User Interface Developement (coming out soon).

1) Create a plugin in plugins SDK.

  • Build a project called “sample-jquery-portlet” with folder docroot and build.xml
  • Add CSS jQuery custom UI in the folder /docroot/css
  • Add images in the folder /docroot/images
  • Add JavaScript jQuery and its custom UI in the folder /docroot/js
  • Add liferay-display.xml, liferay-plugin-package.properties, liferay-portlet.xml, portlet.xml in the folder /docroot/WEB-INF

2) Especially, add following lines, for example, in the file liferay-portlet.xml.
<portlet>
    <portlet-name>1</portlet-name>
    <icon>/images/world.png</icon>
   
<header-portlet-css>/css/ui-lightness/jquery-ui-1.8.5.custom.css</header-portlet-css>
   <header-portlet-javascript>/js/jquery-1.4.3.min.js</header-portlet-javascript>
   <footer-portlet-javascript>/js/jquery-ui-1.8.5.custom.min.js</footer-portlet-javascript>

    <css-class-wrapper>sample-jquery-portlet</css-class-wrapper>
</portlet>

Note that the property header-portal-javascript sets the path of JavaScript that will be referenced in the page's header relative to the portal's context path; and the property footer-portal-javascript sets the path of JavaScript that will be referenced in the page's footer relative to the portal's context path.

Similarly, the property header-portlet-css sets the path of CSS that will be referenced in the page's header relative to the portlet's context path; while the property footer-portlet-css sets the path of CSS that will be referenced in the page's footer relative to the portlet's context path.

Note that these properties have been specified as * in liferay-portlet-app_6_0_0.dtd or liferay-portlet-app_6_1_0.dtd.

header-portlet-css*,
header-portlet-javascript*,
footer-portlet-css*,
footer-portlet-javascript*,

It means that you can include multiple CSS files and/or JavaScript files.

3) Add JSP files under the folder /docroot/jsp

Do-It-Yourself information

You can simply download WAR of Sample jQuery plugin.

sample-jquery-portlet-6.0.6.1.war

And then deploy it. That's it.

Enjoy!

Integrating CAPTCHA or reCAPTCHA with custom assets through plugins

General Blogs October 1, 2010 By Jonas Yuan

Liferay 6 provides a new feature that you can easily implement a different CAPTCHA than the default CAPTCHA, like reCAPTCHA. A blogs post mentioned: Easily Improve Your CAPTCHA. By the way, for 5.2.x one blogs post mentioned: Implement CAPTCHA in Liferay Portlet. Both blogs posts are nice articles. Much thanks to Alex, Jack, entire Liferay development team and contributors in Liferay community.

This article will address how to integrate CAPTCHA or reCAPTCHA with custom assets through plugins in Liferay portal 6 or above versions.  I will use custom asset Knowledge Base Article as an example. Knowledge Base Article would be useful for Q and A management, Hotel management, Restaurant management, etc.

Introduction

As mentioned in previous blogs posts, Knowledge Base article can have a parent article and / or many child articles. When creating a new article, we need ensure that the response is not generated by a computer. In this case, CAPTCHA would be helpful. Furthermore, reCAPTCHA supplies subscribing websites with images of words that optical character recognition (OCR) software has been unable to read. This would be also helpful when users prefer hearing words in images, rather than reading.

For example, when creating a new Knowledge Base Article, CAPTCHA is required by default.

 Of course, you can quickly enable ReCaptcha via Control Panel | Server Administration | Captcha.

Now when creating a new Knowledge Base Article, reCAPTCHA is required.

How to make it?

Abstracted from the book: Liferay User Interface Development.

In brief, it will just take three steps to integrate CAPTCHA or reCAPTCHA with custom assets through plugins.

  • First, Add following lines inside the method serveResource of com.liferay.knowledgebase.admin.portlet.AdminPortlet.

try {
 CaptchaUtil.serveImage(resourceRequest, resourceResponse);
} catch (Exception e) {
 e.printStackTrace();
}

Above code will generate CAPTCHA or reCAPTCHA and returned its content.

  • Then add following line inside the method updateArticle  of com.liferay.knowledgebase.admin.portlet.AdminPortlet before creating Knowledge Base article.

CaptchaUtil.check(actionRequest);

  • Last, add UI tag Liferay-ui:captcha into jsp, that is, /admin/edit_article.jsp after the line <aui:input name="title" />

<c:if test="<%= article == null %>">
 <portlet:resourceURL var="captchaURL"/>
 <liferay-ui:captcha url="<%= captchaURL %>" />
</c:if>

That’s it. You did integrate CAPTCHA or reCAPTCHA with custom asset, for example, Knowledge Base Article, through plugins.

Where do you find sample WAR?

You can download sample code from

knowledge-base-portlet-6.0.6.1.war

and deploy it.

Note that the WAR was generated based on the portal 6.0.10 (revision 63459).

Summary
As you can see, you would be able to add Integrating CAPTCHA or reCAPTCHA with any custom assets generated by Service-Builder in plugins. The asset Knowledge Base Article is one of them (custom assets).

Adding Social Equity services on custom assets through plugins

General Blogs September 27, 2010 By Jonas Yuan

Social Equity is a cool new feature in Liferay 6 or above version. Refer to Zsolt's blogs post Social Equity in Liferay.

Social Equity can be used to measure the contribution and participation of a user and the information value of an asset. The activities that award equities include, but not limited: adding contributions, rating, commenting, viewing content, searching and tagging.

Currently there are three portlets (Wiki, Blogs and Message Boards) that use the social equity service. The activities and their default values are configured in the /resource-actions/wiki.xml, blogs.xml, messageboards.xml.

Logically the Social Equity framework is assets agnostic. It operates on assets directly and uses action keys defined in resource-actions xml. Thus service calls need to be added to the respective services like Journal, Knowledge Base, etc.

As shown in following screenshot, Currently there are three portlets (Wiki, Blogs and Message Boards) that use the social equity service. The activities and their default values are configured in the /resource-actions/wiki.xml, blogs.xml, messageboards.xml.

For Wiki, configured activities are ADD_PAGE, VIEW, and ADD_DISCUSSION; for Blogs configured activities are ADD_ENTRY, VIEW, and ADD_DISCUSSION; and for Message Boards, configured activities are ADD_MESSAGE, ADD_VOTE, REPLY_MESSAGE, and VIEW. How do you add social equity services on custom assets like Knowledge base articles in plugins?

How to make it?

Abstracted from the book: Liferay User Interface Developement.

Supposed that configured activity is VIEW in Knowledge Base plugin, how do you make it? Loosely speaking, adding social equity capabilities in plugins should be simple in following steps.

First, you can configure the activities and their default values in the resource actions xml, that is, $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/src/resource-actions/default.xml. You can simply add following lines before the line </model-resource> of the model com.liferay.knowledgebase.model.Article.

<social-equity>
 <social-equity-mapping>
    <action-key>VIEW</action-key>
    <information-value>1</information-value>
    <information-lifespan>365</information-lifespan>
    <participation-value>1</participation-value>
    <participation-lifespan>365</participation-lifespan>
 </social-equity-mapping>
</social-equity>

Then you should add social equity as references in $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/service.xml as follows.

<reference package-path="com.liferay.portlet.social" entity="SocialEquityLog" />

It is time for you to re-build services by using ANT target build-service. That’s it. From now on, you would be able to see that Knowledge base Article is available under Control Panel | Social Equity | Settings, as shown in above screenshot.

What’s happening?

In fact, the portal has specified following social equity related properties by default in portal.properties. Of course, you would be able to override these properties in portal-ext.properties.

social.equity.equity.log.check.interval=1440   
social.equity.equity.log.enabled=true

As shown in above code, social equity feature is enabled by default and can be turned off by setting the social.equity.equity.log.enabled property to false. The property social.equity.equity.log.check.interval sets the interval like 1140 minutes on which the CheckEquityLogMessageListener will run. The value is set in one minute increments.

Where do you find sample code?

You can download sample code from 

knowledge-base-portlet-6.0.6.1.war

and deploy it.

Note that the WAR was generated based on the portal 6.0.10 (revision 63177 ).

Summary

As you can see, you would be able to add Social Equity services on any custom assets generated by Service-Builder in plugins. The asset Knowledge Base articles is one of them (custom assets).Try it now, you would be able to make Knowledge Base and / or your own portlet as one of Social Equity contributing portlets.

Last but not least, I'd like to send a ton of thanks to Zsolt Berentey, Brian Chan, Samuel Kong, and John Wayne Jiang,  who did a great job to make Social Equity a reality in Liferay portal 6.

Adding Custom Attributes capabilities on custom assets in Liferay 6 through plugins

General Blogs September 15, 2010 By Jonas Yuan

The portal provides a framework to add custom attributes or called custom fields to any Service-Builder generated entities at runtime where indexed values, text boxes, and selection lists for input and dynamic UI are available. For example, you could add custom fields on any entities like Wiki page, Message Boards category, Message Boards message, Calendar event, page, organization, user, Web Content, Document Library document, Document Library folder, Bookmarks entry, Bookmarks folder, Image Gallery image, Image Gallery folder, Blogs entry, etc. Of course, you would be able to add custom fields on custom entities in plugins. (Abstracted from the book: Liferay Portal 6 Enterprise Intranets).

We have discussed how to apply custom attributes in portal core assets, as mentioned in the book Liferay Portal 6 Enterprise Intranets. But how to apply custom attributes on custom assets? And how to build a plugin with custom attributes capabilities on custom assets? This post will address how to apply custom attributes on custom assets, for example, Knowledge Base articles, and how to make custom attributes available in Liferay 6 through plugins.

Note that Knowledge Base articles are used as an example, one of custom assets. Actually you can use same approach for any custom assets as you expected through Plugins.

Managing Custom Fields on Custom Assets

For example, you’re going to add attribute Type on the custom entity Knowledge Base Article. The portal provides a Custom Fields framework, thus you could be able add attributes on custom entities, without writing any code. As shown in following screenshot, custom attributes are available to be added on the custom asset Knowledge Base Articles.

 It is nice feature that you would be able to add custom fields on any resources. Considering above requirement, you’re going to add attribute Type on the custom entity Knowledge Base Article, without writing any Java code. As shown in following screenshot, you could do it in Control Panel with the portlet Expando.

In order to add custom attribute Type, you would be able to use Custom Fields against Knowledge Base Article. You could simply click on Knowledge Base Article in the category Portal of Control Panel first; then click on icon Custom Fields next to the icon Add.

Once a few custom fields were added on a resource, you would be able to add values for custom fields when you edit that resource. For example, you have added custom field Type on the resource Knowledge Base Article. When you edit an instance of that resource, says “Lotti Stein”, you would be able to add values for custom field Type.

Of course, you would be able to display Knowledge Base Article with custom attributes and their values as shown in following screenshot

How to make it?

Abstracted from the book: Liferay User Interface Developement.

How to make it? In this section, we’re going to introduce how to add custom attributes on custom entities in plugins. The entities Knowledge Base Articles will be used as an example. In brief, it should be simple to make it with following steps.

Adding Custom Attributes as references

First, you have to add custom attributes as references in $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/service.xml as follows.

<reference package-path="com.liferay.portlet.expando" entity="ExpandoValue" />

As shown in above code, the reference element allows you to inject services from another service.xml, that is, from portal core, within the same class loader. For example, if you inject the ExpandoValue entity, then you'll be able to reference the Custom Attributes services from your service implementation via the methods getExpandoValueLocalService and getExpandoValueService. You'll also be able to reference the Custom Attributes services via the variables ExpandoValueLocalService and ExpandoValueService.

Then, you need to run ANT target build-service to rebuild service based on newly added custom attributes reference.

Adding Custom Attributes Display

Liferay 6 provides pluggable custom attributes implementations, where developers can register their own custom attributes display implementation for any entity they build. It will appear automatically in the Custom Fields admin portlet so users can associate custom attributes entities with available permissions. To make it happening, we need to add Custom Attributes Display in $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/liferay-portlet.xml of plugin as follows.

<custom-attributes-display>com.liferay.knowledgebase.admin.ArticleCustomAttributesDisplay</custom-attributes-display>

As you can see, the tag custom-attributes-display value must be a class that implements com.liferay.portlet.expando.model.CustomAttributesDisplay and is called by Custom Fields administration UI.

Then you need to create the class com.liferay.knowledgebase.admin.ArticleCustomAttributesDisplay, which implements com.liferay.portlet.expando.model.CustomAttributesDisplay as follows.

public class ArticleCustomAttributesDisplay extends BaseCustomAttributesDisplay {
public static final String CLASS_NAME = Article.class.getName();
public String getClassName() { return CLASS_NAME; }
public String getIconPath(ThemeDisplay themeDisplay) {
 return themeDisplay.getPathThemeImages() + "/common/pages.png"; }
}

As you can see, ArticleCustomAttributesDisplay extends BaseCustomAttributesDisplay and overrode the methods getClassName and getIconPath. That’s simple. Isn’t it?

Adding Custom Attributes UI tags

Last but not least, you need to add custom attributes UI tags in order to take custom attributes as input or to display custom attributes with values for current custom entity, for example, Knowledge Base Article.

To do so, you should add custom attributes UI tags to create or update custom attributes values after creating or updating content at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/admin/edit_article.jsp as follows.

<liferay-ui:custom-attributes-available className="<%= Article.class.getName() %>">
 <liferay-ui:custom-attribute-list
  className="<%= Article.class.getName() %>"
  classPK="<%= (article != null) ? article.getArticleId() : 0 %>"
  editable="<%= true %>"
  label="<%= true %>"
 />
</liferay-ui:custom-attributes-available>

Logically you could re-arrange UI forms (title, content, description and custom attributes) as you expected. For example, you can add above code before or after the line <aui:input name="title" />.

For the same reason, you should add custom attributes UI tags to display custom attributes with their values after displaying content at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/admin/view_article.jsp as follows.

<liferay-ui:custom-attributes-available className="<%= Article.class.getName() %>">
 <liferay-ui:custom-attribute-list
  className="<%= Article.class.getName() %>"
  classPK="<%= (article != null) ? article.getArticleId() : 0 %>"
  editable="<%= false %>"
  label="<%= true %>"
 />
</liferay-ui:custom-attributes-available>

As you can see, the UI tag which is used to display custom attributes and their values is same as that of creating or updating custom attributes values.

Where would you find sample code - Knowledge base plugin with custom attributes capabilities?
You can simply download WAR of Knowledge Base plugin with custom attribute capabilities from

knowledge-base-portlet-6.0.6.1.war

And then deploy it. That’s it.

Note that above WAR was built by Liferay 6.0.6 (revision 62344) and JDK 6.0.12.

Summary

As you can see, you would be able to add custom attributes capabilities on any custom assets generated by Service-Builder in plugins. The asset Knowledge Base articles is one of them (custom assets).Try it now, you would be able to have custom attributes capabilities on your own custom assets. 

How to add workflow capabilities on Knowledge Base articles or any custom assets in plugins

General Blogs September 7, 2010 By Jonas Yuan

In previous blogs post, we had discussed applying workflow on Liferay portal core assets. It is true that Liferay 6 integrates workflow system like jBPM or Kaleo on any assets, either core assets or custom assets. Out-of-the-box liferay 6 supports workflow working on following core assets: Blogs Entry, Comments, Document Library Document, Message Boards Message, Web Content and Wiki Page.

Furthermore, we also discussed applying workflow on any custom assets like Knowledge Base articles in Liferay 6 through plugins. We did answer the question what it was in that blogs post, but the question how to make it programmatically was pending.

This article will introduce how to add workflow capabilities on any custom assets in plugins. Knowledge Base articles will be used as an example, one of custom assets. And moreover, we will use Liferay portal 6.0.5 GA 3 as testing environment. Of course, you could use Liferay portal 6.0.5 or latest version, for instance, Liferay 6 EE.

Abstracted from the book: Liferay User Interface Developement.

Prepare plugin

First of all, let’s prepare a plugin with workflow capabilities, called Knowledge Base. Note that the plugin Knowledge Base here is used as an example only. You can have your own plugin as well.

Structure
The plugin Knowledge Base has following folder structure under the folder $PLUGIN_SDK_HOME/knowledge-base-portlet.

  • admin: view JSP files for portlet Admin;
  • aggregator: view JSP files for portlet Aggregator;
  • display: view JSP files for portlet Display;
  • icons: icon images files,
  • js: JavaScript files,
  • META-INF:  context.xml;
  • search: view JSP files for portlet Search;
  • WEB-INF: web info specification; includes sub-folders classes, client, lib, service, sql, src, and tld.

As you can see, JSP files like init.jsp and css_init.jsp are resided in the folder $PLUGIN_SDK_HOME/knowledge-base-portlet

Services and Models

As you have been noticed, the plugin Knowledge Base has specified services and models with the package named com.liferay.knowledgebase. You would be able to find details at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/service.xml. Service-Builder in plugins SDK will automatically generate services and models against service.xml, plus XML files like portlet-hbm.xml, portlet-model-hints.xml, portlet-orm.xml,  portlet-spring.xml, base-spring.xml, cluster-spring.xml,dynamic-data-source-spring.xml, hibernate-spring.xml, infrastructure-spring.xml, messaging-spring.xml and shard-data-source-spring.xml under the folder $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/src/META-INF.

The service.xml specified knowledge base info as entries: Article and Template. The entry Article included columns: article Id as primary key, resource Prim Key, group Id, company Id, user Id, user Name, create Date, modified Date, parent resource Prim Key, version, title, content, description and priority; the entry Template included columns: template Id as primary key, group Id, company Id, user Id, user Name, create Date, modified Date, title, content and description.

By the way, the custom SQL scripts were provided at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/src/custom-sql/default.xml. In addition, resource actions – that is, permission actions specification - were provided at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/src/resource-actions/default.xml.

Of course, you can use Ant target build-wsdd to generate WSDD server configuration file $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/server-config.wsdd and to use Ant target build-client plus namespace-mapping.properties to generate web service client JAR file $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/client/known-base-portlet-client.jar. In brief, based on your own custom models and services specified in service.xml, you can easily build service, WSDD and web service client in plugins of Liferay 6 or above

Add Workflow Instance Link

 First, you have to add workflow instance link and its related columns and finder in service.xml as follows.

<column name="status" type="int" />
<column name="statusByUserId" type="long" />
<column name="statusByUserName" type="String" />
<column name="statusDate" type="Date" />
<!-- ignore details -->
<finder name="R_S" return-type="Collection">
  <finder-column name="resourcePrimKey" />
  <finder-column name="status" />
</finder>
<!-- ignore details -->
<reference package-path="com.liferay.portal" entity="WorkflowInstanceLink" />

As shown in above code, the column element represents a column in the database, here four columns like status, statusByUserId, statusByUserName and statusDate are required for Knowledge Base workflow; the finder element represents a generated finder method, here the method finder R_S is defined as Collection for return-type with two columns, e.g., resourcePrimkey and status; where the reference element allows you to inject services from another service.xml within the same class loader. For example, if you inject the Resource entity, then you'll be able to reference the Resource services from your service implementation via the methods getResourceLocalService and getResourceService.  You'll also be able to reference the Resource services via the variables resourceLocalService and resourceService.

Then, you need to run ANT target build-service to rebuild service based on newly added workflow instance link.

Add Workflow Handler

Liferay 6 provides pluggable workflow implementations, where developers can register their own workflow handler implementation for any entity they build. It will appear automatically in the workflow admin portlet so users can associate workflow entities with available permissions. To make it happening, we need to add Workflow Handler in $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/liferay-portlet.xml of plugin as follows.

<workflow-handler>com.liferay.knowledgebase.admin.workflow.ArticleWorkflowHandler</workflow-handler>

As shown in above code, the workflow-handler value must be a class that implements com.liferay.portal.kernel.workflow.BaseWorkflowHandler and is called when workflow is run.
Of course, you need to specify ArticleWorkflowHandler under the package com.liferay.knowledgebase.admin.workflow. The following is snippet.

public class ArticleWorkflowHandler extends BaseWorkflowHandler {
 public String getClassName(){/* ignore details */};
 public String getType(Locale locale) {/* ignore details */};
 public Article updateStatus( int status, Map<String, Serializable> workflowContext) throws PortalException, SystemException {/* ignore details */};
 protected String getIconPath(ThemeDisplay themeDisplay) {/* ignore details */};
}

As you can see, ArticleWorkflowHandler extends BaseWorkflowHandler and overrode the methods getClassName, getType, updateStatus and getIconPath. That’s it.

Add the method updateStatus

 As mentioned in previous section, you added method updateStatus in ArticleWorkflowHandler. Now you should provide implementation of the method updateStatus in com.liferay.knowledgebase.service.impl.ArticleLocalServiceImpl.java. The following is sample code. 

public Article updateStatus(long userId, long resourcePrimKey, int status, ServiceContext serviceContext) throws PortalException, SystemException {
/* ignore details */
// Article
Article article = getLatestArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
articlePersistence.update(article, false);
if (status != WorkflowConstants.STATUS_APPROVED) { return article; }
// Articles
// Asset
// Social
// Indexer
// Attachments
// Subscriptions
}

As shown in above code, it first gets latest article by resourcePrimKey and WorkflowConstants.STATUS_ANY. Then it updates the article based on workflow status. And moreover, it updates articles display order, asset tags and categories, social activities, indexer, attachments, subscriptions, etc.

After adding new method at com.liferay.knowledgebase.service.impl.ArticleLocalServiceImpl.java, you need to run ANT target build-service to rebuild services.

Add workflow-related AUI tags

Now it is time to add workflow related AUI tags at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/admin/edit_article.jsp. First of all, add AUI input workflow action with value WorkflowConstants.ACTION_SAVE_DRAFT.

<aui:input name="workflowAction" type="hidden" value="<%= WorkflowConstants.ACTION_SAVE_DRAFT %>" />

As shown in above code, the default value of AUI input workflowAction was set as SAVE DRAFT with type hidden. That is, this AUI input is invisible to end users.

Afterwards, it would be better to add workflow messages by UI tag liferay-ui:message, like a-new-version-will-be-created-automatically-if-this-content-is-modified for WorkflowConstants.STATUS_APPROVED, and there-is-a-publication-workflow-in-process for WorkflowConstants.STATUS_PENDING.

<c:choose>
<c:when test="<%= status == WorkflowConstants.STATUS_APPROVED %>"> <div class="portlet-msg-info">
<liferay-ui:message key="a-new-version-will-be-created-automatically-if-this-content-is-modified" />
</div> </c:when>
<c:when test="<%= status == WorkflowConstants.STATUS_PENDING %>">
<div class="portlet-msg-info">
<liferay-ui:message key="there-is-a-publication-workflow-in-process" />
</div></c:when>
</c:choose>
And then add AUI workflow status tag aui:workflow-status at $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/admin/edit_article.jsp.
<c:if test="<%= article != null %>">
 <aui:workflow-status id="<%= String.valueOf(resourcePrimKey) %>" status="<%= status %>" version="<%= GetterUtil.getDouble(String.valueOf(version)) %>" />
</c:if>

Finally you should add JavaScript to implement the function publishArticle() as follows.

function <portlet:namespace />publishArticle() {
 document.<portlet:namespace />fm.<portlet:namespace />workflowAction.value = "<%= WorkflowConstants.ACTION_PUBLISH %>";
 <portlet:namespace />updateArticle();
}

As you can see, the workflow action value is set as WorkflowConstants.ACTION_PUBLISH.

You did add workflow capabilities on Knowledge Base articles in plugins. From now on, you would be able to apply workflow on Knowledge Base articles through Control Panel, as shown in the blogs post applying-workflow-on-custom-assets-in-liferay-6-through-plugins.

Where would you find sample code - Knowledage base plugin with workflow capabilities?

You can simply download WAR (with source code) of Knowledge Base plugin with workflow capabilities from

knowledge-base-portlet-6.0.6.1.war

And then deploy it. You would be able to see portlets: Knowledge Base Admin (managing knowledge base articles and templates), Knowledge Base Aggregator (publishing knowledge base articles), Knowledge Base Display (displaying knowledge base articles) and Knowledge Base Search (ability to search knowledge base articles).

You may be interested in the latest version of Knowledge Base plugin with workflow capabilities. Thus you can find latest code at SVN like:

svn://svn.liferay.com/repos/public/plugins/trunk/portlets/knowledge-base-portlet

Summary

As you can see, you would be able to add workflow capabilities on any custom assets generated by Service-Builder in plugins. The asset Knowledge Base articles is one of them (custom assets).Try it now, you would be able to have workflow capabilities on your own custom assets.

Last but not least, I'd like to send thanks to Peter Shin and Brian Chan,  who did a great job to make Knowledge Base plugin a reality in Liferay portal 6.

Applying workflow on custom assets in Liferay 6 through plugins

General Blogs August 23, 2010 By Jonas Yuan

As you know, Liferay 6 integrates workflow system like jBPM or Kaleo on any assets finally. By this feature, users are able to manage the content creation process with a workflow. Out-of-the-box, liferay 6 provides the ability to enable workflow for core assets:

  • Blogs Entry
  • Comments
  • Document Library Document
  • Message Boards Message
  • Web Content
  • Wiki Page

Logically, worklow is available for any assets (Out of box entities).For more details, you can refer to blogs Liferay Workflow In Action and Applying workflow on any assets in Liferay 6.

Asset here refers to Liferay core content entities (generated by Service-Builder in portal core) and custom entities (generated by Service-Builder in plugins): like Document Library document, Image Gallery image, Message Boards message, Web Content, Wiki page, comments, Blogs entry. Logically, workflow should be available for any assets like Image Gallery image, Calendar event, layout page, Bookmarks entry, user, organization, etc. (Abstracted from the book: Liferay Portal 6 Enterprise Intranets)

Most importantly, you can apply workflow systems on custom assets in Liferay 6 through plugins. This article will show you how to apply workflow on custom assets (generated by Service-Builder) in Liferay 6 through plugins. Here I use custom assets knowledge base articles as examples in Liferay Portal 6.0.5 GA3.

How does it work?

You can simply download WAR from

knowledge-base-portlet-6.0.6.1.war

and deploy it

Configure workflow on any custom assets

Now you can configure workflow now. I use custom asset Knowledge base Article as an example.

Create two users: David Berger – a content creator; Lotti Stein – a content reviewer. And assign them as members of community Guest.

Login as admin and go to Control panel | Liferay.com| Workflow Configuration

Locate Knowledge Base Artcile and select “Single Approver” workflow and save it.

Go to Control panel | Portal| Communities and assign user roles of community guest; note that you can apply workflow on any assets of any groups (communities and organizations). Here I use the group Guest as an example.

Assign roles (community or organization content reviewer – Auto-generated role from workflow definition) to users (David Berger and Lotti Stein).

Go through workflow

Assign proper permissions to users David Berger and Lotti Stein that they can manage pages and create Knowledge Base articles in community Guest;

Login as David Berger and create Knowledge Base article called “Liferay Portal 6 Enterprise Intranets”; you would see that the asset Knowledge Base article goes workflow and it states as “Pending”;

 Login as Lotti Stein and go to Control Panel | Lotti Stein | My Workflow Tasks; you would see tabs: Assigned to Me, Assigned to My Roles, My Completed Tasks. Under the tab Assigned to My Roles, you would see the workflow task “Liferay Portal 6 Enterprise Intranets” with Asset Title “Liferay Portal 6 Enterprise Intranets” and Asset Type “Knowledge Base Article”.

Now you can review task or assign task to somebody. Click on the workflow task and assign this to yourself “Lotti Stein”; and add comment “Please review”; as you can see, the workflow task is moved to the tab “Assigned to Me”;

 Click on the workflow task under the tab “Assigned to Me”; and you can either reject it or approve it; you can click on “Approve Asset” and add comment “looks good” as well;

As you can see, the workflow task is move to the tab “My Completed Tasks”. In the detail view of the task, you can view and edit the content, read the recent activity of the task, view the status and change its status, add comments, etc.

After approved, Knowledge Base  article“Liferay Portal 6 Enterprise Intranets” would be visible for end users.

Summary

As you can see, you could be able to apply workflow on any custom assets generated by Service-Builder in Liferay 6. The asset Knowledge Base article is one of them (custom assets).

Your comments or suggestions?

How to make it?

You should be able to apply workflow on any custom assets in Liferay 6 or above version. How to make it through plugins? I will address programatic details in next blogs post. 

Building jQuery based plugins in Liferay 6

General Blogs July 7, 2010 By Jonas Yuan

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. Refer to http://jquery.com/

Liferay portal 6 uses Alloy UI instead of jQuery, which means YUI3 (http://developer.yahoo.com/yui/3/) is included as core part, and jQuery is not included as core part anymore.  Ideally you can use whatever version of jQuery you need for your custom developments, refering to the blog post Can I have different jQuery versions in Liferay? and ticket LPS-10872.

This article will introduce how to build jQuery based plugins in Liferay 6. Hope that this article would be helpful to upgrade custom portlets from 5.1.x or 5.2.x to 6.x.

Build jQuery based plugins
Here I use Liferay 6.0.3 GA (revision 57559) and plugins SDK.

  • Build a project called “sample-jquery-portlet” with folder “docroot” and build.xml
  • Add CSS under the folder /docroot/css
  • Add images under the folder /docroot/css
  • Add jquery under the folder /docroot/js
  • Add liferay-display.xml, liferay-plugin-package.properties, liferay-portlet.xml, portlet.xml under the folder /docroot/WEB-INF

Especially, add following lines, for example, in the file liferay-portlet.xml.
<portlet>
    <portlet-name>1</portlet-name>
    <icon>/images/world.png</icon>
    <header-portlet-css>/css/style.css</header-portlet-css>
    <header-portlet-javascript>/js/jquery.js</header-portlet-javascript>
    <footer-portlet-javascript>/js/jquery-ui-custom.js</footer-portlet-javascript>
    <css-class-wrapper>sample-jquery-portlet</css-class-wrapper>
</portlet>

Note that the property header-portal-javascript sets the path of JavaScript that will be referenced in the page's header relative to the portal's context path; and the property footer-portal-javascript sets the path of JavaScript that will be referenced in the page's footer relative to the portal's context path.

  • Add JSP files under the folder /docroot/jsp.

Note that you may include addition JavaScript at JSP file like

<script type='text/javascript' src='js/jquery_1.4.2.js'></script>

Sample Screenshots

Testing environment: Liferay portal 6.0.2.and 6.0 GA (6.0.3 - revision 57559)

A few jQuery examples:

Fade in

Animate

Fade out

Do it yourself
You can download the WAR with source code at:

sample-jquery-portlet-6.0.2.1.war

and drop it to $PORTAL_HOME/deploy or use UI "Plugins Installation" under Control Panel. For more details, you may refer to the book Liferay Portal 6 Enterprise Intranets.

If you want to use different jQuery version other than 1.4.2, you can go to the folder ${sample.jquery.portlet.war}/js and update jquery.js with expected version.

Migration

Supposed that you have custom portlets heavily using jQuery in 5.1 or 5.2, now you are planning to migrate to 6.x.  You can simply add different version of jQuery jquery.js in portlet specification liferay-portlet.xml as follows.

<header-portlet-css>/css/style.css</header-portlet-css>
<header-portlet-javascript>/js/jquery.js</header-portlet-javascript>
<footer-portlet-javascript>/js/jquery-ui-custom.js</footer-portlet-javascript>

That's it. It is simple, isn't it? your comments?

Applying workflow on any assets in Liferay 6

General Blogs June 11, 2010 By Jonas Yuan

Liferay 6 integrates workflow engines like jBPM or Kaleo on any assets finally. This feature has been expected for a while.  By this feature, users are able to manage the content creation process with a workflow. Especially, this feature helps content creators collaborate and go through the necessary steps in order to produce better and more accurate content like assets. Within a workflow, any type of assets like Document Library document, wiki entry or web content can go through review-approval processes.

In this article, I am going to show this feature with examples. Asset here refers to Liferay core content types: like Document Library document, Image Gallery image, Message Boards message, Web Content, Wiki page, comments, Blogs entry. Logically, workflow should be available for any assets like Image Gallery image, Calendar event, layout page, Bookmarks entry, user, organization, etc. (Abstracted from the book: Liferay Portal 6 Enterprise Intranets)


Install Workflow engine

First prepare Liferay portal. Here I use Liferay 6.0.3 GA (revision 55391). Liferay 6.0.2 RC 2 would be OK, too.  Install the portal and you would have a folder $PORTAL_HOME and deploy-folder $PORTAL_HOME/deploy.  Then start the portal. 

When the portal is running, deploy the workflow engine – that is, drop the WAR ${workflow-web-6.0.2.1}.war to the folder $PORTAL_HOME/deploy. You can use either jbpm-web or kaleo-web. Kaleo is Liferay custom Workflow plugin.  Here I use kaleo-web. 

You can download kaleo-web from 

kaleo-web-6.0.2.1.war.

Note that you can find example workflow single-approver-definition.xml at 

/kaleo-web/WEB-INF/classes/META-INF/definitions.

Of course, you can download example at 

/palm_tree/book/0387/chapter09/definitions.

Configure workflow on any assets

Now you can configure workflow now. I use asset Blog Entry as an example.

Create two users: David Berger – a content creator; Lotti Stein – a content reviewer. And assign them as members of community Guest.

Login as admin and go to Control panel | Liferay.com| Workflow Configuration

Locate Blogs Entry and select “Single Approver” workflow and save it.

Go to Control panel | Portal| Communities and assign user roles of community guest; note that you can apply  workflow on any assets of any groups (communities and organizations). Here I  use the group Guest as an example.

Assign roles (community or organization content reviewer – Auto-generated role from workflow definition) to users (David Berger and Lotti Stein).

 

Go through workflow

Assign proper permissions to users David Berger and Lotti Stein that they can manage pages and create blogs entries in community Guest;

Login as David Berger and create a blog called “Liferay Portal 6 Enterprise Intranets”; you would see that the asset Blog entry goes workflow and it states as “Pending Approval”;

 

Login as Lotti Stein and go to Control Panel | Lotti Stein | My Workflow Tasks; you would see tabs: Assigned to Me, Assigned to My Roles, My Completed Tasks. Under the tab Assigned to My Roles, you would see the workflow task “Liferay Portal 6 Enterprise Intranets”.

 
Click on the workflow task and assign this to yourself “Lotti Stein”; and add comment “Please review”; as you can see, the workflow task is moved to the tab “Assigned to Me”;
 

 

Click on the workflow task under the tab “Assigned to Me”; and you can either reject it or approve it; you can click on “Approve Asset” and add comment “looks good” as well; 

 

As you can see, the workflow task is move to the tab “My Completed Tasks”;

 

After approved, the blog entry “Liferay Portal 6 Enterprise Intranets” would be visible for end users.

Summary

As you can see, Liferay 6 integrates workflow engine either jBPM or Kaleo smoothly. Thus you can manage easily workflow definitions, instances and tasks in one place, that is, Control Panel. In brief, this integration has following beauties

  • ability to integrate many workflow engines like jBPM | Kaleo; 

  • ability to have configurable workflow definitions;

  • ability to apply workflow on any assets like Blogs Entry, Bookmarks Entry, Calendar Event, Document Library Document, Image Gallery Image, Web Content, Wiki Page, etc.

Last but not least, I'd like to send a ton of thanks to Brian Chan, Jorge Ferrer, Julio Camarero, Raymond Auge, Bruno Farache, Shuyang Zhou, Michael Han, Marcellus Tavares, etc. who did an amazing job to make Asset Workflow a reality. This is big and long-time expected feature.

What’s next?

What’s next? You should be able to apply workflow on any custom assets in Liferay 6 like Knowledge Base articles. Right? I will address details in next blogs post. 

 

Alfresco 3.3 delivers CMIS support, integration with Liferay 6

General Blogs June 2, 2010 By Jonas Yuan

Alfresco 3.3 with implementation of CMIS provides interoperability of its enterprise content management system with Liferay 6. In previous blogs Integrating Alfresco through CMIS in Liferay and the book: Liferay Portal 6 Enterprise Intranets, we have discussed how to integrate Alfresco 3.2 through CMIS 1.0 in Liferay 6. In this article, we are going to introduce how to integrate Alfresco 3.3 through CMIS 1.0 in Liferay 6. 

This article will use Alfresco 3.3 E and Liferay portal 6.0.2 to show how to integrate Alfresco through CMIS in Liferay.  Of course, you can do the same for Alfresco 3.3 or above community (or enterprise) version.

Integration

You should be able to integrate Alfresco through CMIS in following steps

  • Install Liferay portal 6.0.2 (revision 54489) or above at $LIFERAY_HOME; Liferay-Tomcat bundle is expressed as $TOMCAT_AS_DIR; and $PORTAL_ROOT_HOME = $TOMCAT_AS_DIR/webapps/ROOT;
  • Locate Alfresco 3.3 WAR ${alfresco.war} and Share WAR ${shared.war} at $ALFRESCO_INSTALLATION/ tomcat/webapps
  • Drop ${alfresco.war} and ${shared.war} to $TOMCAT_AS_DIR/webapps;
  • Create a database alfresco in MySQL.
    drop database if exists alfresco;
    create database alfresco character set utf8;
    grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option;
    grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;

  • Optionally, create database lportal in MySQL
    drop database if exists lportal;
    create database lportal character set utf8;
    grant all on lportal.* to 'lportal'@'localhost' identified by 'lportal' with grant option;
    grant all on lportal.* to 'lportal'@'localhost.localdomain' identified by 'lportal' with grant option;

  • Create a file named portal-ext.properties at $PORTAL_ROOT_HOME/WEB-INF/classes and add following lines in portal-ext.properties.
    dl.hook.impl=com.liferay.documentlibrary.util.CMISHook
    cmis.credentials.username=admin
    cmis.credentials.password=admin
    cmis.repository.url=http://localhost:8080/alfresco/service/api/cmis
    cmis.repository.version=1.0
    cmis.system.root.dir=Liferay Home

  • Optionally, add database connection in portal-ext.properties.
    ## MySQL
    jdbc.default.driverClassName=com.mysql.jdbc.Driver
    jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.default.username=lportal
    jdbc.default.password=lportal

Of course, you can use different database systems.

  • Start the portal

By the way, you can download Alfresco 3.3 E WAR and Share WAR directly from

/palm_tree/book/0387/chapter12/cmis/1.0/

Of course, you can get the latest WAR of Alfresco Community version or Enterprise (Trial) version from Alfresco website

http://www.alfresco.com/try/

Results

In Control panel of Liferay portal, select default community “liferay.com”; 

going to Content->Document Library, create a folder "Liferay Home" and upload a document under this folder as shown in following screenshot.

Logging in Alfresco as "admin/admin", you would see the folder "Liferay Home" and the document as shown in following screenshot. That is, Alfresco becomes direct repository of Liferay Document Library via CMIS. All real content is stored in Alfresco, while all metadata is stored in Liferay database.

In brief, Liferay supports CMIS 1.0 100%. Isn’t it? You can integrate other ECM or related systems easily via CMIS in Liferay portal, like Dennis Hamilton, EMC, FatWire, IBM, Microsoft, Open Text, Oracle and SAP, etc.

Liferay 6 and Semantic Web

General Blogs April 30, 2010 By Jonas Yuan

 The Semantic Web is an evolving development of the World Wide Web in which the meaning (that is, semantics) of information and services on the web is defined, making it possible for the web to understand and satisfy the requests of people and machines to use the web content.

Liferay goes Semantic Web! See ticket: Support RDF - Semantic Web.

The portal tagging system allows us to tag web content, documents, message board threads, and more and dynamically publish assets by tags. Tags provide a way of organizing and aggregating content. Basically, the tag administration determines which tags are available for use. The users use these tags on their content. Any content that is tagged can be grouped or aggregated.

The following figure depicts an overview of tags, categories, and assets:

Abstracted from the book: Liferay Portal 6 Enterprise Intranets

Folksonomies

Folksonomies are a user-driven approach to organizing content through tags, cooperative classification, and communication through shared metadata. The portal implements folksonomies through tags. A tag may be associated with many assets, whereas an asset may have many tags associated with it. This is what we called tagging content. Also, a tag may have many properties. Each property is made up of name-value pair.

A tag may be associated with content. Using tags, you can tag almost anything: Bookmarks' entries, Blogs' entries, Wiki articles, Document Library documents, Image Gallery images, Journal articles and Message Board threads, and so on. You can also use these tags to pull content within the Asset Publisher portlet.

Taxonomies

Taxonomies are a hierarchical structure used in scientific classification schemes. Although taxonomies are common, it can be difficult to implement them. The portal implements taxonomies as "vocabularies and category tree" in order to tag contents and classify them.

You can have more than one vocabulary, which forms a top-level item of the hierarchy. Each vocabulary may have many categories. That is, a category cannot be a top-level item of the hierarchy. However, a category can have other categories as its child or siblings. Therefore, vocabulary and categories form a hierarchical tree structure.

In the same way, a category may have many properties. Each property is made up of a name and a value.

In addition, a predefined category will be applied to any asset. In a word, assets could be managed and grouped by categories.

Category Tree

It is very useful that parent categories can have multiple child categories. This parent-child relationship forms a hierarchical structure. However, categories don't have siblings, for example, left-side category and right-side category. Parent-child relationship plus left-side category and right-side category form a tree called Category Tree. This feature will come out soon.

Why it doesn't merge both kinds of tags using ontology

As you can see, there are two kinds of tags: taxonomies and folksonomies. Both of them can be used as a way of organizing and aggregating content. Folksonomy is a way of classification, creating, and managing tags to annotate and categorize content, whereas taxonomy is a hierarchical structure only for classification.

In fact, taxonomies and folksonomies are different. Taxonomies are a closed set of categories (also called tags) and the vocabulary, created and organized in a hierarchical structure. It helps standardization, especially when you store it in the Shared Global group to standardize categorization through all of the organizations. In a word, folksonomies are an open set of tags, which are extended by the end user.

Why can't we merge both of them through ontology? Ontology—the study of entities and their relations—is less concerned with what "is" than with what is possible. The answer would be "yes".

What's next?

  • Ontology support.

Merge tags and categories through ontology.

  • RDF - Sematic Web (Web 3.0) - support

RDF is a standard model for data interchange on the Web. RDF has features that facilitate data merging even if the underlying schemas differ, and it specifically supports the evolution of schemas over time without requiring all the data consumers to be changed.

RDF extends the linking structure of the Web to use URIs to name the relationship between things as well as the two ends of the link (this is usually referred to as a "triple"). Using this simple model, it allows structured and semi-structured data to be mixed, exposed, and shared across different applications.

This linking structure forms a directed, labeled graph, where the edges represent the named link between two resources, represented by the graph nodes. This graph view is the easiest possible mental model for RDF and is often used in easy-to-understand visual explanations.

See details of RDF at http://www.w3.org/RDF/

 

Your suggestions or comments or vision?

Liferay is shining in publishing

General Blogs April 20, 2010 By Jonas Yuan

Liferay Portal is an enterprise web platform for building business solutions that deliver immediate results and long-term value; and Liferay Social Office is a social collaboration solution for the enterprise.

As you can see, Liferay is becoming increasingly popular, developing features to compare with commercial rivals, and finding increased usage in professional channels.

Liferay is shining in publishing. A ton of thanks to all Liferay fanatics and evangelists!  

Here I am happy to post this special invitation from Packt Publishing, which is calling all Liferay Fanatics to write for Packt!

Packt aims to publish books that will make Liferay applications accessible. The topics would cover following, but not limited.

  • Security
  • System Administration
  • Multimedia
  • Ecommerce
  • Project Implementation
  • Cookbooks for developers

For more details, you can refer to Calling all Liferay Fanatics to write for Packt!

Liferay book: Liferay Portal 6 Enterprise Intranets

General Blogs April 19, 2010 By Jonas Yuan

An overview of Liferay Portal 6 Enterprise Intranets

  • Install, set up, and build a corporate intranet with Liferay's complete guide
  • Configure, customize, and integrate with other applications and also implement portals and plugins within Liferay
  • Discussions, Wiki, blogs, collaboration, CMS & WCM, Social Office, federated search, clustering and more
  • Clear, step-by-step instructions, practical examples, and straightforward explanation

Sample chapter, Table of contents, Download the code

Liferay Portal is the world's leading open-source portal platform built on Java and Web 2.0 technologies. Corporations use it to provide a unified web interface to data and tools scattered across many sources.

Liferay Portal uses the latest in Java, J2EE, and Web 2.0 technologies to deliver solutions for enterprises across both public and private sectors. Liferay Portal's flexibility allows it to be deployed in a number of different scenarios to meet key business needs. 

What this book covers

Chapter 1: Introducing Liferay for Your Intranet introduces Liferay portal, CMS and WCM, collaboration, social networking, and Social Office.

Chapter 2: Set up Home Page and Navigation Structure for the Intranet discusses how to implement a portal page with portlets. It also shows how to customize the look and feel of pages and portlets through themes and look and feel preferences. It helps us understand the portal, portlet container, and portlet according to the JSR-286 specification—how to set up the portal, including installation options and deployment matrix, how to configure the home page and all the other pages of the intranet website. Then it introduces us to building basic pages, as well as setting up the portal pages. It, going further, discusses how to navigate the structure of the intranet via portlets, for example, Site Map, Breadcrumb, and Navigation. It also shows how to configure the portal, how to customize the Dock bar menu, and how to configure database and mail. Finally, it provides guidance to bring pages together in action, to share any portlet within a portal page, and to customize the Control Panel.

Chapter 3: Bringing in Users first introduces how to create and manage organizations and locations and teams; how to add users and manage (for example,e.g. view, search, update, deactivate, restore, delete and impersonate) users; how to add user groups and manage (for example,e.g., view, search, update, delete and assign) user groups. Then it introduces how to integrate with different authentication servers: LDAP, LDAP, CAS, NTLM, OpenID, OpenSSO (renamed as OpenAM), SiteMinder. Furthermore, it introduces how to manage permissions, and how to add roles and manage (for example,e.g., view, search, update, delete and assign) roles.

Chapter 4: Forums, Categorization, and Asset Publishing describes how we can add categories and subcategories in Message Boards. Then it discusses how to add a tag and manage (add, delete, and update) categories and vocabulary, as well as how to tag assets and display tags. Finally, it addresses how to publish assets through the Asset Publisher portlet and how to configure and customize the Asset Publisher portlet.

Chapter 5: Wikis, Web Forms, and Polls introduces how to add and manage (view, update and delete) nodes of Wikis, to add pages at the nodes in Wikis, to manage (view, update, delete and search) pages for a give node in Wikis, to use permissions of Wikis portlet and permissions on nodes, and to publish Wiki articles in the intranet first. Then it introduces how to set up Web Form in order to collect users’ suggestions, to configure polls and to display survey in order to assess public opinions. In addition, it introduces how to integrate OpenOffice, Orbeon forms and Alloy UI forms briefly.

Chapter 6: Blogs, WYSIWYG Editors, and RSS  introduces how to add entries of Blogs; how to manage (e.g., view, update and delete) entries of Blogs; and how to add comments for a given entry of Blogs first. Then it discusses how to assign permissions on the Blogs portlet and entries of Blogs. It also introduces the ways to publish Blogs by Recent Bloggers portlet and Blogs Aggregator portlet and to build Blogs with the WYSIWG editor CKEditor. Finally, it discusses RSS and related portlets like RSS portlet, Weather portlet, Announcements portlet, and Alerts portlet.

Chapter 7: Roll Out to Other Teams introduces communities portlet, involved how to add a community; how to manage (edit, delete, search, join, leave) communities first. Then it discusses how to add and manage the pages, teams and users within a community; to assign permissions on communities, and to show what’s different between organization and community. How to employ community virtual hosting is also introduced. Furthermore, it discusses how to use stage, preview, and publish websites, and manage staging workflow. Scheduling and remote publishing are also addressed in details. Finally, it introduces how to use community tools, e.g., my communities, bookmarks, invitation, directory, etc.

Chapter 8:CMS and WCM introduces how to add folders and sub folders for images; to manage folders and sub folders; to add images in folders and manage images; to set up permission on folders and images first. Then it discusses how to add folders and sub folders for documents; to manage documents, to add comments, to give your rating, to view versions; to set up permission on folders and documents; and to publish documents. Moreover, it introduces structures management, templates management and articles management. It emphasizes on how to build articles based on structures and templates, and how to set up permissions on Web Content Management, articles, templates, structures, and Feeds. Finally, it introduces how to publish articles and to employ other WCM tools. In a word, WCM doesn’t only provide high availability to publish, manage, and maintain web contents and documents, but also does it separate contents from the layout.

Chapter 9: Social Office, Hooks, and Custom Fields introduces how to add a participant for chatting; to manage (view and delete) participants in chat portlet; to start chatting; and to set up chat portlet first. Then it discusses how to manage (check, delete, add, reply, forward, search) emails and furthermore, to set up mail portlet properly. It states how to manage SMS Text Messenger portlet and to send SMS text messages. Then it mainly discusses on how to build social office with so-theme, so-portlet together with hooks and other portlets. Finally it states how to apply custom fields on any assets.

Chapter 10: Search, WAP, CRM, Widgets, Reporting, and Auditing introduces how to employ federated search and how to integrate search against content from plugins first. Then it discusses how to use CSZ search and map search portlets. Especially, it discusses the OpenSearch concept. It also introduces Web Content search and how to configure sitemap and pluggable enterprise search. Finally, it discusses plugins management, WAP sites, reporting, auditing, CRM and Widgets.

Chapter 11: Ongoing Admin Tasks introduces system administration which provides ability to view sever information, to create and manage instances. Moreover, it discusses monitoring portal and portlets operations, dynamic data source (database read-writer), and database sharding. Then it introduces portal administration which doesn’t only allow users with permissions to manage users, organizations, user groups, and roles; but also does it show portal settings information, password policies, and monitors users’ activities. It also addresses how to build clustering environment, how to backup data and to migrate data, and how to speed up the portal. In addition, it discusses full integration with Alfresco by web services, RESTful services like OpenSearch, and moreover, CMIS. Furthermore, it introduces full integration of LDAP, SSO CAS, Liferay and Alfresco. Finally, it discusses Ad server OpenX integration.

Approach

This book is a practical guide with a very user-friendly approach. The author has taken a virtual enterprise as an example and has used the features of Liferay to build a corporate intranet for that enterprise.

Who this book is for

This book is for beginners to Liferay and "Do-It-Yourselfers" who want to develop a simple but powerful corporate Intranet. The book assumes technical confidence but does not require specialist administrator or developer skills.

Acknowledgements

I would like to thank team members at Liferay, especially thanks to Raymond Auge, Brian Chan, Bryan Cheung, Jorge Ferrer, Michael Young, Jerry Niu, Ed Shin, Craig Kaneko, Brian Kim, Bruno Farache, Thiago Moreira, Amos Fong, Scott Lee, David Truong, Alexander Chow, Mika Koivisto, Julio Camarero, Douglas Wong, Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Michael Han, Samuel Kong, Nate Cavanaugh, Arcko Duan, Richard Sezov, Joshua Asbury, Shuyang Zhou of Liferay for providing the valuable information and all the support. Thanks to friends in Liferay community for providing comments and suggestions.

Appendix

In addition, two chapters, which are part of this book originally, are not included in this book due to count of pages:

  • Chapter 9 Shared Calendars, WSRP, Business Rules and Workflow (56 pages)
  • Chapter 11 Help Desk, e-Commerce, Social Networking and Knowledge Base (68 pages)

I will post these two chapters as blogs entiries or wiki pages shortly.

Knowledge management - import and export images and documents across groups

General Blogs April 2, 2010 By Jonas Yuan

What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing; multiple-language support; import and export as XML file like DocBook; import and export images and documents across groups; etc.

In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

We have discussed main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like

Import and export Knowledge based articles

Multiple-language support for Knowledge Base articles

Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles

Sharing Content - Knowledge base - across Organizations and Communities

Search by keyword - look-ahead typing – based on Knowledge Base articles in Liferay portal 6

This article will share one more feature: import and export images and documents across groups in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).

Introduction

You may have thousands of articles like Questions & Answers, Ideas management in third party systems. Now you are planning to import these articles into Liferay portal Knowledge base portlets. And moreover, you are required to import images and documents in articles into Image Gallery and Document Library, respectively. Thus once articles got imported in Liferay portal, it would have all images and documents stored in Liferay portal, too.

Similarly, you may have thousands of KB articles. You are planning to export these articles with images and documents in Liferay portal into third party systems like DocBook XML files.

This article will share how to import or export KB articles with images and documents across groups in general.

Import images and documents in Image Gallery and Document Library 

The importing process is smart – it can detect whether it is XML or ZIP file; and furthermore, it can support both DocBook XML format and ROW-ITEM XML format.

 

Default settings

## Import docbook
## like /${kb.ig.default.root.folder.name}/${article.id}/en_US for English
kb.ig.default.root.folder.name=KB_IG_Home
kb.ig.default.root.folder.description=Knowledge Based IG Home

kb.ig.default.folder.languague.description=Knowledge Based Language Home

## enable custom group to contain images and documents
kb.default.group.organization.enabled=true

## default documents and images container group (organization)
## This property would be active when kb.default.group.organization.enabled is set to true
kb.default.group.organization.name=Knowledge Based Group

## default documents root folder
## like /${kb.dl.default.root.folder.name}/${article.id}/en_US for English
kb.dl.default.root.folder.name=KB_DL_Home
kb.dl.default.root.folder.description=Knowledge Based DL Home

## default vocabulary name
kb.default.vocabulary.name=Knowledge Based

As you can see, you can import images and documents into a specific group or current group. Set kb.default.group.organization.enabled to true to import images and documents into a specific group; or set kb.default.group.organization.enabled to false to import images and documents into current group. This is configurable in KB portlet.

Export images and documents in KB Articles

You can export all articles or selected articles or a specific article with images and documents.

export all articles or selected articles

export a specfic article

 

An Example

An article in DocBook with multiple language support plus images and documents for importing

<?xml version='1.0' ?>
<book>
  <bookinfo>
    <chapter>
      <title>Answer ID: 17</title>
      <section>
        <title>Summary</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Question</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Answer</title>
        <para>Jill Parsons or John Stirrup can reset Panagon Passwords.
        <br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible. <a href="http://liferay.cignex.com/palm_tree/book/liferay-portal-5-2-systems-development-sample-chapter-5-managing-pages.pdf" title="Sample Chapter">Sample Chapter</a><img alt="figure6" src="http://liferay.cignex.com/palm_tree/book/liferay-dev.book.png" border="0" /> </para>
      </section>
      <section>
        <title>Product</title>
        <para>Unilever Applications</para>
      </section>
      <section>
        <title>Sub-Product</title>
        <para>Other</para>
      </section>
      <section>
        <title>Language-Locale</title>
        <para>en_US</para>
      </section>
    </chapter>
    <chapter>
      <title>Answer ID: 17</title>
      <section>
        <title>Summary</title>
        <para>Panagon Password Resets DE</para>
      </section>
      <section>
        <title>Question</title>
        <para>Panagon Password Resets DE</para>
      </section>
      <section>
        <title>Answer</title>
        <para>Jill Parsons or John Stirrup can reset Panagon Passwords.<img alt="figure6" src="http://liferay.cignex.com/palm_tree/book/liferay-dev.book.png" border="0" /> <br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible. DE</para>
      </section>
      <section>
        <title>Product</title>
        <para>Unilever Applications</para>
      </section>
      <section>
        <title>Sub-Product</title>
        <para>Other</para>
      </section>
      <section>
        <title>Language-Locale</title>
        <para>de_DE</para>
      </section>
    </chapter>
  </bookinfo>
</book>

After importing, the article has following lines in content

In English

<p>Jill Parsons or John Stirrup can reset Panagon Passwords. <br />
They recommend emailing both of them to ensure that the request is picked up as quickly as possible. <a title="Sample Chapter" href="/c/document_library/get_file?uuid=3cc7d6c1-ebe9-496e-b66a-499b1fc6379a&amp;groupId=17802">Sample Chapter</a><img border="0" src="/image/image_gallery?uuid=a5e53991-46a3-44b7-a587-ecd8838bc1ed&amp;groupId=17802" alt="figure6" /></p>

In German

<p>Jill Parsons or John Stirrup can reset Panagon Passwords.<img border="0" src="/image/image_gallery?uuid=b5fefea6-6b89-4353-83a9-d7c10c54cdc5&amp;groupId=17802" alt="figure6" /> <br />
They recommend emailing both of them to ensure that the request is picked up as quickly as possible. DE</p>

Summary

As you can see, importing and exporting images and documents in KB articles are useful. That is, you can import articles with images and documents from third party systems into Liferay portal as Knowledge base articles; or you can export any Knowledge base articles with images and documents in Liferay portal to third party systems.

Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make importing and exporting images and documents in Knowledge base articles a reality.

Import and export Knowledge based articles

General Blogs March 19, 2010 By Jonas Yuan

What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing; multiple-language support; import and export as XML file like DocBook; etc.

In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

We have discussed main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like

Multiple-language support for Knowledge Base articles

Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles

Sharing Content - Knowledge base - across Organizations and Communities

Search by keyword - look-ahead typing – based on Knowledge Base articles in Liferay portal 6

This article will share one more feature: import and export Knowledge Base articles in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).

Introduction

As you can see, Liferay portal 6 provides features - archive portlet preferences, backup data as LAR. Knowledge base portlet can leverage same frameworks - configuration-action-class and portlet-data-handler-class as shown in following screenshot.

Meanwhile, capabilities in Knowledge based portlet are expected to import XML -based articles from third party systems and to export KB articles as XML files.

Archive, Export and Import as LAR

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

It would be nice that you could save these settings, and moreover, to revert these changes back to the original later. This feature can be achieved through Archive Setup In liferay portal 6. How to archive setup? You can do it in following steps.

  • Locate the portlet Message Boards in a page;
  • Go to More->Configuration->Setup->Archived;
  • Input archive name for current setup, e.g., “My MB”, and click on the Save button as shown in following screenshot.

Archive Setup

After creating an archive, you would be able to see archives with columns Name, User, Modified Date, and the icon Actions within Restore and Delete sub icons. Obviously, you can restore the setup via an archive or delete an archive.

Note that this feature is available for portlets which have the tab setup visible, since the portal specifies this function at portlet configuration archived_setup_action.jsp and edit_archived_setups.jsp under $TOMCAT_AS_DIR/webapps/ROOTPORTAL_ROOT_HOME/html/portlet/portlet_configuration. More details, archives are stored in portlet preferences of the portal instance. Thus you shouldn’t use it for backup from one portal instance to another portal instance. 

What’s happening? A portlet will have the setup tab under More->Configuration if the tag configuration-action-class is specified as follows in $TOMCAT_AS_DIR/webapps/ROOTPORTAL_ROOT_HOME/WEB-INF/liferay-portlet.xml.

<configuration-action-class>com.liferay.portlet.messageboards.action.ConfigurationActionImpl</configuration-action-class>

Fortunately you can use Export / Import feature for backup functions. The portal provides capability to export and import portlet specific data to a Liferay Archive file (LAR). As shown in following screenshot, you can export portlet Message Boards specific data to a LAR file.

Import and Export as LAR

Why does a portlet like Message Boards have Export / Import capability?  But other portlet like Hello World doesn’t have Export / Import capability.  The reason is that the portlet Message Boards has following setting what the portlet Hello World doesn’t have.

<portlet-data-handler-class>com.liferay.portlet.messageboards.lar.MBPortletDataHandlerImpl</portlet-data-handler-class>

The above code shows that the content could be backed up as a LAR file via the tag portlet-data-handler-class.

Note that in order to export / import data properly, versions of source portal instance and target portal instance should be completely same. Otherwise, you may meet migration issues.

What’re differences between archives and Export / Import? By the feature of Export / Import, you could export LAR from one portal server and import it into another portal server, as long as the two portal servers are running the same version; by the feature Archive, only one portal instance is involved.  The main difference is: Archives backup setup configuration whereas LAR contains data.  

Export and Import as XML files

You may have thousands of articles like Questions & Answers in third party systems. Now you are planning to import these articles into Liferay portal Knowledge base portlets. You could take following steps as shown in following figure.

  • Transform XML file using XSL into DocBook format.
  • Import articles in DocBook format into Knowledge base portlets;
  • Add multiple-language info in these articles.

Import articles

Similarly, you may have thousands of KB articles. Now you are planning to export these articles into third party systems like XML files. You could take following steps as shown in following figure.

  • Transform KB Articles into DocBook format.
  • Export articles in DocBook format in XML file;
  • Add multiple-language info in XML files.

Export articles

Examples

 For instance, you have an article Question & Answer like following:

<?xml version="1.0" encoding="utf-8" ?>
<Report>
  <Field>Infoco Answer Export Tool</Field>
 <Row>
  <Item />
  <Item>Id</Item>
  <Item>Summary</Item>
  <Item>Question</Item>
  <Item>Answer</Item>
  <Item>Product</Item>
  <Item>Sub-Product</Item>
  <Item>Language-Locale</Item>
  </Row
<Row>
  <Item>1</Item>
  <Item>17</Item>
  <Item>Panagon Password Resets</Item>
  <Item><font face="Arial, Helvetica" size="2">Panagon Password Resets</font></Item>
  <Item><font face="Arial, Helvetica" size="2">Jill Parsons or John Stirrup can reset Panagon Passwords.<br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible.</font></Item>
  <Item>Unilever Applications</Item>
  <Item>Other</Item>
  </Row>
</Report>

Using importing mechanism, you can transform above article into DocBook format as follows. 

<?xml version='1.0' ?>
<book>
  <bookinfo>
    <chapter>
      <title>Answer ID: 17</title>
      <section>
        <title>Summary</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Question</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Answer</title>
        <para>Jill Parsons or John Stirrup can reset Panagon Passwords.<br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible.</para>
      </section>
      <section>
        <title>Product</title>
        <para>Unilever Applications</para>
      </section>
      <section>
        <title>Sub-Product</title>
        <para>Other</para>
      </section>
      <section>
        <title>Language-Locale</title>
        <para>en_US</para>
      </section>
    </chapter>
  </bookinfo>
</book>

Then map DocBook into KB articles as follows

DocBook <-> KB Article Metadata

  • Summary <-> Description
  • Question <-> Title
  • Answer <-> Content
  • Products <-> Categories
  • Sub-Product <-> Categories

Using exporting mechanism, you can export KB articles into DocBook and moreover save them as XML files.

Screenshot - Import and Export in Liferay 5.2 EE (SP1 and SP2 and SP3):

 

Summary

As you can see, importing and exporting Knowledge Base articles are useful. Isn't it? That is, you can import articles from third party systems into Liferay portal as Knowledge base articles; or you can export any Knowledge base articles in Liferay portal to third party systems.

Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make importing and exporting Knowledge base articles a reality.

Multiple-language support for Knowledge Base articles

General Blogs February 26, 2010 By Jonas Yuan

What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing; multiple-language support, etc.

In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

We have discussed main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like

Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles

Sharing Content - Knowledge base - across Organizations and Communities

Search by keyword - look-ahead typing – based on Knowledge Base articles in Liferay portal 6

This article will share one more feature: Multiple-language support on Knowledge Base articles in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).

Introduction

In Liferay portal, you can use your own language. Multilingual organizations get out-of-the-box support for up to 22 languages. Users can toggle among different language settings with just one click and produce/publish multilingual documents and web content. You can also easily add other languages in your public, private pages, or other organizations.

Multi-languages get supported as well in Web Content. That is, web content can be entered in as many languages as desired. As you can see, only content got localized. In addition, the name (article title) and the summary, that is, abstract description of web content, should be localizable, too.

Fortunately, knowledge base articles have fields: title, content, summary (description), etc. Multi-languages should get supported as well in knowledge base articles. That is, knowledge base articles (title, content and summary) can be entered in as many languages as desired.

How to achieve this?

Multi-languages get support on knowledge base articles could be achieved in following steps. Here English and German are used as examples.

  • Add locale methods in the model.

    public String getTitle(Locale locale);   
    public String getTitle(String localeLanguageId);   
    public String getTitle(Locale locale, boolean useDefault);   
    public String getTitle(String localeLanguageId,boolean useDefault);   
    public void setTitle(String title, Locale locale);   
    public String getContent(Locale locale);   
    public String getContent(String localeLanguageId);   
    public String getContent(Locale locale,boolean useDefault);   
    public String getContent(String localeLanguageId,boolean useDefault);   
    public void setContent(String content, Locale locale);   
    public String getDescription(Locale locale);   
    public String getDescription(String localeLanguageId);   
    public String getDescription(Locale locale, boolean useDefault);   
    public String getDescription(String localeLanguageId, boolean useDefault);   
    public void setDescription(String description, Locale locale);

  • Implement locale methods based on above model.

For more details, you may refer to chapter 5 Managing Pages of the book: Liferay Portal 5.2 Systems Development.

  • Input knowledge base articles in multiple languages.

In English, German, etc.

  • List knowledge base articles (Title and Summary) in selected language

In English.

 

In German.

  • List search results in selected language

In English.

In German.

  • List history (versions) in selected language

 In German

  • View knowledge base article in selected language

 In German

In English

What’s happening?

The portal has following default settings for languages in portal.properties.

locales=ar_SA,eu_ES,bg_BG,ca_AD,ca_ES,zh_CN,zh_TW,cs_CZ,nl_NL,en_US,fi_FI,fr_FR,gl_ES,de_DE,el_GR,hu_HU,it_IT,ja_JP,ko_KR,nb_NO,fa_IR,pl_PL,pt_BR,pt_PT,ru_RU,sk_SK,es_ES,sv_SE,tr_TR,vi_VN
locale.default.request=false
locale.prepend.friendly.url.style=1
time.zones=Pacific/Midway,Pacific/Honolulu,America/Anchorage,America/Los_Angeles,America/Denver,America/Chicago,America/New_York,America/Puerto_Rico,America/St_Johns,America/Sao_Paulo,America/Noronha,Atlantic/Azores,UTC,Europe/Lisbon,Europe/Paris,Europe/Istanbul,Asia/Jerusalem,Asia/Baghdad,Asia/Tehran,Asia/Dubai,Asia/Kabul,Asia/Karachi,Asia/Calcutta,Asia/Katmandu,Asia/Dhaka,Asia/Rangoon,Asia/Saigon,Asia/Shanghai,Asia/Tokyo,Asia/Seoul,Australia/Darwin,Australia/Sydney,Pacific/Guadalcanal,Pacific/Auckland,Pacific/Enderbury,Pacific/Kiritimati

As shown in above code, the portal specifies the available locales. Messages corresponding to a specific language are specified in properties files with file names matching that of content/Language_$[language locale code]*.properties. Of course, these values can also be overridden in properties files with file names matching that of content/Language-ext_$[language locale code]*.properties at $PORTAL_ROOT_HOME/WEB-INF/classes. Obviously you can use a comma to separate each entry. Note that all locales must use UTF-8 encoding.

The portal sets the property locale.default.request to false – that is, unauthenticated users get their preferred language from their company; you can set it true in portal-ext.properties if unauthenticated users get their preferred language from the Accept-Language header.

The portal sets the property locale.prepend.friendly.url.style to 1 – that is, the locale is automatically pre-pended to a URL when the requested locale isn’t the default locale. This means that each URL points to just one language. For example, the URL http://localhost:8080/web/guest/home would point to the default language; The URL http://localhost:8080/zh/web/guest/home and http://localhost:8080/zh_CN/web/guest/home would both point to the Chinese language.

In addition, you would be able to set the property locale.prepend.friendly.url.style to 2 - that is, the locale is automatically pre-pended to every URL, meaning that each URL points to just one language; or you could set the property locale.prepend.friendly.url.style to 0 - that is, the locale isn’t automatically pre-pended to a URL, meaning that each URL could potentially point to many different languages. For instance, the URL http://localhost:8080/web/guest/home could then be viewed by users in many different languages.

The portal specifies available time zones with the property time.zones.

Default language and time zone

The default language is set in system.properties with the following properties.

user.country=US
user.language=en
user.timezone=Europe/Paris

As shown in above code, the portal sets the default locale like country as US and language as en. The portal also sets the default time zone as Europe/Paris (UTC).

Of course, you can customize default language as your own. Supposed that you want to country China Mainland, language Chinese, and time zone Asia/Shanghai, you could add the following lines at $PORTAL_ROOT_HOME/WEB-INF/classes/system-ext.properties.

user.country=CN
user.language=zh
user.timezone=Asia/Shanghai

Remove unwanted languages

As mentioned above, the portal following default languages.

locales=ar_SA,eu_ES,bg_BG,ca_AD,ca_ES,zh_CN,zh_TW,cs_CZ,nl_NL,en_US,fi_FI,fr_FR,gl_ES,de_DE,el_GR,hu_HU,it_IT,ja_JP,ko_KR,nb_NO,fa_IR,pl_PL,pt_BR,pt_PT,ru_RU,sk_SK,es_ES,sv_SE,tr_TR,vi_VN

Of course, you could remove unwanted languages. Supposed that you want to support English, German and Chinese only, you can simply remove the unwanted locales so that your locales value looks like following in portal-ext.properties.

locales=en_US,de_DE,zh_CN,zh_TW

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

Summary

As you can see, multiple-language support based on Knowledge Base articles is useful.  By the way, this solution would be helpful in Liferay portal core portlets like Web Content and any plugin portlets.

Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make multiple-language support based on Knowledge base articles a reality.

Hooks and plugin Ext in Liferay portal 6

General Blogs February 22, 2010 By Jonas Yuan

In summary, the portal (6.0 or above) supports six different types of plugins out-of-the-box. They are portlets, themes, layout templates, webs, hooks, and ext.

  • Portlets: web applications that run in a portion of a web page;
  • Themes : look and feel of pages;
  • Layout Templates : ways of choosing how the portlets will be arranged on a page;
  • Hooks : allow overriding the portal core functionality;
  • Webs : regular Java EE web modules designed to work with the portal, like ESB (Enterprise Service Bus), SSO (Single Sign-On), etc.
  • Ext : use ext environment as a plugin.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets

This article will share two cool features - Hooks and Plugins Ext - in Liferay portal 6. Speciall thanks to Amos Fong, so that we could minimize the ext environment by using hooks. A lot of thanks to Brian Chan , who coined terms "Hook" and "Plugin Ext" and implemented them as part of wonderful features in Liferay portal 6.

Plugin Ext

Ext environment is now available as a plugin.

You would know how to use it (plugin Ext) by an example - hello-world-ext .

Under hello-world-ext/docroot/WEB-INF, you'll see a lot of folders that start with ext-* as shown in following screenshot.

  • ext-impl/src contains code that will override portal-impl/src
  • ext-lib/global is where you put jars that are available in the global class loader
  • ext-lib/portal is where you put jars that are available only to the portal class loader
  • ext-service/src contains code that will override portal-kernel/src and portal-service/src
  • ext-util-bridges/src contains code that will override util-bridges/src
  • ext-util-java/src contains code that will override util-java/src
  • ext-util-taglib/src contains code that will override util-taglib/src
  • ext-web/docroot contains code that will override portal-web.

Note that if you modify ext-web/docroot/WEB-INF/web.xml, those changes are merged into portal-web/WEB-INF/web.xml. ext-web also contains /WEB-INF/*-ext.xml files that are used to override what is in portal-web.

and more ... You could refer to LPS-6341 and Ext environment and the Ext Plugin in 6.x.

As you can see, It works very similarly to that of Ext environment, but it is now much smaller and lighter weight.

Note that support for ServiceBuilder in EXT plugins will be deprecated in future versions. EXT plugins are designed to override the portal's core code that cannot be done with hooks, layout templates, portlets, or themes. EXT plugins are not meant to contain new custom services. Thus migrate your service.xml of 5.x to a portlet plugin.

Open Issues

Of course, it would be nice that the plugin Ext should have same functions and features as that of Ext environment. Actually there are still a set of open issues that should get fixed in future release.The following are some of them.

Hooks

Hooks is a feature to catch hold of the properties and JSP files into an instance of the portal as if catching them with a hook. Hook plugins are more powerful plugins that come to complement portlets, themes, layout templates, and web modules. A hook plugin could be standalone or go with other plugins like portlets, webs, themes. For instance, the portlet so-portlet is a portlet plugin for Social Office with hooks. In general, hooks would be very helpful tools to customize the portal without touching the code part of the portal. In addition, you would use hooks to provide patches for the portal systems or social office products. 

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

Setup

In general, there are four kinds of hook parameters: portal-properties (called portal properties hooks), language-properties (called language properties hooks), custom-jsp-dir (called custom JSPs hooks) and service (called portal service hooks) as specified in $PORTAL_ROOT_HOME/dtd/liferay-hook_6_0_0.dtd.

<!ELEMENT hook (portal-properties?, language-properties*, custom-jsp-dir?, service*)>
<!ELEMENT portal-properties (#PCDATA)>
<!ELEMENT language-properties (#PCDATA)>
<!ELEMENT custom-jsp-dir (#PCDATA)>
<!ELEMENT service (service-type, service-impl)>
<!ELEMENT service-type (#PCDATA)>
<!ELEMENT service-impl (#PCDATA)>

As shown in the preceding code, the ordering of elements is significant in the DTD (Document Type Definition) - you need to have your portal properties (only one marked by ?), language properties (could be many marked by *), custom-jsp-dir (only one marked by ?) and service (could be many marked by *) declared in the same order.

Language properties hooks allow us to install new translations or override few words in existing translations. JSP hooks provide a way to easily modify JSP files without having to alter the core of the portal, whereas portal properties hooks allow runtime re-configuration of the portal. Portal service hooks provide a way to easily override portal services. The portal configuration properties can be altered by specifying an override file, where the properties will immediately take effect when deployed.

Note that not all portal properties can be overridden via a hook. The supported properties are:

auth.forward.by.last.path
auto.deploy.listeners
application.startup.events
auth.failure
auth.max.failures
auth.pipeline.post
auth.pipeline.pre
auto.login.hooks
captcha.check.portal.create_account
control.panel.entry.class.default
default.landing.page.path
dl.hook.impl
field.enable.com.liferay.portal.model.Contact.birthday
field.enable.com.liferay.portal.model.Contact.male
field.enable.com.liferay.portal.model.Organization.status
hot.deploy.listeners
image.hook.impl
javascript.fast.load
layout.static.portlets.all
layout.template.cache.enabled
layout.user.private.layouts.auto.create
layout.user.private.layouts.enabled
layout.user.private.layouts.modifiable
layout.user.public.layouts.auto.create
layout.user.public.layouts.enabled
layout.user.public.layouts.modifiable
ldap.attrs.transformer.impl
login.create.account.allow.custom.password
login.events.post
login.events.pre
logout.events.post
logout.events.pre
mail.hook.impl
my.places.show.community.private.sites.with.no.layouts
my.places.show.community.public.sites.with.no.layouts
my.places.show.organization.private.sites.with.no.layouts
my.places.show.organization.public.sites.with.no.layouts
my.places.show.user.private.sites.with.no.layouts
my.places.show.user.public.sites.with.no.layouts
passwords.passwordpolicytoolkit.generator
passwords.passwordpolicytoolkit.static
servlet.session.create.events
servlet.session.destroy.events
servlet.service.events.post
servlet.service.events.pre
session.phishing.protected.attributes
terms.of.use.required
theme.css.fast.load
theme.images.fast.load
upgrade.processes
users.email.address.generator
users.email.address.required
users.full.name.validator
users.screen.name.always.autogenerate
users.screen.name.generator
users.screen.name.validator
value.object.listener.*

What’s happening?

As you can see, hooks can be standalone plugins, where one XML file is required liferay-hook.xml. Or hooks can work together with portlets, where simply adding one XML file liferay-hook.xml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.0.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd">

<hook>
    <portal-properties>portal.properties</portal-properties>
    <language-properties>content/Language_en.properties</language-properties>
    <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>

Portal Properties Hooks

Through portal properties hooks, we could change certain configuration properties dynamically and inject behaviour into the hooks defined in the portal.properties file. All of the hooks that we have discussed above will revert, and their targeted functionality will be disabled immediately as soon as they are un-deployed from the portal. Also, each type of hook can easily be disabled via the portal.properties file.

Note that a portal.properties file must exist in the plugin hook's WEB-INF/classes folder if portal properties hooks are enabled. Plugin hooks can override the properties like dl.hook.impl, mail.hook.impl, image.hook.impl, etc. To override these properties, add these properties to a portal.properties file in the plugin hook's WEB-INF/classes folder.

Language Properties Hooks

Language properties hooks allow us to install new translations or override few words in existing translations. For example, you’re going to rename “Custom Attributes” as “Custom Fileds” in user editing mode or organization editing mode. You can create and folder content under plugin hook’s WEB-INF/classes, and then you could create a properties file Language_en.properties under the plugin hook's WEB-INF/classes/content. Finally, add following line at Language_en.properties.

custom-attributes=Custom Fields

The above code shows that the message key custom-attributes will have display text Custom Fields.
Note that a Language_en.properties file must exist in the plugin hook's WEB-INF/classes/content folder if language properties hooks got enabled.

More interestingly, language properties hooks allow us to install new translations or override few words in existing translations in both a single language and multiple languages. You can specify multiple language properties files at liferay-hook.xml. Therefore, multiple language properties files got supported via hooks. It is a nice feature that multiple language properties files got supported via hooks.

Custom JSPs Hooks

Custom JSP hooks provide a way to easily modify JSP files of the portal without having to alter the core of the portal. A folder /META-INF/custom_jsps must exist in the plugin hook's Root folder if language properties hooks are enabled.

Under the folder /META-INF/custom_jsps, same folder structure like html as that of $PORTAL_ROOT_HOME/html will be used to override portal JSP files with custom JSP files. In runtime, the original JSP like ${name}.jsp or ${name}.jspf will be renamed as ${name}.portal.jsp or ${name}.portal.jspf under $PORTAL_ROOT_HOME/html; custom JSP files ${name}.jsp or ${name}.jspf will get copied to the folder $PORTAL_ROOT_HOME/html.

For example, you’re going to override the view of login portlet. You can put custom JSP file login.jsp of hook plugin at /META-INF/custom_jsps/html/portlet/login. In runtime, the portal will rename the original JSP login.jsp as login.portal.jsp under $PORTAL_ROOT_HOME/html/portlet/login first; and then the portal will copy custom JSP files login.jsp of hook plugin at /META-INF/custom_jsps/html/portlet/login to the folder $PORTAL_ROOT_HOME/html/portlet/login. More interestingly, you can again include renamed original JSP as follows in custom JSP files login.jsp of hook plugin at /META-INF/custom_jsps/html/portlet/login.

<liferay-util:include page="/html/portlet/login/login.portal.jsp" />

Therefore after deploying hook plugin, you would be see both login.jsp and login.portal.jsp under the folder $PORTAL_ROOT_HOME/html/portlet/login.

Portal Service Hooks

Portal service hooks allow us to customize portal services and models. That is, plugin hooks can override services and models. For example, to override UserLocalService, you can add the following in liferay-hook.xml.
<hook>
 <service>
  <service-type>com.liferay.portal.service.UserLocalService</service-type>
  <service-impl>com.ext.hook.service.impl.ExtUserLocalServiceImpl</service-impl>
 </service>
</hook>

As shown in above code, service was specified by tags <service-type> and <service-impl>. The tag <service-type> provides the original service or model in the portal; and the tag <service-impl> provides customize portal service or model, which will override the original service or model in the portal. More interestingly, you would able to specify many tags <service> if in need.

Note that portal service hooks, portal properties hooks and language properties hooks will get inactive when Hook plugins were un-deployed. 

Enhancement

Custom JSP hooks provide a way to easily modify JSP files of the portal without having to alter the core of the portal. In runtime, the original JSP like ${name}.jsp or ${name}.jspf will be renamed as ${name}.portal.jsp or ${name}.portal.jspf under $PORTAL_ROOT_HOME/html. When hook plugin got un-deployed, the original JSPs should get rolled back. For example, considering custom JSP on logon view, when hook plugin got un-deployed, the portal should delete the JSP login.jsp under $PORTAL_ROOT_HOME/html/portlet/login, and rename login.portal.jsp as login.jsp under $PORTAL_ROOT_HOME/html/portlet/login. This is a nice feature that we could be able to restore the original JSPs of the portal when hook plugin got un-deployed.

And what happens when you deploy two hooks that override the same JSP file? It's currently unsupported for hooks to change the same JSP file. You need to check the hooks for collision; you can use a separate repository for handling this. If you have a collision, the last deployed JSP will be used, but it should be done with care as the order of deployment is not guaranteed.   The hooks should be smart to handle it – this feature is highly expected, too.

As you can see, there are five different kinds of plugins: portlet, theme, layout template, web and ext. For more details, refer to chapter 12 Search, WAP, CRM, Widgets, Reporting and Auditing of the book: Liferay Portal 6 Enterprise Intranets . Ideally one plugin should contain only one kind of plugin like web, ext, theme, hook, and layout template. But the plugin portlet can contain many portlets plus hook optionally, for example the plugin so-portlet included several portlets and a hook. 

Search by keyword - look-ahead typing – based on Knowledge Base articles in Liferay portal 6

General Blogs February 16, 2010 By Jonas Yuan

What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing, etc.

In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

We have discussed two main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like

Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles

Sharing Content - Knowledge base - across Organizations and Communities

This article will share one more features: search by keyword - Look-ahead typing – based on Knowledge Base articles in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).

What’s Look-ahead typing?

Look-ahead is a tool in algorithms for looking ahead a few more input items before making a cost effective decision at one stage of the algorithm. In artificial intelligence, look-ahead is an important component of combinatorial search which specifies, roughly, how deeply the graph representing the problem is explored. Look-ahead is also an important concept in parsers in compilers which establishes the maximum number of incoming input tokens the parser can look at to decide which rule it should use.

In Knowledge base portlets, it is very useful to search articles by keywords. And moreover, it is very nice that the system should remember the keywords that users input for search. When users typing, suggested keywords should be available.

For example, suppose that users input a set of keywords to search Knowledge base article, like “liferay”, “life”, “live”, “look”, “like” and now they want to use these keywords in their keyword search. When a user types “l”, the system should list suggested keywords, like “liferay”, “life”, “live”, “look”, “like”; when a user types “li”, the system should list suggested keywords, like “liferay”, “life”, “live”, “like”; when a user types “lif”, the system should list suggested keywords, like “liferay”, “life”; and so on.

This is a good feature to search knowledge base articles. And moreover, it would be nice feature for Liferay portal core portlets like Search and Web Content Search. 

How to achieve this?

You would have different models on look-ahead type. Here we share our solution. The following is main idea.

  • First create a database table "kb_kbsearchkeyword."

    <entity name="KBSearchKeyword" local-service="true" remote-service="true">
        <!-- PK fields -->
        <column name="keyword" type="String" primary="true"></column>
        <!-- Audit fields -->
        <column name="createDate" type="Date"></column>
        <!-- Order -->
        <order by="desc">
            <order-column name="createDate"></order-column>
        </order>
    </entity>

  • When a user enters a new keyword for search, if the search result is not empty, that keyword will be saved into this table.

KBSearchUtil.typingLookAhead(entries.size(), keywords);

  • The suggested keywords will be retrieved from this table ordered by creation date descending. The first 500 keywords will be retrieved.

KBSearchKeywordLocalServiceUtil.getKBSearchKeywords(0,500);

Prototype

Type “l”

Type “li”

Summary

As you can see, search by keyword - Look-ahead typing – based on Knowledge Base articles is useful.  By the way, this solution would be helpful in Liferay portal core portlets like Search and Web Content Search, etc.

Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make search by keyword - Look-ahead typing – based on Knowledge base articles a reality.

Showing 21 - 40 of 53 results.
Items 20
of 3