
com.aliyun.oss.common.parser.RequestMarshallers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliyun-sdk-oss-shade Show documentation
Show all versions of aliyun-sdk-oss-shade Show documentation
The Aliyun OSS SDK for Java used for accessing Aliyun Object Storage Service, includes all service and dependent JARs.
The newest version!
/*
* 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.common.parser;
import static com.aliyun.oss.internal.OSSConstants.DEFAULT_CHARSET_NAME;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.common.comm.io.FixedLengthInputStream;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.DateUtil;
import com.aliyun.oss.common.utils.StringUtils;
import com.aliyun.oss.internal.RequestParameters;
import com.aliyun.oss.model.*;
import com.aliyun.oss.model.AddBucketReplicationRequest.ReplicationAction;
import com.aliyun.oss.model.DeleteVersionsRequest.KeyVersion;
import com.aliyun.oss.model.LifecycleRule.AbortMultipartUpload;
import com.aliyun.oss.model.LifecycleRule.RuleStatus;
import com.aliyun.oss.model.LifecycleRule.StorageTransition;
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionStorageTransition;
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionExpiration;
import com.aliyun.oss.model.SetBucketCORSRequest.CORSRule;
/**
* A collection of marshallers that marshall HTTP request into crossponding
* input stream.
*/
public final class RequestMarshallers {
public static final StringMarshaller stringMarshaller = new StringMarshaller();
public static final DeleteObjectsRequestMarshaller deleteObjectsRequestMarshaller = new DeleteObjectsRequestMarshaller();
public static final DeleteVersionsRequestMarshaller deleteVersionsRequestMarshaller = new DeleteVersionsRequestMarshaller();
public static final CreateBucketRequestMarshaller createBucketRequestMarshaller = new CreateBucketRequestMarshaller();
public static final BucketRefererMarshaller bucketRefererMarshaller = new BucketRefererMarshaller();
public static final SetBucketLoggingRequestMarshaller setBucketLoggingRequestMarshaller = new SetBucketLoggingRequestMarshaller();
public static final SetBucketWebsiteRequestMarshaller setBucketWebsiteRequestMarshaller = new SetBucketWebsiteRequestMarshaller();
public static final SetBucketLifecycleRequestMarshaller setBucketLifecycleRequestMarshaller = new SetBucketLifecycleRequestMarshaller();
public static final PutBucketImageRequestMarshaller putBucketImageRequestMarshaller = new PutBucketImageRequestMarshaller();
public static final PutImageStyleRequestMarshaller putImageStyleRequestMarshaller = new PutImageStyleRequestMarshaller();
public static final BucketImageProcessConfMarshaller bucketImageProcessConfMarshaller = new BucketImageProcessConfMarshaller();
public static final SetBucketCORSRequestMarshaller setBucketCORSRequestMarshaller = new SetBucketCORSRequestMarshaller();
public static final SetBucketTaggingRequestMarshaller setBucketTaggingRequestMarshaller = new SetBucketTaggingRequestMarshaller();
public static final AddBucketReplicationRequestMarshaller addBucketReplicationRequestMarshaller = new AddBucketReplicationRequestMarshaller();
public static final DeleteBucketReplicationRequestMarshaller deleteBucketReplicationRequestMarshaller = new DeleteBucketReplicationRequestMarshaller();
public static final AddBucketCnameRequestMarshaller addBucketCnameRequestMarshaller = new AddBucketCnameRequestMarshaller();
public static final DeleteBucketCnameRequestMarshaller deleteBucketCnameRequestMarshaller = new DeleteBucketCnameRequestMarshaller();
public static final CreateBucketCnameTokenRequestMarshaller createBucketCnameTokenRequestMarshaller = new CreateBucketCnameTokenRequestMarshaller();
public static final SetBucketQosRequestMarshaller setBucketQosRequestMarshaller = new SetBucketQosRequestMarshaller();
public static final CompleteMultipartUploadRequestMarshaller completeMultipartUploadRequestMarshaller = new CompleteMultipartUploadRequestMarshaller();
public static final CreateLiveChannelRequestMarshaller createLiveChannelRequestMarshaller = new CreateLiveChannelRequestMarshaller();
public static final CreateUdfRequestMarshaller createUdfRequestMarshaller = new CreateUdfRequestMarshaller();
public static final CreateUdfApplicationRequestMarshaller createUdfApplicationRequestMarshaller = new CreateUdfApplicationRequestMarshaller();
public static final UpgradeUdfApplicationRequestMarshaller upgradeUdfApplicationRequestMarshaller = new UpgradeUdfApplicationRequestMarshaller();
public static final ResizeUdfApplicationRequestMarshaller resizeUdfApplicationRequestMarshaller = new ResizeUdfApplicationRequestMarshaller();
public static final ProcessObjectRequestMarshaller processObjectRequestMarshaller = new ProcessObjectRequestMarshaller();
public static final SetBucketVersioningRequestMarshaller setBucketVersioningRequestMarshaller = new SetBucketVersioningRequestMarshaller();
public static final SetBucketEncryptionRequestMarshaller setBucketEncryptionRequestMarshaller = new SetBucketEncryptionRequestMarshaller();
public static final SetBucketPolicyRequestMarshaller setBucketPolicyRequestMarshaller = new SetBucketPolicyRequestMarshaller();
public static final SetBucketRequestPaymentRequestMarshaller setBucketRequestPaymentRequestMarshaller = new SetBucketRequestPaymentRequestMarshaller();
public static final SetBucketQosInfoRequestMarshaller setBucketQosInfoRequestMarshaller = new SetBucketQosInfoRequestMarshaller();
public static final SetAsyncFetchTaskRequestMarshaller setAsyncFetchTaskRequestMarshaller = new SetAsyncFetchTaskRequestMarshaller();
public static final SetBucketInventoryRequestMarshaller setBucketInventoryRequestMarshaller = new SetBucketInventoryRequestMarshaller();
public static final RestoreObjectRequestMarshaller restoreObjectRequestMarshaller = new RestoreObjectRequestMarshaller();
public static final ExtendBucketWormRequestMarshaller extendBucketWormRequestMarshaller = new ExtendBucketWormRequestMarshaller();
public static final InitiateBucketWormRequestMarshaller initiateBucketWormRequestMarshaller = new InitiateBucketWormRequestMarshaller();
public static final CreateSelectObjectMetadataRequestMarshaller createSelectObjectMetadataRequestMarshaller = new CreateSelectObjectMetadataRequestMarshaller();
public static final SelectObjectRequestMarshaller selectObjectRequestMarshaller = new SelectObjectRequestMarshaller();
public static final CreateVpcipRequestMarshaller createVpcipRequestMarshaller = new CreateVpcipRequestMarshaller();
public static final CreateBucketVpcipRequestMarshaller createBucketVpcipRequestMarshaller = new CreateBucketVpcipRequestMarshaller();
public static final DeleteVpcipRequestMarshaller deleteVpcipRequestMarshaller = new DeleteVpcipRequestMarshaller();
public static final DeleteBucketVpcipRequestMarshaller deleteBucketVpcipRequestMarshaller = new DeleteBucketVpcipRequestMarshaller();
public static final SetBucketResourceGroupRequestMarshaller setBucketResourceGroupRequestMarshaller = new SetBucketResourceGroupRequestMarshaller();
public static final PutBucketTransferAccelerationRequestMarshaller putBucketTransferAccelerationRequestMarshaller = new PutBucketTransferAccelerationRequestMarshaller();
public static final PutBucketAccessMonitorRequestMarshaller putBucketAccessMonitorRequestMarshaller = new PutBucketAccessMonitorRequestMarshaller();
public static final DoMetaQueryRequestMarshaller doMetaQueryRequestMarshaller = new DoMetaQueryRequestMarshaller();
public static final SetBucketCallbackPolicyRequestMarshaller setBucketCallbackPolicyRequestMarshaller = new SetBucketCallbackPolicyRequestMarshaller();
public static final AsyncProcessObjectRequestMarshaller asyncProcessObjectRequestMarshaller = new AsyncProcessObjectRequestMarshaller();
public static final PutBucketArchiveDirectReadRequestMarshaller putBucketArchiveDirectReadRequestMarshaller = new PutBucketArchiveDirectReadRequestMarshaller();
public static final PutBucketHttpsConfigRequestMarshaller putBucketHttpsConfigRequestMarshaller = new PutBucketHttpsConfigRequestMarshaller();
public static final PutPublicAccessBlockRequestMarshaller putPublicAccessBlockRequestMarshaller = new PutPublicAccessBlockRequestMarshaller();
public static final PutBucketPublicAccessBlockRequestMarshaller putBucketPublicAccessBlockRequestMarshaller = new PutBucketPublicAccessBlockRequestMarshaller();
public static final CreateAccessPointRequestParser createAccessPointRequestParser = new CreateAccessPointRequestParser();
public static final PutAccessPointPolicyRequestParser putAccessPointPolicyRequestParser = new PutAccessPointPolicyRequestParser();
public interface RequestMarshaller extends Marshaller {
}
public interface RequestMarshaller2 extends Marshaller {
}
public static final class StringMarshaller implements Marshaller {
@Override
public FixedLengthInputStream marshall(String input) {
if (input == null) {
throw new IllegalArgumentException("The input should not be null.");
}
byte[] binaryData = null;
try {
binaryData = input.getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
long length = binaryData.length;
InputStream instream = new ByteArrayInputStream(binaryData);
return new FixedLengthInputStream(instream, length);
}
}
public static final class PutImageStyleRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(PutImageStyleRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class BucketImageProcessConfMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(ImageProcess imageProcessConf) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + imageProcessConf.getCompliedHost() + " ");
if (imageProcessConf.isSourceFileProtect() != null
&& imageProcessConf.isSourceFileProtect().booleanValue()) {
xmlBody.append("Enabled ");
} else {
xmlBody.append("Disabled ");
}
xmlBody.append("" + imageProcessConf.getSourceFileProtectSuffix()
+ " ");
xmlBody.append("" + imageProcessConf.getStyleDelimiters() + " ");
if (imageProcessConf.isSupportAtStyle() != null && imageProcessConf.isSupportAtStyle().booleanValue()) {
xmlBody.append("Enabled ");
} else {
xmlBody.append("Disabled ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class PutBucketImageRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(PutBucketImageRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (request.GetIsForbidOrigPicAccess()) {
xmlBody.append("true ");
} else {
xmlBody.append("false ");
}
if (request.GetIsUseStyleOnly()) {
xmlBody.append("true ");
} else {
xmlBody.append("false ");
}
if (request.GetIsAutoSetContentType()) {
xmlBody.append("true ");
} else {
xmlBody.append("false ");
}
if (request.GetIsUseSrcFormat()) {
xmlBody.append("true ");
} else {
xmlBody.append("false ");
}
if (request.GetIsSetAttachName()) {
xmlBody.append("true ");
} else {
xmlBody.append("false ");
}
xmlBody.append("" + request.GetDefault404Pic() + " ");
xmlBody.append("" + request.GetStyleDelimiters() + " ");
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class CreateBucketRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(CreateBucketRequest request) {
StringBuffer xmlBody = new StringBuffer();
if (request.getLocationConstraint() != null
|| request.getStorageClass() != null
|| request.getDataRedundancyType() != null) {
xmlBody.append("");
if (request.getLocationConstraint() != null) {
xmlBody.append("" + request.getLocationConstraint() + " ");
}
if (request.getStorageClass() != null) {
xmlBody.append("" + request.getStorageClass().toString() + " ");
}
if (request.getDataRedundancyType() != null) {
xmlBody.append("" + request.getDataRedundancyType().toString() + " ");
}
if (request.getXcType() != null) {
xmlBody.append("" + request.getXcType() + " ");
}
xmlBody.append(" ");
}
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class BucketRefererMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(BucketReferer br) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + br.isAllowEmptyReferer() + " ");
if (!br.getRefererList().isEmpty()) {
xmlBody.append("");
for (String referer : br.getRefererList()) {
xmlBody.append("" + referer + " ");
}
xmlBody.append(" ");
} else {
xmlBody.append(" ");
}
if(br.isAllowTruncateQueryString() != null){
xmlBody.append("" + br.isAllowTruncateQueryString() + " ");
}
if (br.getBlackRefererList() != null && !br.getBlackRefererList().isEmpty()) {
xmlBody.append("");
for (String referer : br.getBlackRefererList()) {
xmlBody.append("" + referer + " ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class SetBucketLoggingRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(SetBucketLoggingRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (request.getTargetBucket() != null) {
xmlBody.append("");
xmlBody.append("" + request.getTargetBucket() + " ");
if (request.getTargetPrefix() != null) {
xmlBody.append("" + request.getTargetPrefix() + " ");
}
xmlBody.append(" ");
} else {
// Nothing to do here, user attempt to close bucket logging
// functionality
// by setting an empty BucketLoggingStatus entity.
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class SetBucketWebsiteRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(SetBucketWebsiteRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (request.getIndexDocument() != null) {
xmlBody.append("");
xmlBody.append("" + request.getIndexDocument() + " ");
if(request.isSupportSubDir()) {
xmlBody.append("" + request.isSupportSubDir() + " ");
if (request.getSubDirType() != null) {
xmlBody.append("" + request.getSubDirType().toString() + " ");
}
}
xmlBody.append(" ");
}
if (request.getErrorDocument() != null) {
xmlBody.append("");
xmlBody.append("" + request.getErrorDocument() + " ");
if (request.getHttpStatus() != null) {
xmlBody.append("" + request.getHttpStatus() + " ");
}
xmlBody.append(" ");
}
// RoutingRules可以没有
if (request.getRoutingRules().size() > 0) {
xmlBody.append("");
for (RoutingRule routingRule : request.getRoutingRules()) {
xmlBody.append("");
xmlBody.append("" + routingRule.getNumber() + " ");
// Condition字句可以没有,如果有至少有一个条件
RoutingRule.Condition condition = routingRule.getCondition();
if (condition.getKeyPrefixEquals() != null || condition.getHttpErrorCodeReturnedEquals() > 0) {
xmlBody.append("");
if (condition.getKeyPrefixEquals() != null) {
xmlBody.append("" + escapeKey(condition.getKeyPrefixEquals())
+ " ");
}
// add KeySuffixEquals
if (condition.getKeySuffixEquals() != null) {
xmlBody.append("" + escapeKey(condition.getKeySuffixEquals())
+ " ");
}
if (condition.getHttpErrorCodeReturnedEquals() != null) {
xmlBody.append("" + condition.getHttpErrorCodeReturnedEquals()
+ " ");
}
if (condition.getIncludeHeaders() != null && condition.getIncludeHeaders().size() > 0) {
for (RoutingRule.IncludeHeader includeHeader : condition.getIncludeHeaders()) {
xmlBody.append("");
if (includeHeader.getKey() != null) {
xmlBody.append("" + includeHeader.getKey() + " ");
}
if (includeHeader.getEquals() != null) {
xmlBody.append("" + includeHeader.getEquals() + " ");
}
if (includeHeader.getStartsWith() != null) {
xmlBody.append("" + includeHeader.getStartsWith() + " ");
}
if (includeHeader.getEndsWith() != null) {
xmlBody.append("" + includeHeader.getEndsWith() + " ");
}
xmlBody.append(" ");
}
}
xmlBody.append(" ");
}
// Redirect子句必须存在
RoutingRule.Redirect redirect = routingRule.getRedirect();
xmlBody.append("");
if (redirect.getRedirectType() != null) {
xmlBody.append("" + redirect.getRedirectType().toString() + " ");
}
if (redirect.getHostName() != null) {
xmlBody.append("" + redirect.getHostName() + " ");
}
if (redirect.getProtocol() != null) {
xmlBody.append("" + redirect.getProtocol().toString() + " ");
}
if (redirect.getReplaceKeyPrefixWith() != null) {
xmlBody.append("" + escapeKey(redirect.getReplaceKeyPrefixWith())
+ " ");
}
if (redirect.getReplaceKeyWith() != null) {
xmlBody.append(
"" + escapeKey(redirect.getReplaceKeyWith()) + " ");
}
if (redirect.getHttpRedirectCode() != null) {
xmlBody.append("" + redirect.getHttpRedirectCode() + " ");
}
if (redirect.getMirrorURL() != null) {
xmlBody.append("" + redirect.getMirrorURL() + " ");
}
if(redirect.getMirrorTunnelId() != null) {
xmlBody.append("" + redirect.getMirrorTunnelId() + " ");
}
if (redirect.getMirrorMultiAlternates() != null && redirect.getMirrorMultiAlternates().size() > 0) {
xmlBody.append("");
for (int i = 0; i < redirect.getMirrorMultiAlternates().size(); i++) {
RoutingRule.Redirect.MirrorMultiAlternate mirrorMultiAlternate = redirect.getMirrorMultiAlternates().get(i);
if (mirrorMultiAlternate != null && mirrorMultiAlternate.getUrl() != null) {
xmlBody.append("");
xmlBody.append("");
xmlBody.append(mirrorMultiAlternate.getPrior());
xmlBody.append(" ");
xmlBody.append("");
xmlBody.append(mirrorMultiAlternate.getUrl());
xmlBody.append(" ");
xmlBody.append(" ");
}
}
xmlBody.append(" ");
}
if (redirect.getMirrorSecondaryURL() != null) {
xmlBody.append("" + redirect.getMirrorSecondaryURL() + " ");
}
if (redirect.getMirrorProbeURL() != null) {
xmlBody.append("" + redirect.getMirrorProbeURL() + " ");
}
if (redirect.isMirrorPassQueryString() != null) {
xmlBody.append(
"" + redirect.isMirrorPassQueryString() + " ");
}
if (redirect.isPassOriginalSlashes() != null) {
xmlBody.append("" + redirect.isPassOriginalSlashes()
+ " ");
}
if (redirect.isPassQueryString() != null) {
xmlBody.append("" + redirect.isPassQueryString()
+ " ");
}
// add EnableReplacePrefix and MirrorSwitchAllErrors
if (redirect.isEnableReplacePrefix() != null) {
xmlBody.append("" + redirect.isEnableReplacePrefix()
+ " ");
}
if (redirect.isMirrorSwitchAllErrors() != null) {
xmlBody.append("" + redirect.isMirrorSwitchAllErrors()
+ " ");
}
if (redirect.isMirrorCheckMd5() != null) {
xmlBody.append("" + redirect.isMirrorCheckMd5()
+ " ");
}
if (redirect.isMirrorFollowRedirect() != null) {
xmlBody.append("" + redirect.isMirrorFollowRedirect()
+ " ");
}
if (redirect.isMirrorUserLastModified() != null) {
xmlBody.append("" + redirect.isMirrorUserLastModified()
+ " ");
}
if (redirect.isMirrorIsExpressTunnel() != null) {
xmlBody.append("" + redirect.isMirrorIsExpressTunnel()
+ " ");
}
if (redirect.getMirrorDstRegion() != null) {
xmlBody.append("" + redirect.getMirrorDstRegion()
+ " ");
}
if (redirect.getMirrorDstVpcId() != null) {
xmlBody.append("" + redirect.getMirrorDstVpcId()
+ " ");
}
if (redirect.isMirrorUsingRole() != null) {
xmlBody.append("" + redirect.isMirrorUsingRole() + " ");
}
if (redirect.getMirrorRole() != null) {
xmlBody.append("" + redirect.getMirrorRole() + " ");
}
if (redirect.getMirrorHeaders() != null) {
xmlBody.append("");
RoutingRule.MirrorHeaders mirrorHeaders = redirect.getMirrorHeaders();
xmlBody.append("" + mirrorHeaders.isPassAll() + " ");
if (mirrorHeaders.getPass() != null && mirrorHeaders.getPass().size() > 0) {
for (String pass : mirrorHeaders.getPass()) {
xmlBody.append("" + pass + " ");
}
}
if (mirrorHeaders.getRemove() != null && mirrorHeaders.getRemove().size() > 0) {
for (String remove : mirrorHeaders.getRemove()) {
xmlBody.append("" + remove + " ");
}
}
if (mirrorHeaders.getSet() != null && mirrorHeaders.getSet().size() > 0) {
for (Map setMap : mirrorHeaders.getSet()) {
xmlBody.append("");
xmlBody.append("" + setMap.get("Key") + " ");
xmlBody.append("" + setMap.get("Value") + " ");
xmlBody.append(" ");
}
}
xmlBody.append(" ");
}
xmlBody.append(" ");
xmlBody.append(" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class SetBucketLifecycleRequestMarshaller
implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(SetBucketLifecycleRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
for (LifecycleRule rule : request.getLifecycleRules()) {
xmlBody.append("");
if (rule.getId() != null) {
xmlBody.append("" + rule.getId() + " ");
}
if (rule.getPrefix() != null) {
xmlBody.append("" + rule.getPrefix() + " ");
} else {
xmlBody.append(" ");
}
if (rule.hasTags()) {
for (Map.Entry tag : rule.getTags().entrySet()) {
xmlBody.append("");
xmlBody.append("" + tag.getKey() + " ");
xmlBody.append("" + tag.getValue() + " ");
xmlBody.append(" ");
}
}
if(rule.getFilter() != null){
xmlBody.append("");
if (rule.getFilter().getObjectSizeGreaterThan() != null) {
xmlBody.append("").append(rule.getFilter().getObjectSizeGreaterThan()).append(" ");
}
if (rule.getFilter().getObjectSizeLessThan() != null) {
xmlBody.append("").append(rule.getFilter().getObjectSizeLessThan()).append(" ");
}
for(LifecycleNot not : rule.getFilter().getNotList()){
xmlBody.append("");
xmlBody.append("" + not.getPrefix() + " ");
if(not.getTag() != null){
xmlBody.append("");
xmlBody.append("" + not.getTag().getKey() + " ");
xmlBody.append("" + not.getTag().getValue() + " ");
xmlBody.append(" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
}
if (rule.getStatus() == RuleStatus.Enabled) {
xmlBody.append("Enabled ");
} else {
xmlBody.append("Disabled ");
}
if (rule.getExpirationTime() != null) {
String formatDate = DateUtil.formatIso8601Date(rule.getExpirationTime());
xmlBody.append("" + formatDate + " ");
} else if (rule.getExpirationDays() != 0) {
xmlBody.append("" + rule.getExpirationDays() + " ");
} else if (rule.getCreatedBeforeDate() != null) {
String formatDate = DateUtil.formatIso8601Date(rule.getCreatedBeforeDate());
xmlBody.append(
"" + formatDate + " ");
} else if (rule.getExpiredDeleteMarker() != null) {
xmlBody.append("" + rule.getExpiredDeleteMarker() +
" ");
}
if (rule.hasAbortMultipartUpload()) {
AbortMultipartUpload abortMultipartUpload = rule.getAbortMultipartUpload();
if (abortMultipartUpload.getExpirationDays() != 0) {
xmlBody.append("" + abortMultipartUpload.getExpirationDays()
+ " ");
} else {
String formatDate = DateUtil.formatIso8601Date(abortMultipartUpload.getCreatedBeforeDate());
xmlBody.append("" + formatDate
+ " ");
}
}
if (rule.hasStorageTransition()) {
for (StorageTransition storageTransition : rule.getStorageTransition()) {
xmlBody.append("");
if (storageTransition.hasExpirationDays()) {
xmlBody.append("" + storageTransition.getExpirationDays() + " ");
} else if (storageTransition.hasCreatedBeforeDate()) {
String formatDate = DateUtil.formatIso8601Date(storageTransition.getCreatedBeforeDate());
xmlBody.append("" + formatDate + " ");
}
if (storageTransition.hasIsAccessTime()) {
xmlBody.append("" + storageTransition.getIsAccessTime() + " ");
}
if (storageTransition.hasReturnToStdWhenVisit()) {
xmlBody.append("" + storageTransition.getReturnToStdWhenVisit() + " ");
}
if (storageTransition.hasAllowSmallFile()) {
xmlBody.append("" + storageTransition.getAllowSmallFile() + " ");
}
xmlBody.append("" + storageTransition.getStorageClass() + " ");
xmlBody.append(" ");
}
}
if (rule.hasNoncurrentVersionExpiration()) {
NoncurrentVersionExpiration expiration = rule.getNoncurrentVersionExpiration();
if (expiration.hasNoncurrentDays()) {
xmlBody.append("" + expiration.getNoncurrentDays() +
" ");
}
}
if (rule.hasNoncurrentVersionStorageTransitions()) {
for (NoncurrentVersionStorageTransition transition : rule.getNoncurrentVersionStorageTransitions()) {
xmlBody.append("");
xmlBody.append("" + transition.getNoncurrentDays() + " ");
if (transition.hasIsAccessTime()) {
xmlBody.append("" + transition.getIsAccessTime() + " ");
}
if (transition.hasReturnToStdWhenVisit()) {
xmlBody.append("" + transition.getReturnToStdWhenVisit() + " ");
}
if (transition.hasAllowSmallFile()) {
xmlBody.append("" + transition.getAllowSmallFile() + " ");
}
xmlBody.append("" + transition.getStorageClass() + " ");
xmlBody.append(" ");
}
}
xmlBody.append(" ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class SetBucketCORSRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(SetBucketCORSRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
for (CORSRule rule : request.getCorsRules()) {
xmlBody.append("");
for (String allowedOrigin : rule.getAllowedOrigins()) {
xmlBody.append("" + allowedOrigin + " ");
}
for (String allowedMethod : rule.getAllowedMethods()) {
xmlBody.append("" + allowedMethod + " ");
}
if (rule.getAllowedHeaders().size() > 0) {
for (String allowedHeader : rule.getAllowedHeaders()) {
xmlBody.append("" + allowedHeader + " ");
}
}
if (rule.getExposeHeaders().size() > 0) {
for (String exposeHeader : rule.getExposeHeaders()) {
xmlBody.append("" + exposeHeader + " ");
}
}
if (null != rule.getMaxAgeSeconds()) {
xmlBody.append("" + rule.getMaxAgeSeconds() + " ");
}
xmlBody.append(" ");
}
if (null != request.getResponseVary()) {
xmlBody.append("" + request.getResponseVary() + " ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class CompleteMultipartUploadRequestMarshaller
implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(CompleteMultipartUploadRequest request) {
StringBuffer xmlBody = new StringBuffer();
List eTags = request.getPartETags();
xmlBody.append("");
for (int i = 0; i < eTags.size(); i++) {
PartETag part = eTags.get(i);
String eTag = EscapedChar.QUOT + part.getETag().replace("\"", "") + EscapedChar.QUOT;
xmlBody.append("");
xmlBody.append("" + part.getPartNumber() + " ");
xmlBody.append("" + eTag + " ");
xmlBody.append(" ");
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class CreateSelectObjectMetadataRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateSelectObjectMetadataRequest request) {
StringBuilder xmlBody = new StringBuilder();
InputSerialization inputSerialization = request.getInputSerialization();
CSVFormat csvFormat = inputSerialization.getCsvInputFormat();
JsonFormat jsonFormat = inputSerialization.getJsonInputFormat();
if (inputSerialization.getSelectContentFormat() == SelectContentFormat.CSV) {
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + inputSerialization.getCompressionType() + " ");
xmlBody.append("");
xmlBody.append("" + BinaryUtil.toBase64String(csvFormat.getRecordDelimiter().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvFormat.getFieldDelimiter().toString().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvFormat.getQuoteChar().toString().getBytes()) + " ");
xmlBody.append(" ");
xmlBody.append(" ");
xmlBody.append("" + request.isOverwrite() + " ");
xmlBody.append(" ");
} else {
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + inputSerialization.getCompressionType() + " ");
xmlBody.append("");
xmlBody.append("" + jsonFormat.getJsonType().name() + " ");
xmlBody.append(" ");
xmlBody.append(" ");
xmlBody.append("" + request.isOverwrite() + " ");
xmlBody.append(" ");
}
try {
return xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
}
}
private static void populateSelectRange(StringBuilder xmlBody, SelectObjectRequest request) {
if (request.getLineRange() != null) {
xmlBody.append("" + request.lineRangeToString(request.getLineRange()) + " ");
}
if (request.getSplitRange() != null) {
xmlBody.append("" + request.splitRangeToString(request.getSplitRange()) + " ");
}
}
private static void populateSelectJsonObjectRequest(StringBuilder xmlBody, SelectObjectRequest request) {
InputSerialization inputSerialization = request.getInputSerialization();
JsonFormat jsonInputFormat = inputSerialization.getJsonInputFormat();
xmlBody.append("");
xmlBody.append("" + inputSerialization.getCompressionType() + " ");
xmlBody.append("");
xmlBody.append("" + jsonInputFormat.getJsonType().name() + " ");
xmlBody.append("" + jsonInputFormat.isParseJsonNumberAsString() + " ");
populateSelectRange(xmlBody, request);
xmlBody.append(" ");
xmlBody.append(" ");
OutputSerialization outputSerialization = request.getOutputSerialization();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + BinaryUtil.toBase64String(outputSerialization.getJsonOutputFormat().getRecordDelimiter().getBytes()) + " ");
xmlBody.append(" ");
xmlBody.append("" + outputSerialization.isOutputRawData() + " ");
xmlBody.append("" + outputSerialization.isPayloadCrcEnabled() + " ");
xmlBody.append(" ");
}
private static void populateSelectCsvObjectRequest(StringBuilder xmlBody, SelectObjectRequest request) {
InputSerialization inputSerialization = request.getInputSerialization();
CSVFormat csvInputFormat = inputSerialization.getCsvInputFormat();
xmlBody.append("");
xmlBody.append("" + inputSerialization.getCompressionType() + " ");
xmlBody.append("");
xmlBody.append("" + csvInputFormat.getHeaderInfo() + " ");
xmlBody.append("" + csvInputFormat.isAllowQuotedRecordDelimiter() + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvInputFormat.getRecordDelimiter().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvInputFormat.getFieldDelimiter().toString().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvInputFormat.getQuoteChar().toString().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(csvInputFormat.getCommentChar().toString().getBytes()) + " ");
populateSelectRange(xmlBody, request);
xmlBody.append(" ");
xmlBody.append(" ");
OutputSerialization outputSerialization = request.getOutputSerialization();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + BinaryUtil.toBase64String(outputSerialization.getCsvOutputFormat().getRecordDelimiter().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(outputSerialization.getCsvOutputFormat().getFieldDelimiter().toString().getBytes()) + " ");
xmlBody.append("" + BinaryUtil.toBase64String(outputSerialization.getCsvOutputFormat().getQuoteChar().toString().getBytes()) + " ");
xmlBody.append(" ");
xmlBody.append("" + outputSerialization.isKeepAllColumns() + " ");
xmlBody.append("" + outputSerialization.isOutputHeader() + " ");
xmlBody.append("" + outputSerialization.isOutputRawData() + " ");
xmlBody.append("" + outputSerialization.isPayloadCrcEnabled() + " ");
xmlBody.append(" ");
}
public static final class SelectObjectRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(SelectObjectRequest request) {
StringBuilder xmlBody = new StringBuilder();
xmlBody.append("");
xmlBody.append("" + BinaryUtil.toBase64String(request.getExpression().getBytes()) + " ");
xmlBody.append("");
xmlBody.append("" + request.isSkipPartialDataRecord() + " ");
if (request.getMaxSkippedRecordsAllowed() > 0) {
xmlBody.append("" + request.getMaxSkippedRecordsAllowed() + " ");
}
xmlBody.append(" ");
InputSerialization inputSerialization = request.getInputSerialization();
SelectContentFormat selectContentFormat = inputSerialization.getSelectContentFormat();
if (selectContentFormat == SelectContentFormat.JSON) {
populateSelectJsonObjectRequest(xmlBody, request);
} else {
populateSelectCsvObjectRequest(xmlBody, request);
}
xmlBody.append(" ");
try {
return xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
}
}
public static final class DeleteObjectsRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(DeleteObjectsRequest request) {
StringBuffer xmlBody = new StringBuffer();
boolean quiet = request.isQuiet();
List keysToDelete = request.getKeys();
xmlBody.append("");
xmlBody.append("" + quiet + " ");
for (int i = 0; i < keysToDelete.size(); i++) {
String key = keysToDelete.get(i);
xmlBody.append("");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class DeleteVersionsRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(DeleteVersionsRequest request) {
StringBuffer xmlBody = new StringBuffer();
boolean quiet = request.getQuiet();
List keysToDelete = request.getKeys();
xmlBody.append("");
xmlBody.append("" + quiet + " ");
for (int i = 0; i < keysToDelete.size(); i++) {
KeyVersion key = keysToDelete.get(i);
xmlBody.append("");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketTaggingRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(SetTaggingRequest request) {
StringBuffer xmlBody = new StringBuffer();
TagSet tagSet = request.getTagSet();
xmlBody.append("");
Map tags = tagSet.getAllTags();
if (!tags.isEmpty()) {
for (Map.Entry tag : tags.entrySet()) {
xmlBody.append("");
xmlBody.append("" + tag.getKey() + " ");
xmlBody.append("" + tag.getValue() + " ");
xmlBody.append(" ");
}
}
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class AddBucketReplicationRequestMarshaller
implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(AddBucketReplicationRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + escapeKey(request.getReplicationRuleID()) + " ");
xmlBody.append("");
xmlBody.append("" + request.getTargetBucketName() + " ");
if (request.getTargetBucketLocation() != null) {
xmlBody.append("" + request.getTargetBucketLocation() + " ");
} else if (request.getTargetCloud() != null && request.getTargetCloudLocation() != null) {
xmlBody.append("" + request.getTargetCloud() + " ");
xmlBody.append("" + request.getTargetCloudLocation() + " ");
}
xmlBody.append(" ");
if (request.isEnableHistoricalObjectReplication()) {
xmlBody.append("" + "enabled" + " ");
} else {
xmlBody.append("" + "disabled" + " ");
}
if (request.getObjectPrefixList() != null && request.getObjectPrefixList().size() > 0) {
xmlBody.append("");
for (String prefix : request.getObjectPrefixList()) {
xmlBody.append("" + prefix + " ");
}
xmlBody.append(" ");
}
if (request.getReplicationActionList() != null && request.getReplicationActionList().size() > 0) {
xmlBody.append("" + RequestMarshallers.joinRepliationAction(request.getReplicationActionList())
+ " ");
}
if (request.getSyncRole() != null) {
xmlBody.append("" + request.getSyncRole() + " ");
}
if (request.getReplicaKmsKeyID() != null) {
xmlBody.append("");
xmlBody.append("" + request.getReplicaKmsKeyID() + " ");
xmlBody.append(" ");
}
if (request.ENABLED.equals(request.getSseKmsEncryptedObjectsStatus()) ||
request.DISABLED.equals(request.getSseKmsEncryptedObjectsStatus())) {
xmlBody.append("");
xmlBody.append("" + request.getSseKmsEncryptedObjectsStatus() + " ");
xmlBody.append(" ");
}
if (request.getSourceBucketLocation() != null) {
xmlBody.append("");
xmlBody.append("" + request.getSourceBucketLocation() + " ");
xmlBody.append(" ");
}
xmlBody.append(" ");
xmlBody.append(" ");
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class DeleteBucketReplicationRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(DeleteBucketReplicationRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + escapeKey(request.getReplicationRuleID()) + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class AddBucketCnameRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(AddBucketCnameRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + request.getDomain() + " ");
if (request.getCertificateConfiguration() != null) {
CertificateConfiguration certConf = request.getCertificateConfiguration();
xmlBody.append("");
if (certConf.getId() != null) {
xmlBody.append("");
xmlBody.append(certConf.getId());
xmlBody.append(" ");
}
if (certConf.getPreviousId() != null) {
xmlBody.append("");
xmlBody.append(escapeKey(certConf.getPreviousId()));
xmlBody.append(" ");
}
if (certConf.getPublicKey() != null) {
xmlBody.append("");
xmlBody.append(escapeKey(certConf.getPublicKey()));
xmlBody.append(" ");
}
if (certConf.getPrivateKey() != null) {
xmlBody.append("");
xmlBody.append(escapeKey(certConf.getPrivateKey()));
xmlBody.append(" ");
}
if (certConf.isForceOverwriteCert()) {
xmlBody.append("true ");
}
if (certConf.getDeleteCertificate() != null) {
xmlBody.append("" + certConf.getDeleteCertificate().toString() + " ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class DeleteBucketCnameRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(DeleteBucketCnameRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + request.getDomain() + " ");
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateBucketCnameTokenRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateBucketCnameTokenRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + request.getDomain() + " ");
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketQosRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(UserQos userQos) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (userQos.hasStorageCapacity()) {
xmlBody.append("" + userQos.getStorageCapacity() + " ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketVersioningRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(SetBucketVersioningRequest setBucketVersioningRequest) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody
.append("" + setBucketVersioningRequest.getVersioningConfiguration().getStatus() + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketEncryptionRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(SetBucketEncryptionRequest setBucketEncryptionRequest) {
StringBuffer xmlBody = new StringBuffer();
ServerSideEncryptionConfiguration sseConfig =
setBucketEncryptionRequest.getServerSideEncryptionConfiguration();
ServerSideEncryptionByDefault sseByDefault = sseConfig.getApplyServerSideEncryptionByDefault();
xmlBody.append("");
xmlBody.append("");
xmlBody.append("" + sseByDefault.getSSEAlgorithm() + " ");
if (sseByDefault.getKMSMasterKeyID() != null) {
xmlBody.append("" + sseByDefault.getKMSMasterKeyID() + " ");
} else {
xmlBody.append(" ");
}
if (sseByDefault.getKMSDataEncryption() != null) {
xmlBody.append("" + sseByDefault.getKMSDataEncryption() + " ");
}
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketPolicyRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(SetBucketPolicyRequest setBucketPolicyRequest) {
byte[] rawData = null;
try {
rawData = setBucketPolicyRequest.getPolicyText().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateLiveChannelRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateLiveChannelRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getLiveChannelDescription() + " ");
xmlBody.append("" + request.getLiveChannelStatus() + " ");
LiveChannelTarget target = request.getLiveChannelTarget();
xmlBody.append("");
xmlBody.append("" + target.getType() + " ");
xmlBody.append("" + target.getFragDuration() + " ");
xmlBody.append("" + target.getFragCount() + " ");
xmlBody.append("" + target.getPlaylistName() + " ");
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketRequestPaymentRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(String payer) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" +payer + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketQosInfoRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(BucketQosInfo bucketQosInfo) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (bucketQosInfo.getTotalUploadBw() != null) {
xmlBody.append("" +bucketQosInfo.getTotalUploadBw() + " ");
}
if (bucketQosInfo.getIntranetUploadBw() != null) {
xmlBody.append("" +bucketQosInfo.getIntranetUploadBw() + " ");
}
if (bucketQosInfo.getExtranetUploadBw() != null) {
xmlBody.append("" +bucketQosInfo.getExtranetUploadBw() + " ");
}
if (bucketQosInfo.getTotalDownloadBw() != null) {
xmlBody.append("" +bucketQosInfo.getTotalDownloadBw() + " ");
}
if (bucketQosInfo.getIntranetDownloadBw() != null) {
xmlBody.append("" +bucketQosInfo.getIntranetDownloadBw() + " ");
}
if (bucketQosInfo.getExtranetDownloadBw() != null) {
xmlBody.append("" +bucketQosInfo.getExtranetDownloadBw() + " ");
}
if (bucketQosInfo.getTotalQps() != null) {
xmlBody.append("" +bucketQosInfo.getTotalQps() + " ");
}
if (bucketQosInfo.getIntranetQps() != null) {
xmlBody.append("" +bucketQosInfo.getIntranetQps() + " ");
}
if (bucketQosInfo.getExtranetQps() != null) {
xmlBody.append("" +bucketQosInfo.getExtranetQps() + " ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetAsyncFetchTaskRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(AsyncFetchTaskConfiguration asyncFetchTaskConfiguration) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (asyncFetchTaskConfiguration.getUrl() != null) {
xmlBody.append("" + escapeKey(asyncFetchTaskConfiguration.getUrl()) + " ");
}
if (asyncFetchTaskConfiguration.getObjectName() != null) {
xmlBody.append("");
}
if (asyncFetchTaskConfiguration.getHost() != null) {
xmlBody.append("" + asyncFetchTaskConfiguration.getHost() + " ");
}
if (asyncFetchTaskConfiguration.getContentMd5() != null) {
xmlBody.append("" + asyncFetchTaskConfiguration.getContentMd5() + " ");
}
if (asyncFetchTaskConfiguration.getCallback() != null) {
xmlBody.append("" + asyncFetchTaskConfiguration.getCallback() + " ");
}
if (asyncFetchTaskConfiguration.getIgnoreSameKey() != null) {
xmlBody.append("" + asyncFetchTaskConfiguration.getIgnoreSameKey() + " ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketInventoryRequestMarshaller implements
RequestMarshaller2 {
@Override
public byte[] marshall(InventoryConfiguration config) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if (config.getInventoryId() != null) {
xmlBody.append("" + config.getInventoryId() + " ");
}
if(config.isEnabled() != null) {
xmlBody.append("" + config.isEnabled() + " ");
}
if (config.getIncludedObjectVersions() != null) {
xmlBody.append("" + config.getIncludedObjectVersions() + " ");
}
if (config.getInventoryFilter() != null) {
if (config.getInventoryFilter().getPrefix() != null) {
xmlBody.append("");
xmlBody.append("" +config.getInventoryFilter().getPrefix() + " ");
if(config.getInventoryFilter().getLastModifyBeginTimeStamp() != null){
xmlBody.append("" +config.getInventoryFilter().getLastModifyBeginTimeStamp() + " ");
}
if(config.getInventoryFilter().getLastModifyEndTimeStamp() != null) {
xmlBody.append("" + config.getInventoryFilter().getLastModifyEndTimeStamp() + " ");
}
if(config.getInventoryFilter().getLowerSizeBound() != null) {
xmlBody.append("" + config.getInventoryFilter().getLowerSizeBound() + " ");
}
if(config.getInventoryFilter().getUpperSizeBound() != null) {
xmlBody.append("" + config.getInventoryFilter().getUpperSizeBound() + " ");
}
if(config.getInventoryFilter().getStorageClass() != null) {
xmlBody.append("" + config.getInventoryFilter().getStorageClass() + " ");
}
xmlBody.append(" ");
}
}
if (config.getSchedule() != null) {
xmlBody.append("");
xmlBody.append("" + config.getSchedule().getFrequency() + " ");
xmlBody.append(" ");
}
List fields = config.getOptionalFields();
if (fields != null && !fields.isEmpty()) {
xmlBody.append("");
for (String field : fields) {
xmlBody.append("" + field + " ");
}
xmlBody.append(" ");
}
InventoryDestination destination = config.getDestination();
if (destination != null) {
InventoryOSSBucketDestination bucketDestination = destination.getOssBucketDestination();
if (bucketDestination != null) {
xmlBody.append("");
xmlBody.append("");
if (bucketDestination.getAccountId() != null) {
xmlBody.append("" + bucketDestination.getAccountId() + " ");
}
if (bucketDestination.getRoleArn() != null) {
xmlBody.append("" + bucketDestination.getRoleArn()+ " ");
}
if (bucketDestination.getBucket() != null) {
xmlBody.append("" + "acs:oss:::" + bucketDestination.getBucket()+ " ");
}
if (bucketDestination.getPrefix() != null) {
xmlBody.append("" + bucketDestination.getPrefix() + " ");
}
if (bucketDestination.getFormat() != null) {
xmlBody.append("" + bucketDestination.getFormat()+ " ");
}
if (bucketDestination.getEncryption() != null) {
xmlBody.append("");
if (bucketDestination.getEncryption().getServerSideKmsEncryption() != null) {
xmlBody.append("");
xmlBody.append("" + bucketDestination.getEncryption()
.getServerSideKmsEncryption().getKeyId() + " ");
xmlBody.append(" ");
} else if (bucketDestination.getEncryption().getServerSideOssEncryption() != null) {
xmlBody.append(" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
xmlBody.append(" ");
}
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class InitiateBucketWormRequestMarshaller implements
RequestMarshaller2 {
@Override
public byte[] marshall(InitiateBucketWormRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getRetentionPeriodInDays() + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class ExtendBucketWormRequestMarshaller implements
RequestMarshaller2 {
@Override
public byte[] marshall(ExtendBucketWormRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getRetentionPeriodInDays()+ " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketResourceGroupRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(String resourceGroupId) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + resourceGroupId + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateUdfRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateUdfRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getName() + " ");
if (request.getId() != null) {
xmlBody.append("" + request.getId() + " ");
}
if (request.getDesc() != null) {
xmlBody.append("" + request.getDesc() + " ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateUdfApplicationRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateUdfApplicationRequest request) {
StringBuffer xmlBody = new StringBuffer();
UdfApplicationConfiguration config = request.getUdfApplicationConfiguration();
xmlBody.append("");
xmlBody.append("" + config.getImageVersion() + " ");
xmlBody.append("" + config.getInstanceNum() + " ");
xmlBody.append("");
xmlBody.append("" + config.getFlavor().getInstanceType() + " ");
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class UpgradeUdfApplicationRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(UpgradeUdfApplicationRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getImageVersion() + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class ResizeUdfApplicationRequestMarshaller
implements RequestMarshaller2 {
@Override
public byte[] marshall(ResizeUdfApplicationRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("" + request.getInstanceNum() + " ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class ProcessObjectRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(ProcessObjectRequest request) {
StringBuffer processBody = new StringBuffer();
processBody.append(RequestParameters.SUBRESOURCE_PROCESS);
processBody.append("=" + request.getProcess());
byte[] rawData = null;
try {
rawData = processBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateVpcipRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(CreateVpcipRequest request) {
StringBuffer xmlBody = new StringBuffer();
if (request.getRegion() != null || request.getVSwitchId() != null) {
xmlBody.append("");
if (request.getRegion() != null) {
xmlBody.append("" + request.getRegion() + " ");
}
if (request.getVSwitchId() != null) {
xmlBody.append("" + request.getVSwitchId() + " ");
}
if(request.getLabel() != null){
xmlBody.append("");
}
xmlBody.append(" ");
}
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class DeleteVpcipRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(DeleteVpcipRequest deleteVpcipRequest) {
StringBuffer xmlBody = new StringBuffer();
VpcPolicy request = deleteVpcipRequest.getVpcPolicy();
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
xmlBody.append("");
if (request.getRegion() != null) {
xmlBody.append("" + request.getRegion() + " ");
}
if (request.getVpcId() != null) {
xmlBody.append("" + request.getVpcId() + " ");
}
if (request.getVip() != null) {
xmlBody.append("" + request.getVip() + " ");
}
xmlBody.append(" ");
}
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class DeleteBucketVpcipRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(VpcPolicy request) {
StringBuffer xmlBody = new StringBuffer();
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
xmlBody.append("");
if (request.getRegion() != null) {
xmlBody.append("" + request.getRegion() + " ");
}
if (request.getVpcId() != null) {
xmlBody.append("" + request.getVpcId() + " ");
}
if (request.getVip() != null) {
xmlBody.append("" + request.getVip() + " ");
}
xmlBody.append(" ");
}
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class CreateBucketVpcipRequestMarshaller implements RequestMarshaller {
@Override
public FixedLengthInputStream marshall(CreateBucketVpcipRequest bucketVpcPolicyRequest) {
StringBuffer xmlBody = new StringBuffer();
VpcPolicy request = bucketVpcPolicyRequest.getVpcPolicy();
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
xmlBody.append("");
if (request.getRegion() != null) {
xmlBody.append("" + request.getRegion() + " ");
}
if (request.getVpcId() != null) {
xmlBody.append("" + request.getVpcId() + " ");
}
if (request.getVip() != null) {
xmlBody.append("" + request.getVip() + " ");
}
xmlBody.append(" ");
}
return stringMarshaller.marshall(xmlBody.toString());
}
}
public static final class RestoreObjectRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(RestoreObjectRequest request) {
StringBuffer body = new StringBuffer();
body.append("");
body.append("" + request.getRestoreConfiguration().getDays() + " ");
if (request.getRestoreConfiguration().getRestoreJobParameters() != null) {
body.append("");
RestoreJobParameters jobParameters = request.getRestoreConfiguration().getRestoreJobParameters();
if (jobParameters.getRestoreTier() != null) {
body.append("" + jobParameters.getRestoreTier() + " ");
}
body.append(" ");
}
body.append(" ");
byte[] rawData = null;
try {
rawData = body.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutBucketTransferAccelerationRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(SetBucketTransferAccelerationRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append(input.isEnabled());
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutBucketAccessMonitorRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(PutBucketAccessMonitorRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append(input.getStatus());
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class DoMetaQueryRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(DoMetaQueryRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if(input.getNextToken() != null){
xmlBody.append(""+ input.getNextToken() +" ");
}
xmlBody.append(""+ input.getMaxResults() +" ");
if(input.getQuery() != null){
xmlBody.append(""+ escapeKey(input.getQuery()) +" ");
}
if(input.getSort() != null){
xmlBody.append(""+ input.getSort() +" ");
}
if(input.getOrder() != null){
xmlBody.append(""+ input.getOrder() +" ");
}
if(input.getAggregations() != null && input.getAggregations().getAggregation() != null){
xmlBody.append("");
for(Aggregation agg : input.getAggregations().getAggregation()){
xmlBody.append("");
if(!StringUtils.isNullOrEmpty(agg.getField())){
xmlBody.append(""+ agg.getField() +" ");
}
if(!StringUtils.isNullOrEmpty(agg.getOperation())){
xmlBody.append(""+ agg.getOperation() +" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class SetBucketCallbackPolicyRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(SetBucketCallbackPolicyRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if(request.getPolicyCallbackItems() != null && request.getPolicyCallbackItems().size() > 0){
for(PolicyCallbackItem policy : request.getPolicyCallbackItems()){
xmlBody.append("");
if(!StringUtils.isNullOrEmpty(policy.getPolicyName())){
xmlBody.append(""+ policy.getPolicyName() +" ");
}
if(!StringUtils.isNullOrEmpty(policy.getCallback())){
xmlBody.append(""+ policy.getCallback() +" ");
}
if(StringUtils.isNullOrEmpty(policy.getCallbackVar())){
xmlBody.append(" ");
} else {
xmlBody.append(""+ policy.getCallbackVar() +" ");
}
xmlBody.append(" ");
}
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class AsyncProcessObjectRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(AsyncProcessObjectRequest request) {
StringBuffer processBody = new StringBuffer();
processBody.append(RequestParameters.X_OSS_ASYNC_PROCESS);
processBody.append("=" + request.getProcess());
byte[] rawData = null;
try {
rawData = processBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutBucketArchiveDirectReadRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(PutBucketArchiveDirectReadRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append(input.getEnabled());
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutBucketHttpsConfigRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(PutBucketHttpsConfigRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append("");
xmlBody.append(""+ request.isEnable() +" ");
for(String version : request.getTlsVersion()) {
xmlBody.append("" + version + " ");
}
xmlBody.append(" ");
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutPublicAccessBlockRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(PutPublicAccessBlockRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append(input.getBlockPublicAccess());
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutBucketPublicAccessBlockRequestMarshaller implements RequestMarshaller2 {
@Override
public byte[] marshall(PutBucketPublicAccessBlockRequest input) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
xmlBody.append(input.getBlockPublicAccess());
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class CreateAccessPointRequestParser implements RequestMarshaller2 {
@Override
public byte[] marshall(CreateAccessPointRequest request) {
StringBuffer xmlBody = new StringBuffer();
xmlBody.append("");
if(request.getAccessPointName() != null) {
xmlBody.append("").append(request.getAccessPointName()).append(" ");
}
if(request.getNetworkOrigin() != null) {
xmlBody.append("").append(request.getNetworkOrigin()).append(" ");
}
if(request.getVpc().getVpcId() != null) {
xmlBody.append("");
if(request.getVpc().getVpcId() != null){
xmlBody.append("").append(request.getVpc().getVpcId()).append(" ");
}
xmlBody.append(" ");
}
xmlBody.append(" ");
byte[] rawData = null;
try {
rawData = xmlBody.toString().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
public static final class PutAccessPointPolicyRequestParser implements RequestMarshaller2 {
@Override
public byte[] marshall(PutAccessPointPolicyRequest request) {
byte[] rawData = null;
try {
rawData = request.getAccessPointPolicy().getBytes(DEFAULT_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new ClientException("Unsupported encoding " + e.getMessage(), e);
}
return rawData;
}
}
private static enum EscapedChar {
// "\r"
RETURN("
"),
// "\n"
NEWLINE("
"),
// " "
SPACE(" "),
// "\t"
TAB(" "),
// """
QUOT("""),
// "&"
AMP("&"),
// "<"
LT("<"),
// ">"
GT(">");
private final String escapedChar;
private EscapedChar(String escapedChar) {
this.escapedChar = escapedChar;
}
@Override
public String toString() {
return this.escapedChar;
}
}
private static String escapeKey(String key) {
if (key == null) {
return "";
}
int pos;
int len = key.length();
StringBuilder builder = new StringBuilder();
for (pos = 0; pos < len; pos++) {
char ch = key.charAt(pos);
EscapedChar escapedChar;
switch (ch) {
case '\t':
escapedChar = EscapedChar.TAB;
break;
case '\n':
escapedChar = EscapedChar.NEWLINE;
break;
case '\r':
escapedChar = EscapedChar.RETURN;
break;
case '&':
escapedChar = EscapedChar.AMP;
break;
case '"':
escapedChar = EscapedChar.QUOT;
break;
case '<':
escapedChar = EscapedChar.LT;
break;
case '>':
escapedChar = EscapedChar.GT;
break;
default:
escapedChar = null;
break;
}
if (escapedChar != null) {
builder.append(escapedChar.toString());
} else {
builder.append(ch);
}
}
return builder.toString();
}
private static String joinRepliationAction(List actions) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (ReplicationAction action : actions) {
if (!first) {
sb.append(",");
}
sb.append(action);
first = false;
}
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy