Message Boards

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Default Liferay Permissions
Answer
12/11/12 10:50 PM
Hi Jack,

XMLPortletFactory creates resource_actions/default.xml with the default Liferay permissions for each entity.  However, it seems that the default permissions are not applied when a new entity instance is created.

I believe that the missing piece is that addGuestPermissions and addGroupPermissions have to be set to 'true' in the ServiceContext to trigger the application of the defaults.

I suggest the following changes to ensure that when a new entity is created it is assigned the permissions from default.xml.

In Portlet_XXXXXXPortlet_java.vm, in the showViewEdit... method
1        renderRequest.setAttribute("editType", editType);

In Portlet_editXXXXXX_jsp.vm
1<jsp:useBean id="editType" class="java.lang.String" scope="request"/>
2...
3<c:if test='<%= "add".equals(editType) %>'>
4    <aui:input type="hidden" name="addGuestPermissions" value="true"/>
5    <aui:input type="hidden" name="addGroupPermissions" value="true"/>
6</c:if>

With these changes, the permissions were initialized as I expected.  Let me know though if I am misinterpretting what was intended.

If you agree that this fix makes sense please just let me know and I will check in these changes.

Thanks!
Deb

RE: Default Liferay Permissions
Answer
12/12/12 3:07 PM as a reply to Deb Troxel.
Hi Deb,

Did you try setting those permissions in resource-actions/default.xml



<guest-defaults>

or


<site-member-defaults>


?

RE: Default Liferay Permissions
Answer
12/13/12 5:16 PM as a reply to Juan G..
Hi Juan,

Yes, those are the elements that I'm looking at.

I created a basic example (using XMLPortletFactory 2.2 / Liferay 6.1.1-ce-ga2) to illustrate.  XMLPortletFactory generates resource-actions/default.xml, including the following section for my sample entity:
 1<model-resource>
 2        <model-name>org.xmlportletfactory.example01.permcheck.model.permcheck</model-name>
 3        <portlet-ref>
 4            <portlet-name>permcheck</portlet-name>
 5        </portlet-ref>
 6        <supports>
 7            <action-key>DELETE</action-key>
 8            <action-key>PERMISSIONS</action-key>
 9            <action-key>UPDATE</action-key>
10            <action-key>VIEW</action-key>
11        </supports>
12        <site-member-defaults>
13            <action-key>DELETE</action-key>
14            <action-key>UPDATE</action-key>
15            <action-key>VIEW</action-key>
16        </site-member-defaults>
17        <guest-defaults>
18            <action-key>VIEW</action-key>
19        </guest-defaults>
20        <guest-unsupported>
21            <action-key>PERMISSIONS</action-key>
22        </guest-unsupported>
23    </model-resource>
24

When I create a 'permcheck' entity entry using the XMLPortletFacotry generated admin portlet, I would expect the <guest-defaults> and <site-member-defaults> permissions to be applied by default, but when I create an entry and then click Actions / Permissions, only the Owner permissions are set.  The Guest VIEW and Site Member DELETE, UPDATE, and VIEW that were set in default.xml are not checked.

It looks to me that the xxLocalServiceImpl classes need either the actual array of permissions that should be applied or the addGroup/GuestPermissions flags to be passed in the request:
 1
 2        if (serviceContext.isAddGroupPermissions() ||
 3            serviceContext.isAddGuestPermissions()) {
 4
 5            addEntryResources(
 6                retVal, serviceContext.isAddGroupPermissions(),
 7                serviceContext.isAddGuestPermissions());
 8        }
 9        else {
10            addEntryResources(
11                retVal, serviceContext.getGroupPermissions(),
12                serviceContext.getGuestPermissions());
13        }

When I made the changes described in my original post then the permissions from default.xml were applied when creating the new entry.

Hope this is a better explanation of my issue.

Thanks!  Deb

RE: Default Liferay Permissions
Answer
12/13/12 5:43 PM as a reply to Deb Troxel.
Ok Deb,

If Jack doesn't say anything against it..

let's commit it!!  emoticon

Thanks very much again for you help.

RE: Default Liferay Permissions
Answer
12/13/12 5:49 PM as a reply to Juan G..
Thanks Juan!

Jack, please post here or email me to let me know how you would like to proceed.

RE: Default Liferay Permissions
Answer
12/13/12 6:22 PM as a reply to Deb Troxel.
Hola Deb!! emoticon

         Sorry for the delay, I am in the middle of a month long tecnical dossier, and don't get to see the forum very often. Of course, commit please. Is great!!! Thanks very very much again.

         If you are in the middle of a project, try to download las updates from sourceforge, there has been a couple of commits since 2.2 release

  Saludos, Jack.