/** * get null safe field name from field * @param field * @return field name */ public static String fieldName(Field field) { return (field == null ? null : field.getName()); }
/** * 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 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); } }
/** * 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; }
/** * 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 WsInvalidQueryException("Field '" + field.getName() + "' cannot be nonnull if member filter is composite"); } return group.getCompositeMemberships(); }
if(("read".equals(priv) && canRead(s,field,g)) ||("write".equals(priv) && canWrite(s,field,g))) { fieldsMap.put(field.getName(),Boolean.TRUE);
public Object get(Object key) { Object obj = null; if (field != null || !"displayName".equals(key)) { obj = getByIntrospection(key); if(obj!=null) return obj; obj = super.get(key); //Map overrides wrapped Subject if(obj!=null && !"".equals(obj)) return obj; } //if (values != null && values.size() != 0) // obj = values.iterator().next(); String name = field != null ? field.getName() : legacyAttribute.getLegacyAttributeName(true); if ("displayName".equals(key)) { String displayName = null; try { displayName = GrouperUiFilter.retrieveSessionNavResourceBundle().getString("field.displayName." + name); }catch(Exception e) { displayName = name; } obj=displayName; } return obj; }
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"); }
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()));