这是我的CMIS同步代码。
String documentName = null;
StringBuilder contentBuilder= new StringBuilder();
ByteArrayInputStream inputStream;
byte[] buffer = null;
session=getSession(sourceClientIbmNet);
CmisObject cmisObjectSource = session.getObject(sourceId);
if (BaseTypeId.CMIS_DOCUMENT.equals(cmisObjectSource.getBaseTypeId())) {
Document document = (Document) cmisObjectSource;
List<String> fileContent = getFileContent(document);
for(String string: fileContent){
contentBuilder= contentBuilder.append(string+"\n");
}
}
session = null;
session= getSession(destinatioClientIbmNet);
CmisObject cmisObjectDestination=session.getObject(destinationId);
if (BaseTypeId.CMIS_DOCUMENT.equals(cmisObjectDestination.getBaseTypeId())) {
Document document = (Document) cmisObjectDestination;
documentName = document.getName();
if (((DocumentType) (document.getType())).isVersionable()) {
document.refresh();
Document pwc = (Document) session.getObject(document.checkOut());//Here i got exception
String mimetype = "text/plain; UTF-8";
String content = contentBuilder.toString();
try {
buffer = content.getBytes("UTF-8");
} catch (Exception e) {
}
inputStream = new ByteArrayInputStream(buffer);
ContentStream contentStream = session.getObjectFactory()
.createContentStream(document.getName(), buffer.length,
mimetype, inputStream);
try {
pwc.checkIn(true, null, contentStream, "minor version");
} catch (CmisBaseException e) {
e.printStackTrace();
pwc.cancelCheckOut();
}
if (contentStream != null) {
List<String> newContent;
ContentStream contentStream11 = document.getContentStream();
newContent = getFileContent(document);
}
}
}
这是 例外 ...
org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: Conflict
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:499)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:661)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.VersioningServiceImpl.checkOut(VersioningServiceImpl.java:95)
at org.apache.chemistry.opencmis.client.runtime.DocumentImpl.checkOut(DocumentImpl.java:237)
at com.aegis.web.util.CmisClientIbmNet.updateContent(CmisClientIbmNet.java:304)
at com.aegis.web.controller.RepositoryController.sourceToDestinationSYNC(RepositoryController.java:329)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)