AnsweredAssumed Answered

How to set arbitrary version number for upload?

Question asked by Aleksey Bykov on Feb 18, 2019
Latest reply on Feb 19, 2019 by Aleksey Bykov

I am developing the content uploader that represents a Surf WebScript. Perhaps it would be more correct to say "updater", because the content already exists in the repository, but may not have cm:versionable aspect. I need to update this content and set the correct version number (arbitrary, for example).

 

I noticed that first upload always gets the number 1.0.

 

For example, suppose that content model does not have the cm:versionable aspect. I can add it by this way and specify the version number that I need (1.1):

 

if(!nodeService.hasAspect(nodeRef, QNAME_ASPECT_VERSIONABLE)) {
Map<QName, Serializable> props = new HashMap<>();
props.put(QNAME_VERSION_LABEL, INITIAL_UPLOADED_VERSION);
props.put(QNAME_AUTO_VERSION, false);
nodeService.addAspect(nodeRef, QNAME_ASPECT_VERSIONABLE, props);
// SKIPPED

 

Constants for this case are represented below:

 

String NS_ALF_CONTENT_MODEL = "http://www.alfresco.org/model/content/1.0";
String ASPECT_CM_VERSIONABLE = "versionable";
String PROP_VERSION_LABEL = "versionLabel";
String PROP_AUTO_VERSION = "autoVersion";
String INITIAL_UPLOADED_VERSION = "1.1";

QName QNAME_ASPECT_VERSIONABLE =
QName.createQName(NS_ALF_CONTENT_MODEL, ASPECT_CM_VERSIONABLE);
QName QNAME_VERSION_LABEL =
QName.createQName(NS_ALF_CONTENT_MODEL, PROP_VERSION_LABEL);
QName QNAME_AUTO_VERSION =
QName.createQName(NS_ALF_CONTENT_MODEL, PROP_AUTO_VERSION);

 

Under the debugger, I can see that I get the version that I need.

 

 

However, when I look at the node properties in the node browser, I see that cm:versionLabel == 1.0. 

 

All the next uploads get the correct numbers, according to the logic that I use.

 

Why for the first upload version is always have number 1.0 and how can I change this behaviour?

 

transaction level in my case: <transaction>required</transaction>

 

I would be very grateful for the information.

Thanks to all.

Outcomes