Page 1 of 1

Manually creating .okm files for import?

PostPosted:Sat Nov 17, 2012 5:50 am
by stiebs
If I've got a heap of newly scanned documents to import, I don't want to go through and manually upload, then assign keywords and categories to all documents. Gets very tedious and takes a long time. I can instead write a shell script to generate the *.okm files to be used for an import.

How do I go about doing this, and what information can I omit from the .okm file and still have the import work successfully? Obviously I would not be able to include the uuid. I will have the taxonomy path, the keywords and the category paths (but not the category uuids). I assume author, owner and roles are needed. How about the time stamps? For the omitted information, should I just leave it out, or does it need to be there, but blank?

Do I used {"uuid":[]} or {"uuid":""} or just omit the uuid component completely? Or something else?
Likewise for category. Do I use "categories":[{"uuid":[],"path":"/okm:categories/catname"}], or will "categories":["path":"/okm:categories/catname"}] suffice?

I'v tried creating an okm file and just removing the uuid entries. I put the okm file along with its pdf in a directory, and then tried doing a repository import, but got the error message "Error: Unable to perform operation. Node is protected.".

Is there something else I should be doing?

Thanks.

Re: Manually creating .okm files for import?

PostPosted:Sat Nov 17, 2012 8:03 am
by stiebs
After searching the forums a bit, I found that I was on 5.1.9, and previously someone else with problems importing fixed their problem by upgrading to 5.1.10.
So now that I've upgraded to 5.1.10, I have successfully imported a document from a hand written .okm file, by omitting the "uuid" components.

However there are two outstanding issues I'm still trying to resolve.

1. Even though I specified "path":"/okm:root/path/file.pdf", the document was created in the /okm:root location. If I leave "repository path" blank on the import, the import fails. I assume this means that to bulk import using this method, I should either import one taxonomy location at a time, or replicate the taxonomy structure in my source folders.

2. The keywords were added to the document on import, but the categories were not.

Re: Manually creating .okm files for import?

PostPosted:Sun Nov 18, 2012 8:33 am
by jllort
I suggest you upgrade to 5.1.11 ( is not oficialy released but can be found at nighly build integration.openkm.com )
To create .okm files we use GSON java library I suggest use it too.

In this class is done exportation http://doxygen.openkm.com/6.2.x/db/df6/ ... orter.html and probably you'll be interested in this too http://doxygen.openkm.com/6.2.x/d6/d40/ ... apter.html
Code: Select all
DocumentMetadata dmd = ma.getMetadata(docChild);
String json = gson.toJson(dmd);