use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class KieServerPolicyJbpmIntegrationTest method testStartProcessInDifferentDeploymentWithAlias.
@Test
public void testStartProcessInDifferentDeploymentWithAlias() throws Exception {
Object person = createPersonInstance(USER_JOHN);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("test", USER_MARY);
parameters.put("number", new Integer(12345));
List<Object> list = new ArrayList<Object>();
list.add("item");
parameters.put("list", list);
parameters.put("person", person);
Long processInstanceIdV1 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters);
assertNotNull(processInstanceIdV1);
assertTrue(processInstanceIdV1.longValue() > 0);
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV1);
assertNotNull(processInstance);
assertEquals(CONTAINER_ID, processInstance.getContainerId());
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
ServiceResponse<KieContainerResourceList> containersResponse = client.listContainers();
KieServerAssert.assertSuccess(containersResponse);
List<KieContainerResource> containerResources = containersResponse.getResult().getContainers();
assertEquals(1, containerResources.size());
createExtraContainer();
// wait for sync
KieServerSynchronization.waitForKieServerSynchronization(client, 2);
Long processInstanceIdV2 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION_2, parameters);
assertNotNull(processInstanceIdV2);
assertTrue(processInstanceIdV2.longValue() > 0);
processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV2);
assertNotNull(processInstance);
assertEquals(CONTAINER_ID_101, processInstance.getContainerId());
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(2, tasks.size());
try {
// there are instances in both containers thus the older one cannot be disposed
processClient.abortProcessInstance(CONTAINER_ALIAS, processInstanceIdV1);
} catch (KieServicesException e) {
// In case we try to abort process belonging to currently disposed container then an exception is thrown (as process instance cannot be found in this case).
// Try to abort the process instance again after some time.
Thread.sleep(1000);
processClient.abortProcessInstance(CONTAINER_ALIAS, processInstanceIdV1);
}
// In case of race condition when we abort process instance on container
// which is in process of dispose try by policy, we will wait and synchronize again.
containersResponse = client.listContainers();
KieServerAssert.assertSuccess(containersResponse);
if (containersResponse.getResult().getContainers().size() == 1) {
Thread.sleep(1000);
}
// wait for policy to be activated
KieServerSynchronization.waitForKieServerSynchronization(client, 1);
containersResponse = client.listContainers();
KieServerAssert.assertSuccess(containersResponse);
containerResources = containersResponse.getResult().getContainers();
assertEquals(1, containerResources.size());
ReleaseId latestContainerReleaseId = containerResources.get(0).getReleaseId();
assertEquals(releaseId101, latestContainerReleaseId);
}
use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class KieServicesConfigurationImpl method setRemoteInitialContext.
@Override
public KieServicesConfiguration setRemoteInitialContext(InitialContext context) {
String prop = CONNECTION_FACTORY_NAME;
try {
if (this.connectionFactory == null) {
this.connectionFactory = (ConnectionFactory) context.lookup(prop);
}
prop = REQUEST_QUEUE_NAME;
this.requestQueue = (Queue) context.lookup(prop);
prop = RESPONSE_QUEUE_NAME;
this.responseQueue = (Queue) context.lookup(prop);
} catch (NamingException ne) {
throw new KieServicesException("Unable to retrieve object for " + prop, ne);
}
checkValidValues(connectionFactory, requestQueue, responseQueue);
return this;
}
use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeServiceQueryHelper method readTaskVariables.
private Map<String, Object> readTaskVariables(TaskData taskData) {
KieContainerInstanceImpl container = registry.getContainer(taskData.getContainerId());
if (container == null || (container.getStatus() != KieContainerStatus.STARTED && container.getStatus() != KieContainerStatus.DEACTIVATED)) {
throw new KieServicesException("Container " + taskData.getContainerId() + " is not available to serve requests");
}
Map<String, Object> variables = userTaskService.getTaskInputContentByTaskId(taskData.getContainerId(), taskData.getTaskId());
variables = variables == null ? new HashMap<>() : variables;
return variables.entrySet().stream().filter(entry -> isSimpleTypeValue(entry.getValue())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
Aggregations