grouper-dev - RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned
Subject: Grouper Developers Forum
List archive
- From: Chris Hyzer <>
- To: David Langenberg <>
- Cc: John Gasper <>, "" <>
- Subject: RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned
- Date: Fri, 19 Sep 2014 11:32:17 +0000
- Accept-language: en-US
I added an option to GroupFinder to find by attribute or by attribute and value, I can add that to StemFinder too. Ok? https://github.com/Internet2/grouper/commit/be249b299ebfe47f1616f020a3fa98d41f1845d4 https://bugs.internet2.edu/jira/browse/GRP-1042 Here is the test case:
/** *
*/
public
void testFindByAttributeDefName() { GrouperSession grouperSession = GrouperSession.startRootSession();
AttributeDef attributeDef =
new AttributeDefSave(grouperSession).assignAttributeDefNameToEdit("test:attrDef") .assignAttributeDefType(AttributeDefType.attr).assignCreateParentStemsIfNotExist(true) .assignToGroup(true) .assignValueType(AttributeDefValueType.string).save();
AttributeDefName attributeDefName =
new AttributeDefNameSave(grouperSession, attributeDef) .assignAttributeDefNameNameToEdit("test:attrDefName").assignCreateParentStemsIfNotExist(true).save(); Group group0 =
new GroupSave(grouperSession).assignName("test:group0").assignCreateParentStemsIfNotExist(true).save(); Group group1 =
new GroupSave(grouperSession).assignName("test:group1").assignCreateParentStemsIfNotExist(true).save(); Group group2 =
new GroupSave(grouperSession).assignName("test:group2").assignCreateParentStemsIfNotExist(true).save(); Group group3 =
new GroupSave(grouperSession).assignName("test:group3").assignCreateParentStemsIfNotExist(true).save(); Group group4 =
new GroupSave(grouperSession).assignName("test:group4").assignCreateParentStemsIfNotExist(true).save(); group0.getAttributeValueDelegate().assignValue(attributeDefName.getName(),
"abc"); group1.getAttributeValueDelegate().assignValue(attributeDefName.getName(),
"xyz"); group3.getAttributeValueDelegate().assignValue(attributeDefName.getName(),
"abc"); group4.getAttributeValueDelegate().assignValue(attributeDefName.getName(),
"abc");
attributeDef.getPrivilegeDelegate().grantPriv(SubjectTestHelper.SUBJ0,
AttributeDefPrivilege.ATTR_READ,
false); attributeDef.getPrivilegeDelegate().grantPriv(SubjectTestHelper.SUBJ1,
AttributeDefPrivilege.ATTR_READ,
false);
group0.grantPriv(SubjectTestHelper.SUBJ0,
AccessPrivilege.GROUP_ATTR_READ); group1.grantPriv(SubjectTestHelper.SUBJ0,
AccessPrivilege.GROUP_ATTR_READ); group2.grantPriv(SubjectTestHelper.SUBJ0,
AccessPrivilege.GROUP_ATTR_READ); group3.grantPriv(SubjectTestHelper.SUBJ0,
AccessPrivilege.GROUP_ATTR_READ);
group0.grantPriv(SubjectTestHelper.SUBJ2,
AccessPrivilege.GROUP_ATTR_READ); group1.grantPriv(SubjectTestHelper.SUBJ2,
AccessPrivilege.GROUP_ATTR_READ); group2.grantPriv(SubjectTestHelper.SUBJ2,
AccessPrivilege.GROUP_ATTR_READ); group3.grantPriv(SubjectTestHelper.SUBJ2,
AccessPrivilege.GROUP_ATTR_READ); group4.grantPriv(SubjectTestHelper.SUBJ2,
AccessPrivilege.GROUP_ATTR_READ);
//subj0 can read most of both
//subj1 can read the attr
//subj2 can read the group attrs
GrouperSession.stopQuietly(grouperSession); grouperSession = GrouperSession.start(SubjectTestHelper.SUBJ0);
List<Group> groups =
new ArrayList<Group>(new
GroupFinder().assignNameOfAttributeDefName(attributeDefName.getName()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).findGroups());
assertEquals(3, GrouperUtil.length(groups));
assertEquals("test:group0", groups.get(0).getName());
assertEquals("test:group1", groups.get(1).getName());
assertEquals("test:group3", groups.get(2).getName());
groups =
new ArrayList<Group>(new
GroupFinder().assignNameOfAttributeDefName(attributeDefName.getName()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).assignAttributeValue("abc").findGroups());
assertEquals(2, GrouperUtil.length(groups));
assertEquals("test:group0", groups.get(0).getName());
assertEquals("test:group3", groups.get(1).getName());
GrouperSession.stopQuietly(grouperSession);
// #####################
grouperSession = GrouperSession.start(SubjectTestHelper.SUBJ1); groups =
new ArrayList<Group>(new
GroupFinder().assignNameOfAttributeDefName(attributeDefName.getName()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).findGroups());
assertEquals(0, GrouperUtil.length(groups));
groups =
new ArrayList<Group>(new
GroupFinder().assignNameOfAttributeDefName(attributeDefName.getName()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).assignAttributeValue("abc").findGroups());
assertEquals(0, GrouperUtil.length(groups));
GrouperSession.stopQuietly(grouperSession);
// #####################
grouperSession = GrouperSession.start(SubjectTestHelper.SUBJ2);
try { groups =
new ArrayList<Group>(new
GroupFinder().assignNameOfAttributeDefName(attributeDefName.getName()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).findGroups());
fail("Cant find attribute"); }
catch (Exception e) {
//good }
groups =
new ArrayList<Group>(new
GroupFinder().assignIdOfAttributeDefName(attributeDefName.getId()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).findGroups());
assertEquals(0, GrouperUtil.length(groups));
groups =
new ArrayList<Group>(new
GroupFinder().assignIdOfAttributeDefName(attributeDefName.getId()) .assignPrivileges(AccessPrivilege.ATTRIBUTE_READ_PRIVILEGES).assignAttributeValue("abc").findGroups());
assertEquals(0, GrouperUtil.length(groups));
GrouperSession.stopQuietly(grouperSession);
} From: David Langenberg [mailto:]
Yipes! Seems we need a simple AttributeFinder class that will just find the things an attribute is assigned to similiar to how we have SubjectFinder or GroupFinder. In our Grouper here @ Chicago we're particularly fond of the TypeFinder.
On Wed, Sep 17, 2014 at 11:57 PM, Chris Hyzer <> wrote: We probably need more straightforward ways to query this… anyways, e.g. for stems you can do this:
Set<AttributeAssign> attributeAssigns =
GrouperDAOFactory.getFactory()
.getAttributeAssign().findStemAttributeAssignments(null,
null, GrouperUtil.toSet(attributeDefName.getId()),
null, null,
true, false);
Let me know if you need more info or an example
J Thanks, Chris From:
[mailto:]
On Behalf Of John Gasper Hi all, ---
-- Identity & Access Management The University of Chicago |
- [grouper-dev] Locating Stems and Groups with an Attribute Assigned, John Gasper, 09/17/2014
- RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, Chris Hyzer, 09/18/2014
- Re: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, David Langenberg, 09/18/2014
- Re: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, John Gasper, 09/18/2014
- RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, Chris Hyzer, 09/19/2014
- RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, Chris Hyzer, 09/19/2014
- Re: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, David Langenberg, 09/18/2014
- RE: [grouper-dev] Locating Stems and Groups with an Attribute Assigned, Chris Hyzer, 09/18/2014
Archive powered by MHonArc 2.6.16.