Examples of JSONResponse


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

    @RequestMapping(value = "/admin/edit", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse setForumInformation(@Valid @RequestBody ComponentInformation componentInformation,
                                            BindingResult result, Locale locale) {
        if (result.hasErrors()) {
            return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors());
        }

        componentInformation.setId(componentService.getComponentOfForum().getId());

        try {
            componentService.setComponentInformation(componentInformation);
        } catch (AccessDeniedException e) {
            String errorMessage = messageSource.getMessage(ACCESS_DENIED_MESSAGE, null, locale);
            return new JsonResponse(JsonResponseStatus.FAIL, errorMessage);
        }

        return new JsonResponse(JsonResponseStatus.SUCCESS, null);
    }
View Full Code Here

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

    @RequestMapping(value = "/branch/edit", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse setBranchInformation(@Valid @RequestBody BranchDto branchDto,
                                            BindingResult result, Locale locale) throws NotFoundException {
        if (result.hasErrors()) {
            return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors());
        }

        long forumId = componentService.getComponentOfForum().getId();

        try {
            branchService.changeBranchInfo(forumId, branchDto.getId(), branchDto.getName(), branchDto.getDescription());
        } catch (AccessDeniedException e) {
            String errorMessage = messageSource.getMessage(ACCESS_DENIED_MESSAGE, null, locale);
            return new JsonResponse(JsonResponseStatus.FAIL, errorMessage);
        }

        return new JsonResponse(JsonResponseStatus.SUCCESS, null);
    }
View Full Code Here

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

    @RequestMapping(value = "/branch/new", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse createNewBranch(@Valid @RequestBody BranchDto branchDto,
                                            BindingResult result, Locale locale) throws NotFoundException {
        if (result.hasErrors()) {
            return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors());
        }

        long forumId = componentService.getComponentOfForum().getId();

        try {
            branchService.createNewBranch(forumId, branchDto.getSectionId(), branchDto.getName(), branchDto.getDescription());
        } catch (AccessDeniedException e) {
            String errorMessage = messageSource.getMessage(ACCESS_DENIED_MESSAGE, null, locale);
            return new JsonResponse(JsonResponseStatus.FAIL, errorMessage);
        }

        return new JsonResponse(JsonResponseStatus.SUCCESS, null);
    }
View Full Code Here

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

        List<Group> selectedGroups;
        try {
            selectedGroups = branchService.getPermissionGroupsFor(forumId, permissionInfo.getBranchId(),
                    permissionInfo.isAllowed(), branchPermission);
        } catch (NotFoundException e) {
            return new JsonResponse(JsonResponseStatus.FAIL, null);
        }
        List<GroupDto> alreadySelected = GroupDto.convertGroupList(selectedGroups, true);

        List<Group> availableGroups = permissionManager.getAllGroupsWithoutExcluded(selectedGroups, branchPermission);
        List<GroupDto> available = GroupDto.convertGroupList(availableGroups, true);

        permission.setSelectedGroups(alreadySelected);
        permission.setAvailableGroups(available);

        return new JsonResponse(JsonResponseStatus.SUCCESS, permission);
    }
View Full Code Here

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

        PermissionChanges changes = new PermissionChanges(branchPermission, newlyAddedGroups, removedGroups);
        try {
            branchService.changeBranchPermissions(forumId, permissionInfo.getBranchId(), permissionInfo.isAllowed(),changes);
        } catch (NotFoundException e) {
            return new JsonResponse(JsonResponseStatus.FAIL);
        }
        return new JsonResponse(JsonResponseStatus.SUCCESS);
    }
View Full Code Here

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

     */
    @RequestMapping(value = "/links/save", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse saveLink(@Valid @RequestBody ExternalLink link, BindingResult result) {
        if (result.hasErrors()) {
            return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors());
        }
        Component component = componentService.getComponentOfForum();
        service.saveLink(link, component);
        return new JsonResponse(JsonResponseStatus.SUCCESS, link);
    }
View Full Code Here

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

    @RequestMapping(value = "/links/delete/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public JsonResponse deleteLink(@PathVariable Long id) {
        Component component = componentService.getComponentOfForum();
        boolean result = service.deleteLink(id, component);
        return new JsonResponse(JsonResponseStatus.SUCCESS, result);
    }
View Full Code Here

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

     */
    @RequestMapping(value = "/reviews/{reviewId}/json", method = RequestMethod.GET)
    @ResponseBody
    public JsonResponse getCodeReview(@PathVariable("reviewId") Long reviewId) throws NotFoundException {
        CodeReview review = codeReviewService.get(reviewId);
        return new JsonResponse(JsonResponseStatus.SUCCESS, new CodeReviewDto(review));
    }
View Full Code Here

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

    @Test
    public void testHasPermissionPermissionGranted() {
        when(permissionService.hasPermission(
                anyLong(), anyString(), anyString())).thenReturn(true);
       
        JsonResponse response = securityController.hasPermission(0, null, null);
       
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here

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

    @Test
    public void testHasPermissionPermissionNotGranted() {
        when(permissionService.hasPermission(
                anyLong(), anyString(), anyString())).thenReturn(false);
       
        JsonResponse response = securityController.hasPermission(0, null, null);
       
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.