-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathResponseParsers.java
3149 lines (2609 loc) · 133 KB
/
ResponseParsers.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyun.oss.internal;
import static com.aliyun.oss.common.utils.CodingUtils.isNullOrEmpty;
import static com.aliyun.oss.internal.OSSUtils.safeCloseResponse;
import static com.aliyun.oss.internal.OSSUtils.trimQuotes;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.zip.CheckedInputStream;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.JDOMParseException;
import org.jdom.input.SAXBuilder;
import com.aliyun.oss.common.comm.ResponseMessage;
import com.aliyun.oss.common.parser.ResponseParseException;
import com.aliyun.oss.common.parser.ResponseParser;
import com.aliyun.oss.common.utils.DateUtil;
import com.aliyun.oss.common.utils.HttpUtil;
import com.aliyun.oss.common.utils.StringUtils;
import com.aliyun.oss.model.AccessControlList;
import com.aliyun.oss.model.AddBucketReplicationRequest.ReplicationAction;
import com.aliyun.oss.model.DeleteVersionsResult.DeletedVersion;
import com.aliyun.oss.model.AppendObjectResult;
import com.aliyun.oss.model.Bucket;
import com.aliyun.oss.model.BucketInfo;
import com.aliyun.oss.model.BucketList;
import com.aliyun.oss.model.BucketLoggingResult;
import com.aliyun.oss.model.BucketMetadata;
import com.aliyun.oss.model.BucketProcess;
import com.aliyun.oss.model.BucketQosInfo;
import com.aliyun.oss.model.BucketReferer;
import com.aliyun.oss.model.BucketReplicationProgress;
import com.aliyun.oss.model.BucketStat;
import com.aliyun.oss.model.BucketVersioningConfiguration;
import com.aliyun.oss.model.BucketWebsiteResult;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.CannedUdfAcl;
import com.aliyun.oss.model.CnameConfiguration;
import com.aliyun.oss.model.CompleteMultipartUploadResult;
import com.aliyun.oss.model.CopyObjectResult;
import com.aliyun.oss.model.CreateLiveChannelResult;
import com.aliyun.oss.model.DataRedundancyType;
import com.aliyun.oss.model.DeleteObjectsResult;
import com.aliyun.oss.model.DeleteVersionsResult;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.GetBucketImageResult;
import com.aliyun.oss.model.ImageProcess;
import com.aliyun.oss.model.LiveChannel;
import com.aliyun.oss.model.LiveChannelInfo;
import com.aliyun.oss.model.LiveChannelListing;
import com.aliyun.oss.model.LiveChannelStat;
import com.aliyun.oss.model.LiveRecord;
import com.aliyun.oss.model.LiveChannelStat.AudioStat;
import com.aliyun.oss.model.LiveChannelStat.VideoStat;
import com.aliyun.oss.model.LiveChannelStatus;
import com.aliyun.oss.model.LiveChannelTarget;
import com.aliyun.oss.model.OSSSymlink;
import com.aliyun.oss.model.OSSVersionSummary;
import com.aliyun.oss.model.ReplicationRule;
import com.aliyun.oss.model.GetImageStyleResult;
import com.aliyun.oss.model.GroupGrantee;
import com.aliyun.oss.model.InitiateMultipartUploadResult;
import com.aliyun.oss.model.InstanceFlavor;
import com.aliyun.oss.model.LifecycleRule;
import com.aliyun.oss.model.ReplicationStatus;
import com.aliyun.oss.model.RestoreObjectResult;
import com.aliyun.oss.model.RoutingRule;
import com.aliyun.oss.model.ServerSideEncryptionByDefault;
import com.aliyun.oss.model.ServerSideEncryptionConfiguration;
import com.aliyun.oss.model.StorageClass;
import com.aliyun.oss.model.LifecycleRule.RuleStatus;
import com.aliyun.oss.model.LifecycleRule.StorageTransition;
import com.aliyun.oss.model.MultipartUpload;
import com.aliyun.oss.model.MultipartUploadListing;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.OSSObjectSummary;
import com.aliyun.oss.model.ObjectAcl;
import com.aliyun.oss.model.ObjectListing;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.ObjectPermission;
import com.aliyun.oss.model.Owner;
import com.aliyun.oss.model.PartListing;
import com.aliyun.oss.model.PartSummary;
import com.aliyun.oss.model.Payer;
import com.aliyun.oss.model.Permission;
import com.aliyun.oss.model.PutObjectResult;
import com.aliyun.oss.model.PushflowStatus;
import com.aliyun.oss.model.SetBucketCORSRequest.CORSRule;
import com.aliyun.oss.model.SimplifiedObjectMeta;
import com.aliyun.oss.model.Style;
import com.aliyun.oss.model.TagSet;
import com.aliyun.oss.model.UdfApplicationInfo;
import com.aliyun.oss.model.UdfApplicationLog;
import com.aliyun.oss.model.UdfImageInfo;
import com.aliyun.oss.model.UdfInfo;
import com.aliyun.oss.model.UploadPartCopyResult;
import com.aliyun.oss.model.UserQos;
import com.aliyun.oss.model.UserQosInfo;
import com.aliyun.oss.model.VersionListing;
import com.aliyun.oss.model.GetBucketPolicyResult;
import com.aliyun.oss.model.GetBucketRequestPaymentResult;
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionStorageTransition;
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionExpiration;
import com.aliyun.oss.model.SetAsyncFetchTaskResult;
import com.aliyun.oss.model.GetAsyncFetchTaskResult;
import com.aliyun.oss.model.AsyncFetchTaskConfiguration;
import com.aliyun.oss.model.AsyncFetchTaskState;
import com.aliyun.oss.model.VpcPolicy;
import com.aliyun.oss.model.Vpcip;
/*
* A collection of parsers that parse HTTP reponses into corresponding human-readable results.
*/
public final class ResponseParsers {
public static final ListBucketResponseParser listBucketResponseParser = new ListBucketResponseParser();
public static final ListImageStyleResponseParser listImageStyleResponseParser = new ListImageStyleResponseParser();
public static final GetBucketRefererResponseParser getBucketRefererResponseParser = new GetBucketRefererResponseParser();
public static final GetBucketAclResponseParser getBucketAclResponseParser = new GetBucketAclResponseParser();
public static final GetBucketMetadataResponseParser getBucketMetadataResponseParser = new GetBucketMetadataResponseParser();
public static final GetBucketLocationResponseParser getBucketLocationResponseParser = new GetBucketLocationResponseParser();
public static final GetBucketLoggingResponseParser getBucketLoggingResponseParser = new GetBucketLoggingResponseParser();
public static final GetBucketWebsiteResponseParser getBucketWebsiteResponseParser = new GetBucketWebsiteResponseParser();
public static final GetBucketLifecycleResponseParser getBucketLifecycleResponseParser = new GetBucketLifecycleResponseParser();
public static final GetBucketCorsResponseParser getBucketCorsResponseParser = new GetBucketCorsResponseParser();
public static final GetBucketImageResponseParser getBucketImageResponseParser = new GetBucketImageResponseParser();
public static final GetImageStyleResponseParser getImageStyleResponseParser = new GetImageStyleResponseParser();
public static final GetBucketImageProcessConfResponseParser getBucketImageProcessConfResponseParser = new GetBucketImageProcessConfResponseParser();
public static final GetTaggingResponseParser getTaggingResponseParser = new GetTaggingResponseParser();
public static final GetBucketReplicationResponseParser getBucketReplicationResponseParser = new GetBucketReplicationResponseParser();
public static final GetBucketReplicationProgressResponseParser getBucketReplicationProgressResponseParser = new GetBucketReplicationProgressResponseParser();
public static final GetBucketReplicationLocationResponseParser getBucketReplicationLocationResponseParser = new GetBucketReplicationLocationResponseParser();
public static final GetBucketCnameResponseParser getBucketCnameResponseParser = new GetBucketCnameResponseParser();
public static final GetBucketInfoResponseParser getBucketInfoResponseParser = new GetBucketInfoResponseParser();
public static final GetBucketStatResponseParser getBucketStatResponseParser = new GetBucketStatResponseParser();
public static final GetBucketQosResponseParser getBucketQosResponseParser = new GetBucketQosResponseParser();
public static final GetBucketVersioningResponseParser getBucketVersioningResponseParser = new GetBucketVersioningResponseParser();
public static final GetBucketEncryptionResponseParser getBucketEncryptionResponseParser = new GetBucketEncryptionResponseParser();
public static final GetBucketPolicyResponseParser getBucketPolicyResponseParser = new GetBucketPolicyResponseParser();
public static final GetBucketRequestPaymentResponseParser getBucketRequestPaymentResponseParser = new GetBucketRequestPaymentResponseParser();
public static final GetUSerQosInfoResponseParser getUSerQosInfoResponseParser = new GetUSerQosInfoResponseParser();
public static final GetBucketQosInfoResponseParser getBucketQosInfoResponseParser = new GetBucketQosInfoResponseParser();
public static final SetAsyncFetchTaskResponseParser setAsyncFetchTaskResponseParser = new SetAsyncFetchTaskResponseParser();
public static final GetAsyncFetchTaskResponseParser getAsyncFetchTaskResponseParser = new GetAsyncFetchTaskResponseParser();
public static final CreateVpcipResultResponseParser createVpcipResultResponseParser = new CreateVpcipResultResponseParser();
public static final ListVpcipResultResponseParser listVpcipResultResponseParser = new ListVpcipResultResponseParser();
public static final ListVpcPolicyResultResponseParser listVpcPolicyResultResponseParser = new ListVpcPolicyResultResponseParser();
public static final ListObjectsReponseParser listObjectsReponseParser = new ListObjectsReponseParser();
public static final ListVersionsReponseParser listVersionsReponseParser = new ListVersionsReponseParser();
public static final PutObjectReponseParser putObjectReponseParser = new PutObjectReponseParser();
public static final PutObjectProcessReponseParser putObjectProcessReponseParser = new PutObjectProcessReponseParser();
public static final AppendObjectResponseParser appendObjectResponseParser = new AppendObjectResponseParser();
public static final GetObjectMetadataResponseParser getObjectMetadataResponseParser = new GetObjectMetadataResponseParser();
public static final CopyObjectResponseParser copyObjectResponseParser = new CopyObjectResponseParser();
public static final DeleteObjectsResponseParser deleteObjectsResponseParser = new DeleteObjectsResponseParser();
public static final DeleteVersionsResponseParser deleteVersionsResponseParser = new DeleteVersionsResponseParser();
public static final GetObjectAclResponseParser getObjectAclResponseParser = new GetObjectAclResponseParser();
public static final GetSimplifiedObjectMetaResponseParser getSimplifiedObjectMetaResponseParser = new GetSimplifiedObjectMetaResponseParser();
public static final RestoreObjectResponseParser restoreObjectResponseParser = new RestoreObjectResponseParser();
public static final ProcessObjectResponseParser processObjectResponseParser = new ProcessObjectResponseParser();
public static final HeadObjectResponseParser headObjectResponseParser = new HeadObjectResponseParser();
public static final CompleteMultipartUploadResponseParser completeMultipartUploadResponseParser = new CompleteMultipartUploadResponseParser();
public static final CompleteMultipartUploadProcessResponseParser completeMultipartUploadProcessResponseParser = new CompleteMultipartUploadProcessResponseParser();
public static final InitiateMultipartUploadResponseParser initiateMultipartUploadResponseParser = new InitiateMultipartUploadResponseParser();
public static final ListMultipartUploadsResponseParser listMultipartUploadsResponseParser = new ListMultipartUploadsResponseParser();
public static final ListPartsResponseParser listPartsResponseParser = new ListPartsResponseParser();
public static final CreateLiveChannelResponseParser createLiveChannelResponseParser = new CreateLiveChannelResponseParser();
public static final GetLiveChannelInfoResponseParser getLiveChannelInfoResponseParser = new GetLiveChannelInfoResponseParser();
public static final GetLiveChannelStatResponseParser getLiveChannelStatResponseParser = new GetLiveChannelStatResponseParser();
public static final GetLiveChannelHistoryResponseParser getLiveChannelHistoryResponseParser = new GetLiveChannelHistoryResponseParser();
public static final ListLiveChannelsReponseParser listLiveChannelsReponseParser = new ListLiveChannelsReponseParser();
public static final GetSymbolicLinkResponseParser getSymbolicLinkResponseParser = new GetSymbolicLinkResponseParser();
public static final class EmptyResponseParser implements ResponseParser<ResponseMessage> {
@Override
public ResponseMessage parse(ResponseMessage response) throws ResponseParseException {
// Close response and return it directly without parsing.
safeCloseResponse(response);
return response;
}
}
public static final class ListBucketResponseParser implements ResponseParser<BucketList> {
@Override
public BucketList parse(ResponseMessage response) throws ResponseParseException {
try {
BucketList result = parseListBucket(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class ListImageStyleResponseParser implements ResponseParser<List<Style>> {
@Override
public List<Style> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseListImageStyle(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketRefererResponseParser implements ResponseParser<BucketReferer> {
@Override
public BucketReferer parse(ResponseMessage response) throws ResponseParseException {
try {
BucketReferer result = parseGetBucketReferer(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketAclResponseParser implements ResponseParser<AccessControlList> {
@Override
public AccessControlList parse(ResponseMessage response) throws ResponseParseException {
try {
AccessControlList result = parseGetBucketAcl(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketMetadataResponseParser implements ResponseParser<BucketMetadata> {
@Override
public BucketMetadata parse(ResponseMessage response) throws ResponseParseException {
try {
return parseBucketMetadata(response.getHeaders());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketLocationResponseParser implements ResponseParser<String> {
@Override
public String parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetBucketLocation(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketLoggingResponseParser implements ResponseParser<BucketLoggingResult> {
@Override
public BucketLoggingResult parse(ResponseMessage response) throws ResponseParseException {
try {
BucketLoggingResult result = parseBucketLogging(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketImageResponseParser implements ResponseParser<GetBucketImageResult> {
@Override
public GetBucketImageResult parse(ResponseMessage response) throws ResponseParseException {
try {
return parseBucketImage(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetImageStyleResponseParser implements ResponseParser<GetImageStyleResult> {
@Override
public GetImageStyleResult parse(ResponseMessage response) throws ResponseParseException {
try {
return parseImageStyle(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketImageProcessConfResponseParser implements ResponseParser<BucketProcess> {
@Override
public BucketProcess parse(ResponseMessage response) throws ResponseParseException {
try {
BucketProcess result = parseGetBucketImageProcessConf(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketWebsiteResponseParser implements ResponseParser<BucketWebsiteResult> {
@Override
public BucketWebsiteResult parse(ResponseMessage response) throws ResponseParseException {
try {
BucketWebsiteResult result = parseBucketWebsite(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketLifecycleResponseParser implements ResponseParser<List<LifecycleRule>> {
@Override
public List<LifecycleRule> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetBucketLifecycle(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketCnameResponseParser implements ResponseParser<List<CnameConfiguration>> {
@Override
public List<CnameConfiguration> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetBucketCname(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketInfoResponseParser implements ResponseParser<BucketInfo> {
@Override
public BucketInfo parse(ResponseMessage response) throws ResponseParseException {
try {
BucketInfo result = parseGetBucketInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketStatResponseParser implements ResponseParser<BucketStat> {
@Override
public BucketStat parse(ResponseMessage response) throws ResponseParseException {
try {
BucketStat result = parseGetBucketStat(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketQosResponseParser implements ResponseParser<UserQos> {
@Override
public UserQos parse(ResponseMessage response) throws ResponseParseException {
try {
UserQos result = parseGetUserQos(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketVersioningResponseParser
implements ResponseParser<BucketVersioningConfiguration> {
@Override
public BucketVersioningConfiguration parse(ResponseMessage response) throws ResponseParseException {
try {
BucketVersioningConfiguration result = parseGetBucketVersioning(response.getContent());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketEncryptionResponseParser
implements ResponseParser<ServerSideEncryptionConfiguration> {
@Override
public ServerSideEncryptionConfiguration parse(ResponseMessage response) throws ResponseParseException {
try {
ServerSideEncryptionConfiguration result = parseGetBucketEncryption(response.getContent());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketPolicyResponseParser implements ResponseParser<GetBucketPolicyResult> {
@Override
public GetBucketPolicyResult parse(ResponseMessage response) throws ResponseParseException {
try {
GetBucketPolicyResult result = parseGetBucketPolicy(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketRequestPaymentResponseParser implements ResponseParser<GetBucketRequestPaymentResult> {
@Override
public GetBucketRequestPaymentResult parse(ResponseMessage response) throws ResponseParseException {
try {
GetBucketRequestPaymentResult result = parseGetBucketRequestPayment(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetUSerQosInfoResponseParser implements ResponseParser<UserQosInfo> {
@Override
public UserQosInfo parse(ResponseMessage response) throws ResponseParseException {
try {
UserQosInfo result = parseGetUserQosInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketQosInfoResponseParser implements ResponseParser<BucketQosInfo> {
@Override
public BucketQosInfo parse(ResponseMessage response) throws ResponseParseException {
try {
BucketQosInfo result = parseGetBucketQosInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class SetAsyncFetchTaskResponseParser implements ResponseParser<SetAsyncFetchTaskResult> {
@Override
public SetAsyncFetchTaskResult parse(ResponseMessage response) throws ResponseParseException {
try {
SetAsyncFetchTaskResult result = parseSetAsyncFetchTaskResult(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetAsyncFetchTaskResponseParser implements ResponseParser<GetAsyncFetchTaskResult> {
@Override
public GetAsyncFetchTaskResult parse(ResponseMessage response) throws ResponseParseException {
try {
GetAsyncFetchTaskResult result = parseGetAsyncFetchTaskResult(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class CreateLiveChannelResponseParser implements ResponseParser<CreateLiveChannelResult> {
@Override
public CreateLiveChannelResult parse(ResponseMessage response) throws ResponseParseException {
try {
CreateLiveChannelResult result = parseCreateLiveChannel(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetLiveChannelInfoResponseParser implements ResponseParser<LiveChannelInfo> {
@Override
public LiveChannelInfo parse(ResponseMessage response) throws ResponseParseException {
try {
LiveChannelInfo result = parseGetLiveChannelInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetLiveChannelStatResponseParser implements ResponseParser<LiveChannelStat> {
@Override
public LiveChannelStat parse(ResponseMessage response) throws ResponseParseException {
try {
LiveChannelStat result = parseGetLiveChannelStat(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetLiveChannelHistoryResponseParser implements ResponseParser<List<LiveRecord>> {
@Override
public List<LiveRecord> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetLiveChannelHistory(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class ListLiveChannelsReponseParser implements ResponseParser<LiveChannelListing> {
@Override
public LiveChannelListing parse(ResponseMessage response) throws ResponseParseException {
try {
return parseListLiveChannels(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketCorsResponseParser implements ResponseParser<List<CORSRule>> {
@Override
public List<CORSRule> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseListBucketCORS(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetTaggingResponseParser implements ResponseParser<TagSet> {
@Override
public TagSet parse(ResponseMessage response) throws ResponseParseException {
try {
TagSet result = parseGetBucketTagging(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketReplicationResponseParser implements ResponseParser<List<ReplicationRule>> {
@Override
public List<ReplicationRule> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetBucketReplication(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketReplicationProgressResponseParser
implements ResponseParser<BucketReplicationProgress> {
@Override
public BucketReplicationProgress parse(ResponseMessage response) throws ResponseParseException {
try {
BucketReplicationProgress result = parseGetBucketReplicationProgress(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetBucketReplicationLocationResponseParser implements ResponseParser<List<String>> {
@Override
public List<String> parse(ResponseMessage response) throws ResponseParseException {
try {
return parseGetBucketReplicationLocation(response.getContent());
} finally {
safeCloseResponse(response);
}
}
}
public static final class ListObjectsReponseParser implements ResponseParser<ObjectListing> {
@Override
public ObjectListing parse(ResponseMessage response) throws ResponseParseException {
try {
ObjectListing result = parseListObjects(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class ListVersionsReponseParser implements ResponseParser<VersionListing> {
@Override
public VersionListing parse(ResponseMessage response) throws ResponseParseException {
try {
VersionListing result = parseListVersions(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class PutObjectReponseParser implements ResponseParser<PutObjectResult> {
@Override
public PutObjectResult parse(ResponseMessage response) throws ResponseParseException {
PutObjectResult result = new PutObjectResult();
try {
result.setETag(trimQuotes(response.getHeaders().get(OSSHeaders.ETAG)));
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
result.setRequestId(response.getRequestId());
setCRC(result, response);
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class PutObjectProcessReponseParser implements ResponseParser<PutObjectResult> {
@Override
public PutObjectResult parse(ResponseMessage response) throws ResponseParseException {
PutObjectResult result = new PutObjectResult();
result.setRequestId(response.getRequestId());
result.setETag(trimQuotes(response.getHeaders().get(OSSHeaders.ETAG)));
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
result.setCallbackResponseBody(response.getContent());
result.setResponse(response);
return result;
}
}
public static final class AppendObjectResponseParser implements ResponseParser<AppendObjectResult> {
@Override
public AppendObjectResult parse(ResponseMessage response) throws ResponseParseException {
AppendObjectResult result = new AppendObjectResult();
result.setRequestId(response.getRequestId());
try {
String nextPosition = response.getHeaders().get(OSSHeaders.OSS_NEXT_APPEND_POSITION);
if (nextPosition != null) {
result.setNextPosition(Long.valueOf(nextPosition));
}
result.setObjectCRC(response.getHeaders().get(OSSHeaders.OSS_HASH_CRC64_ECMA));
result.setResponse(response);
setCRC(result, response);
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetObjectResponseParser implements ResponseParser<OSSObject> {
private String bucketName;
private String key;
public GetObjectResponseParser(final String bucketName, final String key) {
this.bucketName = bucketName;
this.key = key;
}
@Override
public OSSObject parse(ResponseMessage response) throws ResponseParseException {
OSSObject ossObject = new OSSObject();
ossObject.setBucketName(this.bucketName);
ossObject.setKey(this.key);
ossObject.setObjectContent(response.getContent());
ossObject.setRequestId(response.getRequestId());
ossObject.setResponse(response);
try {
ossObject.setObjectMetadata(parseObjectMetadata(response.getHeaders()));
setServerCRC(ossObject, response);
return ossObject;
} catch (ResponseParseException e) {
// Close response only when parsing exception thrown. Otherwise,
// just hand over to SDK users and remain them close it when no
// longer in use.
safeCloseResponse(response);
// Rethrow
throw e;
}
}
}
public static final class GetObjectAclResponseParser implements ResponseParser<ObjectAcl> {
@Override
public ObjectAcl parse(ResponseMessage response) throws ResponseParseException {
try {
ObjectAcl result = parseGetObjectAcl(response.getContent());
result.setRequestId(response.getRequestId());
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class GetSimplifiedObjectMetaResponseParser implements ResponseParser<SimplifiedObjectMeta> {
@Override
public SimplifiedObjectMeta parse(ResponseMessage response) throws ResponseParseException {
try {
return parseSimplifiedObjectMeta(response.getHeaders());
} finally {
OSSUtils.mandatoryCloseResponse(response);
}
}
}
public static final class RestoreObjectResponseParser implements ResponseParser<RestoreObjectResult> {
@Override
public RestoreObjectResult parse(ResponseMessage response) throws ResponseParseException {
try {
RestoreObjectResult result = new RestoreObjectResult(response.getStatusCode());
result.setRequestId(response.getRequestId());
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class ProcessObjectResponseParser implements ResponseParser<GenericResult> {
@Override
public GenericResult parse(ResponseMessage response) throws ResponseParseException {
GenericResult result = new PutObjectResult();
result.setRequestId(response.getRequestId());
result.setResponse(response);
return result;
}
}
public static final class GetObjectMetadataResponseParser implements ResponseParser<ObjectMetadata> {
@Override
public ObjectMetadata parse(ResponseMessage response) throws ResponseParseException {
try {
return parseObjectMetadata(response.getHeaders());
} finally {
safeCloseResponse(response);
}
}
}
public static final class HeadObjectResponseParser implements ResponseParser<ObjectMetadata> {
@Override
public ObjectMetadata parse(ResponseMessage response) throws ResponseParseException {
try {
return parseObjectMetadata(response.getHeaders());
} finally {
safeCloseResponse(response);
}
}
}
public static final class CopyObjectResponseParser implements ResponseParser<CopyObjectResult> {
@Override
public CopyObjectResult parse(ResponseMessage response) throws ResponseParseException {
try {
CopyObjectResult result = parseCopyObjectResult(response.getContent());
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
result.setRequestId(response.getRequestId());
result.setResponse(response);
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class DeleteObjectsResponseParser implements ResponseParser<DeleteObjectsResult> {
@Override
public DeleteObjectsResult parse(ResponseMessage response) throws ResponseParseException {
try {
DeleteObjectsResult result = null;
// Occurs when deleting multiple objects in quiet mode.
if (response.getContentLength() == 0) {
result = new DeleteObjectsResult(null);
} else {
result = parseDeleteObjectsResult(response.getContent());
}
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class DeleteVersionsResponseParser implements ResponseParser<DeleteVersionsResult> {
@Override
public DeleteVersionsResult parse(ResponseMessage response) throws ResponseParseException {
try {
DeleteVersionsResult result = null;
// Occurs when deleting multiple objects in quiet mode.
if (response.getContentLength() == 0) {
result = new DeleteVersionsResult(null);
} else {
result = parseDeleteVersionsResult(response.getContent());
}
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class CompleteMultipartUploadResponseParser
implements ResponseParser<CompleteMultipartUploadResult> {
@Override
public CompleteMultipartUploadResult parse(ResponseMessage response) throws ResponseParseException {
try {
CompleteMultipartUploadResult result = parseCompleteMultipartUpload(response.getContent());
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
result.setRequestId(response.getRequestId());
setServerCRC(result, response);
return result;
} finally {
safeCloseResponse(response);
}
}
}
public static final class CompleteMultipartUploadProcessResponseParser
implements ResponseParser<CompleteMultipartUploadResult> {
@Override
public CompleteMultipartUploadResult parse(ResponseMessage response) throws ResponseParseException {
CompleteMultipartUploadResult result = new CompleteMultipartUploadResult();
result.setVersionId(response.getHeaders().get(OSSHeaders.OSS_HEADER_VERSION_ID));
result.setRequestId(response.getRequestId());
result.setCallbackResponseBody(response.getContent());
result.setResponse(response);
return result;
}
}
public static final class InitiateMultipartUploadResponseParser
implements ResponseParser<InitiateMultipartUploadResult> {
@Override
public InitiateMultipartUploadResult parse(ResponseMessage response) throws ResponseParseException {