Search in sources :

Example 6 with CommentData

use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.

the class CommentDataUtil method createCommentData.

public static CommentData createCommentData(CommentDoc commentDoc) {
    CommentData commentData = new CommentData(commentDoc.getId());
    commentData.setUserId(commentDoc.getUserId());
    commentData.setContent(commentDoc.getContent());
    commentData.setCreationDate(commentDoc.getCreationDate());
    commentData.setLastUpdated(commentDoc.getLastUpdated());
    commentData.setLikeCount(commentDoc.getLikeCount());
    commentData.setAccessToUpdate(hasAccessToUpdateCommentData(CommentState.ACTIVE, commentDoc.getUserId()));
    commentData.setLiked(commentDoc.getLikedByUserIds().contains(AccessTokenFilter.getAccessToken().getUserId()));
    return commentData;
}
Also used : CommentData(com.pratilipi.data.client.CommentData)

Example 7 with CommentData

use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.

the class CommentApi method post.

@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
    CommentData commentData = new CommentData(request.commentId);
    commentData.setUserId(AccessTokenFilter.getAccessToken().getUserId());
    commentData.setParentType(request.parentType);
    commentData.setParentId(request.parentId);
    if (request.hasContent)
        commentData.setContent(request.content);
    if (request.hasState)
        commentData.setState(request.state);
    else
        commentData.setState(CommentState.ACTIVE);
    commentData = CommentDataUtil.saveCommentData(commentData);
    if (commentData.getReferenceType() == ReferenceType.PRATILIPI) {
        Task task = TaskQueueFactory.newTask().setUrl("/pratilipi/process").addParam("pratilipiId", commentData.getReferenceId()).addParam("updateReviewsDoc", "true");
        TaskQueueFactory.getPratilipiTaskQueue().add(task);
    }
    return new Response(commentData);
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) Task(com.pratilipi.taskqueue.Task) CommentData(com.pratilipi.data.client.CommentData) Post(com.pratilipi.api.annotation.Post)

Aggregations

CommentData (com.pratilipi.data.client.CommentData)7 DataAccessor (com.pratilipi.data.DataAccessor)2 PratilipiData (com.pratilipi.data.client.PratilipiData)2 UserPratilipiData (com.pratilipi.data.client.UserPratilipiData)2 CommentDoc (com.pratilipi.data.type.CommentDoc)2 HashMap (java.util.HashMap)2 Post (com.pratilipi.api.annotation.Post)1 GenericResponse (com.pratilipi.api.shared.GenericResponse)1 DataListCursorTuple (com.pratilipi.data.DataListCursorTuple)1 DocAccessor (com.pratilipi.data.DocAccessor)1 UserData (com.pratilipi.data.client.UserData)1 VoteData (com.pratilipi.data.client.VoteData)1 PratilipiReviewsDoc (com.pratilipi.data.type.PratilipiReviewsDoc)1 UserPratilipiDoc (com.pratilipi.data.type.UserPratilipiDoc)1 Task (com.pratilipi.taskqueue.Task)1 ArrayList (java.util.ArrayList)1