title: Can't set permissions on Filenet P8 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'm trying to add some permissions to an existing folder using the following code:</p>
  
  <pre><code>public Folder addFolderPermissions(Folder folder) {
  
      AccessPermission permission = Factory.AccessPermission.createInstance();
      permission.set_GranteeName("AMM_000072_00001");
      permission.set_AccessType(AccessType.ALLOW);
      permission.set_InheritableDepth(-1);
      permission.set_AccessMask(EcmFilenetConsts.ACCESS_READ_FOLDER);
      AccessPermissionList permissions = folder.get_Permissions();
      permissions.add(permission);
      folder.set_Permissions(permissions);
      folder.save(RefreshMode.REFRESH);
  
      return folder;
  }
  </code></pre>
  
  <p>where <code>EcmFilenetConsts.ACCESS_READ_FOLDER = AccessRight.READ.getValue() | AccessRight.READ_ACL.getValue();</code></p>
  
  <p>The folder has been retrieved using the following code:</p>
  
  <pre><code>String folderID = "{7084AE5B-0000-C817-9E59-B09C18C55230}";
  PropertyFilter pf = new PropertyFilter();    
  pf.addIncludeProperty(new FilterElement(null, null, null, "Permissions", null));
  Folder folder = Factory.Folder.fetchInstance(objectStore, folderID, pf);
  </code></pre>
  
  <p>The problem is that when <code>folder.save</code> instruction is performed I get the following error:</p>
  
  <pre><code>com.filenet.api.exception.EngineRuntimeException: FNRCE0051E: E_OBJECT_NOT_FOUND: The requested item was not found. propertyName=Permissions, referenced principal=AMM_000072_00001 in Domain {00000000-0000-0000-0000-000000000000} failedBatchItem=0 errorStack={
      at com.filenet.engine.security.SecurityProvider.getSecurityId(SecurityProvider.java:454)
      at com.filenet.engine.security.SecurityProvider.preGetSecurityId(SecurityProvider.java:288)
      at com.filenet.engine.security.SecurityDescriptor.updateOrCreateAce(SecurityDescriptor.java:907)
      at com.filenet.engine.security.SecurityDescriptor.updateAccessPermissionList(SecurityDescriptor.java:713)
      at com.filenet.engine.security.AccessManager.createPersistableSDFromUpdate(AccessManager.java:173)
      at com.filenet.engine.persist.IndependentPersister.preChangeSecurity(IndependentPersister.java:1743)
      at com.filenet.engine.persist.IndependentPersister.executeChange(IndependentPersister.java:329)
      at com.filenet.engine.persist.SubscribablePersister.executeChange(SubscribablePersister.java:177)
      at com.filenet.engine.jca.impl.RequestBrokerImpl.executeChanges(RequestBrokerImpl.java:1487)
      at com.filenet.engine.jca.impl.RequestBrokerImpl.executeChanges(RequestBrokerImpl.java:1345)
      at com.filenet.engine.ejb.EngineCoreBean._executeChanges(EngineCoreBean.java:619)
      at com.filenet.engine.ejb.EngineCoreBean.executeChanges(EngineCoreBean.java:586)
      at com.filenet.engine.ejb.EJSLocalStatelessEngineCore_22877cb1.executeChanges(Unknown Source)
      at com.filenet.engine.ejb.EngineBean.executeChanges(EngineBean.java:913)
      at com.filenet.apiimpl.transport.ejbstubs.EJSLocalStatelessEngine_2e64c374.executeChanges(Unknown Source)
      at com.filenet.apiimpl.transport.ejb.EnginePortLocal.executeChanges(EnginePortLocal.java:53)
      at com.filenet.apiimpl.wsi.ServiceSessionNst$2.run(ServiceSessionNst.java:1360)
      at java.security.AccessController.doPrivileged(AccessController.java:314)
      at javax.security.auth.Subject.doAs(Subject.java:573)
      at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:195)
      at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:152)
      at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:611)
      at com.filenet.apiimpl.util.J2EEUtilWS.doAs(J2EEUtilWS.java:239)
      at com.filenet.apiimpl.wsi.ServiceSessionNst.sMakeInternalEJBCall(ServiceSessionNst.java:1223)
      at com.filenet.apiimpl.wsi.ServiceSessionNst.sHandleIncomingRequest(ServiceSessionNst.java:1067)
      at com.filenet.engine.wsi.ListenerNst.service(ListenerNst.java:179)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1032)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
  }
      at com.filenet.apiimpl.wsi.serialization.core.ExceptionSerialization.deserialize(ExceptionSerialization.java:196)
      at com.filenet.apiimpl.wsi.ServiceSessionNst.cDeserializeSoapFault(ServiceSessionNst.java:693)
      at com.filenet.apiimpl.wsi.ServiceSessionNst.cReqRespPath(ServiceSessionNst.java:223)
      at com.filenet.apiimpl.wsi.ServiceSessionNst.executeChanges(ServiceSessionNst.java:85)
      at com.filenet.apiimpl.util.SessionHandle.executeChanges(SessionHandle.java:112)
      at com.filenet.apiimpl.core.Session.callExecuteChanges(Session.java:146)
      at com.filenet.apiimpl.core.Session.executeChanges(Session.java:532)
      at com.filenet.apiimpl.core.Session.executeChange(Session.java:850)
      at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:76)
      at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:67)
      at com.leonardo.spcic.ecm.filenet.security.SecurityManagerImpl.addFolderPermissions(SecurityManagerImpl.java:44)
      at com.leonardo.spcic.ecm.filenet.security.SecurityManagerImplTest.testAddFolderPermissions(SecurityManagerImplTest.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  </code></pre>
  
  <p>I also tried setting a null propertyFilter for the fetch method but the error still persists.</p>
  
  <p>I followed <a href="https://bitbucket.org/snippets/teraxas/KKBK4/revisions/5b565d77c4fbae167e0a0109eee45b59942e8b11" rel="nofollow noreferrer">this set permission example</a>.</p>
  
  <p>Could anybody tell me what I'm doing wrong?</p>