Page 1 of 1

Keywords, versions and folder handling

PostPosted:Wed Mar 15, 2017 2:17 pm
by greengold
Hi,
I'm affraid I need to ask you for clarification of multiple aspects here:

Document versioning:
What I do is that when I upload a new version of the document, I create Version obj, set it's name and then get's a document by 'uuid' assign it version object and then I call "setProperties" for setting the document new document properties. Code:
Code: Select all
Version v = new Version();
v.setActual(true);
v.setName(version);

Document document = okmWebSrv.getOkmService().getDocumentProperties(docUUID);
document.setActualVersion(v)

okmWebSrv.getOkmService().lock(docUUID);
okmWebSrv.getOkmService().checkin(docUUID, data, "");
okmWebSrv.getOkmService().lock(docUUID);
okmWebSrv.getOkmService().setProperties(document);
okmWebSrv.getOkmService().unlock(docUUID);
thing is that version is never set. it keep's incrementing by minor number regardless of what I set.

Folder manipulation:
First, when I create a folder, I need it to have some keywords assigned, by of which I want to be able to do search later. This is how I create folder:
Code: Select all
Folder folder = new Folder();
folder.setPath(currentTemplate.getName());
folder.setKeywords(currentTemplate.getKeywords());
created = okmWebSrv.getOkmService().createFolder(folder);
and indeed, folder is being ceated but with no keywords assigned, that I can see in the UI. (same with the document keywords)

Ghost folders:
What has surprised me is that as I have created folder structure, I have kept the UUID of lowermost folder in the hierarchy. Than I deleted the uppermost folder of this hierarchy in the UI and whole tree has dissapeared - as expected. Weird thing is that when I supply that UUID I kept to the:
Code: Select all
okmWebSrv.getOkmService().getFolderProperties({UUID});
I can still see this folder existing! Even document creation under this (deleted) folder fails with "ItemExistsException" as if it would exists. I don't see it in the UI, even after tomcat restart.

I'm using local instance of OpenKM version 6.3.2 build 8289 with Java openKM SDK.
Thanks for helping!

Re: Keywords, versions and folder handling

PostPosted:Thu Mar 16, 2017 12:12 pm
by jllort
About document version, really when you do a checkin, it's automatically set a new version ( core does it for you, there's a specific logic for the whole repository what is applied ). About setProperties, this is a method what usually cause confusion, read here about what it changes and what not here https://docs.openkm.com/kcenter/view/ok ... Properties

You must set keywords later ( there are two steps, first create object, then set keyword ). Take a look here https://docs.openkm.com/kcenter/view/ok ... addKeyword

About methods like create(Folder fld) create(Document) etc... although you see we use a complex element for creating, really we only use few vars from the used Object. Almost methods are thinked to perform atomic actions. Take a look here https://docs.openkm.com/kcenter/view/ok ... older.html ( compare create and createSimple methods ).
These methods had been created from the first OpenKM versions and for compatibility reasons we still work with them, but really the initial idea was not use all Folder vars for creating a node. We know it creates some confusion.

About delete, take in consideration delete a node really moves to trash ( openkm node ) and purge is what really makes it disappear definitively.

If you want to start playing with 6.3.3 the source code is available at https://github.com/openkm/document-management-system ( only it remain release the files, the code is yet complete for the official release )

Hope I had provided you some clue for working with API.

Re: Keywords, versions and folder handling

PostPosted:Fri Mar 17, 2017 12:53 pm
by greengold
Thanks for your response.
Leaving out object fields when creating them is very confusing, indeed.
However very ugly, your approach worked for me.