Exporter and Cron

We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
alexkcy
Junior Boarder
Junior Boarder
Posts: 20
Joined: Tue Feb 14, 2017 6:17 am

Exporter and Cron

Post by alexkcy » Sat Aug 12, 2017 6:37 pm

Dear all

I am using the scheduler inside openkm to export. However, I found the "com.openkm.core.PathNotFoundException" in the export log. It seems that the path name with specific characters could not be found like ' become amp;#39;. Any clue ?

I am using the following scripts:

mport com.openkm.util.FileLogger;
import com.openkm.bean.ContentInfo;
import com.openkm.api.*;
import com.openkm.util.impexp.*;
import java.io.*;
import java.text.*;
import com.openkm.core.Config;
import java.util.*;
import com.openkm.module.db.stuff.*;

// Configuration parameters
String token = DbSessionManager.getInstance().getSystemToken();
String LOG_FILE_NAME = "CrontabRepositoryExporter";
String repoPath = "/okm:root";
String fsPath = "/export/backup/root";
boolean metadata = false;
boolean history = false;

// Start
FileWriter fw = null;
try {
FileLogger.info(LOG_FILE_NAME, "Started");
// Open outputstream
String fileDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
String fileName = Config.LOG_DIR + File.separator + LOG_FILE_NAME + "_" + fileDate + ".log";
File file = new File(fileName);
fw = new FileWriter(file);
// Starting the process
ContentInfo cInfo = OKMFolder.getInstance().getContentInfo(token, repoPath);
FileLogger.info(LOG_FILE_NAME, "Files & directories to export:"+(cInfo.getDocuments() + cInfo.getFolders()));
File dir = new File(fsPath);
ImpExpStats stats = RepositoryExporter.exportDocuments(token, repoPath, dir, metadata, history, fw, new HTMLInfoDecorator((int) cInfo.getDocuments() + (int) cInfo.getFolders()));
FileLogger.info("CrontabRepositoryExporter", "Finished");
} catch (Exception e) {
try { if (fw != null) {
fw.close(); }
} catch (IOException e1) { // Ignore
}
}

jllort
Moderator
Moderator
Posts: 9511
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Exporter and Cron

Post by jllort » Sun Aug 13, 2017 9:02 pm

What OpenKM version do you have ?
Do you come from some previous upgrade ?

alexkcy
Junior Boarder
Junior Boarder
Posts: 20
Joined: Tue Feb 14, 2017 6:17 am

Re: Exporter and Cron

Post by alexkcy » Mon Aug 14, 2017 7:55 am

Dear jllort,

I am using 6.3.4, upgraded from 6.3.2 to 6.3.3 to 6.3.4.

I am scratching my head and really have no idea what's happened. According to the source of script, shouldn't have behaved like this.

Regards
Alex

jllort
Moderator
Moderator
Posts: 9511
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Exporter and Cron

Post by jllort » Mon Aug 14, 2017 6:41 pm

Try executing this script (https://docs.openkm.com/kcenter/view/ok ... o-630.html) :

Code: Select all

import com.openkm.dao.bean.*;
import com.openkm.dao.*;
import com.openkm.util.*;
import org.hibernate.*;

String qs = "from NodeBase nb where nb.name like '%&%' and nb.uuid NOT IN (select nb.uuid from NodeBase nb where nb.name like '%&%')";
Session session = null;
Transaction tx = null;

try {
    session = HibernateUtil.getSessionFactory().openSession();
    tx = session.beginTransaction();
    Query q = session.createQuery(qs);

    for (NodeBase nBase : q.list()) {
        print(nBase.getUuid() + " -> " + nBase.getName() + "");
        nBase.setName(PathUtils.encodeEntities(nBase.getName()));
        session.update(nBase);
    }

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

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests