Page 1 of 1

NullPointerException using OKMDocument move

PostPosted:Tue Apr 22, 2014 5:43 am
by matt81
Hi,
From a workflow I am trying to move a document in Openkm, using the following code:
OKMDocument.getInstance().move(token, "/okm:root/bla", "/okm:root/da");

However i am getting the following error:
Code: Select all
ERROR com.openkm.servlet.frontend.WorkflowServlet - 
com.openkm.core.WorkflowException
	at com.openkm.module.common.CommonWorkflowModule.runProcessDefinition(CommonWorkflowModule.java:286)
Caused by: java.lang.NullPointerException
	at com.openkm.module.db.DbDocumentModule.move(DbDocumentModule.java:1056)
	at com.openkm.api.OKMDocument.move(OKMDocument.java:292)
	at com.openkm.workflow.assignment.ConvertDoc.assign(ConvertDoc.java:118)
	at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignmentDelegation(TaskMgmtInstance.java:320)
	at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:274)
Do you know what the problem could be.

Thanks

Re: NullPointerException using OKMDocument move

PostPosted:Wed Apr 23, 2014 3:43 pm
by pavila
I need the complete code to guess what is happening.

Re: NullPointerException using OKMDocument move

PostPosted:Sun Apr 27, 2014 11:18 pm
by matt81
Well that's the line where it is throwing the error, prior to that I am just parsing strings and converting it to PDF like the following code:
Code: Select all
pathName = extFile.substring(0, slashName);
DocumentServlet cm = new DocumentServlet();
cm.convertToPdf(openkmPath);
Please note if I place the code in try catch, the error code is not thrown but I just need to know why this is happening.

Thanks

Re: NullPointerException using OKMDocument move

PostPosted:Mon Apr 28, 2014 6:40 am
by pavila
Sorry but I need a complete working example which can reproduce the error.

Re: NullPointerException using OKMDocument move

PostPosted:Wed Apr 30, 2014 11:07 pm
by matt81
OK here it is:
Code: Select all
public void assign(Assignable arg0, ExecutionContext exec) throws Exception {
		
		//Get UUID, token and nodepath
		String uuid = (String) exec.getContextInstance().getVariable("uuid");
		String token = exec.getToken().toString();
		String openkmPath = OKMRepository.getInstance().getNodePath(token, uuid);

//convert to PDF in openkm
		DocumentServlet cm = new DocumentServlet();
		cm.convertToPdf(openkmPath);

DocumentModule dr = ModuleManager.getDocumentModule();
			dr.move(token, pathName + "/" + deleteFile, "/okm:trash");

//move to next task node automatically
		exec.getToken().signal();
}
Please let me know.

Re: NullPointerException using OKMDocument move

PostPosted:Sat May 03, 2014 8:34 am
by jllort
A lot of strange things here:
Use servlet for conversion seems not good idea, why you do not use DocConverter.java class ?
What's is the pathName and deleteFile values ? I've not seen initialized anyware ?
If you want to delete a file should use OKMDocument.getInstance(token, pathFile to delete), should be deleted in user trash. Or if you want to store always in some place the idea should be create a folder called /okm:trash/workflow but not move files to /okm:trash, that seems not good idea.

Re: NullPointerException using OKMDocument move

PostPosted:Sun May 04, 2014 11:54 pm
by matt81
Thanks for the reply.
Well why would you say strange, it does the job.
I have tried all the other classes and I cannot achieve what I need. With DocConverter.java if I use the following two methods, I have to supply them with a FILE paramenter. How can I pass a File parameter when the file is located within openkm itself, I can only pass a string, hence why I cannot use them.
Code: Select all
DocConverter.getInstance().convert(File arg0, mimetype, File arg2);
DocConverter.getInstance().doc2pdf(File arg0, mimetype, File arg2);
I have tried to delete a file using the following code as well, as you suggested previously but it gave me the same error "Null pointer exception", and also a pop up sating that you cannot delete documents from workflows, hence why I used the move function to the trash folder.
Code: Select all
DocConverter.getInstance().delete(token, path);
The pathName and deleteFile values are initialised I just forgot to include them, so that's all good.
Everything has been tried hence why that solution works for me, aprt fromt he fact that it throws an error if it's not in try and catch block.

Thanks

Re: NullPointerException using OKMDocument move

PostPosted:Thu May 08, 2014 8:43 pm
by jllort
You got FileUtils.java class what allows you to create tmp file, work on int and when finished remove. Take a look here http://doxygen.openkm.com/openkm/d1/d5c ... utils.html