cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable versioning for one of my custom action

hiten_rastogi1
Star Contributor
Star Contributor

Hi,

I am creating a custom action where I am checking in a file after some modification. I would like to know how I can disable the versioning when I check-in the file.

So far, I have done the below.

In my code, I am passing null in the check-in function of the CheckOutCheckInService(checkOutCheckInService.checkin(workingNode, null);) as specified in the comments of the checkIn function to prevent versioning of the file but I can still see that a minor version is created e.g. 2.0 --> 2.1.

Then, I removed the versionable aspect(nodeService.removeAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE);) from the file and I was able to check in file without creating a version but all the information related to previous versions was lost. This is where I am not able to find out how can I check in the file through my custom action without increasing the version and preserving the version history at the same time.

Thanks

Hiten Rastogi

9 REPLIES 9

kaynezhang
World-Class Innovator
World-Class Innovator

If  versioning is enabled  on a node,when you perform a check in,  a new version is always created, you can't disable it.

Hi Kayne,

Ok, so is there a way I can preserve the version history and after removing

versionable aspect and checking-in the file I can just restore all the

version history for that file ??

Thanks

Hiten Rastogi

Sr. Software Engineer

Mobile: +91 9899586608

Email: hiten.rastogi@eisenvault.com <vipul.swarup@eisenvault.com>

afaust
Legendary Innovator
Legendary Innovator

A minor correction...

The CheckInCheckOutService always performs versioning when you use the checkIn operation. Why would you use it anyway if you you did not want to create a new version?

But versioning in terms of the auto-version feature can indeed be disabled / ignored within a single action / transaction. That is what the BehaviourFilter interface allows you to do. With it you can disable policies / behaviours that automatically react to changes on nodes with specific types or aspects. Since versioning is dependant on the versionable aspect, you can disable behaviours for that aspect and have effectively disabled the auto-versioning behaviour.

I guess disabling the behaviour would also result in the version history not be removed when you remove the aspect itself, but I would not recommend it and it is not necessary for your use case as far as I can see.

Many Thanks Alex,

To clarify on above, my action is related to OCR in which the working node

in checked out and after OCR that working node is checked in and in this

action I am using CheckOutCheckInService, which as you said always perform

the versioning. Do we have another way to handle check-in then please let

me know as my knowledge is limited to above.

Now for disabling Behavior Filter, if my understanding is correct from what

you have said above I just need to disable the behavior that is invoked on

the versionable aspect in my custom action call and that will do the job

which will also help in retaining the previous versions history that is

getting lost in my current setup in which I am removing the aspect

versionable and then checking in the file.

Thanks

Hiten Rastogi

Sr. Software Engineer

Mobile: +91 9899586608

Email: hiten.rastogi@eisenvault.com <vipul.swarup@eisenvault.com>

I suggest you do not check out the node for OCR in the first place. If you use checkout just so that no one else modifieds the node, why not just lock it instead?

We are doing OCR using tesseract, so we have to check-out the file to run

tesseract command on the server therefore I believe locking will not work.

I will concentrate now to disable the behavior related to versioning aspect

in my custom action and see if that works for me.

Thanks

Hiten Rastogi

Sr. Software Engineer

Mobile: +91 9899586608

Email: hiten.rastogi@eisenvault.com <vipul.swarup@eisenvault.com>

Can't you simply use the ContentService to get the access to the node's content?

ContentService (Alfresco 5.0.3 Public API) 

I believe you will be able to read the content and then write the content back by using it.

Hi Alex,

I was able to disable the behavior associated with version and now after

check-in the file version does not increase but in one scenario described

below.

In my custom OCR action I am changing the extension of file from

.tiff/.png/.jpg/.jpeg to .pdf atfer ocr'ing and then check-in the file but

in this case I can see a minor version increase though I have disabled all

the behavior. Can you please let me know why it is happening and how can I

disable it.

Thanks

Hiten Rastogi

Sr. Software Engineer

Mobile: +91 9899586608

Email: hiten.rastogi@eisenvault.com <vipul.swarup@eisenvault.com>

On 15 December 2016 at 12:18, Hiten Rastogi <hiten.rastogi@eisenvault.com>

As long as you use check-out / check-in you will always see a version increase. I think we have established this behaviour cannot be suppressed / disabled a couple of times now. If you absolutely do not want a version increase, stop using check-out / check-in. There is - technically speaking - no reason to use that while OCR is being performed (I know because I implemented similar functionality in the past and never needed that). If your business requirements for the OCR action require use of check-out / check-in then you will have to accept there is a version increase.