public static EntityEnum getEntityEnum(Class<?> entityTypeClazz, boolean isGroup) { EntityEnum rslt = null; for (EntityEnum val : EntityEnum.values()) { if (val.getClazz().equals(entityTypeClazz) && val.isGroup() == isGroup) { rslt = val; break; } } return rslt; }
@Override public IAuthorizationPrincipal getPrincipalForEntity(JsonEntityBean entity) { if (entity == null) { throw new IllegalArgumentException("Parameter cannot be null."); } // attempt to determine the entity type class for this principal Class entityType; EntityEnum jsonType = entity.getEntityType(); if (jsonType == null) { throw new IllegalArgumentException("Parameter's entityType cannot be null."); } if (jsonType.isGroup()) { entityType = IEntityGroup.class; } else { entityType = jsonType.getClazz(); } // construct an authorization principal for this JsonEntityBean AuthorizationServiceFacade authService = AuthorizationServiceFacade.instance(); IAuthorizationPrincipal p = authService.newPrincipal(entity.getId(), entityType); return p; }
public String lookupEntityName(EntityEnum entityType, String entityId) { if (entityType == null && (StringUtils.isBlank(entityId))) { return null; } IEntityNameFinder finder; if (entityType.isGroup()) { finder = EntityNameFinderService.instance().getNameFinder(IEntityGroup.class); } else { finder = EntityNameFinderService.instance().getNameFinder(entityType.getClazz()); } try { return finder.getName(entityId); } catch (Exception e) { /* An exception here isn't the end of the world. Just log it and return null. */ log.warn("Couldn't find name for entity " + entityId, e); return null; } }
if (entityEnum.isGroup()) { identifiers = GroupService.searchForGroups(
private 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( IPermission.PORTAL_GROUPS, IPermission.VIEW_GROUP_ACTIVITY); } else if (type.equals(EntityEnum.PERSON)) { return new AuthorizableActivity( IPermission.PORTAL_USERS, IPermission.VIEW_USER_ACTIVITY); } else if (type.equals(EntityEnum.PORTLET)) { return new AuthorizableActivity( IPermission.PORTAL_SUBSCRIBE, IPermission.PORTLET_SUBSCRIBER_ACTIVITY); } } return null; }
if (entityEnum.isGroup()) { identifiers = GroupService.searchForGroups(
if (entityEnum.isGroup()) { finder = EntityNameFinderService.instance().getNameFinder(IEntityGroup.class); } else {
public Entity getEntity(IGroupMember member) { if (member == null) { return null; } // 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); } // if the name hasn't been set yet, look up the entity name if (entity.getName() == null) { entity.setName(lookupEntityName(entity)); } if (EntityEnum.GROUP.toString().equals(entity.getEntityType()) || EntityEnum.PERSON.toString().equals(entity.getEntityType())) { IAuthorizationPrincipal authP = getPrincipalForEntity(entity); Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString()); entity.setPrincipal(principal); } return entity; }
final EntityEnum entityEnum = bean.getEntityType(); final IGroupMember principal = entityEnum.isGroup() ? (GroupService.findGroup(bean.getId())) : (GroupService.getGroupMember(bean.getId(), entityEnum.getClazz()));
Class<?> clazz; EntityEnum entityType = EntityEnum.getEntityEnum(e.getEntityTypeAsString()); if (entityType.isGroup()) { clazz = IEntityGroup.class; } else { Class<?> clazz; EntityEnum entityType = EntityEnum.getEntityEnum(e.getEntityTypeAsString()); if (entityType.isGroup()) { clazz = IEntityGroup.class; } else {
if (entityEnum.isGroup()) {
if (entityEnum.isGroup()) { member = GroupService.findGroup(a.getPrincipal().getId()); } else {
if (type.isGroup()) { IEntityGroup member = GroupService.findGroup(child.getId()); group.addChild(member);
@Override 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); } // if the name hasn't been set yet, look up the entity name if (entity.getName() == null) { entity.setName(lookupEntityName(entity)); } if (EntityEnum.GROUP.equals(entity.getEntityType()) || EntityEnum.PERSON.equals(entity.getEntityType())) { IAuthorizationPrincipal principal = getPrincipalForEntity(entity); entity.setPrincipalString(principal.getPrincipalString()); } return entity; }
if (childType.isGroup()) { IEntityGroup member = GroupService.findGroup(child.getId()); group.addChild(member);