use of org.springframework.web.bind.annotation.ResponseBody in project cas by apereo.
the class StatusController method handleRequestInternal.
/**
* Handle request.
*
* @param request the request
* @param response the response
* @throws Exception the exception
*/
@GetMapping
@ResponseBody
protected void handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
ensureEndpointAccessIsAuthorized(request, response);
final StringBuilder sb = new StringBuilder();
final Health health = this.healthEndpoint.invoke();
final Status status = health.getStatus();
if (status.equals(Status.DOWN) || status.equals(Status.OUT_OF_SERVICE)) {
response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value());
}
sb.append("Health: ").append(status.getCode());
sb.append("\n\nHost:\t\t").append(StringUtils.isBlank(casProperties.getHost().getName()) ? InetAddressUtils.getCasServerHostName() : casProperties.getHost().getName());
sb.append("\nServer:\t\t").append(casProperties.getServer().getName());
sb.append("\nVersion:\t").append(CasVersion.getVersion());
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
try (Writer writer = response.getWriter()) {
IOUtils.copy(new ByteArrayInputStream(sb.toString().getBytes(response.getCharacterEncoding())), writer, StandardCharsets.UTF_8);
writer.flush();
}
}
use of org.springframework.web.bind.annotation.ResponseBody in project cas by apereo.
the class TrustedDevicesController method getRecords.
/**
* Gets records.
*
* @param request the request
* @param response the response
* @return the records
*/
@GetMapping(value = "/getRecords")
@ResponseBody
public Set<MultifactorAuthenticationTrustRecord> getRecords(final HttpServletRequest request, final HttpServletResponse response) {
ensureEndpointAccessIsAuthorized(request, response);
final TrustedDevicesMultifactorProperties trusted = casProperties.getAuthn().getMfa().getTrusted();
final LocalDate onOrAfter = LocalDate.now().minus(trusted.getExpiration(), DateTimeUtils.toChronoUnit(trusted.getTimeUnit()));
this.mfaTrustEngine.expire(onOrAfter);
return this.mfaTrustEngine.get(onOrAfter);
}
use of org.springframework.web.bind.annotation.ResponseBody in project cuba by cuba-platform.
the class RestControllerExceptionHandler method handleMethodResultValidationException.
@ExceptionHandler(MethodResultValidationException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleMethodResultValidationException(MethodResultValidationException e) {
log.error("MethodResultValidationException in service", e);
ErrorInfo errorInfo = new ErrorInfo("Server error", "");
return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
use of org.springframework.web.bind.annotation.ResponseBody in project cuba by cuba-platform.
the class RestControllerExceptionHandler method handleValidationException.
@ExceptionHandler(ValidationException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleValidationException(ValidationException e) {
log.error("ValidationException in service", e);
ErrorInfo errorInfo = new ErrorInfo("Server error", "");
return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
use of org.springframework.web.bind.annotation.ResponseBody in project production_ssm by megagao.
the class PMeasureCheckController method deleteBatch.
@RequestMapping(value = "/delete_batch")
@ResponseBody
private CustomResult deleteBatch(String[] ids) throws Exception {
System.out.println(ids);
CustomResult result = pMeasureCheckService.deleteBatch(ids);
return result;
}
Aggregations