Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.User


     *
     * @param user - the User object to test against
     * @return true if it matches, false if not
     */
    protected boolean isOwner(User user) {
        User currentUser = securityService.getCurrentUser();
        return (user.getId().equals(currentUser.getId()));
    }
View Full Code Here


     *
     * @param account - the account to test to see if the User is in.
     * @return - true if they are, false if they are not
     */
    protected boolean isInAccount(Account account) {
        User currentUser = securityService.getCurrentUser();
        return account.getId().equals(currentUser.getAccount().getId());
    }
View Full Code Here

        if (isEmpty(message)) {
            return error("Message payload can not be empty", Response.status(Response.Status.BAD_REQUEST));
        }

        SobaMessage sobaMessage;
        User sender = applicationManager.getSecurityService().getCurrentUser();
        Map<String, Object> eventContext = new HashMap<>();

        eventContext.put("message", message);
        eventContext.put("payload", json);
View Full Code Here

                                   @QueryParam("limit") int limit, @DefaultValue("true") @QueryParam("ascending") boolean ascending,
                                   @QueryParam("search") String search, @QueryParam("fullText") boolean fullText,
                                   @QueryParam("hashtag") List<String> hashtags, @QueryParam("sender") String sender,
                                   @QueryParam("excludeInsights") boolean excludeInsights) {

        User user = applicationManager.getSecurityService().getCurrentUser();
        List<SobaMessage> allMessages = applicationManager.getMessageService().getAllMessages(user, after, before, limit, ascending, search, hashtags, sender, excludeInsights);

        return Response
                .ok(SobaMessageResponseDTO.fromSobaMessages(allMessages, fullText))
                .build();
View Full Code Here

     */
    @GET
    @Path("{messageId}")
    public Response getMessageById(@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));
        }

View Full Code Here

    }

    @DELETE
    @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

        if (isEmpty(comment)) {
            return error(ErrorMessages.MISSING_REQUIRED_FIELD + "comment", Response.status(Response.Status.BAD_REQUEST));
        }

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

        // check if the user added any tags
        MessageUtils.ParsedMessage parsedMessage = MessageUtils.parseMessage(comment);
        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));
        }

View Full Code Here

     */
    @DELETE
    @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

        if (isEmpty(hashtag)) {
            return error("Hashtag payload is empty", Response.status(Response.Status.BAD_REQUEST));
        }

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

        try {
            applicationManager.getMessageService().addHashtagToMessage(user.getAccount(), new ObjectId(messageId),
                    hashtag);

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

TOP

Related Classes of com.streamreduce.core.model.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.