Search in sources :

Example 41 with CoreException

use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method getServiceByItem.

/**
 * Get service by give item. If item solving form-value, then form value service
 * is returned
 *
 * @param item
 * @param dtoClass
 * @return
 */
@SuppressWarnings("unchecked")
private <R extends Requestable> ReadDtoService<?, ?> getServiceByItem(IdmRequestItemDto item, Class<? extends R> dtoClass) {
    ReadDtoService<?, ?> readService = null;
    if (IdmFormValueDto.class.getName().equals(item.getOwnerType())) {
        // EAV value .. we need find form value service by super owner type
        String superOwnerType = item.getSuperOwnerType();
        Assert.notNull(superOwnerType, "Super owner type is mandatory for EAV value!");
        try {
            readService = this.getFormValueService((Class<? extends FormableEntity>) Class.forName(superOwnerType));
        } catch (ClassNotFoundException e) {
            throw new CoreException(e);
        }
    } else {
        // Standard DTO service
        readService = this.getDtoService(dtoClass);
    }
    return readService;
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)

Example 42 with CoreException

use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method get.

@Override
public <R extends Requestable> R get(UUID requestId, UUID dtoId, Class<R> dtoClass, BasePermission... permission) {
    Assert.notNull(dtoId, "DTO ID is required!");
    Assert.notNull(dtoClass, "DTO class is required!");
    Assert.notNull(requestId, "Request ID is required!");
    // Check permissions on the target service
    ReadDtoService<R, ?> dtoReadService = getDtoService(dtoClass);
    R dto = dtoReadService.get(dtoId, permission);
    if (dto == null) {
        try {
            dto = dtoClass.getDeclaredConstructor().newInstance();
        } catch (ReflectiveOperationException e) {
            throw new CoreException(e);
        }
        dto.setId(dtoId);
    }
    return get(requestId, dto);
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException)

Example 43 with CoreException

use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.

the class ExceptionUtilsUnitTest method testLogExceptionWithoutModel.

@Test
public void testLogExceptionWithoutModel() {
    ExceptionUtils.log(LOG, null, new CoreException("mock"));
    // error is logged without model is specified
    verify(LOG).error(any(String.class), any(CoreException.class));
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 44 with CoreException

use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.

the class ExceptionUtilsUnitTest method testLogModelLevelWarn.

@Test
public void testLogModelLevelWarn() {
    ExceptionUtils.log(LOG, new DefaultErrorModel(CoreResultCode.FORBIDDEN), new CoreException("mock"));
    // error is logged without model is specified
    verify(LOG).warn(any(String.class), any(Exception.class));
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) DefaultErrorModel(eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 45 with CoreException

use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowTaskInstanceService method historyToResource.

private FormDataDto historyToResource(FormProperty property, List<WorkflowHistoricTaskInstanceDto> history) {
    FormDataDto dto = new FormDataDto();
    dto.setId(property.getId());
    dto.setName(property.getName());
    String value;
    try {
        value = new ObjectMapper().writeValueAsString(history);
    } catch (JsonProcessingException e) {
        throw new CoreException(e);
    }
    dto.setValue(value);
    dto.setType(property.getType().getName());
    dto.setReadable(property.isReadable());
    dto.setRequired(property.isRequired());
    dto.setWritable(property.isWritable());
    return dto;
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) FormDataDto(eu.bcvsolutions.idm.core.workflow.model.dto.FormDataDto) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)64 UUID (java.util.UUID)16 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)15 Test (org.junit.Test)14 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)13 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)11 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)10 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)9 Field (java.lang.reflect.Field)9 Embedded (eu.bcvsolutions.idm.core.api.domain.Embedded)8 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)8 BaseEntity (eu.bcvsolutions.idm.core.api.entity.BaseEntity)8 List (java.util.List)8 Requestable (eu.bcvsolutions.idm.core.api.domain.Requestable)7 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)7 IdmRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)7 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)7 RequestOperationType (eu.bcvsolutions.idm.core.api.domain.RequestOperationType)6 IntrospectionException (java.beans.IntrospectionException)6