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/Error.h> |
17 | #include <aws/core/utils/xml/XmlSerializer.h> |
18 | #include <aws/core/utils/StringUtils.h> |
19 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
20 | |
21 | #include <utility> |
22 | |
23 | using namespace Aws::Utils::Xml; |
24 | using namespace Aws::Utils; |
25 | |
26 | namespace Aws |
27 | { |
28 | namespace S3 |
29 | { |
30 | namespace Model |
31 | { |
32 | |
33 | Error::Error() : |
34 | m_keyHasBeenSet(false), |
35 | m_versionIdHasBeenSet(false), |
36 | m_codeHasBeenSet(false), |
37 | m_messageHasBeenSet(false) |
38 | { |
39 | } |
40 | |
41 | Error::Error(const XmlNode& xmlNode) : |
42 | m_keyHasBeenSet(false), |
43 | m_versionIdHasBeenSet(false), |
44 | m_codeHasBeenSet(false), |
45 | m_messageHasBeenSet(false) |
46 | { |
47 | *this = xmlNode; |
48 | } |
49 | |
50 | Error& Error::operator =(const XmlNode& xmlNode) |
51 | { |
52 | XmlNode resultNode = xmlNode; |
53 | |
54 | if(!resultNode.IsNull()) |
55 | { |
56 | XmlNode keyNode = resultNode.FirstChild("Key" ); |
57 | if(!keyNode.IsNull()) |
58 | { |
59 | m_key = Aws::Utils::Xml::DecodeEscapedXmlText(keyNode.GetText()); |
60 | m_keyHasBeenSet = true; |
61 | } |
62 | XmlNode versionIdNode = resultNode.FirstChild("VersionId" ); |
63 | if(!versionIdNode.IsNull()) |
64 | { |
65 | m_versionId = Aws::Utils::Xml::DecodeEscapedXmlText(versionIdNode.GetText()); |
66 | m_versionIdHasBeenSet = true; |
67 | } |
68 | XmlNode codeNode = resultNode.FirstChild("Code" ); |
69 | if(!codeNode.IsNull()) |
70 | { |
71 | m_code = Aws::Utils::Xml::DecodeEscapedXmlText(codeNode.GetText()); |
72 | m_codeHasBeenSet = true; |
73 | } |
74 | XmlNode messageNode = resultNode.FirstChild("Message" ); |
75 | if(!messageNode.IsNull()) |
76 | { |
77 | m_message = Aws::Utils::Xml::DecodeEscapedXmlText(messageNode.GetText()); |
78 | m_messageHasBeenSet = true; |
79 | } |
80 | } |
81 | |
82 | return *this; |
83 | } |
84 | |
85 | void Error::AddToNode(XmlNode& parentNode) const |
86 | { |
87 | Aws::StringStream ss; |
88 | if(m_keyHasBeenSet) |
89 | { |
90 | XmlNode keyNode = parentNode.CreateChildElement("Key" ); |
91 | keyNode.SetText(m_key); |
92 | } |
93 | |
94 | if(m_versionIdHasBeenSet) |
95 | { |
96 | XmlNode versionIdNode = parentNode.CreateChildElement("VersionId" ); |
97 | versionIdNode.SetText(m_versionId); |
98 | } |
99 | |
100 | if(m_codeHasBeenSet) |
101 | { |
102 | XmlNode codeNode = parentNode.CreateChildElement("Code" ); |
103 | codeNode.SetText(m_code); |
104 | } |
105 | |
106 | if(m_messageHasBeenSet) |
107 | { |
108 | XmlNode messageNode = parentNode.CreateChildElement("Message" ); |
109 | messageNode.SetText(m_message); |
110 | } |
111 | |
112 | } |
113 | |
114 | } // namespace Model |
115 | } // namespace S3 |
116 | } // namespace Aws |
117 | |