Retrieving groups, Deleting members of a group, Adding a member to a group – Google Search Appliance Policy ACL API Developers Guide User Manual

Page 10

Advertising
background image

Google Search Appliance: Policy ACL API Developer’s Guide

Policy ACL API Developer’s Guide

10

Retrieving Groups

To retrieve all groups:

GsaFeed groupFeed = service.getFeed(new URL("http://Search_Appliance:8000/a/
feeds/group/2.0/domain/"),

GsaFeed.class);

for(GsaEntry groupEntry : groupFeed.getEntries()) {

System.out.println("Group Name: " + groupEntry.getProperty("groupName"));

}

If the number of groups in the search appliance is more than 500, the result is represented on multiple
pages—you can access the next page as follows:

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

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

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

}

To retrieve a single group:

GsaEntry groupEntry = service.getEntry(new URL("http://Search_Appliance:8000/a/
feeds/group/2.0/domain/testGroup"),

GsaEntry.class);

System.out.println("Group Name: " + groupEntry.getProperty("groupName"));

With search appliance software release 7.0, groups now can have several additional attributes: Domain,
Namespace, and Case Sensitivity. Here is an example in retrieving those fields.

GsaEntry groupEntry = service.getEntry(new URL("http://Search_Appliance:8000/a
/feeds/group/2.0/domain/testGroup/namespace/Default/domain/My_domain/caseType
/everything-case-sensitive"),
GsaEntry.class);
System.out.println("Group Name: " + groupEntry.getProperty("groupName"));
System.out.println("Group Protocol Buffer: " +
groupEntry.getGsaContent("groupProto"));

Deleting Members of a Group

To delete members of a group, use the following DELETE request:

DELETE http://Search_Appliance:8000/a/feeds/group/2.0/domain/groupId

Take note that this request only deletes members of a group, it does not delete the empty group.

Adding a Member to a Group

To add a new member to a group:

GsaEntry memberEntry = new GsaEntry();
memberEntry.addProperty("memberId", "john");
memberEntry.addProperty("memberType", "user");
// Adds member user "john" to group "testGroup"
service.insert(new URL("http://Search_Appliance:8000/a/feeds/group/2.0/domain/" +

"testGroup" + "/member"), memberEntry);

Advertising