Crontab task import failed
PostPosted:Wed May 13, 2015 4:13 pm
Version: 6.3.0 (build: 8156) Community version
Trying to use the crontab import task beanshell script (see below) from the wiki and I am getting a somewhat generic error in the log
catalina.out:Importing BRN30055C6366B4_000480.pdf<br>
catalina.out:Exception:com.openkm.core.RepositoryException: Invalid path: /okm:root/scans/BRN30055C6366B4_000480.pdf<br>
I have confirmed that the path exists and I can upload file to the path via the web interface. How would I debug this further?
Trying to use the crontab import task beanshell script (see below) from the wiki and I am getting a somewhat generic error in the log
catalina.out:Importing BRN30055C6366B4_000480.pdf<br>
catalina.out:Exception:com.openkm.core.RepositoryException: Invalid path: /okm:root/scans/BRN30055C6366B4_000480.pdf<br>
I have confirmed that the path exists and I can upload file to the path via the web interface. How would I debug this further?
Code: Select all
import com.openkm.core.*;
import com.openkm.api.*;
import java.io.*;
import com.openkm.module.db.stuff.DbSessionManager;
String token = DbSessionManager.getInstance().getSystemToken();
OKMDocument document = OKMDocument.getInstance();
OKMFolder folder = OKMFolder.getInstance();
public void autoImport(String okmPath, File fldpath){
try {
print("Scanning " + fldpath.getName() + "<br>");
for (File file : fldpath.listFiles()) {
print("Importing " + file.getName() + "<br>");
try {
if (file.isDirectory()) {
try {
folder.createSimple(token, okmPath + file.getName());
} catch (ItemExistsException ie) {
print("folder already exists<br>");
// Folder already exists - just ignore exception
}
autoImport( okmPath + file.getName() + "/", file);
} else {
// Check if file is still being written to
long length = file.length();
Thread.sleep(1000);
if (file.length() > length) continue; // Skip file this time
document.createSimple(token, okmPath + file.getName(), new FileInputStream(file));
}
print("Created " + okmPath + file.getName() + "<br>");
} catch (Exception e) {
print ("Exception:" + e + "<br>");
// Something bad happened to prevent import. Skip to next file.
continue;
}
file.delete();
}
} catch (Exception e) {
print("Exception: " + e + "<br>");
}
}
autoImport(" /okm:root/scans/", new File("/home/scans/files/"));