use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(AlreadyExistException.class)
public ResponseEntity<JsonResult> exceptionHandler(AlreadyExistException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(ALREADY_EXIST);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(NoExecutableFileException.class)
public ResponseEntity<JsonResult> exceptionHandler(NoExecutableFileException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(PasswordValidationException.class)
public ResponseEntity<JsonResult> exceptionHandler(PasswordValidationException ex) {
LOGGER.error("User tried to register with weak password");
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage("You have provided a weak password");
final ArachnePasswordInfoDTO passwordInfoDTO = conversionService.convert(ex.getPasswordInfo(), ArachnePasswordInfoDTO.class);
result.getValidatorErrors().put("password", passwordInfoDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeController method update.
@ApiOperation(value = "Update professional type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/professional-types/{professionalTypeId}", method = RequestMethod.PUT)
public JsonResult<CommonProfessionalTypeDTO> update(@PathVariable("professionalTypeId") Long id, @RequestBody @Valid CommonProfessionalTypeDTO professionalTypeDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
JsonResult result = null;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
ProfessionalType professionalType = conversionService.convert(professionalTypeDTO, ProfessionalType.class);
professionalType.setId(id);
professionalType = professionalTypeService.update(professionalType);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(professionalType);
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeController method get.
@ApiOperation("Get professional type.")
@RequestMapping(value = "/api/v1/user-management/professional-types/{professionalTypeId}", method = RequestMethod.GET)
public JsonResult<CommonProfessionalTypeDTO> get(@PathVariable("professionalTypeId") Long id) throws NotExistException {
JsonResult result;
if (id == null) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("professionalTypeId", "cannot be null");
} else {
ProfessionalType skill = professionalTypeService.getById(id);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(skill);
}
return result;
}
Aggregations