• Import openkm classes inside an ActionHandler

  • 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.
 #17148  by noxious
 
Hello community!!! I'm an enthousiastic but rookie user so forgive me if my issue seems silly...
I am developing a workflow. When I create a beanshell script like this:
Code: Select all
import com.openkm.module.direct.DirectDocumentModule;
import javax.jcr.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.*;
import com.openkm.frontend.client.bean.GWTWorkflowComment;
import java.util.Map; 
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;

        //Get document's path
        DirectDocumentModule docModule = DirectDocumentModule.class.newInstance();
        String token = JcrSessionManager.getInstance().getSystemToken();
        String uuid=(String)executionContext.getVariable("uuid");
        String path = docModule.getPath(token, uuid);
        
        //Grant User Read, Write
        String newUserName="dioikitis";
        OKMAuth oKMAuth = OKMAuth.getInstance();
        oKMAuth.grantUser(null, path, newUserName, Permission.READ, true);
        oKMAuth.grantUser(null, path, newUserName, Permission.WRITE, true);
inside an event node, everything works perfectly. However, when I want to do the same thing using an ActionHandler, Eclipse cannot import OpenKM classes claiming that these imports cannot be resolved. Why is this happening? Is webservices the answer to my problem?
Here is my ActionHandler:
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.module.direct.DirectDocumentModule;
import javax.jcr.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.*;
import com.openkm.frontend.client.bean.GWTWorkflowComment;
import java.util.Map; 
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;

 
public class grantUser implements ActionHandler {
 
	private static final long serialVersionUID = 1L;
	String user;

@Override
  public void execute(ExecutionContext context) throws Exception {
        //Get document's path
        DirectDocumentModule docModule = DirectDocumentModule.class.newInstance();
        String token = JcrSessionManager.getInstance().getSystemToken();
        String uuid=(String)executionContext.getVariable("uuid");
        String path = docModule.getPath(token, uuid);
        
        //Grant User Read, Write
        String newUserName="dioikitis";
        OKMAuth oKMAuth = OKMAuth.getInstance();
        oKMAuth.grantUser(null, path, newUserName, Permission.READ, true);
        oKMAuth.grantUser(null, path, newUserName, Permission.WRITE, true);
  }
}
I attach an eclipse snapshot
eclipse.jpg
eclipse.jpg (191.66 KiB) Viewed 3034 times
Thank you and keep it open ;)

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.