private StatusLine parseStatusLine(String line) { if (TextUtils.isEmpty(line)) { return null; } return BasicLineParser.parseStatusLine(line, new BasicLineParser()); }
private StatusLine parseStatusLine(String line) { if (TextUtils.isEmpty(line)) { return null; } return BasicLineParser.parseStatusLine(line, new BasicLineParser()); }
/** * Retrieves the status code portion of the Response's <CODE>status</CODE> element. * If it is not present, returns {@link #DEFAULT_STATUS_CODE} (a.k.a. <CODE>200</CODE>). * * @param response The response complex type of the multistatus * @return DEFAULT_STATUS_CODE if not found in response; -1 if status line was malformed */ private int getStatusCode(Response response) { String status = response.getStatus(); if (status == null || status.isEmpty()) { return DEFAULT_STATUS_CODE; } try { return BasicLineParser.parseStatusLine(response.getStatus(), null).getStatusCode(); } catch (ParseException e) { log.warning(String.format("Failed to parse status line: %s", status)); return -1; } }
private static void fromXml(Element response, List<MultiStatus> result) throws IOException { Element href; String str; ChildElements iter; Element propstat; String propstatStatus; Element prop; int status; ChildElements propIter; Dom.require(response, Method.XML_RESPONSE, Method.DAV); href = Dom.getFirstChildElement(response, "href", Method.DAV); if (href == null) { throw new IOException("missing href"); } str = Dom.getString(href).trim(); iter = Method.DAV.childElements(response, XML_PROPSTAT); while (iter.hasNext()) { propstat = iter.next(); propstatStatus = Dom.getString(Dom.getFirstChildElement(propstat, XML_STATUS, Method.DAV)); prop = Dom.getFirstChildElement(propstat, Method.XML_PROP, Method.DAV); status = BasicLineParser.parseStatusLine(propstatStatus, BasicLineParser.DEFAULT).getStatusCode(); propIter = new ChildElements(prop); while (propIter.hasNext()) { result.add(new MultiStatus(str, Property.fromXml(propIter.next()), status)); } } }