Package org.eurekastreams.server.action.request.stream

Examples of org.eurekastreams.server.action.request.stream.PostSplitActivityAndCommentsRequest


     * {@inheritDoc}
     */
    @Override
    public void validate(final ActionContext inActionContext) throws ValidationException
    {
        PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext
                .getParams();

        if (request == null)
        {
            throw new ValidationException("A request must be provided.");
        }

        if (StringUtils.isBlank(request.getText()))
        {
            throw new ValidationException("Request must provide text content.");
        }
    }
View Full Code Here


     * {@inheritDoc}
     */
    @Override
    public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
    {
        PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext
                .getActionContext().getParams();

        // get the entity whose stream to post to
        DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType());
        if (uniqueIdDAO == null)
        {
            throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType());
        }
        String uniqueId = uniqueIdDAO.execute(request.getEntityId());

        // split the text
        List<String> pieces = textSplitter.split(request.getText());
        if (pieces.isEmpty())
        {
            throw new ValidationException("Text to post must not be empty.");
        }

        // post the activity
        ActivityDTO activityToPost = new ActivityDTO();
        activityToPost.setBaseObjectType(BaseObjectType.NOTE);
        activityToPost.setVerb(ActivityVerb.POST);
        activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId));
        activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content",
                pieces.get(0))));
        TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType());
        ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext,
                new PostActivityRequest(activityToPost));

        // post the comments
        for (String piece : pieces.subList(1, pieces.size()))
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.action.request.stream.PostSplitActivityAndCommentsRequest

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.