Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.JCUser


        if (result.hasErrors()) {
            return new ModelAndView(EDIT_PROFILE, EDITED_USER, editedProfileDto);
        }
        long editedUserId = editedProfileDto.getUserSecurityDto().getUserId();
        checkPermissionForEditNotificationsOrSecurity(editedUserId);
        JCUser user = saveEditedProfileWithLockHandling(editedUserId, editedProfileDto, SECURITY);
        if (editedProfileDto.getUserSecurityDto().getNewUserPassword() != null) {
            redirectAttributes.addFlashAttribute(IS_PASSWORD_CHANGED_ATTRIB, true);
        }
        //redirect to the view profile page
        return new ModelAndView("redirect:/users/" + user.getId() + "/" + SECURITY);
    }
View Full Code Here


            editedProfileDto.getUserContactsDto().setContactTypes(contactsService.getAvailableContactTypes());
            return new ModelAndView(EDIT_PROFILE, EDITED_USER, editedProfileDto);
        }
        long editedUserId = editedProfileDto.getUserId();
        checkPermissionsToEditProfile(editedUserId);
        JCUser user = saveEditedProfileWithLockHandling(editedUserId, editedProfileDto, CONTACTS);
        //redirect to the view profile page
        return new ModelAndView("redirect:/users/" + user.getId() + "/" + CONTACTS);
    }
View Full Code Here

     *
     * @param editedUserId an identifier of edited user
     * @see <a href="http://jira.jtalks.org/browse/JC-1740">JC-1740</a>
     */
    private void checkPermissionForEditNotificationsOrSecurity(long editedUserId) {
        JCUser editorUser = userService.getCurrentUser();
        if (editorUser.getId() != editedUserId) {
            userService.checkPermissionToEditOtherProfiles(editorUser.getId());
        }
    }
View Full Code Here

     * So we must check them for users, who try to edit profiles.
     *
     * @param editedUserId an identifier of edited user
     */
    private void checkPermissionsToEditProfile(long editedUserId) {
        JCUser editorUser = userService.getCurrentUser();
        if (editorUser.getId() == editedUserId) {
            userService.checkPermissionToEditOwnProfile(editorUser.getId());
        } else {
            userService.checkPermissionToEditOtherProfiles(editorUser.getId());
        }
    }
View Full Code Here

     */
    @RequestMapping(value = "/users/{id}/postList", method = RequestMethod.GET)
    public ModelAndView showUserPostList(@PathVariable Long id,
                                         @RequestParam(value = "page", defaultValue = "1",
                                                 required = false) String page) throws NotFoundException {
        JCUser user = userService.get(id);
        Page<Post> postsPage = postService.getPostsOfUser(user, page);
        return new ModelAndView("userPostList")
                .addObject("user", user)
                .addObject("postsPage", postsPage)
                .addObject(BREADCRUMB_LIST, breadcrumbBuilder.getForumBreadcrumb());
View Full Code Here

    }

    @RequestMapping(value = "**/language", method = RequestMethod.GET)
    public String saveUserLanguage(@RequestParam(value = "lang", defaultValue = "en") String lang,
                                   HttpServletResponse response, HttpServletRequest request) throws ServletException {
        JCUser jcuser = userService.getCurrentUser();
        Language languageFromRequest = Language.byLocale(new Locale(lang));
        if (!jcuser.isAnonymous()) {
            changeLanguageWithLockHandling(jcuser, languageFromRequest);
        }
        LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
        localeResolver.setLocale(request, response, languageFromRequest.getLocale());
        return "redirect:" + request.getHeader("Referer");
View Full Code Here

                               @PathVariable(TOPIC_ID) Long topicId,
                               @Valid @ModelAttribute PostDto postDto,
                               BindingResult result) throws NotFoundException {
        postDto.setTopicId(topicId);
        if (result.hasErrors()) {
            JCUser currentUser = userService.getCurrentUser();
            Topic topic = topicFetchService.get(topicId);
            postDto.setTopicId(topicId);
            Page<Post> postsPage = postService.getPosts(topic, page);

            return new ModelAndView("topic/postList")
View Full Code Here

    /*===== Common methods =====*/

    @Test
    public void testSave() {
        JCUser user = ObjectsFactory.getDefaultUser();

        dao.saveOrUpdate(user);

        assertNotSame(user.getId(), 0, "Id not created");

        session.evict(user);
        JCUser result = (JCUser) session.get(JCUser.class, user.getId());

        assertReflectionEquals(user, result);
    }
View Full Code Here

        assertReflectionEquals(user, result);
    }

    @Test(expectedExceptions = DataIntegrityViolationException.class)
    public void testSaveUserWithUniqueViolation() {
        JCUser user = ObjectsFactory.getDefaultUser();
        JCUser user2 = ObjectsFactory.getDefaultUser();

        dao.saveOrUpdate(user);
        dao.saveOrUpdate(user2);
    }
View Full Code Here

        dao.saveOrUpdate(user2);
    }

    @Test
    public void testGet() {
        JCUser user = ObjectsFactory.getDefaultUser();
        session.save(user);

        JCUser result = dao.get(user.getId());

        assertNotNull(result);
        assertEquals(result.getId(), user.getId());
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.JCUser

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.