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
Explore our Alfresco products with the links below. Use labels to filter content by product module.