Page 1 of 1

Beanshell Scripting help

PostPosted:Thu Jan 03, 2013 3:36 pm
by chackem
I'm trying to create a series of convenience classes to help do common operations by scripting. I have the nodes figured out pretty well, such as getting node information, history information, keywords, etc. But I'm tearing my hair out over user information. What I'd like to do is something like the following:
Code: Select all
class myUser {
     myUser(String user);

     String getName();
     String isActive();

     void setActive(state);
}

class myUsers {
     addUser(String user);
     count();
     myUser getUser(String user);
     delete(String user)
}
I can't figure out where to get this information. My google-fu has failed me, and I've poured over the class documentation until I was blury eyed. Any advice which classes I should use or how to get this functionality? My version is: Version: 6.2.0 (build: 13077)

Brady Hutmacher

P.S. - Thanks for the great product.

Re: Beanshell Scripting help

PostPosted:Fri Jan 04, 2013 3:59 pm
by jllort
I'm not sure about your question, but to interact with openkm users you should use OKMAuth
http://doxygen.openkm.com/6.2.x/d7/d54/ ... _auth.html
Code: Select all
OKMAuth.getInstance().getRoles(null)
Optionally you can use AuthDAO ( but always is possible use OKMAuth ) http://doxygen.openkm.com/6.2.x/d6/dbe/ ... d_a_o.html

Re: Beanshell Scripting help

PostPosted:Fri Jan 04, 2013 6:23 pm
by chackem
I can't seem to be able to get AuthDAO to create an instance, and OKMAuth doesn't seem to give me access to what I want. I should have been clearer in my OP. What I'd like is to be able to set user info, like isActive, so I can have functions like this:

boolean isActive(user);
void setActive(user, active);

I know those functions exist in various classes, but I haven't been able to get those changes to actually "stick".

Thanks for the swift reply yesterday!
Hack'em

Re: Beanshell Scripting help

PostPosted:Sun Jan 06, 2013 6:14 pm
by jllort
Read with care the class http://doxygen.openkm.com/6.2.x/d9/df0/ ... rvlet.html which contains all login to change / create users in administration

For the operation you want to doing will be something like :
Code: Select all
import com.openkm.dao.AuthDAO;
String usrId = "user1";
User user = AuthDAO.findUserByPk(usrId);
user.setActive = false;
AuthDAO.updateUser(usr);

Re: Beanshell Scripting help

PostPosted:Mon Jan 07, 2013 6:10 pm
by chackem
Thank you so much. My mistake was that I thought you had to have an instance or create an object to use a method. I wasn't able to create or getInstance() on AuthDAO, so that was where my mistake was. I didn't realize you could use it directly. I come from a C++ background and am still learning Java/Beanshell.

Thanks again!
Brady