use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class ApiGroupsService method getGroupsForMember.
// Internal search, thus case sensitive.
@Override
public Set<Entity> getGroupsForMember(String memberName) {
Set<Entity> groups = new HashSet<Entity>();
if (StringUtils.isNotEmpty(memberName)) {
EntityIdentifier[] identifiers = GroupService.searchForEntities(memberName, GroupService.SearchMethod.DISCRETE, EntityEnum.PERSON.getClazz());
for (EntityIdentifier entityIdentifier : identifiers) {
if (entityIdentifier.getType().equals(EntityEnum.PERSON.getClazz())) {
IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
if (memberName.equalsIgnoreCase(groupMember.getKey())) {
Iterator it = GroupService.findParentGroups(groupMember);
while (it.hasNext()) {
IEntityGroup g = (IEntityGroup) it.next();
Entity e = EntityFactory.createEntity(g, EntityEnum.getEntityEnum(g.getLeafType(), true));
groups.add(e);
}
return groups;
}
}
}
}
return groups;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class ApiGroupsService method getMembersForGroup.
@Override
public Set<Entity> getMembersForGroup(String groupName) {
Set<Entity> members = new HashSet<Entity>();
if (StringUtils.isNotEmpty(groupName)) {
EntityIdentifier[] identifiers = GroupService.searchForGroups(groupName, GroupService.SearchMethod.DISCRETE, EntityEnum.GROUP.getClazz());
for (EntityIdentifier entityIdentifier : identifiers) {
if (entityIdentifier.getType().equals(IEntityGroup.class)) {
IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
if (groupMember.getLeafType().equals(IPerson.class)) {
String groupMemberName = EntityService.instance().lookupEntityName(EntityEnum.GROUP, groupMember.getKey());
if (groupName.equalsIgnoreCase(groupMemberName)) {
for (IGroupMember gm : groupMember.asGroup().getDescendants()) {
if (!gm.isGroup()) {
EntityIdentifier ident = gm.getUnderlyingEntityIdentifier();
Entity member = findMember(ident.getKey(), true);
members.add(member);
}
}
return members;
}
}
}
}
}
return members;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class EntityService method search.
// External search, thus case insensitive.
public Set<Entity> search(String entityType, String searchTerm) {
if (StringUtils.isBlank(entityType) && StringUtils.isBlank(searchTerm)) {
return null;
}
Set<Entity> results = new HashSet<Entity>();
EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
EntityIdentifier[] identifiers;
Class<?> identifierType;
// to locate it
if (entityEnum.isGroup()) {
identifiers = GroupService.searchForGroups(searchTerm, GroupService.SearchMethod.CONTAINS_CI, entityEnum.getClazz());
identifierType = IEntityGroup.class;
} else // otherwise use the getGroupMember method
{
identifiers = GroupService.searchForEntities(searchTerm, GroupService.SearchMethod.CONTAINS_CI, entityEnum.getClazz());
identifierType = entityEnum.getClazz();
}
for (EntityIdentifier entityIdentifier : identifiers) {
if (entityIdentifier.getType().equals(identifierType)) {
IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
Entity entity = getEntity(groupMember);
results.add(entity);
}
}
return results;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class ChannelListController method preparePortletCategoryBean.
private PortletCategoryBean preparePortletCategoryBean(WebRequest req, PortletCategory category, Set<IPortletDefinition> portletsNotYetCategorized, IPerson user, Locale locale) {
/* Prepare child categories. */
Set<PortletCategoryBean> subcategories = new HashSet<>();
for (PortletCategory childCategory : this.portletCategoryRegistry.getChildCategories(category)) {
PortletCategoryBean childBean = preparePortletCategoryBean(req, childCategory, portletsNotYetCategorized, user, locale);
subcategories.add(childBean);
}
// add the direct child channels for this category
Set<IPortletDefinition> portlets = portletCategoryRegistry.getChildPortlets(category);
EntityIdentifier ei = user.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
for (IPortletDefinition portlet : portlets) {
if (authorizationService.canPrincipalBrowse(ap, portlet)) {
PortletDefinitionBean pdb = preparePortletDefinitionBean(req, portlet, locale);
marketplacePortlets.add(pdb);
}
/*
* Remove the portlet from the uncategorized collection;
* note -- this approach will not prevent portlets from
* appearing in multiple categories (as appropriate).
*/
portletsNotYetCategorized.remove(portlet);
}
// construct a new portlet category bean for this category
PortletCategoryBean categoryBean = PortletCategoryBean.fromPortletCategory(category, subcategories, marketplacePortlets);
categoryBean.setName(messageSource.getMessage(category.getName(), new Object[] {}, locale));
return categoryBean;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class PermissionAdministrationHelper method canEditOwner.
public boolean canEditOwner(IPerson currentUser, String owner) {
EntityIdentifier ei = currentUser.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
return (ap.hasPermission(IPermission.PORTAL_PERMISSIONS, IPermission.EDIT_PERMISSIONS_ACTIVITY, IPermission.ALL_TARGET));
}
Aggregations