Package fr.ippon.tatami.service.dto

Examples of fr.ippon.tatami.service.dto.StatusDTO


    @RequestMapping(value = "/rest/statuses/{statusId}",
            method = RequestMethod.PATCH)
    @ResponseBody
    public StatusDTO updateStatus(@RequestBody ActionStatus action, @PathVariable("statusId") String statusId) {
        try {
            StatusDTO status = timelineService.getStatus(statusId);
            if (action.isFavorite() != null && status.isFavorite() != action.isFavorite()) {
                if (action.isFavorite()) {
                    timelineService.addFavoriteStatus(statusId);
                } else {
                    timelineService.removeFavoriteStatus(statusId);
                }
                status.setFavorite(action.isFavorite());
            }
            if (action.isShared() != null && action.isShared()) {
                timelineService.shareStatus(statusId);
            }
            if (action.isAnnounced() != null && action.isAnnounced()) {
View Full Code Here


        line.add(statusId);
        Collection<StatusDTO> statusCollection = buildStatusList(line);
        if (statusCollection.isEmpty()) {
            return null;
        } else {
            StatusDTO statusDTO = statusCollection.iterator().next();
            // Private message check
            if (statusDTO.isStatusPrivate()) {
                String login = authenticationService.getCurrentUser().getLogin();
                if (!timelineRepository.isStatusInTimeline(login, statusId)) {
                    log.info("User " + login + " tried to access private message ID " + statusId);
                    return null;
                }
View Full Code Here

                    if ((currentUser != null) && !statusUser.getDomain().equals(currentUser.getDomain())) {
                        throw new DomainViolationException("User " + currentUser + " tried to access " +
                                " status : " + abstractStatus);
                    }

                    StatusDTO statusDTO = new StatusDTO();
                    statusDTO.setStatusId(abstractStatus.getStatusId());
                    statusDTO.setStatusDate(abstractStatus.getStatusDate());
                    statusDTO.setGeoLocalization(abstractStatus.getGeoLocalization());
                    statusDTO.setActivated(statusUser.getActivated());
                    StatusType type = abstractStatus.getType();
                    if (type == null) {
                        statusDTO.setType(StatusType.STATUS);
                    } else {
                        statusDTO.setType(abstractStatus.getType());
                    }

                    if (abstractStatus.getType().equals(StatusType.SHARE)) {
                        Share share = (Share) abstractStatus;
                        AbstractStatus originalStatus = statusRepository.findStatusById(share.getOriginalStatusId());
                        if (originalStatus != null) { // Find the original status
                            statusDTO.setTimelineId(share.getStatusId());
                            statusDTO.setSharedByUsername(share.getUsername());
                            statusUser = userService.getUserByLogin(originalStatus.getLogin());
                            addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
                        } else {
                            log.debug("Original status has been deleted");
                        }
                    } else if (abstractStatus.getType().equals(StatusType.MENTION_SHARE)) {
                        MentionShare mentionShare = (MentionShare) abstractStatus;
                        AbstractStatus originalStatus = statusRepository.findStatusById(mentionShare.getOriginalStatusId());
                        if (originalStatus != null) { // Find the status that was shared
                            statusDTO.setTimelineId(mentionShare.getStatusId());
                            statusDTO.setSharedByUsername(mentionShare.getUsername());
                            statusUser = userService.getUserByLogin(mentionShare.getLogin());
                            addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
                        } else {
                            log.debug("Mentioned status has been deleted");
                        }
                    } else if (abstractStatus.getType().equals(StatusType.MENTION_FRIEND)) {
                        MentionFriend mentionFriend = (MentionFriend) abstractStatus;
                        statusDTO.setTimelineId(mentionFriend.getStatusId());
                        statusDTO.setSharedByUsername(mentionFriend.getUsername());
                        statusUser = userService.getUserByLogin(mentionFriend.getFollowerLogin());
                        statusDTO.setFirstName(statusUser.getFirstName());
                        statusDTO.setLastName(statusUser.getLastName());
                        statusDTO.setAvatar(statusUser.getAvatar());
                        statusDTO.setUsername(statusUser.getUsername());
                        statuses.add(statusDTO);
                    } else if (abstractStatus.getType().equals(StatusType.ANNOUNCEMENT)) {
                        Announcement announcement = (Announcement) abstractStatus;
                        AbstractStatus originalStatus = statusRepository.findStatusById(announcement.getOriginalStatusId());
                        if (originalStatus != null) { // Find the status that was announced
                            statusDTO.setTimelineId(announcement.getStatusId());
                            statusDTO.setSharedByUsername(announcement.getUsername());
                            statusUser = userService.getUserByLogin(originalStatus.getLogin());
                            addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
                        } else {
                            log.debug("Announced status has been deleted");
                        }
                    } else { // Normal status
                        statusDTO.setTimelineId(abstractStatus.getStatusId());
                        addStatusToLine(statuses, statusDTO, abstractStatus, statusUser, usergroups, favoriteLine);
                    }
                } else {
                    log.debug("Deleted user : {}", abstractStatus.getLogin());
                }
            } else {
                log.debug("Deleted status : {}", statusId);
            }
        }

        for(StatusDTO statusDTO : statuses)
            statusDTO.setShareByMe(shareByMe(statusDTO));

        return statuses;
    }
View Full Code Here

    }

    private void assertThatNewTestIsPosted(String username, String content, Collection<StatusDTO> statuses) {
        assertThat(statuses, notNullValue());
        assertThat(statuses.size(), is(1));
        StatusDTO status = (StatusDTO) statuses.toArray()[0];
        assertThat(status.getUsername(), is(username));
        assertThat(status.getContent(), is(content));
    }
View Full Code Here

    private void assertThatLineForUserWithStatusIsOk(String username, Collection<StatusDTO> status) {
        assertThat(status, notNullValue());
        assertThat(status.size(), is(2));

        StatusDTO firstStatus = (StatusDTO) status.toArray()[0];
        assertThat(firstStatus.getStatusId(), is("fa2bd770-9848-11e1-a6ca-e0f847068d52"));
        assertThat(firstStatus.getUsername(), is(username));
        assertThat(firstStatus.getContent(), is("Tatami is an enterprise social network"));

        StatusDTO secondStatus = (StatusDTO) status.toArray()[1];
        assertThat(secondStatus.getStatusId(), is("f97d6470-9847-11e1-a6ca-e0f847068d52"));
        assertThat(secondStatus.getUsername(), is(username));
        assertThat(secondStatus.getContent(), is("Tatami is fully Open Source"));

    }
View Full Code Here

        statusDTOs = new ObjectMapper().readValue(replyAsJson,
                new TypeReference<List<StatusDTO>>() {

                });

        StatusDTO statusDTO = statusDTOs.iterator().next();
        assertEquals("Reply discussion", statusDTO.getContent());
        assertEquals(statusId, statusDTO.getReplyTo());
    }
View Full Code Here

    /**
     * Notifies the user with Atmosphere.
     */
    public void notifyUser(String login, AbstractStatus abstractStatus) {
        log.debug("Notifying user: {}", login);
        StatusDTO statusDTO = timelineService.getStatus(abstractStatus.getStatusId());
        TatamiNotification notification = new TatamiNotification();
        notification.setLogin(login);
        notification.setStatusDTO(statusDTO);
        try {
            Broadcaster broadcaster =
View Full Code Here

        String content = "temporary status";
        statusUpdateService.postStatus(content, false, new ArrayList<String>(), null);

        timelineStatuses = timelineService.getTimeline(10, null, null);
        assertEquals(3, timelineStatuses.size());
        StatusDTO temporaryStatus = timelineStatuses.iterator().next();
        assertEquals("temporary status", temporaryStatus.getContent());
        userlineStatuses = timelineService.getUserline(username, 10, null, null);
        assertEquals(3, userlineStatuses.size());

        timelineService.removeStatus(temporaryStatus.getStatusId());
        timelineStatuses = timelineService.getTimeline(10, null, null);
        assertEquals(2, timelineStatuses.size());
        userlineStatuses = timelineService.getUserline(username, 10, null, null);
        assertEquals(2, userlineStatuses.size());
    }
View Full Code Here

        assertEquals(10, timelineStatuses.size());
        userlineStatuses = timelineService.getUserline(username, 10, null, null);
        assertEquals(10, userlineStatuses.size());
        Iterator<StatusDTO> iterator = timelineStatuses.iterator();
        for (int i = 9; i >= 0; i--) {
            StatusDTO temporaryStatus = iterator.next();
            assertEquals("temporary status " + i, temporaryStatus.getContent());
            timelineService.removeStatus(temporaryStatus.getStatusId());
        }

        timelineStatuses = timelineService.getTimeline(10, null, null);
        assertEquals(2, timelineStatuses.size());
        userlineStatuses = timelineService.getUserline(username, 10, null, null);
View Full Code Here

        tagStatuses = timelineService.getTagline("ippon", 10, null, null);
        assertEquals(10, tagStatuses.size());
        Iterator<StatusDTO> iterator = tagStatuses.iterator();
        for (int i = 9; i >= 0; i--) {
            StatusDTO temporaryStatus = iterator.next();
            assertEquals("temporary status " + i + " #ippon", temporaryStatus.getContent());
            timelineService.removeStatus(temporaryStatus.getStatusId());
        }

        tagStatuses = timelineService.getTagline("ippon", 10, null, null);
        assertEquals(2, tagStatuses.size());
    }
View Full Code Here

TOP

Related Classes of fr.ippon.tatami.service.dto.StatusDTO

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.