1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3*
4* Licensed under the Apache License, Version 2.0 (the "License").
5* You may not use this file except in compliance with the License.
6* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/ListMultipartUploadsResult.h>
17#include <aws/core/utils/xml/XmlSerializer.h>
18#include <aws/core/AmazonWebServiceResult.h>
19#include <aws/core/utils/StringUtils.h>
20
21#include <utility>
22
23using namespace Aws::S3::Model;
24using namespace Aws::Utils::Xml;
25using namespace Aws::Utils;
26using namespace Aws;
27
28ListMultipartUploadsResult::ListMultipartUploadsResult() :
29 m_maxUploads(0),
30 m_isTruncated(false),
31 m_encodingType(EncodingType::NOT_SET)
32{
33}
34
35ListMultipartUploadsResult::ListMultipartUploadsResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) :
36 m_maxUploads(0),
37 m_isTruncated(false),
38 m_encodingType(EncodingType::NOT_SET)
39{
40 *this = result;
41}
42
43ListMultipartUploadsResult& ListMultipartUploadsResult::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result)
44{
45 const XmlDocument& xmlDocument = result.GetPayload();
46 XmlNode resultNode = xmlDocument.GetRootElement();
47
48 if(!resultNode.IsNull())
49 {
50 XmlNode bucketNode = resultNode.FirstChild("Bucket");
51 if(!bucketNode.IsNull())
52 {
53 m_bucket = Aws::Utils::Xml::DecodeEscapedXmlText(bucketNode.GetText());
54 }
55 XmlNode keyMarkerNode = resultNode.FirstChild("KeyMarker");
56 if(!keyMarkerNode.IsNull())
57 {
58 m_keyMarker = Aws::Utils::Xml::DecodeEscapedXmlText(keyMarkerNode.GetText());
59 }
60 XmlNode uploadIdMarkerNode = resultNode.FirstChild("UploadIdMarker");
61 if(!uploadIdMarkerNode.IsNull())
62 {
63 m_uploadIdMarker = Aws::Utils::Xml::DecodeEscapedXmlText(uploadIdMarkerNode.GetText());
64 }
65 XmlNode nextKeyMarkerNode = resultNode.FirstChild("NextKeyMarker");
66 if(!nextKeyMarkerNode.IsNull())
67 {
68 m_nextKeyMarker = Aws::Utils::Xml::DecodeEscapedXmlText(nextKeyMarkerNode.GetText());
69 }
70 XmlNode prefixNode = resultNode.FirstChild("Prefix");
71 if(!prefixNode.IsNull())
72 {
73 m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText());
74 }
75 XmlNode delimiterNode = resultNode.FirstChild("Delimiter");
76 if(!delimiterNode.IsNull())
77 {
78 m_delimiter = Aws::Utils::Xml::DecodeEscapedXmlText(delimiterNode.GetText());
79 }
80 XmlNode nextUploadIdMarkerNode = resultNode.FirstChild("NextUploadIdMarker");
81 if(!nextUploadIdMarkerNode.IsNull())
82 {
83 m_nextUploadIdMarker = Aws::Utils::Xml::DecodeEscapedXmlText(nextUploadIdMarkerNode.GetText());
84 }
85 XmlNode maxUploadsNode = resultNode.FirstChild("MaxUploads");
86 if(!maxUploadsNode.IsNull())
87 {
88 m_maxUploads = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxUploadsNode.GetText()).c_str()).c_str());
89 }
90 XmlNode isTruncatedNode = resultNode.FirstChild("IsTruncated");
91 if(!isTruncatedNode.IsNull())
92 {
93 m_isTruncated = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(isTruncatedNode.GetText()).c_str()).c_str());
94 }
95 XmlNode uploadsNode = resultNode.FirstChild("Upload");
96 if(!uploadsNode.IsNull())
97 {
98 XmlNode uploadMember = uploadsNode;
99 while(!uploadMember.IsNull())
100 {
101 m_uploads.push_back(uploadMember);
102 uploadMember = uploadMember.NextNode("Upload");
103 }
104
105 }
106 XmlNode commonPrefixesNode = resultNode.FirstChild("CommonPrefixes");
107 if(!commonPrefixesNode.IsNull())
108 {
109 XmlNode commonPrefixesMember = commonPrefixesNode;
110 while(!commonPrefixesMember.IsNull())
111 {
112 m_commonPrefixes.push_back(commonPrefixesMember);
113 commonPrefixesMember = commonPrefixesMember.NextNode("CommonPrefixes");
114 }
115
116 }
117 XmlNode encodingTypeNode = resultNode.FirstChild("EncodingType");
118 if(!encodingTypeNode.IsNull())
119 {
120 m_encodingType = EncodingTypeMapper::GetEncodingTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encodingTypeNode.GetText()).c_str()).c_str());
121 }
122 }
123
124 return *this;
125}
126