« Back to Wiki - Need Updating

Overwrite Liferay Portlet Permissions

Table of Contents [-]

There are times when you want to change the default and available permissions of Liferay portlets. The default permissions are found in the configuration screen -> permissions tab for each Liferay portlet and their respective modules. For example you can set the permissions for the Document Library Portlet at large, and also at the Folder and File level. This document will help you overwrite Liferay portlet permissions files without touching the source code.

Disclaimer: This document will only help you change what you see in the configuration screen and permissions tabs. This document will NOT implement permissions for you. If you want to implement custom permissions, you can use this document in conjunction with [http://content.liferay.com/4.0.0/docs/developers/ch07.html]

For a more up to date explanation of permissions read http://www.liferay.com/web/jshum/blog/-/blogs/permissionchecker-explained

Key Concept#

The permissions for all portlets are held inside /resource-actions/$portletname.xml files, so the goal would be to overwrite the $portletname.xml resource-actions file. Since there is a lot of mapping inside Liferay code, we need to include the files that map up to $portletname.xml.

Overwrite#

In the Source Code, there are 3 files and some related code lines to pay attention to:

      1. portal-ejb/classes/portal.properties
    1. resource.actions.configs=resource-actions/default.xml
      1. portal-ejb/classes/resource-actions/default.xml
    2. <resource-action-mapping>
    3. <resource file="resource-actions/$portletname.xml" />
    4. </resource-action-mapping>
      1. portal-ejb/classes/resource-actions/$portletname.xml

Notice how the files map to each other! In order to overwrite $portletname.xml we need to duplicate this structure and mapping in the EXT environment.

Create or modify these 3 files:

      1. ext-ejb/classes/portal-ext.properties
    1. resource.actions.configs=resource-actions/default.xml,resource-actions/default-ext.xml
      1. ext-ejb/classes/resource-actions/default-ext.xml
    2. <resource-action-mapping>
    3. <resource file="resource-actions/$portletname.xml" />
    4. </resource-action-mapping>
      1. ext-ejb/classes/resource-actions/$portletname.xml

Note: If you are not using an extension environment but modifying an existing installation of Liferay just create those files and put them in the application classpath.

0 Attachments
27527 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments