Include Page |
---|
spaceKey | Grouper |
---|
pageTitle | Navigation |
---|
|
Grouper rules
If a student is no longer a member of the course X group, then change the membership in the course wiki group to have an end date in one week. The optional (e.g. nightly) daemon will look for members of the wiki who aren't in the course group and set their end date.
Java example
Code Block |
---|
AttributeAssign attributeAssign = ruleGroup
.getAttributeDelegate().addAttribute(RuleUtils.ruleAttributeDefName()).getAttributeAssign();
AttributeValueDelegate attributeValueDelegate = attributeAssign.getAttributeValueDelegate();
attributeValueDelegate.assignValue(
RuleUtils.ruleActAsSubjectSourceIdName(), actAs.getSourceId());
attributeValueDelegate.assignValue(
RuleUtils.ruleActAsSubjectIdName(), actAs.getId());
//if the user falls out of mustBeInGroup, then set a disabled date in this group
attributeValueDelegate.assignValue(
RuleUtils.ruleCheckOwnerIdName(), mustBeInGroup.getId());
attributeValueDelegate.assignValue(
RuleUtils.ruleCheckTypeName(),
RuleCheckType.membershipRemove.name());
attributeValueDelegate.assignValue(
RuleUtils.ruleIfConditionEnumName(),
RuleIfConditionEnum.thisGroupHasImmediateEnabledNoEndDateMembership.name());
attributeValueDelegate.assignValue(
RuleUtils.ruleThenEnumName(), RuleThenEnum.assignMembershipDisabledDaysForOwnerGroupId.name());
//number of days in future that disabled date should be set
attributeValueDelegate.assignValue(
RuleUtils.ruleThenEnumArg0Name(), "7");
//if the membership in owner group doesnt exist, should it be added? T|F
attributeValueDelegate.assignValue(
RuleUtils.ruleThenEnumArg1Name(), "F");
//should be valid
String isValidString = attributeValueDelegate.retrieveValueString(
RuleUtils.ruleValidName());
if (!StringUtils.equals("T", isValidString)) {
throw new RuntimeException(isValidString);
}
|
GSH shorthand method
Code Block |
---|
RuleApi.groupIntersection(subjectActAs, groupA, groupB, 7);
|
GSH test case
Code Block |
---|
gsh 0% grouperSession = GrouperSession.startRootSession();
edu.internet2.middleware.grouper.GrouperSession: f234aa6876784ea0990ae1aba754d5a7,'GrouperSystem','application'
gsh 1% groupA = new GroupSave(grouperSession).assignName("stem:a").assignCreateParentStemsIfNotExist(true).save();
group: name='stem:a' displayName='stem:a' uuid='4354a7db631e42bf93ac08eb5288b2c9'
gsh 2% groupB = new GroupSave(grouperSession).assignName("stem:b").assignCreateParentStemsIfNotExist(true).save();
group: name='stem:b' displayName='stem:b' uuid='fa2fe9a442a44169875e82954386a332'
gsh 3% subjectActAs = SubjectFinder.findByIdAndSource("GrouperSystem", "g:isa", true);
subject: id='GrouperSystem' type='application' source='g:isa' name='GrouperSysAdmin'
gsh 4% RuleApi.groupIntersection(subjectActAs, groupA, groupB, 7);
gsh 5% addMember("stem:a", "test.subject.0");
true
gsh 6% addMember("stem:b", "test.subject.0");
true
gsh 7% delMember("stem:b", "test.subject.0");
true
gsh 8% hasMember("stem:a", "test.subject.0");
true
gsh 10% subject0 = SubjectFinder.findById("test.subject.0", true);
subject: id='test.subject.0' type='person' source='jdbc' name='my name is test.subject.0'
gsh 11% member0 = MemberFinder.findBySubject(grouperSession, subject0, false);
member: id='test.subject.0' type='person' source='jdbc' uuid='d20d4de2c7074da0a6a286f2b249d5ec'
gsh 12% membership = groupA.getImmediateMembership(Group.getDefaultList(), member0, true, true);
edu.internet2.middleware.grouper.Membership: Membership[createTime=1283754246504,creatorUuid=b0ad34466f1f401ba33c49cba4197cdb,depth=0,listName=members,listType=list,memberUuid=d20d4de2c7074da0a6a286f2b249d5ec,groupId=4354a7db631e42bf93ac08eb5288b2c9,type=immediate,uuid=4e107bdd371f49428ac65615fe43eab6:95f8d90414704e27bd558d41b03f9ba0]
gsh 13% membership.getDisabledTime()
java.sql.Timestamp: 2010-09-13 02:24:20.167
gsh 14%
|
GSH daemon test case
Run the above commands, and continue below
...