Page 1 of 1

Unable to take backup of OKM repository

PostPosted:Sat Jan 20, 2018 6:45 am
by skgoel
Hi

One of our folders has an apostrophe in the folder name (API's). Due to this apostrophe, the backup process initiated through the Admin section errors out with pathNotFoundException. I think it is unable to handle the apostrophe. I am unable to delete the folder.

How can I change the name of the folder and/or take the backup of the repository?

Thanks

Re: Unable to take backup of OKM repository

PostPosted:Sat Jan 20, 2018 8:41 am
by jllort
In this documentation section we talk about how doing backup https://docs.openkm.com/kcenter/view/ok ... store.html ( at least what should consider for it ).

For changing a document name, should execute something like it:
Code: Select all
UPDATE OKM_NODE_DOCUMENT SET NBS_NAME='renamed' where NBS_UUID='SOME DOCUMENT UUID';
To find the document uuid should take a look at all documents what it have this character ( THE DOUBLE '' IS SINGLE ' IN SQL ):
Code: Select all
SELECT * FROM OKM_NODE_DOCUMENT WHERE NBS_NAME LIKE = '%''%'; 
What OpenKM version are you using, because in the last OpenKM this issue should be solved, might be you have missed some step while upgrading ?

You can also try with this script:
Code: Select all
import org.hibernate.*;
    import com.openkm.dao.*;
    import com.openkm.dao.bean.*;

    Session session = null;
    Transaction tx = null;

    try {
      session = HibernateUtil.getSessionFactory().openSession();
      tx = session.beginTransaction();
      Query q = session.createQuery("from NodeBase nb where nb.name like '%''%'"); // The ' character

      for (NodeBase nBase : q.list()) {
        print(nBase.uuid + "<br/>");
        nBase.name = nBase.name.replaceAll("'", "").trim();
        session.update(nBase);
      }

      HibernateUtil.commit(tx);
    } catch (HibernateException e) {
      HibernateUtil.rollback(tx);
    } finally {
      HibernateUtil.close(session);
    }