*/
@RequestMapping(value = "/branch/permissions/json", method = RequestMethod.POST)
@ResponseBody
public JsonResponse getGroupsForBranchPermission(@RequestBody BranchPermissionDto permissionInfo) {
long forumId = componentService.getComponentOfForum().getId();
PermissionGroupsDto permission = new PermissionGroupsDto();
JtalksPermission branchPermission = permissionManager.findBranchPermissionByMask(permissionInfo.getPermissionMask());
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);
}