beautypg.com

Retrieving group members, Removing a member from a group – Google Search Appliance Policy ACL API Developers Guide User Manual

Page 11

background image

Google Search Appliance: Policy ACL API Developer’s Guide

Policy ACL API Developer’s Guide

11

In release 7.0, to add users with the extra attributes of Domain, NameSpace, and Case Sensitivity:

GsaEntry memberEntry = new GsaEntry();
memberEntry.addProperty("memberId", "john");
memberEntry.addProperty("memberType", "user");
memberEntry.addProperty(“memberNamespaceId”, “Default”);
memberEntry.addProperty(“memberDomainId”, “My_domain”);
memberEntry.addProperty(“memberCaseType”, “everything-case-sensitive”);
// Adds member user "john" to group "testGroup"
service.insert(new URL("http://Search_Appliance:8000/a/feeds/group/2.0/domain/" +
"testGroup" + "/member"), memberEntry);

Retrieving Group Members

To retrieve all members of a group:

GsaFeed memberFeed = service.getFeed(new URL("http://Search_Appliance:8000/a
/feeds/group/2.0/domain/" + "testGroup" + "/member"), GsaFeed.class);
for(GsaEntry memberEntry : memberFeed.getEntries()) {

System.out.println("Member Name: " + memberEntry.getProperty("memberId"));
System.out.println("Member Type: " + memberEntry.getProperty("memberType"));

}

If the number of members in a group is more than 500, the result is represented in multiple pages—you
can access the next page as follows:

if (memberFeed.getLink(Link.Rel.NEXT, Link.Type.ATOM) != null) {

memberFeed = service.getFeed(new URL(memberFeed.getLink(Link.Rel.NEXT,

Link.Type.ATOM).getHref()), GsaFeed.class);
}

To retrieve a single member of a group:

memberEntry = service.getEntry(new URL("http://Search_Appliance:8000/a/feeds
/group/2.0/domain/testGroup/member/" + "john"), GsaEntry.class);
System.out.println("Member Name: " + memberEntry.getProperty("memberId"));
System.out.println("Member Type: " + memberEntry.getProperty("memberType"));

To retrieve a single member of a group fully specifying the new fields in release 7.0:

memberEntry = service.getEntry(new URL("http://Search_Appliance:8000/a/feeds
/group/2.0/domain/testGroup/namespace/Default/domain/My_domain/caseType
/everthing-case-sensitive/member/" + "john" + “/memberNamespace/Default
/memberDomain/Default/memberCaseType/everthing-case-sensitive), GsaEntry.class);
System.out.println("Member Name: " + memberEntry.getProperty("memberId"));
System.out.println("Member Protocol Buffer: " +
memberEntry.getProperty("memberProto"));

Removing a Member From a Group

To remove a member from a group:

service.delete(new URL("http://Search_Appliance:8000/a/feeds/group/2.0/domain
/testGroup" + "/member/" + "john"));