@Override public CopyObjectResult parse(Response response) throws IOException { try { CopyObjectResult result = parseCopyObjectResponseXML(response.body().byteStream()); result.setRequestId(response.header(OSSHeaders.OSS_HEADER_REQUEST_ID)); result.setStatusCode(response.code()); result.setResponseHeader(parseResponseHeader(response)); return result; } catch (Exception e) { e.printStackTrace(); throw new IOException(e.getMessage(), e); } finally { safeCloseResponse(response); } }
private static CopyObjectResult parseCopyObjectResponseXML(InputStream in) throws ParseException, ParserConfigurationException, IOException, SAXException { CopyObjectResult result = new CopyObjectResult(); DocumentBuilder builder = domFactory.newDocumentBuilder(); Document dom = builder.parse(in); Element element = dom.getDocumentElement(); OSSLog.logD("[item] - " + element.getNodeName()); NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node item = list.item(i); String name = item.getNodeName(); if (name == null) { continue; } else if (name.equals("LastModified")) { result.setLastModified(DateUtil.parseIso8601Date(checkChildNotNullAndGetValue(item))); } else if (name.equals("ETag")) { result.setEtag(checkChildNotNullAndGetValue(item)); } } return result; }