diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml
deleted file mode 100644
index 394c2391..00000000
--- a/.github/workflows/gradle-wrapper-validation.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-# add a new dedicated workflow. run once.
-# see: https://github.com/gradle/wrapper-validation-action
-name: "Validate Gradle Wrapper"
-on: [push, pull_request]
-
-jobs:
- validation:
- name: "Validation"
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: gradle/wrapper-validation-action@v1
\ No newline at end of file
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index a74aa1b6..a68dfa8d 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -18,28 +18,22 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
+ distribution: 'zulu' # temurin don't provide jdk8 anymore
+ cache: maven
# cache Gradle package to speed up future runs after a successful run.
- - name: Cache Gradle packages
- uses: actions/cache@v2
- with:
- path: ~/.gradle/caches
- key: ${{ matrix.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- restore-keys: ${{ matrix.os }}-gradle
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
- # gradle build process include test phase.
- - name: Build with Gradle
- run: ./gradlew build
+ - name: Run the Maven verify phase
+ run: mvn --batch-mode verify -"DskipITs" -"Dgpg.skip" # double-quotes: workaround for powershell
+ - run: mkdir staging && cp target/*.jar staging
# store the built packages as part of the workflow run.
# Allow us to download these artifacts and import to project to help local test.
# with matrix, Each job overwrites what was previously uploaded, but it's fine for us.
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v4
with:
- name: Package
- path: build/libs
+ name: jar-collection-${{ matrix.os }}-${{ matrix.java-version }}
+ path: staging
retention-days: 7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bd0bf41..1b53ac80 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -200,7 +200,7 @@ Add a construction method of QingStor.java
- Modify the http response header key to lower case
- Now some http response headers have become lowercase, were uppercase before("X-QS-Encryption-Customer-Algorithm" --> "x-qs-encryption-customer-algorithm"). To fix this issue, http headers in SDK are case insensitive.
+Now some http response headers have become lowercase, were uppercase before("X-QS-Encryption-Customer-Algorithm" --> "x-qs-encryption-customer-algorithm"). To fix this issue, http headers in SDK are case insensitive.
## [v2.2.12] - 2018-09-05
@@ -208,7 +208,7 @@ Add a construction method of QingStor.java
- Add has_more in response element
- If you are a private cloud user, please ensure that the version number of your server is greater than 20180801 (inclusive).
+If you are a private cloud user, please ensure that the version number of your server is greater than 20180801 (inclusive).
## [v2.2.11] - 2018-08-09
@@ -255,38 +255,38 @@ Add a construction method of QingStor.java
- Modify UploadManager and UploadManagerCallback
- - We make **interface UploadManagerCallback** become a **abstract class**
+- We make **interface UploadManagerCallback** become a **abstract class**
- Not all of users need sign with server.
- We make methods "String onSignature(String strToSign)" and "String onAccessKey()" do not auto override.
- To support java 1.6 as well, default method in interface does not work.
+ Not all of users need sign with server.
+ We make methods "String onSignature(String strToSign)" and "String onAccessKey()" do not auto override.
+ To support java 1.6 as well, default method in interface does not work.
- In summary, interface UploadManagerCallback is a abstract class now.
+ In summary, interface UploadManagerCallback is a abstract class now.
- - A correct time method added in UploadManagerCallback.
- - A method to correct time added in UploadManager when sign.
+- A correct time method added in UploadManagerCallback.
+- A method to correct time added in UploadManager when sign.
- Modify examples
- Modify examples about how to correct the time of your device.
+Modify examples about how to correct the time of your device.
- If the local time of users' clients are not synchronized with the network time,
- may occur a signture error.
+If the local time of users' clients are not synchronized with the network time,
+may occur a signture error.
- Now you can correct the time of your device by below codes.
+Now you can correct the time of your device by below codes.
- ```java
- requestHandler.getBuilder().setHeader(QSConstant.HEADER_PARAM_KEY_DATE, gmtTime);
- requestHandler.send();
- ```
+```java
+requestHandler.getBuilder().setHeader(QSConstant.HEADER_PARAM_KEY_DATE, gmtTime);
+requestHandler.send();
+```
- See examples for more info.
+See examples for more info.
- [Sign With Server - English Version](docs/example/sign_with_server.md)
- [Sign With Server - Chinese Version](docs/example/sign_with_server_zh.md)
+[Sign With Server - English Version](docs/example/sign_with_server.md)
+[Sign With Server - Chinese Version](docs/example/sign_with_server_zh.md)
- [UploadManager - English Version](docs/example/AutoUpload.md)
- [UploadManager - Chinese Version](docs/example/AutoUpload_zh.md)
+[UploadManager - English Version](docs/example/AutoUpload.md)
+[UploadManager - Chinese Version](docs/example/AutoUpload_zh.md)
## [v2.2.6] - 2018-04-17
@@ -296,12 +296,12 @@ Add a construction method of QingStor.java
- Add requestHandlers in ImageProgressClient
- Modify examples
- We fixed a lot of mistakes in examples.
- And add an example about how to do a image progress.
- Visit below links to get examples.
+We fixed a lot of mistakes in examples.
+And add an example about how to do a image progress.
+Visit below links to get examples.
- [English Version](docs/examples.md)
- [Chinese Version](docs/guide_zh.md)
+[English Version](docs/examples.md)
+[Chinese Version](docs/guide_zh.md)
## [v2.2.5] - 2018-01-25
@@ -320,10 +320,10 @@ Visit below links to get examples.
- Add upload manager to auto upload which will keep the position last uploaded.
- Visit below links to get examples.
+Visit below links to get examples.
- [English Version](docs/example/AutoUpload.md)
- [Chinese Version](docs/example/AutoUpload_zh.md)
+[English Version](docs/example/AutoUpload.md)
+[Chinese Version](docs/example/AutoUpload_zh.md)
## [v2.2.4] - 2018-01-13
@@ -340,10 +340,10 @@ Visit below links to know more.
- Add some examples.
- You can see the new examples here:
+You can see the new examples here:
- [English Version](docs/examples.md)
- [Chinese Version](docs/guide_zh.md)
+[English Version](docs/examples.md)
+[Chinese Version](docs/guide_zh.md)
## [v2.2.3] - 2018-01-05
@@ -357,10 +357,10 @@ Visit below links to know more.
- Add some examples.
- You can see the examples here:
+You can see the examples here:
- [English Version](docs/examples.md)
- [Chinese Version](docs/guide_zh.md)
+[English Version](docs/examples.md)
+[Chinese Version](docs/guide_zh.md)
## [v2.2.2] - 2017-12-21
@@ -370,71 +370,71 @@ Visit below links to know more.
- Fixed twice encode when set responseContentDisposition.
- Now you can set responseContentDisposition like this:
+Now you can set responseContentDisposition like this:
- ```java
- Bucket.GetObjectInput inputs = new Bucket.GetObjectInput();
- String fileName = "测试图片(测试).jpg";
- String urlName = URLEncoder.encode(fileName, "utf-8");
- //do not add blanks int the key "attachment;filename="
- inputs.setResponseContentDisposition("attachment;filename=" + urlName);
- RequestHandler handle = bucket.GetObjectBySignatureUrlRequest("测试图片(测试).jpg", inputs, System.currentTimeMillis() + 10000);
- String tempUrl = handle.getExpiresRequestUrl();
- ```
+```java
+ Bucket.GetObjectInput inputs = new Bucket.GetObjectInput();
+ String fileName = "测试图片(测试).jpg";
+ String urlName = URLEncoder.encode(fileName, "utf-8");
+ //do not add blanks int the key "attachment;filename="
+ inputs.setResponseContentDisposition("attachment;filename=" + urlName);
+ RequestHandler handle = bucket.GetObjectBySignatureUrlRequest("测试图片(测试).jpg", inputs, System.currentTimeMillis() + 10000);
+ String tempUrl = handle.getExpiresRequestUrl();
+```
### Added
- Add config to change url style.
- Available url style:
- One is the default, when requestUrlStyle != QSConstant#PATH_STYLE}
- You may see the url like this(QSConstant#VIRTUAL_HOST_STYLE):
- https://bucket-name.zone-id.qingstor.com/object-name
- Otherwise you may see the url like this(QSConstant#PATH_STYLE):
- https://zone-id.qingstor.com/bucket-name/object-name
+Available url style:
+One is the default, when requestUrlStyle != QSConstant#PATH_STYLE}
+You may see the url like this(QSConstant#VIRTUAL_HOST_STYLE):
+https://bucket-name.zone-id.qingstor.com/object-name
+Otherwise you may see the url like this(QSConstant#PATH_STYLE):
+https://zone-id.qingstor.com/bucket-name/object-name
- - Now you can add configs in EvnContext to change url style.
- In java:
+- Now you can add configs in EvnContext to change url style.
+ In java:
- ```java
- EvnContext evn = EvnContext.loadFromFile("config_stor.yaml");
- Bucket bucket = new Bucket(evn, zoneId, bucketName);
- ```
+```java
+ EvnContext evn = EvnContext.loadFromFile("config_stor.yaml");
+ Bucket bucket = new Bucket(evn, zoneId, bucketName);
+```
- About file config_stor.yaml you can add configs below:
+About file config_stor.yaml you can add configs below:
- ```yaml
- # QingStor services configuration
+```yaml
+# QingStor services configuration
- access_key_id: "ACCESS_KEY_ID"
- secret_access_key: "SECRET_ACCESS_KEY"
+access_key_id: "ACCESS_KEY_ID"
+secret_access_key: "SECRET_ACCESS_KEY"
- host: "qingstor.com"
- port: "443"
- protocol: "https"
- connection_retries: 3
- # uri: '/iaas'
+host: "qingstor.com"
+port: "443"
+protocol: "https"
+connection_retries: 3
+# uri: '/iaas'
- # Valid log levels are "debug", "info", "warn", "error", and "fatal".
- log_level: "warn"
+# Valid log levels are "debug", "info", "warn", "error", and "fatal".
+log_level: "warn"
- # Valid request url styles are "virtual_host_style"(default) and "path_style"
- request_url_style: "path_style"
- ```
+# Valid request url styles are "virtual_host_style"(default) and "path_style"
+request_url_style: "path_style"
+```
- Attention: if some of the configs you do not use, please add a "#" at the first of the line.
- Like this: `# port: '443'`
+Attention: if some of the configs you do not use, please add a "#" at the first of the line.
+Like this: `# port: '443'`
- - Or set request url style with EvnContext.
+- Or set request url style with EvnContext.
- ```java
- EvnContext evn = new EvnContext("ACCESS_KEY_ID_EXAMPLE", "SECRET_ACCESS_KEY_EXAMPLE");
- //Valid request url styles' params are QSConstant.PATH_STYLE and QSConstant.VIRTUAL_HOST_STYLE
- evn.setRequestUrlStyle(QSConstant.PATH_STYLE);
- String zoneName = "pek3a";
- String bucketName = "testBucketName";
- Bucket bucket = new Bucket(evn, zoneKey, bucketName);
- ```
+```java
+ EvnContext evn = new EvnContext("ACCESS_KEY_ID_EXAMPLE", "SECRET_ACCESS_KEY_EXAMPLE");
+ //Valid request url styles' params are QSConstant.PATH_STYLE and QSConstant.VIRTUAL_HOST_STYLE
+ evn.setRequestUrlStyle(QSConstant.PATH_STYLE);
+ String zoneName = "pek3a";
+ String bucketName = "testBucketName";
+ Bucket bucket = new Bucket(evn, zoneKey, bucketName);
+```
## [v2.2.1] - 2017-11-07
@@ -545,17 +545,17 @@ Visit below links to know more.
### Added
- QingStor SDK for the JAVA programming language.
- [v2.2.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.2.0...2.2.1
- [v2.2.0]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.10...2.2.0
- [v2.1.10]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.9...2.1.10
- [v2.1.9]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.8...2.1.9
- [v2.1.8]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.7...2.1.8
- [v2.1.7]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.6...2.1.7
- [v2.1.6]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.5...2.1.6
- [v2.1.5]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.4...2.1.5
- [v2.1.4]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.3...2.1.4
- [v2.1.3]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.2...2.1.3
- [v2.1.2]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.1...2.1.2
- [v2.1.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.0...2.1.1
- [v2.1.0]: https://github.com/yunify/qingstor-sdk-java/compare/2.0.1...2.1.0
- [v2.0.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.0.0...2.0.1
+[v2.2.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.2.0...2.2.1
+[v2.2.0]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.10...2.2.0
+[v2.1.10]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.9...2.1.10
+[v2.1.9]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.8...2.1.9
+[v2.1.8]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.7...2.1.8
+[v2.1.7]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.6...2.1.7
+[v2.1.6]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.5...2.1.6
+[v2.1.5]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.4...2.1.5
+[v2.1.4]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.3...2.1.4
+[v2.1.3]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.2...2.1.3
+[v2.1.2]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.1...2.1.2
+[v2.1.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.1.0...2.1.1
+[v2.1.0]: https://github.com/yunify/qingstor-sdk-java/compare/2.0.1...2.1.0
+[v2.0.1]: https://github.com/yunify/qingstor-sdk-java/compare/2.0.0...2.0.1
diff --git a/Makefile b/Makefile
index 64ea3ea8..b6cbb6e1 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ all: update generate unit build
test:
@echo "run service test"
- ./gradlew cucumber
+ mvn integration-test
@echo "ok"
generate:
@@ -22,7 +22,7 @@ generate:
snips \
-f=./specs/qingstor/2016-01-06/swagger/api_v2.0.json -t=./template -o=./src/main/java/com/qingstor/sdk/service
rm ./src/main/java/com/qingstor/sdk/service/Object.java
- ./gradlew spotlessApply
+ mvn spotless:apply
@echo "ok"
update:
@@ -31,10 +31,10 @@ update:
unit:
@echo "run unit test"
- ./gradlew test
+ mvn test
@echo "ok"
-
+
build:
@echo "run build jar(jar, source, javadoc)"
- ./gradlew build
+ mvn package -Prelease
@echo "ok"
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 2cd5bcdf..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,186 +0,0 @@
-plugins {
- id 'java-library'
- id 'maven-publish'
- id 'signing'
- id("com.diffplug.spotless") version "6.13.0" // the last jdk8 compatible version.
- id 'com.github.johnrengelman.shadow' version '8.1.1'
-}
-
-group = 'com.yunify'
-// Pass command-line option: -Psdk_version=x.x.x if you want build a different version.
-version = findProperty('sdk_version') ?: '2.6.5'
-
-repositories {
- mavenCentral()
-}
-
-java {
- sourceCompatibility(JavaVersion.VERSION_1_8)
- targetCompatibility(JavaVersion.VERSION_1_8)
-
- withJavadocJar()
- withSourcesJar()
-}
-
-def sharedManifest = java.manifest {
- attributes("Implementation-Title": project.name,
- "Implementation-Version": project.version)
-}
-
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-
-tasks.named('shadowJar', ShadowJar) {
- archiveClassifier.set('all-deps')
- archiveVersion.set(project.version.toString())
-
- enableRelocation true
- relocationPrefix "qingstor"
-
-}
-
-tasks {
- compileJava {
- configure options.encoding("UTF-8")
- }
- compileTestJava {
- configure options.encoding("UTF-8")
- }
- jar {
- manifest = java.manifest {
- from sharedManifest
- }
- }
- javadoc {
- options.encoding("UTF-8")
- // see: https://github.com/gradle/gradle/pull/8321
- if (JavaVersion.current().java9Compatible) {
- if (JavaVersion.current().java11Compatible && !JavaVersion.current().java12Compatible) {
- options.addBooleanOption('-no-module-directories', true)
- }
- options.addBooleanOption('html5', true)
- }
- }
- tasks.register('versionProperties') {
- doLast {
- mkdir "$buildDir/resources/main"
- new File("$buildDir/resources/main/version.properties").withWriter { w ->
- Properties p = new Properties()
- p['version'] = project.version.toString()
- p.store w, null
- }
- }
- }
- classes {
- dependsOn versionProperties
- }
- build {
- dependsOn shadowJar
- }
-}
-
-// publish only unshadowed artifacts
-components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
- skip()
-}
-
-publishing {
- publications {
- maven(MavenPublication) {
- from components.java
- artifactId = 'qingstor.sdk.java' // this should be replaced near future.
-
- pom {
- name = project.name
- description = 'The official QingStor SDK for the Java programming language.'
- url = 'https://www.qingcloud.com/products/qingstor/'
- licenses {
- license {
- name = 'The Apache License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- }
- }
- developers {
- developer {
- id = 'yunify'
- name = 'yunify'
- email = 'sdk_group@yunify.com'
- }
- }
- scm {
- connection = 'scm:git:git@github.com:yunify/qingstor-sdk-java.git'
- developerConnection = 'scm:git:git@github.com:yunify/qingstor-sdk-java.git'
- url = 'https://github.com/qingstor/qingstor-sdk-java'
- }
- }
- }
- }
- repositories {
- // local repo for test usage, redirect output to this for verification before upload.
- // or use ./gradlew publishToMavenLocal
- // maven {
- // name = "myRepo"
- // url = uri("file://${buildDir}/repo")
- // }
- maven {
- name = "mavencentral"
- url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
- credentials {
- username = System.getenv("SONATYPE_NEXUS_USERNAME")
- password = System.getenv("SONATYPE_NEXUS_PASSWORD")
- }
- }
- }
-}
-
-signing {
- // https://docs.gradle.org/current/userguide/signing_plugin.html#sec:specifying_what_to_sign
- sign publishing.publications.maven
-}
-
-configurations {
- cucumberRuntime {
- extendsFrom testImplementation
- }
-}
-
-// In this section you declare the dependencies for your production and test code
-dependencies {
- api 'com.squareup.okhttp3:okhttp:4.12.0'
-
- implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.3'
- implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3'
- implementation 'org.json:json:20231013'
- // it's library's consumer's responsibility to choose a log implementation(and set log_level.)
- implementation 'org.slf4j:slf4j-api:1.7.32'
- testImplementation 'io.cucumber:cucumber-java:7.0.0'
- testImplementation 'io.cucumber:cucumber-junit:7.0.0'
- testImplementation 'ch.qos.logback:logback-classic:1.2.6'
-}
-
-task cucumber() {
- dependsOn assemble, testClasses
- doLast {
- javaexec {
- main = 'io.cucumber.core.cli.Main'
- classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
- args = ['--plugin', 'pretty', '--glue', 'integration.cucumber', 'tests/features']
- }
- }
-}
-
-spotless {
- format 'misc', {
- // define the files to apply `misc` to
- target '*.gradle', '*.md', '.gitignore'
- // define the steps to apply to those files
- trimTrailingWhitespace()
- indentWithSpaces(4)
- endWithNewline()
- }
- java {
- // switch to AOSP style
- googleJavaFormat('1.7').aosp()
- // Add license to every java file.
- licenseHeaderFile rootProject.file('spotless.license.java')
- }
-}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index e708b1c0..00000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index a1f2792d..00000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
deleted file mode 100755
index 4f906e0c..00000000
--- a/gradlew
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# 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
-#
-# https://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.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index ac1b06f9..00000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,89 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..f3e3fcb5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,370 @@
+
+ 4.0.0
+
+ com.yunify
+ qingstor.sdk.java
+ 2.6.5
+ Qingcloud Qingstor SDK for Java
+ The official QingStor SDK for the Java programming language.
+ https://www.qingcloud.com/products/objectstorage/
+
+
+ UTF-8
+ 1.8
+ 1.8
+ com.qingstor.sdk.shade
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+
+
+ yunify
+ Qingstor SDK
+ sdk_group@yunify.com
+
+
+
+ scm:git:git@github.com:qingstor/qingstor-sdk-java.git
+ scm:git:git@github.com:qingstor/qingstor-sdk-java.git
+ git@github.com:qingstor/qingstor-sdk-java.git
+
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.12.0
+
+
+ org.json
+ json
+ 20231013
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.15.3
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+ 2.15.3
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+ io.cucumber
+ cucumber-java
+ 7.0.0
+ test
+
+
+ io.cucumber
+ cucumber-junit
+ 7.0.0
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.6
+ test
+
+
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.3.2
+
+
+
+ maven-resources-plugin
+ 3.3.1
+
+
+ maven-compiler-plugin
+ 3.13.0
+
+
+ maven-source-plugin
+ 3.3.1
+
+
+ maven-javadoc-plugin
+ 3.6.3
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.3
+
+
+ maven-surefire-plugin
+ 3.2.5
+
+
+ maven-jar-plugin
+ 3.4.1
+
+
+ maven-install-plugin
+ 3.1.2
+
+
+ maven-deploy-plugin
+ 3.1.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+ maven-gpg-plugin
+ 3.2.4
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ true
+ true
+ UTF-8
+ UTF-8
+ UTF-8
+
+
+
+ attach-docs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+ package
+
+ shade
+
+
+
+
+ all-deps
+ false
+
+ true
+ true
+
+
+
+
+ okhttp3
+ ${shade.package}.okhttp3
+
+
+ okio
+ ${shade.package}.okio
+
+
+ kotlin
+ ${shade.package}.kotlin
+
+
+ com.fasterxml
+ ${shade.package}.com.fasterxml
+
+
+ org
+ ${shade.package}.org
+
+ org/slf4j/**
+
+
+
+
+
+
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.30.0
+
+
+
+
+
+
+ *.md
+ .gitattributes
+ .gitignore
+
+
+
+
+
+ true
+ 4
+
+
+
+
+
+
+ 1.10.0
+
+
+
+
+ ${project.basedir}/spotless.license.java
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ -Dfile.encoding=UTF-8
+
+
+
+ run-test
+ test
+
+
+ **/integration/*.java
+
+
+
+
+
+
+ maven-failsafe-plugin
+ 3.2.5
+
+ -Dfile.encoding=UTF-8
+
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+
+ org.apache.maven.surefire
+ surefire-junit47
+ 3.2.5
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+
+
+ verify
+
+ sign
+
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.13
+ true
+
+ nexus-staging
+ https://oss.sonatype.org/
+
+
+
+
+
+
+
+
+ release
+
+ true
+
+
+
+
+
+
+ nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots/
+
+
+ nexus-staging
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 82e088bf..00000000
--- a/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-rootProject.name = 'qingstor-sdk-java'
diff --git a/src/main/java/com/qingstor/sdk/request/QSBuilder.java b/src/main/java/com/qingstor/sdk/request/QSBuilder.java
index 0f8d75df..09b13d75 100644
--- a/src/main/java/com/qingstor/sdk/request/QSBuilder.java
+++ b/src/main/java/com/qingstor/sdk/request/QSBuilder.java
@@ -151,7 +151,7 @@ private void initUrlWithQueries() throws QSException {
}
this.paramsQuery = queries;
- log.debug("== resource Url ==\n" + this.urlWithoutQueries + "\n");
+ log.debug("== resource Url == " + this.urlWithoutQueries);
}
private Map headParamEncoding(Map headParams) {
@@ -338,7 +338,7 @@ private String getSignature() throws QSException {
} catch (Exception e) {
throw new QSException("Auth signature error", e);
}
- log.debug("== authSign ==\n" + authSign + "\n");
+ log.debug("== authSign == " + authSign);
paramsHeaders.put(QSConstant.HEADER_PARAM_KEY_AUTHORIZATION, authSign);
return authSign;
diff --git a/src/main/java/com/qingstor/sdk/request/QSOkHttpRequestClient.java b/src/main/java/com/qingstor/sdk/request/QSOkHttpRequestClient.java
index 579f1a95..4720b967 100644
--- a/src/main/java/com/qingstor/sdk/request/QSOkHttpRequestClient.java
+++ b/src/main/java/com/qingstor/sdk/request/QSOkHttpRequestClient.java
@@ -101,7 +101,6 @@ public void onResponse(Call call, Response response) {
ResponseBody body = response.body();
if (callBack != null) {
T m = QSParamInvokeUtil.getOutputModel(outputClass);
- log.debug("class name: " + m.getClass().getName());
fillResponseValue2Object(response, m);
callBack.onAPIResponse(m);
}
diff --git a/src/main/java/com/qingstor/sdk/request/impl/InputStreamUploadBody.java b/src/main/java/com/qingstor/sdk/request/impl/InputStreamUploadBody.java
index 0d409dff..8a865e07 100644
--- a/src/main/java/com/qingstor/sdk/request/impl/InputStreamUploadBody.java
+++ b/src/main/java/com/qingstor/sdk/request/impl/InputStreamUploadBody.java
@@ -19,7 +19,6 @@
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
-import okhttp3.internal.Util;
import okio.BufferedSink;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,13 +57,18 @@ public MediaType contentType() {
@Override
public void writeTo(BufferedSink sink) throws IOException {
- if (contentLength > 0) {
- writeWithContentLength(sink, offset);
- } else {
- writeAll(sink);
+ try {
+ if (contentLength > 0) {
+ writeWithContentLength(sink, offset);
+ } else {
+ writeAll(sink);
+ }
+ sink.flush();
+ } finally {
+ if (file != null) {
+ file.close();
+ }
}
- sink.flush();
- Util.closeQuietly(file);
}
private void writeWithContentLength(BufferedSink sink, long offset) throws IOException {
diff --git a/src/main/java/com/qingstor/sdk/utils/QSSignatureUtil.java b/src/main/java/com/qingstor/sdk/utils/QSSignatureUtil.java
index ec7180cc..0b55c05f 100644
--- a/src/main/java/com/qingstor/sdk/utils/QSSignatureUtil.java
+++ b/src/main/java/com/qingstor/sdk/utils/QSSignatureUtil.java
@@ -187,7 +187,6 @@ public static String generateSignature(
Map headers) {
String signature;
String strToSign = getStringToSignature(method, requestURI, params, headers);
- log.debug("== String to sign ==\n" + strToSign + "\n");
signature = generateSignature(secretKey, strToSign);
return signature;
}
@@ -198,9 +197,9 @@ public static String getStringToSignature(
Map params,
Map headers) {
final String SEPARATOR = "&";
- StringBuilder strToSign = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
- strToSign.append(method.toUpperCase()).append("\n");
+ sb.append(method.toUpperCase()).append("\n");
String contentMD5 = "";
String contentType = "";
@@ -208,8 +207,8 @@ public static String getStringToSignature(
if (headers.containsKey("content-md5")) contentMD5 = headers.get("content-md5");
if (headers.containsKey("content-type")) contentType = headers.get("content-type");
}
- strToSign.append(contentMD5).append("\n");
- strToSign.append(contentType);
+ sb.append(contentMD5).append("\n");
+ sb.append(contentType);
// Append request time as string
String dateStr = "";
@@ -221,7 +220,7 @@ public static String getStringToSignature(
dateStr = headers.get(QSConstant.HEADER_PARAM_KEY_EXPIRES);
}
}
- strToSign.append("\n").append(dateStr);
+ sb.append("\n").append(dateStr);
// Generate signed headers.
if (headers != null) {
@@ -229,7 +228,7 @@ public static String getStringToSignature(
Arrays.sort(sortedHeadersKeys);
for (String key : sortedHeadersKeys) {
if (!key.startsWith("x-qs-") && !key.startsWith("X-QS-")) continue;
- strToSign.append(String.format("\n%s:%s", key.toLowerCase(), headers.get(key)));
+ sb.append(String.format("\n%s:%s", key.toLowerCase(), headers.get(key)));
}
}
@@ -265,11 +264,12 @@ public static String getStringToSignature(
if (canonicalizedQuery.length() > 0) {
canonicalizedResource += "?" + canonicalizedQuery;
}
- strToSign.append(String.format("\n%s", canonicalizedResource));
+ sb.append(String.format("\n%s", canonicalizedResource));
+ String strToSign = sb.toString();
- log.debug("== String to sign ==\n" + strToSign + "\n");
+ log.debug("== String to sign == " + strToSign.replaceAll("\n", "\\\\n"));
- return strToSign.toString();
+ return strToSign;
}
public static String generateSignature(String secretKey, String strToSign) {
diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties
new file mode 100644
index 00000000..0759335f
--- /dev/null
+++ b/src/main/resources/version.properties
@@ -0,0 +1 @@
+version=2.6.5
diff --git a/src/test/java/integration/cucumber/RunCucumberIT.java b/src/test/java/integration/cucumber/RunCucumberIT.java
new file mode 100644
index 00000000..a71224b7
--- /dev/null
+++ b/src/test/java/integration/cucumber/RunCucumberIT.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2021 Yunify, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this work except in compliance with the License.
+ * You may obtain a copy of the License in the LICENSE file, or 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 integration.cucumber;
+
+import io.cucumber.junit.Cucumber;
+import io.cucumber.junit.CucumberOptions;
+import org.junit.runner.RunWith;
+
+@RunWith(Cucumber.class)
+@CucumberOptions(
+ plugin = {"pretty"},
+ glue = {"integration.cucumber"},
+ features = {"tests/features"})
+public class RunCucumberIT {}