|
19 | 19 |
|
20 | 20 | package com.aliyun.oss.internal; |
21 | 21 |
|
22 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.bucketRefererMarshaller; |
23 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.createBucketRequestMarshaller; |
24 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.putBucketImageRequestMarshaller; |
25 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.putImageStyleRequestMarshaller; |
26 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketLifecycleRequestMarshaller; |
27 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketLoggingRequestMarshaller; |
28 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketTaggingRequestMarshaller; |
29 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketWebsiteRequestMarshaller; |
30 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.addBucketReplicationRequestMarshaller; |
31 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.deleteBucketReplicationRequestMarshaller; |
32 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.addBucketCnameRequestMarshaller; |
33 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.deleteBucketCnameRequestMarshaller; |
34 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketQosRequestMarshaller; |
35 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.bucketImageProcessConfMarshaller; |
36 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketVersioningRequestMarshaller; |
37 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketEncryptionRequestMarshaller; |
38 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketPolicyRequestMarshaller; |
39 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketRequestPaymentRequestMarshaller; |
40 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketQosInfoRequestMarshaller; |
41 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setAsyncFetchTaskRequestMarshaller; |
42 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.createVpcipRequestMarshaller; |
43 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.deleteVpcipRequestMarshaller; |
44 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.createBucketVpcipRequestMarshaller; |
45 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.deleteBucketVpcipRequestMarshaller; |
46 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketInventoryRequestMarshaller; |
47 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.extendBucketWormRequestMarshaller; |
48 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.initiateBucketWormRequestMarshaller; |
49 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.setBucketResourceGroupRequestMarshaller; |
50 | | -import static com.aliyun.oss.common.parser.RequestMarshallers.putBucketTransferAccelerationRequestMarshaller; |
| 22 | +import static com.aliyun.oss.common.parser.RequestMarshallers.*; |
51 | 23 | import static com.aliyun.oss.common.utils.CodingUtils.assertParameterNotNull; |
52 | 24 | import static com.aliyun.oss.internal.OSSUtils.OSS_RESOURCE_MANAGER; |
53 | 25 | import static com.aliyun.oss.internal.OSSUtils.ensureBucketNameValid; |
54 | 26 | import static com.aliyun.oss.internal.OSSUtils.ensureBucketNameCreationValid; |
55 | 27 | import static com.aliyun.oss.internal.OSSUtils.safeCloseResponse; |
56 | 28 | import static com.aliyun.oss.internal.RequestParameters.*; |
57 | | -import static com.aliyun.oss.internal.ResponseParsers.addBucketCnameResponseParser; |
58 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketAclResponseParser; |
59 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketLifecycleResponseParser; |
60 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketLocationResponseParser; |
61 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketLoggingResponseParser; |
62 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketRefererResponseParser; |
63 | | -import static com.aliyun.oss.internal.ResponseParsers.getTaggingResponseParser; |
64 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketWebsiteResponseParser; |
65 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketReplicationResponseParser; |
66 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketReplicationProgressResponseParser; |
67 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketReplicationLocationResponseParser; |
68 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketCnameResponseParser; |
69 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketInfoResponseParser; |
70 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketStatResponseParser; |
71 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketQosResponseParser; |
72 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketVersioningResponseParser; |
73 | | -import static com.aliyun.oss.internal.ResponseParsers.listBucketResponseParser; |
74 | | -import static com.aliyun.oss.internal.ResponseParsers.listObjectsReponseParser; |
75 | | -import static com.aliyun.oss.internal.ResponseParsers.listObjectsV2ResponseParser; |
76 | | -import static com.aliyun.oss.internal.ResponseParsers.listVersionsReponseParser; |
77 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketImageResponseParser; |
78 | | -import static com.aliyun.oss.internal.ResponseParsers.getImageStyleResponseParser; |
79 | | -import static com.aliyun.oss.internal.ResponseParsers.listImageStyleResponseParser; |
80 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketImageProcessConfResponseParser; |
81 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketEncryptionResponseParser; |
82 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketPolicyResponseParser; |
83 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketRequestPaymentResponseParser; |
84 | | -import static com.aliyun.oss.internal.ResponseParsers.getUSerQosInfoResponseParser; |
85 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketQosInfoResponseParser; |
86 | | -import static com.aliyun.oss.internal.ResponseParsers.getAsyncFetchTaskResponseParser; |
87 | | -import static com.aliyun.oss.internal.ResponseParsers.setAsyncFetchTaskResponseParser; |
88 | | -import static com.aliyun.oss.internal.ResponseParsers.createVpcipResultResponseParser; |
89 | | -import static com.aliyun.oss.internal.ResponseParsers.listVpcipResultResponseParser; |
90 | | -import static com.aliyun.oss.internal.ResponseParsers.listVpcPolicyResultResponseParser; |
91 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketInventoryConfigurationParser; |
92 | | -import static com.aliyun.oss.internal.ResponseParsers.listBucketInventoryConfigurationsParser; |
93 | | -import static com.aliyun.oss.internal.ResponseParsers.initiateBucketWormResponseParser; |
94 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketWormResponseParser; |
95 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketResourceGroupResponseParser; |
96 | | -import static com.aliyun.oss.internal.ResponseParsers.getBucketTransferAccelerationResponseParser; |
| 29 | +import static com.aliyun.oss.internal.ResponseParsers.*; |
97 | 30 |
|
98 | 31 | import java.io.ByteArrayInputStream; |
99 | 32 | import java.util.ArrayList; |
|
115 | 48 | import com.aliyun.oss.common.utils.BinaryUtil; |
116 | 49 | import com.aliyun.oss.common.utils.ExceptionFactory; |
117 | 50 | import com.aliyun.oss.common.utils.HttpHeaders; |
118 | | -import com.aliyun.oss.model.AccessControlList; |
119 | | -import com.aliyun.oss.model.AddBucketCnameResult; |
120 | | -import com.aliyun.oss.model.Bucket; |
121 | | -import com.aliyun.oss.model.BucketInfo; |
122 | | -import com.aliyun.oss.model.BucketList; |
123 | | -import com.aliyun.oss.model.BucketLoggingResult; |
124 | | -import com.aliyun.oss.model.BucketMetadata; |
125 | | -import com.aliyun.oss.model.BucketProcess; |
126 | | -import com.aliyun.oss.model.BucketQosInfo; |
127 | | -import com.aliyun.oss.model.BucketReferer; |
128 | | -import com.aliyun.oss.model.BucketReplicationProgress; |
129 | | -import com.aliyun.oss.model.BucketStat; |
130 | | -import com.aliyun.oss.model.BucketVersioningConfiguration; |
131 | | -import com.aliyun.oss.model.BucketWebsiteResult; |
132 | | -import com.aliyun.oss.model.CannedAccessControlList; |
133 | | -import com.aliyun.oss.model.CnameConfiguration; |
134 | | -import com.aliyun.oss.model.CreateBucketRequest; |
135 | | -import com.aliyun.oss.model.DeleteBucketCnameRequest; |
136 | | -import com.aliyun.oss.model.DeleteBucketReplicationRequest; |
137 | | -import com.aliyun.oss.model.GenericRequest; |
138 | | -import com.aliyun.oss.model.GetBucketImageResult; |
139 | | -import com.aliyun.oss.model.GetBucketReplicationProgressRequest; |
140 | | -import com.aliyun.oss.model.GetBucketRequestPaymentResult; |
141 | | -import com.aliyun.oss.model.ImageProcess; |
142 | | -import com.aliyun.oss.model.ListObjectsV2Request; |
143 | | -import com.aliyun.oss.model.ListObjectsV2Result; |
144 | | -import com.aliyun.oss.model.ReplicationRule; |
145 | | -import com.aliyun.oss.model.ServerSideEncryptionConfiguration; |
146 | | -import com.aliyun.oss.model.SetBucketEncryptionRequest; |
147 | | -import com.aliyun.oss.model.GetImageStyleResult; |
148 | | -import com.aliyun.oss.model.LifecycleRule; |
149 | | -import com.aliyun.oss.model.ListBucketsRequest; |
150 | | -import com.aliyun.oss.model.ListObjectsRequest; |
151 | | -import com.aliyun.oss.model.ListVersionsRequest; |
152 | | -import com.aliyun.oss.model.ObjectListing; |
153 | | -import com.aliyun.oss.model.Payer; |
154 | | -import com.aliyun.oss.model.PutBucketImageRequest; |
155 | | -import com.aliyun.oss.model.PutImageStyleRequest; |
156 | | -import com.aliyun.oss.model.SetBucketAclRequest; |
157 | | -import com.aliyun.oss.model.AddBucketCnameRequest; |
158 | | -import com.aliyun.oss.model.SetBucketLifecycleRequest; |
159 | | -import com.aliyun.oss.model.SetBucketLoggingRequest; |
160 | | -import com.aliyun.oss.model.SetBucketProcessRequest; |
161 | | -import com.aliyun.oss.model.SetBucketQosInfoRequest; |
162 | | -import com.aliyun.oss.model.SetBucketRefererRequest; |
163 | | -import com.aliyun.oss.model.SetBucketRequestPaymentRequest; |
164 | | -import com.aliyun.oss.model.AddBucketReplicationRequest; |
165 | | -import com.aliyun.oss.model.SetBucketStorageCapacityRequest; |
166 | | -import com.aliyun.oss.model.SetBucketTaggingRequest; |
167 | | -import com.aliyun.oss.model.SetBucketVersioningRequest; |
168 | | -import com.aliyun.oss.model.SetBucketWebsiteRequest; |
169 | | -import com.aliyun.oss.model.SetBucketPolicyRequest; |
170 | | -import com.aliyun.oss.model.GetBucketPolicyResult; |
171 | | -import com.aliyun.oss.model.TagSet; |
172 | | -import com.aliyun.oss.model.Style; |
173 | | -import com.aliyun.oss.model.UserQos; |
174 | | -import com.aliyun.oss.model.UserQosInfo; |
175 | | -import com.aliyun.oss.model.VersionListing; |
176 | | -import com.aliyun.oss.model.VoidResult; |
| 51 | +import com.aliyun.oss.model.*; |
177 | 52 | import org.apache.http.HttpStatus; |
178 | | -import com.aliyun.oss.model.SetAsyncFetchTaskRequest; |
179 | | -import com.aliyun.oss.model.SetAsyncFetchTaskResult; |
180 | | -import com.aliyun.oss.model.GetAsyncFetchTaskRequest; |
181 | | -import com.aliyun.oss.model.GetAsyncFetchTaskResult; |
182 | | -import com.aliyun.oss.model.AsyncFetchTaskConfiguration; |
183 | | -import com.aliyun.oss.model.CreateBucketVpcipRequest; |
184 | | -import com.aliyun.oss.model.CreateVpcipRequest; |
185 | | -import com.aliyun.oss.model.CreateVpcipResult; |
186 | | -import com.aliyun.oss.model.DeleteBucketVpcipRequest; |
187 | | -import com.aliyun.oss.model.DeleteVpcipRequest; |
188 | | -import com.aliyun.oss.model.VpcPolicy; |
189 | | -import com.aliyun.oss.model.Vpcip; |
190 | | -import com.aliyun.oss.model.SetBucketInventoryConfigurationRequest; |
191 | | -import com.aliyun.oss.model.GetBucketInventoryConfigurationRequest; |
192 | | -import com.aliyun.oss.model.GetBucketInventoryConfigurationResult; |
193 | | -import com.aliyun.oss.model.ListBucketInventoryConfigurationsRequest; |
194 | | -import com.aliyun.oss.model.ListBucketInventoryConfigurationsResult; |
195 | | -import com.aliyun.oss.model.DeleteBucketInventoryConfigurationRequest; |
196 | | -import com.aliyun.oss.model.ExtendBucketWormRequest; |
197 | | -import com.aliyun.oss.model.GetBucketWormResult; |
198 | | -import com.aliyun.oss.model.CompleteBucketWormRequest; |
199 | | -import com.aliyun.oss.model.InitiateBucketWormRequest; |
200 | | -import com.aliyun.oss.model.InitiateBucketWormResult; |
201 | | -import com.aliyun.oss.model.SetBucketResourceGroupRequest; |
202 | | -import com.aliyun.oss.model.GetBucketResourceGroupResult; |
203 | | -import com.aliyun.oss.model.TransferAcceleration; |
204 | | -import com.aliyun.oss.model.SetBucketTransferAccelerationRequest; |
205 | 53 |
|
206 | 54 | /** |
207 | 55 | * Bucket operation. |
@@ -1213,6 +1061,54 @@ public VoidResult deleteBucketCname(DeleteBucketCnameRequest deleteBucketCnameRe |
1213 | 1061 | return doOperation(request, requestIdResponseParser, bucketName, null); |
1214 | 1062 | } |
1215 | 1063 |
|
| 1064 | + public CreateBucketCnameTokenResult createBucketCnameToken(CreateBucketCnameTokenRequest createBucketCnameTokenRequest) |
| 1065 | + throws OSSException, ClientException { |
| 1066 | + |
| 1067 | + assertParameterNotNull(createBucketCnameTokenRequest, "createBucketCnameTokenRequest"); |
| 1068 | + assertParameterNotNull(createBucketCnameTokenRequest.getDomain(), "createBucketCnameTokenRequest.domain"); |
| 1069 | + |
| 1070 | + String bucketName = createBucketCnameTokenRequest.getBucketName(); |
| 1071 | + assertParameterNotNull(bucketName, "bucketName"); |
| 1072 | + ensureBucketNameValid(bucketName); |
| 1073 | + |
| 1074 | + Map<String, String> params = new HashMap<String, String>(); |
| 1075 | + params.put(RequestParameters.SUBRESOURCE_CNAME, null); |
| 1076 | + params.put(RequestParameters.SUBRESOURCE_COMP, RequestParameters.COMP_TOKEN); |
| 1077 | + |
| 1078 | + byte[] rawContent = createBucketCnameTokenRequestMarshaller.marshall(createBucketCnameTokenRequest); |
| 1079 | + Map<String, String> headers = new HashMap<String, String>(); |
| 1080 | + addRequestRequiredHeaders(headers, rawContent); |
| 1081 | + |
| 1082 | + RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint(createBucketCnameTokenRequest)) |
| 1083 | + .setMethod(HttpMethod.POST).setBucket(bucketName).setParameters(params).setHeaders(headers) |
| 1084 | + .setInputSize(rawContent.length).setInputStream(new ByteArrayInputStream(rawContent)) |
| 1085 | + .setOriginalRequest(createBucketCnameTokenRequest).build(); |
| 1086 | + |
| 1087 | + return doOperation(request, createBucketCnameTokenResponseParser, bucketName, null, true); |
| 1088 | + } |
| 1089 | + |
| 1090 | + public GetBucketCnameTokenResult getBucketCnameToken(GetBucketCnameTokenRequest getBucketCnameTokenRequest) |
| 1091 | + throws OSSException, ClientException { |
| 1092 | + |
| 1093 | + assertParameterNotNull(getBucketCnameTokenRequest, "getBucketCnameTokenRequest"); |
| 1094 | + assertParameterNotNull(getBucketCnameTokenRequest.getDomain(), "getBucketCnameTokenRequest.domain"); |
| 1095 | + |
| 1096 | + String bucketName = getBucketCnameTokenRequest.getBucketName(); |
| 1097 | + assertParameterNotNull(bucketName, "bucketName"); |
| 1098 | + ensureBucketNameValid(bucketName); |
| 1099 | + assertParameterNotNull(getBucketCnameTokenRequest.getDomain(), "bucketName"); |
| 1100 | + |
| 1101 | + Map<String, String> params = new HashMap<String, String>(); |
| 1102 | + params.put(RequestParameters.SUBRESOURCE_CNAME, getBucketCnameTokenRequest.getDomain()); |
| 1103 | + params.put(RequestParameters.SUBRESOURCE_COMP, RequestParameters.COMP_TOKEN); |
| 1104 | + |
| 1105 | + RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint(getBucketCnameTokenRequest)) |
| 1106 | + .setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(params) |
| 1107 | + .setOriginalRequest(getBucketCnameTokenRequest).build(); |
| 1108 | + |
| 1109 | + return doOperation(request, getBucketCnameTokenResponseParser, bucketName, null, true); |
| 1110 | + } |
| 1111 | + |
1216 | 1112 | public BucketInfo getBucketInfo(GenericRequest genericRequest) throws OSSException, ClientException { |
1217 | 1113 |
|
1218 | 1114 | assertParameterNotNull(genericRequest, "genericRequest"); |
|
0 commit comments