List of usage examples for org.springframework.http HttpStatus UNSUPPORTED_MEDIA_TYPE
HttpStatus UNSUPPORTED_MEDIA_TYPE
To view the source code for org.springframework.http HttpStatus UNSUPPORTED_MEDIA_TYPE.
Click Source Link
From source file:io.curly.commons.config.feign.ErrorDecoderFactory.java
public static Exception create(HttpStatus httpStatus, String reason) { if (httpStatus.equals(HttpStatus.NOT_FOUND)) { return new ResourceNotFoundException(reason); } else if (httpStatus.equals(HttpStatus.BAD_REQUEST)) { return new BadRequestException(reason); } else if (httpStatus.equals(HttpStatus.INTERNAL_SERVER_ERROR)) { return new InternalServerErrorException(reason); } else if (httpStatus.equals(HttpStatus.UNAUTHORIZED)) { return new UnauthorizedException(reason); } else if (httpStatus.equals(HttpStatus.UNSUPPORTED_MEDIA_TYPE)) { return new UnsupportedMediaTypeException(reason); }/*from ww w . ja va 2 s . c o m*/ return new BadRequestException(reason); }
From source file:fr.olympicinsa.riocognized.exception.MyExceptionHandler.java
@ExceptionHandler(InvalidContent.class) @ResponseBody//from ww w .j ava 2s . c o m @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE) public ErrorMessage handleInvalidContent(InvalidContent e, HttpServletRequest req) { return new ErrorMessage("INVALID_OR_EMPTY_CONTENT"); }
From source file:apiserver.services.images.controllers.manipulations.BorderController.java
/** * Draw a border around an image//from w w w .j ava 2 s. co m * * @param documentId * @param color * @param thickness * @param format * @return * @throws InterruptedException * @throws java.util.concurrent.ExecutionException * @throws java.util.concurrent.TimeoutException * @throws java.io.IOException */ @RequestMapping(value = "/modify/{documentId}/border.{format}", method = { RequestMethod.GET }) public ResponseEntity<byte[]> drawBorderByImage( @ApiParam(name = "documentId", required = true) @PathVariable(value = "documentId") String documentId, @ApiParam(name = "color", required = true) @RequestParam(required = true) String color, @ApiParam(name = "thickness", required = true) @RequestParam(required = true) Integer thickness, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws InterruptedException, ExecutionException, TimeoutException, IOException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } FileBorderJob args = new FileBorderJob(); args.setDocumentId(documentId); args.setColor(color); args.setThickness(thickness); args.setFormat(format); Future<Map> imageFuture = imageDrawBorderGateway.imageDrawBorderFilter(args); FileBorderJob payload = (FileBorderJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); //pass CF Response back to the client return payload.getHttpResponse(); }
From source file:apiserver.services.images.controllers.filters.BlurController.java
/** * This filter blurs an uploaded image very slightly using a 3x3 blur kernel. * * @param documentId/*from w w w . ja va 2 s . c om*/ * @param format * @return * @throws java.util.concurrent.TimeoutException * @throws java.util.concurrent.ExecutionException * @throws InterruptedException * @throws java.io.IOException */ @ApiOperation(value = "This filter blurs an image very slightly using a 3x3 blur kernel.") @RequestMapping(value = "/filter/{documentId}/blur.{format}", method = RequestMethod.GET) public ResponseEntity<byte[]> imageBlurById( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws TimeoutException, ExecutionException, InterruptedException, IOException, URISyntaxException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } ImageDocumentJob job = new ImageDocumentJob(); job.setDocumentId(documentId); Future<Map> imageFuture = imageFilterBlurGateway.imageBlurFilter(job); ImageDocumentJob payload = (ImageDocumentJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }
From source file:apiserver.services.images.controllers.manipulations.RotateController.java
/** * rotate an image/*from w ww . j a va 2s .c o m*/ * * @param documentId * @param angle * @return */ @ApiOperation(value = "Rotate an uploaded image") @RequestMapping(value = "/modify/{documentId}/rotate.{format}", method = { RequestMethod.GET }) @ResponseBody public ResponseEntity<byte[]> rotateImageByImage( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "angle", required = true, defaultValue = "90") @RequestParam(required = true, defaultValue = "90") Integer angle, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws IOException, InterruptedException, ExecutionException, TimeoutException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } FileRotateJob job = new FileRotateJob(); job.setDocumentId(documentId); job.setAngle(angle); Future<Map> imageFuture = imageRotateGateway.rotateImage(job); FileRotateJob payload = (FileRotateJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }
From source file:apiserver.services.images.controllers.filters.MaximumController.java
/** * This filter blurs an uploaded image very slightly using a 3x3 blur kernel. * * @param documentId/*from w w w. j a va 2s. c o m*/ * @param format * @return * @throws java.util.concurrent.TimeoutException * @throws java.util.concurrent.ExecutionException * @throws InterruptedException * @throws java.io.IOException */ @ApiOperation(value = "This filter replaces each pixel by the maximum of the input pixel and its eight neighbours. Each of the RGB channels is considered separately.") @RequestMapping(value = "/filter/{documentId}/maximum.{format}", method = { RequestMethod.GET }) @ResponseBody public ResponseEntity<byte[]> imageMaximumByFile( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws TimeoutException, ExecutionException, InterruptedException, IOException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } ImageDocumentJob args = new ImageDocumentJob(); args.setDocumentId(documentId); Future<Map> imageFuture = imageFilterMaximumGateway.imageMaximumFilter(args); ImageDocumentJob payload = (ImageDocumentJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }
From source file:apiserver.services.images.controllers.filters.GaussianController.java
/** * This filter performs a Gaussian blur on an uploaded image. * * @param documentId// w w w . ja va2s . c o m * @param radius * @param format * @return * @throws java.util.concurrent.TimeoutException * @throws java.util.concurrent.ExecutionException * @throws InterruptedException * @throws java.io.IOException */ @ApiOperation(value = "This filter performs a Gaussian blur on an image.") @RequestMapping(value = "/filter/{documentId}/gaussian.{format}", method = { RequestMethod.GET }) public ResponseEntity<byte[]> imageDespeckleByFile( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "radius", required = true, defaultValue = "2") @RequestParam(required = false, defaultValue = "2") int radius, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws TimeoutException, ExecutionException, InterruptedException, IOException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } GaussianJob args = new GaussianJob(); args.setDocumentId(documentId); args.setRadius(radius); Future<Map> imageFuture = imageFilterGaussianGateway.imageGaussianFilter(args); ImageDocumentJob payload = (ImageDocumentJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }
From source file:apiserver.services.images.controllers.filters.MedianController.java
/** * This filter replaces each pixel by the median of the input pixel and its eight neighbours. Each of the RGB channels is considered separately. * * @param documentId//from w w w . j a v a 2 s. co m * @param format * @return * @throws java.util.concurrent.TimeoutException * @throws java.util.concurrent.ExecutionException * @throws InterruptedException * @throws java.io.IOException */ @ApiOperation(value = "This filter replaces each pixel by the median of the input pixel and its eight neighbours. Each of the RGB channels is considered separately.") @RequestMapping(value = "/filter/{documentId}/median.{format}", method = { RequestMethod.GET }) @ResponseBody public ResponseEntity<byte[]> imageMedianByFile( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws TimeoutException, ExecutionException, InterruptedException, IOException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } ImageDocumentJob args = new ImageDocumentJob(); args.setDocumentId(documentId); Future<Map> imageFuture = imageFilterMedianGateway.imageMedianFilter(args); ImageDocumentJob payload = (ImageDocumentJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }
From source file:apiserver.services.images.controllers.filters.MinimumController.java
/** * This filter replaces each pixel by the median of the input pixel and its eight neighbours. Each of the RGB channels is considered separately. * * @param documentId// ww w . ja v a 2s . com * @param format * @return * @throws java.util.concurrent.TimeoutException * @throws java.util.concurrent.ExecutionException * @throws InterruptedException * @throws java.io.IOException */ @ApiOperation(value = "This filter replaces each pixel by the minimum of the input pixel and its eight neighbours. Each of the RGB channels is considered separately.") @RequestMapping(value = "/filter/{documentId}/minimum.{format}", method = { RequestMethod.GET }) @ResponseBody public ResponseEntity<byte[]> imageMinimumByFile( @ApiParam(name = "documentId", required = true, defaultValue = "8D981024-A297-4169-8603-E503CC38EEDA") @PathVariable(value = "documentId") String documentId, @ApiParam(name = "format", required = true, defaultValue = "jpg") @PathVariable(value = "format") String format ) throws TimeoutException, ExecutionException, InterruptedException, IOException { String _contentType = MimeType.getMimeType(format).contentType; if (!MimeType.getMimeType(format).isSupportedImage()) { return new ResponseEntity<byte[]>(HttpStatus.UNSUPPORTED_MEDIA_TYPE); } ImageDocumentJob args = new ImageDocumentJob(); args.setDocumentId(documentId); Future<Map> imageFuture = imageFilterMinimumGateway.imageMinimumFilter(args); ImageDocumentJob payload = (ImageDocumentJob) imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); ResponseEntity<byte[]> result = ResponseEntityHelper.processImage(payload.getBufferedImage(), _contentType, false); return result; }