Package org.jasig.portal.portlets.groupselector

Examples of org.jasig.portal.portlets.groupselector.EntityEnum


   * @see org.jasig.portal.layout.dlm.remoting.IGroupListHelper#getEntity(java.lang.String, java.lang.String, boolean)
   */
  public JsonEntityBean getEntity(String entityType, String entityId, boolean populateChildren) {

    // get the EntityEnum for the specified entity type
    EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
   
    // if the entity type is a group, use the group service's findGroup method
    // to locate it
    if(entityEnum.isGroup()) {
      // attempt to find the entity
      IEntityGroup entity = GroupService.findGroup(entityId);
      if(entity == null) {
        return null;
      } else {
        JsonEntityBean jsonBean = new JsonEntityBean(entity, entityEnum);
        if (populateChildren) {
          @SuppressWarnings("unchecked")
          Iterator<IGroupMember> members = (Iterator<IGroupMember>) entity.getMembers();
          jsonBean = populateChildren(jsonBean, members);
        }
                if (jsonBean.getEntityType().isGroup() || EntityEnum.PERSON.equals(jsonBean.getEntityType())) {
                    IAuthorizationPrincipal principal = getPrincipalForEntity(jsonBean);
                    jsonBean.setPrincipalString(principal.getPrincipalString());
                }
        return jsonBean;
      }
    }
   
    // otherwise use the getGroupMember method
    else {
      IGroupMember entity = GroupService.getGroupMember(entityId, entityEnum.getClazz());
      if(entity == null || entity instanceof IEntityGroup) {
        return null;
      }
      JsonEntityBean jsonBean = new JsonEntityBean(entity, entityEnum);
     
View Full Code Here


   * @see org.jasig.portal.layout.dlm.remoting.IGroupListHelper#getEntity(org.jasig.portal.groups.IGroupMember)
   */
  public JsonEntityBean getEntity(IGroupMember member) {

    // get the type of this member entity
    EntityEnum entityEnum = getEntityType(member);
   
    // construct a new entity bean for this entity
    JsonEntityBean entity;
    if (entityEnum.isGroup()) {
      entity = new JsonEntityBean((IEntityGroup) member, entityEnum);
    } else {
      entity = new JsonEntityBean(member, entityEnum);
    }
   
View Full Code Here

   
    public IAuthorizationPrincipal getPrincipalForEntity(JsonEntityBean entity) {
       
        // attempt to determine the entity type class for this principal
        Class entityType;
        EntityEnum jsonType = entity.getEntityType();
        if (jsonType.isGroup()) {
            entityType = IEntityGroup.class;
        } else {
            entityType = jsonType.getClazz();
        }
       
        // construct an authorization principal for this JsonEntityBean
        AuthorizationService authService = AuthorizationService.instance();
        IAuthorizationPrincipal p = authService.newPrincipal(entity.getId(), entityType);
View Full Code Here

   * @param groupMember Entity to look up
   * @return groupMember's name or null if there's an error
   */
  public String lookupEntityName(JsonEntityBean entity) {
   
    EntityEnum entityEnum = entity.getEntityType();
    IEntityNameFinder finder;
    if (entityEnum.isGroup()) {
      finder = EntityNameFinderService.instance()
        .getNameFinder(IEntityGroup.class);
    } else {
      finder = EntityNameFinderService.instance()
        .getNameFinder(entityEnum.getClazz());
    }
   
    try {
      return finder.getName(entity.getId());
    } catch (Exception e) {
View Full Code Here

        }
    }

    protected AuthorizableActivity getViewActivity(final String activityKey, final JsonEntityBean entity) {
        if (entity != null && activityKey.equals("VIEW")) {
            final EntityEnum type = entity.getEntityType();
            if (type.isGroup()) {
                return new AuthorizableActivity(GroupAdministrationHelper.GROUPS_OWNER,
                            GroupAdministrationHelper.VIEW_PERMISSION);
            } else if (type.equals(EntityEnum.PERSON)) {
                return new AuthorizableActivity(IPersonLookupHelper.USERS_OWNER,
                        IPersonLookupHelper.VIEW_USER_PERMISSION);
            } else if (type.equals(EntityEnum.PORTLET)) {
                return new AuthorizableActivity(IPermission.PORTAL_SUBSCRIBE, IPermission.PORTLET_SUBSCRIBER_ACTIVITY);
            }
        }
        return null;
    }
View Full Code Here

    }
   
    // add all the group membership information from the group form
    // to the group
    for (JsonEntityBean child : groupForm.getMembers()) {
      EntityEnum type = EntityEnum.getEntityEnum(child.getEntityTypeAsString());
      if (type.isGroup()) {
        IEntityGroup member = GroupService.findGroup(child.getId());
        group.addMember(member);
      } else {
        IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz());
        group.addMember(member);
      }
    }
   
    // save the group, updating both its basic information and group
View Full Code Here

          + groupForm.toString() + "] and parent ["
          + parent.toString() + "]");
    }

    // get the entity type of the parent group
    EntityEnum type = EntityEnum.getEntityEnum(groupForm.getType());
   
    // create a new group with the parent's entity type
    IEntityGroup group = GroupService.newGroup(type.getClazz());
   
    // find the current version of this group entity
    group.setCreatorID(creator.getUserName());
    group.setName(groupForm.getName());
    group.setDescription(groupForm.getDescription());
   
    // add all the group membership information from the group form
    // to the group
    for (JsonEntityBean child : groupForm.getMembers()) {
      EntityEnum childType = EntityEnum.getEntityEnum(child.getEntityTypeAsString());
      if (childType.isGroup()) {
        IEntityGroup member = GroupService.findGroup(child.getId());
        group.addMember(member);
      } else {
        IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz());
        group.addMember(member);
View Full Code Here

    }

    public Set<Entity> search(String entityType, String searchTerm) {

        Set<Entity> results = new HashSet<Entity>();
        EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
        EntityIdentifier[] identifiers;
        Class identifierType;

        // if the entity type is a group, use the group service's findGroup method
        // to locate it
        if (entityEnum.isGroup()) {
            identifiers = GroupService.searchForGroups(searchTerm, GroupService.CONTAINS,entityEnum.getClazz());
            identifierType = IEntityGroup.class;
        }
        // otherwise use the getGroupMember method
        else {
            identifiers = GroupService.searchForEntities(searchTerm, GroupService.CONTAINS,entityEnum.getClazz());
            identifierType = entityEnum.getClazz();
        }

        for(EntityIdentifier entityIdentifier : identifiers) {
            if(entityIdentifier.getType().equals(identifierType)) {
                IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
View Full Code Here

    }

    public Entity getEntity(String entityType, String entityId, boolean populateChildren) {

        // get the EntityEnum for the specified entity type
        EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);

        // if the entity type is a group, use the group service's findGroup method
        // to locate it
        if(entityEnum.isGroup()) {
            // attempt to find the entity
            IEntityGroup entityGroup = GroupService.findGroup(entityId);
            if(entityGroup == null) {
                return null;
            } else {
                Entity entity = EntityFactory.createEntity(entityGroup,entityEnum);
                if (populateChildren) {
                    @SuppressWarnings("unchecked")
                    Iterator<IGroupMember> members = (Iterator<IGroupMember>) entityGroup.getMembers();
                    entity = populateChildren(entity,members);
                }
                IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
                Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());

                entity.setPrincipal(principal);
                return entity;
            }
        }

        // otherwise use the getGroupMember method
        else {
            IGroupMember groupMember = GroupService.getGroupMember(entityId, entityEnum.getClazz());
            if(groupMember == null || groupMember instanceof IEntityGroup) {
                return null;
            }
            Entity entity = EntityFactory.createEntity(groupMember,entityEnum);
View Full Code Here

    }

    public Entity getEntity(IGroupMember member) {

        // get the type of this member entity
        EntityEnum entityEnum = getEntityType(member);

        // construct a new entity bean for this entity
        Entity entity;
        if (entityEnum.isGroup()) {
            entity = EntityFactory.createEntity((IEntityGroup) member, entityEnum);
        } else {
            entity = EntityFactory.createEntity(member, entityEnum);
        }
View Full Code Here

TOP

Related Classes of org.jasig.portal.portlets.groupselector.EntityEnum

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.