• Beanshell Scripting help

  • 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.
 #20572  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.
 #20592  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
 #20598  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
 #20610  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);
 #20622  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

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.