Reputation:
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 the 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<String, String> map = new HashMap<String, String>() {
{
put(QNAME_VERSION_LABEL, INITIAL_UPLOADED_VERSION); // 1.1
put(QNAME_AUTO_VERSION, false);
}
};
nodeService.addAspect(nodeRef, QNAME_ASPECT_VERSIONABLE, map);
// SKIPPED
Constants that I used:
final String NS_ALF_CONTENT_MODEL = "http://www.alfresco.org/model/content/1.0";
final String ASPECT_CM_VERSIONABLE = "versionable";
final String PROP_VERSION_LABEL = "versionLabel";
final String PROP_AUTO_VERSION = "autoVersion";
final String INITIAL_UPLOADED_VERSION = "1.1";
final QName QNAME_ASPECT_VERSIONABLE = QName.createQName(NS_ALF_CONTENT_MODEL, ASPECT_CM_VERSIONABLE);
final QName QNAME_VERSION_LABEL = QName.createQName(NS_ALF_CONTENT_MODEL, PROP_VERSION_LABEL);
final QName QNAME_AUTO_VERSION = QName.createQName(NS_ALF_CONTENT_MODEL, PROP_AUTO_VERSION);
When I debug this solution, 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 the version for the first upload is always have number 1.0 and how can I change this behaviour?..
transaction level in my case: <transaction>required</transaction>
Upvotes: 0
Views: 247
Reputation:
Yes, Patrik's advise is working (Slothrop's advice I didn't check). I've just set up the initialVersion = false
.
Map<String, String> map = new HashMap<String, String>() {
{
put(QNAME_VERSION_LABEL, INITIAL_UPLOADED_VERSION); // 1.1
put(QNAME_AUTO_VERSION, false);
put(QNAME_INITIAL_VERSION, false);
}
};
nodeService.addAspect(nodeRef, QNAME_ASPECT_CM_VERSIONABLE, map);
Now everything is Ok.
Thank's to @Gagravarr for his assistance.
Upvotes: 1