diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index eb5e1d20..76f6ec6a 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -30,7 +30,7 @@ runs: - name: Build with Maven run: | - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests shell: bash # - name: Piper Maven build diff --git a/.github/actions/deploy-release/action.yml b/.github/actions/deploy-release/action.yml index 134414b0..8fe43826 100644 --- a/.github/actions/deploy-release/action.yml +++ b/.github/actions/deploy-release/action.yml @@ -58,7 +58,7 @@ runs: - name: Deploy to Maven Central run: > - mvn -B -ntp --show-version + ./mvnw -B -ntp --show-version -Dmaven.install.skip=true -Dmaven.test.skip=true -Dgpg.passphrase="$GPG_PASSPHRASE" @@ -74,7 +74,7 @@ runs: # - name: "Deploy Locally" # run: | # echo "Deploying artifacts locally..." - # mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \ + # ./mvnw --batch-mode --no-transfer-progress --fail-at-end --show-version \ # -Durl=file:./temp_local_repo \ # -Dmaven.install.skip=true \ # -Dmaven.test.skip=true \ @@ -98,7 +98,7 @@ runs: # - name: "Deploy Staging" # run: | - # mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \ + # ./mvnw --batch-mode --no-transfer-progress --fail-at-end --show-version \ # org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:deploy-staged-repository \ # -DserverId=ossrh \ # -DnexusUrl=https://oss.sonatype.org \ diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index 027923cc..6b745d6e 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -50,7 +50,7 @@ runs: - name: Deploy run: > - mvn -B -ntp --fae --show-version + ./mvnw -B -ntp --fae --show-version -DaltDeploymentRepository=${{inputs.server-id}}::default::${{inputs.repository-url}} -Dmaven.install.skip=true -Dmaven.test.skip=true diff --git a/.github/actions/newrelease/action.yml b/.github/actions/newrelease/action.yml index 04296d55..c554a5d7 100644 --- a/.github/actions/newrelease/action.yml +++ b/.github/actions/newrelease/action.yml @@ -29,7 +29,7 @@ runs: run: | VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') echo $VERSION > cap-notebook/version.txt - mvn --no-transfer-progress versions:set-property -Dproperty=revision -DnewVersion=$VERSION + ./mvnw --no-transfer-progress versions:set-property -Dproperty=revision -DnewVersion=$VERSION #chmod +x ensure-license.sh #./ensure-license.sh git config --global user.name 'github-actions[bot]' diff --git a/.github/workflows/blackduck.yml b/.github/workflows/blackduck.yml index 70cd6f20..c1d1664c 100644 --- a/.github/workflows/blackduck.yml +++ b/.github/workflows/blackduck.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests - name: Download Synopsys Detect Script run: curl --silent -O https://detect.synopsys.com/detect9.sh diff --git a/.github/workflows/cfdeploy.yml b/.github/workflows/cfdeploy.yml index 4dd2527d..47ca2963 100644 --- a/.github/workflows/cfdeploy.yml +++ b/.github/workflows/cfdeploy.yml @@ -49,7 +49,7 @@ jobs: - name: Build and package 🔨 run: | echo "🚀 Building and packaging..." - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests echo "✅ Build and packaging completed successfully!" - name: Verify and Checkout Deploy Branch 🔄 diff --git a/.github/workflows/internalArticatory.yml b/.github/workflows/internalArticatory.yml index fafc8bbd..8da3b01b 100644 --- a/.github/workflows/internalArticatory.yml +++ b/.github/workflows/internalArticatory.yml @@ -37,7 +37,7 @@ jobs: - name: Read current revision id: read-revision run: | - current_version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version) + current_version=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=project.version) echo "Current version: $current_version" echo "revision=$current_version" >> $GITHUB_OUTPUT echo "updated_version=$current_version" >> $GITHUB_OUTPUT @@ -62,7 +62,7 @@ jobs: else echo "Already a -SNAPSHOT version; no bump performed." fi - updated_version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version) + updated_version=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=project.version) echo "updated_version=$updated_version" >> $GITHUB_OUTPUT # Manual settings.xml generation removed; using setup-java injected server credentials. @@ -71,7 +71,7 @@ jobs: run: | final_version="${{ steps.bump-version.outputs.updated_version || steps.read-revision.outputs.updated_version }}" echo "Deploying ${final_version} to Artifactory" - mvn -B -ntp -fae \ + ./mvnw -B -ntp -fae \ -Dmaven.install.skip=true -Dmaven.test.skip=true -DdeployAtEnd=true \ -DaltDeploymentRepository=artifactory::${{ env.ARTIFACTORY_URL }} deploy env: diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index ecc0662a..c6b31aa8 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -52,7 +52,7 @@ jobs: - name: Get Revision id: get-revision run: | - current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + current_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) echo "Current version: $current_version" echo "REVISION=$current_version" >> $GITHUB_ENV shell: bash @@ -84,7 +84,7 @@ jobs: echo "Current version already contains -SNAPSHOT, no update needed." fi # Export the updated or original version - updated_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + updated_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) echo "UPDATED_VERSION=$updated_version" >> $GITHUB_ENV shell: bash @@ -96,7 +96,7 @@ jobs: - name: Deploy snapshot if: ${{ endsWith(env.UPDATED_VERSION, '-SNAPSHOT') }} run: | - mvn -B -ntp -fae -Dmaven.install.skip=true -Dmaven.test.skip=true -DdeployAtEnd=true -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/cap-java/sdm deploy + ./mvnw -B -ntp -fae -Dmaven.install.skip=true -Dmaven.test.skip=true -DdeployAtEnd=true -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/cap-java/sdm deploy env: GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} shell: bash diff --git a/.github/workflows/multi tenancy_Integration.yml b/.github/workflows/multi tenancy_Integration.yml index 8aef98aa..6c4be953 100644 --- a/.github/workflows/multi tenancy_Integration.yml +++ b/.github/workflows/multi tenancy_Integration.yml @@ -190,8 +190,8 @@ jobs: EOL echo "🎯 Running Maven integration tests" - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests echo "✅ Integration tests completed!" \ No newline at end of file diff --git a/.github/workflows/multiTenancyDeployLocal.yml b/.github/workflows/multiTenancyDeployLocal.yml index 8152132f..220d15b2 100644 --- a/.github/workflows/multiTenancyDeployLocal.yml +++ b/.github/workflows/multiTenancyDeployLocal.yml @@ -42,7 +42,7 @@ jobs: - name: Build and package 📦 run: | echo "🔨 Building and packaging..." - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests echo "✅ Build completed successfully!" - name: Setup Node.js 🟢 diff --git a/.github/workflows/multiTenant_deploy_and_Integration_test.yml b/.github/workflows/multiTenant_deploy_and_Integration_test.yml index 364cda92..44dfa272 100644 --- a/.github/workflows/multiTenant_deploy_and_Integration_test.yml +++ b/.github/workflows/multiTenant_deploy_and_Integration_test.yml @@ -35,7 +35,7 @@ jobs: - name: Build and package 📦 run: | echo "🔨 Building and packaging..." - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests echo "✅ Build completed successfully!" - name: Setup Node.js 🟢 @@ -272,8 +272,8 @@ jobs: EOL echo "🎯 Running Maven integration tests" - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests echo "✅ Integration tests completed!" diff --git a/.github/workflows/multiTenant_deploy_and_Integration_test_LatestVersion.yml b/.github/workflows/multiTenant_deploy_and_Integration_test_LatestVersion.yml index ab0b5e74..119857ff 100644 --- a/.github/workflows/multiTenant_deploy_and_Integration_test_LatestVersion.yml +++ b/.github/workflows/multiTenant_deploy_and_Integration_test_LatestVersion.yml @@ -33,7 +33,7 @@ jobs: - name: Build and package 📦 run: | echo "🔨 Building and packaging..." - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests echo "✅ Build completed successfully!" - name: Setup Node.js 🟢 @@ -75,8 +75,8 @@ jobs: fi done - echo "\nResolving effective value BEFORE override via mvn help:evaluate ..." - RESOLVED_BEFORE=$(mvn -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) + echo "\nResolving effective value BEFORE override via ./mvnw help:evaluate ..." + RESOLVED_BEFORE=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) echo "Effective cds.services.version before override: '${RESOLVED_BEFORE}'" if [ "${RESOLVED_BEFORE}" = "${TARGET_CDS_SERVICES_VERSION}" ]; then echo "NOTE: Effective value already equals target; files will still be normalized to target string." @@ -91,8 +91,8 @@ jobs: echo "\nRaw occurrences AFTER override:" grep -R "" $FILES || true - echo "\nResolving effective value AFTER override via mvn help:evaluate ..." - RESOLVED_AFTER=$(mvn -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) + echo "\nResolving effective value AFTER override via ./mvnw help:evaluate ..." + RESOLVED_AFTER=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) echo "Effective cds.services.version after override: '${RESOLVED_AFTER}'" if [ "${RESOLVED_AFTER}" != "${TARGET_CDS_SERVICES_VERSION}" ]; then echo "WARNING: Resolved value does not match target (profiles or parent POM could be overriding it)." >&2 @@ -321,8 +321,8 @@ jobs: EOL echo "🎯 Running Maven integration tests" - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests echo "✅ Integration tests completed!" diff --git a/.github/workflows/sanity.check.yml b/.github/workflows/sanity.check.yml new file mode 100644 index 00000000..8e616f00 --- /dev/null +++ b/.github/workflows/sanity.check.yml @@ -0,0 +1,39 @@ +name: Sanity Check + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + types: [opened, synchronize, reopened, auto_merge_enabled] + workflow_dispatch: +permissions: + pull-requests: read + +jobs: + sanity-check: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [17] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ matrix.java-version }} + + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Sanity Check + run: | + ./mvnw clean rewrite:dryRun diff --git a/.github/workflows/singleTenant_deploy_and_Integration_test.yml b/.github/workflows/singleTenant_deploy_and_Integration_test.yml index 7a08f41f..634b6f79 100644 --- a/.github/workflows/singleTenant_deploy_and_Integration_test.yml +++ b/.github/workflows/singleTenant_deploy_and_Integration_test.yml @@ -66,8 +66,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # - name: Consume GitHub Packages (com.sap.cds.sdm-root and com.sap.cds.sdm) # run: | - # mvn dependency:get -Dartifact=com.sap.cds:sdm-root:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm - # mvn dependency:get -Dartifact=com.sap.cds:sdm:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm + # ./mvnw dependency:get -Dartifact=com.sap.cds:sdm-root:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm + # ./mvnw dependency:get -Dartifact=com.sap.cds:sdm:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm - name: Prepare and Deploy to Cloud Foundry run: | @@ -207,8 +207,8 @@ jobs: EOL echo "🎯 Running Maven integration tests" # Run Maven integration tests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Technical User Flow"; exit 1; } - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Named User Flow"; exit 1; } + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Technical User Flow"; exit 1; } + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Named User Flow"; exit 1; } diff --git a/.github/workflows/singleTenant_deploy_and_Integration_test_LatestVersion.yml b/.github/workflows/singleTenant_deploy_and_Integration_test_LatestVersion.yml index 9019b0e8..d899e148 100644 --- a/.github/workflows/singleTenant_deploy_and_Integration_test_LatestVersion.yml +++ b/.github/workflows/singleTenant_deploy_and_Integration_test_LatestVersion.yml @@ -64,8 +64,8 @@ jobs: fi done - echo "\nResolving effective value BEFORE override via mvn help:evaluate ..." - RESOLVED_BEFORE=$(mvn -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) + echo "\nResolving effective value BEFORE override via ./mvnw help:evaluate ..." + RESOLVED_BEFORE=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) echo "Effective cds.services.version before override: '${RESOLVED_BEFORE}'" if [ "${RESOLVED_BEFORE}" = "${TARGET_CDS_SERVICES_VERSION}" ]; then echo "NOTE: Effective value already equals target; files will still be normalized to target string." @@ -80,8 +80,8 @@ jobs: echo "\nRaw occurrences AFTER override:" grep -R "" $FILES || true - echo "\nResolving effective value AFTER override via mvn help:evaluate ..." - RESOLVED_AFTER=$(mvn -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) + echo "\nResolving effective value AFTER override via ./mvnw help:evaluate ..." + RESOLVED_AFTER=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=cds.services.version || true) echo "Effective cds.services.version after override: '${RESOLVED_AFTER}'" if [ "${RESOLVED_AFTER}" != "${TARGET_CDS_SERVICES_VERSION}" ]; then echo "WARNING: Resolved value does not match target (profiles or parent POM could be overriding it)." >&2 @@ -117,8 +117,8 @@ jobs: # - name: Consume GitHub Packages (com.sap.cds.sdm-root and com.sap.cds.sdm) # run: | - # mvn dependency:get -Dartifact=com.sap.cds:sdm-root:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm - # mvn dependency:get -Dartifact=com.sap.cds:sdm:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm + # ./mvnw dependency:get -Dartifact=com.sap.cds:sdm-root:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm + # ./mvnw dependency:get -Dartifact=com.sap.cds:sdm:LATEST -DrepoUrl=https://maven.pkg.github.com/cap-java/sdm - name: Prepare and Deploy to Cloud Foundry run: | @@ -259,7 +259,7 @@ jobs: noSDMRoleUserPassword=$noSDMRoleUserPassword EOL # Run Maven integration tests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Technical User Flow"; exit 1; } - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Named User Flow"; exit 1; } + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Technical User Flow"; exit 1; } + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Named User Flow"; exit 1; } diff --git a/.github/workflows/singleTenant_integration_test.yml b/.github/workflows/singleTenant_integration_test.yml index 591e5753..6aebf8d4 100644 --- a/.github/workflows/singleTenant_integration_test.yml +++ b/.github/workflows/singleTenant_integration_test.yml @@ -129,5 +129,5 @@ jobs: EOL echo "🎯 Running Maven integration tests..." # Run Maven integration tests - mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Named User Flow"; exit 1; } - mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Technical User Flow"; exit 1; } \ No newline at end of file + ./mvnw clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Named User Flow"; exit 1; } + ./mvnw clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Technical User Flow"; exit 1; } \ No newline at end of file diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index eb8c08ef..a28dec2b 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -32,7 +32,7 @@ jobs: - name: Install dependencies run: | - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests - name: Install SonarQube Scanner run: | diff --git a/.github/workflows/unit.tests.yml b/.github/workflows/unit.tests.yml index 8b35e9cd..57d83238 100644 --- a/.github/workflows/unit.tests.yml +++ b/.github/workflows/unit.tests.yml @@ -36,7 +36,7 @@ jobs: - name: Install dependencies and run tests with coverage run: | - mvn clean install -P unit-tests -DskipIntegrationTests + ./mvnw clean install -P unit-tests -DskipIntegrationTests - name: Upload code coverage report uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index 17879920..0301fc6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ -sdm/target/ +sdm/target/** .flattened-pom.xml node_modules/ +.idea +/target/rewrite/** +/sdm-root.iml +/target/spotless-index # Compiled class file *.class @@ -28,4 +32,4 @@ hs_err_pid* replay_pid* ### Mac System File ### -*.DS_Store \ No newline at end of file +*.DS_Store diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..222cba3b --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,4 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +distributionSha256Sum=0d7125e8c91097b36edb990ea5934e6c68b4440eef4ea96510a0f6815e7eeadb diff --git a/README.md b/README.md index 2f844ac7..c5c481e2 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ To use a development version of the SDM CAP plugin, follow these steps. This is 2. Install the plugin in the root folder after switiching to the branch you want to use: ```sh - mvn clean install + ./mvnw clean install ``` The plugin is now added to your local .m2 repository, giving it priority over the version available in the central Maven repository during the application build. diff --git a/cap-notebook/attachments-demo-app.capnb b/cap-notebook/attachments-demo-app.capnb index 13a6377c..78f1f48d 100644 --- a/cap-notebook/attachments-demo-app.capnb +++ b/cap-notebook/attachments-demo-app.capnb @@ -36,7 +36,7 @@ { "kind": 1, "language": "markdown", - "value": "## Add Enhancements for the Datamodel\nThe `books` entity will be enhanced with the `attachments` composition.\n\nTo be able to use the `sdm` datamodel a `pom.xml` needs to be added with the maven dependency for the feature.\nThe version for the dependency is taken from the file `version.txt`. \nThis file will be updated if a new version is created in the repository.\n\nOnce the `pom.xml` is available and the version is set a `mvn clean verify` is executed.\nWith the the `resolve` goal of the `cds-maven-plugin` is executed which copies the `cds`-files from the feature in the `target` folder of the `db` module.\n\nOnce available in the `target` folder it will be found and can be used in the data models.", + "value": "## Add Enhancements for the Datamodel\nThe `books` entity will be enhanced with the `attachments` composition.\n\nTo be able to use the `sdm` datamodel a `pom.xml` needs to be added with the maven dependency for the feature.\nThe version for the dependency is taken from the file `version.txt`. \nThis file will be updated if a new version is created in the repository.\n\nOnce the `pom.xml` is available and the version is set a `./mvnw clean verify` is executed.\nWith the the `resolve` goal of the `cds-maven-plugin` is executed which copies the `cds`-files from the feature in the `target` folder of the `db` module.\n\nOnce available in the `target` folder it will be found and can be used in the data models.", "outputs": [] }, { @@ -108,7 +108,7 @@ { "kind": 2, "language": "shell", - "value": "mvn clean compile", + "value": "./mvnw clean compile", "outputs": [ { "mime": "text/plain", @@ -215,13 +215,13 @@ { "kind": 1, "language": "markdown", - "value": "## Build the Service\n\nRun `mvn clean compile` on the service to compile the models with all changes.", + "value": "## Build the Service\n\nRun `./mvnw clean compile` on the service to compile the models with all changes.", "outputs": [] }, { "kind": 2, "language": "shell", - "value": "cd ../../srv\nmvn clean compile", + "value": "cd ../../srv\n./mvnw clean compile", "outputs": [ { "mime": "text/plain", @@ -232,7 +232,7 @@ { "kind": 1, "language": "markdown", - "value": "## Start the Service\n\n\nThe service can now be started with the following command in the `srv` module:\n\n```\nmvn cds:watch\n```\n\nAfter the service is startet the UI can be opened with:\n\n[http://localhost:8080](http://localhost:8080)\n\nNavigate to the index.html of the webapp and use user `admin` with password `admin`. \n\nUsing the tile `Manage Books` the attachments can be used in the detail area of the books.\n\nUsing the tile `Browse Books` no attachments are shown.", + "value": "## Start the Service\n\n\nThe service can now be started with the following command in the `srv` module:\n\n```\n./mvnw cds:watch\n```\n\nAfter the service is startet the UI can be opened with:\n\n[http://localhost:8080](http://localhost:8080)\n\nNavigate to the index.html of the webapp and use user `admin` with password `admin`. \n\nUsing the tile `Manage Books` the attachments can be used in the detail area of the books.\n\nUsing the tile `Browse Books` no attachments are shown.", "outputs": [] }, { diff --git a/deploy-artifactory.sh b/deploy-artifactory.sh index dc0071b1..413667e6 100644 --- a/deploy-artifactory.sh +++ b/deploy-artifactory.sh @@ -21,13 +21,13 @@ echo "Running on branch: $GIT_BRANCH" ######################################## echo "Checking Java & Maven installations..." java -version || { echo "❌ Java not found!"; exit 1; } -mvn -v || { echo "❌ Maven not found!"; exit 1; } +./mvnw -v || { echo "❌ Maven not found!"; exit 1; } ######################################## # READ CURRENT VERSION ######################################## echo "Reading current Maven project version..." -current_version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version) +current_version=$(./mvnw -q -DforceStdout help:evaluate -Dexpression=project.version) echo "Current version: $current_version" updated_version="$current_version" @@ -61,7 +61,7 @@ fi ######################################## if [[ "$updated_version" == *-SNAPSHOT ]]; then echo "Deploying ${updated_version} to Artifactory..." - mvn -B -ntp -fae \ + ./mvnw -B -ntp -fae \ -Dmaven.install.skip=true \ -Dmaven.test.skip=true \ -DdeployAtEnd=true \ diff --git a/mvnw b/mvnw new file mode 100755 index 00000000..1ddd97b9 --- /dev/null +++ b/mvnw @@ -0,0 +1,338 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ]; then + + if [ -f /usr/local/etc/mavenrc ]; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ]; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ]; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +darwin=false +mingw=false +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)" + export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home" + export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ + && JAVA_HOME="$( + cd "$JAVA_HOME" || ( + echo "cannot cd into $JAVA_HOME." >&2 + exit 1 + ) + pwd + )" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin; then + javaHome="$(dirname "$javaExecutable")" + javaExecutable="$(cd "$javaHome" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "$javaExecutable")" + fi + javaHome="$(dirname "$javaExecutable")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$( + \unset -f command 2>/dev/null + \command -v java + )" + fi +fi + +if [ ! -x "$JAVACMD" ]; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." >&2 +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" >&2 + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$( + cd "$wdir/.." || exit 1 + pwd + ) + fi + # end of workaround + done + printf '%s' "$( + cd "$basedir" || exit 1 + pwd + )" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' <"$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1 +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" + fi + while IFS="=" read -r key value; do + case "$key" in wrapperUrl) + wrapperUrl=$(trim "${value-}") + break + ;; + esac + done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget ${QUIET:+"$QUIET"} "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget ${QUIET:+"$QUIET"} --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl >/dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl ${QUIET:+"$QUIET"} -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl ${QUIET:+"$QUIET"} --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in wrapperSha256Sum) + wrapperSha256Sum=$(trim "${value-}") + break + ;; + esac +done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c - >/dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] \ + && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100755 index 00000000..8366e217 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,206 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. >&2 +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. >&2 +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. >&2 +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. >&2 +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index cd23fc4b..296b876b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,6 +2,22 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.sap.cds + + sdm-root + + ${revision} + + pom + + CDS Feature for SAP Document Management Service - Root + This artifact is a is cds-plugin that provides an easy CAP-level integration with SAP Document Management Service. This package supports handling of attachments(documents) by using an aspect Attachments in SAP Document Management Service. + https://cap.cloud.sap/docs/plugins/#attachments + + SAP SE + https://www.sap.com + + The Apache Software License, Version 2.0 @@ -9,18 +25,34 @@ repo - - - SAP SE - https://www.sap.com - - SAP SE https://www.sap.com + + sdm + + + + https://github.com/Pankraz76/sdm + scm:git:git@github.com:Pankraz76/sdm.git + scm:git:git@github.com:Pankraz76/sdm.git + + + + + github-snapshot + GitHub Packages Snapshots + https://maven.pkg.github.com/cap-java/sdm + + + central + MavenCentral + https://central.sonatype.com + + 1.6.1-SNAPSHOT @@ -41,19 +73,6 @@ 5.15.2 - com.sap.cds - sdm-root - ${revision} - pom - - CDS Feature for SAP Document Management Service - Root - This artifact is a is cds-plugin that provides an easy CAP-level integration with SAP Document Management Service. This package supports handling of attachments(documents) by using an aspect Attachments in SAP Document Management Service. - https://cap.cloud.sap/docs/plugins/#attachments - - - sdm - - @@ -84,17 +103,16 @@ pom import - - com.sap.cloud.sdk - sdk-bom - ${sdk-bom-version} - pom - import - + + com.sap.cloud.sdk + sdk-bom + ${sdk-bom-version} + pom + import + - com.sap.cds @@ -137,7 +155,6 @@ org.mockito mockito-core - ${mockito-core-version} org.objenesis @@ -157,7 +174,8 @@ org.apache.httpcomponents httpmime - 4.5.14 + 4.5.14 + commons-codec @@ -169,8 +187,7 @@ - - + @@ -203,7 +220,8 @@ - check + check + compile @@ -257,7 +275,8 @@ org.apache.maven.plugins maven-dependency-plugin - 3.2.0 + 3.2.0 + @@ -269,11 +288,16 @@ + + org.openrewrite.maven + rewrite-maven-plugin + + org.apache.maven.plugins maven-gpg-plugin 3.2.7 @@ -284,46 +308,95 @@ true + org.apache.maven.plugins maven-clean-plugin 3.5.0 + org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.14.1 + org.apache.maven.plugins maven-source-plugin 3.3.1 + org.apache.maven.plugins maven-deploy-plugin 3.1.4 + org.apache.maven.plugins maven-javadoc-plugin 3.11.2 + org.apache.maven.plugins maven-surefire-plugin 3.5.3 + org.apache.maven.plugins maven-pmd-plugin 3.26.0 + org.apache.maven.plugins maven-enforcer-plugin 3.5.0 + + org.openrewrite.maven + rewrite-maven-plugin + 6.24.0 + + true + + com.sap.cds.openrewrite.SanityCheck + + + **.ci-temp** + **.jp*g + **.png + **xdocs-examples** + + + + + org.openrewrite.recipe + rewrite-migrate-java + 3.22.0 + + + org.openrewrite.recipe + rewrite-codemods + 0.22.0 + + + org.openrewrite.recipe + rewrite-static-analysis + 2.22.0 + + + org.openrewrite.recipe + rewrite-rewrite + 0.16.0 + + + + deploy-release + org.apache.maven.plugins maven-gpg-plugin @@ -346,24 +419,6 @@ - - - - github-snapshot - GitHub Packages Snapshots - https://maven.pkg.github.com/cap-java/sdm - - - central - MavenCentral - https://central.sonatype.com - - - - - https://github.com/cap-java/sdm - scm:git:git@github.com:cap-java/sdm.git - scm:git:git@github.com:cap-java/sdm.git - + diff --git a/rewrite.yml b/rewrite.yml new file mode 100644 index 00000000..cf913430 --- /dev/null +++ b/rewrite.yml @@ -0,0 +1,13 @@ +--- +type: specs.openrewrite.org/v1beta/recipe +name: com.sap.cds.openrewrite.SanityCheck +displayName: Apply all best practices +description: Comprehensive code quality recipe combining modernization, security, and best practices. +tags: + - static-analysis + - cleanup +recipeList: + - org.openrewrite.java.migrate.UpgradeToJava17 + - org.openrewrite.maven.BestPractices + - org.openrewrite.maven.UpdateMavenWrapper +--- \ No newline at end of file diff --git a/sdm/pom.xml b/sdm/pom.xml index 70b6d92f..e760feb8 100644 --- a/sdm/pom.xml +++ b/sdm/pom.xml @@ -8,6 +8,17 @@ ${revision} + sdm + + jar + + CDS Feature for SAP Document Management Service + https://cap.cloud.sap/docs/plugins/#attachments + + + SAP SE + https://www.sap.com + The Apache Software License, Version 2.0 @@ -16,16 +27,13 @@ - - SAP SE - https://www.sap.com - - - sdm - jar - - CDS Feature for SAP Document Management Service - https://cap.cloud.sap/docs/plugins/#attachments + + + artifactory + Artifactory_DMZ-snapshots + https://common.repositories.cloud.sap/artifactory/cap-sdm-java + + sdm @@ -35,7 +43,7 @@ 17 17 1.2.2 - 1.18.36 + 1.18.42 0.8.7 3.10.8 3.5.7 @@ -51,83 +59,36 @@ 2.2.21 - - - unit-tests - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.2.5 - - - **/unit/**/*.java - - - - - - - - integration-tests - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.3.1 - - - integration-test - - integration-test - verify - - - - **IntegrationTest_MultipleFacet.java - **IntegrationTest_SingleFacet.java - - - - - - - - - - org.apache.httpcomponents.client5 httpclient5 ${httpclient5-version} - - org.apache.httpcomponents.core5 - httpcore5 - ${httpcore5-version} - + + org.apache.httpcomponents.core5 + httpcore5 + ${httpcore5-version} + - - org.apache.httpcomponents - httpasyncclient - ${httpasyncclient-version} - - - commons-logging - commons-logging - - - - - - - org.apache.logging.log4j - log4j-api - ${log4j-api-version} - + + org.apache.httpcomponents + httpasyncclient + ${httpasyncclient-version} + + + commons-logging + commons-logging + + + + + + + org.apache.logging.log4j + log4j-api + ${log4j-api-version} + org.projectlombok @@ -158,12 +119,10 @@ com.sap.cloud.environment.servicebinding.api java-access-api - 0.10.5 com.sap.cloud.environment.servicebinding.api java-core-api - 0.10.5 com.fasterxml.jackson.core @@ -226,7 +185,7 @@ com.sap.cloud.security java-security - + org.checkerframework checker-qual @@ -284,35 +243,35 @@ test - com.sap.cds - cds-feature-attachments - ${attachments_version} - - - jakarta.jms - jakarta.jms-api - - - com.sap.cloud.sdk.cloudplatform - resilience4j - - + com.sap.cds + cds-feature-attachments + ${attachments_version} + + + jakarta.jms + jakarta.jms-api + + + com.sap.cloud.sdk.cloudplatform + resilience4j + + com.google.guava guava - - + + org.apache.commons commons-lang3 - - - com.sap.cloud.sdk.cloudplatform - connectivity-oauth - - - com.sap.cloud.sdk.cloudplatform - cloudplatform-core - - + + + com.sap.cloud.sdk.cloudplatform + connectivity-oauth + + + com.sap.cloud.sdk.cloudplatform + cloudplatform-core + + com.sap.cloud.sdk.cloudplatform @@ -345,15 +304,15 @@ guava 33.4.0-jre - - com.google.guava - listenablefuture - - + + com.google.guava + listenablefuture + + org.checkerframework checker-qual - + com.google.code.findbugs jsr305 @@ -362,7 +321,6 @@ org.mockito mockito-junit-jupiter - ${mockito-junit-jupiter-version} test @@ -417,17 +375,18 @@ - - io.reactivex.rxjava2 - rxjava - ${rxjava-version} - + + io.reactivex.rxjava2 + rxjava + ${rxjava-version} + ${project.artifactId} - + + org.apache.maven.plugins maven-javadoc-plugin ${skipDuringDeploy} @@ -646,7 +605,6 @@ org.apache.maven.plugins maven-source-plugin - 3.3.1 @@ -660,11 +618,50 @@ - - - artifactory - Artifactory_DMZ-snapshots - https://common.repositories.cloud.sap/artifactory/cap-sdm-java - - + + + unit-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + **/unit/**/*.java + + + + + + + + integration-tests + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.3.1 + + + integration-test + + integration-test + verify + + + + **IntegrationTest_MultipleFacet.java + **IntegrationTest_SingleFacet.java + + + + + + + + + \ No newline at end of file diff --git a/sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java b/sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java index 19beb0c2..e8936b50 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java +++ b/sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java @@ -154,7 +154,7 @@ private SDMConstants() { public static String buildErrorMessage( Collection filenames, StringBuilder prefixTemplate, String closingRemark) { for (String file : filenames) { - prefixTemplate.append(String.format("\t• %s%n", file)); + prefixTemplate.append("\t• %s%n".formatted(file)); } if (closingRemark != null && !closingRemark.isEmpty()) prefixTemplate.append("\n ").append(closingRemark); @@ -165,7 +165,7 @@ public static String buildErrorMessage( public static String nameConstraintMessage(List invalidFileNames) { // if only 1 restricted character is there in file, so different error will throw if (invalidFileNames.size() == 1) { - return String.format(SINGLE_RESTRICTED_CHARACTER_IN_FILE, invalidFileNames.iterator().next()); + return SINGLE_RESTRICTED_CHARACTER_IN_FILE.formatted(invalidFileNames.iterator().next()); } StringBuilder prefix = new StringBuilder(); prefix.append( @@ -177,7 +177,7 @@ public static String nameConstraintMessage(List invalidFileNames) { public static String duplicateFilenameFormat(Collection duplicateFileNames) { // if only 1 duplicate file, so different error will throw if (duplicateFileNames.size() == 1) { - return String.format(SINGLE_DUPLICATE_FILENAME, duplicateFileNames.iterator().next()); + return SINGLE_DUPLICATE_FILENAME.formatted(duplicateFileNames.iterator().next()); } StringBuilder prefix = new StringBuilder(); prefix.append("Objects with the following names already exist:\n\n"); @@ -191,14 +191,14 @@ public static String fileNotFound(List fileNameNotFound) { "Update unsuccessful. The following filename(s) could not be updated as they do not exist. \n\n"; // Create the formatted prefix message - String formattedPrefixMessage = String.format(prefixMessage); + String formattedPrefixMessage = prefixMessage.formatted(); // Initialize the StringBuilder with the formatted message prefix StringBuilder bulletPoints = new StringBuilder(formattedPrefixMessage); // Append each unsupported file name to the StringBuilder for (String file : fileNameNotFound) { - bulletPoints.append(String.format("\t• %s%n", file)); + bulletPoints.append("\t• %s%n".formatted(file)); } bulletPoints.append("\nDelete and upload the files again."); return bulletPoints.toString(); @@ -213,7 +213,7 @@ public static String badRequestMessage(Map badRequest) { // Append each file name and its error message to the StringBuilder for (Map.Entry entry : badRequest.entrySet()) { - bulletPoints.append(String.format("\t• %s : %s%n", entry.getKey(), entry.getValue())); + bulletPoints.append("\t• %s : %s%n".formatted(entry.getKey(), entry.getValue())); } bulletPoints.append("\nPlease try again."); return bulletPoints.toString(); @@ -228,7 +228,7 @@ public static String noSDMRolesMessage(List files, String operation) { // Append each file name and its error message to the StringBuilder for (String item : files) { - bulletPoints.append(String.format("\t• %s%n", item)); + bulletPoints.append("\t• %s%n".formatted(item)); } bulletPoints.append(System.lineSeparator()); if (operation.equals("create")) { @@ -249,7 +249,7 @@ public static String unsupportedPropertiesMessage(List propertiesList) { // Append each unsupported file name to the StringBuilder for (String file : propertiesList) { - bulletPoints.append(String.format("\t• %s%n", file)); + bulletPoints.append("\t• %s%n".formatted(file)); } bulletPoints.append( "\nPlease contact your administrator for assistance with any necessary adjustments."); @@ -263,10 +263,10 @@ public static String getDuplicateFilesError(String filename) { } public static String getGenericError(String event) { - return String.format(GENERIC_ERROR, event); + return GENERIC_ERROR.formatted(event); } public static String getVirusFilesError(String filename) { - return String.format(VIRUS_ERROR, filename); + return VIRUS_ERROR.formatted(filename); } } diff --git a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java index b1f79db0..a59dc6d4 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java +++ b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java @@ -340,7 +340,7 @@ private void handleWarnings( context .getMessages() .warn( - String.format(SDMConstants.duplicateFilenameFormat(duplicateFileNameList)) + SDMConstants.duplicateFilenameFormat(duplicateFileNameList).formatted() + contextInfo); } if (!filesNotFound.isEmpty()) { diff --git a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMUpdateAttachmentsHandler.java b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMUpdateAttachmentsHandler.java index 88ddcadb..36f2f611 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMUpdateAttachmentsHandler.java +++ b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMUpdateAttachmentsHandler.java @@ -363,9 +363,7 @@ private void handleWarnings( if (!duplicateFileNameList.isEmpty()) { context .getMessages() - .warn( - String.format( - SDMConstants.duplicateFilenameFormat(duplicateFileNameList), contextInfo)); + .warn(SDMConstants.duplicateFilenameFormat(duplicateFileNameList).formatted(contextInfo)); } if (!filesNotFound.isEmpty()) { context.getMessages().warn(SDMConstants.fileNotFound(filesNotFound) + contextInfo); diff --git a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/helper/AttachmentsHandlerUtils.java b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/helper/AttachmentsHandlerUtils.java index a55a3e5f..e803a247 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/helper/AttachmentsHandlerUtils.java +++ b/sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/helper/AttachmentsHandlerUtils.java @@ -521,15 +521,15 @@ private static String extractTitleFromEntity(Object entityObj) { for (String field : titleFields) { Object value = entityMap.get(field); - if (value != null && value instanceof String && !((String) value).trim().isEmpty()) { - return (String) value; + if (value != null && value instanceof String string && !string.trim().isEmpty()) { + return string; } } // Fallback: find any string value for (Object value : entityMap.values()) { - if (value != null && value instanceof String && !((String) value).trim().isEmpty()) { - return (String) value; + if (value != null && value instanceof String string && !string.trim().isEmpty()) { + return string; } } @@ -579,8 +579,7 @@ public static Boolean validateFileNames( } if (duplicateFilenames != null && !duplicateFilenames.isEmpty()) { String formattedMessage = - String.format( - "%s%s", SDMConstants.duplicateFilenameFormat(duplicateFilenames), contextInfo); + "%s%s".formatted(SDMConstants.duplicateFilenameFormat(duplicateFilenames), contextInfo); context.getMessages().error(formattedMessage); isError = true; } diff --git a/sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAttachmentsReader.java b/sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAttachmentsReader.java index 1164cdf2..8f1423ad 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAttachmentsReader.java +++ b/sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAttachmentsReader.java @@ -81,7 +81,7 @@ private void collectAttachmentPaths( private boolean isAttachmentEntity(CdsModel model, String entityName) { var entityOpt = model.findEntity(entityName); - if (!entityOpt.isPresent()) { + if (entityOpt.isEmpty()) { return false; } diff --git a/sdm/src/main/java/com/sap/cds/sdm/persistence/DBQuery.java b/sdm/src/main/java/com/sap/cds/sdm/persistence/DBQuery.java index 1fa13df5..e44ae50e 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/persistence/DBQuery.java +++ b/sdm/src/main/java/com/sap/cds/sdm/persistence/DBQuery.java @@ -79,7 +79,7 @@ public CmisDocument getAttachmentForObjectID( Optional optionalParentEntity = model.findEntity(parentEntity); if (optionalParentEntity.isEmpty()) { throw new ServiceException( - String.format(SDMConstants.PARENT_ENTITY_NOT_FOUND_ERROR, parentEntity)); + SDMConstants.PARENT_ENTITY_NOT_FOUND_ERROR.formatted(parentEntity)); } // Find the composition element in the parent entity @@ -87,7 +87,7 @@ public CmisDocument getAttachmentForObjectID( optionalParentEntity.get().findElement(compositionName); if (compositionElement.isEmpty() || !compositionElement.get().getType().isAssociation()) { throw new ServiceException( - String.format(SDMConstants.COMPOSITION_NOT_FOUND_ERROR, compositionName, parentEntity)); + SDMConstants.COMPOSITION_NOT_FOUND_ERROR.formatted(compositionName, parentEntity)); } // Get the target entity of the composition @@ -98,7 +98,7 @@ public CmisDocument getAttachmentForObjectID( Optional attachmentEntity = model.findEntity(targetEntityName); if (attachmentEntity.isEmpty()) { throw new ServiceException( - String.format(SDMConstants.TARGET_ATTACHMENT_ENTITY_NOT_FOUND_ERROR, targetEntityName)); + SDMConstants.TARGET_ATTACHMENT_ENTITY_NOT_FOUND_ERROR.formatted(targetEntityName)); } // Search in active entity first diff --git a/sdm/src/main/java/com/sap/cds/sdm/service/SDMAdminServiceImpl.java b/sdm/src/main/java/com/sap/cds/sdm/service/SDMAdminServiceImpl.java index b2ee530c..1449865a 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/service/SDMAdminServiceImpl.java +++ b/sdm/src/main/java/com/sap/cds/sdm/service/SDMAdminServiceImpl.java @@ -105,8 +105,8 @@ public String onboardRepository(Repository repository) if ((responseString.contains(REPOSITORY_ID + " already exists")) && response.getStatusLine().getStatusCode() == 409) { - return String.format( - SDMConstants.REPOSITORY_ALREADY_EXIST, repository.getDisplayName(), REPOSITORY_ID); + return SDMConstants.REPOSITORY_ALREADY_EXIST.formatted( + repository.getDisplayName(), REPOSITORY_ID); } JsonObject jsonObject; @@ -117,23 +117,22 @@ public String onboardRepository(Repository repository) repositoryId = jsonObject.get("id").getAsString(); } else { logger.error( - String.format(SDMConstants.ONBOARD_REPO_ERROR_MESSAGE, repository.getDisplayName()) + SDMConstants.ONBOARD_REPO_ERROR_MESSAGE.formatted(repository.getDisplayName()) + " : " + responseString); throw new ServiceException( - String.format(SDMConstants.ONBOARD_REPO_ERROR_MESSAGE, repository.getDisplayName()), + SDMConstants.ONBOARD_REPO_ERROR_MESSAGE.formatted(repository.getDisplayName()), responseString); } - return String.format( - SDMConstants.ONBOARD_REPO_MESSAGE, repository.getDisplayName(), repositoryId); + return SDMConstants.ONBOARD_REPO_MESSAGE.formatted(repository.getDisplayName(), repositoryId); } catch (Exception e) { logger.error( - String.format(SDMConstants.ONBOARD_REPO_ERROR_MESSAGE, repository.getDisplayName()) + SDMConstants.ONBOARD_REPO_ERROR_MESSAGE.formatted(repository.getDisplayName()) + " : " + e.getMessage()); throw new ServiceException( - String.format(SDMConstants.ONBOARD_REPO_ERROR_MESSAGE, repository.getDisplayName()), e); + SDMConstants.ONBOARD_REPO_ERROR_MESSAGE.formatted(repository.getDisplayName()), e); } } diff --git a/sdm/src/main/java/com/sap/cds/sdm/service/SDMAttachmentsService.java b/sdm/src/main/java/com/sap/cds/sdm/service/SDMAttachmentsService.java index c99fc4dc..632d0ec4 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/service/SDMAttachmentsService.java +++ b/sdm/src/main/java/com/sap/cds/sdm/service/SDMAttachmentsService.java @@ -41,7 +41,7 @@ public void copyAttachments(CopyAttachmentInput input, boolean isSystemUser) { String[] facetParts = input.facet().split("\\."); if (facetParts.length < 3) { throw new IllegalArgumentException( - String.format(SDMConstants.INVALID_FACET_FORMAT_ERROR, input.facet())); + SDMConstants.INVALID_FACET_FORMAT_ERROR.formatted(input.facet())); } String parentEntity = facetParts[0] + "." + facetParts[1]; // Service.Entity diff --git a/sdm/src/main/java/com/sap/cds/sdm/service/SDMServiceImpl.java b/sdm/src/main/java/com/sap/cds/sdm/service/SDMServiceImpl.java index f1c76502..5e1fd91d 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/service/SDMServiceImpl.java +++ b/sdm/src/main/java/com/sap/cds/sdm/service/SDMServiceImpl.java @@ -631,9 +631,8 @@ public List getValidSecondaryProperties( while (iterator.hasNext()) { String value = iterator.next(); String sdmUrl = - String.format( - "%sbrowser/%s?cmisselector=typeDefinition&typeID=%s", - sdmCredentials.getUrl(), repositoryId, value); + "%sbrowser/%s?cmisselector=typeDefinition&typeID=%s" + .formatted(sdmCredentials.getUrl(), repositoryId, value); HttpGet getTypesRequest = new HttpGet(sdmUrl); try (var response = (CloseableHttpResponse) httpClient.execute(getTypesRequest)) { int statusCode = response.getStatusLine().getStatusCode(); diff --git a/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMAttachmentsServiceHandler.java b/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMAttachmentsServiceHandler.java index 86795bdb..525e400e 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMAttachmentsServiceHandler.java +++ b/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMAttachmentsServiceHandler.java @@ -243,10 +243,10 @@ private void checkAttachmentConstraints( null, eventContext.getParameterInfo().getLocale()); if (errorMessage.equalsIgnoreCase(ATTACHMENT_MAXCOUNT_ERROR_MSG)) - throw new ServiceException(String.format(SDMConstants.MAX_COUNT_ERROR_MESSAGE, maxCount)); + throw new ServiceException(SDMConstants.MAX_COUNT_ERROR_MESSAGE.formatted(maxCount)); throw new ServiceException(errorMessage); } - throw new ServiceException(String.format(SDMConstants.MAX_COUNT_ERROR_MESSAGE, maxCount)); + throw new ServiceException(SDMConstants.MAX_COUNT_ERROR_MESSAGE.formatted(maxCount)); } } diff --git a/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMServiceGenericHandler.java b/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMServiceGenericHandler.java index 1bec4714..cb732b1d 100644 --- a/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMServiceGenericHandler.java +++ b/sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMServiceGenericHandler.java @@ -454,10 +454,10 @@ private void checkAttachmentConstraints( .getLocalizedMessage( "SDM.Attachments.maxCountError", null, context.getParameterInfo().getLocale()); if (errorMessage.equalsIgnoreCase(ATTACHMENT_MAXCOUNT_ERROR_MSG)) - throw new ServiceException(String.format(SDMConstants.MAX_COUNT_ERROR_MESSAGE, maxCount)); + throw new ServiceException(SDMConstants.MAX_COUNT_ERROR_MESSAGE.formatted(maxCount)); throw new ServiceException(errorMessage); } - throw new ServiceException(String.format(SDMConstants.MAX_COUNT_ERROR_MESSAGE, maxCount)); + throw new ServiceException(SDMConstants.MAX_COUNT_ERROR_MESSAGE.formatted(maxCount)); } } diff --git a/sdm/src/test/java/integration/com/sap/cds/sdm/IntegrationTest_MultipleFacet.java b/sdm/src/test/java/integration/com/sap/cds/sdm/IntegrationTest_MultipleFacet.java index a1ec9d76..9a870224 100644 --- a/sdm/src/test/java/integration/com/sap/cds/sdm/IntegrationTest_MultipleFacet.java +++ b/sdm/src/test/java/integration/com/sap/cds/sdm/IntegrationTest_MultipleFacet.java @@ -670,9 +670,8 @@ void testRenameSingleDuplicate() { counter = -1; // Reset counter for the next check response = api.saveEntityDraft(appUrl, entityName, srvpath, entityID); String expected = - String.format( - "{\"error\":{\"code\":\"400\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: references\\nPage: IntegrationTestEntity\",\"details\":[{\"code\":\"\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: attachments\\nPage: IntegrationTestEntity\",\"@Common.numericSeverity\":4},{\"code\":\"\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: footnotes\\nPage: IntegrationTestEntity\",\"@Common.numericSeverity\":4}]}}", - name[1], name[0], name[2]); + "{\"error\":{\"code\":\"400\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: references\\nPage: IntegrationTestEntity\",\"details\":[{\"code\":\"\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: attachments\\nPage: IntegrationTestEntity\",\"@Common.numericSeverity\":4},{\"code\":\"\",\"message\":\"An object named \\\"%s\\\" already exists. Rename the object and try again.\\n\\nTable: footnotes\\nPage: IntegrationTestEntity\",\"@Common.numericSeverity\":4}]}}" + .formatted(name[1], name[0], name[2]); if (response.equals(expected)) { for (int i = 0; i < facet.length; i++) { // Attempt to rename again with a different name diff --git a/sdm/src/test/java/unit/com/sap/cds/sdm/service/SDMAdminServiceImplTest.java b/sdm/src/test/java/unit/com/sap/cds/sdm/service/SDMAdminServiceImplTest.java index cd0a959c..e3cd08c0 100644 --- a/sdm/src/test/java/unit/com/sap/cds/sdm/service/SDMAdminServiceImplTest.java +++ b/sdm/src/test/java/unit/com/sap/cds/sdm/service/SDMAdminServiceImplTest.java @@ -212,8 +212,7 @@ public void testOffboardRepository_success() throws Exception { HttpEntity mockDeleteEntity = mock(HttpEntity.class); String json = - String.format( - """ + """ { "repoAndConnectionInfos": [ { @@ -224,8 +223,8 @@ public void testOffboardRepository_success() throws Exception { } ] } -""", - SDMConstants.REPOSITORY_ID); +""" + .formatted(SDMConstants.REPOSITORY_ID); InputStream getInputStream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); InputStream deleteInputStream = @@ -396,8 +395,7 @@ public void testOffboardRepository_deleteRequestFails_throwsException() throws E HttpEntity mockGetEntity = mock(HttpEntity.class); String json = - String.format( - """ + """ { "repoAndConnectionInfos": [ { @@ -408,8 +406,8 @@ public void testOffboardRepository_deleteRequestFails_throwsException() throws E } ] } - """, - SDMConstants.REPOSITORY_ID); + """ + .formatted(SDMConstants.REPOSITORY_ID); InputStream getInputStream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); diff --git a/sdm/src/test/java/unit/com/sap/cds/sdm/service/handler/SDMServiceGenericHandlerTest.java b/sdm/src/test/java/unit/com/sap/cds/sdm/service/handler/SDMServiceGenericHandlerTest.java index 151c6463..8368c1df 100644 --- a/sdm/src/test/java/unit/com/sap/cds/sdm/service/handler/SDMServiceGenericHandlerTest.java +++ b/sdm/src/test/java/unit/com/sap/cds/sdm/service/handler/SDMServiceGenericHandlerTest.java @@ -369,7 +369,7 @@ void testCreate_ShouldThrowDefaultExceptionWhenMaxCountReached() throws IOExcept // Act & Assert ServiceException ex = assertThrows(ServiceException.class, () -> sdmServiceGenericHandler.create(mockContext)); - assertEquals(String.format(SDMConstants.MAX_COUNT_ERROR_MESSAGE, 2), ex.getMessage()); + assertEquals(SDMConstants.MAX_COUNT_ERROR_MESSAGE.formatted(2), ex.getMessage()); } @Test