I'm trying to create a workflow that creates a folder and moves a file to it. However I have been unsuccessful and cannot even add a folder. Im implementing the logic in the action handler of the node that is supposed to create this folder. Any suggestions are greatly appreciated?
Code: Select all
the forms.xml
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Test">
<start-state name="start">
<transition to="clientInfo"></transition>
</start-state>
<task-node name="clientInfo">
<task name="File Delegation">
<assignment actor-id="okmAdmin"></assignment>
<event type="task-create">
<script>
taskInstance.start();
</script>
</event>
</task>
<transition to="moveFile"></transition>
</task-node>
<node name="moveFile">
<action class="com.Test.TestHandler"></action>
<transition to="end"></transition>
</node>
<end-state name="end"></end-state>
</process-definition>
Code: Select all
here is the Handler implementation
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 1.0//EN"
"http://www.openkm.com/dtd/workflow-forms-1.0.dtd">
<workflow-forms>
<workflow-form task="File Delegation">
<input label="Enter Client's First Name" name="firstName" />
<input label="Enter Client's Last Name" name="lastName" />
<button label="Submit" />
</workflow-form>
</workflow-forms>
Code: Select all
package com.Test;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.api.OKMAuth;
import com.openkm.api.OKMDocument;
import com.openkm.api.OKMFolder;
import com.openkm.bean.form.Input;
public class TestHandler implements ActionHandler
{
private static final long serialVersionUID = 1L;
String firstName;
String lastName;
public void execute(ExecutionContext context) throws Exception
{
firstName = context.getContextInstance().getVariable("firstName").toString().trim();
lastName = context.getContextInstance().getVariable("lastName").toString().trim();
String token = OKMAuth.getInstance().login("okmAdmin", "admin");
Input DP = (Input) context.getContextInstance().getVariable("path");
String docPath = DP.getValue().trim();
if (!OKMFolder.getInstance().isValid(token, "/okm:root/" + lastName + ", " + firstName))
OKMFolder.getInstance().createSimple(token, "/okm:root/" + lastName + ", " + firstName);
OKMDocument.getInstance().move(token, docPath, "/okm:root/" + lastName + ", " + firstName);
context.leaveNode();
}
}