我使用open cmis在Alfresco存储库(5.1e)中创建带附件的文件夹(自定义类型)。文件夹已成功创建,但是为了创建文档(cmis:document - cm:content)作为附件,我得到以下异常:
引起:org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException:类型为#cm; 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] 在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] 在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] at 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:] 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] 在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) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory $ 1.processInvocation(UserInterceptorFactory.java:63) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at 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] 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) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 在org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory $ 1.processInvocation(UserInterceptorFactory.java:63) 在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] 在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] 在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] 在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] 在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) at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) 在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] 在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 =&#34; true&#34;并且对于每个站点用户具有适当的权限)。
是否有人对Cmis约束有同样的问题?
答案 0 :(得分: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!");
}
}