01-15-2019 10:15 AM
Hi all,
when I try to update a document in my Alfresco repository (version Community - 5.0.0) I get this exception:
Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Use CheckOutCheckInservice to manipulate working copies.
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:523)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:750)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:737)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.VersioningServiceImpl.checkIn(VersioningServiceImpl.java:215)
at org.apache.chemistry.opencmis.client.runtime.DocumentImpl.checkIn(DocumentImpl.java:347)
at org.apache.chemistry.opencmis.client.runtime.DocumentImpl.checkIn(DocumentImpl.java:650)
My code is the following:
Session session = alfrescosession.getSession();
Document newdocument = null;
try{
Folder folder = getFolder(session, info.getPath(), true);
String oldid = info.getId();
Map<String, Object> newDocumentProps = new HashMap<String, Object>();
newDocumentProps.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
newDocumentProps.put("cm:title", info.getName());
ArrayList<String> secIds = new ArrayList<String>();
secIds.add("P:cm:titled");
newDocumentProps.put("cmis:secondaryObjectTypeIds", secIds);
InputStream is = null;
try {
is = new FileInputStream(info.getFileHandler().getFile());
ContentStream contentStream = session.getObjectFactory().createContentStream(
info.getFileHandler().getName(),
info.getFileHandler().getFile().length(),
info.getFileHandler().getContentType(), is);
if (oldid==null) {
String name = getUniqueName(session, folder, info.getFileHandler());
newDocumentProps.put(PropertyIds.NAME, name);
// Create versioned document object
Document document = folder.createDocument(newDocumentProps, contentStream, VersioningState.MAJOR);
String[] versions = AlfrescoUtility.removeVersionFromId(document.getId());
info.setId(versions[0]);
} else {
Document document = session.getLatestDocumentVersion(oldid);
ObjectId newid = document.checkOut();
newdocument = (Document)session.getObject(newid);
newdocument.checkIn(false, newDocumentProps, contentStream, null);
}
} catch (Exception ioe) {
throw ioe;
} finally {
try {newdocument.cancelCheckOut();} catch(Exception e1) {}
try {is.close();} catch(Exception e1) {};
}
}catch(AlfrescoException e){
throw e;
}catch(Exception e){
throw new AlfrescoGenericException("Errore in caricamento: "+ info, e);
}
I get the exception on newdocument.checkIn(false, newDocumentProps, contentStream, null).
Could someone help me? What is the problem?
Using other istance of Alfresco (version Community - 5.2.0) this code works for me, maybe there is some configurations to do?
Thanks
11-24-2019 07:28 AM
Hi Jade,
I am facing the same problem. We upgrade to alfresco community 6-1-1. The same code was working with our precedent version ( 5.0-3 I believe).
Did you find a solution to this problem
Best regards martin
05-12-2025 10:26 AM
Good morning, I know it's been a while, but I find myself in the same situation. I have some code that worked in the previous version of Alfresco, but after the update, I get the CmisRuntimeException error. Were you able to resolve it? How did you do it? Thank you very much.
05-13-2025 04:31 AM
I see the message "Use CheckOutCheckInservice to manipulate working copies." in this code: seems related to removing an aspect, probably the cm:workingCopy.
Probably your code is for a quite old version and just need to be refactored to use the CheckOutCheckInservice.
Hope this helps.
Explore our Alfresco products with the links below. Use labels to filter content by product module.