掲示板

Where to place resource-action-mapping in Liferay-Portlet?

14年前 に Bertolt Meier によって更新されました。

Where to place resource-action-mapping in Liferay-Portlet?

New Member 投稿: 2 参加年月日: 10/03/29 最新の投稿
I am trying to add permissions to a Liferay-Portlet based on the documentation of Liferay. Since the Portlet will be delivered in a war-package, I want to mantain the permission definition of the portlets inside the portlet itself.

I created a file resource-actions.xml with the following content (portlet-name is identical to the name specified in portlet.xml and liferay-*.xml):

<!--?xml version="1.0"?-->
<resource-action-mapping>
<portlet-resource>
    <portlet-name>test-portlet</portlet-name>
    <supports>
        <action-key>SELECT</action-key>
        <action-key>VIEW</action-key>
        <action-key>TEST_PERM</action-key>
    </supports>
    <community-defaults>
        <action-key>VIEW</action-key>
    </community-defaults>
    <guest-defaults>
        <action-key>VIEW</action-key>
    </guest-defaults>
</portlet-resource>
</resource-action-mapping>


There is no model-resource defined, because first I just want to see, if Liferay loads the permissions I set in the mapping file.

I placed the file in the folders - WEB-INF - WEB-INF/classes - inside the portal-impl.jar of Liferay - ...

But the new permission TEST_PERM does not show up under Control Panel -> Roles -> Define Permissions -> Add Portlet Permissions -> test-portlet. Does anybody know, what I am doing wrong here?
14年前 に mahmood A によって更新されました。

RE: Where to place resource-action-mapping in Liferay-Portlet?

Junior Member 投稿: 31 参加年月日: 09/03/29 最新の投稿
I've faced this before and placed resource file in \WEB-INF\classes\resource-actions
my resource-actions.zip is attached. hope it helps

添付ファイル:

14年前 に Bertolt Meier によって更新されました。

RE: Where to place resource-action-mapping in Liferay-Portlet?

New Member 投稿: 2 参加年月日: 10/03/29 最新の投稿
Thanks for the fast reply. I did not get that Liferay automatically parses the resource-actions directory. With your setup I got it working.

Another question:

If I add the path to the portal.properties file in directory WEB-INF/classes as described in the sample-permissions-portlet from the liferay repository:

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


I get a NullPointer-Exception:

Loading file:/home/bme/Workspace/Servers/CATALINA_HOME/webapps/remotecommands-0.0.5-SNAPSHOT/WEB-INF/classes/portlet.properties
15:39:29,543 ERROR [HotDeployUtil:111] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for remotecommands-0.0.5-SNAPSHOT
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for remotecommands-0.0.5-SNAPSHOT
	at com.liferay.portal.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:58)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:130)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:108)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43)
	at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113)
	at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:48)
	at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
	at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1173)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1271)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:296)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
	at com.liferay.portal.security.permission.ResourceActionsUtil._read(ResourceActionsUtil.java:800)
	at com.liferay.portal.security.permission.ResourceActionsUtil.read(ResourceActionsUtil.java:366)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.processPortletProperties(PortletHotDeployListener.java:794)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:294)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127)
	... 17 more


Have you also experienced that?
14年前 に mahmood A によって更新されました。

RE: Where to place resource-action-mapping in Liferay-Portlet?

Junior Member 投稿: 31 参加年月日: 09/03/29 最新の投稿
sorry,i forgot the required line in portal.properties. I think it doesn't parse without this line.
I copied the xml above and got the same errors. By comparing i found that guest-unsupported tag is required. you can add this:

<guest-unsupported>
<action-key>TEST_PERM</action-key>
</guest-unsupported>
thumbnail
13年前 に Thomas Berg によって更新されました。

RE: Where to place resource-action-mapping in Liferay-Portlet?

Regular Member 投稿: 131 参加年月日: 09/09/07 最新の投稿
(Old thread but anyways)

I think the following would suffice:

<guest-unsupported />
13年前 に Jack Daniels によって更新されました。

RE: Where to place resource-action-mapping in Liferay-Portlet?

New Member 投稿: 19 参加年月日: 10/05/17 最新の投稿
Just to be clear, the resource mapping XML needs to be placed in the ROOT Liferay application. There doesn't seem to be a way of doing this without an EXT plugin or something along those lines.

Thanks.