List of usage examples for org.springframework.http HttpStatus PAYLOAD_TOO_LARGE
HttpStatus PAYLOAD_TOO_LARGE
To view the source code for org.springframework.http HttpStatus PAYLOAD_TOO_LARGE.
Click Source Link
From source file:cn.edu.zjnu.acm.judge.controller.MailController.java
@PostMapping("/send") @SuppressWarnings("AssignmentToMethodParameter") public String send(@RequestParam("title") String title, @RequestParam("to") String to, @RequestParam("content") String content, Authentication authentication) { String userId = authentication != null ? authentication.getName() : null; if (StringUtils.isEmptyOrWhitespace(title)) { title = "No Topic"; }/*w ww . ja v a2 s .c o m*/ if (content.length() > 40000) { throw new MessageException("Sorry, content too long", HttpStatus.PAYLOAD_TOO_LARGE); } if (userMapper.findOne(to) == null) { throw new MessageException("Sorry, no such user:" + to, HttpStatus.NOT_FOUND); } mailMapper.save(Mail.builder().from(userId).to(to).title(title).content(content).build()); return "mails/sendsuccess"; }
From source file:com.oneops.opamp.ws.OpampWsController.java
/** * Get all cache entries. If cache has more than 100 items, it will respond with * <b>413 Request Entity Too Large</b> http status code. * * @return cache entries map.//from w ww .j ava2s . c om */ @RequestMapping(value = "/cache/entries", method = RequestMethod.GET) @ResponseBody public ResponseEntity<Map<String, Object>> getCacheEntries() { // Do a cache maintenance first before getting the size cache.instance().cleanUp(); long size = cache.instance().size(); Map<String, Object> stat = new LinkedHashMap<>(3); if (size > 100) { stat.put("status", "Too many cache entries (size=" + size + ")"); return new ResponseEntity<>(stat, HttpStatus.PAYLOAD_TOO_LARGE); } stat.put("status", "ok"); stat.put("size", size); Map<String, String> map = cache.instance().asMap(); Map<String, Object> entries = new HashMap<>(map.size()); for (String key : map.keySet()) { entries.put(key, map.get(key)); } stat.put("entries", entries); return new ResponseEntity<>(stat, HttpStatus.OK); }
From source file:uk.ac.ebi.eva.server.ws.ga4gh.GA4GHVariantWSServer.java
@ExceptionHandler(IllegalArgumentException.class) public void handleException(IllegalArgumentException e, HttpServletResponse response) throws IOException { response.sendError(HttpStatus.PAYLOAD_TOO_LARGE.value(), e.getMessage()); }