Skip to content

Commit

Permalink
Update to 3.22.12
Browse files Browse the repository at this point in the history
  • Loading branch information
redabc committed Feb 2, 2023
1 parent 8153970 commit de3172b
Show file tree
Hide file tree
Showing 85 changed files with 3,490 additions and 255 deletions.
22 changes: 13 additions & 9 deletions app/src/main/java/com/obs/services/AbstractBatchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public TaskProgressStatus restoreObjects(RestoreObjectsRequest request) throws O
RestoreObjectRequest taskRequest = new RestoreObjectRequest(request.getBucketName(), kv.getKey(),
kv.getVersion(), request.getDays(), request.getRestoreTier());
taskRequest.setRequesterPays(request.isRequesterPays());
RestoreObjectTask task = new RestoreObjectTask(this, request.getBucketName(), taskRequest,
RestoreObjectTask task = new RestoreObjectTask(this, request.getBucketName(), taskRequest,
callback, listener,
progreStatus, progressInterval);
executor.execute(task);
Expand All @@ -108,10 +108,12 @@ public TaskProgressStatus restoreObjects(RestoreObjectsRequest request) throws O
progreStatus.setTotalTaskNum(totalTasks);
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (ObsException e) {
throw e;
} catch (Exception e) {
throw new ObsException(e.getMessage(), e);
if (e instanceof ObsException) {
throw (ObsException) e;
} else {
throw new ObsException(e.getMessage(), e);
}
}
return progreStatus;
}
Expand Down Expand Up @@ -216,20 +218,22 @@ public UploadProgressStatus putObjects(final PutObjectsRequest request) throws O

int totalTasks = 0;
if (request.getFolderPath() != null) {
totalTasks = uploadFolder(request, executor, progressStatus, listener,
totalTasks = uploadFolder(request, executor, progressStatus, listener,
callback, prefix);
} else if (request.getFilePaths() != null) {
totalTasks = uploadFileLists(request, executor, progressStatus, listener,
totalTasks = uploadFileLists(request, executor, progressStatus, listener,
callback, prefix);
}

progressStatus.setTotalTaskNum(totalTasks);
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (ObsException e) {
throw e;
} catch (Exception e) {
throw new ObsException(e.getMessage(), e);
if (e instanceof ObsException) {
throw (ObsException) e;
} else {
throw new ObsException(e.getMessage(), e);
}
}

return progressStatus;
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/java/com/obs/services/AbstractBucketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
import com.obs.services.model.BucketStoragePolicyConfiguration;
import com.obs.services.model.BucketVersioningConfiguration;
import com.obs.services.model.CreateBucketRequest;
import com.obs.services.model.CreateVirtualBucketRequest;
import com.obs.services.model.CreateVirtualBucketResult;
import com.obs.services.model.DeleteBucketCustomDomainRequest;
import com.obs.services.model.GetBucketCustomDomainRequest;
import com.obs.services.model.HeaderResponse;
import com.obs.services.model.ListBucketAliasResult;
import com.obs.services.model.ListBucketsRequest;
import com.obs.services.model.ListBucketsResult;
import com.obs.services.model.ObsBucket;
Expand Down Expand Up @@ -139,6 +142,35 @@ void authTypeNegotiate(String bucketName) throws ServiceException {
});
}

public CreateVirtualBucketResult createVirtualBucket(CreateVirtualBucketRequest request) throws ObsException {
ServiceUtils.assertParameterNotNull(request, "CreateVirtualBucketRequest is null");
ServiceUtils.assertParameterNotNull(request.getBucketAlias(), "bucket alias is null");
ServiceUtils.assertParameterNotNull(request.getBucketName1(), "bucket name1 is null");
ServiceUtils.assertParameterNotNull(request.getBucketName2(), "bucket name2 is null");
ServiceUtils.assertParameterNotNull(request.getAgencyId(), "agency id is null");
ServiceUtils.assertParameterNotNull(request.getRegionId(), "region id is null");
ServiceUtils.assertParameterNotNull(request.getToken(), "token is null");
return this.doActionWithResult("createVirtualBucket", "All Buckets", new ActionCallbackWithResult<CreateVirtualBucketResult>() {
@Override
public CreateVirtualBucketResult action() throws ServiceException {
if (isCname()) {
throw new ServiceException("createVirtualBucket is not allowed in customdomain mode");
}
return AbstractBucketClient.this.createVirtualBucketImpl(request);
}

@Override
void authTypeNegotiate(String bucketName) throws ServiceException {
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getProviderCredentials()
.getLocalAuthType().get(bucketName);
if (authTypeEnum == null) {
authTypeEnum = AbstractBucketClient.this.getApiVersion("");
AbstractBucketClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum);
}
}
});
}

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -179,6 +211,26 @@ void authTypeNegotiate(String bucketName) throws ServiceException {
});
}

@Override
public ListBucketAliasResult listAliasBuckets() throws ObsException {
return this.doActionWithResult("ListBucketAliasResult", "All Buckets", new ActionCallbackWithResult<ListBucketAliasResult>() {
@Override
public ListBucketAliasResult action() throws ServiceException {
return AbstractBucketClient.this.listAliasBucketsImpl();
}

@Override
void authTypeNegotiate(String bucketName) throws ServiceException {
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getProviderCredentials()
.getLocalAuthType().get(bucketName);
if (authTypeEnum == null) {
authTypeEnum = AbstractBucketClient.this.getApiVersion("");
AbstractBucketClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum);
}
}
});
}

/*
* (non-Javadoc)
*
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/obs/services/AbstractFileClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsExcept
if (!folderName.endsWith(delimiter)) {
folderName = folderName + delimiter;
}
TaskCallback<DeleteObjectResult, String> callback = (request.getCallback() == null)
TaskCallback<DeleteObjectResult, String> callback = (request.getCallback() == null)
? new LazyTaksCallback<DeleteObjectResult, String>()
: request.getCallback();
TaskProgressListener listener = request.getProgressListener();
Expand All @@ -123,10 +123,12 @@ public TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsExcept

executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (ObsException e) {
throw e;
} catch (Exception e) {
throw new ObsException(e.getMessage(), e);
if (e instanceof ObsException) {
throw (ObsException) e;
} else {
throw new ObsException(e.getMessage(), e);
}
}
return progressStatus;
}
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/java/com/obs/services/AbstractObjectClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import com.obs.services.model.RestoreObjectResult;
import com.obs.services.model.SetObjectAclRequest;
import com.obs.services.model.SetObjectMetadataRequest;
import com.obs.services.model.select.SelectObjectRequest;
import com.obs.services.model.select.SelectObjectResult;

public abstract class AbstractObjectClient extends AbstractBucketAdvanceClient {
@Override
Expand Down Expand Up @@ -356,7 +358,26 @@ public ObsObject getObject(final String bucketName, final String objectKey, fina
public ObsObject getObject(final String bucketName, final String objectKey) throws ObsException {
return this.getObject(bucketName, objectKey, null);
}


@Override
public SelectObjectResult selectObjectContent(final SelectObjectRequest selectRequest)
throws ObsException {
ServiceUtils.assertParameterNotNull(selectRequest, "SelectObjectRequest is null");
ServiceUtils.assertParameterNotNull2(selectRequest.getBucketName(), "bucket-name is null");
ServiceUtils.assertParameterNotNull2(selectRequest.getKey(), "object-key is null");
ServiceUtils.assertParameterNotNull2(selectRequest.getExpression(), "sql-expression is null");

return this.doActionWithResult(
"selectObjectContent",
selectRequest.getBucketName(),
new ActionCallbackWithResult<SelectObjectResult>() {
@Override
public SelectObjectResult action() throws ServiceException {
return AbstractObjectClient.this.selectObjectContentImpl(selectRequest);
}
});
}

/*
* (non-Javadoc)
*
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/obs/services/AbstractPFSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
import com.obs.services.model.fs.ListContentSummaryFsRequest;
import com.obs.services.model.fs.ContentSummaryFsRequest;
import com.obs.services.model.fs.ContentSummaryFsResult;
import com.obs.services.model.fs.accesslabel.DeleteAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.DeleteAccessLabelResult;
import com.obs.services.model.fs.accesslabel.GetAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.GetAccessLabelResult;
import com.obs.services.model.fs.accesslabel.SetAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.SetAccessLabelResult;

public abstract class AbstractPFSClient extends AbstractMultipartObjectClient {

Expand Down Expand Up @@ -261,4 +267,37 @@ public ContentSummaryFsResult action() throws ServiceException {
}
});
}

@Override
public SetAccessLabelResult setAccessLabelFs(SetAccessLabelRequest request) throws ObsException {
return this.doActionWithResult("setaccesslabel", request.getBucketName(),
new ActionCallbackWithResult<SetAccessLabelResult>() {
@Override
public SetAccessLabelResult action() throws ServiceException {
return AbstractPFSClient.this.setAccessLabelFsImpl(request);
}
});
}

@Override
public GetAccessLabelResult getAccessLabelFs(GetAccessLabelRequest request) throws ObsException {
return this.doActionWithResult("getaccesslabel", request.getBucketName(),
new ActionCallbackWithResult<GetAccessLabelResult>() {
@Override
public GetAccessLabelResult action() throws ServiceException {
return AbstractPFSClient.this.getAccessLabelFsImpl(request);
}
});
}

@Override
public DeleteAccessLabelResult deleteAccessLabelFs(DeleteAccessLabelRequest request) throws ObsException {
return this.doActionWithResult("deleteaccesslabel", request.getBucketName(),
new ActionCallbackWithResult<DeleteAccessLabelResult>() {
@Override
public DeleteAccessLabelResult action() throws ServiceException {
return AbstractPFSClient.this.deleteAccessLabelFsImpl(request);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class BasicObsCredentialsProvider implements IObsCredentialsProvider {
private volatile ISecurityKey securityKey;

public BasicObsCredentialsProvider(ISecurityKey securityKey) {
setSecurityKey(securityKey);
checkISecurityKey(securityKey);
this.securityKey = securityKey;
}

public BasicObsCredentialsProvider(String accessKey, String secretKey) {
Expand All @@ -31,7 +32,7 @@ public BasicObsCredentialsProvider(String accessKey, String secretKey) {

public BasicObsCredentialsProvider(String accessKey, String secretKey, String securityToken) {
checkSecurityKey(accessKey, secretKey);
setSecurityKey(new BasicSecurityKey(accessKey, secretKey, securityToken));
this.securityKey = new BasicSecurityKey(accessKey, secretKey, securityToken);
}

private static void checkSecurityKey(String accessKey, String secretKey) {
Expand All @@ -46,12 +47,15 @@ private static void checkSecurityKey(String accessKey, String secretKey) {

@Override
public void setSecurityKey(ISecurityKey securityKey) {
checkISecurityKey(securityKey);
this.securityKey = securityKey;
}

private void checkISecurityKey(ISecurityKey securityKey) {
if (securityKey == null) {
throw new IllegalArgumentException("securityKey should not be null.");
}
checkSecurityKey(securityKey.getAccessKey(), securityKey.getSecretKey());

this.securityKey = securityKey;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public HttpProxyConfiguration(String proxyAddr, int proxyPort, String proxyUname
* Proxy port
* @param proxyUname
* Proxy username
* @param userPaaswd
* @param userPasswd
* Proxy password
* @param domain
* Proxy domain
Expand Down
41 changes: 40 additions & 1 deletion app/src/main/java/com/obs/services/IFSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@
import com.obs.services.model.fs.ContentSummaryFsRequest;
import com.obs.services.model.fs.ListContentSummaryFsResult;
import com.obs.services.model.fs.ListContentSummaryFsRequest;
import com.obs.services.model.fs.accesslabel.DeleteAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.DeleteAccessLabelResult;
import com.obs.services.model.fs.accesslabel.GetAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.GetAccessLabelResult;
import com.obs.services.model.fs.accesslabel.SetAccessLabelRequest;
import com.obs.services.model.fs.accesslabel.SetAccessLabelResult;

/**
* Gateway interface for OBS files
*/
public interface IFSClient {
/**
* Disable ObsClient and release connection resources.
* @throws IOException
* @throws IOException ioException
*/
void close() throws IOException;

Expand Down Expand Up @@ -212,4 +218,37 @@ public interface IFSClient {
* thrown when the interface fails to be called or access to OBS fails
*/
ContentSummaryFsResult getContentSummaryFs(ContentSummaryFsRequest request) throws ObsException;

/**
* set access label for a folder
* s3 protocol is not supported
*
* @param request Request parameters for access label setting
* @return Response to the request for access label setting
* @throws ObsException ObsException OBS SDK self-defined exception,
* thrown when the interface fails to be called or access to OBS fails
*/
SetAccessLabelResult setAccessLabelFs(SetAccessLabelRequest request) throws ObsException;

/**
* get access label of the folder
* s3 protocol is not supported
*
* @param request Request parameters for getting access label
* @return Response to the request for getting access label
* @throws ObsException ObsException OBS SDK self-defined exception,
* thrown when the interface fails to be called or access to OBS fails
*/
GetAccessLabelResult getAccessLabelFs(GetAccessLabelRequest request) throws ObsException;

/**
* delete access label of the folder
* s3 protocol is not supported
*
* @param request Request parameters for deleting access label
* @return Response to the request for deleting access label
* @throws ObsException ObsException OBS SDK self-defined exception,
* thrown when the interface fails to be called or access to OBS fails
*/
DeleteAccessLabelResult deleteAccessLabelFs(DeleteAccessLabelRequest request) throws ObsException;
}
Loading

0 comments on commit de3172b

Please sign in to comment.