|
29 | 29 |
|
30 | 30 | import com.aliyun.oss.ClientException; |
31 | 31 | import com.aliyun.oss.common.comm.io.FixedLengthInputStream; |
| 32 | +import com.aliyun.oss.common.utils.BinaryUtil; |
32 | 33 | import com.aliyun.oss.common.utils.DateUtil; |
33 | 34 | import com.aliyun.oss.internal.RequestParameters; |
| 35 | +import com.aliyun.oss.model.*; |
34 | 36 | import com.aliyun.oss.model.AddBucketReplicationRequest.ReplicationAction; |
35 | | -import com.aliyun.oss.model.BucketReferer; |
36 | | -import com.aliyun.oss.model.CompleteMultipartUploadRequest; |
37 | | -import com.aliyun.oss.model.CreateBucketRequest; |
38 | | -import com.aliyun.oss.model.CreateLiveChannelRequest; |
39 | | -import com.aliyun.oss.model.CreateUdfApplicationRequest; |
40 | | -import com.aliyun.oss.model.CreateUdfRequest; |
41 | | -import com.aliyun.oss.model.DeleteBucketCnameRequest; |
42 | | -import com.aliyun.oss.model.DeleteObjectsRequest; |
43 | | -import com.aliyun.oss.model.ImageProcess; |
44 | | -import com.aliyun.oss.model.LifecycleRule; |
45 | 37 | import com.aliyun.oss.model.LifecycleRule.AbortMultipartUpload; |
46 | 38 | import com.aliyun.oss.model.LifecycleRule.RuleStatus; |
47 | 39 | import com.aliyun.oss.model.LifecycleRule.StorageTransition; |
48 | | -import com.aliyun.oss.model.LiveChannelTarget; |
49 | | -import com.aliyun.oss.model.PartETag; |
50 | | -import com.aliyun.oss.model.ProcessObjectRequest; |
51 | | -import com.aliyun.oss.model.PutBucketImageRequest; |
52 | | -import com.aliyun.oss.model.PutImageStyleRequest; |
53 | | -import com.aliyun.oss.model.ResizeUdfApplicationRequest; |
54 | | -import com.aliyun.oss.model.SetBucketCORSRequest; |
55 | 40 | import com.aliyun.oss.model.SetBucketCORSRequest.CORSRule; |
56 | | -import com.aliyun.oss.model.DeleteBucketReplicationRequest; |
57 | | -import com.aliyun.oss.model.RoutingRule; |
58 | | -import com.aliyun.oss.model.AddBucketCnameRequest; |
59 | | -import com.aliyun.oss.model.SetBucketLifecycleRequest; |
60 | | -import com.aliyun.oss.model.SetBucketLoggingRequest; |
61 | | -import com.aliyun.oss.model.AddBucketReplicationRequest; |
62 | | -import com.aliyun.oss.model.SetBucketTaggingRequest; |
63 | | -import com.aliyun.oss.model.SetBucketWebsiteRequest; |
64 | | -import com.aliyun.oss.model.TagSet; |
65 | | -import com.aliyun.oss.model.UdfApplicationConfiguration; |
66 | | -import com.aliyun.oss.model.UpgradeUdfApplicationRequest; |
67 | | -import com.aliyun.oss.model.UserQos; |
68 | 41 |
|
69 | 42 | /** |
70 | 43 | * A collection of marshallers that marshall HTTP request into crossponding |
@@ -99,6 +72,9 @@ public final class RequestMarshallers { |
99 | 72 | public static final ResizeUdfApplicationRequestMarshaller resizeUdfApplicationRequestMarshaller = new ResizeUdfApplicationRequestMarshaller(); |
100 | 73 | public static final ProcessObjectRequestMarshaller processObjectRequestMarshaller = new ProcessObjectRequestMarshaller(); |
101 | 74 |
|
| 75 | + public static final CreateSelectObjectMetadataRequestMarshaller createSelectObjectMetadataRequestMarshaller = new CreateSelectObjectMetadataRequestMarshaller(); |
| 76 | + public static final SelectObjectRequestMarshaller selectObjectRequestMarshaller = new SelectObjectRequestMarshaller(); |
| 77 | + |
102 | 78 | public interface RequestMarshaller<R> extends Marshaller<FixedLengthInputStream, R> { |
103 | 79 |
|
104 | 80 | } |
@@ -501,6 +477,87 @@ public FixedLengthInputStream marshall(CompleteMultipartUploadRequest request) { |
501 | 477 |
|
502 | 478 | } |
503 | 479 |
|
| 480 | + public static final class CreateSelectObjectMetadataRequestMarshaller |
| 481 | + implements RequestMarshaller2<CreateSelectObjectMetadataRequest> { |
| 482 | + |
| 483 | + @Override |
| 484 | + public byte[] marshall(CreateSelectObjectMetadataRequest request) { |
| 485 | + StringBuffer xmlBody = new StringBuffer(); |
| 486 | + InputSerialization inputSerialization = request.getInputSerialization(); |
| 487 | + CSVFormat csvFormat = inputSerialization.getCsvInputFormat(); |
| 488 | + xmlBody.append("<CsvMetaRequest>"); |
| 489 | + xmlBody.append("<InputSerialization>"); |
| 490 | + xmlBody.append("<CompressionType>" + inputSerialization.getCompressionType() + "</CompressionType>"); |
| 491 | + xmlBody.append("<CSV>"); |
| 492 | + xmlBody.append("<RecordDelimiter>" + BinaryUtil.toBase64String(csvFormat.getRecordDelimiter().getBytes()) + "</RecordDelimiter>"); |
| 493 | + xmlBody.append("<FieldDelimiter>" + BinaryUtil.toBase64String(csvFormat.getFieldDelimiter().toString().getBytes()) + "</FieldDelimiter>"); |
| 494 | + xmlBody.append("<QuoteCharacter>" + BinaryUtil.toBase64String(csvFormat.getQuoteChar().toString().getBytes()) + "</QuoteCharacter>"); |
| 495 | + xmlBody.append("</CSV>"); |
| 496 | + xmlBody.append("</InputSerialization>"); |
| 497 | + xmlBody.append("<OverwriteIfExists>" + request.isOverwrite() + "</OverwriteIfExists>"); |
| 498 | + xmlBody.append("</CsvMetaRequest>"); |
| 499 | + |
| 500 | + try { |
| 501 | + return xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME); |
| 502 | + } catch (UnsupportedEncodingException e) { |
| 503 | + throw new ClientException("Unsupported encoding " + e.getMessage(), e); |
| 504 | + } |
| 505 | + } |
| 506 | + } |
| 507 | + |
| 508 | + public static final class SelectObjectRequestMarshaller implements RequestMarshaller2<SelectObjectRequest> { |
| 509 | + |
| 510 | + @Override |
| 511 | + public byte[] marshall(SelectObjectRequest request) { |
| 512 | + StringBuffer xmlBody = new StringBuffer(); |
| 513 | + xmlBody.append("<SelectRequest>"); |
| 514 | + |
| 515 | + xmlBody.append("<Expression>" + BinaryUtil.toBase64String(request.getExpression().getBytes()) + "</Expression>"); |
| 516 | + xmlBody.append("<Options>"); |
| 517 | + xmlBody.append("<SkipPartialDataRecord>" + request.isSkipPartialDataRecord() + "</SkipPartialDataRecord>"); |
| 518 | + xmlBody.append("</Options>"); |
| 519 | + InputSerialization inputSerialization = request.getInputSerialization(); |
| 520 | + CSVFormat csvInputFormat = inputSerialization.getCsvInputFormat(); |
| 521 | + xmlBody.append("<InputSerialization>"); |
| 522 | + xmlBody.append("<CompressionType>" + inputSerialization.getCompressionType() + "</CompressionType>"); |
| 523 | + xmlBody.append("<CSV>"); |
| 524 | + xmlBody.append("<FileHeaderInfo>" + csvInputFormat.getHeaderInfo() + "</FileHeaderInfo>"); |
| 525 | + xmlBody.append("<RecordDelimiter>" + BinaryUtil.toBase64String(csvInputFormat.getRecordDelimiter().getBytes()) + "</RecordDelimiter>"); |
| 526 | + xmlBody.append("<FieldDelimiter>" + BinaryUtil.toBase64String(csvInputFormat.getFieldDelimiter().toString().getBytes()) + "</FieldDelimiter>"); |
| 527 | + xmlBody.append("<QuoteCharacter>" + BinaryUtil.toBase64String(csvInputFormat.getQuoteChar().toString().getBytes()) + "</QuoteCharacter>"); |
| 528 | + xmlBody.append("<CommentCharacter>" + BinaryUtil.toBase64String(csvInputFormat.getCommentChar().toString().getBytes()) + "</CommentCharacter>"); |
| 529 | + |
| 530 | + if (request.getLineRange() != null) { |
| 531 | + xmlBody.append("<Range>" + request.lineRangeToString(request.getLineRange()) + "</Range>"); |
| 532 | + } |
| 533 | + if (request.getSplitRange() != null) { |
| 534 | + xmlBody.append("<Range>" + request.splitRangeToString(request.getSplitRange()) + "</Range>"); |
| 535 | + } |
| 536 | + xmlBody.append("</CSV>"); |
| 537 | + xmlBody.append("</InputSerialization>"); |
| 538 | + OutputSerialization outputSerialization = request.getOutputSerialization(); |
| 539 | + CSVFormat csvOutputFormat = outputSerialization.getCsvOutputFormat(); |
| 540 | + xmlBody.append("<OutputSerialization>"); |
| 541 | + xmlBody.append("<CSV>"); |
| 542 | + xmlBody.append("<RecordDelimiter>" + BinaryUtil.toBase64String(csvOutputFormat.getRecordDelimiter().getBytes()) + "</RecordDelimiter>"); |
| 543 | + xmlBody.append("<FieldDelimiter>" + BinaryUtil.toBase64String(csvOutputFormat.getFieldDelimiter().toString().getBytes()) + "</FieldDelimiter>"); |
| 544 | + xmlBody.append("<QuoteCharacter>" + BinaryUtil.toBase64String(csvOutputFormat.getQuoteChar().toString().getBytes()) + "</QuoteCharacter>"); |
| 545 | + xmlBody.append("</CSV>"); |
| 546 | + xmlBody.append("<KeepAllColumns>" + outputSerialization.isKeepAllColumns() + "</KeepAllColumns>"); |
| 547 | + xmlBody.append("<OutputRawData>" + outputSerialization.isOutputRawData() + "</OutputRawData>"); |
| 548 | + xmlBody.append("<OutputHeader>" + outputSerialization.isOutputHeader() + "</OutputHeader>"); |
| 549 | + xmlBody.append("<EnablePayloadCrc>" + outputSerialization.isPayloadCrcEnabled() + "</EnablePayloadCrc>"); |
| 550 | + xmlBody.append("</OutputSerialization>"); |
| 551 | + xmlBody.append("</SelectRequest>"); |
| 552 | + |
| 553 | + try { |
| 554 | + return xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME); |
| 555 | + } catch (UnsupportedEncodingException e) { |
| 556 | + throw new ClientException("Unsupported encoding " + e.getMessage(), e); |
| 557 | + } |
| 558 | + } |
| 559 | + } |
| 560 | + |
504 | 561 | public static final class DeleteObjectsRequestMarshaller implements RequestMarshaller2<DeleteObjectsRequest> { |
505 | 562 |
|
506 | 563 | @Override |
|
0 commit comments