从Portlet除去定制权限/操作 [英] Removing Custom Permissions/Actions from a Portlet

查看:57
本文介绍了从Portlet除去定制权限/操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够根据Liferay Plugins SDK中的此示例定义自定义portlet操作/权限

I have been able to define custom portlet actions/permissions based on this example in Liferay Plugins SDK

https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-permissions-portlet

我想知道我需要采取哪些必要步骤,以从portlet中删除自定义portlet操作/许可(不是模型许可).

I want to know the necessary steps I need to take to remove the custom portlet actions/permissions (not model permissions) from a portlet.

我记得观察到,当我重新部署具有修改的自定义操作/权限的portlet时,旧的自定义操作/权限仍然存在.

I remember observing that when I re-deploy a portlet with modified custom actions/permissions, the old custom actions/permissions stick around.

我尝试从Tomcat的web应用程序中删除portlet文件夹,并且该文件夹已成功取消注册.但是,当我再次部署portlet并从相应的XML中删除了自定义操作/权限后,仍然可以在角色的定义权限"中看到这些权限.

I tried deleting the portlet folder from Tomcat's webapps and it was successfully unregistered. But after I deploy the portlet again with the custom actions/permissions removed from the corresponding XML, I can still see the permissions in the Define Permissions of a Role.

我尝试在Liferay的服务器管理"的控制面板中清除权限设置,但是它没有做任何更改(本来应该做的).

I tried clearing permissions setting in Server Administration of Liferay's control panel, but it didn't change anything (it wasn't supposed to).

在重新部署具有已删除/修改的权限的portlet并重新启动服务器之后,我仍然看到分配给该portlet的自定义操作/权限,但是当我选择该portlet时,则看不到已删除的权限,是我所需要的.

After re-deploying the portlet with the removed/modified permissions and restarting the server, I still see the custom actions/permissions assigned to the portlet, but when I select the portlet, then I don't see the removed permissions which is what I need.

是否取消部署Portlet会从Liferay Portal和门户数据库中删除所有相关的自定义操作/权限? 还是我需要拨打单独的liferay服务电话来做到这一点? 对此表示感谢.

Does un-deploying a portlet remove all the associated custom actions/permissions from Liferay Portal and the portal's Database? Or do I need to make separate liferay service calls to do that? Any inputs in this regard are really appreciated.

Liferay版本:6.1.2 CE GA3

Liferay Version: 6.1.2 CE GA3

portlet.properties

portlet.properties

include-and-override=portlet-ext.properties
language.bundle=content.Language
resource.actions.configs=resource-actions/default.xml

resource-actions/default.xml

resource-actions/default.xml

<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.2.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_2_0.dtd">

<resource-action-mapping>
    <portlet-resource>
        <portlet-name>1</portlet-name>
        <permissions>
            <supports>
                <action-key>ADD_SOMETHING</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>

content/language.properties

content/language.properties

action.ADD_SOMETHING=Add Something

portlet.xml

portlet.xml

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
    <portlet>
        <portlet-name>1</portlet-name>
        <display-name>Sample Permissions</display-name>
        <portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
        <init-param>
            <name>view-template</name>
            <value>/view.jsp</value>
        </init-param>
        <expiration-cache>0</expiration-cache>
        <supports>
            <mime-type>text/html</mime-type>
        </supports>
        <resource-bundle>content.Language</resource-bundle>
        <portlet-info>
            <title>Sample Permissions</title>
            <short-title>Sample Permissions</short-title>
            <keywords>Sample Permissions</keywords>
        </portlet-info>
        <security-role-ref>
            <role-name>administrator</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>guest</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>power-user</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>user</role-name>
        </security-role-ref>
    </portlet>
</portlet-app>

liferay-portlet.xml

liferay-portlet.xml

<liferay-portlet-app>
    <portlet>
        <portlet-name>1</portlet-name>
        <instanceable>true</instanceable>
    </portlet>
    <role-mapper>
        <role-name>administrator</role-name>
        <role-link>Administrator</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>guest</role-name>
        <role-link>Guest</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>power-user</role-name>
        <role-link>Power User</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>user</role-name>
        <role-link>User</role-link>
    </role-mapper>
</liferay-portlet-app>

liferay-display.xml

liferay-display.xml

<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">

<display>
    <category name="category.sample">
        <portlet id="1" />
    </category>
</display>

liferay-plugin-package.properties

liferay-plugin-package.properties

name=Sample Permissions
module-group-id=liferay
module-incremental-version=1
tags=sample
short-description=This plugin shows how to use the permission service from a portlet.
long-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL
liferay-versions=6.2.0+

portal-dependency-jars=\
    jstl-api.jar,\
    jstl-impl.jar

portal-dependency-tlds=\
    c.tld

web.xml

<?xml version="1.0"?>

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <jsp-config>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
        </taglib>
    </jsp-config>
</web-app>

上面的代码可以正常工作,我可以在定义角色的权限"中看到权限.

The above code works perfectly and I am able to see the permissions in Define Permissions for role.

我要查找的是,如果我将ADD_SOMETHING操作修改为ADD_SOMETHING_ELSE或 删除ADD_SOMETHING操作并添加新的操作键MY_NEW_ACTION, 是否将ADD_SOMETHING权限从门户网站中完全删除?如果不是,我需要采取什么步骤来删除ADD_SOMETHING权限? 重新部署并重新启动服务器足以确保执行这些操作?

What I am looking for is, if I modify ADD_SOMETHING action to ADD_SOMETHING_ELSE or Remove ADD_SOMETHING action and add a new action key MY_NEW_ACTION, would the ADD_SOMETHING permission be removed completely from the portal? And if not what are the steps that I need to take to remove the ADD_SOMETHING permission? Redeploy and Restart the server is enough to ensure these actions?

根据Prakash的回应

Based on Prakash's Response

//Ashok - Beanshell Script for ResourceAction Table Service
import com.liferay.portal.model.ResourceAction;
import com.liferay.portal.service.ResourceActionLocalServiceUtil;
import java.util.List;

List resourceList=ResourceActionLocalServiceUtil.getResourceActions(com.liferay.portal.kernel.dao.orm.QueryUtil.ALL_POS, com.liferay.portal.kernel.dao.orm.QueryUtil.ALL_POS);

for (ResourceAction resourceAction:resourceList) {
    System.out.println("Resource Name: " + resourceAction.getActionId());
    System.out.println("Resource Name: " + resourceAction.getName());
   //ResourceActionLocalServiceUtil.deleteResourceAction(giveActionIdHereForDeleting);
}

推荐答案

在取消部署Portlet或重新启动服务器时,不会从数据库中删除该Portlet的权限.为什么?

Permissions are not removed from database for the portlet either when you un-deploy the portlet, or when you restart the server. why?

因为取消部署Portlet并不一定意味着需要从数据库中删除数据,所以Portlet可以重新部署多次.因此,除非通过数据库或某些服务手动删除数据,否则liferay正确地采取了保持数据完整的安全途径.就像您为自定义资产存储的数据一样,这些权限也被视为数据.

Because, undeploying a portlet does not necessarily mean the data needs to be removed from the database, the portlet can be redeployed many times. So liferay correctly takes the safe route of keeping the data intact unless it is manually deleted through the database or through some service. And the permissions are considered as data just like you have data stored for your custom asset.

因此,您可以通过创建一些服务或通过控制面板→中的bean脚本面板删除ResourceAction表中的权限. 服务器管理脚本选择Beanshell .您还需要注意bitwiseValue和ResourcePermission表中已设置的权限.

So you can delete the permissions from ResourceAction table by creating some service or through the beanshell scripting panel in control PanelServer AdministrationScriptingSelect Beanshell. You would also need to take care of the bitwiseValue and the permissions already set in the ResourcePermission table.

我建议在ResourceAction表中重命名该权限,而不是删除和添加新权限,这可能会变得很复杂.

I would suggest renaming the permission in the ResourceAction table rather than deleting and adding new, it might get complicated.

希望这会有所帮助.

这篇关于从Portlet除去定制权限/操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆