beautypg.com

Inserting a crawler access rule, Retrieving crawler access rules – Google Search Appliance Administrative API Developers Guide: Java User Manual

Page 13

background image

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

13

Crawler access rules instruct the crawler how to authenticate when crawling the protected content.

Inserting a Crawler Access Rule

Insert a new crawler access rule as follows:

// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();

// Add properties to insertEntry
insertEntry.addGsaContent("entryID", "#URL pattern for the new crawler access

rule");

insertEntry.addGsaContent("domain", "domainone");
insertEntry.addGsaContent("isPublic", "1");
insertEntry.addGsaContent("username", "username");
insertEntry.addGsaContent("password", "password");

// Send the request
myClient.insertEntry("crawlAccessNTLM", insertEntry);

Retrieving Crawler Access Rules

Retrieve a list of crawler access rules as follows:

// Send a request and print the response
GsaFeed myFeed = myClient.getFeed("crawlAccessNTLM");

for(GsaEntry myEntry : myFeed.getEntries()) {

System.out.println("URL Pattern: " + myEntry.getGsaContent("urlPattern"));
System.out.println("User Name: " + myEntry.getGsaContent("username"));
System.out.println("Order: " + myEntry.getGsaContent("order"));
System.out.println("Domain: " + myEntry.getGsaContent("domain"));
System.out.println("Is Public: " + myEntry.getGsaContent("isPublic"));

}

Property

Description

domain

Windows domain for NTLM, or empty for HTTP Basic authorization.

isPublic

Indicates whether to allow users to view results of both the public content
(normally available to everyone) and the secure (confidential) content. The
value can be 1 to enable users to view content as public, or 0 to require users to
authenticate to view secure content.

order

Indicates that the crawler access rules are sequential. The order indicates the
sequence. The order is an integer value starting from 1.

password

Password for authentication.

urlPattern

URL pattern that matches the protected files.

username

User name for authentication.