use of eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel in project CzechIdMng by bcvsolutions.
the class ExceptionControllerAdvice method handle.
/**
* Optimistic lock exception - convert to result code exception.
*
* @param ex
* @return
* @since 9.6.3
*/
@ExceptionHandler(ObjectOptimisticLockingFailureException.class)
public ResponseEntity<ResultModels> handle(ObjectOptimisticLockingFailureException ex) {
ErrorModel errorModel = new DefaultErrorModel(CoreResultCode.OPTIMISTIC_LOCK_ERROR, ex.getMessage(), ImmutableMap.of("entityType", String.valueOf(ex.getPersistentClassName()), "entityId", ex.getIdentifier() != null ? ex.getIdentifier().toString() : ""));
LOG.warn("[" + errorModel.getId() + "] ", ex);
return new ResponseEntity<>(new ResultModels(errorModel), new HttpHeaders(), errorModel.getStatus());
}
use of eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel in project CzechIdMng by bcvsolutions.
the class ExceptionControllerAdvice method handle.
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity<ResultModels> handle(HttpRequestMethodNotSupportedException ex) {
ErrorModel errorModel = new DefaultErrorModel(CoreResultCode.METHOD_NOT_ALLOWED, ex.getMessage(), //
ImmutableMap.of(//
"errorMethod", //
ex.getMethod(), "supportedMethods", StringUtils.join(ex.getSupportedMethods(), ", ")));
LOG.warn("[" + errorModel.getId() + "] ", ex);
return new ResponseEntity<>(new ResultModels(errorModel), new HttpHeaders(), errorModel.getStatus());
}
use of eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel in project CzechIdMng by bcvsolutions.
the class ExceptionControllerAdvice method handle.
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<ResultModels> handle(AccessDeniedException ex) {
ErrorModel errorModel = new DefaultErrorModel(CoreResultCode.FORBIDDEN, ex.getMessage());
LOG.warn("[" + errorModel.getId() + "] ", ex);
return new ResponseEntity<>(new ResultModels(errorModel), new HttpHeaders(), errorModel.getStatus());
}
use of eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel in project CzechIdMng by bcvsolutions.
the class AbstractBackupBulkAction method prevalidate.
@Override
@SuppressWarnings("unchecked")
public ResultModels prevalidate() {
ResultModels results = new ResultModels();
Recoverable<DTO> service = (Recoverable<DTO>) getService();
String backupFolder = service.getBackupFolder();
if (StringUtils.isEmpty(backupFolder)) {
ResultModel result = new DefaultErrorModel(CoreResultCode.BACKUP_FOLDER_NOT_FOUND, ImmutableMap.of("property", Recoverable.BACKUP_FOLDER_CONFIG));
results.addInfo(result);
} else {
ResultModel result = new DefaultErrorModel(CoreResultCode.BACKUP_FOLDER_FOUND, ImmutableMap.of("backupFolder", backupFolder));
results.addInfo(result);
}
return results;
}
use of eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel 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));
}
Aggregations