RE: Inherit (propagate) permissions on Document Library does not work as Wi

Jamie Sammons, modified 3 Years ago. New Member Posts: 10 Join Date: 11/8/17 Recent Posts

Hi,

We would like that folders and docs in Document Library inherit the same permissions from their parents. It actually happens on wiki, its folders inherit permissions of their ancestors.  In wiki portlet we saw that this mechanism is implemented in the way explained below.

AtPortletConfigurationPortlet.java  it checks if  permissions.propagation.enabled is true at portal-ext.properties. If that portlet has  PermissionPropagator class implemented, then it is triggered whenever permissions are changed:

 ....

    if (PropsValues.PERMISSIONS_PROPAGATION_ENABLED) {
            Portlet portlet = _portletLocalService.getPortletById(
                themeDisplay.getCompanyId(), portletResource);

            PermissionPropagator permissionPropagator =
                portlet.getPermissionPropagatorInstance();

            if (permissionPropagator != null) {
                permissionPropagator.propagateRolePermissions(
                    actionRequest, modelResource, resourcePrimKey, roleIds);
            }
        }

....

Wiki portlet  has PermissionPropagator implemented this way on WikiPermissionPropagatorImpl:


/**
 * @author Hugo Huijser
 * @author Angelo Jefferson
 */
@Component(
    immediate = true,
    property = {
        "javax.portlet.name=" + WikiPortletKeys.WIKI,
        "javax.portlet.name=" + WikiPortletKeys.WIKI_ADMIN,
        "javax.portlet.name=" + WikiPortletKeys.WIKI_DISPLAY
    },
    service = PermissionPropagator.class
)
public class WikiPermissionPropagatorImpl extends BasePermissionPropagator {

    @Override
    public void propagateRolePermissions(
            ActionRequest actionRequest, String className, String primKey,
            long[] roleIds)
        throws PortalException {

        if (!className.equals(WikiNode.class.getName())) {
            return;
        }

        long nodeId = GetterUtil.getLong(primKey);

        List<WikiPage> wikiPages = _wikiPageLocalService.getPages(
            nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

        for (WikiPage wikiPage : wikiPages) {
            for (long roleId : roleIds) {
                propagateRolePermissions(
                    actionRequest, roleId, WikiNode.class.getName(), nodeId,
                    WikiPage.class.getName(), wikiPage.getResourcePrimKey());
            }
        }
    }

 

Trying to do it in a similar way at Document Library, it does not work and it is never triggered

@Component(
        immediate = true,
        property = {

                "javax.portlet.name=" + "com_liferay_document_library_web_portlet_DLPortlet",
                "javax.portlet.name=" + "com_liferay_document_library_web_portlet_DLAdminPortlet",
                "javax.portlet.name=" + "com_liferay_document_library_web_portlet_IGDisplayPortlet"
        },
        service = PermissionPropagator.class
)
public class MyCustomDLPermissionPropagatorImpl extends BasePermissionPropagator {
 


        @Override
        public void propagateRolePermissions(
                        ActionRequest actionRequest, String className, String primKey,
                        long[] roleIds)
                throws PortalException {

 

                System.out.println("---MyCustomDLPermissionPropagatorImpl has been called!! --);
 


        }
 

It seems that we are missing something or this could not even be the way of doing so.

Any tip or help would be geatly appreciatted

TIA 

Carlos

Lee Jordan, modified 3 Years ago. Expert Posts: 449 Join Date: 5/26/15 Recent Posts

Good info Carlos,

I'm also seeing a similar (maybe same) issue in 7.3, since upgrading from 7.0. I'll need to check the wiki in our environment to see if it matches your findings. If it does I'll be able to submit through the help center as a possible issue with those versions.

Which version are you using?

Jamie Sammons, modified 3 Years ago. New Member Posts: 10 Join Date: 11/8/17 Recent Posts

Hi Lee,

I am very sorry for not answering you before, I did not see your answer til now (too many projects...).

Our version is 7.3.7 CE GA8. We finally found a solution with the help of Jader Jed Francia, who wrote this helpful post ( https://blog.d-vel.com/home/-/blogs/sincronizzare-permessi-tra-modelli-differenti- )

 After many attemps trying to do it as an ext module of DM, we finally just did just a custom (service) bundle and it worked directly. Not also it is easier, it seems the right way to do it.  We guess (we are not very experts on it) that doing it as an ext of DM did not work because the ext did not override something that already existed in the original bundle. In this case, the propagator service was just not implemented in the original bundle. As I said it is a guess, because looking at the docs it does not seem something that cannot be done also as an ext.

HTH

Carlos