on 08-25-2010 8:54 AM
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,
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.