if (element.getFirstChildNamed("href", element.getNamespace()) == null) //$NON-NLS-1$
throw new IOException(Messages.getString("MultiStatusResponse.unexpectedHref")); //$NON-NLS-1$
href = URLUTF8Encoder.decode(element.getFirstChildNamed("href", element.getNamespace()).getContent()); //$NON-NLS-1$
IXMLElement props = element.getFirstChildNamed("propstat", element.getNamespace()); //$NON-NLS-1$
if (props == null)
throw new IOException(Messages.getString("MultiStatusResponse.noPropertyElements")); //$NON-NLS-1$
if (props.getFirstChildNamed("status", element.getNamespace()) == null) //$NON-NLS-1$
throw new IOException(Messages.getString("MultiStatusResponse.unexpectedStatusResponse")); //$NON-NLS-1$
String status = props.getFirstChildNamed("status", element.getNamespace()).getContent(); //$NON-NLS-1$
StringTokenizer tokens = new StringTokenizer(status, " ", false); //$NON-NLS-1$
reason = ""; //$NON-NLS-1$
try {
version = tokens.nextToken();
this.status = Integer.parseInt(tokens.nextToken());
while (tokens.hasMoreTokens()) {
reason += tokens.nextToken() + " "; //$NON-NLS-1$
}
reason = URLDecoder.decode(reason.trim());
} catch (NoSuchElementException e) {
throw new IOException(Messages.getString("MultiStatusResponse.failedToReadHTTPResponseHeader")); //$NON-NLS-1$
} catch (NumberFormatException e) {
throw new IOException(Messages.getString("MultiStatusResponse.failedToReadHTTPResponseHeader")); //$NON-NLS-1$
}
// Create a new set of properties
properties = new Properties();
// Check the status, if its not found then return
if (this.status == 404)
return;
props = props.getFirstChildNamed("prop", props.getNamespace()); //$NON-NLS-1$
if (props == null)
throw new IOException(Messages.getString("MultiStatusResponse.noPropElementsInPropStat")); //$NON-NLS-1$
IXMLElement child;
for (Enumeration e = props.getChildren().elements(); e.hasMoreElements();) {
child = (IXMLElement) e.nextElement();
if (child.getName().equalsIgnoreCase("resourcetype")) { //$NON-NLS-1$
if (child.getChildrenNamed("collection") != null) //$NON-NLS-1$
collection = true;
} else {
properties.put(child.getName().toLowerCase(), child.getContent() == null ? "" : child.getContent()); //$NON-NLS-1$
}
}
}