Page 1 of 1

Import openkm classes inside an ActionHandler

PostPosted:Sat Jul 07, 2012 11:56 pm
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 3031 times
Thank you and keep it open ;)

Re: Import openkm classes inside an ActionHandler

PostPosted:Mon Jul 09, 2012 5:59 am
by noxious
Please, I just need the path to import com.openkm classes...

Re: Import openkm classes inside an ActionHandler

PostPosted:Mon Jul 09, 2012 2:29 pm
by noxious
Ok, I figured it out by myself...You have to download all the source code of the project (http://wiki.openkm.com/index.php/Developer_Guide).

Re: Import openkm classes inside an ActionHandler

PostPosted:Tue Jul 10, 2012 8:18 pm
by jllort