Package org.jtalks.jcommune.web.dto.json

Examples of org.jtalks.jcommune.web.dto.json.FailJsonResponse


    @ExceptionHandler(value = ImageSizeException.class)
    @ResponseBody
    public FailJsonResponse handleImageSizeException(ImageSizeException e, Locale locale) {
        Object[] parameters = new Object[]{e.getMaxSize()};
        String errorMessage = messageSource.getMessage(WRONG_SIZE_RESOURCE_MESSAGE, parameters, locale);
        return new FailJsonResponse(JsonResponseReason.VALIDATION, errorMessage);
    }
View Full Code Here


    @ExceptionHandler(value = ImageFormatException.class)
    @ResponseBody
    public FailJsonResponse handleImageFormatException(ImageFormatException e, Locale locale) {
        Object[] validImageTypes = new Object[]{e.getValidImageTypes()};
        String errorMessage = messageSource.getMessage(WRONG_FORMAT_RESOURCE_MESSAGE, validImageTypes, locale);
        return new FailJsonResponse(JsonResponseReason.VALIDATION, errorMessage);
    }
View Full Code Here

     */
    @ExceptionHandler(value = ImageProcessException.class)
    @ResponseBody
    public FailJsonResponse handleImageProcessException(ImageProcessException e, Locale locale) {
        String errorMessage = messageSource.getMessage(COMMON_ERROR_RESOURCE_MESSAGE, null, locale);
        return new FailJsonResponse(JsonResponseReason.INTERNAL_SERVER_ERROR, errorMessage);
    }
View Full Code Here

                imageUploadController.WRONG_FORMAT_RESOURCE_MESSAGE,
                new Object[]{validTypes},
                locale)
        ).thenReturn(expectedMessage);

        FailJsonResponse result = imageUploadController.handleImageFormatException(new ImageFormatException(validTypes), locale);

        assertEquals(result.getStatus(), JsonResponseStatus.FAIL, "We have an exception, so we should get false value.");
        assertEquals(result.getReason(), JsonResponseReason.VALIDATION, "Failture reason should be validation");
        assertEquals(result.getResult(), expectedMessage, "Result contains incorrect message.");
    }
View Full Code Here

                Matchers.anyString(),
                Matchers.any(Object[].class),
                Matchers.any(Locale.class))
        ).thenReturn(expectedMessage);

        FailJsonResponse result = imageUploadController.handleImageSizeException(exception, locale);

        assertEquals(result.getStatus(), JsonResponseStatus.FAIL, "We have an exception, so we should get false value.");
        assertEquals(result.getReason(), JsonResponseReason.VALIDATION, "Failture reason should be validation");
        assertEquals(result.getResult(), expectedMessage, "Result contains incorrect message.");
    }
View Full Code Here

                imageUploadController.COMMON_ERROR_RESOURCE_MESSAGE,
                null,
                locale)
        ).thenReturn(expectedMessage);

        FailJsonResponse result = imageUploadController.handleImageProcessException(null, locale);

        assertEquals(result.getStatus(), JsonResponseStatus.FAIL, "We have an exception, so we should get false value.");
        assertEquals(result.getReason(), JsonResponseReason.INTERNAL_SERVER_ERROR, "Failture reason should be validation");
        assertEquals(result.getResult(), expectedMessage, "Result contains incorrect message.");
    }
View Full Code Here

     * @return fail response with status 'Fail' and reason 'security'
     */
    @ExceptionHandler(AccessDeniedException.class)
    @ResponseBody
    public FailJsonResponse securityError() {
        return new FailJsonResponse(JsonResponseReason.SECURITY);
    }
View Full Code Here

     * @return fail response with status 'Fail' and reason 'entity-not-found'
     */
    @ExceptionHandler(NotFoundException.class)
    @ResponseBody
    public FailJsonResponse entityNotFoundError() {
        return new FailJsonResponse(JsonResponseReason.ENTITY_NOT_FOUND);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.web.dto.json.FailJsonResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.