I have already read all topics about liferay. I have read a lot of tutorials, but unfortunately i couldn't understand the concept of liferay permission.
I would be grateful if you could answer my questions.
Only i understand that liferay portlet has two types of permissions: model
and portlet
.
For Example:
<?xml version="1.0" encoding="UTF-8"?>
<resource-action-mapping>
<portlet-resource>
<portlet-name>testFCK</portlet-name>
<permissions>
<supports>
<action-key>ADD_FOO</action-key>
<action-key>VIEW</action-key>
<action-key>DO_TRICS</action-key>
</supports>
<community-defaults>
<action-key>VIEW</action-key>
<action-key>ADD_FOO</action-key>
</community-defaults>
<guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
<guest-unsupported>
<action-key>DO_TRICS</action-key>
</guest-unsupported>
</permissions>
</portlet-resource>
<model-resource>
<model-name>me.pd.test.model.Foo</model-name>
<portlet-ref>
<portlet-name>testFCK</portlet-name>
</portlet-ref>
<permissions>
<supports>
<action-key>DELETE</action-key>
<action-key>UPDATE</action-key>
<action-key>VIEW</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>UPDATE</action-key>
<action-key>DELETE</action-key>
</guest-unsupported>
</permissions>
</model-resource>
</resource-action-mapping>
I can use:
<action-key>ADD_FOO</action-key>
<action-key>VIEW</action-key>
<action-key>DO_TRICS</action-key>
in my portlet class to check if user has permission to do something like:
try {
PortletPermissionUtil.check(themeDisplay.getPermissionChecker(), plid, PortalUtil.getPortletId(actionRequest), "ADD_FOO");
} catch(PrincipalException e){
System.out.println("NO ADD_FOO ACTION");
}
Question 1:
What does
<community-defaults>
<action-key>VIEW</action-key>
<action-key>ADD_FOO</action-key>
</community-defaults>
<guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
means? I create a community and add user(user1) to it and when i check user for permission he dosen't have it. Where should i use checking?
There are many example to use addResources before or after STORE enty to base:
resourceLocalService.addResources(foo.getCompanyId(),
foo.getGroupId(), foo.getUserId(),
Foo.class.getName(),
foo.getPrimaryKey(), false,
true, true);
Question 2:
Why should i use it and what do the following last 3 parameters mean? I can't understand which permission they give to Community or Guests?
ResourceLocalServiceUtil.addResources(
entry.getCompanyId(), entry.getGroupId(), entry.getUserId(),BlogsEntry.class.getName(), entry.getPrimaryKey().toString(),
false,
addCommunityPermissions,
addGuestPermissions);
How does addResources
influence permissions on my entrys?
Question 3:
How i can use <model-resource>
's actions and when i should use it?
Thank you in advance.
Best regards