我正在使用open cmis在Alfresco存储库(5.1e)中创建带有附件的文件夹(自定义类型)。文件夹已成功创建,但要创建文档(cmis:文档 - cm:内容)作为附件,我收到以下异常:
原因:org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException:无法将类型为"cmis:document"的对象添加到此文件夹! 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 更多
以下是将文档添加到文件夹的源代码(方法):
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 约束有同样的问题?
这是关于你的文件夹,而不是关于你的文档。 看看导致错误的代码,原因将变为父级。有一个名为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!");
}
}