Skip to content

Commit

Permalink
Merge pull request #133 from zzq996/master
Browse files Browse the repository at this point in the history
Version 3.23.3
New features:
1. 支持crr进度查询 
2. 新增对象标签接口(设置、获取、删除 对象标签)

Third-party dependence:
1. 使用 powermock-module-junit4 2.0.9 替代 powermock-module-junit4 1.6.5
2. 使用 powermock-api-mockito2 2.0.9 替代 powermock-api-mockito 1.6.5
3. 使用 mockito-core 4.11.0 替代 mockito-core 1.10.19
  • Loading branch information
zzq996 authored Aug 12, 2023
2 parents 0512c23 + 978113d commit 2a31fb9
Show file tree
Hide file tree
Showing 71 changed files with 1,264 additions and 171 deletions.
11 changes: 11 additions & 0 deletions README-Android.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 3.23.3
New features:
1. Allow you to query the progress of crr
2. Added interfaces of Object tagging(set, get, delete)

Third-party dependence:
1. Replace powermock-module-junit4 2.0.9 with powermock-module-junit4 1.6.5
2. Replace powermock-api-mockito2 2.0.9 with powermock-api-mockito 1.6.5
3. Replace mockito-core 4.11.0 with mockito-core 1.10.19
-----------------------------------------------------------------------------------

Version 3.21.12
Third-party dependence:
1. Replace log4j2 2.16.0 with log4j2 2.17.0
Expand Down
11 changes: 11 additions & 0 deletions README-Java.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 3.23.3
New features:
1. Allow you to query the progress of crr
2. Added interfaces of Object tagging(set, get, delete)

Third-party dependence:
1. Replace powermock-module-junit4 2.0.9 with powermock-module-junit4 1.6.5
2. Replace powermock-api-mockito2 2.0.9 with powermock-api-mockito 1.6.5
3. Replace mockito-core 4.11.0 with mockito-core 1.10.19
-----------------------------------------------------------------------------------

Version 3.22.12
New features:
1. Added the Deep Archive storage class in the Java SDK.
Expand Down
11 changes: 11 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 3.23.3
New features:
1. Allow you to query the progress of crr
2. Added interfaces of Object tagging(set, get, delete)

Third-party dependence:
1. Replace powermock-module-junit4 2.0.9 with powermock-module-junit4 1.6.5
2. Replace powermock-api-mockito2 2.0.9 with powermock-api-mockito 1.6.5
3. Replace mockito-core 4.11.0 with mockito-core 1.10.19
-----------------------------------------------------------------------------------

Version 3.22.12
New features:
1. Added the Deep Archive storage class in the Java SDK.
Expand Down
11 changes: 11 additions & 0 deletions README_CN.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 3.23.3
New features:
1. 支持crr进度查询
2. 新增对象标签接口(设置、获取、删除 对象标签)

Third-party dependence:
1. 使用 powermock-module-junit4 2.0.9 替代 powermock-module-junit4 1.6.5
2. 使用 powermock-api-mockito2 2.0.9 替代 powermock-api-mockito 1.6.5
3. 使用 mockito-core 4.11.0 替代 mockito-core 1.10.19
-----------------------------------------------------------------------------------

Version 3.22.12
New features:
1. Java SDK支持深度归档
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/obs/log/BasicLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,131 +24,152 @@ 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());
AccessLoggerUtils.appendLog(msg, "info");
}
}

@Override
public void info(Object obj) {
if (obj != null) {
this.logger.info(obj.toString());
AccessLoggerUtils.appendLog(obj, "info");
}
}

@Override
public void info(Object obj, Throwable e) {
if (obj != null) {
this.logger.log(LogConfigurator.INFO, obj.toString(), e);
AccessLoggerUtils.appendLog(obj, "info");
}
}

@Override
public boolean isWarnEnabled() {
return this.logger.isLoggable(LogConfigurator.WARN);
}

@Override
public void warn(CharSequence msg) {
if (msg != null) {
this.logger.warning(msg.toString());
AccessLoggerUtils.appendLog(msg, "warn");
}
}

@Override
public void warn(Object obj) {
if (obj != null) {
this.logger.warning(obj.toString());
AccessLoggerUtils.appendLog(obj, "warn");
}
}

@Override
public void warn(Object obj, Throwable e) {
if (obj != null) {
this.logger.log(LogConfigurator.WARN, obj.toString(), e);
AccessLoggerUtils.appendLog(obj, "warn");
}
}

@Override
public boolean isErrorEnabled() {
return this.logger.isLoggable(LogConfigurator.ERROR);
}

@Override
public void error(CharSequence msg) {
if (msg != null) {
this.logger.severe(msg.toString());
AccessLoggerUtils.appendLog(msg, "error");
}
}

@Override
public void error(Object obj) {
if (obj != null) {
this.logger.severe(obj.toString());
AccessLoggerUtils.appendLog(obj, "error");
}
}

@Override
public void error(Object obj, Throwable e) {
if (obj != null) {
this.logger.log(LogConfigurator.ERROR, obj.toString(), e);
AccessLoggerUtils.appendLog(obj, "error");
}
}

@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());
AccessLoggerUtils.appendLog(msg, "debug");
}
}

@Override
public void debug(Object obj) {
if (obj != null) {
this.logger.log(LogConfigurator.DEBUG, obj.toString());
AccessLoggerUtils.appendLog(obj, "debug");
}
}

@Override
public void debug(Object obj, Throwable e) {
if (obj != null) {
this.logger.log(LogConfigurator.DEBUG, obj.toString(), e);
AccessLoggerUtils.appendLog(obj, "debug");
}
}

@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());
AccessLoggerUtils.appendLog(msg, "trace");
}
}

@Override
public void trace(Object obj) {
if (obj != null) {
this.logger.log(LogConfigurator.TRACE, obj.toString());
AccessLoggerUtils.appendLog(obj, "trace");
}
}

@Override
public void trace(Object obj, Throwable e) {
if (obj != null) {
this.logger.log(LogConfigurator.TRACE, obj.toString(), e);
AccessLoggerUtils.appendLog(obj, "trace");
}
}

@Override
public void accessRecord(Object obj) {
if (obj != null) {
this.logger.log(LogConfigurator.INFO, obj.toString());
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/obs/log/Log4j2Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private static class Log4j2LoggerMethodHolder extends LoggerMethodHolder {
super(logger);
}

@Override
public boolean isInfoEnabled() {
if (isInfoE == -1) {
try {
Expand All @@ -65,6 +66,7 @@ public boolean isInfoEnabled() {
return isInfoE == 1;
}

@Override
public boolean isWarnEnabled() {
if (isWarnE == -1) {
try {
Expand All @@ -77,6 +79,7 @@ public boolean isWarnEnabled() {
return isWarnE == 1;
}

@Override
public boolean isErrorEnabled() {
if (isErrorE == -1) {
try {
Expand All @@ -89,6 +92,7 @@ public boolean isErrorEnabled() {
return isErrorE == 1;
}

@Override
public boolean isDebugEnabled() {
if (isDebugE == -1) {
try {
Expand All @@ -101,6 +105,7 @@ public boolean isDebugEnabled() {
return isDebugE == 1;
}

@Override
public boolean isTraceEnabled() {
if (isTraceE == -1) {
try {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/obs/log/Log4jLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static class Log4jLoggerMethodHolder extends LoggerMethodHolder {
super(logger);
}

@Override
public boolean isInfoEnabled() {
try {
return this.logger != null && Log4jLoggerMethodHolder.infoLevel != null
Expand All @@ -67,6 +68,7 @@ public boolean isInfoEnabled() {
}
}

@Override
public boolean isWarnEnabled() {
try {
return this.logger != null && Log4jLoggerMethodHolder.warnLevel != null
Expand All @@ -77,6 +79,7 @@ public boolean isWarnEnabled() {
}
}

@Override
public boolean isErrorEnabled() {
try {
return this.logger != null && Log4jLoggerMethodHolder.errorLevel != null
Expand All @@ -87,6 +90,7 @@ public boolean isErrorEnabled() {
}
}

@Override
public boolean isDebugEnabled() {
try {
return this.logger != null && Log4jLoggerMethodHolder.debugLevel != null
Expand All @@ -97,6 +101,7 @@ public boolean isDebugEnabled() {
}
}

@Override
public boolean isTraceEnabled() {
try {
return this.logger != null && Log4jLoggerMethodHolder.traceLevel != null
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/obs/log/LoggerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
12 changes: 2 additions & 10 deletions app/src/main/java/com/obs/services/AbstractBatchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/*
Expand Down Expand Up @@ -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<GetCrrProgressResult>() {
@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)
*
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/obs/services/AbstractClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 2a31fb9

Please sign in to comment.