Package org.eurekastreams.server.action.request.profile

Examples of org.eurekastreams.server.action.request.profile.SetFollowingStatusRequest


     * coordinator.
     */
    @Test(expected = AuthorizationException.class)
    public void testAuthorizeRemoveFollowerPrivateGroupNotCoordinator()
    {
        final SetFollowingStatusRequest request = new SetFollowingStatusRequest("1", "1", EntityType.GROUP, false,
                Follower.FollowerStatus.NOTFOLLOWING);

        final DomainGroupModelView testGroup = new DomainGroupModelView();
        testGroup.setIsPublic(false);
        testGroup.setEntityId(1L);
View Full Code Here


     * follower themselves.
     */
    @Test(expected = AuthorizationException.class)
    public void testAuthorizeRemoveFollowerPublicGroupNotOwner()
    {
        final SetFollowingStatusRequest request = new SetFollowingStatusRequest("ntaccount", "groupshortname",
                EntityType.GROUP, false, Follower.FollowerStatus.NOTFOLLOWING);

        final DomainGroupModelView testGroup = new DomainGroupModelView();
        testGroup.setIsPublic(true);
        testGroup.setEntityId(1L);
View Full Code Here

     * follower themselves.
     */
    @Test
    public void testAuthorizeRemoveFollowerPublicGroup()
    {
        final SetFollowingStatusRequest request = new SetFollowingStatusRequest("ntaccount", "groupshortname",
                EntityType.GROUP, false, Follower.FollowerStatus.NOTFOLLOWING);

        final DomainGroupModelView testGroup = new DomainGroupModelView();
        testGroup.setIsPublic(true);
        testGroup.setEntityId(1L);
View Full Code Here

     */
    @Override
    public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
            throws ExecutionException
    {
        SetFollowingStatusRequest request = (SetFollowingStatusRequest) inActionContext.getActionContext().getParams();
        if (logger.isTraceEnabled())
        {
            logger.trace("Entering follow person strategy with followerid: " + request.getFollowerUniqueId()
                    + " targetid: " + request.getTargetUniqueId() + " and status " + request.getFollowerStatus());
        }

        List<UserActionRequest> asyncRequests = inActionContext.getUserActionRequests();
        int followingCount;

        Long followerPersonId;
        Long followedPersonId = getPersonIdByAccountIdMapper.execute(request.getTargetUniqueId());

        // gets the current user if no follower id was passed in.
        if (request.getFollowerUniqueId() == null || request.getFollowerUniqueId() == "")
        {
            followerPersonId = inActionContext.getActionContext().getPrincipal().getId();
        }
        else
        {
            followerPersonId = getPersonIdByAccountIdMapper.execute(request.getFollowerUniqueId());
        }

        switch (request.getFollowerStatus())
        {
        case FOLLOWING:
            logger.trace("Add new following to the list of following.");
            mapper.addFollower(followerPersonId, followedPersonId);
            addCachedFollowerMapper.execute(followerPersonId, followedPersonId);
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException
    {
        SetFollowingStatusRequest request = (SetFollowingStatusRequest) inActionContext.getParams();

        // User cannot follow themselves
        if (request.getFollowerUniqueId() != null && request.getFollowerUniqueId().equals(request.getTargetUniqueId()))
        {
            logger.error("Error occurred authorizing Following a person: " + AUTH_ERROR_FOLLOWING_SELF);
            throw new AuthorizationException(AUTH_ERROR_FOLLOWING_SELF);
        }

        // The user calling the action is the only one who can request to follow another user.
        if (request.getFollowerUniqueId() != null && !request.getFollowerUniqueId()
            .equals(inActionContext.getPrincipal().getAccountId()))
        {
            logger.error("Error occurred authorizing Following a person: " + AUTH_ERROR_NONOWNER_FOLLOWING);
            throw new AuthorizationException(AUTH_ERROR_NONOWNER_FOLLOWING);
        }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException
    {
        SetFollowingStatusRequest request = (SetFollowingStatusRequest) inActionContext.getParams();

        DomainGroupModelView targetResult = groupMapper.fetchUniqueResult(request.getTargetUniqueId());

        if (request.getFollowerStatus().equals(Follower.FollowerStatus.FOLLOWING))
        {
            // If the group is private, only a group coordinator can add a follower to a group.
            if (!targetResult.isPublic())
            {
                Set<Long> groupCoordinators = groupCoordMapper.execute(targetResult.getEntityId());
                if (!groupCoordinators.contains(inActionContext.getPrincipal().getId()))
                {
                    throw new AuthorizationException("Only group coordinators can add members to a private group.");
                }
            }
        }
        else
        {
            // if the group is private, the follower and group coordinators are the only users that can sever the
            // relationship.
            if (!targetResult.isPublic())
            {
                Set<Long> groupCoordinators = groupCoordMapper.execute(targetResult.getEntityId());
                if (!groupCoordinators.contains(inActionContext.getPrincipal().getId())
                        && !request.getFollowerUniqueId().equals(inActionContext.getPrincipal().getAccountId()))
                {
                    throw new AuthorizationException("Coordinators and Followers are the only ones who can remove a "
                            + "follower from a private group.");
                }
            }
            // If the group is public only the own can sever the relationship.
            else if (request.getFollowerUniqueId() != null && request.getFollowerUniqueId() != ""
                    && !request.getFollowerUniqueId().equals(inActionContext.getPrincipal().getAccountId()))
            {
                throw new AuthorizationException("Only the owner of a relationship can remove it.");
            }
        }

View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        SetFollowingStatusRequest inRequest = (SetFollowingStatusRequest) inActionContext.getParams();

        ValidationException vex = new ValidationException();

        if (!inRequest.getTargetEntityType().equals(EntityType.PERSON))
        {
            vex.addError("EntityType", "This action only supports following a person.");
        }

        Long followingId = getPersonIdByAccountIdMapper.execute(inRequest.getTargetUniqueId());

        if (followingId == null)
        {
            vex.addError("FollowerAndTarget", "Target unique id for valid users must be supplied.");
        }
View Full Code Here

     */
    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        ValidationException vex = new ValidationException();
        SetFollowingStatusRequest inRequest = (SetFollowingStatusRequest) inActionContext.getParams();

        if (!inRequest.getTargetEntityType().equals(EntityType.GROUP))
        {
            vex.addError("EntityType", "This action only supports following a group.");
        }

        DomainGroupModelView targetResult = domainGroupMapper.fetchUniqueResult(inRequest.getTargetUniqueId());

        if (targetResult == null)
        {
            vex.addError("FollowerAndTarget", "Target unique id must refer to valid entity.");
        }
View Full Code Here

            lastHandler = followLink.addClickHandler(new ClickHandler()
            {
                public void onClick(final ClickEvent event)
                {
                    SetFollowingStatusRequest request;

                    switch (status)
                    {
                    case FOLLOWING:
                        request = new SetFollowingStatusRequest(Session.getInstance().getCurrentPerson()
                                .getAccountId(), entityId, type, false, Follower.FollowerStatus.NOTFOLLOWING);
                        ((Deletable<SetFollowingStatusRequest>) followModel).delete(request);
                        onFollowerStatusChanged(Follower.FollowerStatus.NOTFOLLOWING);
                        break;
                    case NOTFOLLOWING:
                        request = new SetFollowingStatusRequest(Session.getInstance().getCurrentPerson()
                                .getAccountId(), entityId, type, false, Follower.FollowerStatus.FOLLOWING);
                        ((Insertable<SetFollowingStatusRequest>) followModel).insert(request);
                        Dialog.showCentered(new FollowDialogContent(streamName.getInnerText(), streamReq, streamId,
                                type, subscribeModel, entityId));
                        onFollowerStatusChanged(Follower.FollowerStatus.FOLLOWING);
View Full Code Here

     * {@inheritDoc}.
     */
    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        SetFollowingStatusRequest inRequest = (SetFollowingStatusRequest) inActionContext.getParams();

        ValidationException vex = new ValidationException();

        if (inRequest.getTargetUniqueId().length() <= 0)
        {
            vex.addError("FollowerAndTarget", "This action requires a target unique id");
            logger.error("Validation error - " + vex.getErrors().get("FollowerAndTarget"));
            // if this occurs, throw the error now, no point continuing since the following calls will fail.
            throw vex;
        }

        if (inRequest.getFollowerStatus().equals(Follower.FollowerStatus.NOTSPECIFIED))
        {
            vex.addError("FollowingStatus", "This action does not accept setting FollowerStatus of NOTSPECIFIED");
            logger.error("Validation error - " + vex.getErrors().get("FollowingStatus"));
            throw vex;
        }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.action.request.profile.SetFollowingStatusRequest

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.