Package org.eurekastreams.server.search.modelview

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


     * @param inActivityDTO
     *            - current {@link ActivityDTO} to be posted.
     */
    private void performPersonAuthorization(final Principal inPrincipal, final ActivityDTO inActivityDTO)
    {
        PersonModelView currentPerson = getPersonModelViewByAccountIdMapper.execute(inActivityDTO
                .getDestinationStream().getUniqueIdentifier());

        if (currentPerson == null)
        {
            throw new AuthorizationException("Cannot locate current person.  The activity destination stream id is "
                    + inActivityDTO.getDestinationStream().getUniqueIdentifier());
        }

        boolean isActorTheStreamOwner = inPrincipal.getAccountId().equalsIgnoreCase(
                inActivityDTO.getDestinationStream().getUniqueIdentifier());

        // Test if the user is the owner of the stream being posted to or the stream
        // has been authorized for this type of interaction.
        if (isActorTheStreamOwner || currentPerson.isStreamPostable())
        {
            return;
        }

        throw new AuthorizationException("Current user does not have access rights to post this activity.");
View Full Code Here


        // 3. Create the sample lists of people that shared and liked this resource
        if (personIds.size() > 0)
        {
            List<PersonModelView> people = getPeopleModelViewsByIdsMapper.execute(personIds);
            PersonModelView foundPerson;
            for (long personId : personIds)
            {
                foundPerson = findPersonInList(people, personId);
                if (foundPerson != null)
                {
View Full Code Here

     * @return {@link Principal} object based on the OpenSocial id passed in.
     */
    @Override
    public Principal execute(final String inOpenSocialId)
    {
        PersonModelView user = null;
        try
        {
            // get current user to build principal.
            user = personMapper.fetchUniqueResult(inOpenSocialId);
        }
        catch (Exception e)
        {
            logger.error("Unable to populate principal for OpenSocialId: " + inOpenSocialId);
            throw new PrincipalPopulationException("Unable to populate principal for OpenSocialId: " + inOpenSocialId,
                    e);
        }

        // must handle successful null result from personMapper.fetchUniqueResult
        if (user == null)
        {
            logger.error("Unable to find principal for OpenSocialId: " + inOpenSocialId + " attempting ntid");
            try
            {
                user = getPersonModelViewByAccountIdMapper.execute(inOpenSocialId);
            }
            catch (Exception e)
            {
                throw new PrincipalPopulationException("Unable to find principal for OpenSocialId: " + inOpenSocialId);
            }
            // If the user is still null, neither a valid opensocial id nor a valid ntid was provided.
            if (user == null)
            {
                throw new PrincipalPopulationException("Unable to find principal for OpenSocialId: " + inOpenSocialId);
            }
        }

        return new DefaultPrincipal(user.getAccountId(), user.getOpenSocialId(), user.getEntityId());
    }
View Full Code Here

    {
        DefaultPrincipal result = null;
        try
        {
            // grab info from cache/db.
            PersonModelView pmv = getPersonMVByAccountId.execute(inAccountId);

            // if found, create principal, else attempt to create from LDAP (creates locked user in DB).
            if (pmv != null)
            {
                result = new DefaultPrincipal(pmv.getAccountId(), pmv.getOpenSocialId(), pmv.getId());
            }
            // not found in cache or DB, go to ldap to create person entry and principal if possible.
            else
            {
                logger.info("Unable to populate principal from cache/db, looking up user in LDAP for: " + inAccountId);
View Full Code Here

            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());

            log.info("Removing activity #" + activityId + " from person stream + " + person.getStreamId());

            getCache().removeFromList(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + person.getStreamId(), activityId);

            break;
        default:
            break;
        }
View Full Code Here

     *
     * @return PersonModelView.
     */
    public PersonModelView toPersonModelView()
    {
        PersonModelView p = new PersonModelView();
        p.setEntityId(getId());
        p.setAvatarId(avatarId);
        p.setAccountId(accountId);
        p.setOpenSocialId(openSocialId);
        p.setOptOutVideos(getOptOutVideos());
        p.setDisplayName(getDisplayName());
        p.setFollowersCount(followersCount);
        p.setFollowingCount(followingCount);
        p.setGroupsCount(groupsCount);
        p.setTitle(title);
        p.setEmail(email);
        p.setDateAdded(dateAdded);
        p.setAdditionalProperties(getAdditionalProperties());
        p.setLastName(lastName);
        p.setPreferredName(preferredName);
        p.setJobDescription(getJobDescription());
        p.setCompanyName(getCompanyName());
        p.setAvatarCropSize(avatarCropSize);
        p.setAvatarCropX(avatarCropX);
        p.setAvatarCropY(avatarCropY);
        p.setCellPhone(cellPhone);
        p.setWorkPhone(workPhone);
        p.setFax(fax);
        p.setBannerId(bannerId);

        if (background != null)
        {
            List<String> interests = new ArrayList<String>();
            for (BackgroundItem item : background.getBackgroundItems(BackgroundItemType.SKILL))
            {
                interests.add(item.getName());
            }
            p.setInterests(interests);
        }
        return p;
    }
View Full Code Here

                {
                    GetPeopleByOpenSocialIdsRequest currentRequest = new GetPeopleByOpenSocialIdsRequest(
                            Arrays.asList(userId), groupId.getType().toString().toLowerCase());

                    ServiceActionContext currentContext = new ServiceActionContext(currentRequest, getPrincipal(token));
                    PersonModelView result = null;
                    try
                    {
                        result = ((LinkedList<PersonModelView>) serviceActionController.execute(currentContext,
                                getPeopleAction)).getFirst();
                    }
View Full Code Here

     *            requested userId.
     * @return Bogus PersonModelView for users not in system.
     */
    private PersonModelView createNonUserPersonModelView(final String userId)
    {
        PersonModelView nonUser = new PersonModelView();
        // Populate the OpenSocial person properties.
        nonUser.setDisplayName(userId);
        nonUser.setOpenSocialId(userId);
        nonUser.setDescription("Non Eureka user");
        nonUser.setAccountId(userId);
        nonUser.setEmail("nonEurekaUser@lmco.com");
        nonUser.setAvatarId(null);

        return nonUser;
    }
View Full Code Here

            // get the display name for the destination stream
            if (activity.getDestinationStream().getUniqueIdentifier() != null)
            {
                if (activity.getDestinationStream().getType() == EntityType.PERSON)
                {
                    PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity
                            .getDestinationStream().getUniqueIdentifier());
                    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
View Full Code Here

            {
                log.info("Loading " + recordCounter + "th person record, clearing session.");
                getHibernateSession().clear();
            }

            PersonModelView result = (PersonModelView) scroll.get(0);

            getCache().set(CacheKeys.PERSON_BY_ID + result.getEntityId(), result);
            getCache().set(CacheKeys.PERSON_BY_ACCOUNT_ID + result.getAccountId(), result.getEntityId());
            getCache().set(CacheKeys.PERSON_BY_OPEN_SOCIAL_ID + result.getOpenSocialId(), result.getEntityId());
        }
    }
View Full Code Here

TOP

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

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.