liferay Portal CE6.2 新开发portlet如何设置权限(Security and Permission resources )

在你新建的PORTLET工程Src 下加入:

resource-actions/default.xml

portlet.properties


default.xml:




	
	
		portlet-name
		
			ADD
			PUBLISH
			DELETE
		
		
			ADD
			VIEW
		
		
			VIEW
		
		
			ADD
			PUBLISH
		
	

	
		portlet-name
		
			ADD
			PUBLISH
			DELETE
		
		
			ADD
			VIEW
		
		
			VIEW
		
		
			ADD
			PUBLISH
		
	


portlet.properties:

include-and-override=portlet-ext.properties

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


浏览页面控制button:


String rootPortletId = portletDisplay.getRootPortletId();
String resourcePK = portletDisplay.getResourcePK();
boolean write = false;
boolean publish = false;
boolean delete = false;
List raList = ResourceActionLocalServiceUtil.getResourceActions(rootPortletId);//取得该portlet所有的resource
write = permissionChecker.hasPermission(scopeGroupId, rootPortletId, resourcePK, "ADD");//检查该用户是否有权限该操作
//示例,调用新增页面













image="add_article"
message="add-web-content"
url="<%= addArticleURL %>"
/>
 
  
如何定义一个role的权限:

传图不方便,只能打了。

控制面板 --- 角色 ---新建一个角色 --- 点击“操作” 选择 “定义权限” --- 站点管理 --- 应用程序 --- 先把新建的PORTLET --- 勾选权限,确认即可。



参考地址:https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/adding-and-deleting-resources

你可能感兴趣的:(liferay,portal)