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/Grantee.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 | Grantee::Grantee() : |
34 | m_displayNameHasBeenSet(false), |
35 | m_emailAddressHasBeenSet(false), |
36 | m_iDHasBeenSet(false), |
37 | m_type(Type::NOT_SET), |
38 | m_typeHasBeenSet(false), |
39 | m_uRIHasBeenSet(false) |
40 | { |
41 | } |
42 | |
43 | Grantee::Grantee(const XmlNode& xmlNode) : |
44 | m_displayNameHasBeenSet(false), |
45 | m_emailAddressHasBeenSet(false), |
46 | m_iDHasBeenSet(false), |
47 | m_type(Type::NOT_SET), |
48 | m_typeHasBeenSet(false), |
49 | m_uRIHasBeenSet(false) |
50 | { |
51 | *this = xmlNode; |
52 | } |
53 | |
54 | Grantee& Grantee::operator =(const XmlNode& xmlNode) |
55 | { |
56 | XmlNode resultNode = xmlNode; |
57 | |
58 | if(!resultNode.IsNull()) |
59 | { |
60 | XmlNode displayNameNode = resultNode.FirstChild("DisplayName" ); |
61 | if(!displayNameNode.IsNull()) |
62 | { |
63 | m_displayName = Aws::Utils::Xml::DecodeEscapedXmlText(displayNameNode.GetText()); |
64 | m_displayNameHasBeenSet = true; |
65 | } |
66 | XmlNode emailAddressNode = resultNode.FirstChild("EmailAddress" ); |
67 | if(!emailAddressNode.IsNull()) |
68 | { |
69 | m_emailAddress = Aws::Utils::Xml::DecodeEscapedXmlText(emailAddressNode.GetText()); |
70 | m_emailAddressHasBeenSet = true; |
71 | } |
72 | XmlNode iDNode = resultNode.FirstChild("ID" ); |
73 | if(!iDNode.IsNull()) |
74 | { |
75 | m_iD = Aws::Utils::Xml::DecodeEscapedXmlText(iDNode.GetText()); |
76 | m_iDHasBeenSet = true; |
77 | } |
78 | auto type = resultNode.GetAttributeValue("xsi:type" ); |
79 | if(!type.empty()) |
80 | { |
81 | m_type = TypeMapper::GetTypeForName(StringUtils::Trim(type.c_str()).c_str()); |
82 | m_typeHasBeenSet = true; |
83 | } |
84 | XmlNode uRINode = resultNode.FirstChild("URI" ); |
85 | if(!uRINode.IsNull()) |
86 | { |
87 | m_uRI = Aws::Utils::Xml::DecodeEscapedXmlText(uRINode.GetText()); |
88 | m_uRIHasBeenSet = true; |
89 | } |
90 | } |
91 | |
92 | return *this; |
93 | } |
94 | |
95 | void Grantee::AddToNode(XmlNode& parentNode) const |
96 | { |
97 | Aws::StringStream ss; |
98 | parentNode.SetAttributeValue("xmlns:xsi" , "http://www.w3.org/2001/XMLSchema-instance" ); |
99 | if(m_displayNameHasBeenSet) |
100 | { |
101 | XmlNode displayNameNode = parentNode.CreateChildElement("DisplayName" ); |
102 | displayNameNode.SetText(m_displayName); |
103 | } |
104 | |
105 | if(m_emailAddressHasBeenSet) |
106 | { |
107 | XmlNode emailAddressNode = parentNode.CreateChildElement("EmailAddress" ); |
108 | emailAddressNode.SetText(m_emailAddress); |
109 | } |
110 | |
111 | if(m_iDHasBeenSet) |
112 | { |
113 | XmlNode iDNode = parentNode.CreateChildElement("ID" ); |
114 | iDNode.SetText(m_iD); |
115 | } |
116 | |
117 | if(m_typeHasBeenSet) |
118 | { |
119 | parentNode.SetAttributeValue("xsi:type" , TypeMapper::GetNameForType(m_type)); |
120 | } |
121 | |
122 | if(m_uRIHasBeenSet) |
123 | { |
124 | XmlNode uRINode = parentNode.CreateChildElement("URI" ); |
125 | uRINode.SetText(m_uRI); |
126 | } |
127 | |
128 | } |
129 | |
130 | } // namespace Model |
131 | } // namespace S3 |
132 | } // namespace Aws |
133 | |