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/ListObjectVersionsResult.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
28ListObjectVersionsResult::ListObjectVersionsResult() :
29 m_isTruncated(false),
30 m_maxKeys(0),
31 m_encodingType(EncodingType::NOT_SET)
32{
33}
34
35ListObjectVersionsResult::ListObjectVersionsResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) :
36 m_isTruncated(false),
37 m_maxKeys(0),
38 m_encodingType(EncodingType::NOT_SET)
39{
40 *this = result;
41}
42
43ListObjectVersionsResult& ListObjectVersionsResult::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 isTruncatedNode = resultNode.FirstChild("IsTruncated");
51 if(!isTruncatedNode.IsNull())
52 {
53 m_isTruncated = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(isTruncatedNode.GetText()).c_str()).c_str());
54 }
55 XmlNode keyMarkerNode = resultNode.FirstChild("KeyMarker");
56 if(!keyMarkerNode.IsNull())
57 {
58 m_keyMarker = Aws::Utils::Xml::DecodeEscapedXmlText(keyMarkerNode.GetText());
59 }
60 XmlNode versionIdMarkerNode = resultNode.FirstChild("VersionIdMarker");
61 if(!versionIdMarkerNode.IsNull())
62 {
63 m_versionIdMarker = Aws::Utils::Xml::DecodeEscapedXmlText(versionIdMarkerNode.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 nextVersionIdMarkerNode = resultNode.FirstChild("NextVersionIdMarker");
71 if(!nextVersionIdMarkerNode.IsNull())
72 {
73 m_nextVersionIdMarker = Aws::Utils::Xml::DecodeEscapedXmlText(nextVersionIdMarkerNode.GetText());
74 }
75 XmlNode versionsNode = resultNode.FirstChild("Version");
76 if(!versionsNode.IsNull())
77 {
78 XmlNode versionMember = versionsNode;
79 while(!versionMember.IsNull())
80 {
81 m_versions.push_back(versionMember);
82 versionMember = versionMember.NextNode("Version");
83 }
84
85 }
86 XmlNode deleteMarkersNode = resultNode.FirstChild("DeleteMarker");
87 if(!deleteMarkersNode.IsNull())
88 {
89 XmlNode deleteMarkerMember = deleteMarkersNode;
90 while(!deleteMarkerMember.IsNull())
91 {
92 m_deleteMarkers.push_back(deleteMarkerMember);
93 deleteMarkerMember = deleteMarkerMember.NextNode("DeleteMarker");
94 }
95
96 }
97 XmlNode nameNode = resultNode.FirstChild("Name");
98 if(!nameNode.IsNull())
99 {
100 m_name = Aws::Utils::Xml::DecodeEscapedXmlText(nameNode.GetText());
101 }
102 XmlNode prefixNode = resultNode.FirstChild("Prefix");
103 if(!prefixNode.IsNull())
104 {
105 m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText());
106 }
107 XmlNode delimiterNode = resultNode.FirstChild("Delimiter");
108 if(!delimiterNode.IsNull())
109 {
110 m_delimiter = Aws::Utils::Xml::DecodeEscapedXmlText(delimiterNode.GetText());
111 }
112 XmlNode maxKeysNode = resultNode.FirstChild("MaxKeys");
113 if(!maxKeysNode.IsNull())
114 {
115 m_maxKeys = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxKeysNode.GetText()).c_str()).c_str());
116 }
117 XmlNode commonPrefixesNode = resultNode.FirstChild("CommonPrefixes");
118 if(!commonPrefixesNode.IsNull())
119 {
120 XmlNode commonPrefixesMember = commonPrefixesNode;
121 while(!commonPrefixesMember.IsNull())
122 {
123 m_commonPrefixes.push_back(commonPrefixesMember);
124 commonPrefixesMember = commonPrefixesMember.NextNode("CommonPrefixes");
125 }
126
127 }
128 XmlNode encodingTypeNode = resultNode.FirstChild("EncodingType");
129 if(!encodingTypeNode.IsNull())
130 {
131 m_encodingType = EncodingTypeMapper::GetEncodingTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encodingTypeNode.GetText()).c_str()).c_str());
132 }
133 }
134
135 return *this;
136}
137