Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
venka reddy
Re:Resource Permission
May 29, 2012 6:02 AM
Answer

venka reddy

Rank: Regular Member

Posts: 231

Join Date: March 23, 2011

Recent Posts

Hi,

I am unable to store portlet permissions in permission table.

I am developing plugin.

I have followed following procedure,

1.Create the folder resource-actions under src.

2.Created the "test.xml" file and place under resource-actions.

3.In Test.xml ,

<?xml version="1.0"?>
<resource-action-mapping>
<portlet-resource>
<portlet-name>Test</portlet-name>
<supports>
<action-key>VIEW</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>ADDING</action-key>
<action-key>DELETING</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>CONFIGURATION</action-key>
</guest-unsupported>
</portlet-resource>
</resource-action-mapping>

4.
Create the "default.xml" file and place under resource-actions

In default.xml

--Insert the below contents.

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

5.
Insert the below line just before "</portlet>" in the file "liferay-portlet.xml"

<add-default-resource>true</add-default-resource>

6.
Append the following lines to portlet-ext.properties.

##
## Resource
##
resource.actions.configs=resource-actions/default.xml

7. I have deployed and restart the server.

Nothing happens ,

I have tried by keeping following Sysout it returns false

PortletPermissionUtil.contains(permissionChecker1,plid1,"Test","VIEW").


Is anything i am going wrong?

Its urgent!!!!
Lior Hadaya
RE: Re:Resource Permission
June 27, 2012 5:39 AM
Answer

Lior Hadaya

Rank: Regular Member

Posts: 138

Join Date: January 24, 2012

Recent Posts

Hi, did you ever get this fixed? I'm having problems with this issue too.

Why do you need default.xml?

This is the guide I tried to follow: http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/security-and-permissions

I see that my portlet.properties file does get loaded but I get a null pointer exception for some reason:

 1Loading file:/D:/liferay-portal-6.1.10-ee-ga1/tomcat-7.0.25/temp/18-ccih-blueprint-web-ui/WEB-INF/classes/portlet.properties
 212:01:32,585 ERROR [HotDeployUtil:114] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ccih-blueprint-web-ui
 3com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ccih-blueprint-web-ui
 4        at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46)
 5        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:118)
 6        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:111)
 7        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:188)
 8        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:40)
 9        at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit(PortletContextListener.java:101)
10        at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
11        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:61)
12        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:53)
13        at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
14        at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:55)
15        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
16        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
17        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
18        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
19        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
20        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
21        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
22        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
23        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
24        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
25        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
26        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
27        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
28        at java.lang.Thread.run(Thread.java:619)
29Caused by: java.lang.NullPointerException
30        at com.liferay.portal.security.permission.ResourceActionsImpl.readActionKeys(ResourceActionsImpl.java:852)
31        at com.liferay.portal.security.permission.ResourceActionsImpl.readGroupDefaultActions(ResourceActionsImpl.java:886)
32        at com.liferay.portal.security.permission.ResourceActionsImpl.readModelResource(ResourceActionsImpl.java:996)
33        at com.liferay.portal.security.permission.ResourceActionsImpl.read(ResourceActionsImpl.java:845)
34        at com.liferay.portal.security.permission.ResourceActionsImpl.read(ResourceActionsImpl.java:620)
35        at com.liferay.portal.security.permission.ResourceActionsUtil.read(ResourceActionsUtil.java:275)
36        at com.liferay.portal.deploy.hot.PortletHotDeployListener.processPortletProperties(PortletHotDeployListener.java:664)
37        at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:356)
38        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:115)
39        ... 23 more


I think something is wrong with my permissions xml file:
 1<?xml version="1.0" encoding="UTF-8"?>
 2<resource-action-mapping>
 3    <model-resource>
 4        <model-name>com.smoething.model.MyObject</model-name>
 5        <portlet-ref>
 6            <portlet-name>helloWorld</portlet-name>
 7        </portlet-ref>
 8         <supports>
 9            <action-key>ADD</action-key>
10        </supports>
11         <guest-defaults/>
12        <guest-unsupported/>
13     </model-resource>
14</resource-action-mapping>
Lior Hadaya
RE: Re:Resource Permission
June 27, 2012 6:43 AM
Answer

Lior Hadaya

Rank: Regular Member

Posts: 138

Join Date: January 24, 2012

Recent Posts

Hi,

I managed to fix the permissions xml and the null pointer exception went away:

 1
 2<?xml version="1.0"?>
 3<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.1.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_1_0.dtd">
 4<resource-action-mapping>
 5    <portlet-resource>
 6        <portlet-name>helloWorld</portlet-name>
 7        <permissions>
 8            <supports>
 9                <action-key>ADD_TO_PAGE</action-key>
10                <action-key>CONFIGURATION</action-key>
11                <action-key>VIEW</action-key>
12            </supports>
13            <site-member-defaults>
14                <action-key>VIEW</action-key>
15            </site-member-defaults>
16            <guest-defaults>
17                <action-key>VIEW</action-key>
18            </guest-defaults>
19            <guest-unsupported />
20        </permissions>
21    </portlet-resource>
22</resource-action-mapping>


And in my portlet.properties file I just have:
resource.actions.configs=my-permissions-file.xml

I put them both under WEB-INF/classes.