Tuesday, 8 October 2013

MY LIFERAY CMS TIPS & TRICKS

MY LIFERAY CMS TIPS & TRICKS

It is my honest opinion that the Liferay CMS is the redheaded stepchild of the elements included in the Liferay portal bundle. Wow, he started off by dropping bombs on Liferay! Sorry to be negative, but after using Liferay daily for a couple of years, I can say that, at best, the CMS is competent. However, it is not anywhere near as friendly or as intelligent as WordPress or other content management systems on the market.
The business reasons for choosing a portal solution are usually a complex mish-mash of functionality, system and application architecture needs. The CMS is an obvious necessity, but is rarely the deciding factor in this process. I mention all this to say that many Liferay administrators had little or no say in which product they were going to be administering. In effect, they are stuck with all the good and all the bad parts of the Liferay CMS. Because of this, I wanted to share some of my bright ideas, workarounds and best practices for the CMS included in Liferay’s Portal. I have not used the CE version and will focus only on the 6.1 EE version.  I have found enough quirks and bugs to fill pages on our internal documentation platform from Atlassian.
First off, I will start with how I activated Google Webmaster Tools, a simple process turned impossible because there is not a clear way to add a meta tag to a Liferay page. This is the solution I found that proved to be the easiest and most efficient way of accomplishing this task. Be sure to check back next time when I go over installing a local instance.
Tip #1 How to Activate your Liferay Site on Google Webmaster
  • Download the html file from Google Webmaster Tools
  • Upload it to the doc library with guest permissions enabled
  • Create a new “hidden” page as a “URL link” with the friendly url to set the appropriate html address.
Screen Shot of HTML Document in Library

MANAGING LIFERAY USERS WITH ORGANIZATIONS, USER GROUPS & PERMISSIONS

MANAGING LIFERAY USERS WITH ORGANIZATIONS, USER GROUPS & PERMISSIONS

Administering your audiences and various sites through Liferay can be a challenging task if not properly planned out at the beginning of a project. Known as Information Architecture, or IA, the practice of planning and organizing a sites, audiences, resources, content and flow is too often an overlooked step in website development. There are millions of articles about how to design graphics, interfaces and properly design a site.  However, IA is much less popular. I would pose that IA is just as important as these other concepts because it lends to usability for every person that touches a site. When discussing the architecture of a Liferay Portal, I am speaking about the hierarchy of its Sites, Organizations, Groups and Roles, as well as the navigation and structure of each individually. Please note I am not talking about text, graphics, or any other cosmetic assets. Of course the look and feel is still important, but the Information Architecture is the foundation for the user experience on the site. More often than not a proper IA strategy is left out of a site plan. When this occurs, pages fall where they land and a precedent is set for placing things in a willy-nilly fashion.

 LIFERAY'S IA TERMINOLOGY

  • Portal: Corporate Site that allows User specific content
  • Portlet: Widgets and Modules on a Portlet Page
  • User: Anyone on the portal, logged in or not
    • Roles- determine permission level
  • Site: Web Site unit under a portal
    • User Group- Arbitrary group of users under a site
    • Public/Private- Permission based security for viewable pages
  • Organization: Org unit under a site
    • Team: Arbitrary group of users under an organization
  • Scope: All of the above are different scopes

THE PERMISSION ENGINE

Whether your various Audiences call for a public facing web site, an Intranet site or both, your users will consist of a number of different roles. Some may be clients, others employees and, regardless of the type of site you will have, at least one administrator. Because of this, architectural principles from the real-world apply to planning a web site. A logical sense of context and location enables your users to find what they're looking for. Liferay manages these various roles by setting permissions. Instead of applying a permission set by a user, we set it by the user role so that the permission is more scaleable.

Permissions on every level 
  • Except Individual User Acts
  • Site, Org, Team & Group
  • Roles
  • Regular - Portal Admin
  • Site - Site Admin
  • Org- Org Owner

 

CUSTOM - MESSAGE BOARD ADMIN

To put this into practice I will give you a scenario where the client needs someone interal to be a message board administrator. By creating this role and allowing them all the permissions that pertain to the message board portlet, I can now assign any number of users this new message board admin role.

Monday, 7 October 2013

workflow



workflow
Intro:
In this example we will create the following users:
            Reader: this is a simple user that is a member of the community "My Use Case Community"
            Content Writer: this is the content writer of the community. He's able to create web content
            Content Reviewer: this is the person in charge of controling the content that is going to be published. He can decide if the web content is correct or not.
            Content Publicator: this is the member of the community that publishes content, add new applications to the community and so on.
            Portal Admin: super user that will prepare the environment of this use case

Configure the environment:

With the portal admin, I create "My Use Case Community" and the four users, which I assign to the community as new members.

Assign roles and permissions:
            Assign the "Community Content Reviewer" role (which is an autogenerated role from the workflow definition) to the user "Content Reviewer", so that he can review content
            Assign the "Community Administrator" role to "Content Publicator" so that he can manage everything in the community
            Create a new community role called "Content Writer" and assign it to "Content Writer". This role would have web content's permissions (I don't usually give him "delete" and "permission" permissions, but that's up to you) and access in control panel, so that he can create web content from the control panel (this is not strictly necessary, as he can create web content from the asset publisher, for example)

Important: Enable the workflow for this community's web contents: Go to "Control Panel", "Workflow configuration" and select your workflow definition (by default kaleo provides "Single Approver" definition) in the "Web content" entry.

Now, let's start working! http://www.liferay.com/html/js/editor/fckeditor/editor/images/smiley/msn/teeth_smile.gif

The workflow system in action:

           1.- Creating the content

Login as the "Content Writer", go to the control panel and create a new web content. Notice that the available buttons are "Save as draft" and "Submit for publication", so that the user knows that he can't publish directly (by the way this is a good way to know that the workflow engine is correctly applied to your community). Click "Submit for publication".

http://cdn.www.liferay.com/image/image_gallery?uuid=9b9dc472-605b-4161-bf76-ba0d03163931&groupId=1373757&t=1279016845668

In this moment, the workflow engine starts. The user can see that the content's status is "pending" and he can't modify the content till it's reviewed.
From this moment on, the content writer can follow the process in the "My Submissions" portlet. There he can see the internal workflow status and if he realizes (for example) that he wants to modify something in the content, he can withdraw the submission.

               2.- Reviewing the content

It's time for the "Content Reviewer" to start working.
The main part of the reviewer work is going to be done in the "My Workflow Tasks" portlet, so let's go there. 
In the "Assigned to my roles" view, you'd see the pending tasks and you can assign the task to another user or yourself.

http://cdn.www.liferay.com/image/image_gallery?uuid=9d17e04e-e1e3-49ef-9e89-9e1a5bcbe866&groupId=1373757&t=1279016845669
 
I assign it to myself

http://cdn.www.liferay.com/image/image_gallery?uuid=9677c64a-367d-40c7-b26c-39a269f06b7e&groupId=1373757&t=1279016845670

 
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 (in this case approve or reject, but this would depend on the workflow definition)

http://cdn.www.liferay.com/image/image_gallery?uuid=3dc59bef-16db-4046-a75d-5a97bad683a4&groupId=1373757&t=1279016845671

In this moment, there are two possibilities:
            a) The reviewer rejects the content: he writes the reason in a popup and the content goes back to the writer, so that he can edit/fix/improve it
            b) The reviewer approves the content: he (maybe after editing the content so that it fits the portal's rules) approve the content and the content's status is updated to "approved".

                   3.- Publish the content

The user "Content Publicator", that handles the portlets and has publishing rights, now can go to the community pages and add a web content display portlet with the new content in it

                   4.- Access the content

The user "Reader" (who, remember, has no special permissions, but is a community member) is now able to view the new web content

http://cdn.www.liferay.com/image/image_gallery?uuid=bdef4ea6-d5ff-4264-a5b1-75ca1903cfc5&groupId=1373757&t=1279018560736

 
Remember that, out-of-the-box, liferay 6 provides the hability to enable workflow for these entities:
         1. Wiki Page
         2. Web Content
         3. Document Library Document
         4. Blogs Entry
         5. Comments
         6. Message Boards Message 

And you can extend this functionallity to your custom portlets. 

We are looking forward to hearing your feedback!

Regards, 
Juan Fernández
Liferay Core Engineer

Model-View-Controller

Model-View-Controller

By using this pattern, you separate your concerns into various layers of the application,
just as you did with Data Transfer Objects (DTOs) and Data Access Objects
(DAOs) in your service layer. If you’ve been developing Java-based web applications for
a while, you’re probably familiar with some of the MVC frameworks that are available.
The same concepts apply here, but as you’ll see, they’re implemented in a way that is a
bit easier to use. Let’s look at the various components of the MVC design pattern and
see how they’re implemented.
■ Model—The model layer of the application holds the data of the application
and contains any business rules for manipulating that data. Your PRProduct
object with its fields containing values for the name and serial number is part of
your model and was generated by Service Builder. Any logic that would change
those values based on certain rules would also be part of the model layer.
■ View—The view layer of the application contains all the logic for displaying the
data to the user. Handling fields, check boxes, and other form elements, as well
as hiding or showing data, are functions provided by the view layer. You’ll create
JSPs that will handle the view layer, and you’ll see some tools that Liferay provides
that makes this easy.
■ Controller—The controller layer acts as a traffic director. It passes data back and
forth to and from the model and view layers, providing a separation of concerns.
The controller, for example, might be responsible for determining which
action a user has clicked and directing processing to the proper function to
update the model. Generally, the model and view speak only to the controller,
with the exception that the view may use objects from the model for display purposes
(such as iterating over a List to populate a table).


These three layers are pictured in figure 4.1.
How would you implement this design pattern in a portlet? The model layer is generated
for you by Service Builder from your table design. I stated earlier that your JSPs
will be your view layer. That leaves the portlet class as your controller. As you’ll see,
this design will provide a good implementation of the MVC design pattern, allowing
you to separate your concerns in a way that is maintainable and straightforward.
Liferay has subclassed GenericPortlet to provide functionality that makes it easy
to create MVC applications using portlets. This subclass is called MVCPortlet, and it
enhances the way portlets handle actions and page management. All of Liferay’s portlet
plugins are based on MVCPortlet instead of GenericPortlet, because it’s a much
better option.
What’s different? Well, MVCPortlet is a lot easier to use. You won’t have to worry
about page management anymore; you get it for free. Liferay’s MVCPortlet provides a
simple means for page management. If you want to determine what JSP to display, all
you need to do is point a render parameter called jspPage to the location of the JSP,
and that’s the page that will be displayed to the user. This functionality does several
things for you:
■ You don’t have to worry about doView(), doEdit(), or any other do method.
■ Your portlet class doesn’t need to implement any portlet-specific APIs.
■ Your portlet class is simple: all it contains is action methods.
■ If you wish, you can use any piece of the standard portlet API that you want:
MVCPortlet is subclassed from GenericPortlet, so feel free to override any
functionality for your own purposes.
One of the other things this project will have is a portlet in Liferay’s Control Panel as

an alternative to Edit mode for administrative functions.

Thursday, 3 October 2013

Open Office Integration with Liferay


Open Office Integration with Liferay
Purpose of the Open Office integration is to convert one type of data format to another type
of data format. 
For example I have uploaded one word document into documentLibrary portlet. But I want to 
download the document as pdf. Here in this scenerio openoffice integration comes into the 
picture.
To integrate with Liferay Portal Server please follow the below steps : 

Step 1 :     Install openoffice software into your machine. We can install the software on any OS like windows, MAC, linux.
Step 2 :    Go to the folder where it was installed (for example, C:\Program Files\OpenOffice.org\program) and start OpenOffice service with the following command:
        open cmd and run the below command under above specified path
        soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard 
        The above command will be executed irrespective of Operating Systems. 
Step 3 :    Goto Control panel --> Server Category --> Server Administration --> Open Office
Step 4 :     Select check box of Enableed and make sure that port number should be 8100
or
Step 5 :     We can enable the property from portal-ext.properties by providing the property as
        openoffice.server.enabled=true
        openoffice.server.host=//YourServerURL//

Step 6 :     Now you can upload the document into document library and try to download the document in another format.
I hope it will be helpful to  you.


MacrosVariables/Methods



MacrosVariables/Methods


Theme specific variablesShow
$theme_display
The theme display object
$portlet_display
The portlet display object
$css_class
The css class specified for the "color scheme" in the liferay-look-and-feel.xml
$css_folder
The absolute path to the css directory
$images_folder
The absolute path to the images directory
$javascript_folder
The absolute path to the javascript directory
$templates_folder
The absolute path to the templates directory
$full_css_path
The absolute path to the css directory
$full_templates_path
The absolute path to the templates directory
$css_main_file
The absolute path to the css/main.css file
$js_main_file
The absolute path to the javascript/javascript.js file
Company specific variablesShow
$company_id
The company id (specified in Admin Portlet > Settings)
$company_name
The name of the company (specified in Admin Portlet > Settings)
$company_logo
The absolute path to the image of the company logo (specified in Admin Portlet > Settings)
$company_url
The URL of the company (specified in the Admin Portlet > Settings)
User specific variablesShow
$user_greeting
The greeting that the user get's upon page visit (specfied in My Account or Admin > Users)
$user_email_address
The user's email address (specfied in My Account or Admin > Users)
$user_id
The user's id (set in My Account)
$language_id
The ID of the user's language (specfied in My Account or Admin > Users)
$time_zone
The users's time zone (specfied in My Account)
$user_comments
The comments related to the user (specfied in My Account or Admin > Users)
$user_login_ip
The IP address that the user is currently logged on from
$user_last_login_ip
The last IP address the user logged on from
$is_default_user
A boolean that specifies if the current user is the default one
$user_location
The user's location
$user_organization
The user's organization
$user_group
The group that the user belongs to
$user_birthday
The user's birthday
$is_male
A boolean that specifies if the user is male
$is_female
A boolean that specifies if the user is female
$user_name
The user's full name
$user_first_name
The user's first name
$user_middle_name
The user's middle name (if any)
$user_last_name
The user's last name
Dock specific variablesShow
$show_add_content
Boolean set to specify that the add content link can be displayed
$add_content_text
The text that gets displayed if the add content link is enabled
$add_content_url
The url where the add content link points to
$layout_text
The text to be displayed for the "Change Layout" link
$layout_url
The url where the "Change Layout" link points to
$show_home
Boolean set to specify that the "Home" link can be displayed
$home_text
The text to be displayed for the "Home" link
$home_url
The url where the "Home" link points to
$show_my_account
Boolean set to specify that the "My Account" link can be displayed
$my_account_text
The text to be displayed for the "My Account" link
$my_account_url
The url where the "My Account" link points to
$show_page_settings
Boolean set to specify that the "Page Settings" link can be displayed
$page_settings_text
The text to be displayed for the "Page Settings" link
$page_settings_url
The url where the "Page Settings" link points to
$show_sign_in
Boolean set to specify that the "Sign In" link can be displayed
$sign_in_text
The text to be displayed for the "Sign In" link
$sign_in_url
The url where the "Sign In" link points to
$show_sign_out
Boolean set to specify that the "Sign Out" link can be displayed
$sign_out_text
The text to be displayed for the "Sign Out" link
$sign_out_url
The url where the "Sign Out" link points to
Page specific variablesShow
$selectable
A boolean set that specifies whether a page is "selectable", meaning is it part of the navigation
$page
The current page/layout object
$the_title
The current title of the page
Navigation specific variablesShow
$nav_items
An object that contains all of the pages that are part of the navigation. To set the styling for each navigation item, you must loop through the $nav_items object with a #foreach.
$has_navigation
A boolean set to whether or not there are any pages in the $nav_items object
These methods exist on each sub-object eg. when you're looping through the $nav_items object, you would do $foreach ($nav_item in $nav_items) and you would call $nav_item.METHOD_NAME()
isSelected()
This returns a boolean that indicates whether a navigation item is currently selected.
getURL()
This returns a string that contains the navigation item's URL.
getTarget()
This returns a string that contains the navigation item's target (as defined in the Page Settings).
getName()
This returns a string that contains the navigation item's page name.
hasChildren()
This returns a boolean that indicates whether a navigation item has children.
getChildren()
This returns an object that is has the same methods and variables as the $nav_items object, but contains the current navigation item's children pages.
Misc variablesShow
$update_available_url
The url where the "Update Available" link points to
Utility macrosShow
What's a macro?
A macro is a function that does text manipulation inside of Velocity. You can feed it parameters, and it will print out a string for you. Macros are not like traditional methods or functions, in that they don't return data, and while they can manipulate text based upon the parameters you pass in, it can only print.
#css(FILE_NAME)
Creates a link element like so:
<link href="FILE_NAME" rel="stylesheet" type="text/stylesheet" />
#js(FILE_NAME)
Creates a script element like so:
<script src="FILE_NAME" type="text/javascript"></script>
#language(LANGUAGE_KEY) Prints out the language string related to the LANGUAGE_KEY.
This replaces the following functionality:
$languageUtil.get($company.getCompanyId(), $locale, LANGUAGE_KEY)