From 8a85864e12e6db035bc4b793effb4fc5bdb9623a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Aug 2021 08:02:00 +0000 Subject: [PATCH 01/36] Bump mockito-inline from 3.12.3 to 3.12.4 Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.12.3 to 3.12.4. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.3...v3.12.4) --- updated-dependencies: - dependency-name: org.mockito:mockito-inline dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- gradle/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 1beef4a0f..ca7206d5a 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { // Use JUnit test framework testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' - testImplementation 'org.mockito:mockito-inline:3.12.3' + testImplementation 'org.mockito:mockito-inline:3.12.4' api 'com.squareup.okhttp3:okhttp:4.9.1' From 14c60e4343d9910afbd163a096f6d93f319c1f68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Aug 2021 08:08:18 +0000 Subject: [PATCH 02/36] Bump mockito-inline from 3.12.3 to 3.12.4 Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.12.3 to 3.12.4. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.3...v3.12.4) --- updated-dependencies: - dependency-name: org.mockito:mockito-inline dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1b3b7f3c..ffacd42af 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ org.mockito mockito-inline - 3.12.3 + 3.12.4 test From a0ba2852a2a7e9f331ff13bd5a9f350bd9bf0910 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 26 Aug 2021 14:06:50 -0700 Subject: [PATCH 03/36] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 688c3d4ae..4e5b200cf 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,7 @@ The Microsoft Graph SDK is open for contribution. To contribute to this project, The Microsoft Graph SDK for Java library is supported at runtime for Java 8 and [Android API revision 26](http://source.android.com/source/build-numbers.html) or greater. -Android developers targeting lower android API levels can do so by [enabling desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) in their project. + ## 7. License From 6ce19e86d1bc3806e6428696d12813790aaff116 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Fri, 27 Aug 2021 14:32:09 -0700 Subject: [PATCH 04/36] Update readme.md Co-authored-by: Vincent Biret --- readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.md b/readme.md index 4e5b200cf..72dcc5914 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,6 @@ The Microsoft Graph SDK is open for contribution. To contribute to this project, The Microsoft Graph SDK for Java library is supported at runtime for Java 8 and [Android API revision 26](http://source.android.com/source/build-numbers.html) or greater. - ## 7. License From a95ac24794bae11539da190edcc4268347e651ff Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Wed, 1 Sep 2021 12:55:52 -0700 Subject: [PATCH 05/36] Create build-and-publish.yml --- .github/workflows/build-and-publish.yml | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build-and-publish.yml diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 000000000..12f6318d1 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,50 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and Publish + +on: + push: + branches: [ dev , master ] + paths-ignore: + - .gradle/wrapper + - .gitignore + - CONTRIBUTING.md + - LICENSE + - THIRD PARTY NOTICES + - gradle.properties + - gradlew + - gradlew.bat + - readme.md + - settings.gradle + - Scripts/* + +jobs: + build-and-publish: + env: + GRADLE_OPTIONS: -x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar + PREVIEW_TASK: publishSnapshotPublicationToSonatypeSnapshotRepository + PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '16' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Preview + if: ${{ github.ref == 'refs/head/dev' }} + run: ./gradlew $GRADLE_OPTIONS $PREVIEW_TASK + - name: Publish + if: ${{ github.ref === 'refs/head/master' }} + run: ./gradlew $GRADLE_OPTIONS $PUBLISH_TASK From 28e818cf8f08afec7cb9a7f88a7b80b75f5921af Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 2 Sep 2021 11:08:32 -0700 Subject: [PATCH 06/36] Update .github/workflows/build-and-publish.yml Co-authored-by: Vincent Biret --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 12f6318d1..50863f178 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -33,7 +33,7 @@ jobs: - - name: Set up JDK 11 + - name: Set up JDK uses: actions/setup-java@v2 with: java-version: '16' From b0b2d46008490544154bcae5c9875ca6b7028f88 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:53:44 -0700 Subject: [PATCH 07/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 123 +++++++++++++++++------- 1 file changed, 88 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 50863f178..eda36d495 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -6,45 +6,98 @@ name: Build and Publish on: push: branches: [ dev , master ] - paths-ignore: - - .gradle/wrapper - - .gitignore - - CONTRIBUTING.md - - LICENSE - - THIRD PARTY NOTICES - - gradle.properties - - gradlew - - gradlew.bat - - readme.md - - settings.gradle - - Scripts/* + paths: + - 'src/*' + - '!.gradle/wrapper' + - '!.gitignore' + - '!LICENSE' + - '!THIRD PARTY NOTICES' + - '!*.md' + - '*.gradle' +env: + GRADLE_OPTIONS: -x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar + PREVIEW_TASK: publishSnapshotPublicationToSonatypeSnapshotRepository + PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository jobs: - build-and-publish: - env: - GRADLE_OPTIONS: -x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar - PREVIEW_TASK: publishSnapshotPublicationToSonatypeSnapshotRepository - PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository - + maven_Release: + if: ${{ github.ref == 'ref/head/master' }} + environment: + name: maven_central_release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '16' + distribution: 'adopt' + cache: gradle + + ##Copy the Step below for the other files with the appropriate values + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $ENCODED_VALUE -outputPath $OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: "" + OUTPUT_PATH: "" + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Publish + run: ./gradlew $PUBLISH_TASK + - name: Upload Build Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: drop + path: | + **/libs/* + build/generated-pom.xml + build/generated-pom.xml.asc + build.gradle + gradlew + gradlew.bat + settings.gradle + gradle.properties + **/gradle/** + Scripts/** + + githubRelease: + needs: maven_Release runs-on: ubuntu-latest + steps: + - name: Download Build Artifact + uses: actions/download-artifact@v2.0.10 + with: + name: drop + path: drop + - name: GitHub Releases + uses: fnkr/github-action-ghr@v1.3 + env: + GHR_PATH: current/working/directory/drop/ + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + maven_Preview: + if: ${{ github.ref == 'refs/head/dev' }} + environment: + name: maven_central_snapshot + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '16' + distribution: 'adopt' + cache: gradle + ##Copy the Step below for the other files with the appropriate values + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $ENCODED_VALUE -outputPath $OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: "" + OUTPUT_PATH: "" - - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '16' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Preview - if: ${{ github.ref == 'refs/head/dev' }} - run: ./gradlew $GRADLE_OPTIONS $PREVIEW_TASK - - name: Publish - if: ${{ github.ref === 'refs/head/master' }} - run: ./gradlew $GRADLE_OPTIONS $PUBLISH_TASK + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Publish + run: ./gradlew $PREVIEW_TASK From 25012a060cb2ea9fa445b98198cb3808bf52f11a Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:56:45 -0700 Subject: [PATCH 08/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index eda36d495..f9f1b2c97 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -15,7 +15,6 @@ on: - '!*.md' - '*.gradle' env: - GRADLE_OPTIONS: -x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar PREVIEW_TASK: publishSnapshotPublicationToSonatypeSnapshotRepository PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository @@ -27,6 +26,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Easy detect-secrets + uses: RobertFischer/detect-secrets-action@v2.0.0 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -83,6 +84,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Easy detect-secrets + uses: RobertFischer/detect-secrets-action@v2.0.0 - name: Set up JDK uses: actions/setup-java@v2 with: From 0563999d2bf59effd190439e382697eda3d6f537 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Tue, 7 Sep 2021 10:51:34 -0700 Subject: [PATCH 09/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f9f1b2c97..a03277c9f 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -36,7 +36,7 @@ jobs: cache: gradle ##Copy the Step below for the other files with the appropriate values - - run: .\scripts\decodeAndWrite.ps1 -encodedValue $ENCODED_VALUE -outputPath $OUTPUT_PATH + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH shell: pwsh env: ENCODED_VALUE: "" From f68379043cdb4a64d8e40fa1e5f9d6e994cc3d2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 08:02:24 +0000 Subject: [PATCH 10/36] Bump azure-core from 1.19.0 to 1.20.0 Bumps [azure-core](https://github.com/Azure/azure-sdk-for-java) from 1.19.0 to 1.20.0. - [Release notes](https://github.com/Azure/azure-sdk-for-java/releases) - [Commits](https://github.com/Azure/azure-sdk-for-java/compare/azure-core_1.19.0...azure-core_1.20.0) --- updated-dependencies: - dependency-name: com.azure:azure-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index ca7206d5a..80c1bcfc5 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -9,5 +9,5 @@ dependencies { implementation 'com.google.guava:guava:30.1.1-jre' implementation 'com.google.code.gson:gson:2.8.8' - api 'com.azure:azure-core:1.19.0' + api 'com.azure:azure-core:1.20.0' } \ No newline at end of file From 5b19a507ea3e4a75a56240391b7ccc31c31c2834 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 08:09:09 +0000 Subject: [PATCH 11/36] Bump azure-core from 1.19.0 to 1.20.0 Bumps [azure-core](https://github.com/Azure/azure-sdk-for-java) from 1.19.0 to 1.20.0. - [Release notes](https://github.com/Azure/azure-sdk-for-java/releases) - [Commits](https://github.com/Azure/azure-sdk-for-java/compare/azure-core_1.19.0...azure-core_1.20.0) --- updated-dependencies: - dependency-name: com.azure:azure-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1b3b7f3c..0e0237889 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ com.azure azure-core - 1.19.0 + 1.20.0 org.junit.jupiter From 1cb8ffc7db0a72f7edd128c031e5e13258d5fd63 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Wed, 8 Sep 2021 02:09:18 -0700 Subject: [PATCH 12/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 67 ++++++++++++------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index a03277c9f..f0388120b 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -19,6 +19,31 @@ env: PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository jobs: + maven_Preview: + if: ${{ github.ref == 'refs/head/dev' }} + environment: + name: maven_central_snapshot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Easy detect-secrets + uses: RobertFischer/detect-secrets-action@v2.0.0 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '16' + distribution: 'adopt' + cache: gradle + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }} + OUTPUT_PATH: .\local.properties + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Publish + run: ./gradlew $PREVIEW_TASK + maven_Release: if: ${{ github.ref == 'ref/head/master' }} environment: @@ -33,15 +58,17 @@ jobs: with: java-version: '16' distribution: 'adopt' - cache: gradle - - ##Copy the Step below for the other files with the appropriate values + cache: gradle - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH shell: pwsh env: - ENCODED_VALUE: "" - OUTPUT_PATH: "" - + ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }} + OUTPUT_PATH: .\local.properties + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: ${{ secrets.SECRING_GPG }} + OUTPUT_PATH: .\secring.gpg - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Publish @@ -76,31 +103,3 @@ jobs: env: GHR_PATH: current/working/directory/drop/ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - maven_Preview: - if: ${{ github.ref == 'refs/head/dev' }} - environment: - name: maven_central_snapshot - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Easy detect-secrets - uses: RobertFischer/detect-secrets-action@v2.0.0 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '16' - distribution: 'adopt' - cache: gradle - - ##Copy the Step below for the other files with the appropriate values - - run: .\scripts\decodeAndWrite.ps1 -encodedValue $ENCODED_VALUE -outputPath $OUTPUT_PATH - shell: pwsh - env: - ENCODED_VALUE: "" - OUTPUT_PATH: "" - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Publish - run: ./gradlew $PREVIEW_TASK From 581df0f9bdaab790c877f7e8755c86feba507330 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Wed, 8 Sep 2021 02:20:27 -0700 Subject: [PATCH 13/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f0388120b..d55d1919a 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -7,7 +7,8 @@ on: push: branches: [ dev , master ] paths: - - 'src/*' + - 'src/**' + - '.github/**' - '!.gradle/wrapper' - '!.gitignore' - '!LICENSE' From d2fcdab5bcaeaea5eec871014c03a792f6443f99 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 9 Sep 2021 09:52:28 +0300 Subject: [PATCH 14/36] #309 (cherry picked from commit ff401f9b1ef487b25f71d652fb43139a759a219b) --- .../com/microsoft/graph/httpcore/AuthenticationHandler.java | 2 ++ src/main/java/com/microsoft/graph/httpcore/RetryHandler.java | 1 + .../java/com/microsoft/graph/tasks/LargeFileUploadTask.java | 1 + 3 files changed, 4 insertions(+) diff --git a/src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java b/src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java index daf8fc44c..ce125664b 100644 --- a/src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java @@ -62,6 +62,8 @@ public Response intercept(@Nonnull final Chain chain) throws IOException { .build()); } } catch (InterruptedException | ExecutionException ex) { + if (ex instanceof InterruptedException) + Thread.currentThread().interrupt(); throw new IOException(ex); } } diff --git a/src/main/java/com/microsoft/graph/httpcore/RetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/RetryHandler.java index da032a5d4..ed799a7f0 100644 --- a/src/main/java/com/microsoft/graph/httpcore/RetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/RetryHandler.java @@ -111,6 +111,7 @@ && checkStatus(statusCode) && isBuffered(request) try { Thread.sleep(retryInterval); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); logger.logError("error retrying the request", e); } } diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java index 897cc6d0f..227a4dab6 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java @@ -252,6 +252,7 @@ public LargeFileUploadResult upload(@Nullable final int chunkSize, @ try { return uploadAsync(chunkSize, options, progressCallback).get(); } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); throw new ClientException("The request was interrupted", ex); } catch (ExecutionException ex) { throw new ClientException("Error while executing the request", ex); From 5c5567545c2b5b1c1a142412a3ac8e1ccfc85b7c Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 31 Aug 2021 15:54:36 +0300 Subject: [PATCH 15/36] #300 --- .../serializer/DerivedClassIdentifier.java | 30 ++++++++++++++----- .../DerivedClassIdentifierTest.java | 18 +++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 src/test/java/com/microsoft/graph/serializer/DerivedClassIdentifierTest.java diff --git a/src/main/java/com/microsoft/graph/serializer/DerivedClassIdentifier.java b/src/main/java/com/microsoft/graph/serializer/DerivedClassIdentifier.java index e01346a02..563b396c4 100644 --- a/src/main/java/com/microsoft/graph/serializer/DerivedClassIdentifier.java +++ b/src/main/java/com/microsoft/graph/serializer/DerivedClassIdentifier.java @@ -1,9 +1,11 @@ package com.microsoft.graph.serializer; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.CaseFormat; import com.google.gson.JsonObject; import com.microsoft.graph.logger.ILogger; +import java.util.Locale; import java.util.Objects; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -14,12 +16,13 @@ public class DerivedClassIdentifier { private final static String ODATA_TYPE_KEY = "@odata.type"; private final ILogger logger; + /** * Creates a new instance of the dereived class identifier. * @param logger The logger to use. */ public DerivedClassIdentifier(@Nonnull ILogger logger) { - this.logger = Objects.requireNonNull(logger, "logger parameter cannot be null");; + this.logger = Objects.requireNonNull(logger, "logger parameter cannot be null"); } /** @@ -36,14 +39,9 @@ public Class identify(@Nonnull final JsonObject jsonObject, @Nullable final C Objects.requireNonNull(jsonObject, "parameter jsonObject cannot be null"); //Identify the odata.type information if provided if (jsonObject.get(ODATA_TYPE_KEY) != null) { - /** #microsoft.graph.user or #microsoft.graph.callrecords.callrecord */ + // #microsoft.graph.user or #microsoft.graph.callrecords.callrecord final String odataType = jsonObject.get(ODATA_TYPE_KEY).getAsString(); - final int lastDotIndex = odataType.lastIndexOf("."); - final String derivedType = (odataType.substring(0, lastDotIndex) + - ".models." + - CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, - odataType.substring(lastDotIndex + 1))) - .replace("#", "com."); + final String derivedType = oDataTypeToClassName(odataType); try { Class derivedClass = Class.forName(derivedType); //Check that the derived class inherits from the given parent class @@ -61,4 +59,20 @@ public Class identify(@Nonnull final JsonObject jsonObject, @Nullable final C //If there is no defined OData type, return null return null; } + + /** + * Convert {@code @odata.type} to proper java class name + * + * @param odataType to convert + * @return converted class name + */ + @VisibleForTesting + static String oDataTypeToClassName(@Nonnull String odataType) { + Objects.requireNonNull(odataType); + final int lastDotIndex = odataType.lastIndexOf("."); + return (odataType.substring(0, lastDotIndex).toLowerCase(Locale.ROOT) + + ".models." + + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, odataType.substring(lastDotIndex + 1))) + .replace("#", "com."); + } } diff --git a/src/test/java/com/microsoft/graph/serializer/DerivedClassIdentifierTest.java b/src/test/java/com/microsoft/graph/serializer/DerivedClassIdentifierTest.java new file mode 100644 index 000000000..b73a29f25 --- /dev/null +++ b/src/test/java/com/microsoft/graph/serializer/DerivedClassIdentifierTest.java @@ -0,0 +1,18 @@ +package com.microsoft.graph.serializer; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Created by Valentin Popov valentin@archiva.ru on 31.08.2021. + */ +class DerivedClassIdentifierTest { + + @Test + void oDataTypeToClassName() { + Assertions.assertEquals("com.microsoft.graph.models.Message", + DerivedClassIdentifier.oDataTypeToClassName("#Microsoft.Graph.Message")); + } +} From 5d0a0bc44b81e29f953a211791c69c0bc052cf02 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 9 Sep 2021 11:12:35 +0300 Subject: [PATCH 16/36] performance improvement --- .../TokenCredentialAuthProvider.java | 3 ++- .../java/com/microsoft/graph/core/Multipart.java | 4 ++-- .../com/microsoft/graph/http/BaseRequest.java | 2 +- .../microsoft/graph/httpcore/HttpClients.java | 16 +++++++--------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java b/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java index 56e28a443..d51244acf 100644 --- a/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java +++ b/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -27,7 +28,7 @@ public class TokenCredentialAuthProvider extends BaseAuthenticationProvider { * @param tokenCredential Credential object inheriting the TokenCredential interface used to instantiate the Auth Provider */ public TokenCredentialAuthProvider(@Nonnull final TokenCredential tokenCredential) { - this(Arrays.asList(DEFAULT_GRAPH_SCOPE), tokenCredential); + this(Collections.singletonList(DEFAULT_GRAPH_SCOPE), tokenCredential); } /** diff --git a/src/main/java/com/microsoft/graph/core/Multipart.java b/src/main/java/com/microsoft/graph/core/Multipart.java index 0600cac80..ee1031660 100644 --- a/src/main/java/com/microsoft/graph/core/Multipart.java +++ b/src/main/java/com/microsoft/graph/core/Multipart.java @@ -125,7 +125,7 @@ public static String createContentHeaderValue(@Nonnull final String contentValue if(contentDispParameter != null) { for(Map.Entry entry : contentDispParameter.entrySet()) - builder.append(";" + entry.getKey() + "=\"" + entry.getValue() + "\""); + builder.append(";").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); } return builder.toString(); } @@ -140,7 +140,7 @@ private String createPartHeader(Map headers) { if(headers != null) { for(Map.Entry entry : headers.entrySet()) - builder.append(entry.getKey() +": "+entry.getValue() + RETURN); + builder.append(entry.getKey()).append(": ").append(entry.getValue()).append(RETURN); builder.append(RETURN); } else builder.append(defaultPartContent); diff --git a/src/main/java/com/microsoft/graph/http/BaseRequest.java b/src/main/java/com/microsoft/graph/http/BaseRequest.java index 8bc323005..ee1af338c 100644 --- a/src/main/java/com/microsoft/graph/http/BaseRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseRequest.java @@ -228,7 +228,7 @@ private String addFunctionParameters() { requestUrl.append("="); if (option.getValue() != null) { if (option.getValue() instanceof String) { - requestUrl.append("'" + option.getValue() + "'"); + requestUrl.append("'").append(option.getValue()).append("'"); } else { requestUrl.append(option.getValue()); } diff --git a/src/main/java/com/microsoft/graph/httpcore/HttpClients.java b/src/main/java/com/microsoft/graph/httpcore/HttpClients.java index 34ad32aec..e53586c57 100644 --- a/src/main/java/com/microsoft/graph/httpcore/HttpClients.java +++ b/src/main/java/com/microsoft/graph/httpcore/HttpClients.java @@ -1,17 +1,15 @@ package com.microsoft.graph.httpcore; import com.microsoft.graph.authentication.IAuthenticationProvider; - -import java.util.Arrays; -import java.util.Objects; - -import javax.annotation.Nullable; -import javax.annotation.Nonnull; - import okhttp3.Interceptor; import okhttp3.OkHttpClient; -import okhttp3.Protocol; import okhttp3.OkHttpClient.Builder; +import okhttp3.Protocol; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Collections; +import java.util.Objects; /** * Builder to get a custom HttpClient to be used for requests against Microsoft Graph @@ -33,7 +31,7 @@ public static Builder custom() { .addInterceptor(new TelemetryHandler()) .followRedirects(false) .followSslRedirects(false) - .protocols(Arrays.asList(Protocol.HTTP_1_1)); //https://stackoverflow.com/questions/62031298/sockettimeout-on-java-11-but-not-on-java-8 + .protocols(Collections.singletonList(Protocol.HTTP_1_1)); //https://stackoverflow.com/questions/62031298/sockettimeout-on-java-11-but-not-on-java-8 } /** From ffb2962e3d8a48288748007937ba8ff5877f04e9 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 9 Sep 2021 11:13:28 +0300 Subject: [PATCH 17/36] fix string compare with = not equals --- .../java/com/microsoft/graph/httpcore/TelemetryHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java index 44632a60c..5eba9b79e 100644 --- a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.lang.reflect.Field; +import java.util.Objects; import javax.annotation.Nonnull; @@ -57,8 +58,8 @@ public Response intercept(@Nonnull final Chain chain) throws IOException { final String javaVersion = System.getProperty("java.version"); final String androidVersion = getAndroidAPILevel(); final String sdkversion_value = GRAPH_VERSION_PREFIX + "/" + VERSION + " " + featureUsage + - (javaVersion == DEFAULT_VERSION_VALUE ? "" : (", " + JAVA_VERSION_PREFIX + "/" + javaVersion)) + - (androidVersion == DEFAULT_VERSION_VALUE ? "" : (", " + ANDROID_VERSION_PREFIX + "/" + androidVersion)); + (Objects.equals(javaVersion, DEFAULT_VERSION_VALUE) ? "" : (", " + JAVA_VERSION_PREFIX + "/" + javaVersion)) + + (Objects.equals(androidVersion, DEFAULT_VERSION_VALUE) ? "" : (", " + ANDROID_VERSION_PREFIX + "/" + androidVersion)); telemetryAddedBuilder.addHeader(SDK_VERSION, sdkversion_value); if(request.header(CLIENT_REQUEST_ID) == null) { From a20229844f3e6492efe3952fcd8810b7ac721933 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 9 Sep 2021 11:26:34 +0300 Subject: [PATCH 18/36] java 8 code migration style --- .../TokenCredentialAuthProvider.java | 7 +- .../graph/content/BatchRequestContent.java | 4 +- .../graph/core/CustomRequestBuilder.java | 2 +- .../com/microsoft/graph/core/IBaseClient.java | 2 +- .../com/microsoft/graph/core/Multipart.java | 2 +- .../http/BaseActionCollectionRequest.java | 2 +- .../graph/http/BaseCollectionPage.java | 2 +- .../http/BaseEntityCollectionRequest.java | 2 +- .../http/BaseFunctionCollectionRequest.java | 2 +- .../com/microsoft/graph/http/BaseRequest.java | 4 +- .../microsoft/graph/http/CustomRequest.java | 2 +- .../microsoft/graph/http/GraphInnerError.java | 7 +- .../graph/httpcore/ChaosHttpHandler.java | 1 - .../middlewareoption/RedirectOptions.java | 7 +- .../middlewareoption/RetryOptions.java | 7 +- .../graph/serializer/DefaultSerializer.java | 33 +- .../serializer/EdmNativeTypeSerializer.java | 2 - .../graph/serializer/GsonFactory.java | 298 +++++------------- .../serializer/OffsetDateTimeSerializer.java | 7 - .../graph/tasks/LargeFileUploadRequest.java | 2 +- .../graph/tasks/LargeFileUploadTask.java | 8 +- 21 files changed, 123 insertions(+), 280 deletions(-) diff --git a/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java b/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java index d51244acf..555dc34b2 100644 --- a/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java +++ b/src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java @@ -1,17 +1,16 @@ package com.microsoft.graph.authentication; +import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; +import javax.annotation.Nonnull; import java.net.URL; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - /** * An implementation of the Authentication Provider with Azure-identity */ @@ -57,7 +56,7 @@ public CompletableFuture getAuthorizationTokenAsync(@Nonnull final URL r return this.tokenCredential .getToken(this.context) .toFuture() - .thenApply(resp -> resp.getToken()); + .thenApply(AccessToken::getToken); else return CompletableFuture.completedFuture((String)null); } diff --git a/src/main/java/com/microsoft/graph/content/BatchRequestContent.java b/src/main/java/com/microsoft/graph/content/BatchRequestContent.java index 935f24c1c..0f0dca716 100644 --- a/src/main/java/com/microsoft/graph/content/BatchRequestContent.java +++ b/src/main/java/com/microsoft/graph/content/BatchRequestContent.java @@ -110,7 +110,7 @@ public String addBatchRequestStep(@Nonnull final IHttpRequest request, @Nonn url = protocolAndHostReplacementMatcher.replaceAll(""); body = serializableBody; method = httpMethod.toString().toUpperCase(Locale.getDefault()); - dependsOn = dependsOnRequestsIds != null && dependsOnRequestsIds.length > 0 ? new HashSet(Arrays.asList(dependsOnRequestsIds)) : null; + dependsOn = dependsOnRequestsIds != null && dependsOnRequestsIds.length > 0 ? new HashSet<>(Arrays.asList(dependsOnRequestsIds)) : null; id = getNextRequestId(); }}; @@ -141,7 +141,7 @@ public void removeBatchRequestStepWithId(@Nonnull final String ...stepIds) { requests.removeIf(x -> stepId.equals(x.id)); for(final BatchRequestStep step : requests) { if(step.dependsOn != null) { - step.dependsOn.removeIf(x -> stepId.equals(x)); + step.dependsOn.removeIf(stepId::equals); if(step.dependsOn.isEmpty()) step.dependsOn = null; // so we don't send dependsOn: [] over the wire } diff --git a/src/main/java/com/microsoft/graph/core/CustomRequestBuilder.java b/src/main/java/com/microsoft/graph/core/CustomRequestBuilder.java index 5915eb32b..468dcdde8 100644 --- a/src/main/java/com/microsoft/graph/core/CustomRequestBuilder.java +++ b/src/main/java/com/microsoft/graph/core/CustomRequestBuilder.java @@ -51,6 +51,6 @@ public CustomRequest buildRequest(@Nullable final com.microsoft.graph.options */ @Nonnull public CustomRequest buildRequest(@Nullable final List requestOptions) { - return new CustomRequest(getRequestUrl(), getClient(), requestOptions, responseType); + return new CustomRequest<>(getRequestUrl(), getClient(), requestOptions, responseType); } } diff --git a/src/main/java/com/microsoft/graph/core/IBaseClient.java b/src/main/java/com/microsoft/graph/core/IBaseClient.java index c260831a8..b3b0e7d32 100644 --- a/src/main/java/com/microsoft/graph/core/IBaseClient.java +++ b/src/main/java/com/microsoft/graph/core/IBaseClient.java @@ -100,7 +100,7 @@ public interface IBaseClient { * @return a request builder to execute a batch. */ @Nonnull - public BatchRequestBuilder batch(); + BatchRequestBuilder batch(); /** * Gets the service SDK version if the service SDK is in use, null otherwise diff --git a/src/main/java/com/microsoft/graph/core/Multipart.java b/src/main/java/com/microsoft/graph/core/Multipart.java index ee1031660..878f3e84c 100644 --- a/src/main/java/com/microsoft/graph/core/Multipart.java +++ b/src/main/java/com/microsoft/graph/core/Multipart.java @@ -35,7 +35,7 @@ public class Multipart { */ public Multipart() { out = new ByteArrayOutputStream(); - boundary = "part_" + new BigInteger(130, new SecureRandom()).toString(); + boundary = "part_" + new BigInteger(130, new SecureRandom()); } /** diff --git a/src/main/java/com/microsoft/graph/http/BaseActionCollectionRequest.java b/src/main/java/com/microsoft/graph/http/BaseActionCollectionRequest.java index a9c38b4ec..caff0a918 100644 --- a/src/main/java/com/microsoft/graph/http/BaseActionCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseActionCollectionRequest.java @@ -81,7 +81,7 @@ public java.util.concurrent.CompletableFuture postAsync() { .sendAsync(this, responseCollectionClass, bodyToSend) - .thenApply(r -> buildFromResponse(r)); + .thenApply(this::buildFromResponse); } /** * Invokes the method and returns the resulting collection of objects diff --git a/src/main/java/com/microsoft/graph/http/BaseCollectionPage.java b/src/main/java/com/microsoft/graph/http/BaseCollectionPage.java index fce85908a..b7fe35590 100644 --- a/src/main/java/com/microsoft/graph/http/BaseCollectionPage.java +++ b/src/main/java/com/microsoft/graph/http/BaseCollectionPage.java @@ -72,7 +72,7 @@ public BaseCollectionPage(@Nonnull final ICollectionResponse response, @Nulla public BaseCollectionPage(@Nonnull final List pageContents, @Nullable final T2 nextRequestBuilder) { // CollectionPages are never directly modifiable, either 'update'/'delete' the specific child or 'add' the new // object to the 'children' of the collection. - this.pageContents = Collections.unmodifiableList(pageContents == null ? new ArrayList() : pageContents); + this.pageContents = Collections.unmodifiableList(pageContents == null ? new ArrayList<>() : pageContents); requestBuilder = nextRequestBuilder; } diff --git a/src/main/java/com/microsoft/graph/http/BaseEntityCollectionRequest.java b/src/main/java/com/microsoft/graph/http/BaseEntityCollectionRequest.java index dd725b40b..aefb79604 100644 --- a/src/main/java/com/microsoft/graph/http/BaseEntityCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseEntityCollectionRequest.java @@ -66,7 +66,7 @@ public BaseEntityCollectionRequest(@Nonnull final String requestUrl, */ @Nonnull public java.util.concurrent.CompletableFuture getAsync() { - return sendAsync().thenApply(r -> buildFromResponse(r)); + return sendAsync().thenApply(this::buildFromResponse); } /** * Gets the collection of items diff --git a/src/main/java/com/microsoft/graph/http/BaseFunctionCollectionRequest.java b/src/main/java/com/microsoft/graph/http/BaseFunctionCollectionRequest.java index 19ca7a08f..8e524316a 100644 --- a/src/main/java/com/microsoft/graph/http/BaseFunctionCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseFunctionCollectionRequest.java @@ -66,7 +66,7 @@ public BaseFunctionCollectionRequest(@Nonnull final String requestUrl, */ @Nonnull public java.util.concurrent.CompletableFuture getAsync() { - return sendAsync().thenApply(r -> buildFromResponse(r)); + return sendAsync().thenApply(this::buildFromResponse); } /** diff --git a/src/main/java/com/microsoft/graph/http/BaseRequest.java b/src/main/java/com/microsoft/graph/http/BaseRequest.java index ee1af338c..5e0c537b5 100644 --- a/src/main/java/com/microsoft/graph/http/BaseRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseRequest.java @@ -193,9 +193,9 @@ public URL getRequestUrl() { return new URL(uriBuilder.build().toString()); } catch (final MalformedURLException e) { if (this instanceof CustomRequest) { - this.getClient().getLogger().logError("Invalid custom URL: " + uriBuilder.toString(), e); + this.getClient().getLogger().logError("Invalid custom URL: " + uriBuilder, e); } else { - throw new ClientException("Invalid URL: " + uriBuilder.toString(), e); + throw new ClientException("Invalid URL: " + uriBuilder, e); } } return null; diff --git a/src/main/java/com/microsoft/graph/http/CustomRequest.java b/src/main/java/com/microsoft/graph/http/CustomRequest.java index 5d2b2f7c5..73f7c1f5a 100644 --- a/src/main/java/com/microsoft/graph/http/CustomRequest.java +++ b/src/main/java/com/microsoft/graph/http/CustomRequest.java @@ -64,7 +64,7 @@ public CustomRequest(@Nonnull final String requestUrl, @Nonnull final IBaseClien */ @Nonnull public static CustomRequest create(@Nonnull final String requestUrl, @Nonnull final IBaseClient client, @Nullable final java.util.List requestOptions) { - return new CustomRequest(requestUrl, client, requestOptions, JsonObject.class); + return new CustomRequest<>(requestUrl, client, requestOptions, JsonObject.class); } /** diff --git a/src/main/java/com/microsoft/graph/http/GraphInnerError.java b/src/main/java/com/microsoft/graph/http/GraphInnerError.java index 9516c1845..b46b1b7f6 100644 --- a/src/main/java/com/microsoft/graph/http/GraphInnerError.java +++ b/src/main/java/com/microsoft/graph/http/GraphInnerError.java @@ -1,16 +1,16 @@ // ------------------------------------------------------------------------------ // Copyright (c) 2017 Microsoft Corporation -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sub-license, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import javax.annotation.Nullable; -import javax.annotation.Nonnull; /** * Represents an inner error returned by the service diff --git a/src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java b/src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java index e4eec8304..b1df1b4ee 100644 --- a/src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.concurrent.ThreadLocalRandom; -import javax.annotation.Nullable; import javax.annotation.Nonnull; import com.microsoft.graph.httpcore.middlewareoption.MiddlewareType; diff --git a/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptions.java b/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptions.java index 72c944db1..3016c0a83 100644 --- a/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptions.java +++ b/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptions.java @@ -23,12 +23,7 @@ public class RedirectOptions implements IMiddlewareControl{ /** * Default redirect evaluation, always follow redirect information. */ - public static final IShouldRedirect DEFAULT_SHOULD_REDIRECT = new IShouldRedirect() { - @Override - public boolean shouldRedirect(Response response) { - return true; - } - }; + public static final IShouldRedirect DEFAULT_SHOULD_REDIRECT = response -> true; /** * Create default instance of redirect options, with default values of max redirects and should redirect diff --git a/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptions.java b/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptions.java index ba9418ad8..425a71e13 100644 --- a/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptions.java +++ b/src/main/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptions.java @@ -14,12 +14,7 @@ public class RetryOptions implements IMiddlewareControl { /** * Default retry evaluation, always retry. */ - public static final IShouldRetry DEFAULT_SHOULD_RETRY = new IShouldRetry() { - @Override - public boolean shouldRetry(long delay, int executionCount, Request request, Response response) { - return true; - } - }; + public static final IShouldRetry DEFAULT_SHOULD_RETRY = (delay, executionCount, request, response) -> true; private int mMaxRetries; /** diff --git a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java index 99c31906e..931a5b5e6 100644 --- a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java +++ b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java @@ -32,6 +32,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -98,7 +99,7 @@ public T deserializeObject(@Nonnull final String inputString, @Nonnull final public T deserializeObject(@Nonnull final InputStream inputStream, @Nonnull final Class clazz, @Nullable final Map> responseHeaders) { Objects.requireNonNull(inputStream, "parameter inputStream cannot be null"); T result = null; - try (final InputStreamReader streamReader = new InputStreamReader(inputStream, "UTF-8")) { + try (final InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { final JsonElement rawElement = gson.fromJson(streamReader, JsonElement.class); result = deserializeObject(rawElement, clazz, responseHeaders); } catch (IOException ex) { @@ -155,24 +156,22 @@ private void setChildAdditionalData(final IJsonBackedObject serializedObject, fi // If the object is a HashMap, iterate through its children @SuppressWarnings("unchecked") final HashMap serializableChildren = (HashMap) fieldObject; - final Iterator> it = serializableChildren.entrySet().iterator(); - while (it.hasNext()) { - final Map.Entry pair = (Map.Entry)it.next(); - final Object child = pair.getValue(); + for (Entry pair : serializableChildren.entrySet()) { + final Object child = pair.getValue(); - // If the item is a valid Graph object, set its additional data - if (child instanceof IJsonBackedObject) { - final AdditionalDataManager childAdditionalDataManager = ((IJsonBackedObject) child).additionalDataManager(); - final JsonElement fieldElement = rawJson.get(field.getName()); - if(fieldElement != null && fieldElement.isJsonObject() - && fieldElement.getAsJsonObject().get(pair.getKey()) != null - && fieldElement.getAsJsonObject().get(pair.getKey()).isJsonObject()) { - childAdditionalDataManager.setAdditionalData(fieldElement.getAsJsonObject().get(pair.getKey()).getAsJsonObject()); - setChildAdditionalData((IJsonBackedObject) child,fieldElement.getAsJsonObject().get(pair.getKey()).getAsJsonObject()); - } - } - } + // If the item is a valid Graph object, set its additional data + if (child instanceof IJsonBackedObject) { + final AdditionalDataManager childAdditionalDataManager = ((IJsonBackedObject) child).additionalDataManager(); + final JsonElement fieldElement = rawJson.get(field.getName()); + if (fieldElement != null && fieldElement.isJsonObject() + && fieldElement.getAsJsonObject().get(pair.getKey()) != null + && fieldElement.getAsJsonObject().get(pair.getKey()).isJsonObject()) { + childAdditionalDataManager.setAdditionalData(fieldElement.getAsJsonObject().get(pair.getKey()).getAsJsonObject()); + setChildAdditionalData((IJsonBackedObject) child, fieldElement.getAsJsonObject().get(pair.getKey()).getAsJsonObject()); + } + } + } } // If the object is a list of Graph objects, iterate through elements else if (fieldObject instanceof List) { diff --git a/src/main/java/com/microsoft/graph/serializer/EdmNativeTypeSerializer.java b/src/main/java/com/microsoft/graph/serializer/EdmNativeTypeSerializer.java index 5871ac4e4..1a7fd1a2f 100644 --- a/src/main/java/com/microsoft/graph/serializer/EdmNativeTypeSerializer.java +++ b/src/main/java/com/microsoft/graph/serializer/EdmNativeTypeSerializer.java @@ -1,11 +1,9 @@ package com.microsoft.graph.serializer; -import java.lang.reflect.Type; import java.math.BigDecimal; import java.util.UUID; import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; import com.microsoft.graph.logger.ILogger; import javax.annotation.Nonnull; diff --git a/src/main/java/com/microsoft/graph/serializer/GsonFactory.java b/src/main/java/com/microsoft/graph/serializer/GsonFactory.java index 4b305e5ae..e507ece0c 100644 --- a/src/main/java/com/microsoft/graph/serializer/GsonFactory.java +++ b/src/main/java/com/microsoft/graph/serializer/GsonFactory.java @@ -90,263 +90,129 @@ public static Gson getGsonInstance(@Nonnull final ILogger logger) { @Nonnull public static Gson getGsonInstance(@Nonnull final ILogger logger, final boolean serializeNulls) { Objects.requireNonNull(logger, "parameter logger cannot be null"); - final JsonSerializer calendarJsonSerializer = new JsonSerializer() { - @Override - public JsonElement serialize(final OffsetDateTime src, - final Type typeOfSrc, - final JsonSerializationContext context) { - if (src == null) { - return null; - } - try { - return new JsonPrimitive(OffsetDateTimeSerializer.serialize(src)); - } catch (final Exception e) { - logger.logError(PARSING_MESSAGE + src, e); - return null; - } + final JsonSerializer calendarJsonSerializer = (src, typeOfSrc, context) -> { + if (src == null) { + return null; } - }; - - final JsonDeserializer calendarJsonDeserializer = new JsonDeserializer() { - @Override - public OffsetDateTime deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - if (json == null) { - return null; - } - try { - return OffsetDateTimeSerializer.deserialize(json.getAsString()); - } catch (final ParseException e) { - logger.logError(PARSING_MESSAGE + json.getAsString(), e); - return null; - } + try { + return new JsonPrimitive(OffsetDateTimeSerializer.serialize(src)); + } catch (final Exception e) { + logger.logError(PARSING_MESSAGE + src, e); + return null; } }; - final JsonSerializer byteArrayJsonSerializer = new JsonSerializer() { - @Override - public JsonElement serialize(final byte[] src, - final Type typeOfSrc, - final JsonSerializationContext context) { - if (src == null) { - return null; - } - try { - return new JsonPrimitive(ByteArraySerializer.serialize(src)); - } catch (final Exception e) { - logger.logError(PARSING_MESSAGE + Arrays.toString(src), e); - return null; - } + final JsonDeserializer calendarJsonDeserializer = (json, typeOfT, context) -> { + if (json == null) { + return null; } - }; - - final JsonDeserializer byteArrayJsonDeserializer = new JsonDeserializer() { - @Override - public byte[] deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - if (json == null) { - return null; - } - try { - return ByteArraySerializer.deserialize(json.getAsString()); - } catch (final ParseException e) { - logger.logError(PARSING_MESSAGE + json.getAsString(), e); - return null; - } + try { + return OffsetDateTimeSerializer.deserialize(json.getAsString()); + } catch (final ParseException e) { + logger.logError(PARSING_MESSAGE + json.getAsString(), e); + return null; } }; - final JsonSerializer dateJsonSerializer = new JsonSerializer() { - @Override - public JsonElement serialize(final DateOnly src, - final Type typeOfSrc, - final JsonSerializationContext context) { - if (src == null) { - return null; - } - return new JsonPrimitive(src.toString()); + final JsonSerializer byteArrayJsonSerializer = (src, typeOfSrc, context) -> { + if (src == null) { + return null; } - }; - - final JsonDeserializer dateJsonDeserializer = new JsonDeserializer() { - @Override - public DateOnly deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - if (json == null) { - return null; - } - - try { - return DateOnly.parse(json.getAsString()); - } catch (final ParseException e) { - logger.logError(PARSING_MESSAGE + json.getAsString(), e); - return null; - } + try { + return new JsonPrimitive(ByteArraySerializer.serialize(src)); + } catch (final Exception e) { + logger.logError(PARSING_MESSAGE + Arrays.toString(src), e); + return null; } }; - final EnumSetSerializer eSetSerializer = new EnumSetSerializer(logger); - final JsonSerializer> enumSetJsonSerializer = new JsonSerializer>() { - @Override - public JsonElement serialize(final EnumSet src, - final Type typeOfSrc, - final JsonSerializationContext context) { - if (src == null || src.isEmpty()) { - return null; - } - - return eSetSerializer.serialize(src); + final JsonDeserializer byteArrayJsonDeserializer = (json, typeOfT, context) -> { + if (json == null) { + return null; } - }; - - final JsonDeserializer> enumSetJsonDeserializer = new JsonDeserializer>() { - @Override - public EnumSet deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - if (json == null) { - return null; - } - - return eSetSerializer.deserialize(typeOfT, json.getAsString()); + try { + return ByteArraySerializer.deserialize(json.getAsString()); + } catch (final ParseException e) { + logger.logError(PARSING_MESSAGE + json.getAsString(), e); + return null; } }; - final JsonSerializer durationJsonSerializer = new JsonSerializer() { - @Override - public JsonElement serialize(final Duration src, - final Type typeOfSrc, - final JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); + final JsonSerializer dateJsonSerializer = (src, typeOfSrc, context) -> { + if (src == null) { + return null; } + return new JsonPrimitive(src.toString()); }; - final JsonDeserializer durationJsonDeserializer = new JsonDeserializer() { - @Override - public Duration deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - try { - return DatatypeFactory.newInstance().newDuration(json.getAsString()); - } catch (Exception e) { - return null; - } + final JsonDeserializer dateJsonDeserializer = (json, typeOfT, context) -> { + if (json == null) { + return null; } - }; - final JsonSerializer> collectionPageSerializer = new JsonSerializer>() { - @Override - public JsonElement serialize(final BaseCollectionPage src, - final Type typeOfSrc, - final JsonSerializationContext context) { - return CollectionPageSerializer.serialize(src, logger); + try { + return DateOnly.parse(json.getAsString()); + } catch (final ParseException e) { + logger.logError(PARSING_MESSAGE + json.getAsString(), e); + return null; } }; + final EnumSetSerializer eSetSerializer = new EnumSetSerializer(logger); - final JsonDeserializer> collectionPageDeserializer = new JsonDeserializer>() { - @Override - public BaseCollectionPage deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return CollectionPageSerializer.deserialize(json, typeOfT, logger); + final JsonSerializer> enumSetJsonSerializer = (src, typeOfSrc, context) -> { + if (src == null || src.isEmpty()) { + return null; } - }; - final JsonDeserializer> collectionResponseDeserializer = new JsonDeserializer>() { - @Override - public BaseCollectionResponse deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return CollectionResponseDeserializer.deserialize(json, typeOfT, logger); - } - }; - final JsonDeserializer timeOfDayJsonDeserializer = new JsonDeserializer() { - @Override - public TimeOfDay deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - try { - return TimeOfDay.parse(json.getAsString()); - } catch (Exception e) { - return null; - } - } + return eSetSerializer.serialize(src); }; - final JsonSerializer timeOfDayJsonSerializer = new JsonSerializer() { - @Override - public JsonElement serialize(final TimeOfDay src, - final Type typeOfSrc, - final JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); + final JsonDeserializer> enumSetJsonDeserializer = (json, typeOfT, context) -> { + if (json == null) { + return null; } - }; - final JsonDeserializer booleanJsonDeserializer = new JsonDeserializer() { - @Override - public Boolean deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, Boolean.class, logger); - } + return eSetSerializer.deserialize(typeOfT, json.getAsString()); }; - final JsonDeserializer stringJsonDeserializer = new JsonDeserializer() { - @Override - public String deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, String.class, logger); - } - }; + final JsonSerializer durationJsonSerializer = (src, typeOfSrc, context) -> new JsonPrimitive(src.toString()); - final JsonDeserializer bigDecimalJsonDeserializer = new JsonDeserializer() { - @Override - public BigDecimal deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, BigDecimal.class, logger); + final JsonDeserializer durationJsonDeserializer = (json, typeOfT, context) -> { + try { + return DatatypeFactory.newInstance().newDuration(json.getAsString()); + } catch (Exception e) { + return null; } }; - final JsonDeserializer integerJsonDeserializer = new JsonDeserializer() { - @Override - public Integer deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, Integer.class, logger); - } - }; + final JsonSerializer> collectionPageSerializer = (src, typeOfSrc, context) -> CollectionPageSerializer.serialize(src, logger); - final JsonDeserializer longJsonDeserializer = new JsonDeserializer() { - @Override - public Long deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, Long.class, logger); - } - }; + final JsonDeserializer> collectionPageDeserializer = (json, typeOfT, context) -> CollectionPageSerializer.deserialize(json, typeOfT, logger); + final JsonDeserializer> collectionResponseDeserializer = (json, typeOfT, context) -> CollectionResponseDeserializer.deserialize(json, typeOfT, logger); - final JsonDeserializer uuidJsonDeserializer = new JsonDeserializer() { - @Override - public UUID deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, UUID.class, logger); + final JsonDeserializer timeOfDayJsonDeserializer = (json, typeOfT, context) -> { + try { + return TimeOfDay.parse(json.getAsString()); + } catch (Exception e) { + return null; } }; - final JsonDeserializer floatJsonDeserializer = new JsonDeserializer() { - @Override - public Float deserialize(final JsonElement json, - final Type typeOfT, - final JsonDeserializationContext context) throws JsonParseException { - return EdmNativeTypeSerializer.deserialize(json, Float.class, logger); - } - }; + final JsonSerializer timeOfDayJsonSerializer = (src, typeOfSrc, context) -> new JsonPrimitive(src.toString()); + + final JsonDeserializer booleanJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, Boolean.class, logger); + + final JsonDeserializer stringJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, String.class, logger); + + final JsonDeserializer bigDecimalJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, BigDecimal.class, logger); + + final JsonDeserializer integerJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, Integer.class, logger); + + final JsonDeserializer longJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, Long.class, logger); + + final JsonDeserializer uuidJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, UUID.class, logger); + + final JsonDeserializer floatJsonDeserializer = (json, typeOfT, context) -> EdmNativeTypeSerializer.deserialize(json, Float.class, logger); GsonBuilder builder = new GsonBuilder(); if (serializeNulls) { diff --git a/src/main/java/com/microsoft/graph/serializer/OffsetDateTimeSerializer.java b/src/main/java/com/microsoft/graph/serializer/OffsetDateTimeSerializer.java index 2e8288176..daf22183d 100644 --- a/src/main/java/com/microsoft/graph/serializer/OffsetDateTimeSerializer.java +++ b/src/main/java/com/microsoft/graph/serializer/OffsetDateTimeSerializer.java @@ -23,17 +23,10 @@ package com.microsoft.graph.serializer; import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; import java.util.Objects; -import java.util.TimeZone; import java.util.regex.Pattern; import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.ChronoField; -import java.time.temporal.TemporalField; import javax.annotation.Nullable; import javax.annotation.Nonnull; diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadRequest.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadRequest.java index a36f94af6..ba2f67785 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadRequest.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadRequest.java @@ -103,7 +103,7 @@ public LargeFileUploadResponse upload( if (result != null && (result.chunkCompleted() || result.uploadCompleted())) { return result; } else - return new LargeFileUploadResponse( + return new LargeFileUploadResponse<>( new ClientException("Upload session failed.", result == null ? null : result.getError())); } } diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java index 227a4dab6..78da111b2 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java @@ -115,7 +115,7 @@ public LargeFileUploadTask(@Nonnull final IUploadSession uploadSession, this.inputStream = Objects.requireNonNull(inputStream, "Input stream is null."); this.streamSize = streamSize; this.uploadUrl = uploadSession.getUploadUrl(); - this.responseHandler = new LargeFileUploadResponseHandler(uploadTypeClass, uploadSession.getClass()); + this.responseHandler = new LargeFileUploadResponseHandler<>(uploadTypeClass, uploadSession.getClass()); } /** @@ -169,7 +169,7 @@ public CompletableFuture> uploadAsync(@Nullabl if(progressCallback != null) { progressCallback.progress(this.streamSize, this.streamSize); } - final LargeFileUploadResult result = new LargeFileUploadResult(); + final LargeFileUploadResult result = new LargeFileUploadResult<>(); if (response.getItem() != null) { result.responseBody = response.getItem(); } @@ -190,12 +190,12 @@ public CompletableFuture> uploadAsync(@Nullabl return failedFuture(new ClientException("Upload did not complete", null)); } private CompletableFuture> completedFuture(final LargeFileUploadResult result) { // CompletableFuture.completedFuture(result.getItem()); missing on android - final CompletableFuture> fut = new CompletableFuture>(); + final CompletableFuture> fut = new CompletableFuture<>(); fut.complete(result); return fut; } private CompletableFuture> failedFuture(ClientException ex) { // CompletableFuture.failedFuture not available on android - final CompletableFuture> fut = new CompletableFuture>(); + final CompletableFuture> fut = new CompletableFuture<>(); fut.completeExceptionally(ex); return fut; } From d6a2aa0044354a7f86bf0d59c124918dd81bc8d2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 9 Sep 2021 05:15:21 -0700 Subject: [PATCH 19/36] Apply suggestions from code review --- .../java/com/microsoft/graph/httpcore/TelemetryHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java index 5eba9b79e..0c0b924b6 100644 --- a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java @@ -58,8 +58,8 @@ public Response intercept(@Nonnull final Chain chain) throws IOException { final String javaVersion = System.getProperty("java.version"); final String androidVersion = getAndroidAPILevel(); final String sdkversion_value = GRAPH_VERSION_PREFIX + "/" + VERSION + " " + featureUsage + - (Objects.equals(javaVersion, DEFAULT_VERSION_VALUE) ? "" : (", " + JAVA_VERSION_PREFIX + "/" + javaVersion)) + - (Objects.equals(androidVersion, DEFAULT_VERSION_VALUE) ? "" : (", " + ANDROID_VERSION_PREFIX + "/" + androidVersion)); + (DEFAULT_VERSION_VALUE.equals(javaVersion) ? "" : (", " + JAVA_VERSION_PREFIX + "/" + javaVersion)) + + (DEFAULT_VERSION_VALUE.equals(androidVersion) ? "" : (", " + ANDROID_VERSION_PREFIX + "/" + androidVersion)); telemetryAddedBuilder.addHeader(SDK_VERSION, sdkversion_value); if(request.header(CLIENT_REQUEST_ID) == null) { From dd30785b6fc44ea4e41e8eb79ac436d9377af22f Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 9 Sep 2021 16:03:04 -0700 Subject: [PATCH 20/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index d55d1919a..0154c87a8 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -99,8 +99,10 @@ jobs: with: name: drop path: drop - - name: GitHub Releases - uses: fnkr/github-action-ghr@v1.3 + - name: Github Release + uses: elgohr/Github-Release-Action@v3.1 env: - GHR_PATH: current/working/directory/drop/ - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + args: MS-Graph-SDK-Java-Core Release + From 0f83e1df2c23f1b555f0b548cec9844538379d9a Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Fri, 10 Sep 2021 04:51:03 -0700 Subject: [PATCH 21/36] Merge pull request #303 from microsoftgraph/rsh/addBuildWorkflow Add Build Workflow --- .github/workflows/gradle-build.yml | 64 ++++++++++++++++++ .secrets.baseline | 100 +++++++++++++++++++++++++++++ scripts/decodeAndWrite.ps1 | 31 +++++++++ 3 files changed, 195 insertions(+) create mode 100644 .github/workflows/gradle-build.yml create mode 100644 .secrets.baseline create mode 100644 scripts/decodeAndWrite.ps1 diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml new file mode 100644 index 000000000..57fc61ddf --- /dev/null +++ b/.github/workflows/gradle-build.yml @@ -0,0 +1,64 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + pull_request: + branches: [ dev, master ] + paths: + - 'src/**' + - '.github/**' + - '!.gradle/wrapper' + - '!.gitignore' + - '!LICENSE' + - '!THIRD PARTY NOTICES' + - '!*.md' + - '*.gradle' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 16 + uses: actions/setup-java@v2 + with: + java-version: '16' + distribution: 'adopt' + cache: gradle + - name: Easy detect-secrets + uses: RobertFischer/detect-secrets-action@v2.0.0 + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }} + OUPUT_PATH: .\local.properties + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: ${{ secrets.SECRING_GPG }} + OUPUT_PATH: .\secring.gpg + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Upload a Build Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: drop + path: | + **/libs/* + build/generated-pom.xml + build/generated-pom.xml.asc + build.gradle + gradlew + gradlew.bat + settings.gradle + gradle.properties + **/gradle/** + Scripts/** + + + diff --git a/.secrets.baseline b/.secrets.baseline new file mode 100644 index 000000000..b83d75a8c --- /dev/null +++ b/.secrets.baseline @@ -0,0 +1,100 @@ +{ + "version": "1.0.3", + "plugins_used": [ + { + "name": "ArtifactoryDetector" + }, + { + "name": "AWSKeyDetector" + }, + { + "name": "AzureStorageKeyDetector" + }, + { + "name": "Base64HighEntropyString", + "limit": 4.5 + }, + { + "name": "BasicAuthDetector" + }, + { + "name": "CloudantDetector" + }, + { + "name": "HexHighEntropyString", + "limit": 3.0 + }, + { + "name": "IbmCloudIamDetector" + }, + { + "name": "IbmCosHmacDetector" + }, + { + "name": "JwtTokenDetector" + }, + { + "name": "KeywordDetector", + "keyword_exclude": "" + }, + { + "name": "MailchimpDetector" + }, + { + "name": "NpmDetector" + }, + { + "name": "PrivateKeyDetector" + }, + { + "name": "SlackDetector" + }, + { + "name": "SoftlayerDetector" + }, + { + "name": "SquareOAuthDetector" + }, + { + "name": "StripeDetector" + }, + { + "name": "TwilioKeyDetector" + } + ], + "filters_used": [ + { + "path": "detect_secrets.filters.allowlist.is_line_allowlisted" + }, + { + "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", + "min_level": 2 + }, + { + "path": "detect_secrets.filters.heuristic.is_indirect_reference" + }, + { + "path": "detect_secrets.filters.heuristic.is_likely_id_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_potential_uuid" + }, + { + "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign" + }, + { + "path": "detect_secrets.filters.heuristic.is_sequential_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_templated_secret" + }, + { + "path": "detect_secrets.filters.regex.should_exclude_file", + "pattern": [ + "gradle.properties" + ] + } + ], + "results": {}, + "generated_at": "2021-09-09T20:53:20Z" +} diff --git a/scripts/decodeAndWrite.ps1 b/scripts/decodeAndWrite.ps1 new file mode 100644 index 000000000..8a0045bae --- /dev/null +++ b/scripts/decodeAndWrite.ps1 @@ -0,0 +1,31 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# +.Synopsis + Decode the encoded string and write it to a local file. +.Description + Recieves an encoded string value and decodes it using base64. + Write the new decoded string to a local file for later consumption. +.Parameter encodedValue + The encoded string we wish to decode. +.Parameter outputPath + The file path that we wish to write the decoded value to. +#> + +Param( + [string]$encodedValue , + [string]$outputPath +) + +if($outputPath -eq "" -or $null -eq $outputPath) { + Write-Output "Value of Variable: outputPath is Null or Empty. Exiting." + Exit +} +if($encodedValue -eq "" -or $null -eq $encodedValue) { + Write-Output "Value of Variable: encodedValue is Null of Empty. Exiting." + Exit +} + +$decodedValue = [System.Convert]::FromBase64String($encodedValue) +Set-Content $outputPath -Value $decodedValue -Encoding Byte From 1c89abb289e83333d881348d676beb024a662fd3 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 10 Sep 2021 04:52:40 -0700 Subject: [PATCH 22/36] - removes ADO pipeline definition --- .azure-pipelines/buildAndPackage.yml | 111 ------------------ .../templates/build/build-and-coverage.yml | 16 --- .../templates/build/checkout-and-credscan.yml | 9 -- .../templates/build/publish-artefacts.yml | 22 ---- .azure-pipelines/templates/copy-and-build.yml | 25 ---- .../templates/download-artifacts.yml | 14 --- .azure-pipelines/templates/install-java.yml | 11 -- .azure-pipelines/templates/secure-files.yml | 29 ----- .../templates/version-and-release.yml | 27 ----- 9 files changed, 264 deletions(-) delete mode 100644 .azure-pipelines/buildAndPackage.yml delete mode 100644 .azure-pipelines/templates/build/build-and-coverage.yml delete mode 100644 .azure-pipelines/templates/build/checkout-and-credscan.yml delete mode 100644 .azure-pipelines/templates/build/publish-artefacts.yml delete mode 100644 .azure-pipelines/templates/copy-and-build.yml delete mode 100644 .azure-pipelines/templates/download-artifacts.yml delete mode 100644 .azure-pipelines/templates/install-java.yml delete mode 100644 .azure-pipelines/templates/secure-files.yml delete mode 100644 .azure-pipelines/templates/version-and-release.yml diff --git a/.azure-pipelines/buildAndPackage.yml b/.azure-pipelines/buildAndPackage.yml deleted file mode 100644 index 7b0f89d28..000000000 --- a/.azure-pipelines/buildAndPackage.yml +++ /dev/null @@ -1,111 +0,0 @@ -#Copyright (c) Microsoft Corporation. All rights reserved. -#Licensed under the MIT License. -#Building and packaging the artifacts of the Java-Core libraries using the build.gradle file. -#Ready the package for deployment and release. - -trigger: - branches: - include: - - dev - - main - - master - paths: - include: - - src/* - exclude: - - .gradle/wrapper - - .gitignore - - CONTRIBUTING.md - - LICENSE - - THIRD PARTY NOTICES - - gradle.properties - - gradlew - - gradlew.bat - - readme.md - - settings.gradle - - Scripts/* - -pr: -- dev -- master - -pool: - vmImage: windows-latest - -variables: - DROP_PATH: '$(Agent.BuildDirectory)/Drop' - -stages: -- stage: Build - jobs: - - job: Build - steps: - - template: templates/build/checkout-and-credscan.yml - - template: templates/install-java.yml - - template: templates/secure-files.yml - parameters: - stageID: 'build' - - template: templates/build/build-and-coverage.yml - - template: templates/build/publish-artefacts.yml - -- stage: Maven_Preview - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev')) - jobs: - - deployment: Maven_Preview - environment: 'MSGraph SDK Development - Java' - pool: - vmImage: windows-latest - strategy: - runOnce: - deploy: - steps: - - template: templates/download-artifacts.yml - parameters: - directoryPath: $(DROP_PATH) - - template: templates/install-java.yml - - template: templates/secure-files.yml - - template: templates/copy-and-build.yml - parameters: - task: 'publishSnapshotPublicationToSonatypeSnapshotRepository' - directoryPath: $(DROP_PATH) - -- stage: Maven_Release_And_Github_Release - dependsOn: Build - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - jobs: - - deployment: Maven_Release - environment: 'MSGraph SDK Development - Java' - pool: - vmImage: windows-latest - strategy: - runOnce: - deploy: - steps: - - template: templates/download-artifacts.yml - parameters: - directoryPath: $(DROP_PATH) - - template: templates/install-java.yml - - template: templates/secure-files.yml - parameters: - stageID: 'release' - - template: templates/copy-and-build.yml - parameters: - task: 'publishMavenCentralReleasePublicationToSonatypeRepository' - directoryPath: $(DROP_PATH) - - - deployment: Github_Release - dependsOn: Maven_Release - environment: 'MSGraph SDK Development - Java' - pool: - vmImage: windows-latest - strategy: - runOnce: - deploy: - steps: - - template: templates/download-artifacts.yml - parameters: - directoryPath: $(DROP_PATH) - - template: templates/version-and-release.yml - parameters: - gitConnection: 'microsoftgraphrelease' - directoryPath: $(DROP_PATH) diff --git a/.azure-pipelines/templates/build/build-and-coverage.yml b/.azure-pipelines/templates/build/build-and-coverage.yml deleted file mode 100644 index 02ce894a2..000000000 --- a/.azure-pipelines/templates/build/build-and-coverage.yml +++ /dev/null @@ -1,16 +0,0 @@ -steps: -- task: Gradle@2 - inputs: - gradleWrapperFile: '$(Build.SourcesDirectory)/gradlew' - tasks: 'build' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - javaHomeOption: 'JDKVersion' - sonarQubeRunAnalysis: false - -- task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: $(System.DefaultWorkingDirectory)/build/reports/jacoco/test/jacocoTestReport.xml - pathToSources: $(System.DefaultWorkingDirectory)/src/main/java - failIfCoverageEmpty: true \ No newline at end of file diff --git a/.azure-pipelines/templates/build/checkout-and-credscan.yml b/.azure-pipelines/templates/build/checkout-and-credscan.yml deleted file mode 100644 index a6b9c4b9d..000000000 --- a/.azure-pipelines/templates/build/checkout-and-credscan.yml +++ /dev/null @@ -1,9 +0,0 @@ -steps: -- checkout: self - clean: true - fetchDepth: 1 - -- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3 - displayName: 'Run CredScan' - inputs: - debugMode: false diff --git a/.azure-pipelines/templates/build/publish-artefacts.yml b/.azure-pipelines/templates/build/publish-artefacts.yml deleted file mode 100644 index 5c67587a8..000000000 --- a/.azure-pipelines/templates/build/publish-artefacts.yml +++ /dev/null @@ -1,22 +0,0 @@ -steps: -- task: CopyFiles@2 - condition: ne(variables['Build.Reason'], 'PullRequest') - inputs: - SourceFolder: '$(System.DefaultWorkingDirectory)' - Contents: | - **/libs/* - build/generated-pom.xml - build/generated-pom.xml.asc - build.gradle - gradlew - gradlew.bat - settings.gradle - gradle.properties - **/gradle/** - Scripts/** - TargetFolder: '$(Build.ArtifactStagingDirectory)/' - -- publish: $(Build.ArtifactStagingDirectory) - condition: ne(variables['Build.Reason'], 'PullRequest') - artifact: Drop - displayName: Publish Build Artifact diff --git a/.azure-pipelines/templates/copy-and-build.yml b/.azure-pipelines/templates/copy-and-build.yml deleted file mode 100644 index 787fe1a6f..000000000 --- a/.azure-pipelines/templates/copy-and-build.yml +++ /dev/null @@ -1,25 +0,0 @@ -parameters: -- name: task - type: string - default: '' -- name: directoryPath - type: string - -steps: -- task: CopyFiles@2 - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: '**' - TargetFolder: '${{ parameters.directoryPath }}/' - -- task: Gradle@2 - inputs: - gradleWrapperFile: ${{ parameters.directoryPath }}/gradlew - workingDirectory: '${{ parameters.directoryPath }}/' - options: '-x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar' - tasks: ${{ parameters.task }} - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - javaHomeOption: 'JDKVersion' - sonarQubeRunAnalysis: false - spotBugsAnalysis: false diff --git a/.azure-pipelines/templates/download-artifacts.yml b/.azure-pipelines/templates/download-artifacts.yml deleted file mode 100644 index ecd6d7d9e..000000000 --- a/.azure-pipelines/templates/download-artifacts.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: -- name: directoryPath - type: string - -steps: - - download: none - - task: DownloadPipelineArtifact@2 - inputs: - source: current - artifact: Drop - path: '${{ parameters.directoryPath }}/' - patterns: | - ** - * diff --git a/.azure-pipelines/templates/install-java.yml b/.azure-pipelines/templates/install-java.yml deleted file mode 100644 index 82e866466..000000000 --- a/.azure-pipelines/templates/install-java.yml +++ /dev/null @@ -1,11 +0,0 @@ -steps: -- pwsh: 'Invoke-WebRequest -Uri https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16%2B36/OpenJDK16-jdk_x64_windows_hotspot_16_36.zip -OutFile OpenJDK.zip' - displayName: 'Download JDK' - -- task: JavaToolInstaller@0 - inputs: - versionSpec: '16' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'LocalDirectory' - jdkFile: 'OpenJDK.zip' - jdkDestinationDirectory: 'binaries' \ No newline at end of file diff --git a/.azure-pipelines/templates/secure-files.yml b/.azure-pipelines/templates/secure-files.yml deleted file mode 100644 index 01086fc53..000000000 --- a/.azure-pipelines/templates/secure-files.yml +++ /dev/null @@ -1,29 +0,0 @@ -parameters: -- name: stageID - type: string - default: '' - -steps: -- task: DownloadSecureFile@1 - inputs: - secureFile: 'local.properties' - retryCount: '5' - -- ${{ if or(eq(parameters.stageID, 'build'), eq(parameters.stageID, 'release')) }}: - - task: DownloadSecureFile@1 - inputs: - secureFile: 'secring.gpg' - retryCount: '5' - - - task: DownloadSecureFile@1 - inputs: - secureFile: 'secring.gpg.lock' - retryCount: '5' - -- ${{ if eq(parameters.stageID, 'build') }}: - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: '**' - TargetFolder: '$(System.DefaultWorkingDirectory)' - diff --git a/.azure-pipelines/templates/version-and-release.yml b/.azure-pipelines/templates/version-and-release.yml deleted file mode 100644 index 92eb32359..000000000 --- a/.azure-pipelines/templates/version-and-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -parameters: -- name: gitConnection - type: string - default: '' -- name: directoryPath - type: string - -steps: -- task: PowerShell@2 - inputs: - filePath: '${{ parameters.directoryPath }}/Scripts/getLatestVersion.ps1' - arguments: '-propertiesPath "${{ parameters.directoryPath }}/gradle.properties"' - pwsh: true - -- task: GitHubRelease@1 - inputs: - gitHubConnection: ${{ parameters.gitConnection }} - repositoryName: '$(Build.Repository.Name)' - action: 'create' - target: '$(Build.SourceVersion)' - tagSource: 'userSpecifiedTag' - tag: '$(VERSION_STRING)' - assets: | - !**/** - $(Build.ArtifactStagingDirectory)/* - changeLogCompareToRelease: 'lastFullRelease' - changeLogType: 'commitBased' From 333f451c077552b3a580610097f18a476f0a023d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 08:02:48 +0000 Subject: [PATCH 23/36] Bump junit-jupiter-api from 5.7.2 to 5.8.0 Bumps [junit-jupiter-api](https://github.com/junit-team/junit5) from 5.7.2 to 5.8.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.8.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 80c1bcfc5..3cea79342 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,6 +1,6 @@ dependencies { // Use JUnit test framework - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' testImplementation 'org.mockito:mockito-inline:3.12.4' From ce372153b08e1e4c2417a9e62987363e877bf12c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 08:10:08 +0000 Subject: [PATCH 24/36] Bump junit-jupiter-api from 5.7.2 to 5.8.0 Bumps [junit-jupiter-api](https://github.com/junit-team/junit5) from 5.7.2 to 5.8.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.8.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-api dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 12da91c5d..f56a8c9eb 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ org.junit.jupiter junit-jupiter-api - 5.7.2 + 5.8.0 test From 935add13711f347bef31cbf5766e87008b5d60b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:23:55 +0000 Subject: [PATCH 25/36] Bump junit-jupiter-engine from 5.7.2 to 5.8.0 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.7.2 to 5.8.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.8.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 3cea79342..51dec0e01 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,7 +1,7 @@ dependencies { // Use JUnit test framework testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0' testImplementation 'org.mockito:mockito-inline:3.12.4' api 'com.squareup.okhttp3:okhttp:4.9.1' From 8b7a854d266b590827f5a7fb73122ac859a4e27d Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 09:57:42 -0700 Subject: [PATCH 26/36] add working release action and upload changelog.md --- .github/workflows/build-and-publish.yml | 12 ++++++++---- CHANGELOG.MD | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.MD diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 0154c87a8..be4506c1e 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -100,9 +100,13 @@ jobs: name: drop path: drop - name: Github Release - uses: elgohr/Github-Release-Action@v3.1 + uses: anton-yurchenko/git-release@v4.1 env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + DRAFT_RELEASE: "false" + PRE_RELEASE: "false" + CHANGELOG_FILE: "CHANGELOG.md" + ALLOW_EMPTY_CHANGELOG: "true" with: - args: MS-Graph-SDK-Java-Core Release - + args: | + current/working/directory/drop/** diff --git a/CHANGELOG.MD b/CHANGELOG.MD new file mode 100644 index 000000000..c391cb12f --- /dev/null +++ b/CHANGELOG.MD @@ -0,0 +1,11 @@ +#Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +##[Unreleased] +###Added +###Changed +##[x.x.x] - 2021-09-14 \ No newline at end of file From 046b6da7f7d829a3191255f7002595f7573c2a0c Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:50:00 -0700 Subject: [PATCH 27/36] Update .github/workflows/build-and-publish.yml Co-authored-by: Vincent Biret --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index be4506c1e..5257a4100 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -109,4 +109,4 @@ jobs: ALLOW_EMPTY_CHANGELOG: "true" with: args: | - current/working/directory/drop/** + drop/** From 0b989757ec06832b0b1ce1eb052bd29c03eb53bc Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:51:24 -0700 Subject: [PATCH 28/36] Update .github/workflows/build-and-publish.yml Co-authored-by: Vincent Biret --- .github/workflows/build-and-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 5257a4100..fc73eb9be 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -94,6 +94,7 @@ jobs: needs: maven_Release runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - name: Download Build Artifact uses: actions/download-artifact@v2.0.10 with: From 35ffa517539885b41470cb5ca31350409bf717b3 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 12:47:20 -0700 Subject: [PATCH 29/36] Update CHANGELOG.MD --- CHANGELOG.MD | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index c391cb12f..560d3f24b 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,5 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ##[Unreleased] ###Added +- Workflow for build validation +- Workflow for Maven preview and GitHub Release +- Proper handling for InterruptedException ###Changed -##[x.x.x] - 2021-09-14 \ No newline at end of file +- Casing fixed for Odata type parsing +- Removed .azure-pipelines/** +##[2.0.9] - 2021-09-14 From 6a1b74a170666fd5c9243cf2f7d299601f826103 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:10:16 -0700 Subject: [PATCH 30/36] Update gradle-build.yml --- .github/workflows/gradle-build.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 57fc61ddf..b06e4b93d 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -30,16 +30,6 @@ jobs: cache: gradle - name: Easy detect-secrets uses: RobertFischer/detect-secrets-action@v2.0.0 - - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH - shell: pwsh - env: - ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }} - OUPUT_PATH: .\local.properties - - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH - shell: pwsh - env: - ENCODED_VALUE: ${{ secrets.SECRING_GPG }} - OUPUT_PATH: .\secring.gpg - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle From 628c64dd60e6f0e14a8737e714440b0aa59adaba Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:13:52 -0700 Subject: [PATCH 31/36] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index fc73eb9be..a67e9e515 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -40,6 +40,11 @@ jobs: env: ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }} OUTPUT_PATH: .\local.properties + - run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH + shell: pwsh + env: + ENCODED_VALUE: ${{ secrets.SECRING_GPG }} + OUPUT_PATH: .\secring.gpg - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Publish From 76b2582ddc39da991434ce83d687622bb8b523b3 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:20:58 -0700 Subject: [PATCH 32/36] Create readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 72dcc5914..c35cb81a2 100644 --- a/readme.md +++ b/readme.md @@ -22,7 +22,7 @@ repositories { dependencies { // Include the sdk as a dependency - implementation 'com.microsoft.graph:microsoft-graph-core:2.0.8' + implementation 'com.microsoft.graph:microsoft-graph-core:2.0.9' // This dependency is only needed if you are using the TokenCrendentialAuthProvider implementation 'com.azure:azure-identity:1.3.1' } @@ -37,7 +37,7 @@ Add the dependency in `dependencies` in pom.xml com.microsoft.graph microsoft-graph-core - 2.0.8 + 2.0.9 com.azure azure-identity From de87d611c53e1120264b313f5afcc820dbb62b21 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:23:40 -0700 Subject: [PATCH 33/36] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 884db4ece..f9aba7384 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ mavenGroupId = com.microsoft.graph mavenArtifactId = microsoft-graph-core mavenMajorVersion = 2 mavenMinorVersion = 0 -mavenPatchVersion = 8 +mavenPatchVersion = 9 mavenArtifactSuffix = #These values are used to run functional tests From 648705f2a9b737b37d3a5154dbef8b6b713b480c Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:24:14 -0700 Subject: [PATCH 34/36] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f56a8c9eb..48cae23a1 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.microsoft.graph microsoft-graph-core - 2.0.8 + 2.0.9 pom From a2ee01ff12b594a4d60800eb90f8f18f82cd1b68 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:24:45 -0700 Subject: [PATCH 35/36] Update TelemetryHandler.java --- .../java/com/microsoft/graph/httpcore/TelemetryHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java index 0c0b924b6..e52523027 100644 --- a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java @@ -25,7 +25,7 @@ public class TelemetryHandler implements Interceptor{ /** * Current SDK version */ - public static final String VERSION = "v2.0.8"; + public static final String VERSION = "v2.0.9"; /** * Verion prefix */ From 69c4754ee5ffc2f66e69aff81d94e333f39371fe Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Mon, 13 Sep 2021 13:37:15 -0700 Subject: [PATCH 36/36] Update CHANGELOG.MD --- CHANGELOG.MD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 560d3f24b..82062dd75 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ##[Unreleased] + +##[2.0.9] - 2021-09-14 ###Added - Workflow for build validation - Workflow for Maven preview and GitHub Release @@ -13,4 +15,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ###Changed - Casing fixed for Odata type parsing - Removed .azure-pipelines/** -##[2.0.9] - 2021-09-14