Search in sources :

Example 1 with AddNewRoleCompositionTaskExecutor

use of eu.bcvsolutions.idm.core.scheduler.task.impl.AddNewRoleCompositionTaskExecutor in project CzechIdMng by bcvsolutions.

the class RoleCompositionAfterCreateProcessor method process.

@Override
public EventResult<IdmRoleCompositionDto> process(EntityEvent<IdmRoleCompositionDto> event) {
    IdmRoleCompositionDto roleComposition = event.getContent();
    Assert.notNull(roleComposition.getId(), "Composition identifier is required.");
    // just for sure
    Assert.notNull(roleComposition.getSub(), "Composition sub role is required.");
    // 
    AddNewRoleCompositionTaskExecutor addRoleCompositionTask = AutowireHelper.createBean(AddNewRoleCompositionTaskExecutor.class);
    addRoleCompositionTask.setRoleCompositionId(roleComposition.getId());
    try {
        if (event.getPriority() == PriorityType.IMMEDIATE) {
            longRunningTaskManager.executeSync(addRoleCompositionTask);
        } else {
            longRunningTaskManager.execute(addRoleCompositionTask);
        }
    } catch (AcceptedException ex) {
        DefaultEventResult<IdmRoleCompositionDto> result = new DefaultEventResult<>(event, this);
        result.setSuspended(true);
        // 
        return result;
    }
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : AddNewRoleCompositionTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.AddNewRoleCompositionTaskExecutor) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException)

Aggregations

IdmRoleCompositionDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)1 AddNewRoleCompositionTaskExecutor (eu.bcvsolutions.idm.core.scheduler.task.impl.AddNewRoleCompositionTaskExecutor)1