use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class MidpointUtil method recordEventInTask.
// additional delta is a bit hack ... TODO refactor (but without splitting the modify operation!)
public static void recordEventInTask(CaseEventType event, ObjectDeltaType additionalDelta, String taskOid, OperationResult result) {
RepositoryService cacheRepositoryService = getCacheRepositoryService();
PrismContext prismContext = getPrismContext();
try {
S_ItemEntry deltaBuilder = DeltaBuilder.deltaFor(TaskType.class, getPrismContext()).item(F_WORKFLOW_CONTEXT, F_EVENT).add(event);
if (additionalDelta != null) {
PrismObject<TaskType> task = cacheRepositoryService.getObject(TaskType.class, taskOid, null, result);
WfPrimaryChangeProcessorStateType state = WfContextUtil.getPrimaryChangeProcessorState(task.asObjectable().getWorkflowContext());
ObjectTreeDeltasType updatedDelta = ObjectTreeDeltas.mergeDeltas(state.getDeltasToProcess(), additionalDelta, prismContext);
// assuming it already exists!
ItemPath deltasToProcessPath = new ItemPath(F_WORKFLOW_CONTEXT, F_PROCESSOR_SPECIFIC_STATE, WfPrimaryChangeProcessorStateType.F_DELTAS_TO_PROCESS);
ItemDefinition<?> deltasToProcessDefinition = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(WfPrimaryChangeProcessorStateType.class).findItemDefinition(WfPrimaryChangeProcessorStateType.F_DELTAS_TO_PROCESS);
deltaBuilder = deltaBuilder.item(deltasToProcessPath, deltasToProcessDefinition).replace(updatedDelta);
}
cacheRepositoryService.modifyObject(TaskType.class, taskOid, deltaBuilder.asItemDeltas(), result);
} catch (ObjectNotFoundException | SchemaException | ObjectAlreadyExistsException e) {
throw new SystemException("Couldn't record decision to the task " + taskOid + ": " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class ActivitiInterface method notifyMidpointAboutProcessEvent.
private void notifyMidpointAboutProcessEvent(ProcessEvent event) {
OperationResult result = new OperationResult(DOT_CLASS + "notifyMidpointAboutProcessEvent");
String taskOid = ActivitiUtil.getTaskOid(event.getVariables());
Task task;
try {
task = taskManager.getTask(taskOid, result);
} catch (ObjectNotFoundException | SchemaException | RuntimeException e) {
throw new SystemException("Couldn't get task " + taskOid + " from repository: " + e.getMessage(), e);
}
if (task.getExecutionStatus() != TaskExecutionStatus.WAITING) {
LOGGER.trace("Asynchronous message received in a state different from WAITING (actual state: {}), ignoring it. Task = {}", task.getExecutionStatus(), task);
return;
}
try {
wfTaskController.onProcessEvent(event, task, result);
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | RuntimeException e) {
throw new SystemException("Couldn't process a process-related event: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class TestDummy method test600AddAccountAlreadyExist.
@Test
public void test600AddAccountAlreadyExist() throws Exception {
final String TEST_NAME = "test600AddAccountAlreadyExist";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
syncServiceMock.reset();
dummyResourceCtl.addAccount(ACCOUNT_MURRAY_USERNAME, ACCOUNT_MURRAY_USERNAME);
PrismObject<ShadowType> account = createShadowNameOnly(resource, ACCOUNT_MURRAY_USERNAME);
account.checkConsistence();
display("Adding shadow", account);
// WHEN
try {
provisioningService.addObject(account, null, null, task, result);
AssertJUnit.fail("Unexpected success");
} catch (ObjectAlreadyExistsException e) {
// This is expected
display("Expected exception", e);
}
// THEN
result.computeStatus();
display("add object result", result);
TestUtil.assertFailure(result);
// Even though the operation failed a shadow should be created for the conflicting object
PrismObject<ShadowType> accountRepo = findAccountShadowByUsername(getMurrayRepoIcfName(), resource, result);
assertNotNull("Shadow was not created in the repository", accountRepo);
display("Repository shadow", accountRepo);
checkRepoAccountShadow(accountRepo);
assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo));
assertSteadyResource();
}
Aggregations