cancel
Showing results for 
Search instead for 
Did you mean: 

Update document version

agz
Champ on-the-rise
Champ on-the-rise
Hi all,
I need to update a document through Java into Alfresco.

The scenario is:
the document is in Alfresco (4.0.e), with the version number 1.1 for example.
My code is:

File file = <file passed from UI>
Document document= <get Document object from Alresco through id>
ContentStream contentStream = new ContentStreamImpl(documentgetName(), BigInteger.valueOf(file.asBytes()), file.getContentType(), file.asStream());

Map<String, Object> properties = new HashMap<String, Object>();
properties.put("cm:description", "my personal description");
document.updateProperties(properties, false);     
document.setContentStream(contentStream, true, false);



This code updates document correctly (content and properties) but version from 1.1 goes to 1.3.
I tried differents combinations of latest parameter of updateProperties and of setContentStream but the behaviour doesn't change.

Whenever I update the file the version number increases of 2 minor versions.

Someone knows why?
Is there a method to update the document (like the code above) and increment only 1 skip minor version?

Thanks in advance
2 REPLIES 2

agz
Champ on-the-rise
Champ on-the-rise
I resolved this using:

document.checkIn(false, properties, contentStream, "");

horia
Champ in-the-making
Champ in-the-making
interesting, when I'm doing the same operation on a Document, it throws an exception saying:
Object is not a PWC!