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;
}
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);
}
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));
}
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));
}
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;
}
Aggregations