Thanks for the response. I did try to use the 'creatUser' method as you suggest, but got a error message saying 'Error in method invocation: Method createUser(null, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int) not found in class'com.openkm.api.OKMAuth'
I think I'm getting this because I'm using the Community version. The code I was playing around with is as follows:-
Code: Select allimport java.io.FileReader;
import java.io.Reader;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
import com.googlecode.jcsv.CSVStrategy;
import com.googlecode.jcsv.reader.CSVReader;
import com.googlecode.jcsv.reader.internal.CSVReaderBuilder;
import com.googlecode.jcsv.reader.internal.DefaultCSVEntryParser;
import com.openkm.bean.QueryResult;
import com.openkm.api.*;
import com.openkm.util.FileLogger;
import com.openkm.util.PathUtils;
String INPUT_PATH = "/home/test/";
String INPUT_FILE_NAME = "users.csv";
int usid = 0;
int psswd = 1;
int em = 2;
int uname = 3;
// Format defintion
char delimiter = ',';
char quoteCharacter = '"';
char commentIndicator = '#';
boolean skipHeader = false;
boolean ignoreEmptyLines = true;
CSVStrategy strategy = new CSVStrategy(delimiter, quoteCharacter, commentIndicator, skipHeader, ignoreEmptyLines);
// File reader
Reader reader = new FileReader(INPUT_PATH + INPUT_FILE_NAME);
// CSV reader
CSVReader csvParser = new CSVReaderBuilder(reader).strategy(strategy).entryParser(new DefaultCSVEntryParser()).build();
List data = csvParser.readAll();
int count = 0;
for (Iterator it = data.listIterator(); it.hasNext();) {
String[] row = (String[]) it.next();
String s_usid = '"' + row[usid] + '"';
String s_psswd = '"' + row[psswd] + '"';
String s_em = '"' + row[em] + '"';
String s_uname = '"' + row[uname] + '"';
count++;
print ("User ID = " + s_usid + "</br>");
print ("Password = " + s_psswd + "</br>");
print ("Email Address = " + s_em + "</br>");
print ("User name = " + s_uname + "</br>");
OKMAuth.getInstance().createUser(null,s_usid, s_psswd ,s_em,s_uname,true);
}
print("Total:" + count + "</br>");
Regardless of the above, I think I'm going to use my VB script to generate the SQL to insert the users and assign their roles. I tested with 600 users and it works fine and is pretty quick. Using VB also gives me the ability to construct and send out email notifications to the users with their user_id and password details. If anyone is interested I can post the code for that too, but it's pretty straightforward.