• Exporter and Cron

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
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.
 #44532  by alexkcy
 
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:
Code: Select all
import 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
    }
}
 #44537  by jllort
 
What OpenKM version do you have ?
Do you come from some previous upgrade ?
 #44542  by alexkcy
 
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
 #44545  by jllort
 
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);
}

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.