Page 1 of 1

Crontab task import failed

PostPosted:Wed May 13, 2015 4:13 pm
by itninja
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?


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/"));

Re: Crontab task import failed

PostPosted:Thu May 14, 2015 2:59 pm
by jllort
Can you try the script from scripting view, there probably you will get a better error.

Re: Crontab task import failed

PostPosted:Thu May 14, 2015 4:25 pm
by itninja
Sure, the results are below

Sourced file: inline evaluation of: ``import com.openkm.core.*; import com.openkm.API.*; import java.io.*; import c . . . '' : Typed variable declaration : Class: OKMDocument not found in namespace : at Line: 7 : in file: inline evaluation of: ``import com.openkm.core.*; import com.openkm.API.*; import java.io.*; import c . . . '' : OKMDocument

Re: Crontab task import failed

PostPosted:Sat May 16, 2015 6:51 pm
by jllort
what is wrong is the import com.openkm.API.*; should be import com.openkm.api.*; ( lower case )