public class DocumentationRestExamples {
public void javaRemoteApiRestExample(String deploymentId, URL baseUrl, String user, String password) {
// Configure the RuntimeEngine instance with the necessarry information to communicate with the REST services, and build it
RemoteRuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()
.addDeploymentId(deploymentId)
.addUrl(baseUrl)
.addUserName(user)
.addPassword(password)
.build();
// Create KieSession and TaskService instances and use them
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
// Each opertion on a KieSession, TaskService or AuditLogService (client) instance
// sends a request for the operation to the server side and waits for the response
// If something goes wrong on the server side, the client will throw an exception.
ProcessInstance processInstance
= ksession.startProcess("com.burns.reactor.maintenance.cycle");
long procId = processInstance.getId();
String taskUserId = user;
taskService = engine.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(user, "en-UK");
long taskId = -1;
for (TaskSummary task : tasks) {
if (task.getProcessInstanceId() == procId) {