| 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/ListObjectsV2Result.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 | |
| 23 | using namespace Aws::S3::Model; |
| 24 | using namespace Aws::Utils::Xml; |
| 25 | using namespace Aws::Utils; |
| 26 | using namespace Aws; |
| 27 | |
| 28 | ListObjectsV2Result::ListObjectsV2Result() : |
| 29 | m_isTruncated(false), |
| 30 | m_maxKeys(0), |
| 31 | m_encodingType(EncodingType::NOT_SET), |
| 32 | m_keyCount(0) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | ListObjectsV2Result::ListObjectsV2Result(const Aws::AmazonWebServiceResult<XmlDocument>& result) : |
| 37 | m_isTruncated(false), |
| 38 | m_maxKeys(0), |
| 39 | m_encodingType(EncodingType::NOT_SET), |
| 40 | m_keyCount(0) |
| 41 | { |
| 42 | *this = result; |
| 43 | } |
| 44 | |
| 45 | ListObjectsV2Result& ListObjectsV2Result::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result) |
| 46 | { |
| 47 | const XmlDocument& xmlDocument = result.GetPayload(); |
| 48 | XmlNode resultNode = xmlDocument.GetRootElement(); |
| 49 | |
| 50 | if(!resultNode.IsNull()) |
| 51 | { |
| 52 | XmlNode isTruncatedNode = resultNode.FirstChild("IsTruncated" ); |
| 53 | if(!isTruncatedNode.IsNull()) |
| 54 | { |
| 55 | m_isTruncated = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(isTruncatedNode.GetText()).c_str()).c_str()); |
| 56 | } |
| 57 | XmlNode contentsNode = resultNode.FirstChild("Contents" ); |
| 58 | if(!contentsNode.IsNull()) |
| 59 | { |
| 60 | XmlNode contentsMember = contentsNode; |
| 61 | while(!contentsMember.IsNull()) |
| 62 | { |
| 63 | m_contents.push_back(contentsMember); |
| 64 | contentsMember = contentsMember.NextNode("Contents" ); |
| 65 | } |
| 66 | |
| 67 | } |
| 68 | XmlNode nameNode = resultNode.FirstChild("Name" ); |
| 69 | if(!nameNode.IsNull()) |
| 70 | { |
| 71 | m_name = Aws::Utils::Xml::DecodeEscapedXmlText(nameNode.GetText()); |
| 72 | } |
| 73 | XmlNode prefixNode = resultNode.FirstChild("Prefix" ); |
| 74 | if(!prefixNode.IsNull()) |
| 75 | { |
| 76 | m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText()); |
| 77 | } |
| 78 | XmlNode delimiterNode = resultNode.FirstChild("Delimiter" ); |
| 79 | if(!delimiterNode.IsNull()) |
| 80 | { |
| 81 | m_delimiter = Aws::Utils::Xml::DecodeEscapedXmlText(delimiterNode.GetText()); |
| 82 | } |
| 83 | XmlNode maxKeysNode = resultNode.FirstChild("MaxKeys" ); |
| 84 | if(!maxKeysNode.IsNull()) |
| 85 | { |
| 86 | m_maxKeys = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxKeysNode.GetText()).c_str()).c_str()); |
| 87 | } |
| 88 | XmlNode commonPrefixesNode = resultNode.FirstChild("CommonPrefixes" ); |
| 89 | if(!commonPrefixesNode.IsNull()) |
| 90 | { |
| 91 | XmlNode commonPrefixesMember = commonPrefixesNode; |
| 92 | while(!commonPrefixesMember.IsNull()) |
| 93 | { |
| 94 | m_commonPrefixes.push_back(commonPrefixesMember); |
| 95 | commonPrefixesMember = commonPrefixesMember.NextNode("CommonPrefixes" ); |
| 96 | } |
| 97 | |
| 98 | } |
| 99 | XmlNode encodingTypeNode = resultNode.FirstChild("EncodingType" ); |
| 100 | if(!encodingTypeNode.IsNull()) |
| 101 | { |
| 102 | m_encodingType = EncodingTypeMapper::GetEncodingTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encodingTypeNode.GetText()).c_str()).c_str()); |
| 103 | } |
| 104 | XmlNode keyCountNode = resultNode.FirstChild("KeyCount" ); |
| 105 | if(!keyCountNode.IsNull()) |
| 106 | { |
| 107 | m_keyCount = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(keyCountNode.GetText()).c_str()).c_str()); |
| 108 | } |
| 109 | XmlNode continuationTokenNode = resultNode.FirstChild("ContinuationToken" ); |
| 110 | if(!continuationTokenNode.IsNull()) |
| 111 | { |
| 112 | m_continuationToken = Aws::Utils::Xml::DecodeEscapedXmlText(continuationTokenNode.GetText()); |
| 113 | } |
| 114 | XmlNode nextContinuationTokenNode = resultNode.FirstChild("NextContinuationToken" ); |
| 115 | if(!nextContinuationTokenNode.IsNull()) |
| 116 | { |
| 117 | m_nextContinuationToken = Aws::Utils::Xml::DecodeEscapedXmlText(nextContinuationTokenNode.GetText()); |
| 118 | } |
| 119 | XmlNode startAfterNode = resultNode.FirstChild("StartAfter" ); |
| 120 | if(!startAfterNode.IsNull()) |
| 121 | { |
| 122 | m_startAfter = Aws::Utils::Xml::DecodeEscapedXmlText(startAfterNode.GetText()); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return *this; |
| 127 | } |
| 128 | |