title: Insufficient access rights to create a folder
body: <p>In my current project using Filenet P8 Content Platform Engine 5.2.1 with WebSphere 8.5.5.3, Eclipse Mars 4.5.2 and Apache Maven 3.3.1</p>
  
  <p>I need to create folders on the fly, and I'm following this sequence:</p>
  
  <p>I create a new instance of the folder, using the p8admin user:</p>
  
  <pre><code>Folder newFolder = Factory.Folder.createInstance(objectStore, subFolderClass);
  </code></pre>
  
  <p>I add some properties with the method: </p>
  
  <pre><code>newFolder.getProperties().putValue(EcmFilenetConsts.PROPERTY_ID_LOTTO, ((CNEPropertyBean) sgacPropsBean).getIdLotto());
  </code></pre>
  
  <p>I set the parent and folderName properties:</p>
  
  <pre><code>Folder parentFolder = Factory.Folder.getInstance(objectStore, null, parentFolderPath);
  newFolder.set_Parent(parentFolder);
  newFolder.set_FolderName(subFolderName);
  </code></pre>
  
  <p>Then I set some permissions on the folder before performing <code>newFolder.save(RefreshMode.REFRESH)</code>:</p>
  
  <pre><code>AccessPermission permission = Factory.AccessPermission.createInstance();
  permission.set_GranteeName(granteeName);
  permission.set_AccessType(AccessType.ALLOW);
  permission.set_InheritableDepth(-1);
  permission.set_AccessMask(EcmFilenetConsts.ACCESS_READ_FOLDER);
  AccessPermissionList permissions = Factory.AccessPermission.createList();
  permissions.add(permission);
  folder.set_Permissions(permissions);
  </code></pre>
  
  <p>where <code>EcmFilenetConsts.ACCESS_READ_FOLDER = AccessRight.READ.getValue() | AccessRight.READ_ACL.getValue();</code> </p>
  
  <p>If I save the folder and after that I add permissions I have no problems, but I would like to add all the stuffs before saving like the way it happens when using Content Navigator.</p>
  
  <p>Since I need to add only a direct permission on this folder and all the others are inherited by the parent (or by the document class default instance security), I tried to create an empty AccessPermissionList using the factory, but the result is that all the Reader permissions are correctly set but not the Owner permissions.</p>
  
  <p>So when trying to add a subfolder inside this one I get the following:</p>
  
  <blockquote>
    <p>FNRCE0001E - The requester has insufficient access rights to perform the requested operation.</p>
  </blockquote>
  
  <p>If you look at the newly created folder security<a href="https://i.stack.imgur.com/0UyhI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0UyhI.png" alt="Folder security panel"></a></p>
  
  <p>p8admin user, p8admins and p8operators groups are missing and they are part of the default instance security of the folder class.<a href="https://i.stack.imgur.com/MIC15.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MIC15.png" alt="Document class default instance security"></a></p>
  
  <p>Here is the access masks for each permission of the newly created 'on the fly' folder:</p>
  
  <pre><code>DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000008_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DIRECT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000001_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000002_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=FOR_RTI_L01,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  </code></pre>
  
  <p>and here is the security information expected result (obtained by saving the folder and adding security afterwards)</p>
  
  <pre><code>DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000008_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DIRECT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=p8admin,cn=users,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 999415
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DIRECT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: 0
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000001_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DEFAULT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000002_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DEFAULT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=p8admins,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 999415
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DEFAULT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: 0
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=p8operators,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 999415
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_DEFAULT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: 0
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000001_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=AMM_000002_00001,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - Folder GranteeName: cn=FOR_RTI_L01,cn=groups,ou=spcdev,o=priv
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessMask: 131073
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - AccessType: ALLOW
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - PermissionSource: SOURCE_PARENT
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl  - InheritableDepth: -1
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImplTest  - Folder ACCESS FULL CONTROL:999415
  DEBUG com.leonardo.spcic.ecm.filenet.security.SecurityManagerImplTest  - Folder ACCESS READ:131073
  </code></pre>
  
  <p>My doubts are about the fact I'm not sure I'm following the correct sequence or some steps are missing.
  Which is the correct procedure to create a folder on the fly adding properties and security?
  Do I have to set security manually?</p>