• Crontab task import failed

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
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.
 #39544  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/"));
 #39562  by jllort
 
Can you try the script from scripting view, there probably you will get a better error.
 #39567  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
 #39577  by jllort
 
what is wrong is the import com.openkm.API.*; should be import com.openkm.api.*; ( lower case )

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.