/** * get null safe field name from field * @param field * @return field name */ public static String fieldName(Field field) { return (field == null ? null : field.getName()); }
public static boolean hasOtherReadableFields(Group g, String fieldName) { Field f = null; try { f=FieldFinder.find(fieldName); }catch(SchemaException e) { throw new RuntimeException(e); } Set<GroupType> types=g.getTypes(); int count=0; for(GroupType type : types) { Set<Field> fields = type.getFields(); for(Field field : fields) { try { if(!field.equals(f) && field.isGroupListField() && g.canReadField(field)) { count++; } }catch(SchemaException e) { LOG.error(e); } } } return count > 0 || !f.getName().equals("members"); }
if (!StringUtils.isBlank(fieldName)) { field = GrouperServiceUtils.retrieveField(fieldName); theSummary += ", field: " + field.getName(); groups = memberFilter.getGroups(member, field, scope, stem, stemDotScope, queryOptions, enabledBoolean); } else { pitGroups = PITMember.getGroups(member.getUuid(), field.getUuid(), scope, stem, stemDotScope, pointInTimeFrom, pointInTimeTo, queryOptions);
byHqlStatic.setString("fieldId", Group.getDefaultList().getUuid()); byHqlStatic.setString("ownerId", group.getUuid()); byHqlStatic.setCollectionInClause(query, subjectIds);
/** * Construct a representation of an {@link Privilege} attribute. * * @see edu.internet2.middleware.grouper.shibboleth.dataConnector.field.BaseField#constructor(String id) * * @param id * the identifier * @param accessResolver * the access resolver * @throws GrouperException * */ public PrivilegeField(String id, AccessResolver accessResolver) throws GrouperException { super(id); this.accessResolver = accessResolver; try { Field field = FieldFinder.find(id, true); if (!field.getType().equals(FieldType.ACCESS)) { throw new GrouperException("Field '" + id + "' is not an access privilege"); } privilege = AccessPrivilege.listToPriv(id); if (privilege == null) { throw new GrouperException("Unknown access privilege '" + id + "'"); } } catch (SchemaException e) { throw new GrouperException("Unknown field '" + id + "'", e); } }
/** * see if a subject is in a group * * @param group * @param subject * @param field * @return the set of members (non null) * @throws SchemaException */ public final boolean hasMember(Group group, Subject subject, Field field) { try { return this.hasMemberHelper(group, subject, field); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName(), se); } }
tName = getResource(mediaResources, "field." + field.getName() + ".view." + view); if (tName == null) { tName = getResource(mediaResources, "field." + field.getName() + ".view.default"); tName = getResource(mediaResources, "field." + field.getType() + ".view." + view); tName = getResource(mediaResources, "field." + field.getType() + ".view.default");
/** * get the members from the group based on type of filter * * @param group * @param field * for membership or null to not check field * @return the set of members (non null) */ public final Set<Member> getMembers(Group group, Field field) { try { return this.getMembersHelper(group, field); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName(), se); } }
this.setCreateTime(GrouperServiceUtils.dateToString(membership.getCreateTime())); Field listField = membership.getList(); FieldType listFieldType = listField == null ? null : listField.getType(); this.setListType(listFieldType == null ? null : listFieldType.toString()); this.setListName(listField == null ? null : listField.getName()); if (membership.isImmediate()) { this.setDisabledTime(GrouperServiceUtils.dateToString(membership.getDisabledTime()));
/** * get the composite memberships from the group * * @param group * @param field * for membership or null to not check field * @return the set of members (non null) */ @Override @SuppressWarnings("unchecked") protected Set<Membership> getMembershipsHelper(Group group, Field field) { if (field != null) { throw new RuntimeException("Field '" + field.getName() + "' cannot be nonnull if member filter is composite"); } return group.getCompositeMemberships(); }
/** * get the memberships from the group based on type of filter * * @param group * @param field for membership or null to not check field * @return the set of members (non null) * @throws SchemaException is there is a problem with field */ public final Set<Membership> getMemberships(Group group, Field field) { try { return this.getMembershipsHelper(group, field); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName(), se); } }
/** * see if a subject is in a group * * @param group * @param subject * @param field * @return the set of members (non null) * @throws SchemaException */ public final boolean hasMember(Group group, Subject subject, Field field) { try { return this.hasMemberHelper(group, subject, field); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName(), se); } }
/** * get the memberships from the group based on type of filter * * @param group * @param field * for membership or null to not check field * @return the set of members (non null) * @throws SchemaException * is there is a problem with field */ public final Set<Membership> getMemberships(Group group, Field field) { try { return this.getMembershipsHelper(group, field); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName(), se); } }
/** * see if a group has a subject as member * * @param group * @return true|false */ @Override @SuppressWarnings("unchecked") protected boolean hasMemberHelper(Group group, Subject subject, Field field) { throw new RuntimeException("hasMember with composite is not supported: groupName: " + group.getName() + ", subject: " + subject.getName() + ", field: " + field.getName()); }
/** * see if a group has a subject as member * * @param group * @return true|false */ @Override @SuppressWarnings("unchecked") protected boolean hasMemberHelper(Group group, Subject subject, Field field) { throw new RuntimeException("hasMember with composite is not supported: groupName: " + group.getName() + ", subject: " + subject.getName() + ", field: " + field.getName()); }
/** * get the members from the group based on type of filter * * @param group * @param field for membership or null to not check field * @param sources are the sources to filter the members * @param queryOptions * @return the set of members (non null) */ public final Set<Member> getMembers(Group group, Field field, Set<Source> sources, QueryOptions queryOptions) { try { return this.getMembersHelper(group, field, sources, queryOptions); } catch (SchemaException se) { throw new RuntimeException("Problem with group and field: " + group + ", field: " + field.getName() + ", " + GrouperUtil.toString(sources), se); } }
/** * For a given subject determine all the custom list fields they appear in * @param s * @param subject * @return List of field names the subject is a member of * @throws Exception */ public static List getListFieldsForSubject(GrouperSession s,Subject subject) throws Exception{ Set lists = FieldFinder.findAllByType(FieldType.LIST); List res = new ArrayList(); Iterator it = lists.iterator(); Field field; Set memberships; while(it.hasNext()) { field = (Field)it.next(); if(!"members".equals(field.getName())) { memberships = MemberFinder.findBySubject(s,subject).getMemberships(field); if(memberships.size()>0) { res.add(field.getName()); } } } accumulateFields(res); return res; }