【问题标题】:Unable to create cmis:document inside custom alfresco folder无法在自定义 alfresco 文件夹中创建 cmis:document
【发布时间】:2017-07-07 14:01:02
【问题描述】:

我正在使用 open cmis 在 Alfresco 存储库 (5.1e) 中创建带有附件的文件夹(自定义类型)。文件夹已成功创建,但为了创建文档 (cmis:document - cm:content) 作为附件,我收到以下异常:

原因:org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException:无法将“cmis:document”类型的对象添加到此文件夹! 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:514) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0] 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:717) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0] 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:122) [chemistry-opencmis-client-bindings-1.0.0.jar:1.0.0] 在 org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:1197) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0] 在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0] 在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:471) [chemistry-opencmis-client-impl-1.0.0.jar:1.0.0] 在 com.salviol.frops.common.ejbs.DcmIntegrationEJB.createDocument(DcmIntegrationEJB.java:208) [frops-common-ejb-0.0.1.jar:] 在 com.salviol.frops.common.ejbs.DcmIntegrationEJB.createCase(DcmIntegrationEJB.java:67) [frops-common-ejb-0.0.1.jar:] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_40] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_40] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_40] 在 java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_40] 在 org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 在 org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407) 在 org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 在 org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407) 在 org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 在 org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 在 org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:251) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] ... 174 更多

这里是添加文档到文件夹的源代码(方法):

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;
}

我尝试了版本控制(状态 MAJOR 和 NONE),但问题仍然存在。创建的文件夹具有标准权限(inherit = "true" 并为每个站点用户提供适当的权限)。

有人对 Cmis 约束有同样的问题吗?

【问题讨论】:

    标签: alfresco cmis opencmis


    【解决方案1】:

    这是关于您的文件夹,而不是关于您的文档。 查看导致错误的代码,原因将变得明显。有一个名为 cmis:allowedChildObjectTypeIds 的属性,这就是您所追求的。

    你的模型是如何定义的?

    public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
        {
            TypeDefinitionWrapper targetType = folderInfo.getType();
            PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
                    .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
            List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
                    folderInfo);
    
            if ((childTypes == null) || childTypes.isEmpty())
            {
                return;
            }
    
            if (!childTypes.contains(childType))
            {
                throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
            }
        }
    

    【讨论】:

    • 你好。自定义模型在 alfresco repo 端定义,并包含扩展 cm:folder 类型的自定义类型(及其自定义属性、方面和关联)。在 cmis 创建文件夹中添加 cmis:allowedChildObjectTypeIds、alfresco repo 端(自定义模型)或附加属性的正确位置在哪里?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    • 2020-04-28
    • 2021-07-09
    相关资源
    最近更新 更多