我使用 createfolder 或 streamupdate ,问题是,那是两次版本,我的意思是每次上传都在户外做:
调用uploadFile....返回文档版本版本0.2版本0 1
再次..调用uploadFile..返回文档版本
0.4 版 0.3 版
.... 我怎样才能对上传文件的版本只进行一个版本?
这是创建文档和更新文档的代码。
创建文档...
FileInputStream fis = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fis);
byte[] bytes = new byte[(int) file.length()];
dis.readFully(bytes);
Map<String, String> newDocProps = new HashMap<String, String>();
newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
newDocProps.put(PropertyIds.NAME, file.getName());
newDocProps.put(PropertyIds.IS_LATEST_VERSION, "TRUE");
List<Ace> addAces = new LinkedList<Ace>();
List<Ace> removeAces = new LinkedList<Ace>();
List<Policy> policies = new LinkedList<Policy>();
try {
ContentStream contentStream = new ContentStreamImpl(file.getName(), BigInteger.valueOf(bytes.length), fileType, new ByteArrayInputStream(bytes));
Document doc = folder.createDocument(newDocProps, contentStream, VersioningState.MINOR, policies, removeAces, addAces, session.getDefaultContext());
AlfrescoDocument alfDoc = (AlfrescoDocument) doc;
if(alfDoc.hasAspect("P:cm:versionable")) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("cm:autoVersion", true);
alfDoc.updateProperties(properties);
}
} catch (Exception e) {
if(e.getMessage().contains("Conflict")){
Document document = (Document) session.getObject(session.getObjectByPath(".../Space/"+file.getName()).getId());
ContentStream contentStream = new ContentStreamImpl(file.getName(), BigInteger.valueOf(bytes.length), fileType, new ByteArrayInputStream(bytes));
updateDcoument(document,contentStream);
}
}
}