Fórum

Adding Permissions on Liferay 6

Bruno Santos, modificado 13 Anos atrás.

Adding Permissions on Liferay 6

New Member Postagens: 17 Data de Entrada: 30/06/10 Postagens Recentes
Hello all,

I have been trying, as many, to include new permissions on a portlet i developed. I followed the suggested article and some forum messages. In the end i created on a resource-actions folder on the webapps/ROOT/WEB-INF/classes folder with two files inside: default.xml and test-portlet.xml.

default.xml looks like:

<!--?xml version="1.0"?-->

<resource-action-mapping>
	<resource file="resource-actions/test-portlet.xml" />
</resource-action-mapping>


and test-portlet.xml looks like:

<!--?xml version="1.0"?-->

<resource-action-mapping>
<portlet-resource>
		<portlet-name>test-portlet</portlet-name>
		<supports>
			<action-key>TEST_PERM</action-key>
			<action-key>CONFIGURATION</action-key>
			<action-key>VIEW</action-key>
		</supports>
		<community-defaults>
			<action-key>VIEW</action-key>
		</community-defaults>
		<guest-defaults>
			<action-key>VIEW</action-key>
		</guest-defaults>
		<guest-unsupported>
			<action-key>TEST_PERM</action-key>
		</guest-unsupported>
	</portlet-resource>
</resource-action-mapping>


I did change portal-ext.properties file at first with the line:

resource-actions-configs=resource-actions/test-portlet.xml

But then i noticed that the following errors happened with and without this line (during the server start):

10:14:29,145 ERROR [AdvancedPermissionChecker:651] com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Layout#UPDATE
com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Layout#UPDATE


and

10:14:29,107 ERROR [AdvancedPermissionChecker:651] com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Layout#VIEW
com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Layout#VIEW


and

10:14:29,079 ERROR [AdvancedPermissionChecker:651] com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Group#MANAGE_LAYOUTS
com.liferay.portal.NoSuchResourceActionException: com.liferay.portal.model.Group#MANAGE_LAYOUTS


It seems Liferay is unable to load permissions from inside the portal-impl.jar? Any ideas about what is happening?

Thank you
Bruno Santos
Bruno Santos, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 17 Data de Entrada: 30/06/10 Postagens Recentes
Anybody can help?

Thanx a lot
Bruno Santos, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 17 Data de Entrada: 30/06/10 Postagens Recentes
Anyone?

Thank you
Oliver Bayer, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Bruno,

I'm not sure if that is causing the errors on startup but I think inside the default.xml you should keep the original mappings and only add your new mapping at the end. Maybe you can try the following:
<!--?xml version="1.0"?-->

<resource-action-mapping>
   <resource file="resource-actions/portal.xml" />
   <resource file="resource-actions/announcements.xml" />
   <resource file="resource-actions/blogs.xml" />
   <resource file="resource-actions/bookmarks.xml" />
   ...
   <resource file="resource-actions/wiki.xml" />
   <resource file="resource-actions/test-portlet.xml" />
</resource-action-mapping>

HTH Oli
Bruno Santos, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 17 Data de Entrada: 30/06/10 Postagens Recentes
Hello all,

Finally I was able to make the permissions system work, and sadly I have to say that the documentation refered above is WRONG! At least for liferay 6.0.5

Next I will tell you how i did it, mentioning what is wrong on the documentation:

1. Create the permission xml

I can name the file with anything. Mine was test-portlet.xml. You have to put it inside the folder resource-actions inside webapps/ROOT/WEB-INF/classes.

The format has to be this:

<!--?xml version="1.0"?-->
<resource-action-mapping>
	<portlet-resource>
        <portlet-name>PLUGIN_ID</portlet-name>
		<permissions>
			<supports>
				<action-key>TEST_PERM</action-key>
				<action-key>CONFIGURATION</action-key>
				<action-key>VIEW</action-key>
				<action-key>TEST_PERM2</action-key>
				<action-key>TEST_PERM3</action-key>
			</supports>
			<community-defaults>
				<action-key>TEST_PERM</action-key>
			</community-defaults>
			<guest-defaults>
				<action-key>TEST_PERM</action-key>
			</guest-defaults>
			<guest-unsupported>
				<action-key>TEST_PERM</action-key>
			</guest-unsupported>
		</permissions>
    </portlet-resource>
</resource-action-mapping>


First error: you have to use the <permissions> tag to wrap the permissions. Otherwise liferay will not see the permissions. This is not on the documentation.

Second error: the documentation says you can use the portlet name you put on the portlet.xml. You can't. You have to use the Plugin ID. You can find it on the control panel on the plugins configuration area. Just select the portlet you want to change and check for the Plugin ID.

2. Create the default-aux.xml

Again any name will do but default.xml. With this name I think liferay gets confused with the deafult xml file inside portal-impl.jar. the format is:

<!--?xml version="1.0"?-->
<resource-action-mapping>
	<resource file="resource-actions/test-portlet.xml" />
</resource-action-mapping>


Third error: You have to change the portal-ext.properties file. Nobody tells you that there. You have to insert the following line:

resource.actions.configs=resource-actions/default.xml,resource-actions/default-aux.xml


With this line liferay will load permissions for the default portlets and also yours, without any need to repeat code.

3. I18n everything

I did not try not to do this move but i think usually you'll need to translate the permission actions. for that use the language files of liferay and insert one line for each new permission with the format:

action.TEST_PERM=Translation

Then reboot the server and voila! When you go to the configuration popup on the portlet instances you can see the new permissions emoticon

Hope this helps lots of people. Liferay Staff please keep the documentation more up-to-date, I spent lots of hours on this because i thought this particular documentation page was correct.

Documentation was always the achiles heel of Liferay, hope that changes soon.

Regards
Bruno Santos
Sergey Stepanenko, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

Junior Member Postagens: 47 Data de Entrada: 01/06/10 Postagens Recentes
Thanks for the sharing.

Having digging this issue couple of hours before this thread and some 3 hrs after have found that this config does not work for me with 6.0.5.

However. Here's my solution. It came from sample-permissions-portlet-5.2.0.1 which could be found in download area.

portal.properties - must be in WEB-INF/classes and should be like:
include-and-override=portlet-ext.properties
resource.actions.configs=resource-actions/sample.xml

actions config xml could be everything, I think...

sample.xml - must be in WEB-INF/classes/resource-actions like this:
<?xml version="1.0"?>
<resource-action-mapping>
<portlet-resource>
<portlet-name>Profile</portlet-name>
<supports>
<action-key>VIEW</action-key>
<action-key>EDIT</action-key>
<action-key>ADD_ENTRY</action-key>
<action-key>SEARCH</action-key>
</supports>
<community-defaults>
<action-key>VIEW</action-key>
</community-defaults>
<guest-defaults>
<!-- <action-key>VIEW</action-key> -->
</guest-defaults>
<guest-unsupported>
<action-key>ADD_ENTRY</action-key>
<action-key>EDIT</action-key>
<action-key>VIEW</action-key>
</guest-unsupported>
</portlet-resource>
</resource-action-mapping>

Note that portlet-name is as it is in portlet.xml file.

Seems like this is it! No further configurations beyond traditional plug-in is necessary.

For what I tested so far (10 minutes after the solution) - permissions are available in UI (and written to resourceaction db table) and jsp check for haspermission seems to be working.

Turned out to be much simpler and easier than set-ups I had to do reading couple of wiki's...

Please also note that main key points are that resource actions config xml could be whatever You like (not sure about default.xml - but in mentioned sample portlet it is), locations of portlet.properties and portlet name. Everything else should be according to wiki's and sample portlet. sample.xml is from my testing portlet - so discard/change its contents.
Miguel Coxo, modificado 13 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 16 Data de Entrada: 01/03/10 Postagens Recentes
Hi there,

So here is how i'm currently adding new actions to liferay.

First you need to create the file "portlet.properties" inside your portlet/hook src folder (in my case "WEB-INF/src").

In this file you type: "resource.actions.configs=resource-actions/default.xml" to say that your actions are inside "src/resource-actions/default.xml".

In my case i have the following inside default.xml:


<!--?xml version="1.0" encoding="UTF-8"?-->
<resource-action-mapping>
	<portlet-resource>
		<portlet-name>portlet-name-like-portlet.xml</portlet-name>
		<supports>
			<action-key>create</action-key>
			<action-key>read</action-key>
			<action-key>update</action-key>
			<action-key>delete</action-key>
		</supports>
		<community-defaults>
            <action-key>VIEW</action-key>
        </community-defaults>
        <guest-defaults>
            <action-key>VIEW</action-key>
        </guest-defaults>
        <guest-unsupported />
	</portlet-resource>
</resource-action-mapping>


guest-defaults and guest-unsupported are required. Without them i can't successfully deploy my new actions.

You can now deploy your portlet and your actions will be created. You can even attribute theses actions to roles in the control panel =).

Hope it helps.
A S, modificado 11 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 19 Data de Entrada: 30/04/12 Postagens Recentes
Hey,

Must admit, I'm totally lost on this one.

I've set up my files as described above, and put in the XML as well. I have 2 portlets, one a display and one an admin which lives in the control panel. For simplicity I set both up exactly the same with 2 extra bespoke permissions in there. I've then gone to the control panel, Roles, found a role and gone to "define Permissions". This is where I totally lost any understanding of what it's doing.

In the "Add Permissions" drop-down there are headers, under which my portlets appear. Given that the permissions are defined as no more than a copy paste job...

Under the "Site Content" heading my admin portlet has the default permissions + one of my extra ones. The normal portlet has the same.

Under the "Site Applications" heading the admin portlet doesn't appear, the normal one shows all the default and my additional permissions.

Under the "Control Panel" heading the normal portlet doesn't appear and the admin does, with an extra default "Access in Control Panel" permission, otherwise, nothing more than the defaults, none of my extra permissions.

So, I have 2 portlets, an absolute duplicate of permission settings and 3 different outcomes for each. Totally lost.

Any hints most welcome!

Cheers,

Alex
nguyen van thanh van thanh, modificado 10 Anos atrás.

RE: Adding Permissions on Liferay 6

New Member Postagens: 2 Data de Entrada: 16/09/13 Postagens Recentes
Change: resource-actions-configs=resource-actions/test-portlet.xml to: resource-actions-configs=resource-actions/default.xml in file portal-ext.properties
OR add line: resource.actions.configs=resource-actions/default.xml in file docroot/WEB-INF/src/portlet.properties.
sri p, modificado 9 Anos atrás.

RE: Adding Permissions on Liferay 6

Junior Member Postagens: 85 Data de Entrada: 22/01/11 Postagens Recentes
Can any one help me ? I am not able to see the model resource permissions in the portlet permissions section. I could see them in liferay database though.

Please see the following link for more information.
liferay custom permissions

I appreciate any help.

Thanks,
Sri