beautypg.com

Retrieving a search report, Updating a search report, Deleting a search report – Google Search Appliance Administrative API Developers Guide: Java User Manual

Page 44

background image

Google Search Appliance: Administrative API Developer’s Guide: Java

44

The following example generates and returns a new search report entry:

GsaEntry insertEntry = new GsaEntry();
insertEntry.addGsaContent("reportName", "bbb");
insertEntry.addGsaContent("collectionName", "default_collection");
insertEntry.addGsaContent("reportDate", "month_5_2009");
insertEntry.addGsaContent("withResults", "true");
insertEntry.addGsaContent("topCount", "100");
myClient.insertEntry("searchReport", insertEntry);

Retrieving a Search Report

Retrieve the search report status and get search log content by sending an authenticated GET request to
a search report entry of the searchReport feed.

A search report entry with log content (if content is ready) is returned:

GsaEntry entry = myClient.getEntry("searchReport", "bbb@default_collection");
System.out.println("Entry Name: " + entry.getGsaContent("entryID"));
System.out.println("Report State: " + entry.getGsaContent("reportState"));
System.out.println("Report Creation Date: " +

entry.getGsaContent("reportCreationDate"));

System.out.println("Report Date: " + entry.getGsaContent("reportDate"));
System.out.println("Is Final: " + entry.getGsaContent("isFinal"));
System.out.println("With Results: " + entry.getGsaContent("withResults"));
System.out.println("Top Count: " + entry.getGsaContent("topCount"));
System.out.println("Diagnostic Terms: " +

entry.getGsaContent("diagnosticTerms"));

status = entry.getGsaContent("reportState");
if (status.equals("2") || status.equals("3")) {

System.out.println("Report Content: " + entry.getGsaContent("reportContent"));

}

Updating a Search Report

Update the search report status and get search report content by sending an authenticated PUT request
to a search report entry of the searchReport feed. There are no properties.

A search log entry is returned:

GsaEntry updateEntry = new GsaEntry();
myClient.updateEntry("searchReport","bbb@default_collection");

Deleting a Search Report

Delete a search report by sending an authenticated DELETE request to a search report entry of the
searchReport feed.

The search report entry will be deleted:

myClient.deleteEntry("searchReport", "bbb@default_collection");