Foros de discusión

Re:Resource Permission

venka reddy, modificado hace 11 años.

Re:Resource Permission

Regular Member Mensajes: 231 Fecha de incorporación: 23/03/11 Mensajes recientes
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, modificado hace 11 años.

RE: Re:Resource Permission

Regular Member Mensajes: 138 Fecha de incorporación: 24/01/12 Mensajes recientes
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:

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


I think something is wrong with my permissions xml file:
<!--?xml version="1.0" encoding="UTF-8"?-->
<resource-action-mapping>
    <model-resource>
        <model-name>com.smoething.model.MyObject</model-name>
        <portlet-ref>
            <portlet-name>helloWorld</portlet-name>
        </portlet-ref>
         <supports>
            <action-key>ADD</action-key>
        </supports>
         <guest-defaults />
        <guest-unsupported />
     </model-resource>
</resource-action-mapping>
Lior Hadaya, modificado hace 11 años.

RE: Re:Resource Permission

Regular Member Mensajes: 138 Fecha de incorporación: 24/01/12 Mensajes recientes
Hi,

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


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

<resource-action-mapping>
    <portlet-resource>
        <portlet-name>helloWorld</portlet-name>
        <permissions>
            <supports>
                <action-key>ADD_TO_PAGE</action-key>
                <action-key>CONFIGURATION</action-key>
                <action-key>VIEW</action-key>
            </supports>
            <site-member-defaults>
                <action-key>VIEW</action-key>
            </site-member-defaults>
            <guest-defaults>
                <action-key>VIEW</action-key>
            </guest-defaults>
            <guest-unsupported />
        </permissions>
    </portlet-resource>
</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.