private static CompleteMultipartUploadResult parseCompleteMultipartUploadResponseXML(
      InputStream in) throws ParserConfigurationException, IOException, SAXException {
    CompleteMultipartUploadResult result = new CompleteMultipartUploadResult();
    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.equalsIgnoreCase("Location")) {
        result.setLocation(checkChildNotNullAndGetValue(item));
      } else if (name.equalsIgnoreCase("Bucket")) {
        result.setBucketName(checkChildNotNullAndGetValue(item));
      } else if (name.equalsIgnoreCase("Key")) {
        result.setObjectKey(checkChildNotNullAndGetValue(item));
      } else if (name.equalsIgnoreCase("ETag")) {
        result.setETag(checkChildNotNullAndGetValue(item));
      }
    }

    return result;
  }
 @Override
 public CompleteMultipartUploadResult parse(Response response) throws IOException {
   try {
     CompleteMultipartUploadResult result = new CompleteMultipartUploadResult();
     if (response.header(OSSHeaders.CONTENT_TYPE).equals("application/xml")) {
       result = parseCompleteMultipartUploadResponseXML(response.body().byteStream());
     } else if (response.body() != null) {
       result.setServerCallbackReturnBody(response.body().string());
     }
     result.setRequestId(response.header(OSSHeaders.OSS_HEADER_REQUEST_ID));
     result.setStatusCode(response.code());
     result.setResponseHeader(parseResponseHeader(response));
     return result;
   } catch (Exception e) {
     throw new IOException(e.getMessage(), e);
   } finally {
     safeCloseResponse(response);
   }
 }
Пример #3
0
 public PauseableUploadResult(CompleteMultipartUploadResult completeResult) {
   this.setBucketName(completeResult.getBucketName());
   this.setObjectKey(completeResult.getObjectKey());
   this.setETag(completeResult.getETag());
   this.setLocation(completeResult.getLocation());
   this.setRequestId(completeResult.getRequestId());
   this.setResponseHeader(completeResult.getResponseHeader());
   this.setStatusCode(completeResult.getStatusCode());
 }