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/MultipartUpload.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 | MultipartUpload::MultipartUpload() : |
34 | m_uploadIdHasBeenSet(false), |
35 | m_keyHasBeenSet(false), |
36 | m_initiatedHasBeenSet(false), |
37 | m_storageClass(StorageClass::NOT_SET), |
38 | m_storageClassHasBeenSet(false), |
39 | m_ownerHasBeenSet(false), |
40 | m_initiatorHasBeenSet(false) |
41 | { |
42 | } |
43 | |
44 | MultipartUpload::MultipartUpload(const XmlNode& xmlNode) : |
45 | m_uploadIdHasBeenSet(false), |
46 | m_keyHasBeenSet(false), |
47 | m_initiatedHasBeenSet(false), |
48 | m_storageClass(StorageClass::NOT_SET), |
49 | m_storageClassHasBeenSet(false), |
50 | m_ownerHasBeenSet(false), |
51 | m_initiatorHasBeenSet(false) |
52 | { |
53 | *this = xmlNode; |
54 | } |
55 | |
56 | MultipartUpload& MultipartUpload::operator =(const XmlNode& xmlNode) |
57 | { |
58 | XmlNode resultNode = xmlNode; |
59 | |
60 | if(!resultNode.IsNull()) |
61 | { |
62 | XmlNode uploadIdNode = resultNode.FirstChild("UploadId" ); |
63 | if(!uploadIdNode.IsNull()) |
64 | { |
65 | m_uploadId = Aws::Utils::Xml::DecodeEscapedXmlText(uploadIdNode.GetText()); |
66 | m_uploadIdHasBeenSet = true; |
67 | } |
68 | XmlNode keyNode = resultNode.FirstChild("Key" ); |
69 | if(!keyNode.IsNull()) |
70 | { |
71 | m_key = Aws::Utils::Xml::DecodeEscapedXmlText(keyNode.GetText()); |
72 | m_keyHasBeenSet = true; |
73 | } |
74 | XmlNode initiatedNode = resultNode.FirstChild("Initiated" ); |
75 | if(!initiatedNode.IsNull()) |
76 | { |
77 | m_initiated = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(initiatedNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601); |
78 | m_initiatedHasBeenSet = true; |
79 | } |
80 | XmlNode storageClassNode = resultNode.FirstChild("StorageClass" ); |
81 | if(!storageClassNode.IsNull()) |
82 | { |
83 | m_storageClass = StorageClassMapper::GetStorageClassForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(storageClassNode.GetText()).c_str()).c_str()); |
84 | m_storageClassHasBeenSet = true; |
85 | } |
86 | XmlNode ownerNode = resultNode.FirstChild("Owner" ); |
87 | if(!ownerNode.IsNull()) |
88 | { |
89 | m_owner = ownerNode; |
90 | m_ownerHasBeenSet = true; |
91 | } |
92 | XmlNode initiatorNode = resultNode.FirstChild("Initiator" ); |
93 | if(!initiatorNode.IsNull()) |
94 | { |
95 | m_initiator = initiatorNode; |
96 | m_initiatorHasBeenSet = true; |
97 | } |
98 | } |
99 | |
100 | return *this; |
101 | } |
102 | |
103 | void MultipartUpload::AddToNode(XmlNode& parentNode) const |
104 | { |
105 | Aws::StringStream ss; |
106 | if(m_uploadIdHasBeenSet) |
107 | { |
108 | XmlNode uploadIdNode = parentNode.CreateChildElement("UploadId" ); |
109 | uploadIdNode.SetText(m_uploadId); |
110 | } |
111 | |
112 | if(m_keyHasBeenSet) |
113 | { |
114 | XmlNode keyNode = parentNode.CreateChildElement("Key" ); |
115 | keyNode.SetText(m_key); |
116 | } |
117 | |
118 | if(m_initiatedHasBeenSet) |
119 | { |
120 | XmlNode initiatedNode = parentNode.CreateChildElement("Initiated" ); |
121 | initiatedNode.SetText(m_initiated.ToGmtString(DateFormat::ISO_8601)); |
122 | } |
123 | |
124 | if(m_storageClassHasBeenSet) |
125 | { |
126 | XmlNode storageClassNode = parentNode.CreateChildElement("StorageClass" ); |
127 | storageClassNode.SetText(StorageClassMapper::GetNameForStorageClass(m_storageClass)); |
128 | } |
129 | |
130 | if(m_ownerHasBeenSet) |
131 | { |
132 | XmlNode ownerNode = parentNode.CreateChildElement("Owner" ); |
133 | m_owner.AddToNode(ownerNode); |
134 | } |
135 | |
136 | if(m_initiatorHasBeenSet) |
137 | { |
138 | XmlNode initiatorNode = parentNode.CreateChildElement("Initiator" ); |
139 | m_initiator.AddToNode(initiatorNode); |
140 | } |
141 | |
142 | } |
143 | |
144 | } // namespace Model |
145 | } // namespace S3 |
146 | } // namespace Aws |
147 | |