Examples of JCUser


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

     * {@inheritDoc}
     */
    @Override
    public JCUser saveEditedUserSecurity(long editedUserId, UserSecurityContainer userSecurityInfo)
            throws NotFoundException {
        JCUser editedUser = this.get(editedUserId);

        String newPassword = userSecurityInfo.getNewPassword();
        if (newPassword != null) {
            String encryptedPassword = encryptionService.encryptPassword(newPassword);
            editedUser.setPassword(encryptedPassword);
        }

        this.getDao().saveOrUpdate(editedUser);
        LOGGER.info("Updated user security settings. Username: {}", editedUser.getUsername());
        return editedUser;

    }
View Full Code Here

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

     * {@inheritDoc}
     */
    @Override
    public JCUser saveEditedUserNotifications(long editedUserId, UserNotificationsContainer userNotificationsInfo)
            throws NotFoundException {
        JCUser editedUser = this.get(editedUserId);

        editedUser.setMentioningNotificationsEnabled(userNotificationsInfo.isMentioningNotificationsEnabled());
        editedUser.setSendPmNotification(userNotificationsInfo.isSendPmNotification());
        editedUser.setAutosubscribe(userNotificationsInfo.isAutosubscribe());

        this.getDao().saveOrUpdate(editedUser);
        LOGGER.info("Updated user notification settings. Username: {}", editedUser.getUsername());
        return editedUser;
    }
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    @Override
    public void restorePassword(String email) throws MailingFailedException {
        JCUser user = this.getDao().getByEmail(email);
        String randomPassword = RandomStringUtils.randomAlphanumeric(6);
        // first - mail attempt, then - database changes
        mailService.sendPasswordRecoveryMail(user, randomPassword);
        String encryptedRandomPassword = encryptionService.encryptPassword(randomPassword);
        user.setPassword(encryptedRandomPassword);
        this.getDao().saveOrUpdate(user);

        LOGGER.info("New random password was set for user {}", user.getUsername());
    }
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    @Override
    public void activateAccount(String uuid) throws NotFoundException, UserTriesActivatingAccountAgainException {
        JCUser user = this.getDao().getByUuid(uuid);
        if (user == null) {
            LOGGER.info("Could not activate user with UUID[{}] because it doesn't exist. Either it was removed from DB "
                    + "because too much time passed between registration and activation, or there is an error in link"
                    + ", might be possible the user searches for vulnerabilities in the forum.", uuid);
            throw new NotFoundException();
        } else if (!user.isEnabled()) {
            Group group = groupDao.getGroupByName(AdministrationGroup.USER.getName());
            user.addGroup(group);
            user.setEnabled(true);
            this.getDao().saveOrUpdate(user);
            LOGGER.info("User [{}] successfully activated", user.getUsername());
        } else {
            LOGGER.info("User [{}] tried to activate his account again, but that's impossible. Either he clicked the " +
                    "link again, or someone looks for vulnerabilities in the forum.", user.getUsername());
            throw new UserTriesActivatingAccountAgainException();
        }
    }
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JCUser getByUuid(String uuid) throws NotFoundException {
        JCUser user = this.getDao().getByUuid(uuid);
        if (user == null) {
            throw new NotFoundException();
        } else {
            return user;
        }
View Full Code Here

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

    @BeforeMethod
    protected void setUp() {
        initMocks(this);
        locationService = new LocationService(userService, sessionRegistry);
        user = new JCUser("", "", "");
        topic = new Topic(user, "");
        topic.setUuid("uuid");
        list = new ArrayList<Object>();
        map = new ConcurrentHashMap<JCUser, String>();
    }
View Full Code Here

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

    }

    @Test
    public void testUserNotOnline() {
        when(userService.getCurrentUser()).thenReturn(user);
        JCUser user1 = new JCUser("", "", "");
        list.add(user1);
        when(sessionRegistry.getAllPrincipals()).thenReturn(list);


        locationService.getUsersViewing(topic);
View Full Code Here

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

    }

    @Test
    public void testGetPrivateMessageUserToNotCurrentUser() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(user, user, "title", "body");
        JCUser currentUser = new JCUser(USERNAME, "email", "password");

        when(pmDao.get(PM_ID)).thenReturn(message);
        when(pmDao.isExist(PM_ID)).thenReturn(true);
        when(userService.getCurrentUser()).thenReturn(currentUser);
View Full Code Here

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

        verify(pmDao, times(3)).delete(any(PrivateMessage.class));
    }

    @Test
    public void testDeleteFromInbox() throws NotFoundException {
        JCUser otherUser = new JCUser(USERNAME, null, null);

        PrivateMessage message1 = new PrivateMessage(user, otherUser, null, null);
        message1.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message2 = new PrivateMessage(user, otherUser, null, null);
View Full Code Here

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

        verify(pmDao, times(1)).delete(any(PrivateMessage.class));
    }

    @Test
    public void testDeleteFromOutbox() throws NotFoundException {
        JCUser otherUser = new JCUser(USERNAME, null, null);

        PrivateMessage message1 = new PrivateMessage(otherUser, user, null, null);
        message1.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message2 = new PrivateMessage(otherUser, user, null, null);
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.