Java Code Examples for org.springframework.http.HttpStatus#NOT_ACCEPTABLE
The following examples show how to use
org.springframework.http.HttpStatus#NOT_ACCEPTABLE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HodConfigurationController.java From find with MIT License | 6 votes |
@SuppressWarnings("ProhibitedExceptionDeclared") @RequestMapping(value = "/config", method = {RequestMethod.POST, RequestMethod.PUT}) @ResponseBody public ResponseEntity<?> saveConfig(@RequestBody final ConfigResponse<HodFindConfig> configResponse) throws Exception { try { log.info(Markers.AUDIT, "REQUESTED CHANGE APPLICATION CONFIGURATION"); configService.updateConfig(configResponse.getConfig()); log.info(Markers.AUDIT, "CHANGED APPLICATION CONFIGURATION"); return new ResponseEntity<>(configService.getConfigResponse(), HttpStatus.OK); } catch (final ConfigException ce) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("exception", ce.getMessage()), HttpStatus.NOT_ACCEPTABLE); } catch (final ConfigValidationException cve) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("validation", cve.getValidationErrors()), HttpStatus.NOT_ACCEPTABLE); } }
Example 2
Source File: IdolConfigurationController.java From find with MIT License | 6 votes |
@SuppressWarnings("ProhibitedExceptionDeclared") @RequestMapping(value = "/config", method = {RequestMethod.POST, RequestMethod.PUT}) public ResponseEntity<?> saveConfig(@RequestBody final IdolFindConfigWrapper configResponse) throws Exception { log.info(Markers.AUDIT, "REQUESTED UPDATE CONFIGURATION"); //TODO: move this to CommunityAuthentication validator once FIND-1254 is complete if (LoginTypes.DEFAULT.equals(configResponse.getConfig().getAuthentication().getMethod())) { final ValidationResults validationResults = new ValidationResults.Builder() .put("login", new ValidationResult<>(false, CommunityAuthenticationValidation.DEFAULT_LOGIN)) .build(); return new ResponseEntity<>(Collections.singletonMap("validation", validationResults), HttpStatus.NOT_ACCEPTABLE); } try { configService.updateConfig(configResponse.getConfig()); final Object response = configService.getConfigResponse(); log.info(Markers.AUDIT, "UPDATED CONFIGURATION"); return new ResponseEntity<>(response, HttpStatus.OK); } catch (final ConfigException ce) { return new ResponseEntity<>(Collections.singletonMap("exception", ce.getMessage()), HttpStatus.NOT_ACCEPTABLE); } catch (final ConfigValidationException cve) { return new ResponseEntity<>(Collections.singletonMap("validation", cve.getValidationErrors()), HttpStatus.NOT_ACCEPTABLE); } }
Example 3
Source File: MultiPickerUploadController.java From FileUpload.Java with Apache License 2.0 | 6 votes |
@PostMapping("/") public ResponseEntity<Void> fileUpload(@RequestParam("type") String type, @RequestParam("name") String name, @RequestParam("file") MultipartFile file) throws Exception { switch (type) { case "researchReport": //研究报告 //save file break; case "researchReportStuff": //研究报告支撑材料(限PDF) //save file break; case "applyReport": //应用报告 //save file break; case "applyReportStuff": //应用报告支撑材料(限PDF) //save file break; default: return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } return new ResponseEntity<>(HttpStatus.CREATED); }
Example 4
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidRestaurantException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidRestaurantException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 5
Source File: UserServiceImpl.java From biliob_backend with MIT License | 5 votes |
@Override public ResponseEntity<Result<?>> createUser( String username, String password, String mail, String activationCode) { User user = new User(username, password, RoleEnum.NORMAL_USER.getName()); if (!mailUtil.checkActivationCode(mail, activationCode)) { return new ResponseEntity<>( new Result<>(ResultEnum.ACTIVATION_CODE_UNMATCHED), HttpStatus.BAD_REQUEST); } // activation code unmatched if (1 == userRepository.countByName(user.getName())) { // 已存在同名 return new ResponseEntity<>( new Result<>(ResultEnum.USER_ALREADY_EXIST), HttpStatus.BAD_REQUEST); } if (mongoTemplate.exists(Query.query(Criteria.where("mail").is(mail)), "user")) { return new ResponseEntity<>( new Result<>(ResultEnum.MAIL_HAD_BEEN_REGISTERED), HttpStatus.NOT_ACCEPTABLE); } user.setName(user.getName()); user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); user.setNickName(user.getName()); user.setMail(mail); user.setCredit(0D); user.setExp(0D); user.setRole("普通用户"); userRepository.save(user); UserServiceImpl.logger.info(user.getName()); // 不要返回密码 user.setPassword(null); return new ResponseEntity<>(new Result<>(ResultEnum.SUCCEED, user), HttpStatus.OK); }
Example 6
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidUserException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidUserException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 7
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidRestaurantException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidRestaurantException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 8
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidBookingException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidBookingException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 9
Source File: ExceptionAdviceHandler.java From oauth-boot with MIT License | 5 votes |
/** * 406错误 */ @ExceptionHandler({HttpMediaTypeNotAcceptableException.class}) @ResponseStatus(HttpStatus.NOT_ACCEPTABLE) public BaseResponse request406(HttpServletResponse resp) { return baseResponse(405, "类型不匹配"); }
Example 10
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidRestaurantException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidRestaurantException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 11
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidBookingException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidBookingException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 12
Source File: SessionRestController.java From openvidu with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/recordings/stop/{recordingId}", method = RequestMethod.POST) public ResponseEntity<?> stopRecordingSession(@PathVariable("recordingId") String recordingId) { log.info("REST API: POST /api/recordings/stop/{}", recordingId); Recording recording = recordingManager.getStartedRecording(recordingId); if (recording == null) { if (recordingManager.getStartingRecording(recordingId) != null) { // Recording is still starting return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } // Recording does not exist return new ResponseEntity<>(HttpStatus.NOT_FOUND); } if (!this.recordingManager.sessionIsBeingRecorded(recording.getSessionId())) { // Session is not being recorded return new ResponseEntity<>(HttpStatus.CONFLICT); } Session session = sessionManager.getSession(recording.getSessionId()); Recording stoppedRecording = this.recordingManager.stopRecording(session, recording.getId(), EndReason.recordingStoppedByServer); session.recordingManuallyStopped.set(true); if (session != null && !session.isClosed() && OutputMode.COMPOSED.equals(recording.getOutputMode()) && recording.hasVideo()) { sessionManager.evictParticipant( session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null, null); } return new ResponseEntity<>(stoppedRecording.toJson().toString(), getResponseHeaders(), HttpStatus.OK); }
Example 13
Source File: ErrorController.java From LodView with MIT License | 5 votes |
@ResponseStatus(value = HttpStatus.NOT_ACCEPTABLE, reason = "unhandled encoding") @RequestMapping(value = "/406") public String error406(HttpServletResponse res, ModelMap model, @CookieValue(value = "colorPair") String colorPair) { System.out.println("not acceptable"); model.addAttribute("statusCode", "406"); model.addAttribute("conf", conf); colors(colorPair, res, model); res.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); return "error"; }
Example 14
Source File: EndpointErrorHandler.java From Mastering-Microservices-with-Java-Third-Edition with MIT License | 5 votes |
@ExceptionHandler(InvalidUserException.class) public ResponseEntity<ErrorInfo> handleInvalidRestaurantException(HttpServletRequest request, InvalidUserException ex, Locale locale) { ErrorInfo response = new ErrorInfo(); response.setUrl(request.getRequestURL().toString()); response.setMessage(messageSource.getMessage(ex.getMessage(), ex.getArgs(), locale)); return new ResponseEntity<>(response, HttpStatus.NOT_ACCEPTABLE); }
Example 15
Source File: MaxSizeRuleTest.java From CheckPoint with Apache License 2.0 | 4 votes |
@Override public void exception(ValidationData param, Object inputValue, Object standardValue) { throw new ValidationLibException(param.getName() + " order exception", HttpStatus.NOT_ACCEPTABLE); }
Example 16
Source File: NotAcceptableStatusException.java From spring-analysis-note with MIT License | 4 votes |
/** * Constructor for when the requested Content-Type is not supported. */ public NotAcceptableStatusException(List<MediaType> supportedMediaTypes) { super(HttpStatus.NOT_ACCEPTABLE, "Could not find acceptable representation"); this.supportedMediaTypes = Collections.unmodifiableList(supportedMediaTypes); }
Example 17
Source File: BlackListCheck.java From CheckPoint with Apache License 2.0 | 4 votes |
@Override public void exception(ValidationData param, Object inputValue, Object standardValue) { throw new ValidationLibException(inputValue + " is bad", HttpStatus.NOT_ACCEPTABLE); }
Example 18
Source File: MinSizeRuleTest.java From CheckPoint with Apache License 2.0 | 4 votes |
@Override public void exception(ValidationData param, Object inputValue, Object standardValue) { throw new ValidationLibException(param.getName() + " order exception", HttpStatus.NOT_ACCEPTABLE); }
Example 19
Source File: PatternRuleTest.java From CheckPoint with Apache License 2.0 | 4 votes |
@Override public void exception(ValidationData param, Object inputValue, Object standardValue) { throw new ValidationLibException(param.getName() + " order exception", HttpStatus.NOT_ACCEPTABLE); }
Example 20
Source File: NotAcceptableStatusException.java From java-technology-stack with MIT License | 4 votes |
/** * Constructor for when requested Content-Type is not supported. */ public NotAcceptableStatusException(List<MediaType> supportedMediaTypes) { super(HttpStatus.NOT_ACCEPTABLE, "Could not find acceptable representation", null); this.supportedMediaTypes = Collections.unmodifiableList(supportedMediaTypes); }