cancel
Showing results for 
Search instead for 
Did you mean: 

Versoining the Files in KM repository Using WD java

Former Member
0 Kudos

Hi All,

How do i need to get the versioning of the files in KM repositorty using WD java.

When i try to upload the same documents automatically a new version number should be created for the same.

How can i achieve this.

Thanks in Advance,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

When you upload a document throw KM API, if you want to version the same file, you must set the property "version".

That means, when you createResource (the file), the IPropertyMap you are setting must containt the Property "version" and the value (in this case the number version).

Code Sample:

IMutablePropertyMap propertyMap = new MutablePropertyMap();

IPropertyName pn = new PropertyName("http://sapportals.com/xmlns/cm/gp", "version");

IProperty property = new MutableProperty(pn, "1.0");

propertyMap.put(property);

Code Sample when creating the resource and assigning the PropertyValue:

final IResourceFactory aResourceFactory = ResourceFactory.getInstance();

ICollection aCollection = (ICollection) aResourceFactory.getResource(aRid, resourceContext);

ByteArrayInputStream filedataStream = new ByteArrayInputStream(documentContent);

IMimeHandlerService mimeHandler = MimeHandlerServiceFactory.getInstance();

String mimeType = mimeHandler.getMimetypeForExtension(documentName.substring(documentName.length() - 3));

fileContent = new Content(filedataStream, mimeType, filedataStream.available());

if (aCollection != null) {

fileResource = aCollection.createResource(documentName, propertyMap, fileContent);

return true;

}

I haven't try the code, but it is one way to do it because I have my own API to do this when I apply multi-properties to a file in KM and this is part of the code.

Hope it helps.

David.

Answers (0)