Blog Post


Liferay 7: override Resource Permissions

In Liferay 6 when you needed to change default permission set for some resource, then Ext plugin could be used to override such definitions. The reason of Ext using was the point that all permission definitions were stored in portal-impl.jar and Ext was the only way to override it. Starting from Liferay 7 the portal is moving to OSGi architecture where the other rules take place. Since now each OSGi module (e.g. Calendar) has its permissions defined in its own module, and not in the core of the portal. That’s why a new approach should be applied and this post shows how to achieve this.

In OSGi concept, each bundle’s own classpath is of higher priority than the other fragment modules (the ones that supposed to extend the current one). That means that the configuration defined in a fragment module won’t override the target bundle. So how should we proceed then? What should be done to be able to change guest defaults, supported and unsupported permissions for site members and others on a resource? Such possibility appeared only since Liferay 7-GA4, where the following should be done (a Calendar took as an example):

  1. Create a new fragment module that will override Calendar default permissions. It’s bnd.bnd file should include:
    Fragment-Host: com.liferay.calendar.service;bundle-version="2.1.30"
  2. Put into the root of the current module. Its content:
  3. Create a new file /resource-actions/default-ext.xml that will be a copy of Calendar permissions definition with the custom modification. It will look as usual:
    <?xml version="1.0"?>
    <!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.2.0//EN" "">
                <site-member-defaults />
                <!-- Guest default permission VIEW removed -->
                <guest-defaults />
  4. Build the module and deploy it to portal.

After deployment your custom permissions will be applied.

This approach will work only starting from Liferay 7-GA4, but it’s a good beginning that makes Liferay OSGi more flexible and customizable.

Comments (5)

Tags: liferay



Jaakko Aug 30, 2017 at 14:54 #

Seems that some permissions are still in 7-GA4 under portal-impl. For example documentlibrary.xml so that probably cannot be overriden using a custom OSGi module?


Artem Aug 31, 2017 at 10:25 #

Hi, can you give your project for an example? I have problems with overriding resource-actions for asset publisher portlet. Should I put and folder "resource-actions" into the root of my module fragment project or may be in src/main/resources? Should I restart the server after deployment this module fragment project (properties are read at server startup)? Thank you for your attention.


Stanislav Aug 31, 2017 at 15:06 #

Jaakko, it is possible to override documentlibrary.xml under portal-impl. You need to use Ext for this.


Stanislav Aug 31, 2017 at 15:09 #

Hi, Artem, you should put to src/main/resources dir. No need to restart the whole server. Greets.


Antonio Musarra Jul 16, 2019 at 15:54 #

Hi Stanislav. This article it's great ;-)

Leave a Comment