}
}
protected void performSearchMethod(String query) throws SAXException {
try {
DOMStreamer propertyStreamer = new DOMStreamer(this.xmlConsumer);
OptionsMethod optionsMethod = new OptionsMethod(this.targetUrl);
SearchMethod searchMethod = new SearchMethod(this.targetUrl, query);
HttpURL url = new HttpURL(this.targetUrl);
HttpState state = new HttpState();
state.setCredentials(null, new UsernamePasswordCredentials(
url.getUser(),
url.getPassword()));
HttpConnection conn = new HttpConnection(url.getHost(), url.getPort());
WebdavResource resource = new WebdavResource(new HttpURL(this.targetUrl));
if(!resource.exists()) {
throw new SAXException("The WebDAV resource don't exist");
}
optionsMethod.execute(state, conn);
if(!optionsMethod.isAllowed("SEARCH")) {
throw new SAXException("The server don't support the SEARCH method");
}
searchMethod.execute(state, conn);
Enumeration enumeration = searchMethod.getAllResponseURLs();
this.contentHandler.startElement(
DASL_QUERY_NS,
RESULT_ROOT_TAG,
PREFIX + ":" + RESULT_ROOT_TAG,
new AttributesImpl());
while (enumeration.hasMoreElements()) {
String path = (String) enumeration.nextElement();
Enumeration properties = searchMethod.getResponseProperties(path);
AttributesImpl attr = new AttributesImpl();
attr.addAttribute(DASL_QUERY_NS, PATH_NODE_NAME, PREFIX + ":" + PATH_NODE_NAME, "CDATA",path);
this.contentHandler.startElement(DASL_QUERY_NS,
RESOURCE_NODE_NAME,
PREFIX + ":" + RESOURCE_NODE_NAME,
attr);
while(properties.hasMoreElements()) {
BaseProperty metadata = (BaseProperty) properties.nextElement();
Element propertyElement = metadata.getElement();
propertyStreamer.stream(propertyElement);
}
this.contentHandler.endElement(DASL_QUERY_NS,
RESOURCE_NODE_NAME,
PREFIX + ":" + RESOURCE_NODE_NAME);