Package org.eurekastreams.server.domain.stream

Examples of org.eurekastreams.server.domain.stream.ActivityDTO


                        with(new EasyMatcher<PostActivityRequest>()
                        {
                            @Override
                            protected boolean isMatch(final PostActivityRequest inTestObject)
                            {
                                ActivityDTO act = inTestObject.getActivityDTO();
                                return PIECE1.equals(act.getBaseObjectProperties().get("content"))
                                        && BaseObjectType.NOTE == act.getBaseObjectType()
                                        && act.getVerb() == ActivityVerb.POST
                                        && act.getDestinationStream().getEntityType() == EntityType.PERSON
                                        && PERSON_UNIQUE_ID.equals(act.getDestinationStream().getUniqueId());
                            }
                        }));
                will(returnValue(activity));
            }
        });
View Full Code Here


                        with(new EasyMatcher<PostActivityRequest>()
                        {
                            @Override
                            protected boolean isMatch(final PostActivityRequest inTestObject)
                            {
                                ActivityDTO act = inTestObject.getActivityDTO();
                                return PIECE1.equals(act.getBaseObjectProperties().get("content"))
                                        && BaseObjectType.NOTE == act.getBaseObjectType()
                                        && act.getVerb() == ActivityVerb.POST
                                        && act.getDestinationStream().getEntityType() == EntityType.GROUP
                                        && GROUP_UNIQUE_ID.equals(act.getDestinationStream().getUniqueId());
                            }
                        }));
                will(returnValue(activity));
            }
        });
View Full Code Here

                        with(new EasyMatcher<PostActivityRequest>()
                        {
                            @Override
                            protected boolean isMatch(final PostActivityRequest inTestObject)
                            {
                                ActivityDTO act = inTestObject.getActivityDTO();
                                return PIECE1.equals(act.getBaseObjectProperties().get("content"))
                                        && BaseObjectType.NOTE == act.getBaseObjectType()
                                        && act.getVerb() == ActivityVerb.POST
                                        && act.getDestinationStream().getEntityType() == EntityType.PERSON
                                        && PERSON_UNIQUE_ID.equals(act.getDestinationStream().getUniqueId());
                            }
                        }));
                will(returnValue(activity));
                inSequence(seq);
View Full Code Here

     * @return Populated instance of the {@link ActivityDTO} after being persisted.
     */
    @Override
    public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
    {
        ActivityDTO inActivityDTO = ((PostActivityRequest) inActionContext.getActionContext().getParams())
                .getActivityDTO();
        ActivityDTO persistedActivityDTO;
        Activity newActivity = convertDTOToActivity(inActivityDTO, inActionContext.getUserActionRequests());
        List<UserActionRequest> queueRequests = new ArrayList<UserActionRequest>();

        String actorAccountName = inActionContext.getActionContext().getPrincipal().getAccountId();

        newActivity.setPostedTime(new Date());
        newActivity.setActorId(actorAccountName);
        newActivity.setActorType(EntityType.PERSON);

        long actorId = 0;
        long destinationId = 0;
        EntityType destinationType;

        // Persist to long term storage.
        insertMapper.execute(new PersistenceRequest<Activity>(newActivity));
        insertMapper.flush();

        // Force the cache to load the activityDTO in from the db.
        List<ActivityDTO> activityResults = activitiesMapper.execute(Arrays.asList(newActivity.getId()));
        persistedActivityDTO = activityResults.get(0);
        actorId = persistedActivityDTO.getActor().getId();
        destinationId = persistedActivityDTO.getDestinationStream().getDestinationEntityId();
        destinationType = persistedActivityDTO.getDestinationStream().getType();

        // add activity to destination entity streams
        updateStreamsByActorMapper.execute(persistedActivityDTO);

        // Insert the comment that was posted with a shared post.
        if (inActivityDTO.getFirstComment() != null && inActivityDTO.getVerb().equals(ActivityVerb.SHARE))
        {
            insertCommentDAO.execute(new InsertActivityCommentRequest(actorId, persistedActivityDTO.getId(),
                    inActivityDTO.getFirstComment().getBody()));
        }

        RequestType requestType = null;

        // Sends notifications for new personal stream posts.
        if (destinationType == EntityType.PERSON)
        {
            requestType = RequestType.POST_PERSON_STREAM;
        }
        // Sends notifications for new group stream posts.
        else if (destinationType == EntityType.GROUP)
        {
            requestType = RequestType.POST_GROUP_STREAM;
        }

        // Setup the queued requests.
        if (requestType != null)
        {
            CreateNotificationsRequest notificationRequest = new ActivityNotificationsRequest(requestType, actorId,
                    destinationId, persistedActivityDTO.getEntityId());
            queueRequests
                    .add(new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, notificationRequest));
        }
        // TODO: fix this so activityDTO fields related to specific user
        // are not saved in cache.
View Full Code Here

        // get people who have this activity starred before removal from DB.
        List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId);

        // delete activity/comments/stars from DB and update current user's views.
        ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId));

        // action has already been deleted or was never present, short-circuit here.
        if (activity == null)
        {
            return Boolean.TRUE;
        }

        // if this activity was sticky, reset the stream's sticky activity
        if (activity.getDestinationStream().getEntityType() == EntityType.GROUP)
        {
            DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId());
            if (group != null && activityId.equals(group.getStickyActivityId()))
            {
                clearGroupStickyActivityExecutor.execute(inActionContext,
                        new UpdateStickyActivityRequest(group.getId(), null));
            }
View Full Code Here

    {
        ValidationException valEx = new ValidationException();

        PostActivityRequest currentRequest = (PostActivityRequest) inActionContext.getParams();

        ActivityDTO currentActivity = currentRequest.getActivityDTO();

        // All activities must have a destination stream.
        if (currentActivity.getDestinationStream() == null
                || currentActivity.getDestinationStream().getUniqueIdentifier() == null
                || currentActivity.getDestinationStream().getUniqueIdentifier().length() <= 0)
        {
            valEx.addError("destination_stream", "Activities require a Destination Stream.");
            throw valEx;
        }

        // All activities must be posted to either a person or group stream.
        if (!((currentActivity.getDestinationStream().getType() == EntityType.PERSON)
                || (currentActivity.getDestinationStream().getType() == EntityType.GROUP) || currentActivity
                .getDestinationStream().getType() == EntityType.RESOURCE))
        {
            valEx.addError("destination_stream_type",
                    "Activities can only be submitted to Person, Group, or Resource streams.");
            throw valEx;
        }

        // If there are verb and object validator instances available use them
        // to validate the
        // activity object, if not, throw an exception.
        if (verbValidators.containsKey(currentActivity.getVerb().name())
                && objectValidators.containsKey(currentActivity.getBaseObjectType().name()))
        {
            try
            {
                ActivityValidator currentVerbVal = verbValidators.get(currentActivity.getVerb().name());
                currentVerbVal.validate(currentActivity);

                ActivityValidator currentObjectVal = objectValidators.get(currentActivity.getBaseObjectType().name());
                currentObjectVal.validate(currentActivity);
            }
            catch (ValidationException vex)
            {
                log.error("ActivityValidators failed for this activity.", vex);
View Full Code Here

     * @param inActionContext
     *            the action context
     */
    public void authorize(final PrincipalActionContext inActionContext)
    {
        ActivityDTO activity = null;
        final Principal principal = inActionContext.getPrincipal();
        try
        {
            long activityId = activityIdFromParamsTransformer.transform(inActionContext.getParams());
            activity = getActivityDAO.execute(activityId);
View Full Code Here

     */
    @Override
    public void authorize(final PrincipalActionContext inActionContext)
    {
        Long activityId = (Long) inActionContext.getParams();
        ActivityDTO activity = getActivityById(activityId);
        try
        {
            String currentUserAccountId = inActionContext.getPrincipal().getAccountId();
            Long currentUserId = inActionContext.getPrincipal().getId();
            activityDeletePropertySetter.execute(currentUserAccountId, currentUserId, activity);
        }
        catch (Exception ex)
        {
            log.error("Error occurred determining access rights for activity delete.", ex);
            throw new AuthorizationException("Unable to determine access rights.");
        }

        // If unable to delete, throw access exception.
        if (!activity.isDeletable())
        {
            // if you get to this point, "No soup for you!".
            throw new AuthorizationException("Current user does not have permissions to modify activity id: "
                    + activityId);
        }
View Full Code Here

        AddBufferedActivitiesToCache sut = new AddBufferedActivitiesToCache(bulkActivitiesMapper, cache,
                getIdsOfPeopleFollowingActivityDestinationStreamMapper, updateActorActivityStreamMapper);

        final List<Long> activityIds = null;

        final ActivityDTO activity1 = context.mock(ActivityDTO.class);
        final ActivityDTO activity2 = context.mock(ActivityDTO.class, "a2");

        final List<ActivityDTO> activities = new LinkedList<ActivityDTO>();
        activities.add(activity1);
        activities.add(activity2);
View Full Code Here

        AddBufferedActivitiesToCache sut = new AddBufferedActivitiesToCache(bulkActivitiesMapper, cache,
                getIdsOfPeopleFollowingActivityDestinationStreamMapper, updateActorActivityStreamMapper);

        final List<Long> activityIds = null;

        final ActivityDTO activity1 = context.mock(ActivityDTO.class);
        final ActivityDTO activity2 = context.mock(ActivityDTO.class, "a2");

        final List<ActivityDTO> activities = new LinkedList<ActivityDTO>();

        context.checking(new Expectations()
        {
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.stream.ActivityDTO

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.