From 87f366f1915d6e51e1c2dfe6939509a8aab36fb6 Mon Sep 17 00:00:00 2001 From: z30035417 Date: Fri, 28 Apr 2023 18:00:38 +0800 Subject: [PATCH 1/5] Version 3.23.3 1. Allow you to query the progress of crr 2. Added interfaces of Object tagging(set, get, delete) --- README-Android.md | 5 + README-Java.md | 5 + .../main/java/com/obs/log/BasicLogger.java | 21 + .../main/java/com/obs/log/Log4j2Logger.java | 5 + .../main/java/com/obs/log/Log4jLogger.java | 5 + .../main/java/com/obs/log/LoggerBuilder.java | 7 +- .../com/obs/services/AbstractBatchClient.java | 12 +- .../services/AbstractBucketAdvanceClient.java | 25 ++ .../java/com/obs/services/AbstractClient.java | 1 + .../com/obs/services/AbstractFileClient.java | 6 +- .../obs/services/AbstractObjectClient.java | 64 +++ .../java/com/obs/services/IObsClient.java | 45 ++- .../com/obs/services/ObsConfiguration.java | 13 + .../internal/ConcurrentProgressManager.java | 2 + .../com/obs/services/internal/Constants.java | 10 +- .../internal/DownloadResumableClient.java | 70 ++-- .../com/obs/services/internal/IConvertor.java | 3 + .../obs/services/internal/ObsConstraint.java | 2 +- .../com/obs/services/internal/ObsService.java | 25 +- .../internal/RepeatableRequestEntity.java | 2 +- .../internal/RestConnectionService.java | 4 +- .../services/internal/RestStorageService.java | 15 +- .../internal/UploadResumableClient.java | 16 +- .../services/internal/V2BucketConvertor.java | 17 + .../obs/services/internal/V2Convertor.java | 31 +- .../handler/XmlResponsesSaxParser.java | 116 ++++++ .../io/HttpMethodReleaseInputStream.java | 1 + .../security/ProviderCredentials.java | 11 + .../service/AbstractRequestConvertor.java | 5 +- .../service/ObsBucketAdvanceService.java | 31 +- .../service/ObsBucketBaseService.java | 26 +- .../internal/service/ObsObjectService.java | 55 +++ .../internal/service/RequestConvertor.java | 22 +- .../utils/AbstractAuthentication.java | 10 +- .../services/internal/utils/JSONChange.java | 2 - .../services/internal/utils/RestUtils.java | 38 +- .../services/internal/utils/ServiceUtils.java | 17 +- .../com/obs/services/model/ActionEnum.java | 33 ++ .../obs/services/model/CanonicalGrantee.java | 2 + .../services/model/CreateBucketRequest.java | 32 ++ .../services/model/GetObjectAclRequest.java | 2 + .../model/GetObjectMetadataRequest.java | 2 + .../obs/services/model/GetObjectRequest.java | 4 + .../obs/services/model/HttpMethodEnum.java | 6 +- .../model/LifecycleConfiguration.java | 39 +- .../services/model/ListBucketsRequest.java | 20 + .../obs/services/model/ListBucketsResult.java | 33 +- .../obs/services/model/ObjectTagResult.java | 77 ++++ .../services/model/ObjectTaggingRequest.java | 56 +++ .../com/obs/services/model/ObsBucket.java | 16 + .../com/obs/services/model/ObsObject.java | 10 + .../java/com/obs/services/model/S3Bucket.java | 12 +- .../model/SetObjectMetadataRequest.java | 2 + .../obs/services/model/SpecialParamEnum.java | 16 +- .../model/crr/GetCrrProgressRequest.java | 32 ++ .../model/crr/GetCrrProgressResult.java | 114 ++++++ .../com/obs/services/model/fs/ObsFSFile.java | 2 + .../model/fusion/FusionReplicateEnum.java | 32 ++ .../model/fusion/RedundancyTypeEnum.java | 35 ++ .../model/select/SelectObjectException.java | 2 + .../model/QueryAsynchFetchJobsResult.java | 1 + .../oef/services/model/RequestParamEnum.java | 6 +- assembly-java.xml | 24 +- pom-android.xml | 32 +- pom-dependencies.xml | 18 +- pom-java-optimization.xml | 376 +++++++++--------- pom-java.xml | 11 +- 67 files changed, 1430 insertions(+), 362 deletions(-) create mode 100644 app/src/main/java/com/obs/services/model/ActionEnum.java create mode 100644 app/src/main/java/com/obs/services/model/ObjectTagResult.java create mode 100644 app/src/main/java/com/obs/services/model/ObjectTaggingRequest.java create mode 100644 app/src/main/java/com/obs/services/model/crr/GetCrrProgressRequest.java create mode 100644 app/src/main/java/com/obs/services/model/crr/GetCrrProgressResult.java create mode 100644 app/src/main/java/com/obs/services/model/fusion/FusionReplicateEnum.java create mode 100644 app/src/main/java/com/obs/services/model/fusion/RedundancyTypeEnum.java diff --git a/README-Android.md b/README-Android.md index b79a54a..921f67b 100644 --- a/README-Android.md +++ b/README-Android.md @@ -1,3 +1,8 @@ +Version 3.23.3 +1. Allow you to query the progress of crr +2. Added interfaces of Object tagging(set, get, delete) +----------------------------------------------------------------------------------- + Version 3.21.12 Third-party dependence: 1. Replace log4j2 2.16.0 with log4j2 2.17.0 diff --git a/README-Java.md b/README-Java.md index 744907b..bc0a807 100644 --- a/README-Java.md +++ b/README-Java.md @@ -1,3 +1,8 @@ +Version 3.23.3 +1. Allow you to query the progress of crr +2. Added interfaces of Object tagging(set, get, delete) +----------------------------------------------------------------------------------- + Version 3.22.12 New features: 1. Added the Deep Archive storage class in the Java SDK. diff --git a/app/src/main/java/com/obs/log/BasicLogger.java b/app/src/main/java/com/obs/log/BasicLogger.java index 952ad67..46cfcf3 100644 --- a/app/src/main/java/com/obs/log/BasicLogger.java +++ b/app/src/main/java/com/obs/log/BasicLogger.java @@ -24,10 +24,12 @@ public class BasicLogger implements ILogger { this.logger = logger; } + @Override public boolean isInfoEnabled() { return this.logger.isLoggable(LogConfigurator.INFO); } + @Override public void info(CharSequence msg) { if (msg != null) { this.logger.info(msg.toString()); @@ -35,6 +37,7 @@ public void info(CharSequence msg) { } } + @Override public void info(Object obj) { if (obj != null) { this.logger.info(obj.toString()); @@ -42,6 +45,7 @@ public void info(Object obj) { } } + @Override public void info(Object obj, Throwable e) { if (obj != null) { this.logger.log(LogConfigurator.INFO, obj.toString(), e); @@ -49,10 +53,12 @@ public void info(Object obj, Throwable e) { } } + @Override public boolean isWarnEnabled() { return this.logger.isLoggable(LogConfigurator.WARN); } + @Override public void warn(CharSequence msg) { if (msg != null) { this.logger.warning(msg.toString()); @@ -60,6 +66,7 @@ public void warn(CharSequence msg) { } } + @Override public void warn(Object obj) { if (obj != null) { this.logger.warning(obj.toString()); @@ -67,6 +74,7 @@ public void warn(Object obj) { } } + @Override public void warn(Object obj, Throwable e) { if (obj != null) { this.logger.log(LogConfigurator.WARN, obj.toString(), e); @@ -74,10 +82,12 @@ public void warn(Object obj, Throwable e) { } } + @Override public boolean isErrorEnabled() { return this.logger.isLoggable(LogConfigurator.ERROR); } + @Override public void error(CharSequence msg) { if (msg != null) { this.logger.severe(msg.toString()); @@ -85,6 +95,7 @@ public void error(CharSequence msg) { } } + @Override public void error(Object obj) { if (obj != null) { this.logger.severe(obj.toString()); @@ -92,6 +103,7 @@ public void error(Object obj) { } } + @Override public void error(Object obj, Throwable e) { if (obj != null) { this.logger.log(LogConfigurator.ERROR, obj.toString(), e); @@ -99,10 +111,12 @@ public void error(Object obj, Throwable e) { } } + @Override public boolean isDebugEnabled() { return this.logger.isLoggable(LogConfigurator.DEBUG); } + @Override public void debug(CharSequence msg) { if (msg != null) { this.logger.log(LogConfigurator.DEBUG, msg.toString()); @@ -110,6 +124,7 @@ public void debug(CharSequence msg) { } } + @Override public void debug(Object obj) { if (obj != null) { this.logger.log(LogConfigurator.DEBUG, obj.toString()); @@ -117,6 +132,7 @@ public void debug(Object obj) { } } + @Override public void debug(Object obj, Throwable e) { if (obj != null) { this.logger.log(LogConfigurator.DEBUG, obj.toString(), e); @@ -124,10 +140,12 @@ public void debug(Object obj, Throwable e) { } } + @Override public boolean isTraceEnabled() { return this.logger.isLoggable(LogConfigurator.TRACE); } + @Override public void trace(CharSequence msg) { if (msg != null) { this.logger.log(LogConfigurator.TRACE, msg.toString()); @@ -135,6 +153,7 @@ public void trace(CharSequence msg) { } } + @Override public void trace(Object obj) { if (obj != null) { this.logger.log(LogConfigurator.TRACE, obj.toString()); @@ -142,6 +161,7 @@ public void trace(Object obj) { } } + @Override public void trace(Object obj, Throwable e) { if (obj != null) { this.logger.log(LogConfigurator.TRACE, obj.toString(), e); @@ -149,6 +169,7 @@ public void trace(Object obj, Throwable e) { } } + @Override public void accessRecord(Object obj) { if (obj != null) { this.logger.log(LogConfigurator.INFO, obj.toString()); diff --git a/app/src/main/java/com/obs/log/Log4j2Logger.java b/app/src/main/java/com/obs/log/Log4j2Logger.java index 55b8762..8ba75e3 100644 --- a/app/src/main/java/com/obs/log/Log4j2Logger.java +++ b/app/src/main/java/com/obs/log/Log4j2Logger.java @@ -53,6 +53,7 @@ private static class Log4j2LoggerMethodHolder extends LoggerMethodHolder { super(logger); } + @Override public boolean isInfoEnabled() { if (isInfoE == -1) { try { @@ -65,6 +66,7 @@ public boolean isInfoEnabled() { return isInfoE == 1; } + @Override public boolean isWarnEnabled() { if (isWarnE == -1) { try { @@ -77,6 +79,7 @@ public boolean isWarnEnabled() { return isWarnE == 1; } + @Override public boolean isErrorEnabled() { if (isErrorE == -1) { try { @@ -89,6 +92,7 @@ public boolean isErrorEnabled() { return isErrorE == 1; } + @Override public boolean isDebugEnabled() { if (isDebugE == -1) { try { @@ -101,6 +105,7 @@ public boolean isDebugEnabled() { return isDebugE == 1; } + @Override public boolean isTraceEnabled() { if (isTraceE == -1) { try { diff --git a/app/src/main/java/com/obs/log/Log4jLogger.java b/app/src/main/java/com/obs/log/Log4jLogger.java index e788449..71b966e 100644 --- a/app/src/main/java/com/obs/log/Log4jLogger.java +++ b/app/src/main/java/com/obs/log/Log4jLogger.java @@ -57,6 +57,7 @@ private static class Log4jLoggerMethodHolder extends LoggerMethodHolder { super(logger); } + @Override public boolean isInfoEnabled() { try { return this.logger != null && Log4jLoggerMethodHolder.infoLevel != null @@ -67,6 +68,7 @@ public boolean isInfoEnabled() { } } + @Override public boolean isWarnEnabled() { try { return this.logger != null && Log4jLoggerMethodHolder.warnLevel != null @@ -77,6 +79,7 @@ public boolean isWarnEnabled() { } } + @Override public boolean isErrorEnabled() { try { return this.logger != null && Log4jLoggerMethodHolder.errorLevel != null @@ -87,6 +90,7 @@ public boolean isErrorEnabled() { } } + @Override public boolean isDebugEnabled() { try { return this.logger != null && Log4jLoggerMethodHolder.debugLevel != null @@ -97,6 +101,7 @@ public boolean isDebugEnabled() { } } + @Override public boolean isTraceEnabled() { try { return this.logger != null && Log4jLoggerMethodHolder.traceLevel != null diff --git a/app/src/main/java/com/obs/log/LoggerBuilder.java b/app/src/main/java/com/obs/log/LoggerBuilder.java index 3a363d3..5bb2f89 100644 --- a/app/src/main/java/com/obs/log/LoggerBuilder.java +++ b/app/src/main/java/com/obs/log/LoggerBuilder.java @@ -31,15 +31,16 @@ static class GetLoggerHolder { logManagerClass = Class.forName("org.apache.logging.log4j.LogManager"); loggerClass = Class.forName("org.apache.logging.log4j.Logger"); getLoggerClass = GetLoggerHolder.logManagerClass.getMethod("getLogger", String.class); - } catch (NoSuchMethodException | SecurityException | ClassNotFoundException e) { + } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | NoClassDefFoundError e) { try { loggerClass = Class.forName("org.apache.log4j.Logger"); getLoggerClass = GetLoggerHolder.loggerClass.getMethod("getLogger", String.class); - } catch (NoSuchMethodException | SecurityException | ClassNotFoundException ex) { + } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | NoClassDefFoundError ex) { try { loggerClass = Class.forName("java.util.logging.Logger"); getLoggerClass = GetLoggerHolder.loggerClass.getMethod("getLogger", String.class); - } catch (NoSuchMethodException | SecurityException | ClassNotFoundException exx) { + } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | + NoClassDefFoundError exx) { ILOG.warning(exx.getMessage()); } } diff --git a/app/src/main/java/com/obs/services/AbstractBatchClient.java b/app/src/main/java/com/obs/services/AbstractBatchClient.java index 5bb560d..b96dd37 100644 --- a/app/src/main/java/com/obs/services/AbstractBatchClient.java +++ b/app/src/main/java/com/obs/services/AbstractBatchClient.java @@ -109,11 +109,7 @@ public TaskProgressStatus restoreObjects(RestoreObjectsRequest request) throws O executor.shutdown(); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (Exception e) { - if (e instanceof ObsException) { - throw (ObsException) e; - } else { - throw new ObsException(e.getMessage(), e); - } + throw ServiceUtils.changeFromException(e); } return progreStatus; } @@ -229,11 +225,7 @@ public UploadProgressStatus putObjects(final PutObjectsRequest request) throws O executor.shutdown(); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (Exception e) { - if (e instanceof ObsException) { - throw (ObsException) e; - } else { - throw new ObsException(e.getMessage(), e); - } + throw ServiceUtils.changeFromException(e); } return progressStatus; diff --git a/app/src/main/java/com/obs/services/AbstractBucketAdvanceClient.java b/app/src/main/java/com/obs/services/AbstractBucketAdvanceClient.java index 5c5ccc6..5c5ff10 100644 --- a/app/src/main/java/com/obs/services/AbstractBucketAdvanceClient.java +++ b/app/src/main/java/com/obs/services/AbstractBucketAdvanceClient.java @@ -36,9 +36,12 @@ import com.obs.services.model.SetBucketTaggingRequest; import com.obs.services.model.SetBucketWebsiteRequest; import com.obs.services.model.WebsiteConfiguration; +import com.obs.services.model.crr.GetCrrProgressRequest; +import com.obs.services.model.crr.GetCrrProgressResult; import com.obs.services.model.fs.GetBucketFSStatusRequest; import com.obs.services.model.fs.GetBucketFSStatusResult; import com.obs.services.model.fs.SetBucketFSStatusRequest; +import com.obs.services.model.AuthTypeEnum; public abstract class AbstractBucketAdvanceClient extends AbstractBucketClient { /* @@ -574,6 +577,28 @@ public ReplicationConfiguration action() throws ServiceException { }); } + @Override + public GetCrrProgressResult getCrrProgress(final GetCrrProgressRequest request) throws ObsException { + ServiceUtils.assertParameterNotNull(request, "GetCrrProgressRequest is null"); + ServiceUtils.assertParameterNotNull2(request.getBucketName(), "bucketName is null"); + ServiceUtils.assertParameterNotNull2(request.getRuleId(), "ruleId is null"); + return this.doActionWithResult("getCrrProgress", request.getBucketName(), + new ActionCallbackWithResult() { + @Override + public GetCrrProgressResult action() throws ServiceException { + return AbstractBucketAdvanceClient.this.getCrrProgressImpl(request); + } + void authTypeNegotiate(String bucketName) throws ServiceException { + AuthTypeEnum authTypeEnum = AbstractBucketAdvanceClient.this.getProviderCredentials().getLocalAuthType().get(bucketName); + if (authTypeEnum == null) { + authTypeEnum = AbstractBucketAdvanceClient.this.getApiVersion(request.getBucketName()); + AbstractBucketAdvanceClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum); + } + + } + }); + } + /* * (non-Javadoc) * diff --git a/app/src/main/java/com/obs/services/AbstractClient.java b/app/src/main/java/com/obs/services/AbstractClient.java index 9d6fc5a..793687c 100644 --- a/app/src/main/java/com/obs/services/AbstractClient.java +++ b/app/src/main/java/com/obs/services/AbstractClient.java @@ -65,6 +65,7 @@ protected void init(String accessKey, String secretKey, String securityToken, Ob ObsProperties obsProperties = ServiceUtils.changeFromObsConfiguration(config); credentials.setAuthType(config.getAuthType()); credentials.setLocalAuthTypeCacheCapacity(config.getLocalAuthTypeCacheCapacity()); + credentials.setSecureRandom(config.getSecureRandom()); this.obsProperties = obsProperties; this.credentials = credentials; this.keyManagerFactory = config.getKeyManagerFactory(); diff --git a/app/src/main/java/com/obs/services/AbstractFileClient.java b/app/src/main/java/com/obs/services/AbstractFileClient.java index 3c1d649..59b8caf 100644 --- a/app/src/main/java/com/obs/services/AbstractFileClient.java +++ b/app/src/main/java/com/obs/services/AbstractFileClient.java @@ -124,11 +124,7 @@ public TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsExcept executor.shutdown(); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (Exception e) { - if (e instanceof ObsException) { - throw (ObsException) e; - } else { - throw new ObsException(e.getMessage(), e); - } + throw ServiceUtils.changeFromException(e); } return progressStatus; } diff --git a/app/src/main/java/com/obs/services/AbstractObjectClient.java b/app/src/main/java/com/obs/services/AbstractObjectClient.java index 7853028..2e6a21b 100644 --- a/app/src/main/java/com/obs/services/AbstractObjectClient.java +++ b/app/src/main/java/com/obs/services/AbstractObjectClient.java @@ -51,6 +51,8 @@ import com.obs.services.model.SetObjectMetadataRequest; import com.obs.services.model.select.SelectObjectRequest; import com.obs.services.model.select.SelectObjectResult; +import com.obs.services.model.ObjectTagResult; +import com.obs.services.model.ObjectTaggingRequest; public abstract class AbstractObjectClient extends AbstractBucketAdvanceClient { @Override @@ -702,6 +704,68 @@ public RestoreObjectRequest.RestoreObjectStatus action() }); } + /* + * (non-Javadoc) + * + * @see com.obs.services.IObsClient#getBucketTagging(java.lang.String) + */ + @Override + public ObjectTagResult getObjectTagging(final ObjectTaggingRequest request) throws ObsException { + ServiceUtils.assertParameterNotNull(request, "ObjectTaggingRequest is null"); + ServiceUtils.assertParameterNotNull2(request.getBucketName(), "bucketName is null"); + ServiceUtils.assertParameterNotNull2(request.getObjectKey(), "objectKey is null"); + return this.doActionWithResult("getObjectTagging", request.getBucketName(), + new ActionCallbackWithResult() { + + @Override + public ObjectTagResult action() throws ServiceException { + return AbstractObjectClient.this.getObjectTaggingImpl(request); + } + }); + } + + /* + * (non-Javadoc) + * + * @see com.obs.services.IObsClient#setObjectTagging(java.lang.String, + * com.obs.services.model.ObjectTagResult) + */ + @Override + public HeaderResponse setObjectTagging(final ObjectTaggingRequest request) throws ObsException { + ServiceUtils.assertParameterNotNull(request, "ObjectTaggingRequest is null"); + ServiceUtils.assertParameterNotNull2(request.getBucketName(), "bucketName is null"); + ServiceUtils.assertParameterNotNull2(request.getObjectKey(), "objectKey is null"); + return this.doActionWithResult("setObjectTagging", request.getBucketName(), + new ActionCallbackWithResult() { + @Override + public HeaderResponse action() throws ServiceException { + + return AbstractObjectClient.this.setObjectTaggingImpl(request); + } + }); + } + + /* + * (non-Javadoc) + * + * @see com.obs.services.IObsClient#deleteObjectTagging(java.lang.String) + */ + @Override + public HeaderResponse deleteObjectTagging(final ObjectTaggingRequest request) throws ObsException { + ServiceUtils.assertParameterNotNull(request, "ObjectTaggingRequest is null"); + ServiceUtils.assertParameterNotNull2(request.getBucketName(), "bucketName is null"); + ServiceUtils.assertParameterNotNull2(request.getObjectKey(), "objectKey is null"); + + return this.doActionWithResult("deleteObjectTagging", request.getBucketName(), + new ActionCallbackWithResult() { + + @Override + public HeaderResponse action() throws ServiceException { + return AbstractObjectClient.this.deleteObjectTaggingImpl(request); + } + }); + } + /* * (non-Javadoc) * diff --git a/app/src/main/java/com/obs/services/IObsClient.java b/app/src/main/java/com/obs/services/IObsClient.java index 27f3b8f..0ad4cfe 100644 --- a/app/src/main/java/com/obs/services/IObsClient.java +++ b/app/src/main/java/com/obs/services/IObsClient.java @@ -121,8 +121,12 @@ import com.obs.services.model.UploadPartResult; import com.obs.services.model.UploadProgressStatus; import com.obs.services.model.WebsiteConfiguration; +import com.obs.services.model.crr.GetCrrProgressRequest; +import com.obs.services.model.crr.GetCrrProgressResult; import com.obs.services.model.select.SelectObjectRequest; import com.obs.services.model.select.SelectObjectResult; +import com.obs.services.model.ObjectTagResult; +import com.obs.services.model.ObjectTaggingRequest; /** * Basic OBS interface @@ -1326,8 +1330,43 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat * @since 3.20.3 */ HeaderResponse deleteBucketTagging(BaseBucketRequest request) throws ObsException; - - + + /** + * Obtain object tags. + * + * @param request + * Request parameters + * @return Object tag + * @throws ObsException + * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails + * @since 3.20.3 + */ + ObjectTagResult getObjectTagging(ObjectTaggingRequest request) throws ObsException; + + /** + * Set object tags. + * + * @param request + * Request parameters + * @return Common response headers + * @throws ObsException + * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails + * @since 3.20.3 + */ + HeaderResponse setObjectTagging(ObjectTaggingRequest request) throws ObsException; + + /** + * Delete object tags. + * + * @param request + * Request parameters + * @return Common response headers + * @throws ObsException + * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails + * @since 3.20.3 + */ + HeaderResponse deleteObjectTagging(ObjectTaggingRequest request) throws ObsException; + /** * Obtain bucket encryption configuration. * @@ -1454,6 +1493,8 @@ HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration */ ReplicationConfiguration getBucketReplication(BaseBucketRequest request) throws ObsException; + GetCrrProgressResult getCrrProgress(GetCrrProgressRequest request) throws ObsException; + /** * Delete the bucket cross-region replication configuration. * diff --git a/app/src/main/java/com/obs/services/ObsConfiguration.java b/app/src/main/java/com/obs/services/ObsConfiguration.java index bd4023e..9e8ea09 100644 --- a/app/src/main/java/com/obs/services/ObsConfiguration.java +++ b/app/src/main/java/com/obs/services/ObsConfiguration.java @@ -23,6 +23,8 @@ import okhttp3.Dispatcher; +import java.security.SecureRandom; + /** * Configuration parameters of ObsClient */ @@ -72,6 +74,8 @@ public class ObsConfiguration implements Cloneable { private int localAuthTypeCacheCapacity; + private SecureRandom secureRandom; + private String signatString; private String defaultBucketLocation; private int bufferSize; @@ -128,6 +132,7 @@ public ObsConfiguration() { this.httpProtocolType = HttpProtocolTypeEnum.HTTP1_1; this.xmlDocumentBuilderFactoryClass = ObsConstraint.OBS_XML_DOC_BUILDER_FACTORY_CLASS; this.localAuthTypeCacheCapacity = ObsConstraint.DEFAULT_LOCAL_AUTH_TYPE_CACHE_CAPACITY; + this.secureRandom = new SecureRandom(); } public String getDelimiter() { @@ -889,4 +894,12 @@ public int getLocalAuthTypeCacheCapacity() { public void setLocalAuthTypeCacheCapacity(int localAuthTypeCacheCapacity) { this.localAuthTypeCacheCapacity = localAuthTypeCacheCapacity; } + + public SecureRandom getSecureRandom() { + return secureRandom; + } + + public void setSecureRandom(SecureRandom secureRandom) { + this.secureRandom = secureRandom; + } } diff --git a/app/src/main/java/com/obs/services/internal/ConcurrentProgressManager.java b/app/src/main/java/com/obs/services/internal/ConcurrentProgressManager.java index eafd883..8e51fb3 100644 --- a/app/src/main/java/com/obs/services/internal/ConcurrentProgressManager.java +++ b/app/src/main/java/com/obs/services/internal/ConcurrentProgressManager.java @@ -39,12 +39,14 @@ public ConcurrentProgressManager(long totalBytes, long transferredBytes, Progres this.lastSwapTimeStamp = new AtomicLong(System.currentTimeMillis()); } + @Override public void progressStart() { if (startFlag.compareAndSet(false, true)) { super.progressStart(); } } + @Override public void progressEnd() { if (this.progressListener == null) { return; diff --git a/app/src/main/java/com/obs/services/internal/Constants.java b/app/src/main/java/com/obs/services/internal/Constants.java index 22f5434..7766f19 100644 --- a/app/src/main/java/com/obs/services/internal/Constants.java +++ b/app/src/main/java/com/obs/services/internal/Constants.java @@ -95,6 +95,12 @@ public static class CommonHeaders { public static final String X_AUTH_TOKEN = "X-Auth-Token"; public static final String LOCATION_CLUSTERGROUP_ID = "location-clustergroup-id"; + + public static final String BUCKET_REDUNDANCY = "bucket-redundancy"; + + public static final String FUSION_ALLOW_UPGRADE = "fusion-allow-upgrade"; + + public static final String FUSION_ALLOW_ALTERNATIVE = "fusion-allow-alternative"; } public static class ObsRequestParams { @@ -207,7 +213,7 @@ public static class ObsRequestParams { public static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT"); - public static final String OBS_SDK_VERSION = "3.22.12"; + public static final String OBS_SDK_VERSION = "3.23.3"; public static final String USER_AGENT_VALUE = "obs-sdk-java/" + Constants.OBS_SDK_VERSION; @@ -281,7 +287,7 @@ public static class ObsRequestParams { "storagepolicy", "storageclass", "requestpayment", "versions", "versioning", "versionid", "uploads", "uploadid", "partnumber", "website", "notification", "lifecycle", "deletebucket", "delete", "cors", "restore", "tagging", "replication", "metadata", "encryption", "directcoldaccess", "mirrorrefresh", - "mirrorbacktosource", "obsbucketalias", "obsalias", + "mirrorbacktosource", "obsbucketalias", "obsalias", "replication_progress", /** * File System API */ diff --git a/app/src/main/java/com/obs/services/internal/DownloadResumableClient.java b/app/src/main/java/com/obs/services/internal/DownloadResumableClient.java index 7885bef..af59fac 100644 --- a/app/src/main/java/com/obs/services/internal/DownloadResumableClient.java +++ b/app/src/main/java/com/obs/services/internal/DownloadResumableClient.java @@ -29,8 +29,8 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -79,11 +79,7 @@ public DownloadFileResult downloadFileResume(DownloadFileRequest downloadFileReq } catch (ServiceException e) { throw ServiceUtils.changeFromServiceException(e); } catch (Exception e) { - if (e instanceof ObsException) { - throw (ObsException) e; - } else { - throw new ObsException(e.getMessage(), e); - } + throw ServiceUtils.changeFromException(e); } } @@ -354,6 +350,7 @@ public PartResultDown call() throws Exception { RandomAccessFile output = null; InputStream content = null; + InputStream progressContent = null; try { if (log.isDebugEnabled()) { @@ -371,14 +368,17 @@ public PartResultDown call() throws Exception { ObsObject object = obsClient.getObject(getObjectRequest); content = object.getObjectContent(); - if (this.progressManager != null) { - content = new ProgressInputStream(content, this.progressManager, false); - } - byte[] buffer = new byte[ObsConstraint.DEFAULT_CHUNK_SIZE]; int bytesOffset; - while ((bytesOffset = content.read(buffer)) != -1) { - output.write(buffer, 0, bytesOffset); + if (this.progressManager != null) { + progressContent = new ProgressInputStream(content, this.progressManager, false); + while ((bytesOffset = progressContent.read(buffer)) != -1) { + output.write(buffer, 0, bytesOffset); + } + } else { + while ((bytesOffset = content.read(buffer)) != -1) { + output.write(buffer, 0, bytesOffset); + } } downloadCheckPoint.update(partIndex, true, downloadFileRequest.getTempDownloadFile()); } catch (ObsException e) { @@ -387,43 +387,49 @@ public PartResultDown call() throws Exception { } signPartResultFailed(tr, e); if (log.isErrorEnabled()) { - log.error(String.format("Task %d:%s download part %d failed: ", id, name, partIndex), e); + log.error(String.format(Locale.ROOT,"Task %d:%s download part %d failed: ", id, name, partIndex), e); } } catch (Exception e) { signPartResultFailed(tr, e); if (log.isErrorEnabled()) { - log.error(String.format("Task %d:%s download part %d failed: ", id, name, partIndex), e); + log.error(String.format(Locale.ROOT,"Task %d:%s download part %d failed: ", id, name, partIndex), e); } } finally { // 结束一个子任务 finishOneTask(downloadFileRequest); - closeResource(output); - - closeResource(content); - - if (log.isDebugEnabled()) { - log.debug("end task : " + downloadPart.toString()); + try { + if (null != output) { + output.close(); + } + } catch (IOException e) { + log.warn("output close failed.", e); } - if (downloadFileRequest.isEnableCheckpoint()) { - downloadCheckPoint.updateTmpFile(downloadFileRequest.getTempDownloadFile()); - downloadCheckPoint.record(downloadFileRequest.getCheckpointFile()); + try { + if (null != content) { + content.close(); + } + } catch (IOException e) { + log.warn("content close failed.", e); } - } - return tr; - } - private void closeResource(Closeable resource) { - if (null != resource) { try { - resource.close(); - } catch (IOException e) { - if (log.isWarnEnabled()) { - log.warn("close failed.", e); + if (null != progressContent) { + progressContent.close(); } + } catch (IOException e) { + log.warn("progressContent close failed.", e); + } + + log.debug("end task : " + downloadPart); + + if (downloadFileRequest.isEnableCheckpoint()) { + downloadCheckPoint.updateTmpFile(downloadFileRequest.getTempDownloadFile()); + downloadCheckPoint.record(downloadFileRequest.getCheckpointFile()); } } + return tr; } private void finishOneTask(DownloadFileRequest downloadFileRequest) { diff --git a/app/src/main/java/com/obs/services/internal/IConvertor.java b/app/src/main/java/com/obs/services/internal/IConvertor.java index 1ffcfb5..33f0c15 100644 --- a/app/src/main/java/com/obs/services/internal/IConvertor.java +++ b/app/src/main/java/com/obs/services/internal/IConvertor.java @@ -35,6 +35,7 @@ import com.obs.services.model.StorageClassEnum; import com.obs.services.model.WebsiteConfiguration; import com.obs.services.model.fs.FSStatusEnum; +import com.obs.services.model.ObjectTagResult; public interface IConvertor { @@ -69,6 +70,8 @@ String transKeyAndVersion(KeyAndVersion[] objectNameAndVersions, boolean isQuiet String transBucketTagInfo(BucketTagInfo bucketTagInfo) throws ServiceException; + String transObjectTagInfo(ObjectTagResult objectTagResult) throws ServiceException; + String transBucketNotificationConfiguration(BucketNotificationConfiguration bucketNotificationConfiguration) throws ServiceException; diff --git a/app/src/main/java/com/obs/services/internal/ObsConstraint.java b/app/src/main/java/com/obs/services/internal/ObsConstraint.java index 3fa5ef8..1911649 100644 --- a/app/src/main/java/com/obs/services/internal/ObsConstraint.java +++ b/app/src/main/java/com/obs/services/internal/ObsConstraint.java @@ -69,7 +69,7 @@ public class ObsConstraint { public static final String HTTP_STRICT_HOSTNAME_VERIFICATION = "httpclient.strict-hostname-verification"; - public static final int HTTP_CONNECT_TIMEOUT_VALUE = 60000; + public static final int HTTP_CONNECT_TIMEOUT_VALUE = 20000; public static final int HTTP_MAX_CONNECT_VALUE = 1000; diff --git a/app/src/main/java/com/obs/services/internal/ObsService.java b/app/src/main/java/com/obs/services/internal/ObsService.java index 2adab3f..dc6c5d5 100644 --- a/app/src/main/java/com/obs/services/internal/ObsService.java +++ b/app/src/main/java/com/obs/services/internal/ObsService.java @@ -18,11 +18,14 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.Locale; import com.obs.services.internal.Constants.CommonHeaders; import com.obs.services.internal.security.BasicSecurityKey; @@ -49,6 +52,17 @@ import com.obs.services.model.V4PostSignatureResponse; public class ObsService extends ObsExtensionService { + private static final Set NON_CONTINUE_STRING_LIST = new HashSet<>(); + + static { + NON_CONTINUE_STRING_LIST.add("acl"); + NON_CONTINUE_STRING_LIST.add("bucket"); + NON_CONTINUE_STRING_LIST.add("key"); + NON_CONTINUE_STRING_LIST.add("success_action_redirect"); + NON_CONTINUE_STRING_LIST.add("redirect"); + NON_CONTINUE_STRING_LIST.add("success_action_status"); + } + protected ObsService() { } @@ -177,7 +191,7 @@ private Map convertHeader(String bucketName, Map for (Map.Entry entry : headers.entrySet()) { if (ServiceUtils.isValid(entry.getKey())) { - String key = entry.getKey().toLowerCase().trim(); + String key = entry.getKey().toLowerCase(Locale.ROOT).trim(); key = formatHeaderKey(bucketName, requestMethod, key); if (null != key) { @@ -274,7 +288,7 @@ private void appendOriginPolicy(PostSignatureRequest request, boolean isV4, Basi for (Map.Entry entry : params.entrySet()) { if (ServiceUtils.isValid(entry.getKey())) { - String key = entry.getKey().toLowerCase().trim(); + String key = entry.getKey().toLowerCase(Locale.ROOT).trim(); if (key.equals("bucket")) { matchAnyBucket = false; @@ -284,9 +298,8 @@ private void appendOriginPolicy(PostSignatureRequest request, boolean isV4, Basi if (!Constants.ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES.contains(key) && !key.startsWith(this.getRestHeaderPrefix(request.getBucketName())) - && !key.startsWith(Constants.OBS_HEADER_PREFIX) && !key.equals("acl") - && !key.equals("bucket") && !key.equals("key") && !key.equals("success_action_redirect") - && !key.equals("redirect") && !key.equals("success_action_status")) { + && !key.startsWith(Constants.OBS_HEADER_PREFIX) + && !NON_CONTINUE_STRING_LIST.contains(key)) { continue; } String value = entry.getValue() == null ? "" : entry.getValue().toString(); @@ -466,7 +479,7 @@ private void concatHeaderString(String bucketName, String requestMethod, int index = 0; for (Map.Entry entry : headers.entrySet()) { if (ServiceUtils.isValid(entry.getKey())) { - String key = entry.getKey().toLowerCase().trim(); + String key = entry.getKey().toLowerCase(Locale.ROOT).trim(); key = formatHeaderKey(bucketName, requestMethod, key); if (null != key) { diff --git a/app/src/main/java/com/obs/services/internal/RepeatableRequestEntity.java b/app/src/main/java/com/obs/services/internal/RepeatableRequestEntity.java index 2bfe4e6..89e0ca9 100644 --- a/app/src/main/java/com/obs/services/internal/RepeatableRequestEntity.java +++ b/app/src/main/java/com/obs/services/internal/RepeatableRequestEntity.java @@ -102,7 +102,7 @@ public void writeTo(BufferedSink sink) throws IOException { inputStream.reset(); bytesWritten = 0; } - // this.writeToNIO(sink); + this.writeToBIO(sink); if (INTERFACE_LOG.isInfoEnabled()) { INTERFACE_LOG.info("write data end, cost " + (System.currentTimeMillis() - start) + " ms"); diff --git a/app/src/main/java/com/obs/services/internal/RestConnectionService.java b/app/src/main/java/com/obs/services/internal/RestConnectionService.java index 8e932d9..b0a27b2 100644 --- a/app/src/main/java/com/obs/services/internal/RestConnectionService.java +++ b/app/src/main/java/com/obs/services/internal/RestConnectionService.java @@ -56,7 +56,7 @@ public class RestConnectionService { protected void initHttpClient(Dispatcher httpDispatcher) { OkHttpClient.Builder builder = RestUtils.initHttpClientBuilder(obsProperties, keyManagerFactory, - trustManagerFactory, httpDispatcher); + trustManagerFactory, httpDispatcher, credentials.getSecureRandom()); if (this.obsProperties.getBoolProperty(ObsConstraint.PROXY_ISABLE, true)) { String proxyHostAddress = this.obsProperties.getStringProperty(ObsConstraint.PROXY_HOST, null); @@ -96,8 +96,6 @@ private void invokeShutdown() { Method dispatcherMethod = httpClient.getClass().getMethod("dispatcher"); if (dispatcherMethod != null) { Method m = dispatcherMethod.invoke(httpClient).getClass().getDeclaredMethod("executorService"); - // fix findbugs: DP_DO_INSIDE_DO_PRIVILEGED - // m.setAccessible(true); Object exeService = m.invoke(httpClient.dispatcher()); if (exeService instanceof ExecutorService) { ExecutorService executorService = (ExecutorService) exeService; diff --git a/app/src/main/java/com/obs/services/internal/RestStorageService.java b/app/src/main/java/com/obs/services/internal/RestStorageService.java index db0210b..2b5d7a0 100644 --- a/app/src/main/java/com/obs/services/internal/RestStorageService.java +++ b/app/src/main/java/com/obs/services/internal/RestStorageService.java @@ -69,7 +69,6 @@ public abstract class RestStorageService extends RestConnectionService { static { NON_RETRIABLE_CLASSES.add(UnknownHostException.class); NON_RETRIABLE_CLASSES.add(SSLException.class); - NON_RETRIABLE_CLASSES.add(ConnectException.class); } private static ThreadLocal> userHeaders = new ThreadLocal<>(); @@ -561,16 +560,14 @@ private Response executeRequest(Call call, try { semaphore.acquire(); return call.execute(); - } catch (IOException e) { - if (e instanceof UnrecoverableIOException) { - if (retryController.getLastException() != null) { - throw retryController.getLastException(); - } else { - throw e; - } + } catch (UnrecoverableIOException e) { + if (retryController.getLastException() != null) { + throw retryController.getLastException(); + } else { + throw e; } + } catch (IOException e) { retryController.setLastException(e); - retryOnIOException(e, request, retryController, diff --git a/app/src/main/java/com/obs/services/internal/UploadResumableClient.java b/app/src/main/java/com/obs/services/internal/UploadResumableClient.java index eec9cdc..36e26b5 100644 --- a/app/src/main/java/com/obs/services/internal/UploadResumableClient.java +++ b/app/src/main/java/com/obs/services/internal/UploadResumableClient.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -81,11 +82,7 @@ public CompleteMultipartUploadResult uploadFileResume(UploadFileRequest uploadFi } catch (ServiceException e) { throw ServiceUtils.changeFromServiceException(e); } catch (Exception e) { - if (e instanceof ObsException) { - throw (ObsException) e; - } else { - throw new ObsException(e.getMessage(), e); - } + throw ServiceUtils.changeFromException(e); } } @@ -302,6 +299,7 @@ public PartResult call() throws Exception { long skipByte = input.skip(offset); if (offset < skipByte) { log.error(String.format( + Locale.ROOT, "The actual number of skipped bytes (%d) is less than expected (%d): ", skipByte, offset)); } @@ -330,14 +328,18 @@ public PartResult call() throws Exception { tr.setFailed(true); tr.setException(e); if (log.isErrorEnabled()) { - log.error(String.format("Task %d:%s upload part %d failed: ", id, "upload" + id, partIndex + 1), + log.error(String.format( + Locale.ROOT, + "Task %d:%s upload part %d failed: ", id, "upload" + id, partIndex + 1), e); } } catch (Exception e) { tr.setFailed(true); tr.setException(e); if (log.isErrorEnabled()) { - log.error(String.format("Task %d:%s upload part %d failed: ", id, "upload" + id, partIndex + 1), + log.error(String.format( + Locale.ROOT, + "Task %d:%s upload part %d failed: ", id, "upload" + id, partIndex + 1), e); } } finally { diff --git a/app/src/main/java/com/obs/services/internal/V2BucketConvertor.java b/app/src/main/java/com/obs/services/internal/V2BucketConvertor.java index 137c082..45dbbb0 100644 --- a/app/src/main/java/com/obs/services/internal/V2BucketConvertor.java +++ b/app/src/main/java/com/obs/services/internal/V2BucketConvertor.java @@ -40,6 +40,7 @@ import com.obs.services.model.SSEAlgorithmEnum; import com.obs.services.model.TopicConfiguration; import com.obs.services.model.fs.FSStatusEnum; +import com.obs.services.model.ObjectTagResult; public abstract class V2BucketConvertor implements IConvertor { @@ -223,6 +224,22 @@ public String transBucketTagInfo(BucketTagInfo bucketTagInfo) throws ServiceExce throw new ServiceException("Failed to build XML document for Tagging", e); } } + + @Override + public String transObjectTagInfo(ObjectTagResult objectTagResult) throws ServiceException { + try { + OBSXMLBuilder builder = OBSXMLBuilder.create("Tagging").e("TagSet"); + for (BucketTagInfo.TagSet.Tag tag : objectTagResult.getTagSet().getTags()) { + if (tag != null) { + builder.e("Tag").e("Key").t(ServiceUtils.toValid(tag.getKey())).up().e("Value") + .t(ServiceUtils.toValid(tag.getValue())); + } + } + return builder.up().asString(); + } catch (Exception e) { + throw new ServiceException("Failed to build XML document for Tagging", e); + } + } @Override public String transBucketNotificationConfiguration(BucketNotificationConfiguration bucketNotificationConfiguration) diff --git a/app/src/main/java/com/obs/services/internal/V2Convertor.java b/app/src/main/java/com/obs/services/internal/V2Convertor.java index 249e419..bd0d9ad 100644 --- a/app/src/main/java/com/obs/services/internal/V2Convertor.java +++ b/app/src/main/java/com/obs/services/internal/V2Convertor.java @@ -48,6 +48,7 @@ import com.obs.services.model.RouteRuleCondition; import com.obs.services.model.StorageClassEnum; import com.obs.services.model.WebsiteConfiguration; +import com.obs.services.model.BucketTagInfo; public class V2Convertor extends V2BucketConvertor { @@ -58,7 +59,7 @@ public static IConvertor getInstance() { } public static String getEncodedString(String value, String encodingType) { - if (encodingType != null && encodingType.toLowerCase().equals("url")) { + if (encodingType != null && encodingType.equalsIgnoreCase("url")) { try { return URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException exception) { @@ -129,7 +130,17 @@ public String transLifecycleConfiguration(LifecycleConfiguration config) throws if (ServiceUtils.isValid2(rule.getId())) { b.elem("ID").t(rule.getId()); } - if (rule.getPrefix() != null) { + boolean needFilter = rule.getTagSet() != null; + if(needFilter) { + OBSXMLBuilder filterBuilder = b.elem("Filter"); + OBSXMLBuilder andBuilder = filterBuilder.elem("And"); + if (rule.getPrefix() != null) { + andBuilder.elem("Prefix").t(ServiceUtils.toValid(rule.getPrefix())); + } + if (rule.getTagSet() != null) { + transTagSet(rule, andBuilder); + } + } else if (rule.getPrefix() != null) { b.elem("Prefix").t(ServiceUtils.toValid(rule.getPrefix())); } b.elem("Status").t(rule.getEnabled() ? "Enabled" : "Disabled"); @@ -187,6 +198,22 @@ private void transExpiration(Rule rule, OBSXMLBuilder b) { } } + private void transTagSet(Rule rule, OBSXMLBuilder b) { + if(rule.getTagSet() == null) { + return; + } + List tags = rule.getTagSet().getTags(); + for(BucketTagInfo.TagSet.Tag tag : tags) { + OBSXMLBuilder tagBuilder = b.elem("Tag"); + tagBuilder.elem("Key").t(tag.getKey()); + if (tag.getValue() != null) { + tagBuilder.elem("Value").t(tag.getValue()); + } else { + tagBuilder.elem("Value"); + } + } + } + private void transTransitions(Rule rule, OBSXMLBuilder b) { for (Transition transition : rule.getTransitions()) { if (transition.getObjectStorageClass() != null) { diff --git a/app/src/main/java/com/obs/services/internal/handler/XmlResponsesSaxParser.java b/app/src/main/java/com/obs/services/internal/handler/XmlResponsesSaxParser.java index c8f9dc4..2465b3c 100644 --- a/app/src/main/java/com/obs/services/internal/handler/XmlResponsesSaxParser.java +++ b/app/src/main/java/com/obs/services/internal/handler/XmlResponsesSaxParser.java @@ -67,6 +67,7 @@ import com.obs.services.model.VersionOrDeleteMarker; import com.obs.services.model.VersioningStatusEnum; import com.obs.services.model.WebsiteConfiguration; +import com.obs.services.model.crr.GetCrrProgressResult; import com.obs.services.model.fs.DirContentSummary; import com.obs.services.model.fs.DirSummary; import com.obs.services.model.fs.FolderContentSummary; @@ -85,10 +86,12 @@ import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.LinkedList; import java.util.List; +import com.obs.services.model.ObjectTagResult; public class XmlResponsesSaxParser { @@ -717,6 +720,14 @@ public static class ListBucketsHandler extends DefaultXmlHandler { private ObsBucket currentBucket; + private boolean truncated; + + private String marker; + + private int maxKeys; + + private String nextMarker; + private final List buckets = new ArrayList<>(); public List getBuckets() { @@ -727,6 +738,22 @@ public Owner getOwner() { return bucketsOwner; } + public boolean isTruncated() { + return truncated; + } + + public String getMarker() { + return marker; + } + + public int getMaxKeys() { + return maxKeys; + } + + public String getNextMarker() { + return nextMarker; + } + @Override public void startElement(String name) { if (name.equals("Bucket")) { @@ -738,6 +765,15 @@ public void startElement(String name) { @Override public void endElement(String name, String elementText) { + if (name.equals("Marker")) { + marker = elementText; + } else if (name.equals("MaxKeys")) { + maxKeys = Integer.parseInt(elementText); + } else if (name.equals("IsTruncated")) { + truncated = Boolean.parseBoolean(elementText); + } else if (name.equals("NextMarker")) { + nextMarker = elementText; + } if (null != bucketsOwner) { if (name.equals("ID")) { bucketsOwner.setId(elementText); @@ -775,6 +811,8 @@ public void endElement(String name, String elementText) { currentBucket.setBucketType(BucketTypeEnum.OBJECT); } break; + case "ClusterType": + currentBucket.setClustertype(elementText); default: break; } @@ -2078,6 +2116,30 @@ public void endElement(String name, String content) { } + public static class ObjectTagInfoHandler extends DefaultXmlHandler { + private ObjectTagResult tagInfo = new ObjectTagResult(); + + private String currentKey; + + private String currentValue; + + public ObjectTagResult getObjectTagInfo() { + return tagInfo; + } + + @Override + public void endElement(String name, String content) { + if ("Key".equals(name)) { + currentKey = content; + } else if ("Value".equals(name)) { + currentValue = content; + } else if ("Tag".equals(name)) { + tagInfo.getTagSet().addTag(currentKey, currentValue); + } + } + + } + public static class BucketNotificationConfigurationHandler extends DefaultXmlHandler { private BucketNotificationConfiguration bucketNotificationConfiguration = new BucketNotificationConfiguration(); @@ -2221,6 +2283,20 @@ public void endStatus(String content) { public void endRule(String content) { config.addRule(latestRule); } + + public void endKey(String content) { + if(latestRule.getTagSet() == null) { + latestRule.setTagSet(new BucketTagInfo.TagSet()); + } + latestRule.getTagSet().addTag(content,""); + } + + public void endValue(String content) { + if(latestRule.getTagSet() != null && !latestRule.getTagSet().getTags().isEmpty()) { + int tagSetSize = latestRule.getTagSet().getTags().size(); + latestRule.getTagSet().getTags().get(tagSetSize - 1).setValue(content); + } + } } public static class AccessControlListHandler extends DefaultXmlHandler { @@ -2450,6 +2526,46 @@ public void endElement(String name, String content) { } } + public static class GetCrrProgressResultHandler extends DefaultXmlHandler { + private GetCrrProgressResult getCrrProgressResult = new GetCrrProgressResult(); + SimpleDateFormat formatter = new SimpleDateFormat(Constants.EXPIRATION_DATE_FORMATTER); + + public GetCrrProgressResult getReplicationConfiguration() { + return getCrrProgressResult; + } + + @Override + public void startElement(String name) { + } + + @Override + public void endElement(String name, String content) { + try { + if ("Time".equals(name)) { + getCrrProgressResult.setTime(formatter.parse(content)); + } else if ("ID".equals(name)) { + getCrrProgressResult.setRuleId(content); + } else if ("Prefix".equals(name)) { + getCrrProgressResult.setRulePrefix(content); + } else if ("Bucket".equals(name)) { + getCrrProgressResult.setRuleTargetBucket(content); + } else if ("NewPendingCount".equals(name)) { + getCrrProgressResult.setRuleNewPendingCount(Long.parseLong(content)); + } else if ("NewPendingSize".equals(name)) { + getCrrProgressResult.setRuleNewPendingSize(Long.parseLong(content)); + } else if ("HistoricalProgress".equals(name)) { + getCrrProgressResult.setRuleHistoricalProgress(content); + } else if ("HistoricalPendingCount".equals(name)) { + getCrrProgressResult.setRuleHistoricalPendingCount(Long.parseLong(content)); + } else if ("HistoricalPendingSize".equals(name)) { + getCrrProgressResult.setRuleHistoricalPendingSize(Long.parseLong(content)); + } + } catch (Exception e) { + log.error("Response xml is not well-format, exception message :", e); + } + } + } + public static class BucketDirectColdAccessHandler extends DefaultXmlHandler { private BucketDirectColdAccess access = new BucketDirectColdAccess(); diff --git a/app/src/main/java/com/obs/services/internal/io/HttpMethodReleaseInputStream.java b/app/src/main/java/com/obs/services/internal/io/HttpMethodReleaseInputStream.java index 1791d4d..885d607 100644 --- a/app/src/main/java/com/obs/services/internal/io/HttpMethodReleaseInputStream.java +++ b/app/src/main/java/com/obs/services/internal/io/HttpMethodReleaseInputStream.java @@ -121,6 +121,7 @@ public void close() throws IOException { inputStream.close(); } + @Override public InputStream getWrappedInputStream() { return inputStream; } diff --git a/app/src/main/java/com/obs/services/internal/security/ProviderCredentials.java b/app/src/main/java/com/obs/services/internal/security/ProviderCredentials.java index 3c8d207..2391e41 100644 --- a/app/src/main/java/com/obs/services/internal/security/ProviderCredentials.java +++ b/app/src/main/java/com/obs/services/internal/security/ProviderCredentials.java @@ -21,6 +21,7 @@ import com.obs.services.internal.ObsConstraint; import com.obs.services.model.AuthTypeEnum; +import java.security.SecureRandom; import java.util.LinkedHashMap; import java.util.Map; @@ -31,6 +32,8 @@ public class ProviderCredentials { private LinkedHashMap localAuthType; + private SecureRandom secureRandom; + private IObsCredentialsProvider obsCredentialsProvider; private boolean isAuthTypeNegotiation; @@ -103,4 +106,12 @@ public LinkedHashMap getLocalAuthType() { public void setLocalAuthType(LinkedHashMap localAuthType) { this.localAuthType = localAuthType; } + + public SecureRandom getSecureRandom() { + return secureRandom; + } + + public void setSecureRandom(SecureRandom secureRandom) { + this.secureRandom = secureRandom; + } } diff --git a/app/src/main/java/com/obs/services/internal/service/AbstractRequestConvertor.java b/app/src/main/java/com/obs/services/internal/service/AbstractRequestConvertor.java index 7c5199c..259f94a 100644 --- a/app/src/main/java/com/obs/services/internal/service/AbstractRequestConvertor.java +++ b/app/src/main/java/com/obs/services/internal/service/AbstractRequestConvertor.java @@ -50,6 +50,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.Locale; public abstract class AbstractRequestConvertor extends RestStorageService { private static final ILogger log = LoggerBuilder.getLogger("com.obs.services.ObsClient"); @@ -201,7 +202,7 @@ protected void setHeadersAndStatus(HeaderResponse response, Response res, boolea protected void putCleanedKeyAndValues(Map responseHeaders, String key, List values, boolean needDecode) { - String cleanedKey = key.toLowerCase(); + String cleanedKey = key.toLowerCase(Locale.ROOT); List cleanedValues = new ArrayList<>(values.size()); Object finalValues; if ((Constants.CommonHeaders.DATE.equalsIgnoreCase(key) @@ -224,7 +225,7 @@ protected void putCleanedKeyAndValues(Map responseHeaders, } } else { for (String prefix : Constants.NOT_NEED_HEADER_PREFIXES) { - if (key.toLowerCase().startsWith(prefix)) { + if (key.toLowerCase(Locale.ROOT).startsWith(prefix)) { cleanedKey = cleanedKey.replace(prefix, ""); break; } diff --git a/app/src/main/java/com/obs/services/internal/service/ObsBucketAdvanceService.java b/app/src/main/java/com/obs/services/internal/service/ObsBucketAdvanceService.java index 98ca269..e40725b 100644 --- a/app/src/main/java/com/obs/services/internal/service/ObsBucketAdvanceService.java +++ b/app/src/main/java/com/obs/services/internal/service/ObsBucketAdvanceService.java @@ -75,6 +75,8 @@ import com.obs.services.model.SpecialParamEnum; import com.obs.services.model.StorageClassEnum; import com.obs.services.model.WebsiteConfiguration; +import com.obs.services.model.crr.GetCrrProgressRequest; +import com.obs.services.model.crr.GetCrrProgressResult; import com.obs.services.model.fs.GetBucketFSStatusResult; import com.obs.services.model.http.HttpStatusCode; import com.oef.services.model.RequestParamEnum; @@ -410,6 +412,25 @@ protected ReplicationConfiguration getBucketReplicationConfigurationImpl(BaseBuc return result; } + protected GetCrrProgressResult getCrrProgressImpl(GetCrrProgressRequest request) { + Map requestParameters = new HashMap<>(); + requestParameters.put(SpecialParamEnum.REPLICATION_PROGRESS.getOriginalStringCode(), ""); + requestParameters.put(SpecialParamEnum.RULE_ID.getOriginalStringCode(), request.getRuleId()); + NewTransResult newResult = new NewTransResult(); + newResult.setHttpMethod(HttpMethodEnum.GET); + newResult.setBucketName(request.getBucketName()); + newResult.setParams(requestParameters); + Response httpResponse = performRequest(newResult, true, false, false, false); + + this.verifyResponseContentType(httpResponse); + GetCrrProgressResult result = getXmlResponseSaxParser() + .parse(new HttpMethodReleaseInputStream(httpResponse), + XmlResponsesSaxParser.GetCrrProgressResultHandler.class, false) + .getReplicationConfiguration(); + setHeadersAndStatus(result, httpResponse); + return result; + } + protected HeaderResponse deleteBucketReplicationConfigurationImpl(BaseBucketRequest request) throws ServiceException { Map requestParameters = new HashMap<>(); @@ -832,13 +853,13 @@ protected void createBucketWithClusterId(CreateVirtualBucketRequest request, Lis request.getRegionId(), azIds.get(0)); createBucketWithClusterGroupId(locationClusterGroupIdHeader, request.getBucketName2(), request.getRegionId(), azIds.get(1)); - } else if (bucket1Id.isEmpty() && !bucket2Id.isEmpty()) { + } else if (bucket1Id.isEmpty()) { createBucketWithClusterGroupId(locationClusterGroupIdHeader, request.getBucketName1(), - request.getRegionId(), azIds.get(0) == bucket2Id ? azIds.get(1) : azIds.get(0)); - } else if (!bucket1Id.isEmpty() && bucket2Id.isEmpty()) { + request.getRegionId(), bucket2Id.equals(azIds.get(0)) ? azIds.get(1) : azIds.get(0)); + } else if (bucket2Id.isEmpty()) { createBucketWithClusterGroupId(locationClusterGroupIdHeader, request.getBucketName2(), - request.getRegionId(), azIds.get(0) == bucket1Id ? azIds.get(1) : azIds.get(0)); - } else if (bucket1Id == bucket2Id) { + request.getRegionId(), bucket1Id.equals(azIds.get(0)) ? azIds.get(1) : azIds.get(0)); + } else if (bucket1Id.equals(bucket2Id)) { throw new ObsException("the two bucket is in same az"); } } diff --git a/app/src/main/java/com/obs/services/internal/service/ObsBucketBaseService.java b/app/src/main/java/com/obs/services/internal/service/ObsBucketBaseService.java index a8dfbaf..f786bb3 100644 --- a/app/src/main/java/com/obs/services/internal/service/ObsBucketBaseService.java +++ b/app/src/main/java/com/obs/services/internal/service/ObsBucketBaseService.java @@ -103,20 +103,32 @@ protected HeaderResponse deleteBucketImpl(BaseBucketRequest request) throws Serv protected ListBucketsResult listAllBucketsImpl(ListBucketsRequest request) throws ServiceException { Map headers = new HashMap<>(); - if (request != null && request.isQueryLocation()) { - this.putHeader(headers, this.getIHeaders("").locationHeader(), Constants.TRUE); - } - if (request != null && request.getBucketType() != null) { - this.putHeader(headers, this.getIHeaders("").bucketTypeHeader(), request.getBucketType().getCode()); + Map params = new HashMap<>(); + + if (request != null) { + if (request.isQueryLocation()) { + this.putHeader(headers, this.getIHeaders("").locationHeader(), Constants.TRUE); + } + if (request.getBucketType() != null) { + this.putHeader(headers, this.getIHeaders("").bucketTypeHeader(), request.getBucketType().getCode()); + } + if (request.getMaxKeys() > 0) { + params.put(Constants.ObsRequestParams.MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (request.getMarker() != null) { + params.put(Constants.ObsRequestParams.MARKER, request.getMarker()); + } } - Response httpResponse = performRestGetForListBuckets("", null, null, headers); + + Response httpResponse = performRestGetForListBuckets("", null, params, headers); this.verifyResponseContentType(httpResponse); XmlResponsesSaxParser.ListBucketsHandler handler = getXmlResponseSaxParser().parse( new HttpMethodReleaseInputStream(httpResponse), XmlResponsesSaxParser.ListBucketsHandler.class, true); - ListBucketsResult result = new ListBucketsResult(handler.getBuckets(), handler.getOwner()); + ListBucketsResult result = new ListBucketsResult(handler.getBuckets(), handler.getOwner(), + handler.isTruncated(), handler.getMarker(), handler.getMaxKeys(), handler.getNextMarker()); setHeadersAndStatus(result, httpResponse); return result; diff --git a/app/src/main/java/com/obs/services/internal/service/ObsObjectService.java b/app/src/main/java/com/obs/services/internal/service/ObsObjectService.java index f7201a6..8d51edc 100644 --- a/app/src/main/java/com/obs/services/internal/service/ObsObjectService.java +++ b/app/src/main/java/com/obs/services/internal/service/ObsObjectService.java @@ -26,6 +26,8 @@ import com.obs.services.internal.Constants.ObsRequestParams; import com.obs.services.internal.RepeatableRequestEntity; import com.obs.services.internal.ServiceException; +import com.obs.services.internal.handler.XmlResponsesSaxParser; +import com.obs.services.internal.io.HttpMethodReleaseInputStream; import com.obs.services.internal.trans.NewTransResult; import com.obs.services.internal.utils.Mimetypes; import com.obs.services.internal.utils.ServiceUtils; @@ -45,6 +47,9 @@ import com.obs.services.model.TruncateObjectResult; import okhttp3.Response; +import com.obs.services.model.ObjectTagResult; +import com.obs.services.model.ObjectTaggingRequest; +import com.obs.services.model.HeaderResponse; public abstract class ObsObjectService extends ObsMultipartObjectService { private static final ILogger log = LoggerBuilder.getLogger(ObsObjectService.class); @@ -185,4 +190,54 @@ protected ModifyObjectResult modifyObjectImpl(ModifyObjectRequest request) throw } return ret; } + protected ObjectTagResult getObjectTaggingImpl(ObjectTaggingRequest request) throws ServiceException { + Map requestParams = new HashMap<>(); + requestParams.put(SpecialParamEnum.TAGGING.getOriginalStringCode(), ""); + if(request.getObjectVersionId() != null && !request.getObjectVersionId().equals("")) { + requestParams.put(ObsRequestParams.VERSION_ID, request.getObjectVersionId()); + } + Response httpResponse = this.performRestGet(request.getBucketName(), request.getObjectKey(), requestParams, + transRequestPaymentHeaders(request, null, this.getIHeaders(request.getBucketName())), + request.getUserHeaders()); + + this.verifyResponseContentType(httpResponse); + + ObjectTagResult result = getXmlResponseSaxParser().parse(new HttpMethodReleaseInputStream(httpResponse), + XmlResponsesSaxParser.ObjectTagInfoHandler.class, false).getObjectTagInfo(); + setHeadersAndStatus(result, httpResponse); + return result; + } + protected HeaderResponse setObjectTaggingImpl(ObjectTaggingRequest request) throws ServiceException { + Map requestParams = new HashMap<>(); + requestParams.put(SpecialParamEnum.TAGGING.getOriginalStringCode(), ""); + if(request.getObjectVersionId() != null && !request.getObjectVersionId().equals("")) { + requestParams.put(ObsRequestParams.VERSION_ID, request.getObjectVersionId()); + } + Map headers = new HashMap<>(); + + String xml = this.getIConvertor(request.getBucketName()).transObjectTagInfo(request.getObjectTagInfo()); + + headers.put(CommonHeaders.CONTENT_MD5, ServiceUtils.computeMD5(xml)); + headers.put(CommonHeaders.CONTENT_TYPE, Mimetypes.MIMETYPE_XML); + + transRequestPaymentHeaders(request, headers, this.getIHeaders(request.getBucketName())); + + NewTransResult result = transObjectRequest(request); + result.setParams(requestParams); + result.setHeaders(headers); + result.setBody(createRequestBody(Mimetypes.MIMETYPE_XML, xml)); + Response response = performRequest(result); + return build(response); + } + protected HeaderResponse deleteObjectTaggingImpl(ObjectTaggingRequest request) throws ServiceException { + Map requestParams = new HashMap<>(); + requestParams.put(SpecialParamEnum.TAGGING.getOriginalStringCode(), ""); + if(request.getObjectVersionId() != null && !request.getObjectVersionId() .equals("")) { + requestParams.put(ObsRequestParams.VERSION_ID, request.getObjectVersionId()); + } + Response response = performRestDelete(request.getBucketName(), request.getObjectKey(), requestParams, + transRequestPaymentHeaders(request, null, this.getIHeaders(request.getBucketName())), + request.getUserHeaders()); + return build(response); + } } diff --git a/app/src/main/java/com/obs/services/internal/service/RequestConvertor.java b/app/src/main/java/com/obs/services/internal/service/RequestConvertor.java index 0d62086..382593a 100644 --- a/app/src/main/java/com/obs/services/internal/service/RequestConvertor.java +++ b/app/src/main/java/com/obs/services/internal/service/RequestConvertor.java @@ -31,6 +31,7 @@ import com.obs.services.internal.utils.RestUtils; import com.obs.services.internal.utils.ServiceUtils; import com.obs.services.internal.xml.OBSXMLBuilder; +import com.obs.services.model.ActionEnum; import com.obs.services.model.AppendObjectRequest; import com.obs.services.model.AuthTypeEnum; import com.obs.services.model.BucketTypeEnum; @@ -59,6 +60,7 @@ import com.obs.services.model.fs.ListContentSummaryRequest; import com.obs.services.model.fs.NewBucketRequest; import com.obs.services.model.fs.WriteFileRequest; +import com.obs.services.model.fusion.RedundancyTypeEnum; import okhttp3.RequestBody; import javax.xml.parsers.FactoryConfigurationError; @@ -75,6 +77,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.Locale; public abstract class RequestConvertor extends AclHeaderConvertor { private static final ILogger log = LoggerBuilder.getLogger("com.obs.services.ObsClient"); @@ -174,7 +177,7 @@ private void selectAllowedHeader(Map headers, ObjectMetadata obj key = key.trim(); if ((CAN_USE_STANDARD_HTTP_HEADERS.get() == null || (CAN_USE_STANDARD_HTTP_HEADERS.get() != null && !CAN_USE_STANDARD_HTTP_HEADERS.get())) - && Constants.ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES.contains(key.toLowerCase())) { + && Constants.ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES.contains(key.toLowerCase(Locale.ROOT))) { continue; } headers.put(key, entry.getValue() == null ? "" : entry.getValue().toString()); @@ -284,6 +287,21 @@ protected TransResult transCreateBucketRequest(CreateBucketRequest request) thro } } + String headerPrefix = this.getProviderCredentials().getLocalAuthType(request.getBucketName()) + != AuthTypeEnum.OBS ? Constants.V2_HEADER_PREFIX : Constants.OBS_HEADER_PREFIX; + if (request.getBucketRedundancy() == RedundancyTypeEnum.FUSION) { + putHeader(headers, headerPrefix + Constants.CommonHeaders.BUCKET_REDUNDANCY, + String.valueOf(RedundancyTypeEnum.FUSION.getCode())); + } + if (request.getFusionAllowUpgrade() != ActionEnum.DEFAULT) { + putHeader(headers, headerPrefix + Constants.CommonHeaders.FUSION_ALLOW_UPGRADE, + String.valueOf(request.getFusionAllowUpgrade().getCode())); + } + if (request.getFusionAllowAlternative() != ActionEnum.DEFAULT) { + putHeader(headers, headerPrefix + Constants.CommonHeaders.FUSION_ALLOW_ALTERNATIVE, + String.valueOf(request.getFusionAllowAlternative().getCode())); + } + String contentType = Mimetypes.MIMETYPE_XML; headers.put(Constants.CommonHeaders.CONTENT_TYPE, contentType); TransResult result = new TransResult(headers); @@ -492,7 +510,7 @@ protected TransResult transCopyObjectRequest(CopyObjectRequest request) throws S continue; } key = key.trim(); - if (Constants.ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES.contains(key.toLowerCase())) { + if (Constants.ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES.contains(key.toLowerCase(Locale.ROOT))) { continue; } headers.put(key, entry.getValue() == null ? "" : entry.getValue().toString()); diff --git a/app/src/main/java/com/obs/services/internal/utils/AbstractAuthentication.java b/app/src/main/java/com/obs/services/internal/utils/AbstractAuthentication.java index f72fc4b..bc0017b 100644 --- a/app/src/main/java/com/obs/services/internal/utils/AbstractAuthentication.java +++ b/app/src/main/java/com/obs/services/internal/utils/AbstractAuthentication.java @@ -77,8 +77,8 @@ public final String makeServiceCanonicalString(String method, String resource, M if (paramNameValue.length > 1) { value = URLDecoder.decode(paramNameValue[1], Constants.DEFAULT_ENCODING); } - if (serviceResourceParameterNames.contains(name.toLowerCase()) - || name.toLowerCase().startsWith(headerPrefix)) { + if (serviceResourceParameterNames.contains(name.toLowerCase(Locale.ROOT)) + || name.toLowerCase(Locale.ROOT).startsWith(headerPrefix)) { sortedResourceParams.put(name, value); } } @@ -135,9 +135,9 @@ private StringBuilder transCanonicalString(String method, String headerPrefix, @SuppressWarnings("unchecked") private SortedMap transHeaders(Map headersMap, String headerPrefix, String expires) { - String dateHeader = Constants.CommonHeaders.DATE.toLowerCase(); - String contentTypeHeader = Constants.CommonHeaders.CONTENT_TYPE.toLowerCase(); - String contentMd5Header = Constants.CommonHeaders.CONTENT_MD5.toLowerCase(); + String dateHeader = Constants.CommonHeaders.DATE.toLowerCase(Locale.ROOT); + String contentTypeHeader = Constants.CommonHeaders.CONTENT_TYPE.toLowerCase(Locale.ROOT); + String contentMd5Header = Constants.CommonHeaders.CONTENT_MD5.toLowerCase(Locale.ROOT); SortedMap interestingHeaders = new TreeMap(); if (null != headersMap) { diff --git a/app/src/main/java/com/obs/services/internal/utils/JSONChange.java b/app/src/main/java/com/obs/services/internal/utils/JSONChange.java index 3c1b2fe..8b6182f 100644 --- a/app/src/main/java/com/obs/services/internal/utils/JSONChange.java +++ b/app/src/main/java/com/obs/services/internal/utils/JSONChange.java @@ -120,8 +120,6 @@ public MyObjectMapper() { // 不包含空值属性 this.setSerializationInclusion(Include.NON_EMPTY); this.setSerializationInclusion(Include.NON_NULL); - // this.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, - // true); // 是否缩放排列输出,默认false, this.configure(SerializationFeature.INDENT_OUTPUT, false); } diff --git a/app/src/main/java/com/obs/services/internal/utils/RestUtils.java b/app/src/main/java/com/obs/services/internal/utils/RestUtils.java index cb629c7..4658785 100644 --- a/app/src/main/java/com/obs/services/internal/utils/RestUtils.java +++ b/app/src/main/java/com/obs/services/internal/utils/RestUtils.java @@ -29,18 +29,18 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.SocketFactory; -import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; @@ -71,6 +71,14 @@ public class RestUtils { private static final ILogger log = LoggerBuilder.getLogger(RestUtils.class); + private static final Set SPECIAL_CHAR = new HashSet<>(); + + static { + SPECIAL_CHAR.add('_'); + SPECIAL_CHAR.add('-'); + SPECIAL_CHAR.add('~'); + SPECIAL_CHAR.add('.'); + } //CHECKSTYLE:OFF private static Pattern chinesePattern = Pattern.compile("[\u4e00-\u9fa5]"); @@ -118,8 +126,9 @@ private static void tryEncode(CharSequence input, boolean chineseOnly, StringBui } else { for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); - if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' - || ch == '-' || ch == '~' || ch == '.') { + boolean isAlpha = (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); + boolean isNumber = (ch >= '0' && ch <= '9'); + if (isAlpha || isNumber || SPECIAL_CHAR.contains(ch)) { result.append(ch); } else if (ch == '/') { result.append("%2F"); @@ -164,7 +173,8 @@ public static String encodeUrlPath(String path, String delimiter) throws Service return result.toString(); } - private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm, String provider) throws Exception { + private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm, String provider, + SecureRandom secureRandom) throws Exception { SSLContext sslContext; try { sslContext = SSLContext.getInstance("TLSv1.2", provider); @@ -179,11 +189,12 @@ private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm, S } } } - sslContext.init(km, tm, SecureRandom.getInstanceStrong()); + sslContext.init(km, tm, secureRandom); return sslContext; } - private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm) throws Exception { + private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm, + SecureRandom secureRandom) throws Exception { SSLContext sslContext; try { sslContext = SSLContext.getInstance("TLSv1.2"); @@ -198,7 +209,7 @@ private static SSLContext createSSLContext(KeyManager[] km, TrustManager[] tm) t } } } - sslContext.init(km, tm, SecureRandom.getInstanceStrong()); + sslContext.init(km, tm, secureRandom); return sslContext; } @@ -317,9 +328,9 @@ public Socket createSocket(InetAddress address, int port, InetAddress localAddre } - public static OkHttpClient.Builder initHttpClientBuilder(ObsProperties obsProperties, + public static OkHttpClient.Builder initHttpClientBuilder(ObsProperties obsProperties, KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory, - Dispatcher httpDispatcher) { + Dispatcher httpDispatcher, SecureRandom secureRandom) { List protocols = new ArrayList(2); protocols.add(Protocol.HTTP_1_1); @@ -330,9 +341,6 @@ public static OkHttpClient.Builder initHttpClientBuilder(ObsProperties obsProper } OkHttpClient.Builder builder = new OkHttpClient.Builder(); - // OkHttpClient.Builder builder = new - // OkHttpClient.Builder().addNetworkInterceptor(new - // RemoveDirtyConnIntercepter()); initHttpDispatcher(obsProperties, httpDispatcher, builder); @@ -390,7 +398,7 @@ public static OkHttpClient.Builder initHttpClientBuilder(ObsProperties obsProper SSLContext sslContext = null; if (ServiceUtils.isValid(provider)) { try { - sslContext = createSSLContext(km, tm, provider); + sslContext = createSSLContext(km, tm, provider, secureRandom); } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Exception happened in create ssl context with provider" + provider, e); @@ -398,7 +406,7 @@ public static OkHttpClient.Builder initHttpClientBuilder(ObsProperties obsProper } } if (sslContext == null) { - sslContext = createSSLContext(km, tm); + sslContext = createSSLContext(km, tm, secureRandom); } SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); builder.sslSocketFactory(new WrapperedSSLSocketFactory(sslSocketFactory, socketReadWriteBufferSize), diff --git a/app/src/main/java/com/obs/services/internal/utils/ServiceUtils.java b/app/src/main/java/com/obs/services/internal/utils/ServiceUtils.java index de5a5c8..2634f82 100644 --- a/app/src/main/java/com/obs/services/internal/utils/ServiceUtils.java +++ b/app/src/main/java/com/obs/services/internal/utils/ServiceUtils.java @@ -179,7 +179,7 @@ public static String signWithHmacSha1(String sk, String canonicalString) throws private static String transRealKey(String headerPrefix, String metadataPrefix, String key, boolean needDecode) throws UnsupportedEncodingException { - if (key.toLowerCase().startsWith(metadataPrefix)) { + if (key.toLowerCase(Locale.ROOT).startsWith(metadataPrefix)) { key = key.substring(metadataPrefix.length()); if (needDecode) { key = URLDecoder.decode(key, Constants.DEFAULT_ENCODING); @@ -208,7 +208,7 @@ public static Map cleanRestMetadataMapV2(Map met // Trim prefixes from keys. key = key != null ? key : ""; - if (key.toLowerCase().startsWith(headerPrefix)) { + if (key.toLowerCase(Locale.ROOT).startsWith(headerPrefix)) { try { key = transRealKey(headerPrefix, metadataPrefix, key, needDecode); if (needDecode) { @@ -220,7 +220,7 @@ public static Map cleanRestMetadataMapV2(Map met } } - } else if (key.toLowerCase().startsWith(Constants.OBS_HEADER_PREFIX)) { + } else if (key.toLowerCase(Locale.ROOT).startsWith(Constants.OBS_HEADER_PREFIX)) { try { key = transRealKey(Constants.OBS_HEADER_PREFIX, Constants.OBS_HEADER_META_PREFIX, key, needDecode); @@ -255,7 +255,7 @@ public static Map cleanUserMetadata(Map original Map userMetadata = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (Map.Entry entry : originalHeaders.entrySet()) { String key = entry.getKey(); - if (key.toLowerCase().startsWith("x-obs-meta-") || key.toLowerCase().startsWith("x-amz-meta-")) { + if (key.toLowerCase(Locale.ROOT).startsWith("x-obs-meta-") || key.toLowerCase(Locale.ROOT).startsWith("x-amz-meta-")) { Object originalValue = originalHeaders.get(key); try { if (originalValue instanceof ArrayList) { @@ -523,6 +523,15 @@ public static SimpleDateFormat getExpirationDateFormat() { return format; } + public static ObsException changeFromException(Exception e) { + boolean isObsException = e instanceof ObsException; + if (!isObsException) { + return new ObsException(e.getMessage(), e); + } else { + return (ObsException) e; + } + } + public static ObsException changeFromServiceException(ServiceException se) { ObsException exception; if (se.getResponseCode() < 0) { diff --git a/app/src/main/java/com/obs/services/model/ActionEnum.java b/app/src/main/java/com/obs/services/model/ActionEnum.java new file mode 100644 index 0000000..bfe9a24 --- /dev/null +++ b/app/src/main/java/com/obs/services/model/ActionEnum.java @@ -0,0 +1,33 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model; + +public enum ActionEnum { + DEFAULT("default"), + + TRUE("true"), + + FALSE("false"); + + private String code; + + ActionEnum(String code) { + this.code = code; + } + + public String getCode() { + return code; + } +} diff --git a/app/src/main/java/com/obs/services/model/CanonicalGrantee.java b/app/src/main/java/com/obs/services/model/CanonicalGrantee.java index b24e5e0..b9f5c30 100644 --- a/app/src/main/java/com/obs/services/model/CanonicalGrantee.java +++ b/app/src/main/java/com/obs/services/model/CanonicalGrantee.java @@ -41,6 +41,7 @@ public CanonicalGrantee(String identifier) { * @param canonicalGrantId * ID of the domain to which the grantee belongs */ + @Override public void setIdentifier(String canonicalGrantId) { this.grantId = canonicalGrantId; } @@ -50,6 +51,7 @@ public void setIdentifier(String canonicalGrantId) { * * @return ID of the domain to which the grantee belongs */ + @Override public String getIdentifier() { return grantId; } diff --git a/app/src/main/java/com/obs/services/model/CreateBucketRequest.java b/app/src/main/java/com/obs/services/model/CreateBucketRequest.java index bca3702..cbeafee 100644 --- a/app/src/main/java/com/obs/services/model/CreateBucketRequest.java +++ b/app/src/main/java/com/obs/services/model/CreateBucketRequest.java @@ -20,6 +20,8 @@ import java.util.Set; import com.obs.services.internal.utils.ServiceUtils; +import com.obs.services.model.fusion.FusionReplicateEnum; +import com.obs.services.model.fusion.RedundancyTypeEnum; /** * Parameters in a bucket creation request @@ -47,6 +49,12 @@ public class CreateBucketRequest extends GenericRequest { private BucketTypeEnum bucketType = BucketTypeEnum.OBJECT; + private RedundancyTypeEnum bucketRedundancy = RedundancyTypeEnum.CLASSIC; + + private ActionEnum fusionAllowUpgrade = ActionEnum.DEFAULT; + + private ActionEnum fusionAllowAlternative = ActionEnum.DEFAULT; + public CreateBucketRequest() { } @@ -269,4 +277,28 @@ public BucketTypeEnum getBucketType() { public void setBucketType(BucketTypeEnum bucketType) { this.bucketType = bucketType; } + + public RedundancyTypeEnum getBucketRedundancy() { + return bucketRedundancy; + } + + public void setBucketRedundancy(RedundancyTypeEnum bucketRedundancy) { + this.bucketRedundancy = bucketRedundancy; + } + + public ActionEnum getFusionAllowUpgrade() { + return fusionAllowUpgrade; + } + + public void setFusionAllowUpgrade(ActionEnum fusionAllowUpgrade) { + this.fusionAllowUpgrade = fusionAllowUpgrade; + } + + public ActionEnum getFusionAllowAlternative() { + return fusionAllowAlternative; + } + + public void setFusionAllowAlternative(ActionEnum fusionAllowAlternative) { + this.fusionAllowAlternative = fusionAllowAlternative; + } } diff --git a/app/src/main/java/com/obs/services/model/GetObjectAclRequest.java b/app/src/main/java/com/obs/services/model/GetObjectAclRequest.java index 5f3b072..f2fddc2 100644 --- a/app/src/main/java/com/obs/services/model/GetObjectAclRequest.java +++ b/app/src/main/java/com/obs/services/model/GetObjectAclRequest.java @@ -71,6 +71,7 @@ public void setVersionId(String versionId) { * * @return Object name */ + @Override public String getObjectKey() { return objectKey; } @@ -81,6 +82,7 @@ public String getObjectKey() { * @param objectKey * Object name */ + @Override public void setObjectKey(String objectKey) { this.objectKey = objectKey; } diff --git a/app/src/main/java/com/obs/services/model/GetObjectMetadataRequest.java b/app/src/main/java/com/obs/services/model/GetObjectMetadataRequest.java index 3550ab4..a474343 100644 --- a/app/src/main/java/com/obs/services/model/GetObjectMetadataRequest.java +++ b/app/src/main/java/com/obs/services/model/GetObjectMetadataRequest.java @@ -83,6 +83,7 @@ public void setSseCHeader(SseCHeader sseCHeader) { * * @return Object name */ + @Override public String getObjectKey() { return objectKey; } @@ -93,6 +94,7 @@ public String getObjectKey() { * @param objectKey * Object name */ + @Override public void setObjectKey(String objectKey) { this.objectKey = objectKey; } diff --git a/app/src/main/java/com/obs/services/model/GetObjectRequest.java b/app/src/main/java/com/obs/services/model/GetObjectRequest.java index b2b1630..769a5eb 100644 --- a/app/src/main/java/com/obs/services/model/GetObjectRequest.java +++ b/app/src/main/java/com/obs/services/model/GetObjectRequest.java @@ -115,6 +115,7 @@ public void setReplaceMetadata(ObjectRepleaceMetadata replaceMetadata) { * * @return SSE-C decryption headers */ + @Override public SseCHeader getSseCHeader() { return sseCHeader; } @@ -125,6 +126,7 @@ public SseCHeader getSseCHeader() { * @param sseCHeader * SSE-C decryption headers */ + @Override public void setSseCHeader(SseCHeader sseCHeader) { this.sseCHeader = sseCHeader; } @@ -173,6 +175,7 @@ public void setRangeEnd(Long rangeEnd) { * * @return Version ID of the object */ + @Override public String getVersionId() { return versionId; } @@ -184,6 +187,7 @@ public String getVersionId() { * Version ID of the object * */ + @Override public void setVersionId(String versionId) { this.versionId = versionId; } diff --git a/app/src/main/java/com/obs/services/model/HttpMethodEnum.java b/app/src/main/java/com/obs/services/model/HttpMethodEnum.java index a740930..ab92040 100644 --- a/app/src/main/java/com/obs/services/model/HttpMethodEnum.java +++ b/app/src/main/java/com/obs/services/model/HttpMethodEnum.java @@ -14,6 +14,8 @@ package com.obs.services.model; +import java.util.Locale; + /** * HTTP/HTTPS request method */ @@ -58,7 +60,7 @@ private HttpMethodEnum(String operationType) { } public String getOperationType() { - return this.operationType.toUpperCase(); + return this.operationType.toUpperCase(Locale.ROOT); } public static HttpMethodEnum getValueFromStringCode(String operationType) { @@ -67,7 +69,7 @@ public static HttpMethodEnum getValueFromStringCode(String operationType) { } for (HttpMethodEnum installMode : HttpMethodEnum.values()) { - if (installMode.getOperationType().equals(operationType.toUpperCase())) { + if (installMode.getOperationType().equals(operationType.toUpperCase(Locale.ROOT))) { return installMode; } } diff --git a/app/src/main/java/com/obs/services/model/LifecycleConfiguration.java b/app/src/main/java/com/obs/services/model/LifecycleConfiguration.java index 3a17640..c99e5a0 100644 --- a/app/src/main/java/com/obs/services/model/LifecycleConfiguration.java +++ b/app/src/main/java/com/obs/services/model/LifecycleConfiguration.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; - +import com.obs.services.model.BucketTagInfo.TagSet; import com.obs.services.internal.utils.ObjectUtils; import com.obs.services.internal.utils.ServiceUtils; @@ -590,6 +590,8 @@ public String toString() { public class Rule { protected String id; + protected TagSet tagSet; + protected String prefix; protected Boolean enabled; @@ -623,6 +625,22 @@ public Rule(String id, String prefix, Boolean enabled) { this.enabled = enabled; } + /** + * @param id + * Rule ID + * @param prefix + * Object name prefix identifying one or more objects to + * which the rule applies + * @param enabled + * Identifier that specifies whether the rule is enabled + */ + public Rule(String id, String prefix, TagSet tagset, Boolean enabled) { + this.id = id; + this.tagSet = tagset; + this.prefix = prefix; + this.enabled = enabled; + } + /** * Expiration time of objects * @@ -690,6 +708,25 @@ public void setId(String id) { this.id = id; } + /** + * Obtain the rule tagSet. + * + * @return Rule tagSet + */ + public TagSet getTagSet() { + return this.tagSet; + } + + /** + * Set the rule tagSet. + * + * @param tagSet + * Rule tagSet + */ + public void setTagSet(TagSet tagSet) { + this.tagSet = tagSet; + } + /** * Obtain the object name prefix used to identify one or more objects to * which the rule applies. diff --git a/app/src/main/java/com/obs/services/model/ListBucketsRequest.java b/app/src/main/java/com/obs/services/model/ListBucketsRequest.java index 3662421..f4ce88e 100644 --- a/app/src/main/java/com/obs/services/model/ListBucketsRequest.java +++ b/app/src/main/java/com/obs/services/model/ListBucketsRequest.java @@ -23,6 +23,10 @@ public class ListBucketsRequest { private BucketTypeEnum bucketType; + private int maxKeys; + + private String marker; + public boolean isQueryLocation() { return queryLocation; } @@ -49,4 +53,20 @@ public BucketTypeEnum getBucketType() { public void setBucketType(BucketTypeEnum bucketType) { this.bucketType = bucketType; } + + public int getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } } diff --git a/app/src/main/java/com/obs/services/model/ListBucketsResult.java b/app/src/main/java/com/obs/services/model/ListBucketsResult.java index 27bdbe7..bc46a59 100644 --- a/app/src/main/java/com/obs/services/model/ListBucketsResult.java +++ b/app/src/main/java/com/obs/services/model/ListBucketsResult.java @@ -26,14 +26,27 @@ public class ListBucketsResult extends HeaderResponse { private Owner owner; - public ListBucketsResult(List buckets, Owner owner) { + private boolean truncated; + + private String marker; + + private int maxKeys; + + private String nextMarker; + + public ListBucketsResult(List buckets, Owner owner, boolean truncated, String marker, int maxKeys, + String nextMarker) { this.buckets = buckets; this.owner = owner; + this.truncated = truncated; + this.marker = marker; + this.maxKeys = maxKeys; + this.nextMarker = nextMarker; } public List getBuckets() { if (buckets == null) { - buckets = new ArrayList(); + buckets = new ArrayList<>(); } return buckets; } @@ -42,6 +55,22 @@ public Owner getOwner() { return owner; } + public boolean isTruncated() { + return truncated; + } + + public String getMarker() { + return marker; + } + + public int getMaxKeys() { + return maxKeys; + } + + public String getNextMarker() { + return nextMarker; + } + @Override public String toString() { return "ListBucketsResult [buckets=" + buckets + ", owner=" + owner + "]"; diff --git a/app/src/main/java/com/obs/services/model/ObjectTagResult.java b/app/src/main/java/com/obs/services/model/ObjectTagResult.java new file mode 100644 index 0000000..15055a0 --- /dev/null +++ b/app/src/main/java/com/obs/services/model/ObjectTagResult.java @@ -0,0 +1,77 @@ +/** +* Copyright 2019 Huawei Technologies Co.,Ltd. +* Licensed 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.obs.services.model; + +import com.obs.services.model.BucketTagInfo.TagSet; +/** + * Object tagging configuration + * + */ +public class ObjectTagResult extends HeaderResponse { + private TagSet tagSet; + + public ObjectTagResult() { + + } + + /** + * Constructor + * + * @param tagSet + * Object tag set + */ + public ObjectTagResult(TagSet tagSet) { + this.tagSet = tagSet; + } + + /** + * Obtain the tag set of an Object. + * + * @return Tag set + */ + public TagSet getTagSet() { + if (tagSet == null) { + tagSet = new TagSet(); + } + return tagSet; + } + + /** + * Configure the tag set for an Object. + * + * @param tagSet + * Tag set + */ + public void setTagSet(TagSet tagSet) { + this.tagSet = tagSet; + } + + @Override + public String toString() { + StringBuilder s = new StringBuilder("["); + if (tagSet != null) { + int i = 0; + for (TagSet.Tag t : tagSet.getTags()) { + s.append("[").append("key=").append(t.getKey()).append(",").append("value=").append(t.getValue()) + .append("]"); + if (i++ != tagSet.getTags().size() - 1) { + s.append(","); + } + } + } + s.append("]"); + return "ObjectTagResult [tagSet=[tags=" + s + "]"; + } +} diff --git a/app/src/main/java/com/obs/services/model/ObjectTaggingRequest.java b/app/src/main/java/com/obs/services/model/ObjectTaggingRequest.java new file mode 100644 index 0000000..cc01912 --- /dev/null +++ b/app/src/main/java/com/obs/services/model/ObjectTaggingRequest.java @@ -0,0 +1,56 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model; + +/** + * Request for setting tags for a object + * + * @since 3.22.12 + * + */ +public class ObjectTaggingRequest extends BaseObjectRequest { + + { + httpMethod = HttpMethodEnum.PUT; + } + + protected String versionId; + private ObjectTagResult objectTagResult; + + public ObjectTaggingRequest(String bucketName, String objectKey, String versionId, ObjectTagResult objectTagResult) { + this.bucketName = bucketName; + this.objectKey = objectKey; + this.versionId = versionId; + this.objectTagResult = objectTagResult; + } + + public ObjectTagResult getObjectTagInfo() { + return objectTagResult; + } + + public void setObjectTagging(ObjectTagResult objectTagResult) { + this.objectTagResult = objectTagResult; + } + + @Override + public String toString() { + return "ObjectTaggingRequest [ObjectTagResult=" + objectTagResult + ", getObjectKey()=" + getObjectKey() + + ", getObjectVersionId()=" + getObjectVersionId() + ", isRequesterPays()=" + isRequesterPays() + "]"; + } + + public String getObjectVersionId() { + return this.versionId; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/obs/services/model/ObsBucket.java b/app/src/main/java/com/obs/services/model/ObsBucket.java index 1232667..fdabbd3 100644 --- a/app/src/main/java/com/obs/services/model/ObsBucket.java +++ b/app/src/main/java/com/obs/services/model/ObsBucket.java @@ -48,6 +48,7 @@ public ObsBucket(String bucketName, String location) { * * @return Bucket name */ + @Override public String getBucketName() { return bucketName; } @@ -59,6 +60,7 @@ public String getBucketName() { * @param bucketName * Bucket name */ + @Override public void setBucketName(String bucketName) { this.bucketName = bucketName; } @@ -68,6 +70,7 @@ public void setBucketName(String bucketName) { * * @return Owner of the bucket */ + @Override public Owner getOwner() { return owner; } @@ -78,6 +81,7 @@ public Owner getOwner() { * @param bucketOwner * Owner of the bucket */ + @Override public void setOwner(Owner bucketOwner) { this.owner = bucketOwner; } @@ -87,6 +91,7 @@ public void setOwner(Owner bucketOwner) { * * @return Creation time of the bucket */ + @Override public Date getCreationDate() { return ServiceUtils.cloneDateIgnoreNull(this.creationDate); } @@ -97,6 +102,7 @@ public Date getCreationDate() { * @param bucketCreationDate * Creation time of the bucket */ + @Override public void setCreationDate(Date bucketCreationDate) { this.creationDate = ServiceUtils.cloneDateIgnoreNull(bucketCreationDate); } @@ -106,6 +112,7 @@ public void setCreationDate(Date bucketCreationDate) { * * @return Bucket properties */ + @Override @Deprecated public Map getMetadata() { if (this.metadata == null) { @@ -120,6 +127,7 @@ public Map getMetadata() { * @param metadata * Bucket properties */ + @Override @Deprecated public void setMetadata(Map metadata) { this.metadata = metadata; @@ -130,6 +138,7 @@ public void setMetadata(Map metadata) { * * @return Bucket location */ + @Override public String getLocation() { return location; } @@ -141,6 +150,7 @@ public String getLocation() { * Bucket location. This parameter is mandatory unless the * endpoint belongs to the default region. */ + @Override public void setLocation(String location) { this.location = location; } @@ -150,6 +160,7 @@ public void setLocation(String location) { * * @return Bucket ACL */ + @Override public AccessControlList getAcl() { return acl; } @@ -160,6 +171,7 @@ public AccessControlList getAcl() { * @param acl * Bucket ACL */ + @Override public void setAcl(AccessControlList acl) { this.acl = acl; } @@ -169,6 +181,7 @@ public void setAcl(AccessControlList acl) { * * @return Bucket storage class */ + @Override @Deprecated public String getStorageClass() { return this.storageClass != null ? this.storageClass.getCode() : null; @@ -180,6 +193,7 @@ public String getStorageClass() { * @param storageClass * Bucket storage class */ + @Override @Deprecated public void setStorageClass(String storageClass) { this.storageClass = StorageClassEnum.getValueFromCode(storageClass); @@ -193,6 +207,7 @@ public void setBucketType(BucketTypeEnum bucketTypeEnum) { this.bucketTypeEnum = bucketTypeEnum; } + @Override public StorageClassEnum getBucketStorageClass() { return storageClass; } @@ -203,6 +218,7 @@ public StorageClassEnum getBucketStorageClass() { * @param storageClass * Bucket storage class */ + @Override public void setBucketStorageClass(StorageClassEnum storageClass) { this.storageClass = storageClass; } diff --git a/app/src/main/java/com/obs/services/model/ObsObject.java b/app/src/main/java/com/obs/services/model/ObsObject.java index bf3eef6..2644791 100644 --- a/app/src/main/java/com/obs/services/model/ObsObject.java +++ b/app/src/main/java/com/obs/services/model/ObsObject.java @@ -27,6 +27,7 @@ public class ObsObject extends S3Object { * * @return Name of the bucket to which the object belongs */ + @Override public String getBucketName() { return bucketName; } @@ -37,6 +38,7 @@ public String getBucketName() { * @param bucketName * Name of the bucket to which the object belongs */ + @Override public void setBucketName(String bucketName) { this.bucketName = bucketName; } @@ -46,6 +48,7 @@ public void setBucketName(String bucketName) { * * @return Object name */ + @Override public String getObjectKey() { return objectKey; } @@ -56,6 +59,7 @@ public String getObjectKey() { * @param objectKey * Object name */ + @Override public void setObjectKey(String objectKey) { this.objectKey = objectKey; } @@ -66,6 +70,7 @@ public void setObjectKey(String objectKey) { * * @return Object properties */ + @Override public ObjectMetadata getMetadata() { if (metadata == null) { this.metadata = new ObjectMetadata(); @@ -80,6 +85,7 @@ public ObjectMetadata getMetadata() { * @param metadata * Object properties */ + @Override public void setMetadata(ObjectMetadata metadata) { this.metadata = metadata; } @@ -89,6 +95,7 @@ public void setMetadata(ObjectMetadata metadata) { * * @return Data stream of the object */ + @Override public InputStream getObjectContent() { return objectContent; } @@ -99,6 +106,7 @@ public InputStream getObjectContent() { * @param objectContent * Object data stream */ + @Override public void setObjectContent(InputStream objectContent) { this.objectContent = objectContent; } @@ -108,6 +116,7 @@ public void setObjectContent(InputStream objectContent) { * * @return Owner of the object */ + @Override public Owner getOwner() { return owner; } @@ -118,6 +127,7 @@ public Owner getOwner() { * @param owner * Owner of the object */ + @Override public void setOwner(Owner owner) { this.owner = owner; } diff --git a/app/src/main/java/com/obs/services/model/S3Bucket.java b/app/src/main/java/com/obs/services/model/S3Bucket.java index c66f3f4..546b016 100644 --- a/app/src/main/java/com/obs/services/model/S3Bucket.java +++ b/app/src/main/java/com/obs/services/model/S3Bucket.java @@ -40,6 +40,8 @@ public class S3Bucket extends HeaderResponse { protected String location; + protected String clustertype; + protected StorageClassEnum storageClass; protected Map metadata = new HashMap(); @@ -123,10 +125,18 @@ public void setBucketStorageClass(StorageClassEnum storageClass) { this.storageClass = storageClass; } + public String getClustertype() { + return clustertype; + } + + public void setClustertype(String clustertype) { + this.clustertype = clustertype; + } + @Override public String toString() { return "ObsBucket [bucketName=" + bucketName + ", owner=" + owner + ", creationDate=" + creationDate + ", location=" + location + ", storageClass=" + storageClass + ", metadata=" + metadata + ", acl=" - + acl + "]"; + + acl + ", clustertype= " + clustertype + "]"; } } diff --git a/app/src/main/java/com/obs/services/model/SetObjectMetadataRequest.java b/app/src/main/java/com/obs/services/model/SetObjectMetadataRequest.java index d122f3c..cacce1c 100644 --- a/app/src/main/java/com/obs/services/model/SetObjectMetadataRequest.java +++ b/app/src/main/java/com/obs/services/model/SetObjectMetadataRequest.java @@ -324,6 +324,7 @@ public Map getMetadata() { * @param encodeHeaders * Specifies whether to encode and decode header fields. */ + @Override public void setIsEncodeHeaders(boolean encodeHeaders) { this.encodeHeaders = encodeHeaders; } @@ -333,6 +334,7 @@ public void setIsEncodeHeaders(boolean encodeHeaders) { * * @return Specifies whether to encode and decode header fields. */ + @Override public boolean isEncodeHeaders() { return encodeHeaders; } diff --git a/app/src/main/java/com/obs/services/model/SpecialParamEnum.java b/app/src/main/java/com/obs/services/model/SpecialParamEnum.java index 856fa5d..3870703 100644 --- a/app/src/main/java/com/obs/services/model/SpecialParamEnum.java +++ b/app/src/main/java/com/obs/services/model/SpecialParamEnum.java @@ -14,6 +14,8 @@ package com.obs.services.model; +import java.util.Locale; + /** * Special operator, which indicates the sub-resource to be operated */ @@ -103,7 +105,15 @@ public enum SpecialParamEnum { * Set, obtain, or delete the cross-region replication configuration of a bucket. */ REPLICATION("replication"), - + + /** + * get the cross-region replication progress. + */ + REPLICATION_PROGRESS("replication_progress"), + /** + * get the cross-region replication configuration rule id. + */ + RULE_ID("ruleId"), /** * Perform an appendable upload. */ @@ -189,7 +199,7 @@ private SpecialParamEnum(String stringCode) { } public String getStringCode() { - return this.stringCode.toLowerCase(); + return this.stringCode.toLowerCase(Locale.ROOT); } public String getOriginalStringCode() { @@ -202,7 +212,7 @@ public static SpecialParamEnum getValueFromStringCode(String stringCode) { } for (SpecialParamEnum installMode : SpecialParamEnum.values()) { - if (installMode.getStringCode().equals(stringCode.toLowerCase())) { + if (installMode.getStringCode().equals(stringCode.toLowerCase(Locale.ROOT))) { return installMode; } } diff --git a/app/src/main/java/com/obs/services/model/crr/GetCrrProgressRequest.java b/app/src/main/java/com/obs/services/model/crr/GetCrrProgressRequest.java new file mode 100644 index 0000000..e029d57 --- /dev/null +++ b/app/src/main/java/com/obs/services/model/crr/GetCrrProgressRequest.java @@ -0,0 +1,32 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model.crr; + +import com.obs.services.model.BaseBucketRequest; + +public class GetCrrProgressRequest extends BaseBucketRequest { + protected String ruleId; + + public String getRuleId() { + if(ruleId == null) { + this.ruleId = ""; + } + return ruleId; + } + + public void setRuleId(String ruleId) { + this.ruleId = ruleId; + } +} diff --git a/app/src/main/java/com/obs/services/model/crr/GetCrrProgressResult.java b/app/src/main/java/com/obs/services/model/crr/GetCrrProgressResult.java new file mode 100644 index 0000000..063767d --- /dev/null +++ b/app/src/main/java/com/obs/services/model/crr/GetCrrProgressResult.java @@ -0,0 +1,114 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model.crr; + +import com.obs.services.model.HeaderResponse; +import java.util.Date; + +public class GetCrrProgressResult extends HeaderResponse { + public GetCrrProgressResult() { + this.time = new Date(); + this.ruleId = ""; + this.rulePrefix = ""; + this.ruleTargetBucket = ""; + this.ruleNewPendingCount = -1L; + this.ruleNewPendingSize = -1L; + this.ruleHistoricalProgress = ""; + this.ruleHistoricalPendingCount = -1L; + this.ruleHistoricalPendingSize = -1L; + } + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } + + public String getRuleId() { + return ruleId; + } + + public void setRuleId(String ruleId) { + this.ruleId = ruleId; + } + + public String getRulePrefix() { + return rulePrefix; + } + + public void setRulePrefix(String rulePrefix) { + this.rulePrefix = rulePrefix; + } + + public String getRuleTargetBucket() { + return ruleTargetBucket; + } + + public void setRuleTargetBucket(String ruleTargetBucket) { + this.ruleTargetBucket = ruleTargetBucket; + } + + public Long getRuleNewPendingCount() { + return ruleNewPendingCount; + } + + public void setRuleNewPendingCount(Long ruleNewPendingCount) { + this.ruleNewPendingCount = ruleNewPendingCount; + } + + public Long getRuleNewPendingSize() { + return ruleNewPendingSize; + } + + public void setRuleNewPendingSize(Long ruleNewPendingSize) { + this.ruleNewPendingSize = ruleNewPendingSize; + } + + public String getRuleHistoricalProgress() { + return ruleHistoricalProgress; + } + + public void setRuleHistoricalProgress(String ruleHistoricalProgress) { + this.ruleHistoricalProgress = ruleHistoricalProgress; + } + + public Long getRuleHistoricalPendingCount() { + return ruleHistoricalPendingCount; + } + + public void setRuleHistoricalPendingCount(Long ruleHistoricalPendingCount) { + this.ruleHistoricalPendingCount = ruleHistoricalPendingCount; + } + + public Long getRuleHistoricalPendingSize() { + return ruleHistoricalPendingSize; + } + + public void setRuleHistoricalPendingSize(Long ruleHistoricalPendingSize) { + this.ruleHistoricalPendingSize = ruleHistoricalPendingSize; + } + + protected Date time; + protected String ruleId; + protected String rulePrefix; + protected String ruleTargetBucket; + protected Long ruleNewPendingCount; + protected Long ruleNewPendingSize; + protected String ruleHistoricalProgress; + protected Long ruleHistoricalPendingCount; + protected Long ruleHistoricalPendingSize; +} diff --git a/app/src/main/java/com/obs/services/model/fs/ObsFSFile.java b/app/src/main/java/com/obs/services/model/fs/ObsFSFile.java index 35c8445..6fa3009 100644 --- a/app/src/main/java/com/obs/services/model/fs/ObsFSFile.java +++ b/app/src/main/java/com/obs/services/model/fs/ObsFSFile.java @@ -39,6 +39,7 @@ public ObsFSFile(String bucketName, String objectKey, String etag, String versio * OBS SDK self-defined exception, thrown when the interface * fails to be called or access to OBS fails */ + @Override public ObsFSAttribute attribute() throws ObsException { return super.attribute(); } @@ -181,6 +182,7 @@ public ObsFSFile write(InputStream input) throws ObsException { * OBS SDK self-defined exception, thrown when the interface * fails to be called or access to OBS fails */ + @Override public RenameResult rename(String newName) throws ObsException { this.checkInternalClient(); RenameRequest request = new RenameRequest(this.getBucketName(), this.getObjectKey(), newName); diff --git a/app/src/main/java/com/obs/services/model/fusion/FusionReplicateEnum.java b/app/src/main/java/com/obs/services/model/fusion/FusionReplicateEnum.java new file mode 100644 index 0000000..84907b8 --- /dev/null +++ b/app/src/main/java/com/obs/services/model/fusion/FusionReplicateEnum.java @@ -0,0 +1,32 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model.fusion; + +public enum FusionReplicateEnum { + /** + * 异步模式 + */ + ASYNC("async"); + + private String code; + + FusionReplicateEnum(String code) { + this.code = code; + } + + public String getCode() { + return code; + } +} diff --git a/app/src/main/java/com/obs/services/model/fusion/RedundancyTypeEnum.java b/app/src/main/java/com/obs/services/model/fusion/RedundancyTypeEnum.java new file mode 100644 index 0000000..2c3b7de --- /dev/null +++ b/app/src/main/java/com/obs/services/model/fusion/RedundancyTypeEnum.java @@ -0,0 +1,35 @@ +/** + * Copyright 2019 Huawei Technologies Co.,Ltd. + * Licensed 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.obs.services.model.fusion; + +public enum RedundancyTypeEnum { + /* + 基础桶 [1az, 3az] + */ + CLASSIC("classic"), + /* + 融合桶(由多个基础桶组合而成) + */ + FUSION("fusion"); + private String code; + + RedundancyTypeEnum(String code) { + this.code = code; + } + + public String getCode() { + return code; + } +} diff --git a/app/src/main/java/com/obs/services/model/select/SelectObjectException.java b/app/src/main/java/com/obs/services/model/select/SelectObjectException.java index abb9e99..a9acb70 100644 --- a/app/src/main/java/com/obs/services/model/select/SelectObjectException.java +++ b/app/src/main/java/com/obs/services/model/select/SelectObjectException.java @@ -41,6 +41,7 @@ public SelectObjectException(String code, String message) { * * @returns Error code */ + @Override public String getErrorCode() { return super.getErrorCode(); } @@ -50,6 +51,7 @@ public String getErrorCode() { * * @returns Error message */ + @Override public String getErrorMessage() { return super.getErrorMessage(); } diff --git a/app/src/main/java/com/oef/services/model/QueryAsynchFetchJobsResult.java b/app/src/main/java/com/oef/services/model/QueryAsynchFetchJobsResult.java index 3884b35..b417fee 100644 --- a/app/src/main/java/com/oef/services/model/QueryAsynchFetchJobsResult.java +++ b/app/src/main/java/com/oef/services/model/QueryAsynchFetchJobsResult.java @@ -78,6 +78,7 @@ public QueryAsynchFetchJobsResult(String requestId, String err, String code, Str * * @return Unique ID of a request */ + @Override public String getRequestId() { return requestId; } diff --git a/app/src/main/java/com/oef/services/model/RequestParamEnum.java b/app/src/main/java/com/oef/services/model/RequestParamEnum.java index f320491..493c96f 100644 --- a/app/src/main/java/com/oef/services/model/RequestParamEnum.java +++ b/app/src/main/java/com/oef/services/model/RequestParamEnum.java @@ -16,6 +16,8 @@ import com.obs.services.model.SpecialParamEnum; +import java.util.Locale; + public enum RequestParamEnum { /** * Obtain, set, or delete an asynchronous policy. @@ -40,7 +42,7 @@ private RequestParamEnum(String stringCode) { } public String getStringCode() { - return this.stringCode.toLowerCase(); + return this.stringCode.toLowerCase(Locale.ROOT); } public String getOriginalStringCode() { @@ -53,7 +55,7 @@ public static SpecialParamEnum getValueFromStringCode(String stringCode) { } for (SpecialParamEnum installMode : SpecialParamEnum.values()) { - if (installMode.getStringCode().equals(stringCode.toLowerCase())) { + if (installMode.getStringCode().equals(stringCode.toLowerCase(Locale.ROOT))) { return installMode; } } diff --git a/assembly-java.xml b/assembly-java.xml index d94d9c5..ea28b80 100644 --- a/assembly-java.xml +++ b/assembly-java.xml @@ -31,6 +31,10 @@ ${project.basedir}/app/src/main/resource/log4j2.xml / + + ${project.basedir}/app/src/test/resource/test_data.properties + /source/src/test/resource + ${project.basedir}/assembly-android.xml / @@ -40,21 +44,25 @@ / - ${project.basedir}/pom-android.xml + ${project.basedir}/poms/pom-android.xml / - ${project.basedir}/pom-dependencies.xml + ${project.basedir}/poms/pom-dependencies.xml / - ${project.basedir}/pom-java-optimization.xml + ${project.basedir}/poms/pom-java-optimization.xml / ${project.basedir}/pom-java.xml / + + ${project.basedir}/poms/pom-for-ci.xml + / + ${project.basedir}/LICENSE / @@ -67,12 +75,10 @@ ${project.basedir}/Help on License / - ${project.basedir}/README-Java.md / - ${project.basedir}/README-Android.md / @@ -87,10 +93,6 @@ ${project.basedir}/app/src/test/java/samples_android /samples_android - - ${project.basedir}/app/src/third_part - /third_part - ${project.build.directory}/doc /doc @@ -106,5 +108,9 @@ proguard-rules.pro + + ${project.basedir}/app/src/test/java/com + /source/src/test/java/com + \ No newline at end of file diff --git a/pom-android.xml b/pom-android.xml index b2e7981..f6463d6 100644 --- a/pom-android.xml +++ b/pom-android.xml @@ -4,7 +4,7 @@ com.huaweicloud esdk-obs-android - 3.22.12 + 3.22.3 jar OBS SDK for Android @@ -12,10 +12,10 @@ UTF-8 - true + com.jamesmurty.utils java-xmlbuilder @@ -30,7 +30,7 @@ com.squareup.okhttp3 okhttp - 4.10.0 + 4.9.3 com.squareup.okio @@ -41,18 +41,19 @@ com.fasterxml.jackson.core jackson-core - 2.13.3 + 2.13.0 com.fasterxml.jackson.core jackson-databind - 2.13.4.1 + 2.13.0 com.fasterxml.jackson.core jackson-annotations - 2.13.3 + 2.13.0 + @@ -122,25 +123,20 @@ org.apache.maven.plugins maven-assembly-plugin - - - - com.test.MainClassName - - - - jar-with-dependencies - - - make-assembly - package + install single + + false + + assembly-android.xml + + diff --git a/pom-dependencies.xml b/pom-dependencies.xml index 45310b4..feb17fa 100644 --- a/pom-dependencies.xml +++ b/pom-dependencies.xml @@ -2,9 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.huawei.storage + com.huaweicloud esdk-obs-java - 3.21.4.1 + 3.22.3 jar OBS SDK for Java @@ -30,39 +30,39 @@ com.squareup.okhttp3 okhttp - 3.14.9 + 4.9.3 com.squareup.okio okio - 1.17.5 + 2.10.0 com.fasterxml.jackson.core jackson-core - 2.11.1 + 2.13.0 com.fasterxml.jackson.core jackson-databind - 2.11.1 + 2.13.0 com.fasterxml.jackson.core jackson-annotations - 2.11.1 + 2.13.0 org.apache.logging.log4j log4j-core - 2.13.2 + 2.17.1 org.apache.logging.log4j log4j-api - 2.13.2 + 2.17.1 diff --git a/pom-java-optimization.xml b/pom-java-optimization.xml index 310b26c..1396325 100644 --- a/pom-java-optimization.xml +++ b/pom-java-optimization.xml @@ -1,194 +1,200 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.huaweicloud - esdk-obs-java-optimised - 3.22.12.1 - jar + com.huaweicloud + esdk-obs-java-optimised + 3.22.12 + jar - OBS SDK for Java - The OBS SDK for Java used for accessing Object Storage Service + OBS SDK for Java Optimised + The OBS SDK for Java used for accessing Object Storage Service - - UTF-8 - + + UTF-8 + - - - com.jamesmurty.utils - java-xmlbuilder - 1.3 - - - net.iharder - base64 - - - - - com.squareup.okhttp3 - okhttp - 3.14.9 - - - com.squareup.okio - okio - 1.17.5 - - - - com.fasterxml.jackson.core - jackson-core - 2.13.3 - - - com.fasterxml.jackson.core - jackson-databind - 2.13.4.1 - - - com.fasterxml.jackson.core - jackson-annotations - 2.13.3 - - - - org.apache.logging.log4j - log4j-core - 2.18.0 - + + + com.jamesmurty.utils + java-xmlbuilder + 1.3 + + + net.iharder + base64 + + + + + com.squareup.okhttp3 + okhttp + 3.14.9 + + + com.squareup.okio + okio + 1.17.5 + + + + com.fasterxml.jackson.core + jackson-core + 2.13.3 + + + com.fasterxml.jackson.core + jackson-databind + 2.13.4.1 + + + com.fasterxml.jackson.core + jackson-annotations + 2.13.2 + + + + org.apache.logging.log4j + log4j-core + 2.18.0 + + + org.apache.logging.log4j + log4j-api + 2.18.0 + - org.apache.logging.log4j - log4j-api - 2.18.0 - - + org.powermock + powermock-module-junit4 + 1.6.5 + test + + + + + ../app/src/main/java + + ../app/src/test/java + + + org.apache.maven.plugins + maven-clean-plugin + + + + logs + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + UTF-8 + 1.8 + 1.8 + + + + compile + + + + - - app/src/main/java - - app/src/test/java - - - org.apache.maven.plugins - maven-clean-plugin - - - - logs - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - UTF-8 - 1.8 - 1.8 - - - - compile - - - - - - + - - org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - package - - shade - - - - - - - com.fasterxml.jackson.core:jackson-core:jar: - com.fasterxml.jackson.core:jackson-databind:jar: - com.fasterxml.jackson.core:jackson-annotations:jar: - org.apache.logging.log4j:log4j-core:jar: - org.apache.logging.log4j:log4j-api:jar: - - - - - com.jamesmurty.utils - com.obs.shade.jamesmurty.utils - - - okhttp3 - com.obs.shade.okhttp3 - - - okio - com.obs.shade.okio - - - - - - - - + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + + + com.fasterxml.jackson.core:jackson-core:jar: + com.fasterxml.jackson.core:jackson-databind:jar: + com.fasterxml.jackson.core:jackson-annotations:jar: + org.apache.logging.log4j:log4j-core:jar: + org.apache.logging.log4j:log4j-api:jar: + + + + + com.jamesmurty.utils + com.obs.shade.jamesmurty.utils + + + okhttp3 + com.obs.shade.okhttp3 + + + okio + com.obs.shade.okio + + + + + + + + diff --git a/pom-java.xml b/pom-java.xml index de781ba..2adba79 100644 --- a/pom-java.xml +++ b/pom-java.xml @@ -4,7 +4,7 @@ com.huaweicloud esdk-obs-java - 3.22.12 + 3.23.3 jar OBS SDK for Java @@ -68,22 +68,23 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test org.powermock - powermock-api-mockito - 1.6.5 + powermock-api-mockito2 + 2.0.9 test org.powermock powermock-module-junit4 - 1.6.5 + 2.0.9 test + From cc00b8a1c6640922b558c493632d721298992f81 Mon Sep 17 00:00:00 2001 From: z30035417 Date: Fri, 28 Apr 2023 18:27:23 +0800 Subject: [PATCH 2/5] Version 3.23.3 --- assembly-java.xml | 32 ++++++++++++----------------- pom-android.xml | 42 +++++++++++++++++++++------------------ pom-dependencies.xml | 36 ++++++++++++++++----------------- pom-java-optimization.xml | 24 +++++++++------------- 4 files changed, 63 insertions(+), 71 deletions(-) diff --git a/assembly-java.xml b/assembly-java.xml index ea28b80..ba3094b 100644 --- a/assembly-java.xml +++ b/assembly-java.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> assembly_zip zip @@ -16,8 +16,8 @@ false runtime - com.jamesmurty.utils:java-xmlbuilder - + com.jamesmurty.utils:java-xmlbuilder + @@ -31,10 +31,6 @@ ${project.basedir}/app/src/main/resource/log4j2.xml / - - ${project.basedir}/app/src/test/resource/test_data.properties - /source/src/test/resource - ${project.basedir}/assembly-android.xml / @@ -44,25 +40,21 @@ / - ${project.basedir}/poms/pom-android.xml + ${project.basedir}/pom-android.xml / - ${project.basedir}/poms/pom-dependencies.xml + ${project.basedir}/pom-dependencies.xml / - ${project.basedir}/poms/pom-java-optimization.xml + ${project.basedir}/pom-java-optimization.xml / ${project.basedir}/pom-java.xml / - - ${project.basedir}/poms/pom-for-ci.xml - / - ${project.basedir}/LICENSE / @@ -75,10 +67,12 @@ ${project.basedir}/Help on License / + ${project.basedir}/README-Java.md / + ${project.basedir}/README-Android.md / @@ -93,6 +87,10 @@ ${project.basedir}/app/src/test/java/samples_android /samples_android + + ${project.basedir}/app/src/third_part + /third_part + ${project.build.directory}/doc /doc @@ -108,9 +106,5 @@ proguard-rules.pro - - ${project.basedir}/app/src/test/java/com - /source/src/test/java/com - \ No newline at end of file diff --git a/pom-android.xml b/pom-android.xml index f6463d6..346a1e9 100644 --- a/pom-android.xml +++ b/pom-android.xml @@ -1,10 +1,10 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.huaweicloud esdk-obs-android - 3.22.3 + 3.22.12 jar OBS SDK for Android @@ -12,10 +12,10 @@ UTF-8 + true - com.jamesmurty.utils java-xmlbuilder @@ -30,30 +30,29 @@ com.squareup.okhttp3 okhttp - 4.9.3 + 4.10.0 com.squareup.okio okio 2.10.0 - + com.fasterxml.jackson.core jackson-core - 2.13.0 + 2.13.3 com.fasterxml.jackson.core jackson-databind - 2.13.0 + 2.13.4.1 com.fasterxml.jackson.core jackson-annotations - 2.13.0 + 2.13.3 - @@ -109,34 +108,39 @@ - + org.apache.maven.plugins maven-jar-plugin - okio/* + okio/* - + org.apache.maven.plugins maven-assembly-plugin + + + + com.test.MainClassName + + + + jar-with-dependencies + + - install + make-assembly + package single - - false - - assembly-android.xml - - diff --git a/pom-dependencies.xml b/pom-dependencies.xml index feb17fa..3a0324c 100644 --- a/pom-dependencies.xml +++ b/pom-dependencies.xml @@ -1,10 +1,10 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.huaweicloud + com.huawei.storage esdk-obs-java - 3.22.3 + 3.21.4.1 jar OBS SDK for Java @@ -26,47 +26,47 @@ - + - com.squareup.okhttp3 - okhttp - 4.9.3 + com.squareup.okhttp3 + okhttp + 3.14.9 com.squareup.okio okio - 2.10.0 + 1.17.5 - + com.fasterxml.jackson.core jackson-core - 2.13.0 + 2.11.1 com.fasterxml.jackson.core jackson-databind - 2.13.0 + 2.11.1 com.fasterxml.jackson.core jackson-annotations - 2.13.0 + 2.11.1 - + org.apache.logging.log4j log4j-core - 2.17.1 + 2.13.2 org.apache.logging.log4j log4j-api - 2.17.1 + 2.13.2 - + - - + + diff --git a/pom-java-optimization.xml b/pom-java-optimization.xml index 1396325..f0ac3ed 100644 --- a/pom-java-optimization.xml +++ b/pom-java-optimization.xml @@ -1,13 +1,13 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.huaweicloud esdk-obs-java-optimised - 3.22.12 + 3.22.12.1 jar - OBS SDK for Java Optimised + OBS SDK for Java The OBS SDK for Java used for accessing Object Storage Service @@ -50,7 +50,7 @@ com.fasterxml.jackson.core jackson-annotations - 2.13.2 + 2.13.3 @@ -62,25 +62,19 @@ org.apache.logging.log4j log4j-api 2.18.0 - - - org.powermock - powermock-module-junit4 - 1.6.5 - test - ../app/src/main/java - - ../app/src/test/java + app/src/test/java org.apache.maven.plugins @@ -110,7 +104,7 @@ - - + app/src/test/java + + + org.apache.maven.plugins + maven-clean-plugin + + + + logs + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + UTF-8 + 1.8 + 1.8 + + + + compile + + + + + + - - org.apache.logging.log4j - log4j-core - 2.18.0 - - - org.apache.logging.log4j - log4j-api - 2.18.0 - - - - - app/src/main/java - - app/src/test/java - - - org.apache.maven.plugins - maven-clean-plugin - - - - logs - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - UTF-8 - 1.8 - 1.8 - - - - compile - - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - package - - shade - - - - - - - com.fasterxml.jackson.core:jackson-core:jar: - com.fasterxml.jackson.core:jackson-databind:jar: - com.fasterxml.jackson.core:jackson-annotations:jar: - org.apache.logging.log4j:log4j-core:jar: - org.apache.logging.log4j:log4j-api:jar: - - - - - com.jamesmurty.utils - com.obs.shade.jamesmurty.utils - - - okhttp3 - com.obs.shade.okhttp3 - - - okio - com.obs.shade.okio - - - - - - - - + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + + + com.fasterxml.jackson.core:jackson-core:jar: + com.fasterxml.jackson.core:jackson-databind:jar: + com.fasterxml.jackson.core:jackson-annotations:jar: + org.apache.logging.log4j:log4j-core:jar: + org.apache.logging.log4j:log4j-api:jar: + + + + + com.jamesmurty.utils + com.obs.shade.jamesmurty.utils + + + okhttp3 + com.obs.shade.okhttp3 + + + okio + com.obs.shade.okio + + + + + + + +