Java 露天文件版本
我使用createfolder或streamupdate,问题是,该版本有两次,我的意思是每次上传alfresco都要做: 调用uploadFile。。。。 返回到文档版本 版本0.2 版本0 1 再一次。。 调用uploadFile。。。。 返回到文档版本 版本0.4 版本0.3 。。。。我怎样才能将一个版本的文件上传到另一个版本 下面是创建文档和更新文档的代码 创建文档Java 露天文件版本,java,alfresco,opencmis,Java,Alfresco,Opencmis,我使用createfolder或streamupdate,问题是,该版本有两次,我的意思是每次上传alfresco都要做: 调用uploadFile。。。。 返回到文档版本 版本0.2 版本0 1 再一次。。 调用uploadFile。。。。 返回到文档版本 版本0.4 版本0.3 。。。。我怎样才能将一个版本的文件上传到另一个版本 下面是创建文档和更新文档的代码 创建文档 FileInputStream fis = new FileInputStream(file); Data
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);
}
}
}
FileInputStream fis=新的FileInputStream(文件);
DataInputStream dis=新的DataInputStream(fis);
byte[]bytes=新字节[(int)file.length()];
dis.readfull(字节);
Map newDocProps=newhashmap();
newDocProps.put(PropertyIds.OBJECT_TYPE_ID,“cmis:document”);
newDocProps.put(PropertyIds.NAME,file.getName());
newDocProps.put(PropertyIds.IS_最新版本,“TRUE”);
List addAces=new LinkedList();
List Removeces=新建LinkedList();
列表策略=新建LinkedList();
试一试{
ContentStream ContentStream=new ContentStreamImpl(file.getName(),biginger.valueOf(bytes.length),fileType,new ByteArrayInputStream(bytes));
Document doc=folder.createDocument(newDocProps,contentStream,VersioningState.MINOR,policies,removeces,addAces,session.getDefaultContext());
露天文件alfDoc=(露天文件)文件;
if(alfDoc.hasapect(“P:cm:versionable”){
映射属性=新的HashMap();
properties.put(“cm:autoVersion”,true);
alfDoc.updateProperties(属性);
}
}捕获(例外e){
如果(例如getMessage()包含(“冲突”)){
Document Document=(Document)session.getObject(session.getObjectByPath(“…/Space/”+file.getName()).getId());
ContentStream ContentStream=new ContentStreamImpl(file.getName(),biginger.valueOf(bytes.length),fileType,new ByteArrayInputStream(bytes));
更新的文档(文档、内容流);
}
}
}
在您的代码中,您确实创建了文档的两个版本:
Document doc = folder.createDocument(newDocProps, contentStream, VersioningState.MINOR, policies, removeAces, addAces, session.getDefaultContext());
及
默认情况下,
cm:versionable
设置为将cm:autoversionUpdateProps
设置为true
后一个调用发出要创建的新版本。您可以在对象上或通过更改cm:versionable
定义,将该属性设置为false
。请参阅。OpenCMIS中没有上载文件,我想这是自定义代码。您能发布它吗?当我调用folder.createDocument(…)时,它工作正常,但当我在浏览器上检查此文档的版本历史时,它会将我的版本设置为0.1和0.2。并且两个版本包含相同的内容;代码中的部分,但仍有相同的问题。我们是否应该用代码手动更新文档版本??我的意思是露天版。
alfDoc.updateProperties(properties);