cancel
Showing results for 
Search instead for 
Did you mean: 

how to delete a document version via API

Former Member
0 Kudos

Hi guys,

Just a very quick question for you.

Environment:

6.0.7.0.0.Enterprise_Portal_Support_Package_7

6.0.6.2.0.ContentManagementAndCollaboration

6.0.6.2.0. ContentManagementAndCollaboration

We'd like to get version history from a KM resource and delete, from this history, the version n-1.

Is it possible to do this via APIs?

We have tried with remove method of IVersionHistory interface but seems that nothing happens.

Do you have any suggestion or code snippets in order to perform this action?

Many many thanks in adavance

Merry Xmas to all

Cheers

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you should be able to delete any version, unless (I think) it's the checked-in/checked-out version. In any case, either the version should be deleted, or an exception should be thrown.

Maybe you could provide more details (sample code and layout of the version history before the delete attempt?).

Best regards, Julian

Former Member
0 Kudos

Hi,

i'm working with Roberto.

This is the code that i'm using.

I make a check if it's active the versioning and i get the Version History.

As you can see in the code, in the ListHistory i delete version n-1 but the details of resource have not been modified.

movedResource.checkOut();

p = aCollection.getProperty PropertyName.createEnhancedCollection());

aVersion = p.getBooleanValue();

if (aVersion) {

// TODO Delete Version n-1

String no_vers = (String) common.get("NOT_CREATE_VERSION");

IVersionHistory ListHistory;

IResource b;

if ("X".equalsIgnoreCase(no_vers)) {

ListHistory = movedResource.getVersionHistory();

b = ListHistory.get(ListHistory.size() - 2);

ListHistory.remove(b);

}

aContent = movedResource.getContent();

IPropertyMap propMap = movedResource.getProperties();

movedResource.checkIn(aContent, propMap, true);

Best regards, Fabio

Former Member
0 Kudos

Hi,

1) Removing something from an IResourceList doesn't affect the underlying store. You'll have to apply <b>delete()</b> to the version itself.

2) What are you doing with the "Enhanced Collection" stuff here? The reliable way to find out whether something is version-controlled is simply to call <b>IResource.isVersioned()</b>...

Best regards, Julian

Former Member
0 Kudos

Hi,

1) I applied <b>b.delete();</b> and it works very well.

2) I tried to use <b>IResource.isVersioned()</b> but it doesn't work so i used the "Enhanced Collection".

Thank you very much for help and i wish you a Happy New Year.

Former Member
0 Kudos

Well, <b>isVersioned()</b> is supposed to work; and if it doesn't that's a bug. Relying on "enhanced collection" is a bad idea because it's a different concept which may not even exist on all repository managers.

Please re-check that <b>isVersioned()</b> applied to the resource itself (<i>not</i> it's parent collection) really doesn't return the correct information. If this is the case, please open a support case.

Best regards, Julian

Answers (0)