Package org.jtalks.jcommune.model.entity

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


     * @throws ServletException  forwarded from handler chain
     * @throws IOException       forwarded from handler chain
     */
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
                                        Authentication authentication) throws ServletException, IOException {
        JCUser user = (JCUser) authentication.getPrincipal();
        userService.updateLastLoginTime(user);
        logger.info("JCUser logged in: " + user.getUsername());
        //apply language settings assuming CookieLocaleResolver usage
        String languageCode = user.getLanguage().getLanguageCode();
        LocaleResolver localeResolver = new CookieLocaleResolver();
        localeResolver.setLocale(request, response, user.getLanguage().getLocale());
        Cookie cookie = new Cookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME, languageCode);
        cookie.setPath("/");
        response.addCookie(cookie);
        super.onAuthenticationSuccess(request, response, authentication);
    }
View Full Code Here


        branchService.checkIfBranchExists(branchId);
        Branch branch = branchService.get(branchId);
        Page<Topic> topicsPage = topicFetchService.getTopics(branch, page);
        lastReadPostService.fillLastReadPostForTopics(topicsPage.getContent());

        JCUser currentUser = userService.getCurrentUser();
        List<Breadcrumb> breadcrumbs = breadcrumbBuilder.getForumBreadcrumb(branch);

        return new ModelAndView("topic/topicList")
                .addObject("viewList", locationService.getUsersViewing(branch))
                .addObject("branch", branch)
View Full Code Here

     * Populate {@link JCUser} from fields.
     *
     * @return populated {@link JCUser} object
     */
    public JCUser createUser() {
        return new JCUser(userDto.getUsername(), userDto.getEmail(), userDto.getPassword());
    }
View Full Code Here

                                    BindingResult result) throws NotFoundException {
        if (result.hasErrors()) {
            return new ModelAndView(PM_FORM)
                    .addObject(DTO, pmDto);
        }
        JCUser userFrom = userService.getCurrentUser();
        JCUser userTo = userService.getByUsername(pmDto.getRecipient());
        // todo: we can easily get current user in service
        if (pmDto.getId() > 0) {
            pmService.sendDraft(pmDto.getId(), pmDto.getTitle(), pmDto.getBody(), userTo, userFrom);
        } else {
            pmService.sendMessage(pmDto.getTitle(), pmDto.getBody(), userTo, userFrom);
View Full Code Here

        String targetView = "redirect:/drafts";
        if (result.hasErrors()) {
            return PM_FORM;
        }

        JCUser userFrom = userService.getCurrentUser();
        try {
            pmService.saveDraft(pmDto.getId(), pmDto.getRecipient(), pmDto.getTitle(), pmDto.getBody(), userFrom);
        } catch (NotFoundException e) {
            result.rejectValue("recipient", "validation.wrong_recipient");
            targetView = PM_FORM;
View Full Code Here

    }

    @Override
    public CodeReviewComment addComment(Long reviewId, int lineNumber, String body) throws NotFoundException {
        CodeReview review = get(reviewId);
        JCUser currentUser = userService.getCurrentUser();

        permissionService.checkPermission(
                review.getTopic().getBranch().getId(),
                AclClassName.BRANCH,
                BranchPermission.LEAVE_COMMENTS_IN_CODE_REVIEW);

        CodeReviewComment comment = new CodeReviewComment();
        comment.setLineNumber(lineNumber);
        comment.setBody(body);
        comment.setCreationDate(new DateTime(System.currentTimeMillis()));
        comment.setAuthor(currentUser);
        if (currentUser.isAutosubscribe()) {
            review.getSubscribers().add(currentUser);
        }

        review.addComment(comment);
        getDao().saveOrUpdate(review);
View Full Code Here

     * @return Users, who're viewing the page for entity passed. Will return empty list if
     *         there are no viewers or view tracking is not supported for this entity type
     */
    public List<JCUser> getUsersViewing(Entity entity) {
        List<JCUser> viewList = new ArrayList<JCUser>();
        JCUser currentUser = userService.getCurrentUser();
        /**
         * This condition does not allow Anonymous add to the map of active users.
         */
        if (!currentUser.isAnonymous()) {
            registerUserMap.put(currentUser, entity.getUuid());
        }

        for (Object o : sessionRegistry.getAllPrincipals()) {
            JCUser user = (JCUser) o;
            if (entity.getUuid().equals(registerUserMap.get(user))) {
                viewList.add(user);
            }
        }
        return viewList;
View Full Code Here

     *            - comment to check permissions on
     * @param branchId
     *            - ID of branch where review with comment located
     */
    private void checkHasUpdatePermission(CodeReviewComment comment, long branchId) {
        JCUser currentUser = userService.getCurrentUser();
        boolean canEditOwnPosts = permissionService.hasBranchPermission(branchId, BranchPermission.EDIT_OWN_POSTS);
        boolean canEditOthersPosts = permissionService
                .hasBranchPermission(branchId, BranchPermission.EDIT_OTHERS_POSTS);

        if (!(canEditOthersPosts && !comment.isCreatedBy(currentUser))
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public JCUser getByUsername(String username) throws NotFoundException {
        JCUser user = this.getDao().getByUsername(username);
        if (user == null) {
            String msg = "JCUser [" + username + "] not found.";
            LOGGER.info(msg);
            throw new NotFoundException(msg);
        }
View Full Code Here

     */
    @Override
    public JCUser saveEditedUserProfile(
            long editedUserId, UserInfoContainer editedUserProfileInfo) throws NotFoundException {

        JCUser editedUser = this.get(editedUserId);
        byte[] decodedAvatar = base64Wrapper.decodeB64Bytes(editedUserProfileInfo.getB64EncodedAvatar());

        editedUser.setEmail(editedUserProfileInfo.getEmail());

        if (!Arrays.equals(editedUser.getAvatar(), decodedAvatar)) {
            editedUser.setAvatarLastModificationTime(new DateTime());
        }
        editedUser.setAvatar(decodedAvatar);
        editedUser.setSignature(editedUserProfileInfo.getSignature());
        editedUser.setFirstName(editedUserProfileInfo.getFirstName());
        editedUser.setLastName(editedUserProfileInfo.getLastName());
        editedUser.setPageSize(editedUserProfileInfo.getPageSize());
        editedUser.setLocation(editedUserProfileInfo.getLocation());

        this.getDao().saveOrUpdate(editedUser);
        LOGGER.info("Updated user profile. Username: {}", editedUser.getUsername());
        return editedUser;
    }
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.