Package fr.ippon.tatami.domain

Examples of fr.ippon.tatami.domain.User


            method = RequestMethod.GET,
            produces = "application/json")
    @ResponseBody
    @Timed
    public Collection<Group> getUserGroups(@RequestParam("screen_name") String username) {
        User user = userService.getUserByUsername(username);
        if (user == null) {
            log.debug("Trying to find group for non-existing username = {}", username);
            return new ArrayList<Group>();
        }
        return groupService.getGroupsForUser(user);
View Full Code Here


            produces = "application/json")
    @ResponseBody
    @Timed
    public Collection<UserGroupDTO> getGroupsUsers(HttpServletResponse response, @PathVariable("groupId") String groupId) {

        User currentUser = authenticationService.getCurrentUser();
        Group currentGroup = groupService.getGroupById(currentUser.getDomain(), groupId);

        Collection<UserGroupDTO> users = null;

        if (currentUser == null) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // Authentication required
        } else if (currentGroup == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND); // Resource not found
        } else {
            users = groupService.getMembersForGroup(groupId, currentUser.getLogin());
        }
        return users;
    }
View Full Code Here

            produces = "application/json")
    @ResponseBody
    @Timed
    public UserGroupDTO getUserToGroup(HttpServletResponse response, @PathVariable("groupId") String groupId, @PathVariable("username") String username) {

        User currentUser = authenticationService.getCurrentUser();
        Group currentGroup = groupService.getGroupById(currentUser.getDomain(), groupId);

        Collection<UserGroupDTO> users = null;

        if (currentUser == null) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // Authentication required
        } else if (currentGroup == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND); // Resource not found
        } else {
            users = groupService.getMembersForGroup(groupId, currentUser.getLogin());
        }

        for (UserGroupDTO user : users) {
            if (user.getLogin().equals(currentUser.getLogin())) {
                return user;
            }
        }

        UserGroupDTO currentUserDTO = new UserGroupDTO();
        currentUserDTO.setLogin(currentUser.getLogin());
        currentUserDTO.setUsername(currentUser.getUsername());
        currentUserDTO.setAvatar(currentUser.getAvatar());
        currentUserDTO.setFirstName(currentUser.getFirstName());
        currentUserDTO.setLastName(currentUser.getLastName());
        currentUserDTO.setIsMember(false);

        return currentUserDTO;
    }
View Full Code Here

            produces = "application/json")
    @ResponseBody
    @Timed
    public UserGroupDTO addUserToGroup(HttpServletResponse response, @PathVariable("groupId") String groupId, @PathVariable("username") String username) {

        User currentUser = authenticationService.getCurrentUser();
        Group currentGroup = groupService.getGroupById(currentUser.getDomain(), groupId);
        User userToAdd = userService.getUserByUsername(username);

        UserGroupDTO dto = null;

        if (currentUser == null) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // Authentication required
View Full Code Here

            produces = "application/json")
    @ResponseBody
    @Timed
    public boolean removeUserFromGroup(HttpServletResponse response, @PathVariable("groupId") String groupId, @PathVariable("username") String username) {

        User currentUser = authenticationService.getCurrentUser();
        Group currentGroup = groupService.getGroupById(currentUser.getDomain(), groupId);
        User userToremove = userService.getUserByUsername(username);

        if (currentUser == null) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // Authentication required
            return false;
        } else if (currentGroup == null || userToremove == null) {
View Full Code Here

            statusUpdateService.replyToStatus(escapedContent, status.getReplyTo(), attachmentIds);
        } else if (status.isStatusPrivate() || status.getGroupId() == null || status.getGroupId().equals("")) {
            log.debug("Private status");
            statusUpdateService.postStatus(escapedContent, status.isStatusPrivate(), attachmentIds, status.getGeoLocalization());
        } else {
            User currentUser = authenticationService.getCurrentUser();
            Collection<Group> groups = groupService.getGroupsForUser(currentUser);
            Group group = null;
            for (Group testGroup : groups) {
                if (testGroup.getGroupId().equals(status.getGroupId())) {
                    group = testGroup;
                    break;
                }
            }
            if (group == null) {
                log.info("Permission denied! User {} tried to access " +
                        "group ID = {}", currentUser.getLogin(), status.getGroupId());
                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            } else if (group.isArchivedGroup()) {
                log.info("Archived group! User {} tried to post a message to archived " +
                        "group ID = {}", currentUser.getLogin(), status.getGroupId());
                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            } else {
                statusUpdateService.postStatusToGroup(escapedContent, group, attachmentIds, status.getGeoLocalization());
            }
        }
View Full Code Here

     * The mentioned user can also be notified by email.
     */
    public void mentionUser(String mentionedLogin, Status status) {
        mentionlineRepository.addStatusToMentionline(mentionedLogin, status.getStatusId());

        User mentionnedUser = userRepository.findUserByLogin(mentionedLogin);

        if (mentionnedUser != null && (mentionnedUser.getPreferencesMentionEmail() == null || mentionnedUser.getPreferencesMentionEmail().equals(true))) {
            if (status.getStatusPrivate()) { // Private status
                mailService.sendUserPrivateMessageEmail(mentionnedUser, status);
                if (applePushService != null) {
                    applePushService.notifyUser(mentionedLogin, status);
                }
View Full Code Here

            }
        }
        List<String> mostFollowedUsers = findMostUsedKeys(userCount);
        List<User> userSuggestions = new ArrayList<User>();
        for (String mostFollowedUser : mostFollowedUsers) {
            User suggestion = userService.getUserByLogin(mostFollowedUser);
            if ( suggestion.getActivated() ){
                userSuggestions.add(suggestion);
            }
        }
        if (userSuggestions.size() > SUGGESTIONS_SIZE) {
            return userSuggestions.subList(0, SUGGESTIONS_SIZE);
View Full Code Here

            client.close();
        }
    }

    protected User constructAUser(String login, String firstName, String lastName) {
        User user = new User();
        user.setLogin(login);
        user.setPassword("");
        user.setUsername(DomainUtil.getUsernameFromLogin(login));
        user.setDomain(DomainUtil.getDomainFromLogin(login));
        user.setFirstName(firstName);
        user.setLastName(lastName);
        user.setJobTitle("web developer");
        counterRepository.createStatusCounter(user.getLogin());
        counterRepository.createFriendsCounter(user.getLogin());
        counterRepository.createFollowersCounter(user.getLogin());
        return user;
    }
View Full Code Here

        TimelineController timelineController = new TimelineController();
        ReflectionTestUtils.setField(timelineController, "timelineService", timelineService);
        ReflectionTestUtils.setField(timelineController, "statusUpdateService", statusUpdateService);

        User authenticateUser = constructAUser(username + "@ippon.fr");
        AuthenticationService mockAuthenticationService = mock(AuthenticationService.class);
        when(mockAuthenticationService.getCurrentUser()).thenReturn(authenticateUser);
        ReflectionTestUtils.setField(timelineController, "authenticationService", mockAuthenticationService);
        ReflectionTestUtils.setField(userService, "authenticationService", mockAuthenticationService);
        ReflectionTestUtils.setField(timelineService, "authenticationService", mockAuthenticationService);
View Full Code Here

TOP

Related Classes of fr.ippon.tatami.domain.User

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.