Class SearchMethod
- java.lang.Object
-
- org.apache.commons.httpclient.HttpMethodBase
-
- org.apache.webdav.lib.methods.HttpRequestBodyMethodBase
-
- org.apache.webdav.lib.methods.XMLResponseMethodBase
-
- org.apache.webdav.lib.methods.SearchMethod
-
- All Implemented Interfaces:
org.apache.commons.httpclient.HttpMethod
public class SearchMethod extends XMLResponseMethodBase
This class implements the WebDAV SEARCH Method.The SEARCH method initiates a server-side search. The body of the request defines the query. The server responds with a text/xml entity matching the WebDAV PROPFIND response.
According to
the DASL draft a typical request looks like this: SEARCH /folder/ HTTP/1.1 Host: www.foo.bar Content-type: text/xml; charset="utf-8" Content-Length: xxxx <?xml version="1.0"?> <D:searchrequest xmlns:D = "DAV:" > <D:basicsearch> <D:select> <D:prop><D:getcontentlength/></D:prop> </D:select> <D:from> <D:scope> <D:href>/folder/</D:href> <D:depth>infinity</D:depth> </D:scope> </D:from> </D:basicsearch> </D:searchrequest>However, other query grammars may be used. A typical request using the
SQL-based grammar implemented in Microsoft's Web Storage System (currently shipping with Exchange 2000 and SharePoint Portal Server) looks like this: SEARCH /folder/ HTTP/1.1 Host: www.foo.bar Content-type: text/xml; charset="utf-8" Content-Length: xxxx <?xml version="1.0"?> <D:searchrequest xmlns:D = "DAV:" > <D:sql> SELECT "DAV:contentclass", "DAV:displayname" FROM "/folder/" WHERE "DAV:ishidden" = false AND "DAV:isfolder" = false </D:sql> </D:searchrequest>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.webdav.lib.methods.XMLResponseMethodBase
XMLResponseMethodBase.OptionsResponse, XMLResponseMethodBase.Response, XMLResponseMethodBase.ResponseWithinMultistatus, XMLResponseMethodBase.SingleResponse
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringprefixThe namespace abbreviation that prefixes DAV tags-
Fields inherited from class org.apache.webdav.lib.methods.XMLResponseMethodBase
builder, decodeResponseHrefs, responseURLs
-
-
Constructor Summary
Constructors Constructor Description SearchMethod()Method constructor.SearchMethod(java.lang.String path)Method constructor.SearchMethod(java.lang.String path, java.lang.String query)Construct a SearchMethod using the given XML request body.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRequestHeaders(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn)Generate additional headers needed by the request.protected java.lang.StringgenerateRequestBody()DAV requests that contain a body must override this function to generate that body.java.util.EnumerationgetAllResponseURLs()This method returns an enumeration of URL paths.java.lang.StringgetName()java.util.EnumerationgetResponseProperties(java.lang.String urlPath)Returns an enumeration ofPropertyobjects.voidparseResponse(java.io.InputStream input, org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn)Parse response.voidrecycle()Reset the State of the class to its initial state, so that it can be used again.-
Methods inherited from class org.apache.webdav.lib.methods.XMLResponseMethodBase
convertElementToProperty, getDebug, getRequestContentLength, getResponseDocument, getResponseHashtable, getResponses, getResponseURLs, parseXMLResponse, readResponseBody, setDebug, setDecodeResponseHrefs, setDocument, setResponseHashtable, writeRequestBody
-
Methods inherited from class org.apache.webdav.lib.methods.HttpRequestBodyMethodBase
isRequestContentAlreadySet, readContinueCode, setRequestBody, setRequestBody, setRequestBody, setRequestBody, setRequestBody
-
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLine
-
-
-
-
Constructor Detail
-
SearchMethod
public SearchMethod()
Method constructor.
-
SearchMethod
public SearchMethod(java.lang.String path)
Method constructor.
-
SearchMethod
public SearchMethod(java.lang.String path, java.lang.String query)Construct a SearchMethod using the given XML request body.- Parameters:
path- Relative path to the WebDAV resource (presumably a collection).query- Complete request body in XML including a search query in your favorite grammar.
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceorg.apache.commons.httpclient.HttpMethod- Specified by:
getNamein classorg.apache.commons.httpclient.HttpMethodBase
-
recycle
public void recycle()
Description copied from class:XMLResponseMethodBaseReset the State of the class to its initial state, so that it can be used again.- Specified by:
recyclein interfaceorg.apache.commons.httpclient.HttpMethod- Overrides:
recyclein classXMLResponseMethodBase
-
addRequestHeaders
public void addRequestHeaders(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws java.io.IOException, org.apache.commons.httpclient.HttpExceptionGenerate additional headers needed by the request.- Overrides:
addRequestHeadersin classorg.apache.commons.httpclient.HttpMethodBase- Parameters:
state- State tokenconn- the connection- Throws:
java.io.IOExceptionorg.apache.commons.httpclient.HttpException
-
generateRequestBody
protected java.lang.String generateRequestBody()
DAV requests that contain a body must override this function to generate that body.The default behavior simply returns an empty body.
- Overrides:
generateRequestBodyin classXMLResponseMethodBase
-
getAllResponseURLs
public java.util.Enumeration getAllResponseURLs()
This method returns an enumeration of URL paths. If the PropFindMethod was sent to the URL of a collection, then there will be multiple URLs. The URLs are picked out of the<D:href>elements of the response.- Returns:
- an enumeration of URL paths as Strings
-
getResponseProperties
public java.util.Enumeration getResponseProperties(java.lang.String urlPath)
Returns an enumeration ofPropertyobjects.
-
parseResponse
public void parseResponse(java.io.InputStream input, org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws java.io.IOException, org.apache.commons.httpclient.HttpExceptionParse response.- Overrides:
parseResponsein classXMLResponseMethodBase- Parameters:
input- Input stream- Throws:
java.io.IOExceptionorg.apache.commons.httpclient.HttpException
-
-