Package com.streamreduce.core.model.messages

Examples of com.streamreduce.core.model.messages.SobaMessage


    @Path("{messageId}")
    public Response deleteMessage(@PathParam("messageId") ObjectId messageId) {
        User user = applicationManager.getSecurityService().getCurrentUser();

        try {
            SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
            // users can only nullify a message from a resource they own
            if (sobaMessage.getOwnerId().equals(user.getId())) {
                applicationManager.getMessageService().nullifyMessage(user, sobaMessage);
            } else {
                return error(ErrorMessages.APPLICATION_ACCESS_DENIED, Response.status(Response.Status.BAD_REQUEST));
            }
View Full Code Here


        Set<String> hashtags = parsedMessage.getTags();

        MessageComment messageComment = new MessageComment(user, parsedMessage.getMessage());

        try {
            SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
            // this is now a conversation, so add that tag
            hashtags.add("#conversation");
            applicationManager.getMessageService().addCommentToMessage(user.getAccount(), sobaMessage.getId(), messageComment, hashtags);

        } catch (MessageNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
View Full Code Here

    @GET
    @Path("{messageId}/comment")
    public Response getCommentsForMessage(@PathParam("messageId") ObjectId messageId) {

        User user = applicationManager.getSecurityService().getCurrentUser();
        SobaMessage sobaMessage;

        try {
            sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);

        } catch (MessageNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }

        MessageCommentsResponseDTO dto = new MessageCommentsResponseDTO();
        List<MessageCommentResponseDTO> allComments = new ArrayList<>();
        for (MessageComment comment : sobaMessage.getComments()) {
            allComments.add(comment.toDTO());
        }

        dto.setComments(allComments);
View Full Code Here

    @Path("{messageId}/comment/{created}")
    public Response deleteCommentForMessage(@PathParam("messageId") ObjectId messageId, @PathParam("created") Long created) {

        User user = applicationManager.getSecurityService().getCurrentUser();
        try {
            SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
            for (MessageComment messageComment : sobaMessage.getComments()) {
                // find the message comment to update
                if (messageComment.getSenderId().equals(user.getId()) && messageComment.getCreated().equals(created)) {
                    applicationManager.getMessageService().nullifyMessageComment(user, sobaMessage, messageComment);
                    break;
                }
View Full Code Here

    public Response getTags(@PathParam("messageId") String messageId) {

        User user = applicationManager.getSecurityService().getCurrentUser();
        Set<String> tags;
        try {
            SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(),
                    new ObjectId(messageId));
            tags = sobaMessage.getHashtags();

        } catch (MessageNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
View Full Code Here

    @Consumes(MediaType.APPLICATION_JSON)
    public Response email(@PathParam("messageId") ObjectId messageId, JSONObject json) {

        User user = applicationManager.getSecurityService().getCurrentUser();

        SobaMessage message;
        try {
            message = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
        }
        catch (MessageNotFoundException mnfe) {
            logger.error("Unable to find message with ID {}", messageId);
View Full Code Here

    }


    @Test
    public void testSendCommentAddedEmail() throws Exception {
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(testUser)
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage(LOREM_IPSUM)
                .type(MessageType.USER)
                .build();
        sobaMessage.setId(new ObjectId());
        MessageComment messageComment = new MessageComment(testSenderUser, LOREM_IPSUM);

        when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser));

        testSenderUser.setId(new ObjectId());
View Full Code Here

        Assert.assertFalse("Encountered unexpanded template token.", emailContent.contains("${"));
    }

    @Test
    public void testSendCommentAddedEmail_userConfigDisabled() throws Exception {
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(testUser)
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage(LOREM_IPSUM)
                .type(MessageType.USER)
                .build();
        sobaMessage.setId(new ObjectId());
        MessageComment messageComment = new MessageComment(testSenderUser, LOREM_IPSUM);

        when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser));

        testUser.getConfig().put(User.ConfigKeys.RECEIVES_COMMENT_NOTIFICATIONS, false);
View Full Code Here

        verify(mockAmazonSimpleEmailServiceClient, never()).sendEmail(null);
    }

    @Test
    public void testSendUserMessageEmail() throws Exception {
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(testUser)
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage(LOREM_IPSUM)
                .type(MessageType.USER)
                .build();
        sobaMessage.setId(new ObjectId());

        testUser.getConfig().put(User.ConfigKeys.RECEIVES_COMMENT_NOTIFICATIONS, false);

        testSenderUser.setId(new ObjectId());
        JSONObject payload = new JSONObjectBuilder()
View Full Code Here

        String path = searchBaseUrl.getPath() + resourceName;
        JSONObject response = makeRequest(path,query,searchParameters,"GET");


        if (response.containsKey("_source")) {
            SobaMessage sobaMessage = createSobaMessageFromJson(response.getJSONObject("_source"));
            return Lists.newArrayList(sobaMessage);
        } else {
            JSONArray hits = response.getJSONObject("hits").getJSONArray("hits");
            List<SobaMessage> sobaMessages = new ArrayList<>();
            for (Object hit : hits) {
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.messages.SobaMessage

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.