com.google.enterprise.adaptor
Interface Response


public interface Response

Interface provided to Adaptor.getDocContent(Request, Response) for performing the actions needed to satisfy a request.

There are several ways that a request can be processed. In the simplest case an Adaptor always sets different pieces of metadata, calls getOutputStream(), and writes the document contents. If the document does not exist, it should call respondNotFound() instead.

For improved efficiency during recrawl by the GSA, an Adaptor should check Request.hasChangedSinceLastAccess(java.util.Date) and call respondNotModified() when it is true. This prevents the Adaptor from ever needing to retrieve the document contents and metadata.


Method Summary
 void addAnchor(URI uri, String text)
          Add a hyperlink for the GSA to follow without modifying the document contents.
 void addMetadata(String key, String value)
          Add metadata element that applies to the document.
 OutputStream getOutputStream()
          Get stream to write document contents to.
 void putNamedResource(String fragment, Acl acl)
          Provide alternative ACLs for this document, uniquely identified by response document's DocId and fragment.
 void respondNotFound()
          Respond to the GSA or other client that the request document does not exist.
 void respondNotModified()
          Respond to the GSA or other client that it already has the latest version of a file and its metadata.
 void setAcl(Acl acl)
          Provide the document's ACLs for early-binding security on the GSA.
 void setContentType(String contentType)
          Describe the content type of the document.
 void setCrawlOnce(boolean crawlOnce)
          Instruct the GSA to not recrawl the document after the initial retrieval.
 void setDisplayUrl(URI displayUrl)
          Set the URI to be displayed in search results.
 void setLastModified(Date lastModified)
          Provide the last modification time of the document.
 void setLock(boolean lock)
          Instruct the GSA to "lock" the document into its index.
 void setNoArchive(boolean noArchive)
          Whether the GSA should show the "Cached" link in search results for this document.
 void setNoFollow(boolean noFollow)
          Whether the GSA should follow the links within the document to find other documents.
 void setNoIndex(boolean noIndex)
          Whether the GSA should index the content for searching.
 void setSecure(boolean secure)
          Mark the document as secure, for use with late-binding security.
 

Method Detail

respondNotModified

void respondNotModified()
                        throws IOException
Respond to the GSA or other client that it already has the latest version of a file and its metadata. If you have called other methods on this object to provide various metadata, the effects of those methods will be ignored.

If called, this must be the last call to this interface. Once you call this method, for the rest of the processing, exceptions may no longer be communicated to clients cleanly.

Throws:
IOException

respondNotFound

void respondNotFound()
                     throws IOException
Respond to the GSA or other client that the request document does not exist. If you have called other methods on this object, the effects of those methods will be ignored.

If called, this must be the last call to this interface. Once you call this method, for the rest of the processing, exceptions may no longer be communicated to the clients cleanly.

Throws:
IOException

getOutputStream

OutputStream getOutputStream()
                             throws IOException
Get stream to write document contents to. There is no need to flush or close the OutputStream when done.

If called, this must be the last call to this interface (although, for convenience, you may call this method multiple times). Once you call this method, for the rest of the processing, exceptions may no longer be communicated to clients cleanly.

Throws:
IOException

setContentType

void setContentType(String contentType)
Describe the content type of the document.


setLastModified

void setLastModified(Date lastModified)
Provide the last modification time of the document.


addMetadata

void addMetadata(String key,
                 String value)
Add metadata element that applies to the document. Providing multiple values for the same key is supported; simply repeat the call once for each value.

Parameters:
key - the key of metadata element
value - the value of metadata element
Throws:
NullPointerException - if key or value is null

setAcl

void setAcl(Acl acl)
Provide the document's ACLs for early-binding security on the GSA. By default, the document's ACL will be null, which means the document is public if the document isn't marked as secure via setSecure(boolean).


putNamedResource

void putNamedResource(String fragment,
                      Acl acl)
Provide alternative ACLs for this document, uniquely identified by response document's DocId and fragment.


setSecure

void setSecure(boolean secure)
Mark the document as secure, for use with late-binding security. By default, the secure setting will be false, which means the document is public if there are no ACLs. ACLs should be used, if possible, instead of setting this option to true. When true, the GSA needs to be correctly configured to issue a SAML request to the Adaptor. Setting ACLs to non-null will override setSecure and send secure indicator to GSA.


addAnchor

void addAnchor(URI uri,
               String text)
Add a hyperlink for the GSA to follow without modifying the document contents. This is equivalent to the following HTML: <a href='$uri'>$text</a>. If you want to link to a DocId, then you may use the DocIdEncoder provided by AdaptorContext.getDocIdEncoder() to produce an appropriate URI.

Parameters:
uri - the URI of the anchor
text - the text of the anchor, or null
Throws:
NullPointerException - if uri is null

setNoIndex

void setNoIndex(boolean noIndex)
Whether the GSA should index the content for searching. When true, the document will not be visible in search results. This does not change the GSA's behavior of following links within the document to find other documents. By default, the GSA will index the document (a value of false).

Parameters:
noIndex - true when the GSA shouldn't index this document

setNoFollow

void setNoFollow(boolean noFollow)
Whether the GSA should follow the links within the document to find other documents. By default, the GSA will follow links (a value of false).

Parameters:
noFollow - true when the GSA shouldn't follow links from this document to find other documents

setNoArchive

void setNoArchive(boolean noArchive)
Whether the GSA should show the "Cached" link in search results for this document. By default, the GSA will show the "Cached" link (a value of false).

Parameters:
noArchive - true when the GSA shouldn't show the "Cached" link in search results

setDisplayUrl

void setDisplayUrl(URI displayUrl)
Set the URI to be displayed in search results. If null, then the crawl URI representing the DocId is used. The default is null.

Parameters:
displayUrl - URI to be used for this document in search results

setCrawlOnce

void setCrawlOnce(boolean crawlOnce)
Instruct the GSA to not recrawl the document after the initial retrieval. The default is false.

Parameters:
crawlOnce - if true, the document does not need to be recrawled periodically

setLock

void setLock(boolean lock)
Instruct the GSA to "lock" the document into its index. When the license limit is reached on the GSA, it deletes unlocked documents before locked documents while making room for new documents. The default is false.

Parameters:
lock - if true, keep this document in the index in preference to unlocked documents