Search in sources :

Example 1 with Builder

use of eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method changeRequestState.

/**
 * Change request state
 *
 * @param requestable
 * @param request
 * @param ex
 * @return
 */
private <R extends Requestable> IdmRequestDto changeRequestState(R requestable, IdmRequestDto request, ResultCodeException ex) {
    if (request.getState().isTerminatedState()) {
        // If is request in the terminated state, then we only add result code
        // exception,
        // but don't modify the result state
        request.setResult(// 
        new Builder(request.getResult().getState()).setException(// 
        ex).build());
    } else {
        request = requestService.cancel(request);
        request.setResult(// 
        new Builder(OperationState.CANCELED).setException(// 
        ex).build());
    }
    if (requestable instanceof Codeable && ((Codeable) requestable).getCode() != null) {
        request.setName(((Codeable) requestable).getCode());
    }
    return request;
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) Builder(eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder)

Example 2 with Builder

use of eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method changeItemState.

/**
 * Change item state
 *
 * @param requestable
 * @param item
 * @param ex
 * @return
 */
private <R extends Requestable> IdmRequestItemDto changeItemState(R requestable, IdmRequestItemDto item, ResultCodeException ex) {
    if (item.getState().isTerminatedState()) {
        // If is item in the terminated state, then we only add result code exception,
        // but don't modify the result state
        item.setResult(// 
        new Builder(item.getResult().getState()).setException(// 
        ex).build());
    } else {
        item = requestItemService.cancel(item);
        item.setResult(// 
        new Builder(OperationState.CANCELED).setException(// 
        ex).build());
    }
    return item;
}
Also used : Builder(eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder)

Aggregations

Builder (eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder)2 Codeable (eu.bcvsolutions.idm.core.api.domain.Codeable)1