AnsweredAssumed Answered

Objects of type 'cmis:document' cannot be added to this folder

Question asked by ispasojevic on Jul 4, 2017

Hello,

 

I'm using open cmis to create folder (custom type) with attachments in Alfresco repository (5.1e). Folder is successfully created, but for creation of document (cmis:document) as attachment I'm getting following exception:

 

org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: Objects of type 'cmis:document' cannot be added to this folder!
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:514) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0]
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:717) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0]
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:122) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0]
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:1197) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0]
at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0]
at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:471) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0]
at com.salviol.frops.common.ejbs.DcmIntegrationEJB.createDocument(DcmIntegrationEJB.java:208) [frops-common-ejb-0.0.1.jar:]
at com.salviol.frops.common.ejbs.DcmIntegrationEJB.createCase(DcmIntegrationEJB.java:67) [frops-common-ejb-0.0.1.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_40]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_40]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:251) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
... 174 more

 

Is there maybe problem with permission on that folder or any other issue? Here is the source code  (method) for adding document to folder:

 

private Document createDocument(Session cmisSession, Folder parentFolder, byte[] file, String fileName, String fileType) {

    

    Document document = null;

    

    try {

    

    Map<String, Object> docProperties = new HashMap<String, Object>();    

    docProperties.put(PropertyIds.OBJECT_TYPE_ID,  "cmis:document");

    docProperties.put(PropertyIds.NAME, fileName);

    

        ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(fileName, file.length, fileType, new ByteArrayInputStream(file));

       

            document = parentFolder.createDocument(docProperties, contentStream, null);

            

        } catch (CmisContentAlreadyExistsException ccaee) {

            document = (Document) cmisSession.getObjectByPath(parentFolder.getPath() + "/" + fileName);            

        }

 

        return document;

    }

Outcomes