Search in sources :

Example 1 with RequestManager

use of eu.bcvsolutions.idm.core.api.service.RequestManager in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method startRequest.

@Override
@Transactional
public IdmRequestDto startRequest(UUID requestId, boolean checkRight) {
    IdmRequestDto request = requestService.get(requestId);
    Assert.notNull(request, "Request is required!");
    try {
        RequestManager service = this.getRequestManager();
        if (!(service instanceof DefaultRequestManager)) {
            throw new CoreException("We expects instace of DefaultRequestManager!");
        }
        return ((DefaultRequestManager) service).startRequestNewTransactional(requestId, checkRight);
    } catch (Exception ex) {
        LOG.error(ex.getLocalizedMessage(), ex);
        request = requestService.get(requestId);
        Throwable exceptionToLog = ExceptionUtils.resolveException(ex);
        if (exceptionToLog instanceof ResultCodeException) {
            // 
            request.setResult(new // 
            OperationResultDto.Builder(// 
            OperationState.EXCEPTION).setException(// 
            (ResultCodeException) exceptionToLog).build());
        } else {
            // 
            request.setResult(new // 
            OperationResultDto.Builder(// 
            OperationState.EXCEPTION).setCause(// 
            exceptionToLog).build());
        }
        request.setState(RequestState.EXCEPTION);
        return requestService.save(request);
    }
}
Also used : RequestManager(eu.bcvsolutions.idm.core.api.service.RequestManager) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) Builder(eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IOException(java.io.IOException) RoleRequestException(eu.bcvsolutions.idm.core.api.exception.RoleRequestException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IdmRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)1 Builder (eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder)1 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 RoleRequestException (eu.bcvsolutions.idm.core.api.exception.RoleRequestException)1 RequestManager (eu.bcvsolutions.idm.core.api.service.RequestManager)1 IntrospectionException (java.beans.IntrospectionException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Transactional (org.springframework.transaction.annotation.Transactional)1