2020 *
2121 */
2222
23+ using System ;
2324using System . Collections . Generic ;
2425using Amazon . S3 . Model ;
2526
@@ -37,10 +38,11 @@ internal static class ResponseMapper
3738 /// </summary>
3839 /// <param name="source">The PutObjectResponse to map from</param>
3940 /// <returns>A new TransferUtilityUploadResponse with mapped fields</returns>
41+ /// <exception cref="ArgumentNullException">Thrown when source is null</exception>
4042 internal static TransferUtilityUploadResponse MapPutObjectResponse ( PutObjectResponse source )
4143 {
4244 if ( source == null )
43- return null ;
45+ throw new ArgumentNullException ( nameof ( source ) ) ;
4446
4547 var response = new TransferUtilityUploadResponse ( ) ;
4648
@@ -72,10 +74,11 @@ internal static TransferUtilityUploadResponse MapPutObjectResponse(PutObjectResp
7274 /// </summary>
7375 /// <param name="source">The CompleteMultipartUploadResponse to map from</param>
7476 /// <returns>A new TransferUtilityUploadResponse with mapped fields</returns>
77+ /// <exception cref="ArgumentNullException">Thrown when source is null</exception>
7578 internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse ( CompleteMultipartUploadResponse source )
7679 {
7780 if ( source == null )
78- return null ;
81+ throw new ArgumentNullException ( nameof ( source ) ) ;
7982
8083 var response = new TransferUtilityUploadResponse ( ) ;
8184
@@ -100,55 +103,92 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse
100103 return response ;
101104 }
102105
106+ /// <summary>
107+ /// Private helper method to populate the common properties from GetObjectResponse to the base response class.
108+ /// Contains all the shared mapping logic for GetObjectResponse fields.
109+ /// </summary>
110+ /// <param name="source">The GetObjectResponse to map from</param>
111+ /// <param name="target">The TransferUtilityGetObjectResponseBase to populate</param>
112+ /// <exception cref="ArgumentNullException">Thrown when source or target is null</exception>
113+ private static void PopulateGetObjectResponseBase ( GetObjectResponse source , TransferUtilityGetObjectResponseBase target )
114+ {
115+ if ( source == null )
116+ throw new ArgumentNullException ( nameof ( source ) ) ;
117+ if ( target == null )
118+ throw new ArgumentNullException ( nameof ( target ) ) ;
119+
120+ // Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
121+ target . AcceptRanges = source . AcceptRanges ;
122+ target . BucketKeyEnabled = source . BucketKeyEnabled . GetValueOrDefault ( ) ;
123+ target . ChecksumCRC32 = source . ChecksumCRC32 ;
124+ target . ChecksumCRC32C = source . ChecksumCRC32C ;
125+ target . ChecksumCRC64NVME = source . ChecksumCRC64NVME ;
126+ target . ChecksumSHA1 = source . ChecksumSHA1 ;
127+ target . ChecksumSHA256 = source . ChecksumSHA256 ;
128+ target . ChecksumType = source . ChecksumType ;
129+ target . ContentRange = source . ContentRange ;
130+ target . Headers = source . Headers ;
131+ target . DeleteMarker = source . DeleteMarker ;
132+ target . ETag = source . ETag ;
133+ target . Expiration = source . Expiration ;
134+ target . ExpiresString = source . ExpiresString ;
135+ target . LastModified = source . LastModified ;
136+ target . Metadata = source . Metadata ;
137+ target . MissingMeta = source . MissingMeta ;
138+ target . ObjectLockLegalHoldStatus = source . ObjectLockLegalHoldStatus ;
139+ target . ObjectLockMode = source . ObjectLockMode ;
140+ target . ObjectLockRetainUntilDate = source . ObjectLockRetainUntilDate ;
141+ target . PartsCount = source . PartsCount ;
142+ target . ReplicationStatus = source . ReplicationStatus ;
143+ target . RequestCharged = source . RequestCharged ;
144+ target . RestoreExpiration = source . RestoreExpiration ;
145+ target . RestoreInProgress = source . RestoreInProgress ;
146+ target . ServerSideEncryptionCustomerMethod = source . ServerSideEncryptionCustomerMethod ;
147+ target . ServerSideEncryptionCustomerProvidedKeyMD5 = source . ServerSideEncryptionCustomerProvidedKeyMD5 ;
148+ target . ServerSideEncryptionKeyManagementServiceKeyId = source . ServerSideEncryptionKeyManagementServiceKeyId ;
149+ target . ServerSideEncryptionMethod = source . ServerSideEncryptionMethod ;
150+ target . StorageClass = source . StorageClass ;
151+ target . TagCount = source . TagCount ;
152+ target . VersionId = source . VersionId ;
153+ target . WebsiteRedirectLocation = source . WebsiteRedirectLocation ;
154+ }
155+
103156 /// <summary>
104157 /// Maps a GetObjectResponse to TransferUtilityDownloadResponse.
105158 /// Uses the field mappings defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse".
106159 /// </summary>
107160 /// <param name="source">The GetObjectResponse to map from</param>
108161 /// <returns>A new TransferUtilityDownloadResponse with mapped fields</returns>
162+ /// <exception cref="ArgumentNullException">Thrown when source is null</exception>
109163 internal static TransferUtilityDownloadResponse MapGetObjectResponse ( GetObjectResponse source )
110164 {
111165 if ( source == null )
112- return null ;
166+ throw new ArgumentNullException ( nameof ( source ) ) ;
113167
114168 var response = new TransferUtilityDownloadResponse ( ) ;
115-
116- // Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
117- response . AcceptRanges = source . AcceptRanges ;
118- response . BucketKeyEnabled = source . BucketKeyEnabled . GetValueOrDefault ( ) ;
119- response . ChecksumCRC32 = source . ChecksumCRC32 ;
120- response . ChecksumCRC32C = source . ChecksumCRC32C ;
121- response . ChecksumCRC64NVME = source . ChecksumCRC64NVME ;
122- response . ChecksumSHA1 = source . ChecksumSHA1 ;
123- response . ChecksumSHA256 = source . ChecksumSHA256 ;
124- response . ChecksumType = source . ChecksumType ;
125- response . ContentRange = source . ContentRange ;
126- response . Headers = source . Headers ;
127- response . DeleteMarker = source . DeleteMarker ;
128- response . ETag = source . ETag ;
129- response . Expiration = source . Expiration ;
130- response . ExpiresString = source . ExpiresString ;
131- response . LastModified = source . LastModified ;
132- response . Metadata = source . Metadata ;
133- response . MissingMeta = source . MissingMeta ;
134- response . ObjectLockLegalHoldStatus = source . ObjectLockLegalHoldStatus ;
135- response . ObjectLockMode = source . ObjectLockMode ;
136- response . ObjectLockRetainUntilDate = source . ObjectLockRetainUntilDate ;
137- response . PartsCount = source . PartsCount ;
138- response . ReplicationStatus = source . ReplicationStatus ;
139- response . RequestCharged = source . RequestCharged ;
140- response . RestoreExpiration = source . RestoreExpiration ;
141- response . RestoreInProgress = source . RestoreInProgress ;
142- response . ServerSideEncryptionCustomerMethod = source . ServerSideEncryptionCustomerMethod ;
143- response . ServerSideEncryptionCustomerProvidedKeyMD5 = source . ServerSideEncryptionCustomerProvidedKeyMD5 ;
144- response . ServerSideEncryptionKeyManagementServiceKeyId = source . ServerSideEncryptionKeyManagementServiceKeyId ;
145- response . ServerSideEncryptionMethod = source . ServerSideEncryptionMethod ;
146- response . StorageClass = source . StorageClass ;
147- response . TagCount = source . TagCount ;
148- response . VersionId = source . VersionId ;
149- response . WebsiteRedirectLocation = source . WebsiteRedirectLocation ;
169+ PopulateGetObjectResponseBase ( source , response ) ;
150170 return response ;
151171 }
172+
173+ /// <summary>
174+ /// Maps a GetObjectResponse to TransferUtilityOpenStreamResponse.
175+ /// Uses the same field mappings as DownloadResponse plus the ResponseStream property.
176+ /// </summary>
177+ /// <param name="source">The GetObjectResponse to map from</param>
178+ /// <returns>A new TransferUtilityOpenStreamResponse with mapped fields</returns>
179+ /// <exception cref="ArgumentNullException">Thrown when source is null</exception>
180+ internal static TransferUtilityOpenStreamResponse MapGetObjectResponseToOpenStream ( GetObjectResponse source )
181+ {
182+ if ( source == null )
183+ throw new ArgumentNullException ( nameof ( source ) ) ;
184+
185+ var response = new TransferUtilityOpenStreamResponse ( ) ;
186+ PopulateGetObjectResponseBase ( source , response ) ;
187+ response . ResponseStream = source . ResponseStream ;
188+
189+ return response ;
190+ }
191+
152192
153193 }
154194}
0 commit comments