当我在地图中添加自定义对象时,它会给我错误。
java.lang.IllegalArgumentException:Property' pos:empCode'不是 有效期 这种类型或其中一种次要类型!在org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl.conver tProperties(ObjectFactoryImpl.java:426)at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(会话 Impl.java:1091)org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImp) l.java:77)
我的代码是:
Map<String, Object> metaData = new HashMap<String, Object>(0);
metaData.put(DocumentConstants.EMPCODE, empCode);
// metaData.put(DocumentConstants.TYPE, Constants.EMP_FILE_UPLOAD);
// metaData.put(DocumentConstants.SUBTYPE, Constants.ADD);
docService.uploadDocumentsForAlfresco(metaData, byteArray, fileName);
DocService:
public Boolean uploadDocumentsForAlfresco(Map<String, Object> metaData,
byte[] data, String name) {
Session session = connect();
String folderPath = null;
folderPath = cmisSite.concat(cmisPath).concat("documentlibrary/");
// String path =
"DATAFILES/".concat(metaData.get(DocumentConstants.EMPCODE).toString());
String path = "DATAFILES/".concat("6");
folderPath = folderPath.concat(path);
Folder folder = createFolder(session, folderPath);
// metaData.put(PropertyIds.OBJECT_TYPE_ID, "D:ebs:bulkUploadDoc");
metaData.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
// set the alfresco object factory
metaData.put(PropertyIds.NAME, name);
ByteArrayInputStream input = new ByteArrayInputStream(data);
ContentStream contentStream =
session.getObjectFactory().createContentStream(name, data.length,
"application/octet-stream", input);
try {
folder.createDocument(metaData, contentStream,
VersioningState.MAJOR);
return true;
} catch (Exception ex) {
//log.error("exception while uploading document",ex);
ex.printStackTrace();
return false;
}
}
在pom.xml中添加了依赖
<dependency>
<groupId>org.alfresco.cmis.client</groupId>
<artifactId>alfresco-opencmis-extension</artifactId>
<version>0.3</version>
</dependency>
<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-impl</artifactId>
<version>0.13.0</version>
</dependency>
答案 0 :(得分:1)
pos:empCode是在您的一个自定义类型或方面上定义的属性。您正在尝试在对象上设置该属性的值,但您已告知CMIS对象类型为cmis:document。 cmis:文档类型映射到cm:content,即没有自定义属性的开箱即用类型。
不使用cmis:document作为对象类型ID,而是使用自定义模型中定义pos:empCode属性的类型的对象类型ID。