<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>LF 7.0 - Override default permissions defined inside of documentlibrary.xml</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110927774" />
  <subtitle>LF 7.0 - Override default permissions defined inside of documentlibrary.xml</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110927774</id>
  <updated>2026-04-06T18:00:00Z</updated>
  <dc:date>2026-04-06T18:00:00Z</dc:date>
  <entry>
    <title>RE: LF 7.0 - Override default permissions defined inside of documentlibrary</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110955720" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110955720</id>
    <updated>2018-09-14T18:12:07Z</updated>
    <published>2018-09-14T18:12:07Z</published>
    <summary type="html">&lt;p&gt;Looks like you already figure out a solution, but just wanted to post
  an alternative in case someone needs more logic like I did.&lt;/p&gt;
&lt;p&gt;I created a JournalArticleLocalServiceWrapper and overrided the
  addArticle method and based on a condition, changed the permissions:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;
    protected Map&amp;lt;Long, String[]&amp;gt; getRoleIdsToActionIds(JournalArticle journalArticle) {
        Map&amp;lt;Long, String[]&amp;gt; roleIdsToActionIds = new HashMap&amp;lt;&amp;gt;();

        roleIdsToActionIds.put(ROLE_GUEST_ID, new String[0]);
        roleIdsToActionIds.put(ROLE_EMPLOYEE_ID, new String[] {ActionKeys.VIEW});
        roleIdsToActionIds.put(ROLE_SITE_MEMBER_ID, new String[0]);

        /*
        if (structureFieldValue == x) {
            add more permissions here
        }*/

        return roleIdsToActionIds;
    }

    protected void updateResourcePermissions(JournalArticle journalArticle)
        throws PortalException {

        Map&amp;lt;Long, String[]&amp;gt; roleIdsToActionIds = getRoleIdsToActionIds(journalArticle);

        _resourcePermissionLocalService.setResourcePermissions(
            journalArticle.getCompanyId(), JournalArticle.class.getName(),
            ResourceConstants.SCOPE_INDIVIDUAL,
            String.valueOf(journalArticle.getResourcePrimKey()),
            roleIdsToActionIds);
    }&lt;/pre&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2018-09-14T18:12:07Z</dc:date>
  </entry>
  <entry>
    <title>RE: LF 7.0 - Override default permissions defined inside of documentlibrary</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110930768" />
    <author>
      <name>Seth Burden</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110930768</id>
    <updated>2018-09-11T19:40:32Z</updated>
    <published>2018-09-11T19:40:32Z</published>
    <summary type="html">&lt;p&gt;I have found a working solution and wanted to share in-case anyone
  else is running into a similar issue. Hopefully there aren’t any
  hidden/unforeseen pitfalls but it seems to be working fine in my local
  environment so far. &lt;/p&gt;
&lt;p&gt;If using the Eclipse Liferay IDE&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Start a new Liferay Module Project Fragment&lt;/li&gt;
  &lt;li&gt;Select 'com.liferay.document.library.web-1.4.2.jar' as the Host
    OSGi Bundle&lt;/li&gt;
  &lt;li&gt;Click the 'liferay +' icon to select from the list of available
    files to override&lt;/li&gt;
  &lt;li&gt;Select 'resource-actions/default.xml'&lt;/li&gt;
  &lt;li&gt;Click Finish&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;After project creation, open default-ext.xml&lt;/p&gt;
&lt;p&gt;Note: Only a couple of ‘portlet-resource’ elements are defined. It
  does not include any ‘model-resource’ elements which I added manually
  as described below. &lt;/p&gt;
&lt;p&gt;See the source for documentlibrary.xml&lt;/p&gt;
&lt;p&gt;
  &lt;a href="https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/resource-actions/documentlibrary.xml"&gt;https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/resource-actions/documentlibrary.xml&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;...there is a model-resource element for
  'com.liferay.document.library.kernel.model.DLFolder' within documentlibrary.xml&lt;/p&gt;
&lt;p&gt;Copy the model-resource element into default-ext.xml and remove/add
  any default permissions. I have attached a copy of my default-ext.xml.&lt;/p&gt;
&lt;p&gt;Build/Deploy the module. Go to documents and media and click to
  create a new folder. You should see the default permissions checked or
  not checked based on what you defined in default-ext.xml.&lt;/p&gt;
&lt;p&gt;Warning – this may impact any existing folders already existing in
  your documents and media libraries. I had a small library set up
  locally and could not access the parent folder contents anymore. New
  folders and contents once the module is deployed are fine. I’m not
  sure if something I tried before I implemented this solution messed up
  the existing parent folder of my library or what. This is just a fair
  warning in-case you have anything important setup locally for
  something else. The error I was seeing is – ‘…Someone may be trying to
  circumvent the permission checker’. However, I created the entire
  library as admin and was logged in as the admin when clicking on it
  (which is when the error occurs on the console) so I’m not sure what
  happened to corrupt my folder.&lt;/p&gt;</summary>
    <dc:creator>Seth Burden</dc:creator>
    <dc:date>2018-09-11T19:40:32Z</dc:date>
  </entry>
  <entry>
    <title>LF 7.0 - Override default permissions defined inside of documentlibrary.xml</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110927773" />
    <author>
      <name>Seth Burden</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110927773</id>
    <updated>2018-09-11T14:38:17Z</updated>
    <published>2018-09-11T14:38:17Z</published>
    <summary type="html">&lt;p&gt;In Liferay 7.0, how do I override default permissions defined inside
  of documentlibrary.xml? I want some of the automatically checked
  permissions on the User role to be removed when folders are created
  and the Access permission to be automatically checked. In 6.2, we were
  able to override by modifying documentlibrary.xml, placing it in a
  folder named resource-actions and then placing the resources-actions
  folder at \liferay-portal-6.2-ee-sp11\tomcat-7.0.42\webapps\ROOT\WEB-INF\classes&lt;/p&gt;
&lt;p&gt;What the new way to accomplish this within Liferay 7.0? Thank you in
  advance for anyone who can help on this!&lt;/p&gt;</summary>
    <dc:creator>Seth Burden</dc:creator>
    <dc:date>2018-09-11T14:38:17Z</dc:date>
  </entry>
</feed>
