* 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;
import java.io.IOException;
@@ -18,6 +19,8 @@
import com.obs.services.exception.ObsException;
import com.obs.services.model.HeaderResponse;
import com.obs.services.model.TaskProgressStatus;
+import com.obs.services.model.fs.ListContentSummaryRequest;
+import com.obs.services.model.fs.ListContentSummaryResult;
import com.obs.services.model.fs.ObsFSAttribute;
import com.obs.services.model.fs.DropFileRequest;
import com.obs.services.model.fs.DropFileResult;
@@ -39,128 +42,174 @@
import com.obs.services.model.fs.TruncateFileRequest;
import com.obs.services.model.fs.TruncateFileResult;
import com.obs.services.model.fs.WriteFileRequest;
+import com.obs.services.model.fs.ContentSummaryFsResult;
+import com.obs.services.model.fs.ContentSummaryFsRequest;
+import com.obs.services.model.fs.ListContentSummaryFsResult;
+import com.obs.services.model.fs.ListContentSummaryFsRequest;
/**
* Gateway interface for OBS files
*/
public interface IFSClient {
- /**
- * Disable ObsClient and release connection resources.
- * @throws IOException
- */
- void close() throws IOException;
-
- /**
- * Create a bucket.
- * @param request Request parameters for creating a bucket
- * @return Bucket supporting the file interface
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSBucket newBucket(NewBucketRequest request) throws ObsException;
-
- /**
- * Specify whether to enable the file gateway feature for the bucket.
- * @param request Request parameters for specifying whether to enable the file gateway feature for the bucket
- * @return Common response headers
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- HeaderResponse setBucketFSStatus(SetBucketFSStatusRequest request) throws ObsException;
-
- /**
- * Check whether the file gateway feature is enabled for the bucket.
- * @param request Request parameters for checking whether the file gateway feature is enabled for the bucket
- * @return Response to the check of whether the file gateway feature is enabled for the bucket
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- GetBucketFSStatusResult getBucketFSStatus(GetBucketFSStatusRequest request) throws ObsException;
-
- /**
- * Create a file.
- * @param request Request parameters for creating a file
- * @return Files in the bucket that supports the file interface
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSFile newFile(NewFileRequest request) throws ObsException;
-
- /**
- * Create a folder.
- * @param request Request parameters for creating a folder
- * @return Folders in the bucket that supports the file interface
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSFolder newFolder(NewFolderRequest request) throws ObsException;
-
- /**
- * Obtain file or folder properties.
- * @param request Request parameters for obtaining filer or folder properties
- * @return File or folder properties
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSAttribute getAttribute(GetAttributeRequest request) throws ObsException;
-
-
- /**
- * Obtain the file content.
- * @param request Request parameters for obtaining the file content
- * @return Response to the request for obtaining file content
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ReadFileResult readFile(ReadFileRequest request) throws ObsException;
-
- /**
- * Write data to a file.
- * @param request Request parameters for writing data to a file
- * @return Files in the bucket that supports the file interface
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSFile writeFile(WriteFileRequest request) throws ObsException;
-
- /**
- * Append data to a file.
- * @param request Request parameters for writing data to a file
- * @return Files in the bucket that supports the file interface
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- ObsFSFile appendFile(WriteFileRequest request) throws ObsException;
-
- /**
- * Rename a file.
- * @param request Request parameters for renaming a file
- * @return Response to the request for renaming a file
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- RenameResult renameFile(RenameRequest request) throws ObsException;
-
- /**
- * Rename a folder.
- * @param request Request parameters for renaming a folder
- * @return Response to the request for renaming a folder
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- RenameResult renameFolder(RenameRequest request) throws ObsException;
-
- /**
- * Truncate a file.
- * @param request Request parameters for truncating a file
- * @return Response to the request for truncating a file
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- TruncateFileResult truncateFile(TruncateFileRequest request) throws ObsException;
-
- /**
- * Delete a file.
- * @param request Request parameters for deleting a file
- * @return Response to the request for deleting a file
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- DropFileResult dropFile(DropFileRequest request) throws ObsException;
-
- /**
- * Delete a folder.
- * @param request Request parameters for deleting a folder
- * @return Batch task execution status
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsException;
-
+ /**
+ * Disable ObsClient and release connection resources.
+ * @throws IOException
+ */
+ void close() throws IOException;
+
+ /**
+ * Create a bucket.
+ * @param request Request parameters for creating a bucket
+ * @return Bucket supporting the file interface
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSBucket newBucket(NewBucketRequest request) throws ObsException;
+
+ /**
+ * Specify whether to enable the file gateway feature for the bucket.
+ * @param request Request parameters for specifying whether to enable the file gateway feature for the bucket
+ * @return Common response headers
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ HeaderResponse setBucketFSStatus(SetBucketFSStatusRequest request) throws ObsException;
+
+ /**
+ * Check whether the file gateway feature is enabled for the bucket.
+ * @param request Request parameters for checking whether the file gateway feature is enabled for the bucket
+ * @return Response to the check of whether the file gateway feature is enabled for the bucket
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ GetBucketFSStatusResult getBucketFSStatus(GetBucketFSStatusRequest request) throws ObsException;
+
+ /**
+ * Create a file.
+ * @param request Request parameters for creating a file
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSFile newFile(NewFileRequest request) throws ObsException;
+
+ /**
+ * Create a folder.
+ * @param request Request parameters for creating a folder
+ * @return Folders in the bucket that supports the file interface
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSFolder newFolder(NewFolderRequest request) throws ObsException;
+
+ /**
+ * Obtain file or folder properties.
+ * @param request Request parameters for obtaining filer or folder properties
+ * @return File or folder properties
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSAttribute getAttribute(GetAttributeRequest request) throws ObsException;
+
+ /**
+ * Obtain the file content.
+ * @param request Request parameters for obtaining the file content
+ * @return Response to the request for obtaining file content
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ReadFileResult readFile(ReadFileRequest request) throws ObsException;
+
+ /**
+ * Write data to a file.
+ * @param request Request parameters for writing data to a file
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSFile writeFile(WriteFileRequest request) throws ObsException;
+
+ /**
+ * Append data to a file.
+ * @param request Request parameters for writing data to a file
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ObsFSFile appendFile(WriteFileRequest request) throws ObsException;
+
+ /**
+ * Rename a file.
+ * @param request Request parameters for renaming a file
+ * @return Response to the request for renaming a file
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ RenameResult renameFile(RenameRequest request) throws ObsException;
+
+ /**
+ * Rename a folder.
+ * @param request Request parameters for renaming a folder
+ * @return Response to the request for renaming a folder
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ RenameResult renameFolder(RenameRequest request) throws ObsException;
+
+ /**
+ * Truncate a file.
+ * @param request Request parameters for truncating a file
+ * @return Response to the request for truncating a file
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ TruncateFileResult truncateFile(TruncateFileRequest request) throws ObsException;
+
+ /**
+ * Delete a file.
+ * @param request Request parameters for deleting a file
+ * @return Response to the request for deleting a file
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ DropFileResult dropFile(DropFileRequest request) throws ObsException;
+
+ /**
+ * Delete a folder.
+ * @param request Request parameters for deleting a folder
+ * @return Batch task execution status
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsException;
+
+ /**
+ * obtain folder contentSummary
+ *
+ * @param request Request parameters for obtain folder contentSummary
+ * @return Response to the request for obtain folder contentSummary
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.5
+ */
+ ListContentSummaryResult listContentSummary(ListContentSummaryRequest request) throws ObsException;
+
+ /**
+ * obtain folder contentSummary
+ *
+ * @param request Request parameters for obtain folder contentSummary
+ * @return Response to the request for obtain folder contentSummary
+ * @throws ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ListContentSummaryFsResult listContentSummaryFs(ListContentSummaryFsRequest request) throws ObsException;
+
+ /**
+ * obtain current folder contentSummary
+ * @param request Request parameters for obtain current folder contentSummary
+ * @return Response to the request for obtain current folder contentSummary
+ * @throws ObsException ObsException OBS SDK self-defined exception,
+ * thrown when the interface fails to be called or access to OBS fails
+ */
+ ContentSummaryFsResult getContentSummaryFs(ContentSummaryFsRequest request) throws ObsException;
}
diff --git a/app/src/main/java/com/obs/services/IObsBucketExtendClient.java b/app/src/main/java/com/obs/services/IObsBucketExtendClient.java
new file mode 100644
index 0000000..1e3a4dc
--- /dev/null
+++ b/app/src/main/java/com/obs/services/IObsBucketExtendClient.java
@@ -0,0 +1,86 @@
+/**
+ * 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;
+
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketCustomDomainInfo;
+import com.obs.services.model.DeleteBucketCustomDomainRequest;
+import com.obs.services.model.GetBucketCustomDomainRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.SetBucketCustomDomainRequest;
+
+/**
+ *
+ *
+ * @since 3.21.8
+ */
+public interface IObsBucketExtendClient {
+ /**
+ * Deleting the Custom Domain Name of a Bucket
+ * @param bucketName Bucket name
+ * @param domainName Custom Domain Name
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ HeaderResponse deleteBucketCustomDomain(String bucketName, String domainName) throws ObsException;
+
+ /**
+ * Deleting the Custom Domain Name of a Bucket
+ * @param request
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ HeaderResponse deleteBucketCustomDomain(DeleteBucketCustomDomainRequest request) throws ObsException;
+
+ /**
+ * Obtaining the Custom Domain Name of a Bucket
+ * @param bucketName Bucket name
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ BucketCustomDomainInfo getBucketCustomDomain(String bucketName) throws ObsException;
+
+ /**
+ * Obtaining the Custom Domain Name of a Bucket
+ * @param request
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ BucketCustomDomainInfo getBucketCustomDomain(GetBucketCustomDomainRequest request) throws ObsException;
+
+ /**
+ * Configuring a Custom Domain Name for a Bucket
+ * @param bucketName Bucket name
+ * @param domainName Custom Domain Name
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ HeaderResponse setBucketCustomDomain(String bucketName, String domainName) throws ObsException;
+
+ /**
+ * Configuring a Custom Domain Name for a Bucket
+ * @param request
+ * @return
+ * @throws ObsException
+ * @since 3.21.8
+ */
+ HeaderResponse setBucketCustomDomain(SetBucketCustomDomainRequest request) throws ObsException;
+}
diff --git a/app/src/main/java/com/obs/services/IObsClient.java b/app/src/main/java/com/obs/services/IObsClient.java
index c39f37c..0863666 100644
--- a/app/src/main/java/com/obs/services/IObsClient.java
+++ b/app/src/main/java/com/obs/services/IObsClient.java
@@ -11,6 +11,7 @@
* 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;
import java.io.File;
@@ -23,6 +24,7 @@
import com.obs.services.model.AccessControlList;
import com.obs.services.model.AppendObjectRequest;
import com.obs.services.model.AppendObjectResult;
+import com.obs.services.model.BaseBucketRequest;
import com.obs.services.model.BucketCors;
import com.obs.services.model.BucketDirectColdAccess;
import com.obs.services.model.BucketEncryption;
@@ -44,11 +46,13 @@
import com.obs.services.model.CopyPartRequest;
import com.obs.services.model.CopyPartResult;
import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.DeleteObjectRequest;
import com.obs.services.model.DeleteObjectResult;
import com.obs.services.model.DeleteObjectsRequest;
import com.obs.services.model.DeleteObjectsResult;
import com.obs.services.model.DownloadFileRequest;
import com.obs.services.model.DownloadFileResult;
+import com.obs.services.model.GetObjectAclRequest;
import com.obs.services.model.GetObjectMetadataRequest;
import com.obs.services.model.GetObjectRequest;
import com.obs.services.model.HeaderResponse;
@@ -81,10 +85,28 @@
import com.obs.services.model.RenameObjectRequest;
import com.obs.services.model.RenameObjectResult;
import com.obs.services.model.ReplicationConfiguration;
+import com.obs.services.model.RequestPaymentConfiguration;
+import com.obs.services.model.RequestPaymentEnum;
import com.obs.services.model.RestoreObjectRequest;
import com.obs.services.model.RestoreObjectRequest.RestoreObjectStatus;
import com.obs.services.model.RestoreObjectResult;
import com.obs.services.model.RestoreObjectsRequest;
+import com.obs.services.model.SetBucketAclRequest;
+import com.obs.services.model.SetBucketCorsRequest;
+import com.obs.services.model.SetBucketDirectColdAccessRequest;
+import com.obs.services.model.SetBucketEncryptionRequest;
+import com.obs.services.model.SetBucketLifecycleRequest;
+import com.obs.services.model.SetBucketLoggingRequest;
+import com.obs.services.model.SetBucketNotificationRequest;
+import com.obs.services.model.SetBucketPolicyRequest;
+import com.obs.services.model.SetBucketQuotaRequest;
+import com.obs.services.model.SetBucketReplicationRequest;
+import com.obs.services.model.SetBucketRequestPaymentRequest;
+import com.obs.services.model.SetBucketStoragePolicyRequest;
+import com.obs.services.model.SetBucketTaggingRequest;
+import com.obs.services.model.SetBucketVersioningRequest;
+import com.obs.services.model.SetBucketWebsiteRequest;
+import com.obs.services.model.SetObjectAclRequest;
import com.obs.services.model.SetObjectMetadataRequest;
import com.obs.services.model.TaskProgressStatus;
import com.obs.services.model.TemporarySignatureRequest;
@@ -100,8 +122,9 @@
/**
* Basic OBS interface
*/
-public interface IObsClient {
-
+//CHECKSTYLE:OFF
+public interface IObsClient extends IObsBucketExtendClient {
+
/**
*
* Refresh the temporary access key.
@@ -123,7 +146,8 @@ public interface IObsClient {
* Parameters in a request for temporarily authorized access
* @return Response to the request for temporarily authorized access
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
TemporarySignatureResponse createTemporarySignature(TemporarySignatureRequest request);
@@ -134,7 +158,8 @@ public interface IObsClient {
* Request parameters for V4 browser-based authorized access
* @return Response to the V4 browser-based authorized access
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PostSignatureResponse createPostSignature(PostSignatureRequest request) throws ObsException;
@@ -150,14 +175,16 @@ public interface IObsClient {
*
Cannot be an IP address.
*
Cannot end with a hyphen (-).
*
Cannot contain two consecutive periods (..).
- *
Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, "my-.bucket" and "my.-bucket".
+ *
Cannot contain periods (.) and hyphens (-) adjacent to each other,
+ * for example, "my-.bucket" and "my.-bucket".
*
*
* @param bucketName
* Bucket name
* @return Bucket information
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsBucket createBucket(String bucketName) throws ObsException;
@@ -174,17 +201,20 @@ public interface IObsClient {
*
Cannot be an IP address.s
*
Cannot end with a hyphen (-).
*
Cannot contain two consecutive periods (..).
- *
Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, "my-.bucket" and "my.-bucket".
+ *
Cannot contain periods (.) and hyphens (-) adjacent to each other,
+ * for example, "my-.bucket" and "my.-bucket".
*
*
*
* @param bucketName
* Bucket name
* @param location
- * Bucket location. This parameter is mandatory unless the endpoint belongs to the default region.
+ * Bucket location. This parameter is mandatory unless the
+ * endpoint belongs to the default region.
* @return Bucket information
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsBucket createBucket(String bucketName, String location) throws ObsException;
@@ -201,14 +231,16 @@ public interface IObsClient {
*
Cannot be an IP address.
*
Cannot end with a hyphen (-).
*
Cannot contain two consecutive periods (..).
- *
Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, "my-.bucket" and "my.-bucket".
+ *
Cannot contain periods (.) and hyphens (-) adjacent to each other,
+ * for example, "my-.bucket" and "my.-bucket".
*
*
* @param bucket
* Bucket information, including the request parameters
* @return Bucket information
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsBucket createBucket(ObsBucket bucket) throws ObsException;
@@ -224,41 +256,130 @@ public interface IObsClient {
*
Cannot be an IP address.
*
Cannot end with a hyphen (-).
*
Cannot contain two consecutive periods (..).
- *
Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, "my-.bucket" and "my.-bucket".
+ *
Cannot contain periods (.) and hyphens (-) adjacent to each other,
+ * for example, "my-.bucket" and "my.-bucket".
*
*
* @param request
* Request parameters for creating a bucket
* @return Bucket information
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*
*/
ObsBucket createBucket(CreateBucketRequest request) throws ObsException;
+ /**
+ * Rename a file or directory. Only the parallel file system supports this interface.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param objectKey
+ * File name or directory name
+ * @param newObjectKey
+ * Name of the renamed file or directory
+ * @return Response to the request for renaming a file
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ RenameObjectResult renameObject(String bucketName, String objectKey, String newObjectKey) throws ObsException;
- RenameObjectResult renameObject(String bucketName, String objectKey, String newObjectKey) throws ObsException;
-
-
- RenameObjectResult renameObject(final RenameObjectRequest request) throws ObsException;
-
-
- TruncateObjectResult truncateObject(String bucketName, String objectKey, long newLength) throws ObsException;
-
-
- TruncateObjectResult truncateObject(final TruncateObjectRequest request) throws ObsException;
-
-
- ModifyObjectResult modifyObject(String bucketName, String objectKey, long position, File file) throws ObsException;
+ /**
+ * Rename a file or directory. Only the parallel file system supports this interface.
+ *
+ * @param request
+ * Parameters of a request for renaming a file
+ * @return Response to the request for renaming a file
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ RenameObjectResult renameObject(final RenameObjectRequest request) throws ObsException;
+ /**
+ * Truncate a file. Only the parallel file system supports this interface.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param objectKey
+ * File name
+ * @param newLength
+ * Size of the truncated file
+ * @return Response to the request for truncating a file
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ TruncateObjectResult truncateObject(String bucketName, String objectKey, long newLength) throws ObsException;
- ModifyObjectResult modifyObject(String bucketName, String objectKey, long position, InputStream input) throws ObsException;
+ /**
+ * Truncate a file. Only the parallel file system supports this interface.
+ *
+ * @param request
+ * Parameters of a request for truncating a file
+ * @return Response to the request for truncating a file
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ TruncateObjectResult truncateObject(final TruncateObjectRequest request) throws ObsException;
+ /**
+ * Write a file. Only the parallel file system supports this interface.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param objectKey
+ * File name
+ * @param position
+ * Start position for writing data to a file
+ * @param file
+ * Local file path
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ ModifyObjectResult modifyObject(String bucketName, String objectKey, long position, File file) throws ObsException;
- ModifyObjectResult modifyObject(ModifyObjectRequest request) throws ObsException;
+ /**
+ * Write a file. Only the parallel file system supports this interface.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param objectKey
+ * File name
+ * @param position
+ * Start position for writing data to a file
+ * @param input
+ * Data stream to be uploaded
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ ModifyObjectResult modifyObject(String bucketName, String objectKey, long position, InputStream input)
+ throws ObsException;
+ /**
+ * Write a file. Only the parallel file system supports this interface.
+ *
+ * @param request
+ * Request parameters for writing data to a file
+ * @return Files in the bucket that supports the file interface
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ ModifyObjectResult modifyObject(ModifyObjectRequest request) throws ObsException;
- List listBuckets(ListBucketsRequest request) throws ObsException;
+ /**
+ * Obtain the bucket list.
+ *
+ * @param request
+ * Obtain the request parameters for obtaining the bucket list.
+ * @return Bucket list
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ List listBuckets(ListBucketsRequest request) throws ObsException;
/**
* Obtain the bucket list.
@@ -267,7 +388,8 @@ public interface IObsClient {
* Obtain the request parameters for obtaining the bucket list.
* @return Response to the request for obtaining the bucket list
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListBucketsResult listBucketsV2(ListBucketsRequest request) throws ObsException;
@@ -278,10 +400,23 @@ public interface IObsClient {
* Bucket name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse deleteBucket(String bucketName) throws ObsException;
+ /**
+ * Delete a bucket.
+ *
+ * @param request
+ * Parameters of a request for deleting a bucket
+ * @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 deleteBucket(BaseBucketRequest request) throws ObsException;
+
/**
* List objects in the bucket.
*
@@ -289,7 +424,8 @@ public interface IObsClient {
* Request parameters for listing objects in a bucket
* @return Response to the request for listing objects in the bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectListing listObjects(ListObjectsRequest request) throws ObsException;
@@ -300,7 +436,8 @@ public interface IObsClient {
* Bucket name
* @return Response to the request for listing objects in the bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectListing listObjects(String bucketName) throws ObsException;
@@ -311,18 +448,34 @@ public interface IObsClient {
* Bucket name
* @return Identifier indicating whether the bucket exists
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
boolean headBucket(String bucketName) throws ObsException;
+ /**
+ * Identify whether a bucket exists.
+ *
+ * @param request
+ * Request parameters
+ * @return Identifier indicating whether the bucket exists
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ boolean headBucket(BaseBucketRequest request) throws ObsException;
+
/**
* List versioning objects in a bucket.
*
* @param request
- * Request parameters for listing versioning objects in the bucket
- * @return Response to the request for listing versioning objects in the bucket
+ * Request parameters for listing versioning objects in the
+ * bucket
+ * @return Response to the request for listing versioning objects in the
+ * bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListVersionsResult listVersions(ListVersionsRequest request) throws ObsException;
@@ -331,9 +484,11 @@ public interface IObsClient {
*
* @param bucketName
* Bucket name
- * @return Response to the request for listing versioning objects in the bucket
+ * @return Response to the request for listing versioning objects in the
+ * bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListVersionsResult listVersions(String bucketName) throws ObsException;
@@ -344,9 +499,11 @@ public interface IObsClient {
* Bucket name
* @param maxKeys
* Maximum number of versioning objects to be listed
- * @return Response to the request for listing versioning objects in the bucket
+ * @return Response to the request for listing versioning objects in the
+ * bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListVersionsResult listVersions(String bucketName, long maxKeys) throws ObsException;
@@ -360,17 +517,21 @@ public interface IObsClient {
* @param delimiter
* Character for grouping object names
* @param keyMarker
- * Start position for listing versioning objects (sorted by object name)
+ * Start position for listing versioning objects (sorted by
+ * object name)
* @param versionIdMarker
- * Start position for listing versioning objects (sorted by version ID)
+ * Start position for listing versioning objects (sorted by
+ * version ID)
* @param maxKeys
* Maximum number of versioning objects to be listed
- * @return Response to the request for listing versioning objects in the bucket
+ * @return Response to the request for listing versioning objects in the
+ * bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListVersionsResult listVersions(String bucketName, String prefix, String delimiter, String keyMarker,
- String versionIdMarker, long maxKeys) throws ObsException;
+ String versionIdMarker, long maxKeys) throws ObsException;
/**
* Obtain bucket metadata.
@@ -379,7 +540,8 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Request parameters for obtaining bucket metadata
* @return Response to the request for obtaining bucket metadata
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketMetadataInfoResult getBucketMetadata(BucketMetadataInfoRequest request) throws ObsException;
@@ -390,10 +552,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Bucket ACL
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
AccessControlList getBucketAcl(String bucketName) throws ObsException;
+ /**
+ * Obtain a bucket ACL.
+ *
+ * @param request
+ * Request parameters for obtaining the bucket ACL
+ * @return Response to a request for obtaining the bucket ACL
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ AccessControlList getBucketAcl(BaseBucketRequest request) throws ObsException;
+
/**
* Set a bucket ACL.
*
@@ -403,10 +578,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* ACL
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketAcl(String bucketName, AccessControlList acl) throws ObsException;
+ /**
+ * Set a bucket ACL.
+ *
+ * @param request
+ * Request parameters for setting a bucket ACL
+ * @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 setBucketAcl(SetBucketAclRequest request) throws ObsException;
+
/**
* Obtain the bucket location.
*
@@ -414,10 +602,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Bucket location
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
String getBucketLocation(String bucketName) throws ObsException;
+ /**
+ * Obtain the bucket location.
+ *
+ * @param request
+ * Request parameters
+ * @return Response to the request for obtaining the bucket location
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketLocationResponse getBucketLocation(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the bucket location.
*
@@ -425,7 +626,8 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Response to the request for obtaining the bucket location
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketLocationResponse getBucketLocationV2(String bucketName) throws ObsException;
@@ -436,10 +638,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Bcket storage information
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketStorageInfo getBucketStorageInfo(String bucketName) throws ObsException;
+ /**
+ * Obtain bucket storage information.
+ *
+ * @param request
+ * Bucket name
+ * @return Bucket storage information
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketStorageInfo getBucketStorageInfo(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the bucket quota.
*
@@ -447,10 +662,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Bucket quota
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketQuota getBucketQuota(String bucketName) throws ObsException;
+ /**
+ * Obtain the bucket quota.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket quota
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketQuota getBucketQuota(BaseBucketRequest request) throws ObsException;
+
/**
* Set the bucket quota.
*
@@ -459,11 +687,24 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* @param bucketQuota
* Bucket quota
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
* @return Common response headers
*/
HeaderResponse setBucketQuota(String bucketName, BucketQuota bucketQuota) throws ObsException;
+ /**
+ * Set the bucket quota.
+ *
+ * @param request
+ * Request parameters
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @return Common response headers
+ * @since 3.20.3
+ */
+ HeaderResponse setBucketQuota(SetBucketQuotaRequest request) throws ObsException;
+
/**
* Obtain the bucket storage class.
*
@@ -471,10 +712,23 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket name
* @return Bucket storage policy
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketStoragePolicyConfiguration getBucketStoragePolicy(String bucketName) throws ObsException;
+ /**
+ * Obtain the bucket storage class.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket storage policy
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketStoragePolicyConfiguration getBucketStoragePolicy(BaseBucketRequest request) throws ObsException;
+
/**
* Set the bucket storage class.
*
@@ -484,11 +738,24 @@ ListVersionsResult listVersions(String bucketName, String prefix, String delimit
* Bucket storage policy
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketStoragePolicy(String bucketName, BucketStoragePolicyConfiguration bucketStorage)
throws ObsException;
+ /**
+ * Set the bucket storage class.
+ *
+ * @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 setBucketStoragePolicy(SetBucketStoragePolicyRequest request) throws ObsException;
+
/**
* Configure the bucket CORS.
*
@@ -498,10 +765,23 @@ HeaderResponse setBucketStoragePolicy(String bucketName, BucketStoragePolicyConf
* CORS rules
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketCors(String bucketName, BucketCors bucketCors) throws ObsException;
+ /**
+ * Configure the bucket CORS.
+ *
+ * @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 setBucketCors(SetBucketCorsRequest request) throws ObsException;
+
/**
* Obtain the bucket CORS rules.
*
@@ -509,10 +789,23 @@ HeaderResponse setBucketStoragePolicy(String bucketName, BucketStoragePolicyConf
* Bucket name
* @return Bucket CORS rules
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketCors getBucketCors(String bucketName) throws ObsException;
+ /**
+ * Obtain the bucket CORS rules.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket CORS configuration
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketCors getBucketCors(BaseBucketRequest request) throws ObsException;
+
/**
* Delete the bucket CORS rules.
*
@@ -520,10 +813,23 @@ HeaderResponse setBucketStoragePolicy(String bucketName, BucketStoragePolicyConf
* Bucket name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse deleteBucketCors(String bucketName) throws ObsException;
+ /**
+ * Delete the bucket CORS rules.
+ *
+ * @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 deleteBucketCors(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the logging settings of a bucket.
*
@@ -531,12 +837,25 @@ HeaderResponse setBucketStoragePolicy(String bucketName, BucketStoragePolicyConf
* Bucket name
* @return Logging settings of the bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketLoggingConfiguration getBucketLogging(String bucketName) throws ObsException;
+ /**
+ * Obtain the logging settings of a bucket.
+ *
+ * @param request
+ * Request parameters
+ * @return Logging settings of the bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketLoggingConfiguration getBucketLogging(BaseBucketRequest request) throws ObsException;
+
HeaderResponse setBucketLoggingConfiguration(String bucketName, BucketLoggingConfiguration loggingConfiguration,
- boolean updateTargetACLifRequired) throws ObsException;
+ boolean updateTargetACLifRequired) throws ObsException;
/**
* Configure logging for a bucket.
@@ -547,11 +866,24 @@ HeaderResponse setBucketLoggingConfiguration(String bucketName, BucketLoggingCon
* Logging settings
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketLogging(String bucketName, BucketLoggingConfiguration loggingConfiguration)
throws ObsException;
+ /**
+ * Configure logging for a bucket.
+ *
+ * @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 setBucketLogging(SetBucketLoggingRequest request) throws ObsException;
+
/**
* Set the versioning status for a bucket.
*
@@ -561,11 +893,24 @@ HeaderResponse setBucketLogging(String bucketName, BucketLoggingConfiguration lo
* Versioning status of the bucket
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfiguration versioningConfiguration)
throws ObsException;
+ /**
+ * Set the versioning status for a bucket.
+ *
+ * @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 setBucketVersioning(SetBucketVersioningRequest request) throws ObsException;
+
/**
* Obtain the versioning status for a bucket.
*
@@ -573,10 +918,72 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Versioning status of the bucket
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketVersioningConfiguration getBucketVersioning(String bucketName) throws ObsException;
+ /**
+ * Obtain the versioning status for a bucket.
+ *
+ * @param request
+ * Request parameters
+ * @return Versioning status of the bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketVersioningConfiguration getBucketVersioning(BaseBucketRequest request) throws ObsException;
+
+ /**
+ * Configure the requester-pays function for a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param payer
+ * The status of the requester-pays function
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
+ HeaderResponse setBucketRequestPayment(String bucketName, RequestPaymentEnum payer) throws ObsException;
+
+ /**
+ * Configure the requester-pays function for a bucket.
+ *
+ * @param request
+ * Configuration of the requester-pays function of a bucket
+ * @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 setBucketRequestPayment(SetBucketRequestPaymentRequest request) throws ObsException;
+
+ /**
+ * Obtain the status of the requester-pays function of a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Configuration of the requester-pays function of the bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ RequestPaymentConfiguration getBucketRequestPayment(String bucketName) throws ObsException;
+
+ /**
+ * Obtain the requester-pays status of a bucket.
+ *
+ * @param request
+ * Basic bucket information
+ * @return Configuration of the requester-pays function of the bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ RequestPaymentConfiguration getBucketRequestPayment(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the bucket lifecycle rules.
*
@@ -584,10 +991,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Bucket lifecycle rules
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
LifecycleConfiguration getBucketLifecycle(String bucketName) throws ObsException;
+ /**
+ * Obtain the bucket lifecycle rules.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket lifecycle rules
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ LifecycleConfiguration getBucketLifecycle(BaseBucketRequest request) throws ObsException;
+
/**
* Set the bucket lifecycle rules.
*
@@ -597,10 +1017,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket lifecycle rules
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketLifecycle(String bucketName, LifecycleConfiguration lifecycleConfig) throws ObsException;
+ /**
+ * Configure lifecycle rules for a bucket.
+ *
+ * @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 setBucketLifecycle(SetBucketLifecycleRequest request) throws ObsException;
+
/**
* Delete the bucket lifecycle rules from a bucket.
*
@@ -608,10 +1041,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse deleteBucketLifecycle(String bucketName) throws ObsException;
+ /**
+ * Delete the bucket lifecycle rules from a bucket.
+ *
+ * @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 deleteBucketLifecycle(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain bucket policies.
*
@@ -619,10 +1065,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Bucket policy, in the JSON format
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
String getBucketPolicy(String bucketName) throws ObsException;
+ /**
+ * Obtain a bucket policy.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket policy, in the JSON format
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ String getBucketPolicy(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain bucket policies.
*
@@ -630,10 +1089,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Response to a request for obtaining bucket policies
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketPolicyResponse getBucketPolicyV2(String bucketName) throws ObsException;
+ /**
+ * Obtain bucket policies.
+ *
+ * @param request
+ * Request parameters
+ * @return Response to a request for obtaining bucket policies
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketPolicyResponse getBucketPolicyV2(BaseBucketRequest request) throws ObsException;
+
/**
* Set bucket policies.
*
@@ -643,10 +1115,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket policy, in the JSON format
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketPolicy(String bucketName, String policy) throws ObsException;
+ /**
+ * Set bucket policies.
+ *
+ * @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 setBucketPolicy(SetBucketPolicyRequest request) throws ObsException;
+
/**
* Delete bucket policies.
*
@@ -654,10 +1139,23 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse deleteBucketPolicy(String bucketName) throws ObsException;
+ /**
+ * Delete bucket policies.
+ *
+ * @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 deleteBucketPolicy(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the website hosting configuration of a Bucket
*
@@ -665,101 +1163,221 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Bucket name
* @return Website hosting configuration of a bucket
* @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ WebsiteConfiguration getBucketWebsite(String bucketName) throws ObsException;
+
+ /**
+ * Obtain the website hosting settings of a Bucket
+ *
+ * @param request
+ * Request parameters
+ * @return Website hosting configuration of a bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ WebsiteConfiguration getBucketWebsite(BaseBucketRequest request) throws ObsException;
+
+ /**
+ * Configure website hosting for a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param websiteConfig
+ * Website hosting configuration of a bucket
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ HeaderResponse setBucketWebsite(String bucketName, WebsiteConfiguration websiteConfig) throws ObsException;
+
+ /**
+ * Configure website hosting for a bucket.
+ *
+ * @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 setBucketWebsite(SetBucketWebsiteRequest request) throws ObsException;
+
+ /**
+ * Delete the website hosting configuration of a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ HeaderResponse deleteBucketWebsite(String bucketName) throws ObsException;
+
+ /**
+ * Delete the website hosting configuration of a bucket.
+ *
+ * @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 deleteBucketWebsite(BaseBucketRequest request) throws ObsException;
+
+ /**
+ * Obtain bucket tags.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Bucket tag
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ BucketTagInfo getBucketTagging(String bucketName) throws ObsException;
+
+ /**
+ * Obtain bucket tags.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket 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
+ */
+ BucketTagInfo getBucketTagging(BaseBucketRequest request) throws ObsException;
+
+ /**
+ * Set bucket tags.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param bucketTagInfo
+ * Bucket tags
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ HeaderResponse setBucketTagging(String bucketName, BucketTagInfo bucketTagInfo) throws ObsException;
+
+ /**
+ * Set bucket 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 setBucketTagging(SetBucketTaggingRequest request) throws ObsException;
+
+ /**
+ * Delete bucket tags.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ HeaderResponse deleteBucketTagging(String bucketName) throws ObsException;
+
+ /**
+ * Delete bucket 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
*/
- WebsiteConfiguration getBucketWebsite(String bucketName) throws ObsException;
-
+ HeaderResponse deleteBucketTagging(BaseBucketRequest request) throws ObsException;
+
+
/**
- * Configure website hosting for a bucket.
- *
+ * Obtain bucket encryption configuration.
+ *
* @param bucketName
* Bucket name
- * @param websiteConfig
- * Website hosting configuration of a bucket
- * @return Common response headers
+ * @return Bucket encryption configuration
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
+ BucketEncryption getBucketEncryption(String bucketName) throws ObsException;
+
+ /**
+ * Obtain bucket encryption configuration.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket encryption configuration
* @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 setBucketWebsite(String bucketName, WebsiteConfiguration websiteConfig) throws ObsException;
+ BucketEncryption getBucketEncryption(BaseBucketRequest request) throws ObsException;
/**
- * Delete the website hosting configuration of a bucket.
- *
+ * Set bucket encryption.
+ *
* @param bucketName
* Bucket name
+ * @param bucketEncryption
+ * Bucket encryption configuration
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
- HeaderResponse deleteBucketWebsite(String bucketName) throws ObsException;
+ HeaderResponse setBucketEncryption(String bucketName, BucketEncryption bucketEncryption) throws ObsException;
/**
- * Obtain bucket tags.
- *
- * @param bucketName
- * Bucket name
- * @return Bucket tag
+ * Configure bucket encryption.
+ *
+ * @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
*/
- BucketTagInfo getBucketTagging(String bucketName) throws ObsException;
+ HeaderResponse setBucketEncryption(SetBucketEncryptionRequest request) throws ObsException;
/**
- * Set bucket tags.
- *
+ * Delete bucket encryption configuration.
+ *
* @param bucketName
* Bucket name
- * @param bucketTagInfo
- * Bucket tags
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
- HeaderResponse setBucketTagging(String bucketName, BucketTagInfo bucketTagInfo) throws ObsException;
+ HeaderResponse deleteBucketEncryption(String bucketName) throws ObsException;
/**
- * Delete bucket tags.
- *
- * @param bucketName
- * Bucket name
+ * Delete bucket encryption configuration.
+ *
+ * @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 deleteBucketTagging(String bucketName) throws ObsException;
-
-
- /**
- * Obtain bucket encryption configuration.
- * @param bucketName
- * Bucket name
- * @return Bucket encryption configuration
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- BucketEncryption getBucketEncryption(String bucketName) throws ObsException;
-
- /**
- * Set bucket encryption.
- * @param bucketName
- * Bucket name
- * @param bucketEncryption
- * Bucket encryption configuration
- * @return Common response headers
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- HeaderResponse setBucketEncryption(String bucketName, BucketEncryption bucketEncryption) throws ObsException;
-
- /**
- * Delete bucket encryption configuration.
- * @param bucketName
- * Bucket name
- * @return Common response headers
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- HeaderResponse deleteBucketEncryption(String bucketName) throws ObsException;
+ HeaderResponse deleteBucketEncryption(BaseBucketRequest request) throws ObsException;
/**
* Configure cross-region replication for a bucket.
@@ -770,12 +1388,25 @@ HeaderResponse setBucketVersioning(String bucketName, BucketVersioningConfigurat
* Cross-region replication configuration
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*
*/
HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration replicationConfiguration)
throws ObsException;
+ /**
+ * Configure cross-region replication for a bucket.
+ *
+ * @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 setBucketReplication(SetBucketReplicationRequest request) throws ObsException;
+
/**
* Obtain the cross-region replication configuration of a bucket.
*
@@ -783,10 +1414,23 @@ HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration
* Bucket name
* @return Cross-region replication configuration
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ReplicationConfiguration getBucketReplication(String bucketName) throws ObsException;
+ /**
+ * Obtain the cross-region replication configuration of a bucket.
+ *
+ * @param request
+ * Request parameters
+ * @return Cross-region replication configuration
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ ReplicationConfiguration getBucketReplication(BaseBucketRequest request) throws ObsException;
+
/**
* Delete the bucket cross-region replication configuration.
*
@@ -794,10 +1438,23 @@ HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration
* Bucket name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse deleteBucketReplication(String bucketName) throws ObsException;
+ /**
+ * Delete the bucket cross-region replication configuration.
+ *
+ * @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 deleteBucketReplication(BaseBucketRequest request) throws ObsException;
+
/**
* Obtain the notification configuration of a bucket.
*
@@ -805,10 +1462,23 @@ HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration
* Bucket name
* @return Bucket notification configuration
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
BucketNotificationConfiguration getBucketNotification(String bucketName) throws ObsException;
+ /**
+ * Obtain the notification configuration of a bucket.
+ *
+ * @param request
+ * Request parameters
+ * @return Bucket notification configuration
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketNotificationConfiguration getBucketNotification(BaseBucketRequest request) throws ObsException;
+
/**
* Configure bucket notification.
*
@@ -818,10 +1488,23 @@ HeaderResponse setBucketReplication(String bucketName, ReplicationConfiguration
* Bucket notification configuration
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setBucketNotification(String bucketName,
- BucketNotificationConfiguration bucketNotificationConfiguration) throws ObsException;
+ BucketNotificationConfiguration bucketNotificationConfiguration) throws ObsException;
+
+ /**
+ * Set event notification for a bucket.
+ *
+ * @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 setBucketNotification(SetBucketNotificationRequest request) throws ObsException;
/**
* Upload an object.
@@ -836,7 +1519,8 @@ HeaderResponse setBucketNotification(String bucketName,
* Object properties
* @return Response to an object upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PutObjectResult putObject(String bucketName, String objectKey, InputStream input, ObjectMetadata metadata)
throws ObsException;
@@ -852,7 +1536,8 @@ PutObjectResult putObject(String bucketName, String objectKey, InputStream input
* Data stream to be uploaded
* @return Response to an object upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PutObjectResult putObject(String bucketName, String objectKey, InputStream input) throws ObsException;
@@ -863,7 +1548,8 @@ PutObjectResult putObject(String bucketName, String objectKey, InputStream input
* Parameters in an object upload request
* @return Response to an object upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PutObjectResult putObject(PutObjectRequest request) throws ObsException;
@@ -878,7 +1564,8 @@ PutObjectResult putObject(String bucketName, String objectKey, InputStream input
* File to be uploaded
* @return Response to an object upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PutObjectResult putObject(String bucketName, String objectKey, File file) throws ObsException;
@@ -895,16 +1582,21 @@ PutObjectResult putObject(String bucketName, String objectKey, InputStream input
* Object properties
* @return Response to an object upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
PutObjectResult putObject(String bucketName, String objectKey, File file, ObjectMetadata metadata)
throws ObsException;
/**
* Perform an appendable upload.
- * @param request Parameters in an appendable upload request
+ *
+ * @param request
+ * Parameters in an appendable upload request
* @return Response to the appendable upload request
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
AppendObjectResult appendObject(AppendObjectRequest request) throws ObsException;
@@ -915,22 +1607,55 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Parameters in a file upload request
* @return Result of part combination
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
CompleteMultipartUploadResult uploadFile(UploadFileRequest uploadFileRequest) throws ObsException;
+ /**
+ * Upload files in a batch.
+ *
+ * @param request
+ * Request parameters for uploading files in a batch
+ * @return Batch task execution status
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
UploadProgressStatus putObjects(PutObjectsRequest request) throws ObsException;
+ /**
+ * Check whether an object exists.
+ *
+ * @param buckeName
+ * Bucket name
+ * @param objectKey
+ * Object name
+ * @return Whether an object exists
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
boolean doesObjectExist(String buckeName, String objectKey) throws ObsException;
+ /**
+ * Check whether an object exists.
+ *
+ * @param request
+ * Request parameters for obtaining the properties of an object
+ * @return Whether an object exists
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ */
boolean doesObjectExist(GetObjectMetadataRequest request) throws ObsException;
+
/**
* Download a file. The resumable download mode is supported.
*
* @param downloadFileRequest
* Parameters in a request for downloading a file
* @return File download result
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
DownloadFileResult downloadFile(DownloadFileRequest downloadFileRequest) throws ObsException;
@@ -941,7 +1666,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Parameters in an object download request
* @return Object information, including the object data stream
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsObject getObject(GetObjectRequest request) throws ObsException;
@@ -956,7 +1682,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object version ID
* @return Object information, including the object data stream
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsObject getObject(String bucketName, String objectKey, String versionId) throws ObsException;
@@ -969,7 +1696,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object name
* @return Object information, including the object data stream
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObsObject getObject(String bucketName, String objectKey) throws ObsException;
@@ -977,10 +1705,12 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Obtain object properties.
*
* @param request
- * Parameters in a request for obtaining the properties of an object
+ * Parameters in a request for obtaining the properties of an
+ * object
* @return Object properties
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectMetadata getObjectMetadata(GetObjectMetadataRequest request) throws ObsException;
@@ -995,7 +1725,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object version ID
* @return Object properties
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectMetadata getObjectMetadata(String bucketName, String objectKey, String versionId) throws ObsException;
@@ -1008,15 +1739,20 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object name
* @return Object properties
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectMetadata getObjectMetadata(String bucketName, String objectKey) throws ObsException;
/**
* Set object properties.
- * @param request Parameters in the request for obtaining object properties
+ *
+ * @param request
+ * Parameters in the request for obtaining object properties
* @return Object properties
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ObjectMetadata setObjectMetadata(SetObjectMetadataRequest request) throws ObsException;
@@ -1027,33 +1763,35 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Parameters in a request for restoring an Archive object
* @return Status of the to-be-restored Archive object
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*
*/
- @Deprecated
RestoreObjectStatus restoreObject(RestoreObjectRequest request) throws ObsException;
- /**
+ /**
* Restore an Archive object.
*
* @param request
* Request parameters for restoring an Archive object
* @return Result of restoring the Archive object
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*
*/
RestoreObjectResult restoreObjectV2(RestoreObjectRequest request) throws ObsException;
- /**
+ /**
* Restore Archive objects in a batch.
*
* @param request
* Request parameters for restoring Archive objects in a batch
- * @return Batch task execution status
+ * @return Batch task execution status
*
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*
*/
@@ -1070,7 +1808,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object version ID
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
DeleteObjectResult deleteObject(String bucketName, String objectKey, String versionId) throws ObsException;
@@ -1084,10 +1823,23 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object name
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
DeleteObjectResult deleteObject(String bucketName, String objectKey) throws ObsException;
+ /**
+ * Delete an object.
+ *
+ * @param request
+ * Request parameters for deleting an object
+ * @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
+ */
+ DeleteObjectResult deleteObject(DeleteObjectRequest request) throws ObsException;
+
/**
* Delete objects in a batch.
*
@@ -1095,7 +1847,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Parameters in an object batch deletion request
* @return Result of the object batch deletion request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws ObsException;
@@ -1110,7 +1863,8 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object version ID
* @return Object ACL
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
AccessControlList getObjectAcl(String bucketName, String objectKey, String versionId) throws ObsException;
@@ -1123,10 +1877,23 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object name
* @return Object ACL
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
AccessControlList getObjectAcl(String bucketName, String objectKey) throws ObsException;
+ /**
+ * Obtain an object ACL.
+ *
+ * @param request
+ * Request parameters for obtaining an object ACL
+ * @return Object ACL
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ AccessControlList getObjectAcl(GetObjectAclRequest request) throws ObsException;
+
/**
* Set an object ACL.
*
@@ -1140,14 +1907,15 @@ PutObjectResult putObject(String bucketName, String objectKey, File file, Object
* Object version ID
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse setObjectAcl(String bucketName, String objectKey, AccessControlList acl, String versionId)
throws ObsException;
/**
* Set an object ACL.
- *
+ *
* @param bucketName
* Bucket name
* @param objectKey
@@ -1160,6 +1928,18 @@ HeaderResponse setObjectAcl(String bucketName, String objectKey, AccessControlLi
*/
HeaderResponse setObjectAcl(String bucketName, String objectKey, AccessControlList acl) throws ObsException;
+ /**
+ * Set an object ACL.
+ *
+ * @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 setObjectAcl(SetObjectAclRequest request) throws ObsException;
+
/**
* Copy an object.
*
@@ -1167,7 +1947,8 @@ HeaderResponse setObjectAcl(String bucketName, String objectKey, AccessControlLi
* Parameters in a request for copying an object
* @return Result of the object copy
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
CopyObjectResult copyObject(CopyObjectRequest request) throws ObsException;
@@ -1184,10 +1965,11 @@ HeaderResponse setObjectAcl(String bucketName, String objectKey, AccessControlLi
* Destination object name
* @return Result of the object copy
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
CopyObjectResult copyObject(String sourceBucketName, String sourceObjectKey, String destBucketName,
- String destObjectKey) throws ObsException;
+ String destObjectKey) throws ObsException;
/**
* Initialize a multipart upload.
@@ -1196,7 +1978,8 @@ CopyObjectResult copyObject(String sourceBucketName, String sourceObjectKey, Str
* Parameters in a request for initializing a multipart upload
* @return Result of the multipart upload
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest request) throws ObsException;
@@ -1207,7 +1990,8 @@ CopyObjectResult copyObject(String sourceBucketName, String sourceObjectKey, Str
* Parameters in a request for aborting a multipart upload
* @return Common response headers
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
HeaderResponse abortMultipartUpload(AbortMultipartUploadRequest request) throws ObsException;
@@ -1226,7 +2010,8 @@ CopyObjectResult copyObject(String sourceBucketName, String sourceObjectKey, Str
* Data stream to be uploaded
* @return Response to a part upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId, int partNumber, InputStream input)
throws ObsException;
@@ -1246,7 +2031,8 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* File to be uploaded
* @return Response to a part upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId, int partNumber, File file)
throws ObsException;
@@ -1258,7 +2044,8 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* Parameters in a part upload request
* @return Response to a part upload request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
UploadPartResult uploadPart(UploadPartRequest request) throws ObsException;
@@ -1269,7 +2056,8 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* Parameters in the request for copying a part
* @return Response to a part copy request
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
CopyPartResult copyPart(CopyPartRequest request) throws ObsException;
@@ -1280,7 +2068,8 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* Parameters in a request for combining parts
* @return Result of part combination
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest request) throws ObsException;
@@ -1291,7 +2080,8 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* Parameters in a request for listing uploaded parts
* @return Response to a request for listing uploaded parts
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
ListPartsResult listParts(ListPartsRequest request) throws ObsException;
@@ -1302,66 +2092,132 @@ UploadPartResult uploadPart(String bucketName, String objectKey, String uploadId
* Parameters in a request for listing multipart uploads
* @return List of multipart uploads
* @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
*/
MultipartUploadListing listMultipartUploads(ListMultipartUploadsRequest request) throws ObsException;
- /**
- * Read ahead objects.
- * @param request Request parameters for reading ahead objects
- * @return Response to the request for reading ahead objects
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Read ahead objects.
+ *
+ * @param request
+ * Request parameters for reading ahead objects
+ * @return Response to the request for reading ahead objects
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
ReadAheadResult readAheadObjects(ReadAheadRequest request) throws ObsException;
- /**
- * Delete the read-ahead cache.
- * @param bucketName Bucket name
- * @param prefix Name prefix of objects to be read ahead
- * @return Response to the request for reading ahead objects
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Delete the read-ahead cache.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param prefix
+ * Name prefix of objects to be read ahead
+ * @return Response to the request for reading ahead objects
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
ReadAheadResult deleteReadAheadObjects(String bucketName, String prefix) throws ObsException;
- /**
- * Query the progress of a read-ahead task.
- * @param bucketName Bucket name
- * @param taskId ID of the read-ahead task
- * @return Response to the request for querying the progress of the read-ahead task
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Query the progress of a read-ahead task.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param taskId
+ * ID of the read-ahead task
+ * @return Response to the request for querying the progress of the
+ * read-ahead task
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
ReadAheadQueryResult queryReadAheadObjectsTask(String bucketName, String taskId) throws ObsException;
- /**
- * Set the direct reading policy for Archive objects in a bucket.
- * @param bucketName Bucket name
- * @param access Direct reading policy
- * @return
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Set the direct reading policy for Archive objects in a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @param access
+ * Direct reading policy
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
HeaderResponse setBucketDirectColdAccess(String bucketName, BucketDirectColdAccess access) throws ObsException;
- /**
- * Obtain the direct reading policy for Archive objects in a bucket.
- * @param bucketName Bucket name
- * @return
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Configure the direct reading policy for Archive objects in a bucket.
+ *
+ * @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 setBucketDirectColdAccess(SetBucketDirectColdAccessRequest request) throws ObsException;
+
+ /**
+ * Obtain the direct reading policy for Archive objects in a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Direct reading policy for Archive objects of a bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
BucketDirectColdAccess getBucketDirectColdAccess(String bucketName) throws ObsException;
- /**
- * Delete the direct reading policy for Archive objects in a bucket.
- * @param bucketName Bucket name
- * @return
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
+ /**
+ * Obtain the direct reading policy for Archive objects in a bucket.
+ *
+ * @param request
+ * Request parameters
+ * @return Direct reading policy for Archive objects in a bucket
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
+ * @since 3.20.3
+ */
+ BucketDirectColdAccess getBucketDirectColdAccess(BaseBucketRequest request) throws ObsException;
+
+ /**
+ * Delete the direct reading policy for Archive objects in a bucket.
+ *
+ * @param bucketName
+ * Bucket name
+ * @return Common response headers
+ * @throws ObsException
+ * OBS SDK self-defined exception, thrown when the interface
+ * fails to be called or access to OBS fails
+ */
HeaderResponse deleteBucketDirectColdAccess(String bucketName) throws ObsException;
+ /**
+ * Delete the direct reading policy for Archive objects in a bucket.
+ *
+ * @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 deleteBucketDirectColdAccess(BaseBucketRequest request) throws ObsException;
+
/**
* Close ObsClient and release connection resources.
- * @throws IOException ObsClient close exception
+ *
+ * @throws IOException
+ * ObsClient close exception
*/
void close() throws IOException;
}
-
diff --git a/app/src/main/java/com/obs/services/IObsCredentialsProvider.java b/app/src/main/java/com/obs/services/IObsCredentialsProvider.java
index d159bd3..90c2f1f 100644
--- a/app/src/main/java/com/obs/services/IObsCredentialsProvider.java
+++ b/app/src/main/java/com/obs/services/IObsCredentialsProvider.java
@@ -11,6 +11,7 @@
* 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;
import com.obs.services.model.ISecurityKey;
diff --git a/app/src/main/java/com/obs/services/Log4j2Configurator.java b/app/src/main/java/com/obs/services/Log4j2Configurator.java
index c9c9388..0f9fbc1 100644
--- a/app/src/main/java/com/obs/services/Log4j2Configurator.java
+++ b/app/src/main/java/com/obs/services/Log4j2Configurator.java
@@ -11,6 +11,7 @@
* 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;
import java.io.FileInputStream;
@@ -20,113 +21,133 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.logging.Logger;
/**
- * Log configuration class integrated with Log4j2
+ * Log configuration class integrated with Log4j2
*
*/
public class Log4j2Configurator {
+
+ private static volatile boolean isWatchStart = false;
+
+ private static volatile boolean log4j2Enabled = false;
+
+ private static final Logger logger = Logger.getLogger(Log4j2Configurator.class.getName());
- private static volatile boolean isWatchStart = false;
-
- private static volatile boolean log4j2Enabled = false;
-
- /**
- * Configure logs.
- * @param configPath Path to the log configuration file
- */
- public static synchronized void setLogConfig(String configPath) {
- setLogConfig(configPath, false);
- }
-
- /**
- * Configure logs.
- * @param configPath Path to the log configuration file
- * @param isWatchConfig Whether to monitor changes of the log configuration file
- */
- public static synchronized void setLogConfig(String configPath, boolean isWatchConfig) {
- setLogConfig(configPath, isWatchConfig, 60000);
- }
-
- private static Object getLogContext(String configPath) {
- Object ctx = null;
- FileInputStream configInputStream = null;
- try {
- Class> configurationSource = Class.forName("org.apache.logging.log4j.core.config.ConfigurationSource");
- Class> configurator = Class.forName("org.apache.logging.log4j.core.config.Configurator");
- Constructor> con = configurationSource.getConstructor(InputStream.class);
- Method m = configurator.getMethod("initialize", ClassLoader.class, configurationSource);
-
- configInputStream = new FileInputStream(configPath);
- ctx = m.invoke(null, null, con.newInstance(configInputStream));
- }catch (ClassNotFoundException | NoSuchMethodException | SecurityException
- | InvocationTargetException | IllegalAccessException | InstantiationException | FileNotFoundException e) {
- }finally {
- if(null != configInputStream) {
- try {
- configInputStream.close();
- } catch (IOException e) {
- }
- }
- }
- return ctx;
- }
-
- private static class LogWatcher extends Thread{
- private Object ctx;
- private long watchInterval;
- private String configPath;
- LogWatcher(String configPath, Object ctx, long watchInterval){
- this.configPath = configPath;
- this.ctx = ctx;
- this.watchInterval = watchInterval;
-
- }
- public void run() {
- try {
- Class> configuration = Class.forName("org.apache.logging.log4j.core.config.Configuration");
- final Method stop = ctx.getClass().getMethod("stop");
- final Method start = ctx.getClass().getMethod("start", configuration);
- Class> xmlConfiguration = Class.forName("org.apache.logging.log4j.core.config.xml.XmlConfiguration");
- Class> configurationSource = Class.forName("org.apache.logging.log4j.core.config.ConfigurationSource");
- Constructor> configurationSourceConstructor = configurationSource.getConstructor(InputStream.class);
- Constructor> xmlConfigurationConstructor = xmlConfiguration.getConstructor(ctx.getClass(), configurationSource);
- while(true) {
- Thread.sleep(this.watchInterval);
- stop.invoke(ctx);
- start.invoke(ctx, xmlConfigurationConstructor.newInstance(ctx, configurationSourceConstructor.newInstance(new FileInputStream(this.configPath))));
- }
- }catch (ClassNotFoundException | FileNotFoundException | NoSuchMethodException | SecurityException
- | InterruptedException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Configure logs.
- * @param configPath Path to the log configuration file
- * @param isWatchConfig Whether to monitor changes of the log configuration file
- * @param watchInterval Interval for monitoring changes of the log configuration file, in units of ms
- */
- public static synchronized void setLogConfig(String configPath, boolean isWatchConfig, long watchInterval) {
- if(log4j2Enabled) {
- return;
- }
- Object ctx = getLogContext(configPath);
- if(isWatchConfig && ctx != null && !isWatchStart) {
- try {
- isWatchStart = true;
- long _watchInterval = watchInterval > 0 ? watchInterval : 60000;
- LogWatcher wather = new LogWatcher(configPath, ctx, _watchInterval);
- wather.setDaemon(true);
- wather.start();
- } catch (Exception e) {
- }
- }
- log4j2Enabled = true;
- }
+ /**
+ * Configure logs.
+ *
+ * @param configPath
+ * Path to the log configuration file
+ */
+ public static synchronized void setLogConfig(String configPath) {
+ setLogConfig(configPath, false);
+ }
-}
+ /**
+ * Configure logs.
+ *
+ * @param configPath
+ * Path to the log configuration file
+ * @param isWatchConfig
+ * Whether to monitor changes of the log configuration file
+ */
+ public static synchronized void setLogConfig(String configPath, boolean isWatchConfig) {
+ setLogConfig(configPath, isWatchConfig, 60000);
+ }
+
+ private static Object getLogContext(String configPath) {
+ Object ctx = null;
+ FileInputStream configInputStream = null;
+ try {
+ Class> configurationSource = Class.forName("org.apache.logging.log4j.core.config.ConfigurationSource");
+ Class> configurator = Class.forName("org.apache.logging.log4j.core.config.Configurator");
+ Constructor> con = configurationSource.getConstructor(InputStream.class);
+ Method m = configurator.getMethod("initialize", ClassLoader.class, configurationSource);
+ configInputStream = new FileInputStream(configPath);
+ ctx = m.invoke(null, null, con.newInstance(configInputStream));
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InvocationTargetException
+ | IllegalAccessException | InstantiationException | FileNotFoundException e) {
+ logger.warning(e.getMessage());
+ } finally {
+ if (null != configInputStream) {
+ try {
+ configInputStream.close();
+ } catch (IOException e) {
+ logger.warning(e.getMessage());
+ }
+ }
+ }
+ return ctx;
+ }
+ private static class LogWatcher extends Thread {
+ private Object ctx;
+ private long watchInterval;
+ private String configPath;
+
+ LogWatcher(String configPath, Object ctx, long watchInterval) {
+ this.configPath = configPath;
+ this.ctx = ctx;
+ this.watchInterval = watchInterval;
+
+ }
+
+ public void run() {
+ try {
+ Class> configuration = Class.forName("org.apache.logging.log4j.core.config.Configuration");
+ final Method stop = ctx.getClass().getMethod("stop");
+ final Method start = ctx.getClass().getMethod("start", configuration);
+ Class> xmlConfiguration = Class.forName("org.apache.logging.log4j.core.config.xml.XmlConfiguration");
+ Class> configurationSource = Class
+ .forName("org.apache.logging.log4j.core.config.ConfigurationSource");
+ Constructor> configurationSourceConstructor = configurationSource.getConstructor(InputStream.class);
+ Constructor> xmlConfigurationConstructor = xmlConfiguration.getConstructor(ctx.getClass(),
+ configurationSource);
+ while (true) {
+ Thread.sleep(this.watchInterval);
+ stop.invoke(ctx);
+ start.invoke(ctx, xmlConfigurationConstructor.newInstance(ctx,
+ configurationSourceConstructor.newInstance(new FileInputStream(this.configPath))));
+ }
+ } catch (ClassNotFoundException | FileNotFoundException | NoSuchMethodException | SecurityException
+ | InterruptedException | InvocationTargetException | IllegalAccessException
+ | InstantiationException e) {
+ logger.warning(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Configure logs.
+ *
+ * @param configPath
+ * Path to the log configuration file
+ * @param isWatchConfig
+ * Whether to monitor changes of the log configuration file
+ * @param watchInterval
+ * Interval for monitoring changes of the log configuration file,
+ * in units of ms
+ */
+ public static synchronized void setLogConfig(String configPath, boolean isWatchConfig, long watchInterval) {
+ if (log4j2Enabled) {
+ return;
+ }
+ Object ctx = getLogContext(configPath);
+ if (isWatchConfig && ctx != null && !isWatchStart) {
+ try {
+ isWatchStart = true;
+ long interval = watchInterval > 0 ? watchInterval : 60000;
+ LogWatcher wather = new LogWatcher(configPath, ctx, interval);
+ wather.setDaemon(true);
+ wather.start();
+ } catch (Exception e) {
+ logger.warning(e.getMessage());
+ }
+ }
+ log4j2Enabled = true;
+ }
+
+}
diff --git a/app/src/main/java/com/obs/services/LogConfigurator.java b/app/src/main/java/com/obs/services/LogConfigurator.java
index 28c8b2d..2b3eaa4 100644
--- a/app/src/main/java/com/obs/services/LogConfigurator.java
+++ b/app/src/main/java/com/obs/services/LogConfigurator.java
@@ -11,11 +11,12 @@
* 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;
+package com.obs.services;
import java.io.File;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
@@ -31,31 +32,28 @@
import com.obs.services.internal.utils.ServiceUtils;
/**
- * Log configuration class that uses the standard JDK log library
+ * Log configuration class that uses the standard JDK log library
*
*/
public class LogConfigurator {
-
+
public static final Level OFF = Level.parse("OFF");
-
+
public static final Level TRACE = Level.parse("FINEST");
-
+
public static final Level DEBUG = Level.parse("FINE");
-
+
public static final Level INFO = Level.parse("INFO");
-
+
public static final Level WARN = Level.parse("WARNING");
-
- public static final Level ERROR = Level.parse("SEVERE");
-
- private static final Logger logger = Logger.getLogger("com.obs");
- private static final Logger accessLogger = Logger.getLogger("com.obs.log.AccessLogger");
+ public static final Level ERROR = Level.parse("SEVERE");
+ private static final Logger ILOG = Logger.getLogger(LogConfigurator.class.getName());
- static{
- LogConfigurator.disableLog();
- LogConfigurator.disableAccessLog();
+ static {
+ LogConfigurator.disableLog();
+ LogConfigurator.disableAccessLog();
}
private static Level logLevel;
@@ -65,115 +63,113 @@ public class LogConfigurator {
private static int logFileSize = 30 * 1024 * 1024; // 30MB
private static int logFileRolloverCount = 50;
-
+
private static volatile boolean logEnabled = false;
private static volatile boolean accessLogEnabled = false;
- private static String getDefaultLogFileDir(){
- try{
+ private static String getDefaultLogFileDir() {
+ try {
Class> c = Class.forName("android.os.Environment");
Method m = c.getMethod("getExternalStorageDirectory");
- if(m != null){
+ if (m != null) {
return m.invoke(c).toString() + "/logs";
}
- }catch (ClassNotFoundException | NoSuchMethodException
- | InvocationTargetException | IllegalAccessException e){
-
+ } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException
+ | IllegalAccessException e) {
+ ILOG.warning(e.getMessage());
}
return System.getProperty("user.dir") + "/logs";
}
-
- private static void logOn(final Logger pLogger, String logName)
- {
- pLogger.setUseParentHandlers(false);
- pLogger.setLevel(logLevel == null ? LogConfigurator.WARN : logLevel);
- if(logFileDir == null){
+ private synchronized static void logOn(final Logger currentLogger, String logName) {
+ currentLogger.setUseParentHandlers(false);
+ currentLogger.setLevel(logLevel == null ? LogConfigurator.WARN : logLevel);
+ if (logFileDir == null) {
logFileDir = getDefaultLogFileDir();
}
- try
- {
- File dir = new File(logFileDir);
- if(!dir.exists()){
- if(!dir.mkdirs()) {
- if(!dir.exists()) {
- logFileDir = System.getProperty("user.dir") + "/";
- }
- }
- }
- FileHandler fh = new FileHandler(logFileDir + logName, logFileSize, logFileRolloverCount,true);
- fh.setEncoding("UTF-8");
- fh.setFormatter(new Formatter()
- {
-
- @Override
- public String format(LogRecord record)
- {
- String levelName = record.getLevel().getName();
- if("SEVERE".equals(levelName)){
- levelName = "ERROR";
- }else if("FINE".equals(levelName)){
- levelName = "DEBUG";
- }else if("FINEST".equals(levelName)){
- levelName = "TRACE";
- }
- if(pLogger == accessLogger)
- {
- return Thread.currentThread().getName() + "\n" + record.getMessage() + (record.getThrown() == null ? "" : record.getThrown()) + System.getProperty("line.separator");
- }
- Date d = new Date(record.getMillis());
-
- SimpleDateFormat format = AccessLoggerUtils.getFormat();
-
- return format.format(d) + "|" + Thread.currentThread().getName() + "|" + levelName + " |" + record.getMessage() + (record.getThrown() == null ? "" : record.getThrown()) + System.getProperty("line.separator");
- }
- });
- pLogger.addHandler(fh);
- if(pLogger == accessLogger)
- {
+ try {
+ FileHandler fh = createFileHandler(currentLogger, logName);
+ currentLogger.addHandler(fh);
+ if (currentLogger == AccessLog.getLogger()) {
accessLogEnabled = true;
- }
- else if(pLogger == logger)
- {
+ } else if (currentLogger == BaseLog.getLogger()) {
logEnabled = true;
}
+ } catch (IOException e) {
+ onException(currentLogger, e);
}
- catch (IOException e)
- {
- try
- {
- Class> c = Class.forName("android.util.Log");
- try{
- Method m = c.getMethod("i", String.class, String.class, Throwable.class);
- m.invoke(null, "OBS Android SDK", "Enable SDK log failed", e);
- }catch (NoSuchMethodException | SecurityException ex) {
- Method m = c.getMethod("i", String.class, String.class);
- m.invoke(null, "OBS Android SDK", "Enable SDK log failed" + e.getMessage());
- }
+ }
+
+ private static void onException(final Logger currentLogger, IOException e) {
+ try {
+ Class> c = Class.forName("android.util.Log");
+ try {
+ Method m = c.getMethod("i", String.class, String.class, Throwable.class);
+ m.invoke(null, "OBS Android SDK", "Enable SDK log failed", e);
+ } catch (NoSuchMethodException | SecurityException ex) {
+ Method m = c.getMethod("i", String.class, String.class);
+ m.invoke(null, "OBS Android SDK", "Enable SDK log failed" + e.getMessage());
}
- catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex)
- {
+ } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException
+ | IllegalAccessException ex) {
+ ILOG.warning(e.getMessage());
+ }
+ logOff(currentLogger);
+ }
+
+ private static FileHandler createFileHandler(final Logger currentLogger, String logName)
+ throws IOException, UnsupportedEncodingException {
+ File dir = new File(logFileDir);
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ if (!dir.exists()) {
+ logFileDir = System.getProperty("user.dir") + "/";
+ }
}
- logOff(pLogger);
}
+ FileHandler fh = new FileHandler(logFileDir + logName, logFileSize, logFileRolloverCount, true);
+ fh.setEncoding("UTF-8");
+ fh.setFormatter(new Formatter() {
+
+ @Override
+ public String format(LogRecord record) {
+ String levelName = record.getLevel().getName();
+ if ("SEVERE".equals(levelName)) {
+ levelName = "ERROR";
+ } else if ("FINE".equals(levelName)) {
+ levelName = "DEBUG";
+ } else if ("FINEST".equals(levelName)) {
+ levelName = "TRACE";
+ }
+ if (currentLogger == AccessLog.getLogger()) {
+ return Thread.currentThread().getName() + "\n" + record.getMessage()
+ + (record.getThrown() == null ? "" : record.getThrown())
+ + System.getProperty("line.separator");
+ }
+ Date d = new Date(record.getMillis());
+
+ SimpleDateFormat format = AccessLoggerUtils.getFormat();
+
+ return format.format(d) + "|" + Thread.currentThread().getName() + "|" + levelName + " |"
+ + record.getMessage() + (record.getThrown() == null ? "" : record.getThrown())
+ + System.getProperty("line.separator");
+ }
+ });
+ return fh;
}
- private static void logOff(Logger pLogger)
- {
- pLogger.setLevel(LogConfigurator.OFF);
- Handler[] handlers = pLogger.getHandlers();
- if(handlers != null){
- for(Handler handler : handlers){
- pLogger.removeHandler(handler);
+ private static void logOff(Logger currentLogger) {
+ currentLogger.setLevel(LogConfigurator.OFF);
+ Handler[] handlers = currentLogger.getHandlers();
+ if (handlers != null) {
+ for (Handler handler : handlers) {
+ currentLogger.removeHandler(handler);
}
}
- if(pLogger == accessLogger)
- {
+ if (currentLogger == AccessLog.getLogger()) {
accessLogEnabled = false;
- }
- else if(pLogger == logger)
- {
+ } else if (currentLogger == BaseLog.getLogger()) {
logEnabled = false;
}
}
@@ -181,73 +177,92 @@ else if(pLogger == logger)
/**
* Enable SDK logging.
*/
- public synchronized static void enableLog(){
- if(logEnabled) {
- logOff(logger);
- }
- logOn(logger, "/OBS-SDK.log");
+ public synchronized static void enableLog() {
+ if (logEnabled) {
+ logOff(BaseLog.getLogger());
+ }
+ logOn(BaseLog.getLogger(), "/OBS-SDK.log");
}
/**
* Disable SDK logging.
*/
- protected synchronized static void disableLog(){
- logOff(logger);
+ protected synchronized static void disableLog() {
+ logOff(BaseLog.getLogger());
}
-
- public synchronized static void enableAccessLog()
- {
- if(accessLogEnabled)
- {
- logOff(accessLogger);
+ public synchronized static void enableAccessLog() {
+ if (accessLogEnabled) {
+ logOff(AccessLog.getLogger());
}
- logOn(accessLogger, "/OBS-SDK-access.log");
+ logOn(AccessLog.getLogger(), "/OBS-SDK-access.log");
}
- protected synchronized static void disableAccessLog()
- {
- logOff(accessLogger);
+ protected synchronized static void disableAccessLog() {
+ logOff(AccessLog.getLogger());
}
/**
* Set the log level.
- * @param level Log level
+ *
+ * @param level
+ * Log level
*/
- public synchronized static void setLogLevel(Level level){
- if(level != null){
+ public synchronized static void setLogLevel(Level level) {
+ if (level != null) {
logLevel = level;
}
}
/**
* Set the number of retained log files.
- * @param count Number of retained log files
+ *
+ * @param count
+ * Number of retained log files
*/
- public synchronized static void setLogFileRolloverCount(int count){
- if(count > 0){
+ public synchronized static void setLogFileRolloverCount(int count) {
+ if (count > 0) {
logFileRolloverCount = count;
}
}
/**
- * Set the log file size (in bytes).
- * @param fileSize Log file size
+ * Set the log file size (in bytes).
+ *
+ * @param fileSize
+ * Log file size
*/
- public synchronized static void setLogFileSize(int fileSize){
- if(fileSize >= 0){
+ public synchronized static void setLogFileSize(int fileSize) {
+ if (fileSize >= 0) {
logFileSize = fileSize;
}
}
/**
* Set a directory for saving log files.
- * @param dir Directory for saving log files
+ *
+ * @param dir
+ * Directory for saving log files
*/
- public synchronized static void setLogFileDir(String dir){
- if(ServiceUtils.isValid(dir)){
+ public synchronized static void setLogFileDir(String dir) {
+ if (ServiceUtils.isValid(dir)) {
logFileDir = dir;
}
}
+ private static class BaseLog {
+ private static final Logger logger = Logger.getLogger("com.obs");
+
+ public static Logger getLogger() {
+ return logger;
+ }
+ }
+
+ private static class AccessLog {
+ private static final Logger logger = Logger.getLogger("com.obs.log.AccessLogger");
+
+ public static Logger getLogger() {
+ return logger;
+ }
+ }
}
diff --git a/app/src/main/java/com/obs/services/OBSCredentialsProviderChain.java b/app/src/main/java/com/obs/services/OBSCredentialsProviderChain.java
index 2d52f32..891f5e0 100644
--- a/app/src/main/java/com/obs/services/OBSCredentialsProviderChain.java
+++ b/app/src/main/java/com/obs/services/OBSCredentialsProviderChain.java
@@ -11,15 +11,16 @@
* 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;
public class OBSCredentialsProviderChain extends DefaultCredentialsProviderChain {
- public OBSCredentialsProviderChain() {
- this(true);
- }
+ public OBSCredentialsProviderChain() {
+ this(true);
+ }
- public OBSCredentialsProviderChain(boolean reused) {
- super(reused, new EnvironmentVariableObsCredentialsProvider(), new EcsObsCredentialsProvider());
- }
+ public OBSCredentialsProviderChain(boolean reused) {
+ super(reused, new EnvironmentVariableObsCredentialsProvider(), new EcsObsCredentialsProvider());
+ }
}
diff --git a/app/src/main/java/com/obs/services/ObsClient.java b/app/src/main/java/com/obs/services/ObsClient.java
index 7c3f4b6..3a43484 100644
--- a/app/src/main/java/com/obs/services/ObsClient.java
+++ b/app/src/main/java/com/obs/services/ObsClient.java
@@ -11,126 +11,38 @@
* 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;
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ConcurrentHashMap;
-import com.obs.log.ILogger;
-import com.obs.log.InterfaceLogBean;
-import com.obs.log.LoggerBuilder;
import com.obs.services.exception.ObsException;
-import com.obs.services.internal.Constants;
-import com.obs.services.internal.Constants.CommonHeaders;
-import com.obs.services.internal.ObsConstraint;
-import com.obs.services.internal.ObsProperties;
-import com.obs.services.internal.ObsService;
-import com.obs.services.internal.ResumableClient;
import com.obs.services.internal.ServiceException;
-import com.obs.services.internal.consensus.CacheManager;
-import com.obs.services.internal.consensus.SegmentLock;
-import com.obs.services.internal.security.ProviderCredentials;
-import com.obs.services.internal.task.DefaultTaskProgressStatus;
-import com.obs.services.internal.task.DropFolderTask;
-import com.obs.services.internal.task.LazyTaksCallback;
-import com.obs.services.internal.task.PutObjectTask;
-import com.obs.services.internal.task.RestoreObjectTask;
-import com.obs.services.internal.task.ResumableUploadTask;
-import com.obs.services.internal.task.UploadTaskProgressStatus;
-import com.obs.services.internal.utils.AccessLoggerUtils;
-import com.obs.services.internal.utils.ReflectUtils;
import com.obs.services.internal.utils.ServiceUtils;
-import com.obs.services.model.*;
-import com.obs.services.model.PolicyConditionItem.ConditionOperator;
-import com.obs.services.model.RestoreObjectRequest.RestoreObjectStatus;
-import com.obs.services.model.fs.DropFileRequest;
-import com.obs.services.model.fs.DropFileResult;
-import com.obs.services.model.fs.DropFolderRequest;
-import com.obs.services.model.fs.GetAttributeRequest;
-import com.obs.services.model.fs.GetBucketFSStatusRequest;
-import com.obs.services.model.fs.GetBucketFSStatusResult;
+import com.obs.services.model.ObsBucket;
+import com.obs.services.model.PutObjectRequest;
+import com.obs.services.model.ReadAheadQueryResult;
+import com.obs.services.model.ReadAheadRequest;
+import com.obs.services.model.ReadAheadResult;
import com.obs.services.model.fs.NewBucketRequest;
import com.obs.services.model.fs.NewFileRequest;
import com.obs.services.model.fs.NewFolderRequest;
-import com.obs.services.model.fs.ObsFSAttribute;
import com.obs.services.model.fs.ObsFSBucket;
import com.obs.services.model.fs.ObsFSFile;
import com.obs.services.model.fs.ObsFSFolder;
-import com.obs.services.model.fs.ReadFileRequest;
-import com.obs.services.model.fs.ReadFileResult;
-import com.obs.services.model.fs.RenameRequest;
-import com.obs.services.model.fs.RenameResult;
-import com.obs.services.model.fs.SetBucketFSStatusRequest;
-import com.obs.services.model.fs.TruncateFileRequest;
-import com.obs.services.model.fs.TruncateFileResult;
import com.obs.services.model.fs.WriteFileRequest;
/**
* ObsClient
*/
-public class ObsClient extends ObsService implements Closeable, IObsClient, IFSClient {
-
- private static final ILogger ILOG = LoggerBuilder.getLogger(ObsClient.class);
-
- private void init(String accessKey, String secretKey, String securityToken, ObsConfiguration config) {
- InterfaceLogBean reqBean = new InterfaceLogBean("ObsClient", config.getEndPoint(), "");
- ProviderCredentials credentials = new ProviderCredentials(accessKey, secretKey, securityToken);
- ObsProperties obsProperties = ServiceUtils.changeFromObsConfiguration(config);
- credentials.setAuthType(config.getAuthType());
- this.obsProperties = obsProperties;
- this.credentials = credentials;
- this.obsProperties = obsProperties;
- this.keyManagerFactory = config.getKeyManagerFactory();
- this.trustManagerFactory = config.getTrustManagerFactory();
- if (this.isAuthTypeNegotiation()) {
- this.apiVersionCache = new CacheManager();
- this.getProviderCredentials().initThreadLocalAuthType();
- this.segmentLock = new SegmentLock();
- }
- this.initHttpClient(config.getHttpDispatcher());
- reqBean.setRespTime(new Date());
- reqBean.setResultCode(Constants.RESULTCODE_SUCCESS);
- if (ILOG.isInfoEnabled()) {
- ILOG.info(reqBean);
- }
-
- if (ILOG.isWarnEnabled()) {
- StringBuilder sb = new StringBuilder("[OBS SDK Version=");
- sb.append(Constants.OBS_SDK_VERSION);
- sb.append("];");
- sb.append("[Endpoint=");
- String ep = "";
- if (this.getHttpsOnly()) {
- ep = "https://" + this.getEndpoint() + ":" + this.getHttpsPort() + "/";
- } else {
- ep = "http://" + this.getEndpoint() + ":" + this.getHttpPort() + "/";
- }
- sb.append(ep);
- sb.append("];");
- sb.append("[Access Mode=");
- sb.append(this.isPathStyle() ? "Path" : "Virtul Hosting");
- sb.append("]");
- ILOG.warn(sb);
- }
- }
+public class ObsClient extends AbstractBatchClient {
+ private static Map fields = new ConcurrentHashMap();
+
/**
* Constructor
*
@@ -138,11 +50,11 @@ private void init(String accessKey, String secretKey, String securityToken, ObsC
* OBS endpoint
*
*/
- public ObsClient(String endPoint) {
- ObsConfiguration config = new ObsConfiguration();
- config.setEndPoint(endPoint);
- this.init("", "", null, config);
- }
+ public ObsClient(String endPoint) {
+ ObsConfiguration config = new ObsConfiguration();
+ config.setEndPoint(endPoint);
+ this.init("", "", null, config);
+ }
/**
* Constructor
@@ -151,12 +63,12 @@ public ObsClient(String endPoint) {
* Configuration parameters of ObsClient
*
*/
- public ObsClient(ObsConfiguration config) {
- if (config == null) {
- config = new ObsConfiguration();
- }
- this.init("", "", null, config);
- }
+ public ObsClient(ObsConfiguration config) {
+ if (config == null) {
+ config = new ObsConfiguration();
+ }
+ this.init("", "", null, config);
+ }
/**
* Constructor
@@ -169,11 +81,11 @@ public ObsClient(ObsConfiguration config) {
* OBS endpoint
*
*/
- public ObsClient(String accessKey, String secretKey, String endPoint) {
- ObsConfiguration config = new ObsConfiguration();
- config.setEndPoint(endPoint);
- this.init(accessKey, secretKey, null, config);
- }
+ public ObsClient(String accessKey, String secretKey, String endPoint) {
+ ObsConfiguration config = new ObsConfiguration();
+ config.setEndPoint(endPoint);
+ this.init(accessKey, secretKey, null, config);
+ }
/**
* Constructor
@@ -186,12 +98,12 @@ public ObsClient(String accessKey, String secretKey, String endPoint) {
* Configuration parameters of ObsClient
*
*/
- public ObsClient(String accessKey, String secretKey, ObsConfiguration config) {
- if (config == null) {
- config = new ObsConfiguration();
- }
- this.init(accessKey, secretKey, null, config);
- }
+ public ObsClient(String accessKey, String secretKey, ObsConfiguration config) {
+ if (config == null) {
+ config = new ObsConfiguration();
+ }
+ this.init(accessKey, secretKey, null, config);
+ }
/**
* Constructor
@@ -206,11 +118,11 @@ public ObsClient(String accessKey, String secretKey, ObsConfiguration config) {
* OBS endpoint
*
*/
- public ObsClient(String accessKey, String secretKey, String securityToken, String endPoint) {
- ObsConfiguration config = new ObsConfiguration();
- config.setEndPoint(endPoint);
- this.init(accessKey, secretKey, securityToken, config);
- }
+ public ObsClient(String accessKey, String secretKey, String securityToken, String endPoint) {
+ ObsConfiguration config = new ObsConfiguration();
+ config.setEndPoint(endPoint);
+ this.init(accessKey, secretKey, securityToken, config);
+ }
/**
* Constructor
@@ -225,2652 +137,157 @@ public ObsClient(String accessKey, String secretKey, String securityToken, Strin
* Configuration parameters of ObsClient
*
*/
- public ObsClient(String accessKey, String secretKey, String securityToken, ObsConfiguration config) {
- if (config == null) {
- config = new ObsConfiguration();
- }
- this.init(accessKey, secretKey, securityToken, config);
- }
-
- public ObsClient(IObsCredentialsProvider provider, String endPoint){
- ServiceUtils.asserParameterNotNull(provider, "ObsCredentialsProvider is null");
- ObsConfiguration config = new ObsConfiguration();
- config.setEndPoint(endPoint);
- this.init(provider.getSecurityKey().getAccessKey(), provider.getSecurityKey().getSecretKey(), provider.getSecurityKey().getSecurityToken(), config);
- this.credentials.setObsCredentialsProvider(provider);
- }
-
- public ObsClient(IObsCredentialsProvider provider, ObsConfiguration config){
- ServiceUtils.asserParameterNotNull(provider, "ObsCredentialsProvider is null");
- if (config == null) {
- config = new ObsConfiguration();
- }
- this.init(provider.getSecurityKey().getAccessKey(), provider.getSecurityKey().getSecretKey(), provider.getSecurityKey().getSecurityToken(), config);
- this.credentials.setObsCredentialsProvider(provider);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#refresh(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void refresh(String accessKey, String secretKey, String securityToken) {
- ProviderCredentials credentials = new ProviderCredentials(accessKey, secretKey, securityToken);
- credentials.setAuthType(this.credentials.getAuthType());
- this.setProviderCredentials(credentials);
- }
-
- /**
- * Create a temporarily authorized URL.
- *
- * @param method
- * HTTP request method
- * @param bucketName
- * Bucket name
- * @param objectKey
- * Object name
- * @param specialParam
- * Special operator
- * @param expiryTime
- * Time when the temporary authentication expires
- * @param headers
- * Header information
- * @param queryParams
- * Query parameter information
- * @return Temporarily authorized URL
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public String createSignedUrl(HttpMethodEnum method, String bucketName, String objectKey,
- SpecialParamEnum specialParam, Date expiryTime, Map headers,
- Map queryParams) throws ObsException {
- return this.createSignedUrl(method, bucketName, objectKey, specialParam,
- expiryTime == null ? ObsConstraint.DEFAULT_EXPIRE_SECONEDS
- : (expiryTime.getTime() - System.currentTimeMillis()) / 1000,
- headers, queryParams);
- }
-
- /**
- * Create a temporarily authorized URL.
- *
- * @param method
- * HTTP request method
- * @param bucketName
- * Bucket name
- * @param objectKey
- * Object name
- * @param specialParam
- * Special operator
- * @param expires
- * Time when the temporary authentication expires. The unit is second and the default value is 300.
- * @param headers
- * Header information
- * @param queryParams
- * Query parameter information
- * @return Temporarily authorized URL
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public String createSignedUrl(HttpMethodEnum method, String bucketName, String objectKey,
- SpecialParamEnum specialParam, long expires, Map headers, Map queryParams) {
- TemporarySignatureRequest request = new TemporarySignatureRequest();
- request.setMethod(method);
- request.setBucketName(bucketName);
- request.setObjectKey(objectKey);
- request.setSpecialParam(specialParam);
- request.setHeaders(headers);
- request.setQueryParams(queryParams);
- if(expires > 0) {
- request.setExpires(expires);
- }
- return createTemporarySignature(request).getSignedUrl();
- }
-
- @Deprecated
- public V4TemporarySignatureResponse createV4TemporarySignature(V4TemporarySignatureRequest request) {
- ServiceUtils.asserParameterNotNull(request, "V4TemporarySignatureRequest is null");
- InterfaceLogBean reqBean = new InterfaceLogBean("createV4TemporarySignature", this.getEndpoint(), "");
- try {
- TemporarySignatureResponse response = this.createV4TemporarySignature((TemporarySignatureRequest)request);
- V4TemporarySignatureResponse res = new V4TemporarySignatureResponse(response.getSignedUrl());
- res.getActualSignedRequestHeaders().putAll(response.getActualSignedRequestHeaders());
- return res;
- } catch (Exception e) {
- reqBean.setRespTime(new Date());
- if (ILOG.isErrorEnabled()) {
- ILOG.error(reqBean);
- }
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- @Deprecated
- public V4PostSignatureResponse createV4PostSignature(String acl, String contentType, long expires,
- String bucketName, String objectKey) throws ObsException {
- V4PostSignatureRequest request = new V4PostSignatureRequest(expires, new Date(), bucketName, objectKey);
- request.getFormParams().put("acl", acl);
- request.getFormParams().put("content-type", contentType);
- return this.createV4PostSignature(request);
- }
-
- @Deprecated
- public V4PostSignatureResponse createV4PostSignature(long expires, String bucketName, String objectKey)
- throws ObsException {
- V4PostSignatureRequest request = new V4PostSignatureRequest(expires, new Date(), bucketName, objectKey);
- return this.createV4PostSignature(request);
- }
-
- @Deprecated
- public V4PostSignatureResponse createV4PostSignature(V4PostSignatureRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "V4PostSignatureRequest is null");
- InterfaceLogBean reqBean = new InterfaceLogBean("createV4PostSignature", this.getEndpoint(), "");
- try {
- V4PostSignatureResponse response = (V4PostSignatureResponse)this._createPostSignature(request, true);
- reqBean.setRespTime(new Date());
- reqBean.setResultCode(Constants.RESULTCODE_SUCCESS);
- if (ILOG.isInfoEnabled()) {
- ILOG.info(reqBean);
- }
- return response;
- } catch (Exception e) {
- reqBean.setRespTime(new Date());
- if (ILOG.isErrorEnabled()) {
- ILOG.error(reqBean);
- }
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createTemporarySignature(com.obs.services.model.TemporarySignatureRequest)
- */
- @Override
- public TemporarySignatureResponse createTemporarySignature(TemporarySignatureRequest request) {
- ServiceUtils.asserParameterNotNull(request, "TemporarySignatureRequest is null");
- InterfaceLogBean reqBean = new InterfaceLogBean("createTemporarySignature", this.getEndpoint(), "");
- try {
- TemporarySignatureResponse response = this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4
- ? this.createV4TemporarySignature(request)
- : this._createTemporarySignature(request);
- return response;
- } catch (Exception e) {
- reqBean.setRespTime(new Date());
- if (ILOG.isErrorEnabled()) {
- ILOG.error(reqBean);
- }
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- /**
- * Generate temporary authorization parameters for GET requests based on the object name prefix and validity period.
- * @param bucketName Bucket name
- * @param objectKey Object name
- * @param prefix Object name prefix
- * @param expiryDate Expiration date (ISO 8601 UTC)
- * @param headers Header information
- * @param queryParams Query parameter information
- * @return Response to the request for temporary access authorization
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- public TemporarySignatureResponse createGetTemporarySignature(String bucketName, String objectKey, String prefix,
- Date expiryDate, Map headers, Map queryParams) {
- try {
- PolicyTempSignatureRequest request = createPolicyGetRequest(bucketName, objectKey, prefix, headers, queryParams);
- request.setExpiryDate(expiryDate);
- TemporarySignatureResponse response = this._createTemporarySignature(request);
- return response;
- } catch (Exception e) {
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- /**
- * Generate temporary authorization parameters for GET requests based on the object name prefix and validity period.
- * @param bucketName Bucket name
- * @param objectKey Object name
- * @param prefix Object name prefix
- * @param expires Validity period (seconds)
- * @param headers Header information
- * @param queryParams Query parameter information
- * @return Response to the request for temporary access authorization
- * @throws ObsException OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- public TemporarySignatureResponse createGetTemporarySignature(String bucketName, String objectKey, String prefix,
- long expires, Map headers, Map queryParams) {
- try {
- PolicyTempSignatureRequest request = createPolicyGetRequest(bucketName, objectKey, prefix, headers, queryParams);
- request.setExpires(expires);
- TemporarySignatureResponse response = this._createTemporarySignature(request);
- return response;
- } catch (Exception e) {
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- private PolicyTempSignatureRequest createPolicyGetRequest(String bucketName, String objectKey, String prefix,
- Map headers, Map queryParams) {
- PolicyTempSignatureRequest request = new PolicyTempSignatureRequest(HttpMethodEnum.GET, bucketName, objectKey);
- List conditions = new ArrayList();
- PolicyConditionItem keyCondition = new PolicyConditionItem(ConditionOperator.STARTS_WITH, "key", prefix);
- String _bucket = this.isCname() ? this.getEndpoint() : bucketName;
- PolicyConditionItem bucketCondition = new PolicyConditionItem(ConditionOperator.EQUAL, "bucket", _bucket);
- conditions.add(keyCondition);
- conditions.add(bucketCondition);
- request.setConditions(conditions);
- request.setHeaders(headers);
- request.setQueryParams(queryParams);
- return request;
+ public ObsClient(String accessKey, String secretKey, String securityToken, ObsConfiguration config) {
+ if (config == null) {
+ config = new ObsConfiguration();
+ }
+ this.init(accessKey, secretKey, securityToken, config);
}
- /**
- * Generate parameters for browser-based authorized access.
- *
- * @param acl
- * Object ACL
- * @param contentType
- * MIME type of the object
- * @param expires
- * Validity period (in seconds)
- * @param bucketName
- * Bucket name
- * @param objectKey
- * Object name
- * @return Response to the V4 browser-based authorized access
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- public PostSignatureResponse createPostSignature(String acl, String contentType, long expires, String bucketName,
- String objectKey) throws ObsException {
- PostSignatureRequest request = new PostSignatureRequest(expires, new Date(), bucketName, objectKey);
- request.getFormParams().put(
- this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4 ? "acl" : this.getIHeaders().aclHeader(),
- acl);
- request.getFormParams().put(CommonHeaders.CONTENT_TYPE, contentType);
- return this.createPostSignature(request);
- }
-
- /**
- * Generate parameters for browser-based authorized access.
- *
- * @param expires
- * Validity period (in seconds)
- * @param bucketName
- * Bucket name
- * @param objectKey
- * Object name
- * @return Response to the V4 browser-based authorized access
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- public PostSignatureResponse createPostSignature(long expires, String bucketName, String objectKey)
- throws ObsException {
- PostSignatureRequest request = new PostSignatureRequest(expires, new Date(), bucketName, objectKey);
- return this.createPostSignature(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createPostSignature(com.obs.services.model.PostSignatureRequest)
- */
- @Override
- public PostSignatureResponse createPostSignature(PostSignatureRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "PostSignatureRequest is null");
- InterfaceLogBean reqBean = new InterfaceLogBean("createPostSignature", this.getEndpoint(), "");
- try {
- PostSignatureResponse response = this._createPostSignature(request, this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4);
- reqBean.setRespTime(new Date());
- reqBean.setResultCode(Constants.RESULTCODE_SUCCESS);
- if (ILOG.isInfoEnabled()) {
- ILOG.info(reqBean);
- }
- return response;
- } catch (Exception e) {
- reqBean.setRespTime(new Date());
- if (ILOG.isErrorEnabled()) {
- ILOG.error(reqBean);
- }
- throw new ObsException(e.getMessage(), e);
- }
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createBucket(java.lang.String)
- */
- @Override
- public ObsBucket createBucket(String bucketName) throws ObsException {
- ObsBucket obsBucket = new ObsBucket();
- obsBucket.setBucketName(bucketName);
- return this.createBucket(obsBucket);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createBucket(java.lang.String, java.lang.String)
- */
- @Override
- public ObsBucket createBucket(String bucketName, String location) throws ObsException {
- ObsBucket obsBucket = new ObsBucket();
- obsBucket.setBucketName(bucketName);
- obsBucket.setLocation(location);
- return this.createBucket(obsBucket);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createBucket(com.obs.services.model.ObsBucket)
- */
- @Override
- public ObsBucket createBucket(final ObsBucket bucket) throws ObsException {
- CreateBucketRequest request = new CreateBucketRequest();
- request.setBucketName(bucket.getBucketName());
- request.setAcl(bucket.getAcl());
- request.setBucketStorageClass(bucket.getBucketStorageClass());
- request.setLocation(bucket.getLocation());
- return this.createBucket(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#createBucket(com.obs.services.model.CreateBucketRequest)
- */
- @Override
- public ObsBucket createBucket(final CreateBucketRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "CreateBucketRequest is null");
- return this.doActionWithResult("createBucket", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public ObsBucket action() throws ServiceException {
- if (isCname()) {
- throw new ServiceException("createBucket is not allowed in customdomain mode");
- }
- try {
- return ObsClient.this.createBucketImpl(request);
- } catch (ServiceException e) {
- if(ObsClient.this.isAuthTypeNegotiation() && e.getResponseCode() == 400 &&
- "Unsupported Authorization Type".equals(e.getErrorMessage()) &&
- ObsClient.this.getProviderCredentials().getAuthType() == AuthTypeEnum.OBS) {
- ObsClient.this.getProviderCredentials().setThreadLocalAuthType(AuthTypeEnum.V2);
- return ObsClient.this.createBucketImpl(request);
- } else {
- throw e;
- }
- }
- }
-
- @Override
- void authTypeNegotiate(String bucketName) throws ServiceException {
- AuthTypeEnum authTypeEnum = ObsClient.this.getApiVersionCache().getApiVersionInCache(bucketName);
- if (authTypeEnum == null) {
- authTypeEnum = ObsClient.this.getApiVersion("");
- }
- ObsClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
- }
- });
- }
-
- @Deprecated
- public ObsBucket createBucket(final S3Bucket bucket) throws ObsException {
- ServiceUtils.asserParameterNotNull(bucket, "bucket is null");
- ObsBucket obsBucket = new ObsBucket();
- obsBucket.setBucketName(bucket.getBucketName());
- obsBucket.setLocation(bucket.getLocation());
- obsBucket.setAcl(bucket.getAcl());
- obsBucket.setMetadata(bucket.getMetadata());
- obsBucket.setBucketStorageClass(bucket.getBucketStorageClass());
- return this.createBucket(obsBucket);
- }
-
- @Deprecated
- public List listBuckets() throws ObsException {
- List ret = this.listBuckets(null);
- List buckets = new ArrayList(ret.size());
- buckets.addAll(ret);
- return buckets;
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listBuckets(com.obs.services.model.ListBucketsRequest)
- */
- @Override
- public List listBuckets(final ListBucketsRequest request) throws ObsException {
- return this.listBucketsV2(request).getBuckets();
- }
-
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listBucketsV2(com.obs.services.model.ListBucketsRequest)
- */
- @Override
- public ListBucketsResult listBucketsV2(final ListBucketsRequest request) throws ObsException {
- return this.doActionWithResult("listBuckets", "All Buckets", new ActionCallbackWithResult() {
- @Override
- public ListBucketsResult action() throws ServiceException {
- if (isCname()) {
- throw new ServiceException("listBuckets is not allowed in customdomain mode");
- }
- return ObsClient.this.listAllBucketsImpl(request);
- }
-
- @Override
- void authTypeNegotiate(String bucketName) throws ServiceException {
- AuthTypeEnum authTypeEnum = ObsClient.this.getApiVersion("");
- ObsClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
- }
- });
- }
-
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucket(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucket(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucket", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listObjects(com.obs.services.model.ListObjectsRequest)
- */
- @Override
- public ObjectListing listObjects(final ListObjectsRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "ListObjectsRequest is null");
- return this.doActionWithResult("listObjects", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public ObjectListing action() throws ServiceException {
- return ObsClient.this.listObjectsImpl(request);
- }
-
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listObjects(java.lang.String)
- */
- @Override
- public ObjectListing listObjects(String bucketName) throws ObsException {
- ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
- return this.listObjects(listObjectsRequest);
- }
+ public ObsClient(IObsCredentialsProvider provider, String endPoint) {
+ ServiceUtils.assertParameterNotNull(provider, "ObsCredentialsProvider is null");
+ ObsConfiguration config = new ObsConfiguration();
+ config.setEndPoint(endPoint);
+ this.init(provider.getSecurityKey().getAccessKey(), provider.getSecurityKey().getSecretKey(),
+ provider.getSecurityKey().getSecurityToken(), config);
+ this.credentials.setObsCredentialsProvider(provider);
+ }
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#headBucket(java.lang.String)
- */
- @Override
- public boolean headBucket(final String bucketName) throws ObsException {
- return this.doActionWithResult("headBucket", bucketName, new ActionCallbackWithResult() {
+ public ObsClient(IObsCredentialsProvider provider, ObsConfiguration config) {
+ ServiceUtils.assertParameterNotNull(provider, "ObsCredentialsProvider is null");
+ if (config == null) {
+ config = new ObsConfiguration();
+ }
+ this.init(provider.getSecurityKey().getAccessKey(), provider.getSecurityKey().getSecretKey(),
+ provider.getSecurityKey().getSecurityToken(), config);
+ this.credentials.setObsCredentialsProvider(provider);
+ }
- @Override
- public Boolean action() throws ServiceException {
- return ObsClient.this.headBucketImpl(bucketName);
- }
+ @Override
+ public ReadAheadResult readAheadObjects(final ReadAheadRequest request) throws ObsException {
+ ServiceUtils.assertParameterNotNull(request, "request is null");
+ return this.doActionWithResult("readAheadObjects", request.getBucketName(),
+ new ActionCallbackWithResult() {
+ @Override
+ public ReadAheadResult action() throws ServiceException {
+ return ObsClient.this.readAheadObjectsImpl(request);
- @Override
- void authTypeNegotiate(String bucketName) throws ServiceException {
- try {
- AuthTypeEnum authTypeEnum = ObsClient.this.getApiVersion(bucketName);
- ObsClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
- } catch (ServiceException e) {
- if (e.getResponseCode() != 404) {
- throw e;
}
- }
- }
- });
- }
-
- /**
- * List versioning objects in a bucket.
- *
- * @param bucketName
- * Bucket name
- * @param prefix
- * Object name prefix used for listing versioning objects
- * @param delimiter
- * Character for grouping object names
- * @param keyMarker
- * Start position for listing versioning objects (sorted by object name)
- * @param versionIdMarker
- * Start position for listing versioning objects (sorted by version ID)
- * @param maxKeys
- * Maximum number of versioning objects to be listed
- * @param nextVersionIdMarker
- * Deprecated field
- * @return Response to the request for listing versioning objects in the bucket
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public ListVersionsResult listVersions(final String bucketName, final String prefix, final String delimiter,
- final String keyMarker, final String versionIdMarker, final long maxKeys, final String nextVersionIdMarker)
- throws ObsException {
- ListVersionsRequest request = new ListVersionsRequest();
- request.setBucketName(bucketName);
- request.setPrefix(prefix);
- request.setKeyMarker(keyMarker);
- request.setMaxKeys((int) maxKeys);
- request.setVersionIdMarker(versionIdMarker);
- request.setDelimiter(delimiter);
- return this.listVersions(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listVersions(com.obs.services.model.ListVersionsRequest)
- */
- @Override
- public ListVersionsResult listVersions(final ListVersionsRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "ListVersionsRequest is null");
- return this.doActionWithResult("listVersions", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public ListVersionsResult action() throws ServiceException {
- return ObsClient.this.listVersionsImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listVersions(java.lang.String)
- */
- @Override
- public ListVersionsResult listVersions(final String bucketName) throws ObsException {
- ListVersionsRequest request = new ListVersionsRequest();
- request.setBucketName(bucketName);
- return this.listVersions(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listVersions(java.lang.String, long)
- */
- @Override
- public ListVersionsResult listVersions(final String bucketName, final long maxKeys) throws ObsException {
- ListVersionsRequest request = new ListVersionsRequest();
- request.setBucketName(bucketName);
- request.setMaxKeys((int) maxKeys);
- return this.listVersions(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#listVersions(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long)
- */
- @Override
- public ListVersionsResult listVersions(final String bucketName, final String prefix, final String delimiter,
- final String keyMarker, final String versionIdMarker, final long maxKeys) throws ObsException {
- return this.listVersions(bucketName, prefix, delimiter, keyMarker, versionIdMarker, maxKeys, null);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketMetadata(com.obs.services.model.BucketMetadataInfoRequest)
- */
- @Override
- public BucketMetadataInfoResult getBucketMetadata(final BucketMetadataInfoRequest request)
- throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "BucketMetadataInfoRequest is null");
- return this.doActionWithResult("getBucketMetadata", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public BucketMetadataInfoResult action() throws ServiceException {
- return ObsClient.this.getBucketMetadataImpl(request);
- }
- });
- }
-
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketAcl(java.lang.String)
- */
- @Override
- public AccessControlList getBucketAcl(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketAcl", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public AccessControlList action() throws ServiceException {
- return ObsClient.this.getBucketAclImpl(bucketName);
- }
-
- });
- }
-
- /**
- * Set a bucket ACL.
- *
- * @param bucketName
- * Bucket name
- * @param cannedACL
- * Pre-defined access control policy
- * @param acl
- * ACL ("acl" and "cannedACL" cannot be used together.)
- * @return Common response headers
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public HeaderResponse setBucketAcl(final String bucketName, final String cannedACL, final AccessControlList acl)
- throws ObsException {
- return this.doActionWithResult("setBucketAcl", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- if (acl == null && null == cannedACL) {
- throw new IllegalArgumentException("Both CannedACL and AccessControlList is null");
- }
- return ObsClient.this.setBucketAclImpl(bucketName, cannedACL, acl);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketAcl(java.lang.String, com.obs.services.model.AccessControlList)
- */
- @Override
- public HeaderResponse setBucketAcl(final String bucketName, final AccessControlList acl) throws ObsException {
- return this.setBucketAcl(bucketName, null, acl);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketLocation(java.lang.String)
- */
- @Override
- public String getBucketLocation(final String bucketName) throws ObsException {
- return this.getBucketLocationV2(bucketName).getLocation();
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketLocationV2(java.lang.String)
- */
- @Override
- public BucketLocationResponse getBucketLocationV2(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketLocation", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public BucketLocationResponse action() throws ServiceException {
- return ObsClient.this.getBucketLocationImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketStorageInfo(java.lang.String)
- */
- @Override
- public BucketStorageInfo getBucketStorageInfo(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketStorageInfo", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public BucketStorageInfo action() throws ServiceException {
- return ObsClient.this.getBucketStorageInfoImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketQuota(java.lang.String)
- */
- @Override
- public BucketQuota getBucketQuota(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketQuota", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public BucketQuota action() throws ServiceException {
- return ObsClient.this.getBucketQuotaImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketQuota(java.lang.String, com.obs.services.model.BucketQuota)
- */
- @Override
- public HeaderResponse setBucketQuota(final String bucketName, final BucketQuota bucketQuota) throws ObsException {
- return this.doActionWithResult("setBucketQuota", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(bucketQuota,
- "The bucket '" + bucketName + "' does not include Quota information");
- return ObsClient.this.setBucketQuotaImpl(bucketName, bucketQuota);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketStoragePolicy(java.lang.String)
- */
- @Override
- public BucketStoragePolicyConfiguration getBucketStoragePolicy(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketStoragePolicy", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public BucketStoragePolicyConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketStoragePolicyImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketStoragePolicy(java.lang.String, com.obs.services.model.BucketStoragePolicyConfiguration)
- */
- @Override
- public HeaderResponse setBucketStoragePolicy(final String bucketName,
- final BucketStoragePolicyConfiguration bucketStorage) throws ObsException {
- return this.doActionWithResult("setBucketStoragePolicy", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(bucketStorage,
- "The bucket '" + bucketName + "' does not include storagePolicy information");
- return ObsClient.this.setBucketStorageImpl(bucketName, bucketStorage);
- }
- });
- }
-
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketCors(java.lang.String, com.obs.services.model.BucketCors)
- */
- @Override
- public HeaderResponse setBucketCors(final String bucketName, final BucketCors bucketCors) throws ObsException {
- return this.doActionWithResult("setBucketCors", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(bucketCors, "BucketCors is null");
- return ObsClient.this.setBucketCorsImpl(bucketName, bucketCors);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse setBucketCors(final String bucketName, final S3BucketCors s3BucketCors) throws ObsException {
- ServiceUtils.asserParameterNotNull(s3BucketCors,
- "The bucket '" + bucketName + "' does not include Cors information");
- BucketCors bucketCors = new BucketCors();
- bucketCors.setRules(s3BucketCors.getRules());
- return this.setBucketCors(bucketName, bucketCors);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketCors(java.lang.String)
- */
- @Override
- public BucketCors getBucketCors(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketCors", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public BucketCors action() throws ServiceException {
- return ObsClient.this.getBucketCorsImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketCors(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketCors(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketCors", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketCorsImpl(bucketName);
- }
- });
- }
-
- /**
- * Pre-request a bucket.
- *
- * @param bucketName
- * Bucket name
- * @param optionInfo
- * Parameters in a bucket preflight request
- * @return Response to the bucket preflight request
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public OptionsInfoResult optionsBucket(final String bucketName, final OptionsInfoRequest optionInfo)
- throws ObsException {
- return this.doActionWithResult("optionsBucket", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public OptionsInfoResult action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(optionInfo, "OptionsInfoRequest is null");
- return ObsClient.this.optionsImpl(bucketName, null, optionInfo);
- }
- });
- }
-
- /**
- * Perform a preflight on a bucket.
- *
- * @param bucketName
- * Bucket name
- * @param objectKey
- * Object name
- * @param optionInfo
- * Parameters in an object preflight request
- * @return Response to the object preflight request
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public OptionsInfoResult optionsObject(final String bucketName, final String objectKey,
- final OptionsInfoRequest optionInfo) throws ObsException {
- return this.doActionWithResult("optionsObject", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public OptionsInfoResult action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(optionInfo, "OptionsInfoRequest is null");
- return ObsClient.this.optionsImpl(bucketName, objectKey, optionInfo);
- }
- });
- }
-
- /**
- * Obtain the logging settings of a bucket.
- *
- * @param bucketName
- * Bucket name
- * @return Logging settings of the bucket
- * @throws ObsException
- * OBS SDK self-defined exception, thrown when the interface fails to be called or access to OBS fails
- */
- @Deprecated
- public BucketLoggingConfiguration getBucketLoggingConfiguration(final String bucketName) throws ObsException {
- return this.getBucketLogging(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketLogging(java.lang.String)
- */
- @Override
- public BucketLoggingConfiguration getBucketLogging(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketLoggingConfiguration", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public BucketLoggingConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketLoggingConfigurationImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketLoggingConfiguration(java.lang.String, com.obs.services.model.BucketLoggingConfiguration, boolean)
- */
- @Override
- public HeaderResponse setBucketLoggingConfiguration(final String bucketName,
- final BucketLoggingConfiguration loggingConfiguration, final boolean updateTargetACLifRequired)
- throws ObsException {
- return this.doActionWithResult("setBucketLoggingConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.setBucketLoggingConfigurationImpl(bucketName,
- loggingConfiguration == null ? new BucketLoggingConfiguration() : loggingConfiguration,
- updateTargetACLifRequired);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse setBucketLoggingConfiguration(final String bucketName,
- final BucketLoggingConfiguration loggingConfiguration) throws ObsException {
- return this.setBucketLogging(bucketName, loggingConfiguration);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketLogging(java.lang.String, com.obs.services.model.BucketLoggingConfiguration)
- */
- @Override
- public HeaderResponse setBucketLogging(final String bucketName,
- final BucketLoggingConfiguration loggingConfiguration) throws ObsException {
- return this.setBucketLoggingConfiguration(bucketName, loggingConfiguration, false);
- }
-
- @Deprecated
- public HeaderResponse setBucketVersioning(String bucketName, String status) throws ObsException {
- return this.setBucketVersioning(bucketName, new BucketVersioningConfiguration(status));
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketVersioning(java.lang.String, com.obs.services.model.BucketVersioningConfiguration)
- */
- @Override
- public HeaderResponse setBucketVersioning(final String bucketName,
- final BucketVersioningConfiguration versioningConfiguration) throws ObsException {
- return this.doActionWithResult("setBucketVersioning", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(versioningConfiguration, "BucketVersioningConfiguration is null");
- return ObsClient.this.setBucketVersioningImpl(bucketName,
- versioningConfiguration.getVersioningStatus());
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketVersioning(java.lang.String)
- */
- @Override
- public BucketVersioningConfiguration getBucketVersioning(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketVersioning", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public BucketVersioningConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketVersioningImpl(bucketName);
- }
- });
- }
-
- @Deprecated
- public LifecycleConfiguration getBucketLifecycleConfiguration(final String bucketName) throws ObsException {
- return this.getBucketLifecycle(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketLifecycle(java.lang.String)
- */
- @Override
- public LifecycleConfiguration getBucketLifecycle(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketLifecycleConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public LifecycleConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketLifecycleConfigurationImpl(bucketName);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse setBucketLifecycleConfiguration(final String bucketName,
- final LifecycleConfiguration lifecycleConfig) throws ObsException {
- return this.setBucketLifecycle(bucketName, lifecycleConfig);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketLifecycle(java.lang.String, com.obs.services.model.LifecycleConfiguration)
- */
- @Override
- public HeaderResponse setBucketLifecycle(final String bucketName,
- final LifecycleConfiguration lifecycleConfig) throws ObsException {
- return this.doActionWithResult("setBucketLifecycleConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(lifecycleConfig, "LifecycleConfiguration is null");
- return ObsClient.this.setBucketLifecycleConfigurationImpl(bucketName, lifecycleConfig);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse deleteBucketLifecycleConfiguration(final String bucketName) throws ObsException {
- return this.deleteBucketLifecycle(bucketName);
-
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketLifecycle(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketLifecycle(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketLifecycleConfiguration", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketLifecycleConfigurationImpl(bucketName);
- }
- });
-
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketPolicy(java.lang.String)
- */
- @Override
- public String getBucketPolicy(final String bucketName) throws ObsException {
- return this.getBucketPolicyV2(bucketName).getPolicy();
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketPolicyV2(java.lang.String)
- */
- @Override
- public BucketPolicyResponse getBucketPolicyV2(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketPolicy", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public BucketPolicyResponse action() throws ServiceException {
- return ObsClient.this.getBucketPolicyImpl(bucketName);
- }
-
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketPolicy(java.lang.String, java.lang.String)
- */
- @Override
- public HeaderResponse setBucketPolicy(final String bucketName, final String policy) throws ObsException {
- return this.doActionWithResult("setBucketPolicy", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(policy, "policy is null");
- return ObsClient.this.setBucketPolicyImpl(bucketName, policy);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketPolicy(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketPolicy(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketPolicy", bucketName,
- new ActionCallbackWithResult() {
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketPolicyImpl(bucketName);
- }
- });
- }
-
- @Deprecated
- public WebsiteConfiguration getBucketWebsiteConfiguration(final String bucketName) throws ObsException {
- return this.getBucketWebsite(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketWebsite(java.lang.String)
- */
- @Override
- public WebsiteConfiguration getBucketWebsite(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketWebsiteConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public WebsiteConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketWebsiteConfigurationImpl(bucketName);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse setBucketWebsiteConfiguration(final String bucketName,
- final WebsiteConfiguration websiteConfig) throws ObsException {
- return this.setBucketWebsite(bucketName, websiteConfig);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketWebsite(java.lang.String, com.obs.services.model.WebsiteConfiguration)
- */
- @Override
- public HeaderResponse setBucketWebsite(final String bucketName,
- final WebsiteConfiguration websiteConfig) throws ObsException {
- return this.doActionWithResult("setBucketWebsiteConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(websiteConfig, "WebsiteConfiguration is null");
- return ObsClient.this.setBucketWebsiteConfigurationImpl(bucketName, websiteConfig);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse deleteBucketWebsiteConfiguration(final String bucketName) throws ObsException {
- return this.deleteBucketWebsite(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketWebsite(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketWebsite(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketWebsiteConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketWebsiteConfigurationImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketTagging(java.lang.String)
- */
- @Override
- public BucketTagInfo getBucketTagging(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketTagging", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public BucketTagInfo action() throws ServiceException {
- return ObsClient.this.getBucketTaggingImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketTagging(java.lang.String, com.obs.services.model.BucketTagInfo)
- */
- @Override
- public HeaderResponse setBucketTagging(final String bucketName, final BucketTagInfo bucketTagInfo)
- throws ObsException {
- return this.doActionWithResult("setBucketTagging", bucketName, new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(bucketTagInfo, "BucketTagInfo is null");
- return ObsClient.this.setBucketTaggingImpl(bucketName, bucketTagInfo);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketTagging(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketTagging(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketTagging", bucketName,
- new ActionCallbackWithResult() {
+ });
+ }
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketTaggingImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketEncryption(java.lang.String)
- */
@Override
- public BucketEncryption getBucketEncryption(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketEncryption", bucketName, new ActionCallbackWithResult() {
+ public ReadAheadResult deleteReadAheadObjects(final String bucketName, final String prefix) throws ObsException {
+ ServiceUtils.assertParameterNotNull(bucketName, "bucketName is null");
+ ServiceUtils.assertParameterNotNull(prefix, "prefix is null");
+ return this.doActionWithResult("deleteReadAheadObjects", bucketName,
+ new ActionCallbackWithResult() {
+ @Override
+ public ReadAheadResult action() throws ServiceException {
+ return ObsClient.this.deleteReadAheadObjectsImpl(bucketName, prefix);
- @Override
- BucketEncryption action() throws ServiceException {
- return ObsClient.this.getBucketEncryptionImpl(bucketName);
- }
- });
+ }
+ });
}
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketEncryption(java.lang.String, com.obs.services.model.BucketEncryption)
- */
@Override
- public HeaderResponse setBucketEncryption(final String bucketName, final BucketEncryption bucketEncryption)
+ public ReadAheadQueryResult queryReadAheadObjectsTask(final String bucketName, final String taskId)
throws ObsException {
- return this.doActionWithResult("setBucketEncryption", bucketName, new ActionCallbackWithResult() {
+ ServiceUtils.assertParameterNotNull(bucketName, "bucketName is null");
+ ServiceUtils.assertParameterNotNull(taskId, "taskId is null");
+ return this.doActionWithResult("queryReadAheadObjectsTask", bucketName,
+ new ActionCallbackWithResult() {
+ @Override
+ public ReadAheadQueryResult action() throws ServiceException {
+ return ObsClient.this.queryReadAheadObjectsTaskImpl(bucketName, taskId);
- @Override
- HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(bucketEncryption, "BucketEncryption is null");
- return ObsClient.this.setBucketEncryptionImpl(bucketName, bucketEncryption);
- }
- });
+ }
+ });
}
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketEncryption(java.lang.String)
- */
@Override
- public HeaderResponse deleteBucketEncryption(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketEncryption", bucketName, new ActionCallbackWithResult() {
- @Override
- HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketEncryptionImpl(bucketName);
- }
- });
+ public ObsFSBucket newBucket(NewBucketRequest request) throws ObsException {
+ ObsBucket bucket = this.createBucket(request);
+ ObsFSBucket fsBucket = new ObsFSBucket(bucket.getBucketName(), bucket.getLocation());
+ setInnerClient(fsBucket, this);
+ return fsBucket;
}
- @Deprecated
- public HeaderResponse setBucketReplicationConfiguration(final String bucketName,
- final ReplicationConfiguration replicationConfiguration) throws ObsException {
- return this.setBucketReplication(bucketName, replicationConfiguration);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketReplication(java.lang.String, com.obs.services.model.ReplicationConfiguration)
- */
- @Override
- public HeaderResponse setBucketReplication(final String bucketName,
- final ReplicationConfiguration replicationConfiguration) throws ObsException {
- return this.doActionWithResult("setBucketReplication", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- ServiceUtils.asserParameterNotNull(replicationConfiguration, "ReplicationConfiguration is null");
- return ObsClient.this.setBucketReplicationConfigurationImpl(bucketName,
- replicationConfiguration);
- }
- });
- }
-
- @Deprecated
- public ReplicationConfiguration getBucketReplicationConfiguration(final String bucketName) throws ObsException {
- return this.getBucketReplication(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketReplication(java.lang.String)
- */
- @Override
- public ReplicationConfiguration getBucketReplication(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketReplicationConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public ReplicationConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketReplicationConfigurationImpl(bucketName);
- }
- });
- }
-
- @Deprecated
- public HeaderResponse deleteBucketReplicationConfiguration(final String bucketName) throws ObsException {
- return this.deleteBucketReplication(bucketName);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#deleteBucketReplication(java.lang.String)
- */
- @Override
- public HeaderResponse deleteBucketReplication(final String bucketName) throws ObsException {
- return this.doActionWithResult("deleteBucketReplicationConfiguration", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.deleteBucketReplicationConfigurationImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getBucketNotification(java.lang.String)
- */
- @Override
- public BucketNotificationConfiguration getBucketNotification(final String bucketName) throws ObsException {
- return this.doActionWithResult("getBucketNotification", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public BucketNotificationConfiguration action() throws ServiceException {
- return ObsClient.this.getBucketNotificationConfigurationImpl(bucketName);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setBucketNotification(java.lang.String, com.obs.services.model.BucketNotificationConfiguration)
- */
- @Override
- public HeaderResponse setBucketNotification(final String bucketName,
- final BucketNotificationConfiguration bucketNotificationConfiguration) throws ObsException {
- return this.doActionWithResult("setBucketNotification", bucketName,
- new ActionCallbackWithResult() {
-
- @Override
- public HeaderResponse action() throws ServiceException {
- return ObsClient.this.setBucketNotificationImpl(bucketName,
- bucketNotificationConfiguration == null ? new BucketNotificationConfiguration()
- : bucketNotificationConfiguration);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#putObject(java.lang.String, java.lang.String, java.io.InputStream, com.obs.services.model.ObjectMetadata)
- */
- @Override
- public PutObjectResult putObject(String bucketName, String objectKey, InputStream input, ObjectMetadata metadata)
- throws ObsException {
- PutObjectRequest request = new PutObjectRequest();
- request.setBucketName(bucketName);
- request.setInput(input);
- request.setMetadata(metadata);
- request.setObjectKey(objectKey);
- return this.putObject(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#putObject(java.lang.String, java.lang.String, java.io.InputStream)
- */
- @Override
- public PutObjectResult putObject(String bucketName, String objectKey, InputStream input) throws ObsException {
- return this.putObject(bucketName, objectKey, input, null);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#putObject(com.obs.services.model.PutObjectRequest)
- */
- @Override
- public PutObjectResult putObject(final PutObjectRequest request) throws ObsException {
-
- ServiceUtils.asserParameterNotNull(request, "PutObjectRequest is null");
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
-
- return this.doActionWithResult("putObject", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public PutObjectResult action() throws ServiceException {
- if (null != request.getInput() && null != request.getFile()) {
- throw new ServiceException("Both input and file are set, only one is allowed");
- }
- return ObsClient.this.putObjectImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#putObject(java.lang.String, java.lang.String, java.io.File)
- */
- @Override
- public PutObjectResult putObject(String bucketName, String objectKey, File file) throws ObsException {
- return this.putObject(bucketName, objectKey, file, null);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#putObject(java.lang.String, java.lang.String, java.io.File, com.obs.services.model.ObjectMetadata)
- */
- @Override
- public PutObjectResult putObject(String bucketName, String objectKey, File file, ObjectMetadata metadata)
- throws ObsException {
- PutObjectRequest request = new PutObjectRequest();
- request.setBucketName(bucketName);
- request.setFile(file);
- request.setObjectKey(objectKey);
- request.setMetadata(metadata);
- return this.putObject(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#appendObject(com.obs.services.model.AppendObjectRequest)
- */
- @Override
- public AppendObjectResult appendObject(final AppendObjectRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "AppendObjectRequest is null");
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
-
- return this.doActionWithResult("appendObject", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public AppendObjectResult action() throws ServiceException {
- if (null != request.getInput() && null != request.getFile()) {
- throw new ServiceException("Both input and file are set, only one is allowed");
- }
- return ObsClient.this.appendObjectImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#uploadFile(com.obs.services.model.UploadFileRequest)
- */
- @Override
- public CompleteMultipartUploadResult uploadFile(UploadFileRequest uploadFileRequest) throws ObsException {
- return new ResumableClient(this).uploadFileResume(uploadFileRequest);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#downloadFile(com.obs.services.model.DownloadFileRequest)
- */
- @Override
- public DownloadFileResult downloadFile(DownloadFileRequest downloadFileRequest) throws ObsException {
- return new ResumableClient(this).downloadFileResume(downloadFileRequest);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObject(com.obs.services.model.GetObjectRequest)
- */
- @Override
- public ObsObject getObject(final GetObjectRequest request) throws ObsException {
-
- ServiceUtils.asserParameterNotNull(request, "GetObjectRequest is null");
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
- return this.doActionWithResult("getObject", request.getBucketName(), new ActionCallbackWithResult() {
-
- @Override
- public ObsObject action() throws ServiceException {
- return ObsClient.this.getObjectImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObject(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public ObsObject getObject(final String bucketName, final String objectKey, final String versionId)
- throws ObsException {
- return this.getObject(new GetObjectRequest(bucketName, objectKey, versionId));
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObject(java.lang.String, java.lang.String)
- */
- @Override
- public ObsObject getObject(final String bucketName, final String objectKey) throws ObsException {
- return this.getObject(bucketName, objectKey, null);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObjectMetadata(com.obs.services.model.GetObjectMetadataRequest)
- */
- @Override
- public ObjectMetadata getObjectMetadata(final GetObjectMetadataRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "GetObjectMetadataRequest is null");
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
- return this.doActionWithResult("getObjectMetadata", request.getBucketName(),
- new ActionCallbackWithResult() {
-
- @Override
- public ObjectMetadata action() throws ServiceException {
- return ObsClient.this.getObjectMetadataImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#setObjectMetadata(com.obs.services.model.SetObjectMetadataRequest)
- */
- @Override
- public ObjectMetadata setObjectMetadata(final SetObjectMetadataRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "SetObjectMetadataRequest is null");
- return this.doActionWithResult("setObjectMetadata", request.getBucketName(),
- new ActionCallbackWithResult() {
- @Override
- public ObjectMetadata action() throws ServiceException {
- return ObsClient.this.setObjectMetadataImpl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObjectMetadata(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public ObjectMetadata getObjectMetadata(String bucketName, String objectKey, String versionId) throws ObsException {
- GetObjectMetadataRequest request = new GetObjectMetadataRequest();
- request.setBucketName(bucketName);
- request.setObjectKey(objectKey);
- request.setVersionId(versionId);
- return this.getObjectMetadata(request);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#getObjectMetadata(java.lang.String, java.lang.String)
- */
- @Override
- public ObjectMetadata getObjectMetadata(String bucketName, String objectKey) throws ObsException {
- return this.getObjectMetadata(bucketName, objectKey, null);
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#restoreObject(com.obs.services.model.RestoreObjectRequest)
- */
- @Deprecated
- public RestoreObjectStatus restoreObject(final RestoreObjectRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "RestoreObjectRequest is null");
- return this.doActionWithResult("restoreObject", request.getBucketName(),
- new ActionCallbackWithResult() {
-
- @Override
- public RestoreObjectStatus action() throws ServiceException {
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
- return ObsClient.this.restoreObjectImpl(request);
- }
- });
-
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#restoreObjectV2(com.obs.services.model.RestoreObjectRequest)
- */
- @Override
- public RestoreObjectResult restoreObjectV2(final RestoreObjectRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "RestoreObjectRequest is null");
- return this.doActionWithResult("restoreObjectV2", request.getBucketName(),
- new ActionCallbackWithResult() {
-
- @Override
- public RestoreObjectResult action() throws ServiceException {
- ServiceUtils.asserParameterNotNull2(request.getObjectKey(), "objectKey is null");
- return ObsClient.this.restoreObjectV2Impl(request);
- }
- });
- }
-
- /* (non-Javadoc)
- * @see com.obs.services.IObsClient#restoreObjects(com.obs.services.model.RestoreObjectsRequest)
- */
- @Override
- public TaskProgressStatus restoreObjects(RestoreObjectsRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "RestoreObjectsRequest is null");
- if (! this.isCname()) {
- ServiceUtils.asserParameterNotNull(request.getBucketName(), "bucketName is null");
- }
-
- if (request.getKeyAndVersions() != null && request.getPrefix() != null) {
- throw new IllegalArgumentException("Prefix and keyandVersions cannot coexist in the same request");
- }
-
- int days = request.getDays();
- if (! (days >= 1 && days <= 30)) {
- throw new IllegalArgumentException("Restoration days should be at least 1 and at most 30");
- }
- DefaultTaskProgressStatus progreStatus = new DefaultTaskProgressStatus();
- ThreadPoolExecutor executor = this.initThreadPool(request);
-
- try {
- String bucketName = request.getBucketName();
- String prefix = request.getPrefix();
- RestoreTierEnum tier = request.getRestoreTier();
- boolean versionRestored = request.isVersionRestored();
- TaskCallback callback;
- TaskProgressListener listener;
- callback = (request.getCallback() == null) ? new LazyTaksCallback() : request.getCallback();
- listener = request.getProgressListener() ;
- int progressInterval = request.getProgressInterval();
- int totalTasks = 0;
- if (request.getKeyAndVersions() != null) {
- totalTasks = request.getKeyAndVersions().size();
- for (KeyAndVersion kv : request.getKeyAndVersions()) {
- RestoreObjectRequest taskRequest = new RestoreObjectRequest(bucketName, kv.getKey(), kv.getVersion(), days, tier);
- RestoreObjectTask task = new RestoreObjectTask(this, bucketName, taskRequest, callback, listener, progreStatus, progressInterval);
- executor.execute(task);
- }
- } else {
- if (versionRestored) {
- ListVersionsResult versionResult;
- ListVersionsRequest listRequest = new ListVersionsRequest(bucketName);
- listRequest.setPrefix(prefix);
- do{
- versionResult = this.listVersions(listRequest);
- for(VersionOrDeleteMarker v : versionResult.getVersions()) {
- if (v.getObjectStorageClass() == StorageClassEnum.COLD) {
- totalTasks ++;
- RestoreObjectRequest taskRequest = new RestoreObjectRequest(bucketName, v.getKey(), v.getVersionId(), days, tier);
- RestoreObjectTask task = new RestoreObjectTask(this, bucketName, taskRequest, callback, listener, progreStatus, progressInterval);
- executor.execute(task);
- if (ILOG.isInfoEnabled()) {
- if (totalTasks % 1000 == 0) {
- ILOG.info("RestoreObjects: " + totalTasks + " tasks have submitted to restore objects");
- }
- }
- }
- }
- listRequest.setKeyMarker(versionResult.getNextKeyMarker());
- listRequest.setVersionIdMarker(versionResult.getNextVersionIdMarker());
- } while(versionResult.isTruncated());
- } else {
- ObjectListing objectsResult;
- ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
- listObjectsRequest.setPrefix(prefix);
- do{
- objectsResult = this.listObjects(listObjectsRequest);
- for(ObsObject o : objectsResult.getObjects()) {
- if (o.getMetadata().getObjectStorageClass() == StorageClassEnum.COLD) {
- totalTasks ++;
- RestoreObjectRequest taskRequest = new RestoreObjectRequest(bucketName, o.getObjectKey(), null, days, tier);
- RestoreObjectTask task = new RestoreObjectTask(this, bucketName, taskRequest, callback, listener, progreStatus, progressInterval);
- executor.execute(task);
- if (ILOG.isInfoEnabled()) {
- if (totalTasks % 1000 == 0) {
- ILOG.info("RestoreObjects: " + totalTasks + " tasks have submitted to restore objects");
- }
- }
- }
- }
- listObjectsRequest.setMarker(objectsResult.getNextMarker());
- } while(objectsResult.isTruncated());
- }
- }
-
- 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);
- }
- return progreStatus;
+ @Override
+ public ObsFSFile newFile(NewFileRequest request) throws ObsException {
+ ObsFSFile obsFile = (ObsFSFile) this.putObject(request);
+ setInnerClient(obsFile, this);
+ return obsFile;
}
-
- @Override
- public UploadProgressStatus putObjects(final PutObjectsRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "PutObjectsRequest is null");
-
- ThreadPoolExecutor executor = this.initThreadPool(request);
- Date now = new Date();
- UploadTaskProgressStatus progressStatus = new UploadTaskProgressStatus(request.getTaskProgressInterval(), now);
-
- try {
- UploadObjectsProgressListener listener = request.getUploadObjectsProgressListener();
- TaskCallback callback = (request.getCallback() == null) ?
- new LazyTaksCallback() : request.getCallback();
- String prefix = request.getPrefix() == null ? "" : request.getPrefix();
- int totalTasks = 0;
- if(request.getFolderPath() != null) {
- String folderPath = request.getFolderPath();
- File fileRoot = new File(folderPath);
-
- if(fileRoot.exists()) {
- if(fileRoot.isDirectory()) {
- String folderRoot = fileRoot.getName();
- LinkedList list = new LinkedList();
- list.add(fileRoot);
- File[] files = fileRoot.listFiles();
- File temp_file;
- while (!list.isEmpty()) {
- temp_file = list.removeFirst();
- if(null == temp_file) {
- continue;
- }
- files = temp_file.listFiles();
- for (File file : files) {
- if (file.isDirectory()) {
- if(!file.exists()) {
- String filePath = file.getCanonicalPath();
- String erroInfo = "putObjects: the folder \"" + filePath + "\" dose not a folder";
- ILOG.warn(erroInfo);
- }else {
- list.add(file);
- }
- } else {
- // File upload
- String filePath = file.getCanonicalPath();
- if(!file.exists()) {
- ILOG.warn("putObjects: the file \"" + filePath + "\" dose not exist");
- continue;
- }
- totalTasks ++;
- String objectKey = prefix + folderRoot
- + filePath.substring(folderPath.length(), filePath.length()).replace("\\", "/");
- uploadObjectTask(request, filePath, objectKey, executor, progressStatus, callback, listener);
- }
- }
- }
- }else {
- String erroInfo = "putObjects: the folder \"" + folderPath + "\" dose not a folder";
- ILOG.warn(erroInfo);
- throw new ObsException(erroInfo);
- }
-
- }else {
- String erroInfo = "putObjects: the folder \"" + folderPath + "\" dose not exist";
- ILOG.warn(erroInfo);
- throw new ObsException(erroInfo);
- }
-
- }else if (request.getFilePaths() != null) {
- for(String filePath: request.getFilePaths()) {
- File file = new File(filePath);
- if(file.exists()) {
- totalTasks ++;
- String objectKey = prefix + file.getName();
- // File upload
- uploadObjectTask(request, filePath, objectKey, executor, progressStatus, callback, listener);
- }else {
- ILOG.warn("putObjects: the file \"" + filePath + "\" is not exist");
- }
- }
- }
-
- 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);
- }
-
- return progressStatus;
- }
-
- private void uploadObjectTask(final PutObjectsRequest request, final String filePath, final String objectKey
- , final ThreadPoolExecutor executor, final UploadTaskProgressStatus progressStatus
- , final TaskCallback callback, final UploadObjectsProgressListener listener) {
- File fileObject = new File(filePath);
- String bucketName = request.getBucketName();
- int progressInterval = request.getProgressInterval();
- int taskNum = request.getTaskNum();
- long detailProgressInterval = request.getDetailProgressInterval();
- long bigfileThreshold = request.getBigfileThreshold();
- long partSize = request.getPartSize();
- AccessControlList acl = request.getAcl();
- Map> extensionPermissionMap = request.getExtensionPermissionMap();
- SseCHeader sseCHeader = request.getSseCHeader();
- SseKmsHeader sseKmsHeader = request.getSseKmsHeader();
- String successRedirectLocation = request.getSuccessRedirectLocation();
-
- if(fileObject.length() > bigfileThreshold) {
- UploadFileRequest taskRequest = new UploadFileRequest(bucketName, objectKey);
- taskRequest.setUploadFile(filePath);
- taskRequest.setPartSize(partSize);
- taskRequest.setTaskNum(taskNum);
- taskRequest.setExtensionPermissionMap(extensionPermissionMap);
- taskRequest.setAcl(acl);
- taskRequest.setSuccessRedirectLocation(successRedirectLocation);
- taskRequest.setSseCHeader(sseCHeader);
- taskRequest.setSseKmsHeader(sseKmsHeader);
- taskRequest.setEnableCheckpoint(true);
- progressStatus.addTotalSize(fileObject.length());
- taskRequest.setProgressListener(new ProgressListener() {
-
- @Override
- public void progressChanged(ProgressStatus status) {
- progressStatus.putTaskTable(objectKey, status);
- if(progressStatus.isRefreshprogress()) {
- Date dateNow = new Date();
- long totalMilliseconds = dateNow.getTime() - progressStatus.getStartDate().getTime();
- progressStatus.setTotalMilliseconds(totalMilliseconds);
- listener.progressChanged(progressStatus);
- }
- }
- });
- taskRequest.setProgressInterval(detailProgressInterval);
-
- ResumableUploadTask task = new ResumableUploadTask(this, bucketName, taskRequest
- , callback, listener, progressStatus, progressInterval);
- executor.execute(task);
- }else {
- PutObjectRequest taskRequest = new PutObjectRequest(bucketName, objectKey, fileObject);
- taskRequest.setExtensionPermissionMap(extensionPermissionMap);
- taskRequest.setAcl(acl);
- taskRequest.setSuccessRedirectLocation(successRedirectLocation);
- taskRequest.setSseCHeader(sseCHeader);
- taskRequest.setSseKmsHeader(sseKmsHeader);
- progressStatus.addTotalSize(fileObject.length());
- taskRequest.setProgressListener(new ProgressListener() {
-
- @Override
- public void progressChanged(ProgressStatus status) {
- progressStatus.putTaskTable(objectKey, status);
- if(progressStatus.isRefreshprogress()) {
- Date dateNow = new Date();
- long totalMilliseconds = dateNow.getTime() - progressStatus.getStartDate().getTime();
- progressStatus.setTotalMilliseconds(totalMilliseconds);
- listener.progressChanged(progressStatus);
- }
- }
- });
- taskRequest.setProgressInterval(detailProgressInterval);
- PutObjectTask task = new PutObjectTask(this, bucketName, taskRequest, callback, listener
- , progressStatus, progressInterval);
- executor.execute(task);
- }
- }
-
-
- /* (non-Javadoc)
- * @see com.obs.services.IFSClient#deleteFolder(com.obs.services.model.fs.DeleteFSFolderRequest)
- */
- @Override
- public TaskProgressStatus dropFolder(DropFolderRequest request) throws ObsException {
- ServiceUtils.asserParameterNotNull(request, "DropFolderRequest is null");
- if (! this.isCname()) {
- ServiceUtils.asserParameterNotNull(request.getBucketName(), "bucketName is null");
- }
- ThreadPoolExecutor executor = this.initThreadPool(request);
- DefaultTaskProgressStatus progressStatus = new DefaultTaskProgressStatus();
- try {
- String bucketName = request.getBucketName();
- String folderName = request.getFolderName();
- String delimiter = this.getFileSystemDelimiter();
- if (! folderName.endsWith(delimiter)) {
- folderName = folderName + delimiter;
- }
- TaskCallback callback;
- TaskProgressListener listener;
- callback = (request.getCallback() == null) ? new LazyTaksCallback() : request.getCallback();
- listener = request.getProgressListener();
- int interval = request.getProgressInterval();
- int[] totalTasks = {0};
- boolean isSubDeleted = recurseFolders(folderName, bucketName, callback, interval, progressStatus, listener, executor, totalTasks);
- Map> futures = new HashMap>();
- totalTasks[0] ++;
- progressStatus.setTotalTaskNum(totalTasks[0]);
-
- if (isSubDeleted) {
- submitDropTask(folderName, bucketName, callback, interval, progressStatus, listener, executor, futures);
- checkDropFutures(futures, progressStatus, callback, listener, interval);
- } else {
- progressStatus.failTaskIncrement();
- callback.onException(new ObsException("Failed to delete due to child file deletion failed"), folderName);
- recordBulkTaskStatus(progressStatus, callback, listener, interval);
+ @Override
+ public ObsFSFolder newFolder(NewFolderRequest request) throws ObsException {
+ ServiceUtils.assertParameterNotNull(request, "CreateFolderRequest is null");
+ if (request.getObjectKey() != null) {
+ String delimiter = this.getFileSystemDelimiter();
+ if (!request.getObjectKey().endsWith(delimiter)) {
+ request.setObjectKey(request.getObjectKey() + delimiter);
}
-
- executor.shutdown();
- executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
- } catch (ObsException e) {
- throw e;
- } catch (Exception e) {
- throw new ObsException(e.getMessage(), e);
}
- return progressStatus;
+
+ ObsFSFolder obsFolder = (ObsFSFolder) this.putObject(new PutObjectRequest(request));
+ setInnerClient(obsFolder, this);
+ return obsFolder;
}
-
- private boolean recurseFolders(String folders, String bucketName, TaskCallback callback, int interval,
- DefaultTaskProgressStatus progressStatus, TaskProgressListener listener, ThreadPoolExecutor executor, int[] count) {
- ListObjectsRequest request = new ListObjectsRequest(bucketName);
- request.setDelimiter("/");
- request.setPrefix(folders);
- ObjectListing result;
- boolean isDeleted = true;
- do {
- result = this.listObjects(request);
- Map> futures = new HashMap>();
-
- for (ObsObject o : result.getObjects()) {
- if (!o.getObjectKey().endsWith("/")) {
- count[0] ++;
- isDeleted = submitDropTask(o.getObjectKey(),bucketName,callback,interval,progressStatus,listener,executor, futures) && isDeleted;
- if (ILOG.isInfoEnabled()) {
- if (count[0] % 1000 == 0) {
- ILOG.info("DropFolder: " + Arrays.toString(count) + " tasks have submitted to delete objects");
+
+ @Override
+ public ObsFSFile writeFile(final WriteFileRequest request) throws ObsException {
+ ServiceUtils.assertParameterNotNull(request, "WriteFileRequest is null");
+ ServiceUtils.assertParameterNotNull2(request.getObjectKey(), "objectKey is null");
+ ObsFSFile obsFile = this.doActionWithResult("writeFile", request.getBucketName(),
+ new ActionCallbackWithResult() {
+ @Override
+ public ObsFSFile action() throws ServiceException {
+ if (null != request.getInput() && null != request.getFile()) {
+ throw new ServiceException("Both input and file are set, only one is allowed");
}
+ return ObsClient.this.writeFileImpl(request);
}
- }
- }
-
- for (String prefix : result.getCommonPrefixes()) {
- boolean isSubDeleted = recurseFolders(prefix, bucketName, callback, interval, progressStatus, listener, executor, count);
- count[0] ++;
- if (isSubDeleted) {
- isDeleted = submitDropTask(prefix, bucketName, callback, interval, progressStatus, listener, executor, futures) && isDeleted;
- } else {
- progressStatus.failTaskIncrement();
- callback.onException(new ObsException("Failed to delete due to child file deletion failed"), prefix);
- recordBulkTaskStatus(progressStatus, callback, listener, interval);
- }
- if (ILOG.isInfoEnabled()) {
- if (count[0] % 1000 == 0) {
- ILOG.info("DropFolder: " + count + " tasks have submitted to delete objects");
- }
- }
- }
-
- request.setMarker(result.getNextMarker());
- isDeleted = checkDropFutures(futures, progressStatus, callback, listener, interval) && isDeleted;
- } while (result.isTruncated());
- return isDeleted;
- }
-
- private boolean submitDropTask(String key, String bucketName, TaskCallback callback, int interval,
- DefaultTaskProgressStatus progreStatus, TaskProgressListener listener, ThreadPoolExecutor executor, Map> futures) {
- DropFolderTask task = new DropFolderTask(this, bucketName, key, progreStatus, listener, interval, callback);
- try {
- futures.put(key, executor.submit(task));
- } catch (RejectedExecutionException e) {
- progreStatus.failTaskIncrement();
- callback.onException(new ObsException(e.getMessage(), e), key);
- return false;
- }
- return true;
+ });
+ setInnerClient(obsFile, this);
+ return obsFile;
}
- private boolean checkDropFutures(Map> futures, DefaultTaskProgressStatus progressStatus,
- TaskCallback callback, TaskProgressListener listener, int interval) {
- boolean isDeleted = true;
- for (Entry> entry :futures.entrySet()) {
- try {
- entry.getValue().get();
- } catch(ExecutionException e) {
- progressStatus.failTaskIncrement();
- if (e.getCause() instanceof ObsException) {
- callback.onException((ObsException)e.getCause(), entry.getKey());
- } else {
- callback.onException(new ObsException(e.getMessage(), e), entry.getKey());
+ private static void setInnerClient(final Object obj, final ObsClient obsClient) {
+ if (obj != null && obsClient != null) {
+ final Class> clazz = obj.getClass();
+ final String name = clazz.getName();
+
+ // fix findbugs: DP_DO_INSIDE_DO_PRIVILEGED
+ AccessController.doPrivileged(new PrivilegedAction