cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set base version for documents to 0.1??

iro
Champ in-the-making
Champ in-the-making
Hello,

I´m trying to implement Alfresco Share for document management, but I can´t find a way to set a base version to 0.1 (or 0.0) instead of 1.0

Can anyone please direct me to where I can modify this?? It doesn´t need to be user configurable, it could be fixed on 0.1 for all new uploads.

The reason for this is that we have always worked starting with R0 (for revision 0) and it is getting complicated to manage a diferent version number than the revision the document is supposed to be on.

I´m on:
Alfresco Community v3.4.0 - (d 3370) schema 4113
Spring Surf and Spring WebScripts - v1.0.0 - (Release Candidate 2 744)

Thanks in advance!

IRO
16 REPLIES 16

jpotts
World-Class Innovator
World-Class Innovator
iro,

This is actually something that has changed between 3.4.d and 4.0.d. The way the initial version label is determined is through an inner class called SerialVersionLabel that lives within org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy.java. If you look at the constructor for SerialVersionLabel, you'll see that when there is no version label, the majorRevisionNumber is set to 1:
        public SerialVersionLabel(String versionLabel)
        {
            if (versionLabel != null && versionLabel.length() != 0)
            {
                VersionNumber versionNumber = new VersionNumber(versionLabel);
                majorRevisionNumber = versionNumber.getPart(0);
                minorRevisionNumber = versionNumber.getPart(1);
            }
            else
            {
                majorRevisionNumber = 1;
                minorRevisionNumber = 0;
            }
        }
In 4.0.d, this is now set to 0.

So if you are not going to upgrade any time soon, but you want your labels to start with 0.1, you'll need to override SerialVersionLabelPolicy.java with your own class that sets that majorRevisionNumber to 0. In addition to this Java change, you'll also need to tell Spring to use your version policy instead of Alfresco's. You can grep the Alfresco webapp for the class name to find the Spring bean to override.

One other short sidebar related to verison labels in case you come across it: I noticed that in Alfresco 4.0.d, when you create content in Share, the details page shows "Version 1.0". But documents aren't versionable by default and that label isn't really set–it's just a UI thing. If you add a rule to the folder that adds the versionable aspect, new documents will show the correct version label, 0.1.

Jeff

orbital
Champ in-the-making
Champ in-the-making
Hi Jeff,

I have recently become acquainted and have a very well thumbed copy of your guide to working with custom content - great work, thanks. It makes people generally unfamiliar with java coding able to create a real solution fairly easily. This thread is something that I would like to implement to put the icing on the cake (so to speak). Do you have any examples of creating code to override the class so that I can set the base version number?

Any help is very welcome

orbital
Champ in-the-making
Champ in-the-making
Hi Jeff (all),

Just to follow up on my last post - I am in the middle of test driving 4.0.d and can confirm that the base version is STILL 1.0 and not 0.1. Does anybody know if there is a property implemented yet?

Thanks,

jpotts
World-Class Innovator
World-Class Innovator
I think my earlier post should have said, "when you create content in Explorer", because if you create content in Explorer, you'll see it has no version label and has no versionable aspect. If you create a rule that adds the versionable aspect, then you look at the document in Share, the version history will look like this:
[img]http://i.imgur.com/PwShH.png[/img]
However, as you point out, if you add the document in Share the version label will be 1.0. So somewhere in the Share code that version label is set.

Jeff

3acascia
Champ in-the-making
Champ in-the-making
Hi Jeff,

your approach works in Alfresco Community 4.2.b but it doesn't work in Alfresco Community 4.2.c.
Can you help me?

Thanks you in advance,
Toma

sasquatch58
Champ in-the-making
Champ in-the-making
Would this link help?
https://forums.alfresco.com/en/viewtopic.php?f=14&t=42124

Cheers, Sasquatch

orbital
Champ in-the-making
Champ in-the-making
Thanks for your help both. Interestingly, this got me thinking. After reading Jeff's post I went back in to a previously uploaded document (that was showing as version 1.0 in share) and added the Versionable aspect in Explorer. It changed the version number from 1.0 to 0.1. Doing the same in Share left the version number at 1.0

I have also found a Jira bug that relates to this but the fix does seem to be contrary to the behaviour in Explorer, i.e., they have 'fixed' it so that Share uses 1.0.

Jeff: do I need to raise this as a bug, do you think?

mrogers
Star Contributor
Star Contributor
Share's "lazy versioning" is currently hard coded.

It's simple to change but is a change rather than something that is configurable.     I don't think you will get very far with a "bug" but someone could contribute an "enhancement" to make it configurable.

jpotts
World-Class Innovator
World-Class Innovator
This may be working as designed from Engineering's perspective, but it surely is not optimal. It's confusing to end-users who see different behavior between the two clients.

orbital, if you raise a bug and post the link here, I'll certainly vote for it.

And if you (or someone else) fixes Share to make version labels configurable, even better.

Jeff