Package org.eurekastreams.server.search.modelview

Examples of org.eurekastreams.server.search.modelview.DomainGroupModelView


     * @param inActivityDTO
     *            - current {@link ActivityDTO} to be posted.
     */
    private void performGroupAuthorization(final Principal inPrincipal, final ActivityDTO inActivityDTO)
    {
        DomainGroupModelView currentDomainGroup = domainGroupsByShortNameMapper.fetchUniqueResult(inActivityDTO
                .getDestinationStream().getUniqueIdentifier());

        boolean isUserCoordinator = groupCoordMapper.execute(currentDomainGroup.getEntityId()).contains(
                inPrincipal.getId());

        // if group is public check to see if the current stream interaction is allowed based on configuration,
        // if so then short-circuit.
        if (currentDomainGroup.isPublic())
        {
            if (currentDomainGroup.isStreamPostable() || isUserCoordinator)
            {
                return;
            }
            else
            {
                throw new AuthorizationException("Group is public but the poster is not a "
                        + "coordinator and the group is configured to not allow stream posts.");
            }
        }

        // The group is private, continue forward testing private group authorization.

        if (isUserCoordinator)
        {
            // user is a coordinator
            return;
        }

        if (groupFollowersDAO.execute(currentDomainGroup.getEntityId()).contains(inPrincipal.getId())
                && currentDomainGroup.isStreamPostable())
        {
            // user is a follower
            return;
        }

View Full Code Here


    {
        StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams();
        if (request.getStreamEntityScopeType() == ScopeType.GROUP)
        {
            // only private groups require authorization
            DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey());
            if (!group.isPublic())
            {
                Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId());
                if (!groupsUserCanAccess.contains(group.getId()))
                {
                    throw new AuthorizationException(inActionContext.getPrincipal().getAccountId()
                            + " cannot access popular hashtags for group with short name " + group.getShortName());
                }
            }
        }
    }
View Full Code Here

    @Override
    public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        String shortName = (String) inActionContext.getParams();
        log.debug("shortName = " + shortName);
        DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName);
        log.debug("result = " + result);

        if (result != null)
        {
            // set banner for group.
            result.setBannerEntityId(result.getId());

            // short circuit here if restricted for user.
            if (!isAccessPermitted(inActionContext.getPrincipal(), result))
            {
                // convert to new limited model view to prevent data leakage as model view grows.
                DomainGroupModelView restricted = new DomainGroupModelView();
                restricted.setRestricted(true);
                restricted.setEntityId(result.getId());
                restricted.setBannerId(result.getBannerId());
                restricted.setName(result.getName());
                restricted.setShortName(result.getShortName());
                restricted.setAvatarId(result.getAvatarId());
                return restricted;
            }
            else
            {
                result.setRestricted(false);
View Full Code Here

            ActivityDTO origActivity = originalActivityResults.get(0);

            if (origActivity.getDestinationStream().getType() == EntityType.GROUP)
            {
                DomainGroupModelView group = groupShortNameCacheMapper.fetchUniqueResult(origActivity
                        .getDestinationStream().getUniqueIdentifier());

                if (group != null && !group.isPublic())
                {
                    ve.addError("OriginalActivity", "OriginalActivity from a private group and can not be shared.");
                    throw ve;
                }
                else if (group == null)
View Full Code Here

        EntityType streamType = activity.getDestinationStream().getType();

        switch (streamType)
        {
        case GROUP:
            DomainGroupModelView group = groupByShortNameDAO.execute(
                    Arrays.asList(activity.getDestinationStream().getUniqueIdentifier())).get(0);
            log.info("Removing activity #" + activityId + " from group stream + " + group.getStreamId());

            getCache().removeFromList(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + group.getStreamId(), activityId);
            break;
        case PERSON:
            PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getDestinationStream()
                    .getUniqueIdentifier());
View Full Code Here

                    activity.getDestinationStream().setDisplayName(person.getDisplayName());

                }
                else if (activity.getDestinationStream().getType() == EntityType.GROUP)
                {
                    DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream()
                            .getUniqueIdentifier());
                    activity.getDestinationStream().setDisplayName(group.getName());
                }
            }

            final StreamEntityDTO actor = activity.getActor();
            if (actor.getType() == EntityType.PERSON)
            {
                List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections
                        .singletonList(actor.getUniqueIdentifier()));
                if (!people.isEmpty())
                {
                    final PersonModelView person = people.get(0);
                    actor.setId(person.getEntityId());
                    actor.setDestinationEntityId(person.getEntityId());
                    actor.setDisplayName(person.getDisplayName());
                    actor.setAvatarId(person.getAvatarId());
                }
            }
            else if (actor.getType() == EntityType.GROUP)
            {
                List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor
                        .getUniqueIdentifier()));
                if (!groups.isEmpty())
                {
                    final DomainGroupModelView group = groups.get(0);
                    actor.setId(group.getEntityId());
                    actor.setDestinationEntityId(group.getEntityId());
                    actor.setDisplayName(group.getName());
                    actor.setAvatarId(group.getAvatarId());
                }
            }
            // fills in data from cached view of original actor
            final StreamEntityDTO originalActor = activity.getOriginalActor();
            if (originalActor != null)
View Full Code Here

     * @return a new DomainGroupModelView
     */
    @Override
    public DomainGroupModelView buildModelView()
    {
        return new DomainGroupModelView();
    }
View Full Code Here

            final boolean strict)
    {
        long entityId = activity.getDestinationStream().getEntityId();
        // this is bad style to declare case-specific variables here (variables should be declared in the most limited
        // scope possible), but checkstyle won't allow blocks in switch cases
        DomainGroupModelView group;

        switch (activity.getDestinationStream().getType())
        {
        case PERSON:
            return isStreamInteractionAuthorized(getPersonByIdDAO.execute(entityId), interactionType);
        case GROUP:
            group = getGroupByIdDAO.execute(entityId);
            return (!strict || group.isPublic()) ? isStreamInteractionAuthorized(group, interactionType) : false;
        case RESOURCE:
            // anyone can post comment to resource stream activity.
            return true;
        default:
            return false;
View Full Code Here

            final ActivityInteractionType interactionType)
    {
        try
        {
            final long groupId = inActivity.getDestinationStream().getEntityId();
            DomainGroupModelView group = getGroupByIdDAO.execute(groupId);
            if (group.isPublic())
            {
                // first see if user is allowed to take action in general
                if (isStreamInteractionAuthorized(group, interactionType))
                {
                    return true;
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest)
    {
        DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId());
        Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId());

        NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds);
        batch.setProperty("group", group);
        batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true);
        batch.setProperty(NotificationPropertyKeys.URL,
                UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId()));
        return batch;
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.search.modelview.DomainGroupModelView

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.