diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..03dd70d4d4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# Global SW360 repo code owners ( owns all code ) +* @heliocastro @gmishx @koukihama @arunazhakesan @ag4ums + +# Docker specific +Dockerfile @heliocastro +docker-compose.yml @heliocastro + diff --git a/.github/actions/clean_up_package_registry/action.yml b/.github/actions/clean_up_package_registry/action.yml deleted file mode 100644 index ae721ac6bb..0000000000 --- a/.github/actions/clean_up_package_registry/action.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright Helio Chissini de Castro, 2023 -# SPDX-FileCopyrightText: 2024 Helio Chissini de Castro -# -# SPDX-License-Identifier: EPL-2.0 -# SPDX-License-Identifier: MIT - -name: 'Delete old non-release packages from Github package registry' -description: 'Delete older packages set by a minimal level input' -author: 'The ORT Project Authors' - -inputs: - registry: - description: 'Github container registry' - default: 'ghcr.io' - token: - description: 'Github token' - required: true - keep: - description: 'Number of non-release packages to keep' - required: false - default: '3' - packages: - description: 'Name of the packages to be cleaned up' - required: true - dry-run: - description: 'Execute a dry run operation to check the execution is correct' - default: 'false' - -runs: - using: 'composite' - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - cache: 'pip' - - - name: Execute the operation - id: check_image - shell: bash - env: - INPUT_REGISTRY: ${{ inputs.registry }} - INPUT_TOKEN: ${{ inputs.token }} - INPUT_KEEP: ${{ inputs.keep }} - INPUT_PACKAGES: ${{ inputs.packages }} - INPUT_DRY_RUN: ${{ inputs.dry-run}} - run: | - pip install -r ./.github/actions/clean_up_package_registry/requirements.txt - python ./.github/actions/clean_up_package_registry/clean_up_package_registry.py diff --git a/.github/actions/clean_up_package_registry/clean_up_package_registry.py b/.github/actions/clean_up_package_registry/clean_up_package_registry.py deleted file mode 100644 index 1bdf18f817..0000000000 --- a/.github/actions/clean_up_package_registry/clean_up_package_registry.py +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright Helio Chissini de Castro, 2023 -# -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 - - -import os -import sys -from typing import Any -from urllib.parse import parse_qs, urlparse - -import requests -from rich import print - -""" Use current Github API to list packages - in registry and remove all but last 3 or custom - set number of packages. - Reference: https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#about-github-packages -""" - -dry_run: bool = True if os.getenv("INPUT_DRY_RUN") == "true" else False -keep = int(os.getenv("INPUT_KEEP")) if os.getenv("INPUT_KEEP") else 5 -org = os.getenv("GITHUB_REPOSITORY_OWNER") -packages = os.getenv("INPUT_PACKAGES").split("\n") -token = os.getenv("INPUT_TOKEN") - -headers = { - "Accept": "application/vnd.github+json", - "Authorization": f"Bearer {token}", - "X-GitHub-Api-Version": "2022-11-28", -} - -# Assembly organization packages url string -pkg_url: str = f"https://api.github.com/orgs/{org}/packages" - - -def get_last_page(headers: dict[str, Any]) -> int: - if "link" not in headers: - return 1 - - links = headers["link"].split(", ") - - last_page = None - for link in links: - if 'rel="last"' in link: - last_page = link - break - - if last_page: - parsed_url = urlparse( - last_page[last_page.index("<") + 1 : last_page.index(">")] - ) - return int(parse_qs(parsed_url.query)["page"][0]) - - return 1 - - -def delete_packages(): - for package in packages: - print(f":package: {package}") - - # Start page is 1 as stated by documentation - url = f"{pkg_url}/container/{package.replace('/', '%2F')}/versions?page=1&per_page=50" - - # Get the header - response = requests.head(url, headers=headers) - pages: int | None = get_last_page(response.headers) - - for page in range(pages, 0, -1): - print(f"Page: {page}") - url = f"{pkg_url}/container/{package.replace('/', '%2F')}/versions?page={page}&per_page=50" - response = requests.get(url, headers=headers) - if response.status_code == 404: - print(f":cross_mark: Not found - {url}") - continue - elif response.status_code == 401: - print(f":cross_mark: Requires authentication - {url}") - sys.exit(1) - elif response.status_code == 403: - print(f":cross_mark: Forbidden - {url}") - sys.exit(1) - - # Sort all images on id. - images = sorted(response.json(), key=lambda x: x["id"], reverse=True) - - # Slice and remove all - if len(images) > keep: - for image in images if page != 1 else images[keep + 1 :]: - url = f"{pkg_url}/container/{package.replace('/', '%2F')}/versions/{image['id']}" - - # Never remove latest or non snapshot tagged images - if restrict_delete_tags(image["metadata"]["container"]["tags"]): - print( - f":package: Skip tagged {package} id {image['id']} tags {image['metadata']['container']['tags']}" - ) - continue - - if not dry_run: - response = requests.delete(url, headers=headers) - if response.status_code == 404: - print(f":cross_mark: Failed to delete package {package} version id {image['id']}.") - continue - elif response.status_code == 401: - print(f":cross_mark: Requires authentication - {url}") - sys.exit(1) - elif response.status_code == 403: - print(f":cross_mark: Forbidden - {url}") - sys.exit(1) - - tags = image["metadata"]["container"]["tags"] - if tags: - print( - f":white_heavy_check_mark: Deleted tagged package {package} version id {image['id']}" - f"with tags {tags}." - ) - else: - print( - f":white_heavy_check_mark: Deleted untagged package {package} version id {image['id']}" - ) - - -def restrict_delete_tags(tags: list) -> bool: - if not tags: - return False - for tag in tags: - if tag == "latest": - return True - elif "nightly" in tag: - return True - return False - - -if __name__ == "__main__": - delete_packages() diff --git a/.github/actions/clean_up_package_registry/requirements.txt b/.github/actions/clean_up_package_registry/requirements.txt deleted file mode 100644 index feb07bd95e..0000000000 --- a/.github/actions/clean_up_package_registry/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -certifi==2023.7.22 -charset-normalizer==3.3.2 -idna==3.7 -markdown-it-py==3.0.0 -mdurl==0.1.2 -Pygments==2.16.1 -requests==2.31.0 -rich==13.6.0 -urllib3==2.1.0 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..0743fa3ae1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + + - package-ecosystem: docker + directory: / + schedule: + interval: daily + + - package-ecosystem: maven + directory: / + schedule: + interval: daily diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000000..d06efdd542 --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,31 @@ + +--- +name: Bug report +about: Create a report to help us improve +labels: bug +--- + + + +### Description + +Please describe your issue in few words here. + +#### How to reproduce + +Describe the bug and list the steps you used when the issue occurred. + +#### Screenshots ( if applicable ) + +Add screenshots to help explain your problem. + +### Versions + +* Docker version OR +* Last commit id on main + +#### SW360 logs + +* With docker through `docker logs sw360` +* From bare metal / vm install system under /var/log/sw360/sw360.log and /var/log/tomcat/error.log diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d06efdd542..b1954ba126 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,31 +1,21 @@ +[//]: # (This program and the accompanying materials are made) +[//]: # (available under the terms of the Eclipse Public License 2.0) +[//]: # (which is available at https://www.eclipse.org/legal/epl-2.0/) +[//]: # (SPDX-License-Identifier: EPL-2.0) ---- -name: Bug report -about: Create a report to help us improve -labels: bug ---- +> Please provide a summary of your changes here. +> * Which issue is this pull request belonging to and how is it solving it? (*Refer to issue here*) +> * Did you add or update any new dependencies that are required for your change? - +Issue: -### Description +### Suggest Reviewer +> You can suggest reviewers here with an @mention. -Please describe your issue in few words here. +### How To Test? +> How should these changes be tested by the reviewer? +> Have you implemented any additional tests? -#### How to reproduce - -Describe the bug and list the steps you used when the issue occurred. - -#### Screenshots ( if applicable ) - -Add screenshots to help explain your problem. - -### Versions - -* Docker version OR -* Last commit id on main - -#### SW360 logs - -* With docker through `docker logs sw360` -* From bare metal / vm install system under /var/log/sw360/sw360.log and /var/log/tomcat/error.log +### Checklist +Must: +- [ ] All related issues are referenced in commit messages and in PR diff --git a/.github/testForLicenseHeaders.sh b/.github/testForLicenseHeaders.sh index 98466b7eb3..3e54fa74f3 100755 --- a/.github/testForLicenseHeaders.sh +++ b/.github/testForLicenseHeaders.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ----------------------------------------------------------------------------- # Copyright Siemens AG, 2017. # Copyright Bosch.IO 2020. @@ -20,6 +20,7 @@ cd "$(dirname "$0")/.." || exit 1 failure=false while read -r file ; do + # shellcheck disable=SC2086 if ! head -15 "$file" | grep -q 'SPDX-License-Identifier:' $file; then echo "WARN: no 'SPDX-License-Identifier' in $file" fi @@ -34,19 +35,19 @@ while read -r file ; do failure=true done <<< "$(git ls-files \ | grep -Ev '\.(csv|rdf|ent|dtd|lar|png|gif|psd|ico|jpg|docx|gitignore|dockerignore|cert|jks|spdx|rdf|MockMaker|json)' \ - | grep -Ev '(LICENSE|NOTICE|README|CHANGELOG|CODE_OF_CONDUCT|CONTRIBUTING|Language|Language_vi)' \ + | grep -Ev '(LICENSE|NOTICE|README|SECURITY|CHANGELOG|CODE_OF_CONDUCT|CONTRIBUTING|Language|Language_vi)' \ | grep -v .pre-commit-config.yaml \ | grep -v 'id_rsa' \ | grep -v '.versions' \ - | grep -v '.github/actions/docker_control/action.yml' \ - | grep -v '.github/actions/docker_control/check_image.py' \ - | grep -v '.github/ISSUE_TEMPLATE/*' \ - | grep -v '.github/pull_request_template.md' \ + | grep -v '.github/*' \ + | grep -v 'scripts/lint/checkstyle.xml' \ + | grep -v 'scripts/lint/google_checks.xml' \ | grep -v 'sw360.code-workspace' \ | grep -v 'default_secrets' \ | grep -v 'requirements.txt' \ - | grep -Ev 'third-party/couchdb-lucene/*' \ - | grep -Ev '*/asciidoc/*')" + | grep -Ev '.*/asciidoc/.*' \ + | grep -Ev '.vscode/*' \ + | grep -Ev 'config/*')" if [ "$failure" = true ]; then echo "test failed" diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 7d3b754d2c..fb09b3273b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -14,107 +14,100 @@ name: SW360 Build and Test on: pull_request: - branches: [ main ] + branches: [main] paths-ignore: - "**.md" - ".github/workflows/docker_deploy.yml" + - ".github/workflows/scorecard.yml" workflow_dispatch: -permissions: write-all - env: - COUCHDB_USER: admin - COUCHDB_PASSWORD: password + COUCHDB_USER: sw360 + COUCHDB_PASSWORD: sw360fossie + +permissions: + contents: read jobs: build: name: Build and Test - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - - uses: webiny/action-conventional-commits@v1.3.0 - - - name: Verify license headers - run: | - chmod +x .github/testForLicenseHeaders.sh - bash .github/testForLicenseHeaders.sh - - - name: Set environment variables - run: | - echo _JAVA_OPTIONS= '-Djdk.util.zip.disableZip64ExtraFieldValidation=true' >> $GITHUB_ENV - cat .versions >> $GITHUB_ENV - - - name: Setup CouchDB - run: scripts/startCouchdbForTests.sh - - - name: Update properties with DB credentials - run: | - sudo mkdir -p /etc/sw360 - sudo cp ./build-configuration/test-resources/couchdb-test.properties /etc/sw360/ - sudo cp ./scripts/sw360BackendRestDockerConfig/etc_sw360/rest-test.properties /etc/sw360/ - sudo sed -i 's/^couchdb.user\s*=/& '${COUCHDB_USER}'/' /etc/sw360/couchdb-test.properties - sudo sed -i 's/^couchdb.password\s*=/& '${COUCHDB_PASSWORD}'/' /etc/sw360/couchdb-test.properties - - - name: Prepare build environment - run: | - sudo apt-get update -qq - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq python3-pip build-essential libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config libssl-dev git cmake - pip install mkdocs mkdocs-material - - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - java-version: '11' - distribution: 'temurin' - check-latest: true - cache: 'maven' - - - name: Cache Thrift - id: cache-thrift - uses: actions/cache@v4 - with: - path: | - /usr/local/bin/thrift - /usr/share/thrift/${{ env.THRIFT_VERSION }} - key: ${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }} - restore-keys: | - ${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }} - - - name: Install Thrift - if: steps.cache-thrift.outputs.cache-hit != 'true' - run: | - chmod +x scripts/install-thrift.sh - bash scripts/install-thrift.sh - - - name: Build SW360 - run: | - mvn clean install --no-transfer-progress -P deploy -Dhelp-docs=true -Dbase.deploy.dir=. -Dliferay.deploy.dir=${PWD}/deploy -Dbackend.deploy.dir=${PWD}/deploy/webapps -Drest.deploy.dir=${PWD}/deploy/webapps -DRunComponentVisibilityRestrictionTest=false -DRunPrivateProjectAccessTest=false -DRunRestForceUpdateTest=false - - - name: Run PrivateProjectAccessTest - run: | - cd build-configuration - mvn install - cd .. - cd libraries/datahandler - mvn test -Dtest=ProjectPermissionsVisibilityTest -DRunPrivateProjectAccessTest=true -DRunRestForceUpdateTest=true - cd ../.. - - - name: Run BulkReleaseDeletingTest - run: | - cd backend/src/src-components - mvn test -Dtest=BulkDeleteUtilTest -DRunPrivateProjectAccessTest=true -DRunBulkReleaseDeletingTest=true - - - name: Deploy Backend and Rest Server - run: | - sudo docker build -t sw360backendrest -f sw360BackendRest.Dockerfile . - sudo docker run -dt --network=host sw360backendrest - bash scripts/sw360BackendRestDockerConfig/scripts/checkDeploymentIsSuccess.sh - - - name: Create users and oauth client - run: bash scripts/sw360BackendRestDockerConfig/scripts/createUserAndOauthClient.sh - - - name: Run Client Integration Test for Rest Api - run: | - cd clients - mvn clean install --no-transfer-progress -DRunRestIntegrationTest=true + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: webiny/action-conventional-commits@8bc41ff4e7d423d56fa4905f6ff79209a78776c7 # v1.3.0 + + - name: Verify license headers + run: | + chmod +x .github/testForLicenseHeaders.sh + bash .github/testForLicenseHeaders.sh + + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + + - name: Setup CouchDB + run: scripts/startCouchdbForTests.sh + + - name: Update properties with DB credentials + run: | + sudo mkdir -p /etc/sw360 + sudo cp ./build-configuration/test-resources/couchdb-test.properties /etc/sw360/ + sudo sed -i 's/^couchdb.user\s*=/& '${COUCHDB_USER}'/' /etc/sw360/couchdb-test.properties + sudo sed -i 's/^couchdb.password\s*=/& '${COUCHDB_PASSWORD}'/' /etc/sw360/couchdb-test.properties + + - name: Set up JDK 21 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 + with: + java-version: "21" + distribution: "temurin" + check-latest: true + cache: "maven" + + - name: Cache Thrift + id: cache-thrift + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + with: + path: | + ${{ github.workspace }}/dist/thrift-${{ env.THRIFT_VERSION }} + key: ${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }} + restore-keys: | + ${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }} + + - name: Install Thrift + if: steps.cache-thrift.outputs.cache-hit != 'true' + run: | + sudo apt-get update -qq + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq build-essential libevent-dev libtool flex bison pkg-config libssl-dev git cmake + chmod +x scripts/install-thrift.sh + DESTDIR=${{ github.workspace }}/dist/thrift-${{ env.THRIFT_VERSION }} scripts/install-thrift.sh + + - name: Build SW360 + run: | + export PATH=$PATH:${{ github.workspace }}/dist/thrift-${{ env.THRIFT_VERSION }}/usr/local/bin + mvn clean install \ + --no-transfer-progress \ + -P deploy -Dhelp-docs=true \ + -Dbase.deploy.dir=. \ + -Djars.deploy.dir=${PWD}/deploy \ + -Dbackend.deploy.dir=${PWD}/deploy/webapps \ + -Drest.deploy.dir=${PWD}/deploy/webapps \ + -DRunComponentVisibilityRestrictionTest=false \ + -DRunPrivateProjectAccessTest=false \ + -DRunRestForceUpdateTest=false \ + -fae \ + -Dmaven.plugin.validation=VERBOSE + + - name: Run PrivateProjectAccessTest + run: | + mvn install -pl :build-configuration -am -Dbase.deploy.dir=. + mvn -pl :datahandler test -Dtest=ProjectPermissionsVisibilityTest -DRunPrivateProjectAccessTest=true -DRunRestForceUpdateTest=true -Dbase.deploy.dir=. + + - name: Run BulkReleaseDeletingTest + run: | + mvn -pl :backend-components test -Dtest=BulkDeleteUtilTest -DRunPrivateProjectAccessTest=true -DRunBulkReleaseDeletingTest=true -Dbase.deploy.dir=. diff --git a/.github/workflows/clean_up_package_registry.yml b/.github/workflows/clean_up_package_registry.yml deleted file mode 100644 index 1fd3680cfb..0000000000 --- a/.github/workflows/clean_up_package_registry.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright Helio Chissini de Castro, 2023 -# -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 - -name: Clean up packages in Github package registry - -on: - workflow_dispatch: - # Runs always Sunday Midnight - schedule: - - cron: "0 0 * * 0" - -jobs: - clean_all: - name: Cleaning older packages - runs-on: ubuntu-22.04 - steps: - - name: Checkout default branch - uses: actions/checkout@v4 - - name: Clean up package registry - uses: ./.github/actions/clean_up_package_registry - with: - token: ${{ secrets.GITHUB_TOKEN }} - packages: |- - sw360 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..1f6ffb7653 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,101 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: ["main"] + schedule: + - cron: "55 5 * * *" + workflow_dispatch: + +permissions: + contents: read + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: "ubuntu-24.04" + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: java-kotlin + build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too. + - language: python + build-mode: none + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000000..21a469b132 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,27 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, +# PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: 'Dependency Review' + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.github/workflows/docker_deploy.yml b/.github/workflows/docker_deploy.yml index 623f937e59..e890990704 100644 --- a/.github/workflows/docker_deploy.yml +++ b/.github/workflows/docker_deploy.yml @@ -1,5 +1,6 @@ # ----------------------------------------------------------------------------- # Copyright Helio Chissini de Castro 2022. +# Copyright Cariad SE 2024 # Part of the SW360 Project. # # This program and the accompanying materials are made @@ -14,93 +15,77 @@ name: Docker Build on: schedule: - - cron: '0 0 * * *' # Midnight + - cron: "0 0 * * *" # Midnight workflow_dispatch: inputs: invalidate-cache: - description: 'Build all images disregarding exists same version' + description: "Build all images disregarding exists same version" required: false debug: - description: 'Debug docker build' + description: "Debug docker build" required: false push: tags: - - 'sw360-*' + - "sw360-*" paths-ignore: - - '**.md' + - "**.md" env: REGISTRY: ghcr.io -permissions: write-all +permissions: + contents: read jobs: sw360_version: name: SW360 Version - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 outputs: sw360_version: ${{ steps.pom_version.outputs.SW360_VERSION }} - steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout main repository - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Set up JDK 11 - uses: actions/setup-java@v4 + - name: Set up JDK 17 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 with: - java-version: '11' - cache: 'maven' - distribution: 'temurin' + java-version: "17" + cache: "maven" + distribution: "temurin" - name: Get revision from pom.xml id: pom_version run: | echo "SW360_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)" >> "$GITHUB_OUTPUT" - base_image: - name: SW360 Base image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout default branch - uses: actions/checkout@v4 - - name: Set environment variables - run: | - cat .versions >> $GITHUB_ENV - - name: Build base image - uses: heliocastro/docker-build-control@v1 - with: - name: base - token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ env.JAVA_VERSION }}-jdk-${{ env.UBUNTU_VERSION }} - invalidate-cache: ${{ inputs.invalidate-cache }} - debug: ${{ inputs.debug }} - build-args: | - LIFERAY_VERSION=${{ env.LIFERAY_VERSION }} - LIFERAY_SOURCE=${{ env.LIFERAY_SOURCE }} - JAVA_VERSION=${{ env.JAVA_VERSION }} - UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} thrift_image: name: Build SW360 Thrift image - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: - contents: read packages: write steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout main repository - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set environment variables run: | cat .versions >> $GITHUB_ENV - name: Build thrift image - uses: heliocastro/docker-build-control@v1 + uses: heliocastro/docker-build-control@944a0451eadb63cf4f45a8ca66dba07118740faf # v5.1 with: name: thrift + target: localthrift token: ${{ secrets.GITHUB_TOKEN }} version: ${{ env.THRIFT_VERSION }} invalidate-cache: ${{ inputs.invalidate-cache }} @@ -110,25 +95,29 @@ jobs: binary_image: name: SW360 Binary - needs: [sw360_version, base_image, thrift_image] - runs-on: ubuntu-latest + needs: [sw360_version, thrift_image] + runs-on: ubuntu-24.04 permissions: - contents: read packages: write steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout main repository - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set environment variables run: | cat .versions >> $GITHUB_ENV - name: Build binary image - uses: heliocastro/docker-build-control@v1 + uses: heliocastro/docker-build-control@944a0451eadb63cf4f45a8ca66dba07118740faf # v5.1 with: name: binaries - version: ${{ needs.sw360_version.outputs.sw360_version }} + version: ${{ env.SW360_VERSION }} token: ${{ secrets.GITHUB_TOKEN }} invalidate-cache: ${{ inputs.invalidate-cache }} debug: ${{ inputs.debug }} @@ -136,31 +125,35 @@ jobs: THRIFT_VERSION=${{ env.THRIFT_VERSION }} SW360_VERSION=${{ env.SHORT_SHA }} secret-files: | - "sw360=./scripts/docker-config/default_secrets" + "couchdb=./config/couchdb/default_secrets" build-contexts: | - thrift=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/thrift:${{ env.THRIFT_VERSION }} + localthrift=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/thrift:${{ env.THRIFT_VERSION }} runtime_image: name: SW360 Runtime image - needs: [sw360_version, base_image, binary_image] - runs-on: ubuntu-latest + needs: [sw360_version, binary_image] + runs-on: ubuntu-24.04 permissions: - contents: read packages: write steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout main repository - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set environment variables run: | cat .versions >> $GITHUB_ENV - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 - name: Login to GitHub Container Registry - uses: docker/login-action@v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -168,25 +161,26 @@ jobs: - name: Extract components metadata (tags, labels) runtime image id: meta_runtime - uses: docker/metadata-action@v5 + uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 with: images: | ${{ env.REGISTRY }}/${{ github.repository }} tags: | type=schedule,pattern={{date 'YYYYMMDD'}} type=schedule,pattern=nightly - type=raw,value=${{ needs.sw360_version.outputs.sw360_version }} + type=raw,value=${{ env.SW360_VERSION }} type=sha,enable=true,prefix=sha-,format=short type=ref,event=tag - name: Build image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 with: context: . target: sw360 push: true tags: ${{ steps.meta_runtime.outputs.tags }} labels: ${{ steps.meta_runtime.outputs.labels }} + provenance: mode=max + sbom: true build-contexts: | - base=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:${{ env.JAVA_VERSION }}-jdk-${{ env.UBUNTU_VERSION }} - binaries=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/binaries:${{ needs.sw360_version.outputs.sw360_version }} + binaries=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/binaries:${{ env.SW360_VERSION }} diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000000..64e2bd5414 --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,60 @@ +# ----------------------------------------------------------------------------- +# Copyright Helio Chissini de Castro 2022. +# Part of the SW360 Project. +# +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# ----------------------------------------------------------------------------- + +name: Scorecard supply-chain security +on: + workflow_dispatch: + branch_protection_rule: + schedule: + - cron: "22 22 * * 2" + push: + branches: ["main"] + +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + security-events: write + id-token: write + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + + - name: "Upload artifact" + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + sarif_file: results.sarif diff --git a/.gitignore b/.gitignore index a22b8df9b7..94d3d8ba15 100644 --- a/.gitignore +++ b/.gitignore @@ -33,10 +33,6 @@ jgiven-reports/ .settings .factorypath -# Ignore VSCode files -.vscode/ -#*.code-workspace - # Ignore backup files *.bak *.orig @@ -48,7 +44,7 @@ jgiven-reports/ # Ignore docker local files deps data -config +#config .tmp .env @@ -67,3 +63,12 @@ tmp/**/* # DS_Store .DS_Store + +.python-version + +# Local logs for dev runtime +logs +scripts/docker-config/etc_sw360/couchdb-test.properties +scripts/docker-config/etc_sw360/couchdb.properties +**/*.versionsBackup +output diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5303b9e831..ed725f34db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,25 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v5.0.0 hooks: + - id: end-of-file-fixer + - id: trailing-whitespace - id: check-merge-conflict - # - id: end-of-file-fixer - # - id: trailing-whitespace - repo: https://github.com/compilerla/conventional-pre-commit - rev: 'v2.1.1' + rev: 'v3.6.0' hooks: - id: conventional-pre-commit stages: [commit-msg] - -- repo: https://github.com/ejba/pre-commit-maven - rev: v0.3.3 +- repo: https://github.com/gitleaks/gitleaks + rev: v8.21.2 + hooks: + - id: gitleaks +- repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck +- repo: https://github.com/pylint-dev/pylint + rev: v3.3.1 hooks: - - id: maven-spotless-apply - stages: [manual] - always_run: false \ No newline at end of file + - id: pylint diff --git a/.versions b/.versions index 52977f040e..4dd9e9b126 100755 --- a/.versions +++ b/.versions @@ -1,5 +1,3 @@ -THRIFT_VERSION=0.18.1 -LIFERAY_VERSION=7.4.3.18-ga18 -LIFERAY_SOURCE=liferay-ce-portal-tomcat-7.4.3.18-ga18-20220329092001364.tar.gz -UBUNTU_VERSION=jammy -JAVA_VERSION=11 +THRIFT_VERSION=0.20.0 +JAVA_VERSION=21 +SW360_VERSION=19.0.0 diff --git a/.vscode/java-formatter.xml b/.vscode/java-formatter.xml new file mode 100644 index 0000000000..7bb6804eb3 --- /dev/null +++ b/.vscode/java-formatter.xml @@ -0,0 +1,337 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index aaa24d55fa..2c262d9716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,367 @@ This is the changelog file of the sw360 project. It starts with the first releas https://github.com/sw360/sw360portal/releases +## sw360-19.0.0-M1 +This tag covers many corrections, bug fixes and features after the 18.1 release. +Version 19.0.0 is also the first release without the Front-end integrated, but +as a separate [sw360-frontend](https://github.com/eclipse-sw360/sw360-frontend) +project. + +Major changes in the release includes: +* Removal of Liferay and related libraries, OSGi framework +* Unification of various backend packages from src and svd +* Support for Java 21 and Apache Tomcat 11.0.0 +* Replace couchdb-lucene with couchdb-nouveau + +### Credits + +The following GitHub users have contributed to the source code since the last +release (in alphabetical order): + +``` +> afsahsyeda +> Akshit Joshi +> Gaurav Mishra +> Helio Chissini de Castro +> hoangnt2 +> Keerthi B L +> Nikesh Kumar +> Rudra Chopra +> Sameed +> Smruti Prakash Sahoo +> tuannn2 +``` + +Please note that also many other persons usually contribute to the project with +reviews, testing, documentations, conversations or presentations. + +### Features +* `c167bcca9` feat(rest): Endpoint to add comment on a clearing request +* `cd97b6154` feat(rest): Create new endpoint for schedule CVE and schedule attachment deletion. +* `00d70bcc5` feat(rest): get releases used by vendor +* `31b720b9e` feat(rest) : Rest end point for generate source code bundle +* `062a89290` feat(rest): saveUsages in project page +* `9751a2e1a` feat(Project): Add new endpoint for project's license clearing tree view (New GUI) +* `546d35b73` feat(Project): Import SPDX as dependency network +* `a18b053f5` feat(rest): Create new endpoint to download component template in csv format. +* `144ea5b81` feat(rest) : Move GenerateLicenseInfoFile rest end point to SW360reportcontroller +* `61ec9ac39` feat(REST): Exclude release version from license info +* `295f1cbff` feat(rest): fetch group list in project add and edit page. +* `e9ec8d8a7` feat: Make Java 21 default +* `cb99fc678` feat(ImportSBOM):Change naming convention of imported components +* `441fa7d85` feat(Project): Create new endpoint to serve list view of dependency network (New GUI) +* `7b4c534e3` feat(cloudant): use IBM SDK +* `09586fad6` feat(ektorp): remove ektorp from search handlers +* `af0262112` feat(lucene): nouveau integration +* `a019b468b` feat(keycloak-spis): Added the custom keycloak SPIs +* `3c453670d` feat(couchdb): Enable use of latest CouchDB with nouveau +* `8fdd93c86` feat(rest): endpoint to update a vendor. +* `bff430140` feat: Add CODEOWNERS to the repository +* `90ad3ea1c` feat(rest): Add additional fields in get clearingrequest endpoints. +* `771b965b2` feat(ComponentPortletandImportCDX): Validate VCS URL and sanitize GitHub Repo URLs during CDX import +* `99d0c80ed` feat(api): postpone moderation request action +* `af15a09e3` feat(rest): includeAllAttachments parameter in licenseInfo endpoint +* `66cac90c6` feat(CycloneDX): Make methods compatible with cyclonedx upgrade and update jackson version +* `9a15832c0` feat(rest): Endpoint to get comments of a Clearing Request. +* `ffbf1b183` feat(project): endpoint for vulnerabilitySummary page. +* `0d6908ab2` feat(project): Add necessary library dependencies required by rest code +* `acb1e54ea` feat(vscode): Add base Eclipse java formatter config file +* `a29d5b0c2` feat: Generate provenance and SBOMs on Docker images +* `8b6aa42cf` feat(docs): Remove old asciidocs support +* `fd0546244` feat: Update to Ubuntu 24.04 (Noble) +* `8f971f765` feat(rest): new endpoint for releases of linked projects. +* `5bd4cae83` feat(obligation): rest endpoint to update license obligations of the project. +* `3c40f09f2` feat(License): Add API Listing LicenseType and Add pageble for licenses, obligations +* `204ce2f02` feat: Add scorecard + +### Corrections +* `9452b2b89` fix(cloudant): fix attachment creation +* `5bdef6d51` fix(pom): fixed the java version in kc module pom.xml +* `48e0f6c8c` fix(ImportCDX): VCS sanitization failing on characters like colon +* `dc18109b8` fix(Project): Fix project handler test with dependency network feature +* `5702dc595` fix(clearingState): making fossology report download configurable. +* `3f10b6856` fix(build): add the missing excludeReleaseVersion +* `69fcc6c9f` fix(servlet): complete migration javax to jakarta +* `3cad1c4aa` fix(UI): Add lang attribute to ReadmeOSS.html for generated license info. +* `77b801825` fix(keycloak-spi): Added the README.md +* `e43c3422a` fix(nouveau): fix nouveau query result +* `442ac94c7` fix(test): fix test cases with cloudant SDK +* `41e3d4605` fix(nouveau): extend nouveau connector as cloudant +* `cbcffd979` fix(cloudant): fix query builders +* `ced70a0e4` fix(cloudant): fix views +* `57f5b6908` fix(REST): Patch Release is causing the clearing state to be updated to NEW even if a Clearing is existing +* `5c4810a56` fix(backend): fix dependency for backend core +* `f0719b97a` fix(rest): Resolved null value returning for svm tracking status. +* `fe05d9f29` fix(rest): Update search API to return 200 status with empty results array when no match found +* `b0c11a1fb` fix(GenerateLicenseInfo): Generate License Info failing for releases having the same CLX +* `d6f630021` fix(rest): Ensure visibility field is case-insensitive +* `6a1408f50` fix(doc): fix OpenAPI doc for Search endpoint +* `83796a935` fix(rest): add requestClosedOn field in get clearingRequest_by_id endpoint +* `45a8137f3` fix: Update docker documentation to reflect current status +* `9dc2d6835` fix(rest): Enable back authorization and resource server with up to dat springboot +* `c493d83bf` fix(couchdb): Move setup data for single file and update compose to use as read only +* `c15e36cd8` fix(docker): Use Tomcat with Ubuntu 24.04 (Noble) +* `d655adc64` fix(rest): Add null check for linkedProject field if it is empty +* `77bdbf7f6` fix(rest): Add null check for linkedProject field to prevent Internal Server Error on GET request to fetch the linked projects of a project +* `5943127c6` fix(rest): Add code to update user details when creating a moderation request. +* `9777923f8` fix(docker): Reinstate docker builds +* `0265205b0` fix(docker): Update docker build to fit Ubuntu Noble and improved caching +* `293e025cf` fix(rest): Added JWT token convert to fix the issue with authorities +* `540f9baf1` fix(rest): Added the Oidc user info customizer and token customizer +* `1fb7bcf97` fix(rest): Add null check for linkedProject field to prevent Internal Server Error on GET request to fetch the linked projects of a project +* `3f6ae983b` fix(importCDX):Improve error message when PURL is invalid +* `3dfbb5538` fix(rest): Fix internal server error with 500 status code for link project to projects endpoint +* `f0e149422` fix(rest): Fixing pagination for endpoint '/packages'. +* `0d88cacc7` fix(rest) : Non uniform link format in attachmentUsage end point +* `fea2d4eda` fix(rest): Fixed the swagger issue +* `01218278d` fix(backend) : Product clearing report generated has strange numbering issue fix +* `da95be6e7` fix(rest): Added modifiedBy field in get package_by_id endpoint. +* `82ad83e70` Revert "fix(rest): Fixed the swagger issue" +* `cc38d07df` fix(rest): Fixed the swagger issue +* `51fabdfc2` fix(rest):Added code to resolve the server error while fetching a summaryAdministraion endpoint. +* `b262c4c82` fix(rest): Fixing the rest test cases +* `308ce540b` fix(rest): Added a missed field in package endpoint for allDetails. +* `8f0560c04` fix: Only publish test report on failures +* `f48e6d27b` fix: Thrift cache location +* `b69720c91` fix: Update thrift build to fix github caching +* `89f47fe05` fix(test): Proper build tests now without jump folders +* `4dd4f8aa7` fix: Remove wrong placed copyrights on commit template +* `f8dcd79f2` fix(test): Disable rest test to avoid chicken and egg integration +* `7ce112133` fix(github): restore pull_request_template.md + +### Infrastructure +* `4e883a5a1` chore(deps): bump org.springframework:spring-context +* `7dd44a5fd` chore: Add maven validation on build +* `d086e9a71` chore(deps): bump org.keycloak:keycloak-core +* `2d90a9a00` chore(deps): bump org.keycloak:keycloak-core +* `bfd296052` chore(maven): deploy keycloak listeners +* `c71b0d5c4` chore(maven): segregate war and jar deploy dirs +* `d9b3edf25` chore: Add Tomcat 11 default for Docker +* `872c74ef1` chore(nouveau): catch exception for nouveau query +* `824504564` chore(docker): update compose with dockerhub image +* `3fc2e0976` chore(couchdb-lucene): remove third-party/couchdb-lucene +* `111a0fe88` chore(refactor): Refactored the models by adding Lombok +* `e3dccf3ee` chore: Reduce couchdb log level on docker compose +* `e3f3dab7e` chore: Update the license header checkfor CODEOWNERS +* `af056ef15` chore: Properly set components servlet as war file +* `27fddd182` refactor: Use the correct thrift image +* `56b63f065` refactor: Remove dead code comments +* `7b3fe9233` chore: CouchDB setup can't be read only +* `442970d4c` chore: Add color coding for sw360 project +* `30b6114f8` refactor(backend): Adjust component test call +* `9a09353af` refactor(backend): Disable ComponentImportTestUtils +* `a0369e0a3` refactor(backend): Allow test properties be configurable +* `b7d9941dd` refactor(backend): Fix licenseinfo test +* `2f24d0b3e` chore: Disable logging on disk for couchdb and configure authorization server +* `bc759edb4` refactor(backend): Restore webapps install +* `a9cff25ea` chore: Fix version dependencies +* `a81fe91dc` refactor(backend): Remove invalid recursive add-build-configuration process +* `a973a70f4` refactor(backend): Disable usage of Handlers by importer +* `2019328a3` refactor(backend): Adjust dependencies for subprojects +* `a5df30cbb` refactor(backend): Move svc-common to service-core +* `2e9b67182` refactor(backend): Create licenses-core shared library +* `d1f88af5c` refactor(backend): Move vulnerabilities shared classes to core +* `eaeb4e0e8` refactor(backend): Unify source tree +* `eec9f1557` chore(vscode): Increase memory requirements for language server +* `9dbbaf958` chore: Update README_DOCKER with proper commands +* `1bb1ce228` chore: Update couchdb user and password for scripts +* `86be40d49` chore: Ignore vscode directory +* `d1e1269b2` chore: Remove dead code +* `e8d6398cc` chore(docker): Fix syntax warnings +* `09517affc` ci(docker): Use correct thrift docker context +* `f10c1b0bb` refactor(docker): Adjust CouchDB configurations +* `714e16eac` ci: Minor quality control fixes +* `406b2eec2` chore: Remove pom duplicates +* `828c05a63` build(deps): bump urllib3 in /.github/actions/clean_up_package_registry +* `612bce6b7` refactor: Remove liferay deploy dir +* `0462eec98` refactor(project): Remove OSGI bundle plugin +* `51af9238f` refactor(libraries): Remove OSGI bundle from importers +* `d66d6f6db` refactor(libraries): Remove OSGI bundle from exporters +* `a305f5f08` refactor(libraries): Remove OSGI bundle from CommonIO +* `0507602ba` refactor(datahandler): Remove OSGI bundle +* `063c294e1` refactor(project): Remove log4j-osgi-support +* `8505587a3` chore: Remove unused buildnumber plugin +* `1eb27eb2c` refactor: Remove liferay build references +* `41e6951ea` chore: Remove unused spotless plugin +* `e2719816b` chore: Remove unused flatten plugin +* `2e04e949d` chore: Place enforcer plugin in correct place +* `712f7c057` refactor: Versioning update +* `474323658` chore: Update gitignore and ide settings +* `8d493bcd3` build(deps): bump requests in /.github/actions/clean_up_package_registry +* `f754535e4` chore: Ignore templates to check license +* `02824ef71` chore(project): Minor clenaups +* `8b68eff39` refactor(docker): Modernize docker without liferay +* `447c89c68` refactor(project): Adjust dependencies for Java 17 and Liferay removal +* `f7dc1d0f9` build(deps): bump certifi in /.github/actions/clean_up_package_registry +* `f8b201838` build(deps): bump org.springframework:spring-web from 6.1.5 to 6.1.6 +* `83da48abc` chore(upgrade): skipped rest auth server test cases until its fixed +* `d31c5bd60` chore(upgrade): Resolving src-licenseinfo module test cases. +* `8a2688883` chore(upgrade): Added a patch for the java 17 related changes w.r.t couchdb-lucene +* `aa9422126` chore(upgrade): Authorization upgrade +* `a2a30f552` chore(upgrade): Upgrade to Java 17 +* `d8d8ef585` chore(upgrade): Remove liferay +* `62829f44c` refactor(java): Disable some tests to easy migration +* `0cfdeada8` ci(java): Update to Java 17 as default and enforce it + + +## sw360-18.1.0-M1 +This tag includes important corrections and fixes following the 18.0 pre-release. It is also the final tag with Liferay, as SW360 will use the SW360-frontend project (https://github.com/eclipse-sw360/sw360-frontend) starting from the next release. + +### Migrations + +For existing installations, a data migration is required with PR 1963. Please go to the readme file in scripts/migrations to see more information: + +https://github.com/eclipse/sw360/blob/master/scripts/migrations/README.md + +Note: For running the migrations scripts, you will need python and the couchdb package. Please note that you will need to change manually in the python file: the DRYRUN variable and the couchdb URL (if that is not on localhost or requires password or both). + +### Credits + +The following github users have contributed to the source code since the last release (in alphabetical order): + +``` +> Afsah Syeda +> Aftab, Farooq Fateh (ext) +> Anupam Ghosh +> Akshit Joshi +> Eldrin +> Gaurav Mishra +> Helio Chissini de Castro +> Jens Viebig +> hoangnt2 +> Keerthi B L +> Nikesh kumar +> rudra-superrr +> sameed.ahmad +> tuannn2 +``` + +Please note that also many other persons usually contribute to the project with reviews, testing, documentations, conversations or presentations. + +### Features +* `4bfabe486` feat(rest) : Remove mail-request parameter and read from config file +* `96863d14c` feat(REST): Search package by purl and version +* `684d90117` feat(REST): Create clearing request for a project and move the preferred clearing date limit field out of Liferay" +* `fe044d00` feat(project): Added release field for licenseObligation get endpoint +* `70837b27` feat(rest): filter attachment usages in project +* `ea94202b` feat(license): Update Whitelist +* `af155858` feat(CR): Update clearing request state from AWAITING RESPONSE to PENDING INPUT +* `2bd2b2fd` feat(vscode): Add workspace java settings +* `8ceba8fb` feat(docker): Add test build using docker +* `944a7164` feat(rest): added pagination for vulnerability tracking status page. +* `70391d07` feat(rest): add license obligations to a project. +* `4f65386f` feat(obligation): endpoint to list license obligation table data +* `5fcb3533` feat(rest) : endpoint to list license obligations from license database. +* `240c73f3` feat(CR): Create a new Clearing Request state Sanity Check to perform sanity check before accepting a project +* `4bc56326` Revert "feat(CR): Disable Clearing Request creation for the projects which have linked releases without SRC type attachment" +* `71d3a470` Feat(User): Create new endpoints to Create/Revoke/List rest api token +* `d4820efc` feat(Rest) : Download license clearing report end point. +* `14fda713` feat(api): new endpoint /mySubmissions +* `cec7f4b7` feat(docker): Improve output of check_image script. +* `d7699485` feat(docker): Revamp docker build setup +* `2ddf76f0` feat(user): Enable API user endpoint by default +* `36a41cef` feat(Obligation): adding obligation type data in license obligation table. +* `44219a39` feat(rest) : Pagination for vulnerability tracking status +* `b925c0ab` Revert "feat(UI): enhanced date filter for open and closed clearing requests tab" +* `a3038447` feat(UI): enhanced date filter for open and closed clearing requests tab +* `9f9a1ffa1` feat(UI): Add an info button in the create CR page +* `b98d346a4` feat(UI): Add clearing type column in closed clearing request tab +* `b6aa50650` feat(Project): - Extract license from all releases in dependency network when download license information of a project - Generate source code bundle from all releases in dependency network when download Generate source code bundle for a project +* `49f5486fa` feat(rest): endpoint to link sourceProject to list of projects. +* `1ab14350b` feat(CR): Disable Clearing Request creation for the projects which have linked releases without SRC type attachment +* `bcd600c26` feat(User): Add new endpoints to get/update requesting user profile +* `3cb73c19f` feat(rest): Create new endpoint to unschedule all services. +* `83a2b3a28` feat(license): Listing obligations by license +* `8a9c407e8` feat(license): Fix Update License isChecked +* `89a75f815` feat(project): Update ghactions workflows deps +* `849e10a0c` feat(obligation): Add api listing obligations by ObligationLevel +* `3ec2cb129` feat(rest) : Rest end point for releases by lucene search +* `7ccba71d5` feat(project): Setup Sonatype publishing +* `c0fb731c4` feat(license): Create API Export License +* `141e24bab` feat(Release):Upload Source Code Attachment to Releases through a Scheduled Service +* `c7c33c78f` feat(rest): adding pagination for listing vendors endpoint. +* `c805ff90f` feat(rest) : Adding or Modifying fields to project summaryadminastration page +* `6a89beabc` feat(Script): Delete MR's for a specific user +* `adc862038` feat(license): Create new api update license + +### Corrections +* `dfabecd2c` fix(importCDX) : Fix package's linked release updation when an SBOM is imported +* `3de514387` fix(project): adding project owner field in project get endpoint. +* `c31464972` fix(api): throw 409 if last moderator +* `219792b1` fix(importCDX): Resolve incorrect package/release count in import summary +* `6d9f3620` fix(rest): Create a new endpoint for dataBaseSanitation. +* `ae997be2` fix(project): Update outdated Github actions +* `cb02b200` fix(sw360): changing mkdocs version +* `0c9523fb` fix(REST): Improve error message handling for CycloneDX sbom import using REST API +* `df735e9b` fix(Release): Updating the license overview in the summary page +* `e5ac9278` fix(SRCUploadService): Source upload should work for release versions having alphanumeric characters +* `fa42d204` fix(api): provide typeMasks name as Optional type +* `6e36abbb` fix(api): check project modifier before embedding +* `3beff049` fix(Project): Fix bug Expand Next Level and Collapse All button are hidden when click on sort icon +* `5112980f` fix(urlEncoding): url encoding. +* `fe0a4408` fix(Release): Add embedded other licenses in release response +* `d4a8be84` fix(importCDX): Packages without VCS in SBOM having VCS in SW360 are not getting linked to project +* `8af9bd5e` fix(importCDX): Add check for existing comps and package using case-insensitive comparison of vcs and purl +* `ee3ed068` fix(Liferay): Fix bug cannot access oauth client page when import lar file +* `edc9320c` fix(rest) : attachment usage type fix in response +* `49be7428` fix(importSBOM): Remove the invalid characters appearing in import summary message for invalid packages list +* `5a726764` fix(rest): create endpoint for search by userName using lucene search. +* `ff068133` fix(rest): Added releaseId in recentRelease and release mySubscription. +* `87a14f7a` fix(Rest): Added status for mysubsciption in component. +* `d28843c2` fix(docker): Fix broken binaries context inclusion +* `16475d70` fix(rest) : create new endpoint for cleanup attachment. +* `0950a2ca` fix(script): update modifiedBy/modifiedOn project fields. +* `67696a9f` fix(department): Division by zero caused by bad default value for interval +* `9703661d` fix(rest): Added primaryRole and secondaryDepartmentRoles fields for user endpoint. +* `fba0d8e5` fix(rest): Added modifiedBy field in project search by id. +* `178813e5f` fix(docker): Adjust local naming for docker images +* `b55372562` fix(thrift): Add proper version to build +* `34765dd80` fix(thrift): Follow link download step +* `ef5cc0142` fix(database): Restore reading environment database vars +* `8aaf95734` fix(UI) : Issue fix for vulnerability not displaying for project +* `c63023c4d` fix(release): modify the externalId query parsing +* `6a6cb33b5` fix(docker): We have been using wrong Java version +* `625ffcfa1` fix(release): revert external id query parsing +* `222879a9e` fix(rest): error handling when user dont have sufficient import permission +* `d619c5121` fix(Table): Fix error of hiding attachment table content when clicking sort +* `ef83441df` fix(moderator): show message when only moderator choose remove me option. +* `590a2b3ad` fix(docker): Remove deletion that invalidate image +* `2fe147f09` fix(rest): create new enpoint to check server connection. +* `47d14b158` fix(script): Fix migration script not working with python3 +* `0d535c386` fix(config): Correct file number +* `0f9d9b85a` fix(rest): create a new endpoint for fossology in admin tab. +* `5b9f10921` fix(script): Fix incorrect numbering for migration scripts +* `0f9d31974` fix(couchdb): Add config entry to disable couchdb cache +* `451948a79` fix(javadoc): Remove invalid link reference +* `05c2445fa` fix(lib): Add meta information to enable publish +* `b5f6cb469` fix(importCDX): Update failed component creation error message +* `6e1964a40` fix(rest-fossology): applied changes for upload endpoint +* `5a83fe2c9` fix(RequestsPortlet): Unable to reopen CR, Open Components to display open releases, clearing progress to show percentage +* `2fdd5f4c5` fix(Rest): Allowing search for releases using externalIds +* `d9fce216f` Fix(package): Fix issues api for package - Cannot unlink orphan packages from the project - Cannot link a package to a release without any package - Handle message when package with same purl already exists +* `02d84be81` fix (rest) : rest api created for component search by lucene search + +### Infrastructure +* `e71c5e53f` Revert "build(deps): bump org.apache.commons:commons-compress" +* `42ed65ee` chore(deps): Update json to version 20240303 +* `cd53eed2` refactor(deps): Update new codebase library +* `8fca0929` chore(license): Ignore checks under templates +* `73ea0cf3` chore(templates): Second batch of bug report template updates +* `f375af4f` chore(templates): Update outdated bug/issue templates +* `a28f3ce3` build(deps): bump idna in /.github/actions/clean_up_package_registry +* `2d907549` build(deps): bump org.apache.commons:commons-compress +* `4d87a2bb` build(deps): bump org.bitbucket.b_c:jose4j in /rest/resource-server +* `7ee06367` build(deps): bump org.springframework.security:spring-security-core +* `737a1320` ci(docker): Use external action to reduce maintenance +* `d9341ee28` chore(package-portlet): package-portlet enabled for default installation +* `ecb30a34d` Update build status +* `7d3511146` build(deps): bump com.jayway.jsonpath:json-path from 2.8.0 to 2.9.0 +* `8b5428d92` docs(api): add OpenAPI docs for /vulnerabilities +* `27dc3d8bb` docs(api): add OpenAPI docs for releases +* `72a99c897` docs(project): response codes DELETE /projects +* `1c3f70f8e` chore(javadoc): Fix javadoc entries as requirements to publish in sonatype + + ## sw360-18.0.0-M1 This tag covers many corrections/bug after the 17.0 release and multiple new endpoints to support sw360 UI project. diff --git a/Dockerfile b/Dockerfile index 193b08298b..4d61b1c335 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -# syntax=docker/dockerfile:1.4 -# + # Copyright Helio Chisisni de Castro, 2023. Part of the SW360 Portal Project. # Copyright Siemens AG, 2020. Part of the SW360 Portal Project. # Copyright BMW CarIT GmbH, 2021. +# Copyright Cariad SE, 2024. Part of the SW360 Portal Project. # # This program and the accompanying materials are made # available under the terms of the Eclipse Public License 2.0 @@ -10,90 +10,17 @@ # # SPDX-License-Identifier: EPL-2.0 -#----------------------------------------------------------------------------------- -# Base image -# We need use JDK, JRE is not enough as Liferay do runtime changes and require javac -ARG JAVA_VERSION=11 -ARG UBUNTU_VERSION=jammy - -# Use OpenJDK Eclipe Temurin Ubuntu LTS -FROM eclipse-temurin:$JAVA_VERSION-jdk-$UBUNTU_VERSION as base - -ENV LANG=en_US.UTF-8 -ENV LANGUAGE=en_US:en -ENV LC_ALL=en_US.UTF-8 - -# Set versions as arguments -ARG LIFERAY_VERSION -ARG LIFERAY_SOURCE - -ENV LIFERAY_HOME=/app/sw360 -ENV LIFERAY_INSTALL=/app/sw360 - -ARG USERNAME=sw360 -ARG USER_ID=1000 -ARG USER_GID=$USER_ID -ARG HOMEDIR=/workspace -ENV HOME=$HOMEDIR - -# Base system -RUN --mount=type=cache,target=/var/cache/apt \ - apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - ca-certificates \ - curl \ - dos2unix \ - gnupg2 \ - iproute2 \ - iputils-ping \ - less \ - libarchive-tools \ - locales \ - lsof \ - netbase \ - openssl \ - procps \ - tzdata \ - sudo \ - unzip \ - zip \ - && rm -rf /var/lib/apt/lists/* - -# Prepare system for non-priv user -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd \ - --uid $USER_ID \ - --gid $USER_GID \ - --shell /bin/bash \ - --home-dir $HOMEDIR \ - --create-home $USERNAME - -# sudo support -RUN echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME - -# Unpack liferay as sw360 and link current tomcat version -# to tomcat to make future proof updates -RUN --mount=type=cache,target=/var/cache/deps \ - mkdir -p /app/sw360 \ - && if [ ! -f /var/cache/deps/"$LIFERAY_SOURCE" ]; then \ - curl -o /var/cache/deps/"$LIFERAY_SOURCE" -JL https://github.com/liferay/liferay-portal/releases/download/"$LIFERAY_VERSION"/"$LIFERAY_SOURCE"; \ - fi \ - && tar -xzf /var/cache/deps/"$LIFERAY_SOURCE" -C /app/sw360 --strip-components=1 \ - && chown -R $USERNAME:$USERNAME /app \ - && ln -s /app/sw360/tomcat-* /app/sw360/tomcat - -WORKDIR /app/sw360 -ENTRYPOINT [ "/bin/bash" ] - #-------------------------------------------------------------------------------------------------- # Thrift -FROM ubuntu:jammy AS sw360thriftbuild +# Ubuntu Noble image +FROM ubuntu@sha256:278628f08d4979fb9af9ead44277dbc9c92c2465922310916ad0c46ec9999295 AS sw360thriftbuild ARG BASEDIR="/build" +ARG DESTDIR="/" ARG THRIFT_VERSION -RUN --mount=type=cache,target=/var/cache/apt \ +RUN rm -f /etc/apt/apt.conf.d/docker-clean +RUN --mount=type=cache,mode=0755,target=/var/cache/apt \ apt-get -qq update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bison \ @@ -113,64 +40,42 @@ RUN --mount=type=tmpfs,target=/build \ --mount=type=cache,target=/var/cache/deps \ ./build_thrift.sh -FROM scratch AS thrift +FROM scratch AS localthrift COPY --from=sw360thriftbuild /usr/local/bin/thrift /usr/local/bin/thrift #-------------------------------------------------------------------------------------------------- # SW360 Build Test image -# Base image to build with test - -FROM maven:3-eclipse-temurin-11 as sw360test -COPY --from=thrift /usr/local/bin/thrift /usr/bin +# 3-eclipse-temurin-21 +FROM maven@sha256:5a44dff9390bff393693518d70233977ff245c2876320655a47be5622719becf AS sw360test -# Thanks to Liferay, we need fix the java version -ENV _JAVA_OPTIONS='-Djdk.util.zip.disableZip64ExtraFieldValidation=true' +COPY --from=localthrift /usr/local/bin/thrift /usr/bin SHELL ["/bin/bash", "-c"] -# Install mkdocs to generate documentation -RUN --mount=type=cache,target=/var/cache/apt \ - apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends \ - gettext-base \ - git \ - python3-pip \ - python3-wheel \ - zip \ - unzip \ - && rm -rf /var/lib/apt/lists/* \ - && pip install mkdocs-material - #-------------------------------------------------------------------------------------------------- # SW360 # We build sw360 and create real image after everything is ready # So when decide to use as development, only this last stage # is triggered by buildkit images -FROM maven:3.9-eclipse-temurin-11 as sw360build +# 3-eclipse-temurin-21 +FROM maven@sha256:5a44dff9390bff393693518d70233977ff245c2876320655a47be5622719becf AS sw360build ARG COUCHDB_HOST=localhost -# Thanks to Liferay, we need fix the java version -ENV _JAVA_OPTIONS='-Djdk.util.zip.disableZip64ExtraFieldValidation=true' - WORKDIR /build SHELL ["/bin/bash", "-c"] -# Install mkdocs to generate documentation -RUN --mount=type=cache,target=/var/cache/apt \ +RUN rm -f /etc/apt/apt.conf.d/docker-clean +RUN --mount=type=cache,mode=0755,target=/var/cache/apt \ apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends \ gettext-base \ git \ - python3-pip \ - python3-wheel \ - zip \ unzip \ - && rm -rf /var/lib/apt/lists/* \ - && pip install mkdocs-material + zip # Prepare maven from binary to avoid wrong java dependencies and proxy COPY scripts/docker-config/mvn-proxy-settings.xml /etc @@ -178,16 +83,16 @@ COPY scripts/docker-config/set_proxy.sh /usr/local/bin/setup_maven_proxy RUN chmod a+x /usr/local/bin/setup_maven_proxy \ && setup_maven_proxy -COPY --from=thrift /usr/local/bin/thrift /usr/bin +COPY --from=localthrift /usr/local/bin/thrift /usr/bin + +WORKDIR /build/sw360 RUN --mount=type=bind,target=/build/sw360,rw \ --mount=type=cache,target=/root/.m2 \ - --mount=type=secret,id=sw360 \ - cd /build/sw360 \ - && set -a \ - && source /run/secrets/sw360 \ + --mount=type=secret,id=couchdb \ + set -a \ + && source /run/secrets/couchdb \ && envsubst < scripts/docker-config/couchdb.properties.template | tee scripts/docker-config/etc_sw360/couchdb.properties \ - && envsubst < scripts/docker-config/couchdb-lucene.ini | tee third-party/couchdb-lucene/src/main/resources/couchdb-lucene.ini \ && set +a \ && cp scripts/docker-config/etc_sw360/couchdb.properties build-configuration/resources/ \ && cp -a scripts/docker-config/etc_sw360 /etc/sw360 \ @@ -195,11 +100,10 @@ RUN --mount=type=bind,target=/build/sw360,rw \ && envsubst < scripts/docker-config/manager/tomcat-users.xml | tee /etc/sw360/manager/tomcat-users.xml \ && mvn clean package \ -P deploy \ + -Dbase.deploy.dir="${PWD}" \ -Dtest=org.eclipse.sw360.rest.resourceserver.restdocs.* \ -Dsurefire.failIfNoSpecifiedTests=false \ - -Dbase.deploy.dir=. \ -Djars.deploy.dir=/sw360_deploy \ - -Dliferay.deploy.dir=/sw360_deploy \ -Dbackend.deploy.dir=/sw360_tomcat_webapps \ -Drest.deploy.dir=/sw360_tomcat_webapps \ -Dhelp-docs=true @@ -218,50 +122,25 @@ COPY --from=sw360build /sw360_tomcat_webapps /sw360_tomcat_webapps #-------------------------------------------------------------------------------------------------- # Runtime image -FROM base AS sw360 - -ARG DEBUG -ARG USERNAME=sw360 -WORKDIR /app/ +# 11-jre21-temurin-noble +FROM tomcat@sha256:2ade2b0a424a446601688adc36c4dc568dfe5198f75c99c93352c412186ba3c9 AS sw360 -# Make sw360 dir owned byt the user -RUN chown -R $USERNAME:$USERNAME /app/sw360 - -USER $USERNAME +ARG TOMCAT_DIR=/usr/local/tomcat # Modified etc -COPY --chown=$USERNAME:$USERNAME --from=binaries /etc/sw360 /etc/sw360 -# Downloaded jar dependencies -COPY --chown=$USERNAME:$USERNAME --from=binaries /sw360_deploy/* /app/sw360/deploy +COPY --from=binaries /etc/sw360 /etc/sw360 # Streamlined wars -COPY --chown=$USERNAME:$USERNAME --from=binaries /sw360_tomcat_webapps/slim-wars/*.war /app/sw360/tomcat/webapps/ +COPY --from=binaries /sw360_tomcat_webapps/slim-wars/*.war ${TOMCAT_DIR}/webapps/ # org.eclipse.sw360 jar artifacts -COPY --chown=$USERNAME:$USERNAME --from=binaries /sw360_tomcat_webapps/*.jar /app/sw360/tomcat/webapps/ +COPY --from=binaries /sw360_tomcat_webapps/*.jar ${TOMCAT_DIR}/webapps/ # Shared streamlined jar libs -COPY --chown=$USERNAME:$USERNAME --from=binaries /sw360_tomcat_webapps/libs/*.jar /app/sw360/tomcat/shared/ - -# Make catalina understand shared directory -RUN dos2unix /app/sw360/tomcat/conf/catalina.properties \ - && sed -i "s,shared.loader=,shared.loader=/app/sw360/tomcat/shared/*.jar,g" /app/sw360/tomcat/conf/catalina.properties - -# Copy liferay/sw360 config files -COPY --chown=$USERNAME:$USERNAME ./scripts/docker-config/portal-ext.properties /app/sw360/portal-ext.properties -COPY --chown=$USERNAME:$USERNAME ./scripts/docker-config/entry_point.sh /app/entry_point.sh +COPY --from=binaries /sw360_tomcat_webapps/libs/*.jar ${TOMCAT_DIR}/lib/ # Tomcat manager for debugging portlets -COPY --chown=$USERNAME:$USERNAME --from=tomcat:9.0.56-jdk11 /usr/local/tomcat/webapps.dist/manager /app/sw360/tomcat/webapps/manager RUN --mount=type=bind,target=/build/sw360,rw \ - if [ DEBUG ]; then \ - cp /etc/sw360/manager/tomcat-users.xml /app/sw360/tomcat/conf/tomcat-users.xml ; \ - cp /build/sw360/scripts/docker-config/manager/context.xml /app/sw360/tomcat/webapps/manager/META-INF/context.xml ; \ - else \ - mv /app/sw360/tomcat/webapps/manager /app/sw360/tomcat/webapps/manager.disabled ; \ - fi - -STOPSIGNAL SIGINT - -WORKDIR /app/sw360 - -ENTRYPOINT [ "/app/entry_point.sh" ] + mv ${TOMCAT_DIR}/webapps.dist/manager ${TOMCAT_DIR}/webapps/manager \ + && cp /etc/sw360/manager/tomcat-users.xml ${TOMCAT_DIR}/conf/tomcat-users.xml \ + && cp /build/sw360/scripts/docker-config/manager/context.xml ${TOMCAT_DIR}/webapps/manager/META-INF/context.xml +WORKDIR ${TOMCAT_DIR} diff --git a/README.md b/README.md index 8424a4485a..360440b5e7 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,16 @@ [![SW360 Build and Test](https://github.com/eclipse-sw360/sw360/workflows/SW360%20Build%20and%20Test/badge.svg)](https://github.com/eclipse-sw360/sw360/actions?query=workflow:"SW360+Build+and+Test") [![Slack Channel](https://img.shields.io/badge/slack-sw360chat-blue.svg?longCache=true&logo=slack)](https://join.slack.com/t/sw360chat/shared_invite/enQtNzg5NDQxMTQyNjA5LThiMjBlNTRmOWI0ZjJhYjc0OTk3ODM4MjBmOGRhMWRmN2QzOGVmMzQwYzAzN2JkMmVkZTI1ZjRhNmJlNTY4ZGI) [![Changelog](https://badgen.net/badge/changelog/%E2%98%85/blue)](https://github.com/eclipse/sw360/blob/master/CHANGELOG.md) + + [![GitHub release (latest by date)](https://img.shields.io/github/v/release/eclipse/sw360)](https://github.com/eclipse/sw360/releases/latest) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9485/badge)](https://www.bestpractices.dev/projects/9485) ### SW360 Portal A software component catalogue application. -SW360 is a server with a REST interface and a Liferay CE portal application -to maintain your projects / products and the software components within. +SW360 is a Backend server with a REST API to maintain your projects / products and the software components within. It can manage SPDX files for maintaining the license conditions and maintain license information. @@ -18,7 +20,6 @@ license information. It is comprised of one frontend (portal) part, backend (services) part and additionally a REST API: -* Frontend: Liferay-CE-(Tomcat-)based portal application using portlets. * Backend: Tomcat-based thrift services for being called by different applications. * Database: we store software components and metadata about them in CouchDB. * Rest: this REST API provides access to project resources for external integration. @@ -29,7 +30,6 @@ The reference platform is the Ubuntu server 22.04 (which is an LTS version). This is a multi module maven file. please consider that we have the following modules: -* frontend: For portlets, themes and layouts, the liferay part. * backend: For the thrift based services. * libraries: For general stuff that is reused among the above, for example, couchdb access. * scripts: Auxiliary scripts to help build, deploy and config system @@ -37,18 +37,17 @@ This is a multi module maven file. please consider that we have the following mo ### Issues -If you run in any issues with documentation or software, please be kind and report to our -[Github issues area](https://github.com/eclipse/sw360/issues). +If you run in any issues with documentation or software, please be kind and report to our +[GitHub issues area](https://github.com/eclipse/sw360/issues). ### Deployment -Is recommended using the docker based setup, +Is recommended using the docker based setup, [described here](https://github.com/eclipse/sw360/blob/main/README_DOCKER.md). -If you intend to install in a bare metal machine or use in your own virtualizaed system, [bare metal instructions are provided here](https://www.eclipse.org/sw360/docs/deployment/baremetal/deploy-natively/). - +If you intend to install in a bare metal machine or use in your own virtualized system, [bare metal instructions are provided here](https://www.eclipse.org/sw360/docs/deployment/baremetal/deploy-natively/). -### Development +### Development If you intend to develop over SW360, few steps are needed as equal you need have base requirements @@ -58,59 +57,42 @@ requirements * Maven 3.8.7 * pre-commit * thrift 0.16.0 runtime - * Python environment ( to [pre-commit](https://pre-commit.com/) ) - SW360 use Eclipse formatting rules + * Python environment ( to [pre-commit](https://pre-commit.com/) ) - SW360 use Eclipse formatting rules through [Spotless maven plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) If you can't install thrift 0.16 runtime, you will need the following requirements: + * C++ dev environment * cmake Then run the current build script: -```bash + +```bash ./scripts/install-thrift.sh ``` #### Local Building **Step 1**: Prepare source code + ```bash -git clone https://github.com/eclipse/sw360.git +git clone https://github.com/eclipse-sw360/sw360.git cd sw360 pip install pre-commit pre-commit install ``` -**Step 2**: Build the code (without tests and docs) +**Step 2**: Build the code + ```bash mvn package -P deploy \ -Dhelp-docs=false \ -DskipTests \ -Djars.deploy.dir=deploy \ -Drest.deploy.dir=webapps \ - -Dliferay.deploy.dir=webapps \ -Dbackend.deploy.dir=webapps ``` -If you want run the the tests, we need start a local couchdb server and Docker is required: - -**Step 3**: -```bash -pip install mkdocs-material -./scripts/startCouchdbForTests.sh - -mvn package -P deploy \ - -Djars.deploy.dir=deploy \ - -Drest.deploy.dir=webapps \ - -Dliferay.deploy.dir=webapps \ - -Dbackend.deploy.dir=webapps -``` - -To check your code linting without commit: -```bash -mvn spotless:check -``` - -Please refer to [SW360 main documentation website](https://www.eclipse.org/sw360/docs/) for more details. - +If you want to run the tests, we need start a local couchdb server and Docker is required: ### License @@ -118,4 +100,4 @@ SPDX-License-Identifier: EPL-2.0 This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 -which is available at https://www.eclipse.org/legal/epl-2.0/ +which is available at [https://www.eclipse.org/legal/epl-2.0/](https://www.eclipse.org/legal/epl-2.0/) diff --git a/README_DOCKER.md b/README_DOCKER.md index 4b09baca03..5b868faec8 100644 --- a/README_DOCKER.md +++ b/README_DOCKER.md @@ -1,5 +1,7 @@ # SW360 Docker +> **WARNING**: This readme refers to main branch. [This is the Docker documentation for stable 18.x series](https://github.com/eclipse-sw360/sw360/blob/releases/18/README_DOCKER.md) + ## Table of Contents [Building](#building) @@ -8,7 +10,6 @@ [Extra Configurations](#configurations) - ## Building * Install Docker recent version @@ -21,12 +22,13 @@ ``` If you want to specify [CVE-Search](https://github.com/cve-search/cve-search) host at build time, run as follows: + ```sh ./docker_build.sh --cvesearch-host ``` - The `` above should be `http://:` style, - or it can be https://cvepremium.circl.lu for testing purposes only. + The `` above should be `http://:` style, + or it can be [https://cvepremium.circl.lu](https://cvepremium.circl.lu) for testing purposes only. The script will build multiple intermediary images. Subsequent builds will only build the differences @@ -34,13 +36,14 @@ To configure couchdb, create a file containing the necessary credentials. A template of this file can be found in: - `scripts/docker_config/default_secrets` + `config/couchdb/default_secrets` Example: + ```ini COUCHDB_URL=http://couchdb:5984 - COUCHDB_USER=admin - COUCHDB_PASSWORD=password + COUCHDB_USER=sw360 + COUCHDB_PASSWORD=sw360fossie ``` To pass your file during build export a variable called **SECRETS** pointing to your file @@ -51,68 +54,74 @@ It's suggested though to configure docker system wide ( require super user privileges ) - * systemd based - If you are using a regular systemd based docker: - * Create the following file **http_proxy.conf** on the directory `/etc/systemd/system/docker.service.d/` + * systemd based + If you are using a regular systemd based docker: + * Create the following file **http_proxy.conf** on the directory `/etc/systemd/system/docker.service.d/` - ```ini - [Service] - Environment="HTTP_PROXY=" - Environment="HTTPS_PROXY=" - Environment="NO_PROXY=" - ``` + ```ini + [Service] + Environment="HTTP_PROXY=" + Environment="HTTPS_PROXY=" + Environment="NO_PROXY=" + ``` - * Do a regular systemctl daemon-reload and systemctl restart docker + * Do a regular systemctl daemon-reload and systemctl restart docker * Volumes - By default couchdb, postgres and sw360 have their own storage volumes: + By default couchdb and sw360 have their own storage volumes: - **Postgres** - ```yml - - postgres:/var/lib/postgresql/data/ - ``` + **CouchDB** - **CouchDB** - ```yml - - couchdb:/opt/couchdb/data - ``` + ```yml + - couchdb → /opt/couchdb/data + ``` - **sw360** - ```yml - - etc:/etc/sw360 - - webapps:/app/sw360/tomcat/webapps - - document_library:/app/sw360/data/document_library - ``` - There is a local mounted as binded dir volume to add customizations - ```yml - - ./config:/app/sw360/config - ``` + **sw360** - If you want to override all configs, create a docker env file and alter for your needs. + ```yml + - etc → /etc/sw360 + - webapps → /app/sw360/tomcat/webapps + ``` - Then just rebuild the project with **-env env_file** option + There is a local mounted as binded dir volume to add customizations + **sw360** + + ```yml + - ./config/sw360 -> /app/sw360/config + ``` + + **couchdb** + + ```yml + - config/couchdb/sw360_setup.ini → /opt/couchdb/sw360_setup.ini + - config/couchdb/sw360_log.ini → /opt/couchdb/etc/local.d/sw360_log.ini + - logs/couchdb → /opt/couchdb/log + ``` + + If you want to override all configs, create a docker env file and alter for your needs. + + Then just rebuild the project with **-env env_file** option ## Networking This composed image runs under a single default network, called **sw360net** -So any external docker image can connect to internal couchdb or postgresql through this network - +So any external docker image can connect to internal couchdb through this network ## Running the image first time * Run the resulting image: ```sh - docker-compose up + docker compose up ``` * With custom env file ```sh - docker-compose --env-file up + docker compose --env-file up ``` You can add **-d** parameter at end of line to start in daemon mode and see the logs with the following command: @@ -127,22 +136,20 @@ So any external docker image can connect to internal couchdb or postgresql throu [SW360 Initial Setup Configuration](https://eclipse.dev/sw360/docs/deployment/legacy/deploy-liferay7.4/) ## Fossology + For docker based approach, is recommended use official [Fossology docker image](https://hub.docker.com/r/fossology/fossology/) This is the steps to quick perform this: ```sh -# Create Fossology database on internal postgres -docker exec -it sw360_postgresdb_1 createdb -U liferay -W fossology - # Start Fossology container connected to sw360 env docker run \ --network sw360net \ -p 8081:80 \ --name fossology \ - -e FOSSOLOGY_DB_HOST=postgresdb \ - -e FOSSOLOGY_DB_USER=liferay \ - -e FOSSOLOGY_DB_PASSWORD=liferay \ + -e FOSSOLOGY_DB_HOST= \ + -e FOSSOLOGY_DB_USER= \ + -e FOSSOLOGY_DB_PASSWORD= \ -d fossology/fossology ``` @@ -159,86 +166,21 @@ This will pull/start the fossology container and made it available on the host m * Add the id of folder. The default id is **1** (Software Repository). You can get the ID of the folder you want from the folder URL in Fossology * Add your obtained Token from Fossology - ## Configurations -By default, docker image of sw360 runs without internal web server and is assigned to be on port 8080. This is configured on *portal-ext.properties* +By default, docker image of sw360 runs without internal web server and is assigned to be on port 8080. Here's some extra configurations that can be useful to fix some details. -### Customize portal-ext - -The config file __portal-ext.properties__ overrides a second file that can be created to add a custom configuration with all data related to your necessities. - -This file is called __portal-sw360.properties__ - -To add your custom configs, create this file under config dir on project root like this ( or with your favorite editor): - -```sh -cd -mkdir config -cat "company.default.name=MYCOMPANY" > config/sw360-portal-ext.properties -``` - -Docker compose will treat config as a bind volume dir and will expose to application. - - -### Make **HTTPS** default - -Modify the following line on your custom __portal-sw360.properties__ to https: - -```ini -web.server.protocol=https -``` - -### CSS layout looks wrong or using non standard ports - -If you do not use an external web server with redirection ( see below ), you may find the main CSS theme scrambled ( not properly loaded ) or you are using a different port - -This happens because current Liferay used version try to access the theme using only canonical hostname, without the port assigned, so leading to an invalid CSS url. - -To fix, you will need to change __portal-sw360.properties__ ( as described above ) with the following extra values: - -```ini -# For different hostname redirection -web.server.host= -# For HTTP non standard 80 port -web.server.http.port= -# For HTTPS non standard 443 port -web.server.https.port= -``` - -This will tell liferay where is your real host instead of trying to guess the wrong host. - - -### Nginx config for reverse proxy and X-Frame issues on on host machine ( not docker ) - -For nginx, assuming you are using default config for your sw360, this is a simple configuration for root web server under Ubuntu. - -```nginx - location / { - resolver 127.0.0.11 valid=30s; - proxy_pass http://localhost:8080/; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-Proto https; - proxy_redirect off; - proxy_read_timeout 3600s; - proxy_hide_header X-Frame-Options; - add_header X-Frame-Options "ALLOWALL"; - } -``` - -***WARNING*** - X-frame is enabled wide open for development purposes. If you intend to use the above config in production, remember to properly secure the web server. - -### Liferay Redirects +### CouchDB -Liferay by default for security reasons do not allow redirect for unknown ips/domains, so is necessary to add your domain or ip to the redirect allowed lists in the Liferay Control Panel +CouchDB in compose runs with one standard admin user in a single node setup, user **sw360** and password **sw360fossy** -As admin, go to Control Panel -> Instance Settings -> Content Data -> Pages +To modify the entries and setup, you have two possible options: -Decide to use: +* Modify `config/couchdb/docker.ini` in main source tree +* Create a new `.ini` file, add to `config/couchdb/` folder and add as a mounted volume file in docker compose -**IP based** - List of ips you want to allow tro redirect +For logging, they are now file based on local source folder `logs/couchdb` and the base configuration is in `config/couchdb/log.ini`. -**Domain based** - List of domains you want to allow redirect +You can find [CouchDB configuration docs here](https://docs.couchdb.org/en/stable/config/index.html) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..a19031aa97 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,39 @@ + +# Eclipse SW360 Security Policy + + +This Eclipse Foundation Project adheres to the [Eclipse Foundation Vulnerability Reporting Policy](https://www.eclipse.org/security/policy/). + +## How To Report a Vulnerability + +If you think you have found a vulnerability in this repository, please report it to us through coordinated disclosure. + +**Please do not report security vulnerabilities through public issues, discussions, or change requests.** + +Instead, report it using one of the following ways: + +* Contact the [Eclipse Foundation Security Team](mailto:security@eclipse-foundation.org) via email +* Create a [confidential issue](https://gitlab.eclipse.org/security/vulnerability-reports/-/issues/new?issuable_template=new_vulnerability) in the Eclipse Foundation Vulnerability Reporting Tracker +* Report a [vulnerability](https://github.com/eclipse-sw360/sw360/security/advisories/new) directly via private vulnerability reporting on GitHub + +You can find more information about reporting and disclosure at the [Eclipse Foundation Security page](https://www.eclipse.org/security/). + +Please include as much of the information listed below as you can to help us better understand and resolve the issue: + +* The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting) +* Affected version(s) +* Impact of the issue, including how an attacker might exploit the issue +* Step-by-step instructions to reproduce the issue +* The location of the affected source code (tag/branch/commit or direct URL) +* Full paths of source file(s) related to the manifestation of the issue +* Configuration required to reproduce the issue +* Log files that are related to this issue (if possible) +* Proof-of-concept or exploit code (if possible) + +This information will help us triage your report more quickly. + +## Supported Versions + +Supported versions are: + +* Version 19.0.0 diff --git a/backend/src/src-health/pom.xml b/backend/attachments/pom.xml similarity index 58% rename from backend/src/src-health/pom.xml rename to backend/attachments/pom.xml index 433f44a6d9..3962f1536c 100644 --- a/backend/src/src-health/pom.xml +++ b/backend/attachments/pom.xml @@ -10,20 +10,26 @@ 4.0.0 + + + org.eclipse.sw360 + backend + 19.0.0 + + + backend-attachments + war + backend-attachments + attachments + + ${backend.deploy.dir} + - junit - junit - test + org.eclipse.sw360 + backend-common + ${project.version} - - org.eclipse.sw360 - backend-src - ${revision} - - src-health - jar - src-health diff --git a/backend/src/src-attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java b/backend/attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java similarity index 96% rename from backend/src/src-attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java rename to backend/attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java index 749c6523d0..d5b90e03ad 100644 --- a/backend/src/src-attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java +++ b/backend/attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentHandler.java @@ -9,8 +9,8 @@ */ package org.eclipse.sw360.attachments; -import com.cloudant.client.api.CloudantClient; import com.google.common.collect.ImmutableSet; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.apache.thrift.TException; import org.eclipse.sw360.datahandler.db.AttachmentDatabaseHandler; import org.eclipse.sw360.datahandler.common.DatabaseSettings; @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Supplier; import java.util.stream.Collectors; import static org.eclipse.sw360.datahandler.common.SW360Assert.*; @@ -46,8 +45,8 @@ public AttachmentHandler() throws MalformedURLException { handler = new AttachmentDatabaseHandler(DatabaseSettings.getConfiguredClient(), DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_ATTACHMENTS); } - public AttachmentHandler(Supplier httpClient, String dbName, String attachmentDbName) throws MalformedURLException { - handler = new AttachmentDatabaseHandler(httpClient, dbName, attachmentDbName); + public AttachmentHandler(Cloudant client, String dbName, String attachmentDbName) throws MalformedURLException { + handler = new AttachmentDatabaseHandler(client, dbName, attachmentDbName); } @Override diff --git a/backend/src/src-attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentServlet.java b/backend/attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentServlet.java similarity index 100% rename from backend/src/src-attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentServlet.java rename to backend/attachments/src/main/java/org/eclipse/sw360/attachments/AttachmentServlet.java diff --git a/backend/svc/svc-attachments/src/main/webapp/WEB-INF/web.xml b/backend/attachments/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-attachments/src/main/webapp/WEB-INF/web.xml rename to backend/attachments/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-attachments/src/main/webapp/index.jsp b/backend/attachments/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-attachments/src/main/webapp/index.jsp rename to backend/attachments/src/main/webapp/index.jsp diff --git a/backend/src/src-attachments/src/test/java/org/eclipse/sw360/attachments/AttachmentHandlerTest.java b/backend/attachments/src/test/java/org/eclipse/sw360/attachments/AttachmentHandlerTest.java similarity index 100% rename from backend/src/src-attachments/src/test/java/org/eclipse/sw360/attachments/AttachmentHandlerTest.java rename to backend/attachments/src/test/java/org/eclipse/sw360/attachments/AttachmentHandlerTest.java diff --git a/backend/src/src-attachments/src/test/java/org/eclipse/sw360/attachments/TestAttachmentClient.java b/backend/attachments/src/test/java/org/eclipse/sw360/attachments/TestAttachmentClient.java similarity index 100% rename from backend/src/src-attachments/src/test/java/org/eclipse/sw360/attachments/TestAttachmentClient.java rename to backend/attachments/src/test/java/org/eclipse/sw360/attachments/TestAttachmentClient.java diff --git a/backend/src/src-users/pom.xml b/backend/changelogs/pom.xml similarity index 56% rename from backend/src/src-users/pom.xml rename to backend/changelogs/pom.xml index 624cd696dc..048af404c9 100644 --- a/backend/src/src-users/pom.xml +++ b/backend/changelogs/pom.xml @@ -8,26 +8,32 @@ ~ ~ SPDX-License-Identifier: EPL-2.0 --> + 4.0.0 - backend-src + backend org.eclipse.sw360 - ${revision} + 19.0.0 + + backend-changelogs + war + backend-changelogs + changelogs + + ${backend.deploy.dir} + + - - com.opencsv - opencsv - 5.5.2 - compile - - + + org.eclipse.sw360 + backend-common + ${project.version} + + - src-users - jar - src-users diff --git a/backend/src/src-changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java b/backend/changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java similarity index 91% rename from backend/src/src-changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java rename to backend/changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java index 89d4485ba1..f256f4966b 100644 --- a/backend/src/src-changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java +++ b/backend/changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsHandler.java @@ -15,9 +15,7 @@ import java.io.IOException; import java.util.List; -import java.util.function.Supplier; -import org.apache.thrift.TException; import org.eclipse.sw360.datahandler.common.DatabaseSettings; import org.eclipse.sw360.datahandler.db.ChangeLogsDatabaseHandler; import org.eclipse.sw360.datahandler.thrift.SW360Exception; @@ -26,7 +24,7 @@ import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.thrift.RequestStatus; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; /** * Implementation of the Thrift service @@ -41,7 +39,7 @@ public class ChangeLogsHandler implements ChangeLogsService.Iface { this(DatabaseSettings.getConfiguredClient(), DatabaseSettings.COUCH_DB_CHANGE_LOGS); } - ChangeLogsHandler(Supplier client, String dbName) throws IOException { + ChangeLogsHandler(Cloudant client, String dbName) throws IOException { handler = new ChangeLogsDatabaseHandler(client, dbName); } diff --git a/backend/src/src-changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsServlet.java b/backend/changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsServlet.java similarity index 100% rename from backend/src/src-changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsServlet.java rename to backend/changelogs/src/main/java/org/eclipse/sw360/changelogs/ChangeLogsServlet.java diff --git a/backend/svc/svc-changelogs/src/main/webapp/WEB-INF/web.xml b/backend/changelogs/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-changelogs/src/main/webapp/WEB-INF/web.xml rename to backend/changelogs/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-changelogs/src/main/webapp/index.jsp b/backend/changelogs/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-changelogs/src/main/webapp/index.jsp rename to backend/changelogs/src/main/webapp/index.jsp diff --git a/backend/src-common/pom.xml b/backend/common/pom.xml similarity index 58% rename from backend/src-common/pom.xml rename to backend/common/pom.xml index 46b95cb588..c5d2bf8ce5 100644 --- a/backend/src-common/pom.xml +++ b/backend/common/pom.xml @@ -14,54 +14,54 @@ backend org.eclipse.sw360 - ${revision} + 19.0.0 4.0.0 - src-common - - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - test-jar - - - - - - + backend-common + jar - org.apache.httpcomponents - httpmime - 4.3.3 + org.eclipse.sw360 + backend-service-core + 19.0.0 org.spdx tools-java - + + org.cyclonedx + cyclonedx-core-java + + + org.apache.httpcomponents + httpmime + 4.5.14 + org.apache.logging.log4j log4j-1.2-api - org.apache.commons - commons-lang3 + org.eclipse.sw360 + nouveau-handler + ${project.version} + compile - org.cyclonedx - cyclonedx-core-java + com.ibm.cloud + cloudant + ${cloudantsdk.version} + + + org.codehaus.plexus + plexus-utils - com.github.package-url - packageurl-java + jakarta.activation + jakarta.activation-api + ${jakarta.activation-api.version} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java b/backend/common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java similarity index 86% rename from backend/src-common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java rename to backend/common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java index 10212c7952..317ff26144 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java +++ b/backend/common/src/main/java/org/eclipse/sw360/common/utils/BackendUtils.java @@ -20,6 +20,7 @@ public class BackendUtils { public static final Boolean MAINLINE_STATE_ENABLED_FOR_USER; public static final Boolean IS_BULK_RELEASE_DELETING_ENABLED; public static final Boolean IS_FORCE_UPDATE_ENABLED; + public static final Boolean DISABLE_CLEARING_FOSSOLOGY_REPORT_DOWNLOAD; static { loadedProperties = CommonUtils.loadProperties(BackendUtils.class, PROPERTIES_FILE_PATH); @@ -27,6 +28,7 @@ public class BackendUtils { IS_BULK_RELEASE_DELETING_ENABLED = Boolean.parseBoolean(System.getProperty("RunBulkReleaseDeletingTest", loadedProperties.getProperty("bulk.release.deleting.enabled", "false"))); IS_FORCE_UPDATE_ENABLED = Boolean.parseBoolean( System.getProperty("RunRestForceUpdateTest", loadedProperties.getProperty("rest.force.update.enabled", "false"))); + DISABLE_CLEARING_FOSSOLOGY_REPORT_DOWNLOAD = Boolean.parseBoolean(loadedProperties.getProperty("disable.clearing.fossology.report.download", "false")); } protected BackendUtils() { diff --git a/backend/common/src/main/java/org/eclipse/sw360/common/utils/SearchUtils.java b/backend/common/src/main/java/org/eclipse/sw360/common/utils/SearchUtils.java new file mode 100644 index 0000000000..619af56566 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/common/utils/SearchUtils.java @@ -0,0 +1,66 @@ +/* + * Copyright Siemens AG, 2024. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.sw360.common.utils; + +public class SearchUtils { + /* + * This function returns the entire document as a string which can then be + * indexed as a text field for 'default' index in Nouveau. + * Possible values for `typeof` are documented at + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#description + * We entertain only following types: + * - number, bigint, string -> Directly converted to string with `+` + * - boolean -> Converted to string using `toString()` + * - object -> Recursively converted to string. + * - function & others -> skip + */ + public static final String OBJ_TO_DEFAULT_INDEX = " function getObjAsString(obj) {" + + " let result = '';" + + " for (var key in obj) {" + + " if (key == '_rev' || key == 'type') continue;" + + " switch (typeof(obj[key])) {" + + " case 'object':" + + " if (obj[key] !== null) {" + + " result += ' ' + getObjAsString(obj[key]);" + + " }" + + " break;" + + " case 'number':" + + " case 'bigint':" + + " case 'string':" + + " result += ' ' + obj[key];" + + " break;" + + " case 'boolean':" + + " result += ' ' + obj[key].toString();" + + " break;" + + " case 'function':" + + " default:" + + " break;" + + " }" + + " }" + + " return result.trim();" + + " };"; + + /* + * This function takes an array (or object) and traverse through it. Get all + * the values and index them as a text index. + */ + public static final String OBJ_ARRAY_TO_STRING_INDEX = " function arrayToStringIndex(arr, indexName) {" + + " let result = '';" + + " for (let i in arr) {" + + " if (arr[i] && typeof(arr[i]) == 'string' && arr[i].length > 0) {" + + " result += ' ' + arr[i];" + + " }" + + " }" + + " if (result.trim().length > 0) {" + + " index('text', indexName, result.trim(), {'store': true});" + + " }" + + " }"; +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java similarity index 96% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java index fba1536424..a2b71e325a 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java +++ b/backend/common/src/main/java/org/eclipse/sw360/components/summary/ComponentSummary.java @@ -106,6 +106,10 @@ private Component makeExportSummary(Component document, List releases) copyField(document, copy, Component._Fields.MAIN_LICENSE_IDS); copyField(document, copy, Component._Fields.COMPONENT_TYPE); copyField(document, copy, Component._Fields.DEFAULT_VENDOR_ID); + copyField(document, copy, Component._Fields.VCS); + copyField(document, copy, Component._Fields.HOMEPAGE); + copyField(document, copy, Component._Fields.EXTERNAL_IDS); + for (Release release : releases) { diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/DocumentCreationInformationSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/DocumentCreationInformationSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/DocumentCreationInformationSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/DocumentCreationInformationSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/DocumentSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/DocumentSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/DocumentSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/DocumentSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/FileInformationSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/FileInformationSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/FileInformationSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/FileInformationSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/LicenseSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/LicenseSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/LicenseSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/LicenseSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/LicenseTypeSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/LicenseTypeSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/LicenseTypeSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/LicenseTypeSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ModerationRequestSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/ModerationRequestSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ModerationRequestSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/ModerationRequestSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/PackageInformationSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/PackageInformationSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/PackageInformationSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/PackageInformationSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ProjectSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/ProjectSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ProjectSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/ProjectSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ReleaseSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/ReleaseSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/ReleaseSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/ReleaseSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/SpdxDocumentSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/SpdxDocumentSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/SpdxDocumentSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/SpdxDocumentSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/SummaryType.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/SummaryType.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/SummaryType.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/SummaryType.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/components/summary/UserSummary.java b/backend/common/src/main/java/org/eclipse/sw360/components/summary/UserSummary.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/components/summary/UserSummary.java rename to backend/common/src/main/java/org/eclipse/sw360/components/summary/UserSummary.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java b/backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java similarity index 98% rename from backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java rename to backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java index 44c7eb291e..c59dbe2de8 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java +++ b/backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMExporter.java @@ -17,8 +17,9 @@ import org.apache.logging.log4j.Logger; import org.codehaus.plexus.util.CollectionUtils; import org.cyclonedx.exception.GeneratorException; -import org.cyclonedx.generators.json.BomJsonGenerator14; -import org.cyclonedx.generators.xml.BomXmlGenerator14; +import org.cyclonedx.generators.json.BomJsonGenerator; +import org.cyclonedx.generators.xml.BomXmlGenerator; +import org.cyclonedx.Version; import org.cyclonedx.model.Bom; import org.cyclonedx.model.Component.Type; import org.cyclonedx.model.ExternalReference; @@ -135,10 +136,10 @@ public RequestSummary exportSbom(String projectId, String bomType, Boolean inclu bom.setMetadata(metadata); if (SW360Constants.JSON_FILE_EXTENSION.equalsIgnoreCase(bomType)) { - BomJsonGenerator14 jsonBom = new BomJsonGenerator14(bom); + BomJsonGenerator jsonBom = new BomJsonGenerator(bom, Version.VERSION_14); summary.setMessage(jsonBom.toJsonString()); } else { - BomXmlGenerator14 xmlBom = new BomXmlGenerator14(bom); + BomXmlGenerator xmlBom = new BomXmlGenerator(bom, Version.VERSION_14); summary.setMessage(xmlBom.toXmlString()); } return summary; diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java b/backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java similarity index 86% rename from backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java rename to backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java index 08402379e8..c0eeb7f690 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java +++ b/backend/common/src/main/java/org/eclipse/sw360/cyclonedx/CycloneDxBOMImporter.java @@ -12,18 +12,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.net.URI; import java.nio.charset.Charset; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.commons.io.IOUtils; @@ -93,11 +85,8 @@ public class CycloneDxBOMImporter { private static final String DOT_GIT = ".git"; private static final String SLASH = "/"; private static final String DOT = "."; - private static final String HASH = "#"; private static final String HYPHEN = "-"; private static final String JOINER = "||"; - private static final Pattern THIRD_SLASH_PATTERN = Pattern.compile("[^/]*(/[^/]*){2}"); - private static final Pattern FIRST_SLASH_PATTERN = Pattern.compile("/(.*)"); private static final String VCS_HTTP_REGEX = "^[^:]+://"; private static final String COLON_REGEX = "[:,\\s]"; private static final String HTTPS_SCHEME = "https://"; @@ -124,6 +113,16 @@ public class CycloneDxBOMImporter { private final User user; private final AttachmentConnector attachmentConnector; + // Map of supported hosts and base URL formats + private static final Map VCS_HOSTS = Map.of( + "github.com", "https://github.com/%s/%s", + "gitlab.com", "https://gitlab.com/%s/%s", + "bitbucket.org", "https://bitbucket.org/%s/%s", + "cs.opensource.google", "https://cs.opensource.google/%s/%s", + "go.googlesource.com", "https://go.googlesource.com/%s", + "pypi.org", "https://pypi.org/project/%s" + ); + public CycloneDxBOMImporter(ProjectDatabaseHandler projectDatabaseHandler, ComponentDatabaseHandler componentDatabaseHandler, PackageDatabaseHandler packageDatabaseHandler, AttachmentConnector attachmentConnector, User user) { this.projectDatabaseHandler = projectDatabaseHandler; @@ -142,20 +141,20 @@ public CycloneDxBOMImporter(ProjectDatabaseHandler projectDatabaseHandler, Compo * @return Map> */ private Map> getVcsToComponentMap(List components) { - return components.stream().filter(Objects::nonNull) + return components.parallelStream().filter(Objects::nonNull) .flatMap(comp -> CommonUtils.nullToEmptyList(comp.getExternalReferences()).stream() .filter(Objects::nonNull) .filter(ref -> ExternalReference.Type.VCS.equals(ref.getType())) .map(ExternalReference::getUrl) - .map(String::toLowerCase) - .map(url -> StringUtils.removeEnd(url, DOT_GIT)) + .map(url -> sanitizeVCS(url.toLowerCase())) + .filter(url -> CommonUtils.isValidUrl(url)) .map(url -> new AbstractMap.SimpleEntry<>(url, comp))) .collect(Collectors.groupingBy(e -> e.getKey(), Collectors.mapping(Map.Entry::getValue, Collectors.toList()))); } @SuppressWarnings("unchecked") - public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent attachmentContent, String projectId, User user) { + public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent attachmentContent, String projectId, User user, boolean doNotReplacePackageAndRelease) { RequestSummary requestSummary = new RequestSummary(); Map messageMap = new HashMap<>(); requestSummary.setRequestStatus(RequestStatus.FAILURE); @@ -186,24 +185,21 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a // Getting List of org.cyclonedx.model.Component from the Bom List components = CommonUtils.nullToEmptyList(bom.getComponents()); - long vcsCount = components.stream().map(org.cyclonedx.model.Component::getExternalReferences) - .filter(Objects::nonNull).flatMap(List::stream).map(ExternalReference::getType).filter(typeFilter).count(); + long vcsCount = getVcsToComponentMap(components).size(); long componentsCount = components.size(); org.cyclonedx.model.Component compMetadata = bomMetadata.getComponent(); Map> vcsToComponentMap = new HashMap<>(); if (!IS_PACKAGE_PORTLET_ENABLED) { vcsToComponentMap.put("", components); - requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent); + requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent, doNotReplacePackageAndRelease); } else { - vcsToComponentMap = getVcsToComponentMap(components); if (componentsCount == vcsCount) { - requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent); + requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent, doNotReplacePackageAndRelease); } else if (componentsCount > vcsCount) { - - requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent); + requestSummary = importSbomAsProject(compMetadata, vcsToComponentMap, projectId, attachmentContent, doNotReplacePackageAndRelease); if (requestSummary.requestStatus.equals(RequestStatus.SUCCESS)) { @@ -236,7 +232,8 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a for (org.cyclonedx.model.Component comp : components) { if (CommonUtils.isNullOrEmptyCollection(comp.getExternalReferences()) - || comp.getExternalReferences().stream().map(ExternalReference::getType).filter(typeFilter).count() == 0) { + || comp.getExternalReferences().stream().map(ExternalReference::getType).filter(typeFilter).count() == 0 + || !containsComp(vcsToComponentMap, comp)) { final var fullName = SW360Utils.getVersionedName(comp.getName(), comp.getVersion()); final var licenses = getLicenseFromBomComponent(comp); @@ -282,6 +279,7 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a } } } + RequestStatus updateStatus = projectDatabaseHandler.updateProject(project, user); if (RequestStatus.SUCCESS.equals(updateStatus)) { log.info("linking packages to project successfull: " + projId); @@ -366,7 +364,7 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a } public RequestSummary importSbomAsProject(org.cyclonedx.model.Component compMetadata, - Map> vcsToComponentMap, String projectId, AttachmentContent attachmentContent) + Map> vcsToComponentMap, String projectId, AttachmentContent attachmentContent, boolean doNotReplacePackageAndRelease) throws SW360Exception { final RequestSummary summary = new RequestSummary(); summary.setRequestStatus(RequestStatus.FAILURE); @@ -411,7 +409,6 @@ public RequestSummary importSbomAsProject(org.cyclonedx.model.Component compMeta summary.setMessage("Invalid Projct metadata present in SBOM or Multiple project with same name and version is already present in SW360!"); return summary; } - } } catch (SW360Exception e) { log.error("An error occured while importing project from SBOM: " + e.getMessage()); @@ -420,7 +417,7 @@ public RequestSummary importSbomAsProject(org.cyclonedx.model.Component compMeta } if (IS_PACKAGE_PORTLET_ENABLED) { - messageMap = importAllComponentsAsPackages(vcsToComponentMap, project); + messageMap = importAllComponentsAsPackages(vcsToComponentMap, project, doNotReplacePackageAndRelease); } else { messageMap = importAllComponentsAsReleases(vcsToComponentMap, project); } @@ -550,8 +547,7 @@ private Map importAllComponentsAsReleases(Map importAllComponentsAsPackages(Map> vcsToComponentMap, Project project) { - + private Map importAllComponentsAsPackages(Map> vcsToComponentMap, Project project, boolean doNotReplacePackageAndRelease) throws SW360Exception { final var countMap = new HashMap(); final Set duplicateComponents = new HashSet<>(); final Set duplicateReleases = new HashSet<>(); @@ -559,16 +555,32 @@ private Map importAllComponentsAsPackages(Map invalidReleases = new HashSet<>(); final Set invalidPackages = new HashSet<>(); final Map releaseRelationMap = CommonUtils.isNullOrEmptyMap(project.getReleaseIdToUsage()) ? new HashMap<>() : project.getReleaseIdToUsage(); + final Set projectPkgIds = CommonUtils.isNullOrEmptyCollection(project.getPackageIds()) ? new HashSet<>() : project.getPackageIds(); countMap.put(REL_CREATION_COUNT_KEY, 0); countMap.put(REL_REUSE_COUNT_KEY, 0); countMap.put(PKG_CREATION_COUNT_KEY, 0); countMap.put(PKG_REUSE_COUNT_KEY, 0); int relCreationCount = 0, relReuseCount = 0, pkgCreationCount = 0, pkgReuseCount = 0; + if (!doNotReplacePackageAndRelease) { + releaseRelationMap.clear(); + projectPkgIds.clear(); + log.info("Cleared existing releases and packages for project: " + project.getName()); + } + for (Map.Entry> entry : vcsToComponentMap.entrySet()) { Component comp = createComponent(entry.getKey()); + List componentsFromBom = entry.getValue(); + Release release = new Release(); String relName = ""; AddDocumentRequestSummary compAddSummary; try { + Component dupCompByName = componentDatabaseHandler.getComponentByName(comp.getName()); + + if (dupCompByName != null && (CommonUtils.isNotNullEmptyOrWhitespace(dupCompByName.getVcs()) + && !(comp.getVcs().equalsIgnoreCase(dupCompByName.getVcs())))) { + comp.setName(getComponentNameFromVCS(entry.getKey(), true)); + } + compAddSummary = componentDatabaseHandler.addComponent(comp, user.getEmail()); if (CommonUtils.isNotNullEmptyOrWhitespace(compAddSummary.getId())) { @@ -583,7 +595,6 @@ private Map importAllComponentsAsPackages(Map licenses = getLicenseFromBomComponent(bomComp); release = createRelease(bomComp.getVersion(), comp, licenses); if (CommonUtils.isNullEmptyOrWhitespace(release.getVersion()) ) { @@ -595,6 +606,7 @@ private Map importAllComponentsAsPackages(Map importAllComponentsAsPackages(Map importAllComponentsAsPackages(Map importAllComponentsAsPackages(Map Use this to remove Publisher email id. - return new StringBuilder(comp.getPublisher()).append(delimiter).append(name).toString(); + return new StringBuilder(pkgManager).append(delimiter).append(comp.getPublisher()).append(delimiter).append(name).toString(); } else { - return name; + return pkgManager + delimiter + name; } } - private String getComponentNameFromVCS(String vcsUrl){ - String compName = vcsUrl.replaceAll(SCHEMA_PATTERN, "$1"); - Matcher thirdSlashMatcher = THIRD_SLASH_PATTERN.matcher(compName); - if (thirdSlashMatcher.find()) { - compName = thirdSlashMatcher.group(); - Matcher firstSlashMatcher = FIRST_SLASH_PATTERN.matcher(compName); - if (firstSlashMatcher.find()) { - compName = firstSlashMatcher.group(1); - compName = StringUtils.substringBefore(compName, HASH); - compName = compName.replaceAll(SLASH, "."); - } - } - - return compName; - } - private Package createPackage(org.cyclonedx.model.Component componentFromBom, Release release, Set licenses) { Package pckg = new Package(); String purl = componentFromBom.getPurl(); @@ -927,12 +937,10 @@ private Package createPackage(org.cyclonedx.model.Component componentFromBom, Re purl = purl.toLowerCase().trim(); PackageURL packageURL = new PackageURL(purl); pckg.setPurl(purl); - String packageName; - if (PackageManager.NPM.toString().equalsIgnoreCase(packageURL.getType()) - || PackageManager.GOLANG.toString().equalsIgnoreCase(packageURL.getType())) { + String packageName = componentFromBom.getName(); + boolean isDuplicatePackageName = packageDatabaseHandler.getPackageByNameAndVersion(packageName, packageURL.getVersion()).size() > 0; + if (isDuplicatePackageName) { packageName = getPackageName(packageURL, componentFromBom, SLASH).trim(); - } else { - packageName = getPackageName(packageURL, componentFromBom, DOT).replaceAll(SLASH, DOT).trim(); } pckg.setName(packageName); pckg.setVersion(packageURL.getVersion()); @@ -974,4 +982,107 @@ public String getComponetNameById(String id, User user) throws SW360Exception { Component comp = componentDatabaseHandler.getComponent(id, user); return comp.getName(); } + + private String getComponentNameFromVCS(String vcsUrl, boolean isGetVendorandName) { + String compName = vcsUrl.replaceAll(SCHEMA_PATTERN, "$1"); + String[] parts = compName.split("/"); + + if (parts.length >= 2) { + if (isGetVendorandName) { + return String.join("/", Arrays.copyOfRange(parts, 1, parts.length)); + } else { + return parts[parts.length - 1]; + } + } + return compName; + } + + /* + * Sanitize different repository URLS based on their defined schema + */ + public String sanitizeVCS(String vcs) { + for (String host : VCS_HOSTS.keySet()) { + if (vcs.contains(host)) { + return sanitizeVCSByHost(vcs, host); + } + } + return vcs; // Return unchanged if no known host is found + } + + private String sanitizeVCSByHost(String vcs, String host) { + vcs = "https://" + vcs.substring(vcs.indexOf(host)).trim(); + + try { + URI uri = URI.create(vcs); + String[] urlParts = uri.getPath().split("/"); + String formattedUrl = formatVCSUrl(host, urlParts); + + if (formattedUrl == null) { + log.error("Invalid {} repository URL: {}", host, vcs); + return vcs; + } + return formattedUrl.endsWith("/") ? formattedUrl.substring(0, formattedUrl.length() - 1) : formattedUrl; + + } catch (IllegalArgumentException e) { + log.error("Invalid URL format: {}", vcs, e); + return vcs; + } + } + + private String formatVCSUrl(String host, String[] urlParts) { + String formattedUrl = null; + + switch (host) { + case "github.com": + case "bitbucket.org": + if (urlParts.length >= 3) { + formattedUrl = String.format(VCS_HOSTS.get(host), + urlParts[1], urlParts[2].replaceAll("\\.git.*|#.*", "")); + } + break; + + case "gitlab.com": + if (urlParts.length >= 2) { + // Join everything after the main host to get the full nested path + String repoPath = String.join("/", Arrays.copyOfRange(urlParts, 1, urlParts.length)); + + // Remove everything from the first occurrence of .git or # + repoPath = repoPath.replaceAll("\\.git.*|#.*", ""); + + formattedUrl = String.format(VCS_HOSTS.get(host), repoPath); + } + break; + + case "cs.opensource.google": + if (urlParts.length >= 3) { + String thirdSegment = urlParts.length > 3 && !urlParts[3].isEmpty() && !urlParts[3].equals("+") + ? urlParts[3] : ""; + formattedUrl = String.format(VCS_HOSTS.get(host), urlParts[1], urlParts[2], thirdSegment); + } + break; + + case "go.googlesource.com": + if (urlParts.length >= 2) { + formattedUrl = String.format(VCS_HOSTS.get(host), urlParts[1]); + } + break; + + case "pypi.org": + if (urlParts.length >= 3) { + formattedUrl = String.format(VCS_HOSTS.get(host), urlParts[2].replaceAll("\\.git.*|#.*", "")); + } + break; + } + + return formattedUrl; + } + + public static boolean containsComp(Map> map, org.cyclonedx.model.Component element) { + for (List list : map.values()) { + if (list.contains(element)) { + return true; + } + } + return false; + } } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/couchdb/SummaryAwareRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/couchdb/SummaryAwareRepository.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/couchdb/SummaryAwareRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/couchdb/SummaryAwareRepository.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java similarity index 93% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java index 34c50559a9..793887ce5d 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandler.java @@ -16,9 +16,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.function.Supplier; import java.util.stream.Collectors; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.apache.thrift.TBase; import org.apache.thrift.TFieldIdEnum; import org.eclipse.sw360.datahandler.common.SW360Utils; @@ -31,7 +31,6 @@ import org.eclipse.sw360.datahandler.thrift.packages.Package; import org.eclipse.sw360.datahandler.thrift.projects.Project; -import com.cloudant.client.api.CloudantClient; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; @@ -43,8 +42,8 @@ protected AttachmentAwareDatabaseHandler(AttachmentDatabaseHandler attachmentDat this.attachmentDatabaseHandler = attachmentDatabaseHandler; } - protected AttachmentAwareDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName) throws MalformedURLException { - this(new AttachmentDatabaseHandler(httpClient, dbName, attachmentDbName)); + protected AttachmentAwareDatabaseHandler(Cloudant client, String dbName, String attachmentDbName) throws MalformedURLException { + this(new AttachmentDatabaseHandler(client, dbName, attachmentDbName)); } protected Source toSource(Release release){ diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java similarity index 79% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java index 35ae1db878..b077f14e1e 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentContentRepository.java @@ -18,11 +18,9 @@ import org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent; import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.model.Response; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; import java.util.HashMap; import java.util.List; @@ -44,15 +42,17 @@ public class AttachmentContentRepository extends DatabaseRepositoryCloudantClien public AttachmentContentRepository(DatabaseConnectorCloudant db) { super(db, AttachmentContent.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("onlyRemotes", createMapReduce(ONLYREMOTES, null)); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); } public List getOnlyRemoteAttachments() { - ViewRequestBuilder query = getConnector().createQuery(AttachmentContent.class, "onlyRemotes"); - UnpaginatedRequestBuilder req = query.newRequest(Key.Type.STRING, Object.class).includeDocs(true); + PostViewOptions req = getConnector() + .getPostViewQueryBuilder(AttachmentContent.class, "onlyRemotes") + .includeDocs(true) + .build(); return queryView(req); } @@ -69,10 +69,14 @@ public RequestSummary vacuumAttachmentDB(User user, final Set usedIds) { requestSummary.setTotalElements(allAttachmentContents.size()); requestSummary.setTotalAffectedElements(unusedAttachmentContents.size()); - final List documentOperationResults = getConnector().deleteBulk(unusedAttachmentContents); + final List documentOperationResults = getConnector().deleteIds( + unusedAttachmentContents + .stream() + .map(AttachmentContent::getId).collect(Collectors.toSet()) + ); if (unusedAttachmentContents.isEmpty() || !documentOperationResults.isEmpty()) { requestSummary.setRequestStatus(RequestStatus.SUCCESS); - }else{ + } else { requestSummary.setRequestStatus(RequestStatus.FAILURE); } return requestSummary; diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java similarity index 89% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java index 7bd083d5c2..6b0f33a861 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandler.java @@ -9,13 +9,13 @@ */ package org.eclipse.sw360.datahandler.db; -import com.cloudant.client.api.CloudantClient; -import com.cloudant.client.api.model.Response; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.common.CommonUtils; import org.eclipse.sw360.datahandler.couchdb.AttachmentConnector; @@ -24,7 +24,6 @@ import org.eclipse.sw360.datahandler.thrift.users.User; import org.apache.logging.log4j.Logger; -import org.apache.http.HttpStatus; import org.apache.logging.log4j.LogManager; import org.apache.thrift.TException; @@ -33,7 +32,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import java.util.stream.Collectors; import static org.eclipse.sw360.datahandler.common.Duration.durationOf; @@ -56,25 +54,25 @@ public class AttachmentDatabaseHandler { private static final Logger log = LogManager.getLogger(AttachmentDatabaseHandler.class); - public AttachmentDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName) throws MalformedURLException { - db = new DatabaseConnectorCloudant(httpClient, attachmentDbName); - attachmentConnector = new AttachmentConnector(httpClient, attachmentDbName, durationOf(30, TimeUnit.SECONDS)); + public AttachmentDatabaseHandler(Cloudant client, String dbName, String attachmentDbName) throws MalformedURLException { + db = new DatabaseConnectorCloudant(client, attachmentDbName); + attachmentConnector = new AttachmentConnector(client, attachmentDbName, durationOf(30, TimeUnit.SECONDS)); attachmentContentRepository = new AttachmentContentRepository(db); - attachmentUsageRepository = new AttachmentUsageRepository(new DatabaseConnectorCloudant(httpClient, dbName)); - attachmentRepository = new AttachmentRepository(new DatabaseConnectorCloudant(httpClient, dbName)); - attachmentOwnerRepository = new AttachmentOwnerRepository(new DatabaseConnectorCloudant(httpClient, dbName)); + attachmentUsageRepository = new AttachmentUsageRepository(new DatabaseConnectorCloudant(client, dbName)); + attachmentRepository = new AttachmentRepository(new DatabaseConnectorCloudant(client, dbName)); + attachmentOwnerRepository = new AttachmentOwnerRepository(new DatabaseConnectorCloudant(client, dbName)); } public AttachmentConnector getAttachmentConnector(){ return attachmentConnector; } - public AttachmentContent add(AttachmentContent attachmentContent){ + public AttachmentContent add(AttachmentContent attachmentContent) throws SW360Exception { attachmentContentRepository.add(attachmentContent); return attachmentContent; } public List makeAttachmentContents(List attachmentContents) throws TException { - final List documentOperationResults = attachmentContentRepository.executeBulk(attachmentContents); + final List documentOperationResults = attachmentContentRepository.executeBulk(attachmentContents); if (documentOperationResults.isEmpty()) log.error("Failed Attachment store results " + documentOperationResults); @@ -91,7 +89,7 @@ public void updateAttachmentContent(AttachmentContent attachment) throws TExcept attachmentConnector.updateAttachmentContent(attachment); } public RequestSummary bulkDelete(List ids) { - final List documentOperationResults = attachmentContentRepository.deleteIds(ids); + final List documentOperationResults = attachmentContentRepository.deleteIds(ids); return CommonUtils.getRequestSummary(ids, documentOperationResults); } public RequestStatus deleteAttachmentContent(String attachmentId) throws TException { @@ -140,16 +138,16 @@ public void deleteAttachmentUsagesByUsageDataTypes(Source usedBy, Set attachmentUsages) throws TException { List sanitizedUsages = distinctAttachmentUsages(attachmentUsages); - List results = attachmentUsageRepository.executeBulk(sanitizedUsages); - results = results.stream().filter(res -> res.getError() != null || res.getStatusCode() != HttpStatus.SC_CREATED) - .collect(Collectors.toList()); + List results = attachmentUsageRepository.executeBulk(sanitizedUsages); + results = results.stream().filter(res -> res.getError() != null || !res.isOk()) + .toList(); if (!results.isEmpty()) { throw new SW360Exception("Some of the usage documents could not be created: " + results); } @@ -187,9 +185,9 @@ public AttachmentUsage updateAttachmentUsage(AttachmentUsage attachmentUsage) { } public void updateAttachmentUsages(List attachmentUsages) throws TException { - List results = attachmentUsageRepository.executeBulk(attachmentUsages); - results = results.stream().filter(res -> res.getError() != null || res.getStatusCode() != HttpStatus.SC_CREATED) - .collect(Collectors.toList()); + List results = attachmentUsageRepository.executeBulk(attachmentUsages); + results = results.stream().filter(res -> res.getError() != null || !res.isOk()) + .toList(); if (!results.isEmpty()) { throw new SW360Exception("Some of the usage documents could not be updated: " + results); } @@ -200,10 +198,10 @@ public void deleteAttachmentUsage(AttachmentUsage attachmentUsage) throws SW360E } public void deleteAttachmentUsages(List attachmentUsages) throws SW360Exception { - List results = attachmentUsageRepository.deleteIds( + List results = attachmentUsageRepository.deleteIds( attachmentUsages.stream().map(AttachmentUsage::getId).collect(Collectors.toList())); - results = results.stream().filter(res -> res.getError() != null || res.getStatusCode() != HttpStatus.SC_OK) - .collect(Collectors.toList()); + results = results.stream().filter(res -> res.getError() != null || !res.isOk()) + .toList(); if (!results.isEmpty()) { throw new SW360Exception("Some of the usage documents could not be deleted: " + results); } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java similarity index 71% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java index 5717b5ab76..5c7f8aa0d5 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentOwnerRepository.java @@ -13,8 +13,9 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.Source; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.List; @@ -31,13 +32,17 @@ public class AttachmentOwnerRepository extends DatabaseRepositoryCloudantClient< public AttachmentOwnerRepository(DatabaseConnectorCloudant db) { super(db, Source.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("attachmentOwner", createMapReduce(ATTACHMENTOWNER_VIEW_NAME, null)); initStandardDesignDocument(views, db); } - public List getOwnersByIds(Set ids) { - ViewRequestBuilder viewQuery = getConnector().createQuery(Source.class, "attachmentOwner"); - return queryViewForSource(buildRequest(viewQuery, ids)); + public List getOwnersByIds(@NotNull Set ids) { + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(Source.class, "attachmentOwner") + .includeDocs(false) + .keys(ids.stream().map(r -> (Object)r).toList()) + .build(); + return queryViewForSource(viewQuery); } } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java similarity index 62% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java index f3b9322c83..a307f28b82 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentRepository.java @@ -13,8 +13,9 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.attachments.Attachment; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.List; @@ -32,19 +33,27 @@ public class AttachmentRepository extends DatabaseRepositoryCloudantClient views = new HashMap(); + Map views = new HashMap<>(); views.put("byid", createMapReduce(BYID_VIEW_NAME, null)); views.put("bysha1", createMapReduce(BYSHA1_VIEW_NAME, null)); initStandardDesignDocument(views, db); } - public List getAttachmentsByIds(Set ids) { - ViewRequestBuilder viewQuery = getConnector().createQuery(Attachment.class, "byid"); - return queryViewForAttchmnt(buildRequest(viewQuery, ids)); + public List getAttachmentsByIds(@NotNull Set ids) { + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(Attachment.class, "byid") + .includeDocs(false) + .keys(ids.stream().map(r -> (Object)r).toList()) + .build(); + return queryViewForAttachment(viewQuery); } - public List getAttachmentsBySha1s(Set sha1s) { - ViewRequestBuilder viewQuery = getConnector().createQuery(Attachment.class, "bysha1"); - return queryViewForAttchmnt(buildRequest(viewQuery, sha1s)); + public List getAttachmentsBySha1s(@NotNull Set sha1s) { + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(Attachment.class, "bysha1") + .includeDocs(false) + .keys(sha1s.stream().map(r -> (Object)r).toList()) + .build(); + return queryViewForAttachment(viewQuery); } } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java similarity index 53% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java index a828d3dba0..b5afc642c5 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/AttachmentUsageRepository.java @@ -10,20 +10,17 @@ package org.eclipse.sw360.datahandler.db; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.MultipleRequestBuilder; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequestBuilder; -import com.cloudant.client.api.views.ViewResponse; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResult; +import org.apache.commons.lang3.StringUtils; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.attachments.AttachmentUsage; -import org.ektorp.support.View; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -55,7 +52,7 @@ public class AttachmentUsageRepository extends DatabaseRepositoryCloudantClient< public AttachmentUsageRepository(DatabaseConnectorCloudant db) { super(db, AttachmentUsage.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("usagesByAttachment", createMapReduce(USAGESBYATTACHMENT, "_count")); views.put("usedAttachments", createMapReduce(USEDATTACHMENTS, "_count")); @@ -67,34 +64,53 @@ public AttachmentUsageRepository(DatabaseConnectorCloudant db) { } public List getUsageForAttachment(String ownerId, String attachmentContentId) { - ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usagesByAttachment"); - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).keys(Key.complex(new String[] {ownerId, attachmentContentId})).includeDocs(true).reduce(false); - return queryView(reqBuilder); + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(AttachmentUsage.class, "usagesByAttachment") + .includeDocs(true) + .reduce(false) + .keys(List.of(List.of(ownerId, attachmentContentId))) + .build(); + return queryView(viewQuery); } public List getUsedAttachments(String usedById) { - ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usedAttachments"); - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.STRING, Object.class).includeDocs(true).reduce(false).keys(usedById); - return queryView(reqBuilder); + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(AttachmentUsage.class, "usedAttachments") + .includeDocs(true) + .reduce(false) + .keys(List.of(usedById)) + .build(); + return queryView(viewQuery); } public List getUsedAttachmentById(String attachmentContentId) { - ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usedAttachmentById"); - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.STRING, Object.class).includeDocs(true).reduce(false).keys(attachmentContentId); - return queryView(reqBuilder); + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(AttachmentUsage.class, "usedAttachmentById") + .includeDocs(true) + .reduce(false) + .keys(List.of(attachmentContentId)) + .build(); + return queryView(viewQuery); } public List getUsageForAttachment(String ownerId, String attachmentContentId, String filter) { - ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usagesByAttachmentUsageType"); - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).includeDocs(true).reduce(false) - .keys(Key.complex(new String[] { ownerId, attachmentContentId, filter })); - return queryView(reqBuilder); + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(AttachmentUsage.class, "usagesByAttachmentUsageType") + .includeDocs(true) + .reduce(false) + .keys(List.of(List.of(ownerId, attachmentContentId, filter))) + .build(); + return queryView(viewQuery); } public List getUsedAttachments(String usedById, String filter) { - ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usedAttachmentsUsageType"); - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).includeDocs(true).reduce(false).keys(Key.complex(new String[] { usedById, filter })); - return queryView(reqBuilder); + PostViewOptions viewQuery = getConnector() + .getPostViewQueryBuilder(AttachmentUsage.class, "usedAttachmentsUsageType") + .includeDocs(true) + .reduce(false) + .keys(List.of(List.of(usedById, filter))) + .build(); + return queryView(viewQuery); } public List getUsagesByReleaseId(String releaseId) { @@ -102,50 +118,39 @@ public List getUsagesByReleaseId(String releaseId) { } public Map, Integer> getAttachmentUsageCount(Map> attachments, String filter) { - ViewRequestBuilder viewQuery = createUsagesByAttachmentQuery(filter); - List complexKeysList = prepareKeys(attachments, filter); - Key.ComplexKey[] compexKeys = new Key.ComplexKey[complexKeysList.size()]; - for (int i = 0; i < compexKeys.length; i++) { - Key.ComplexKey key = Key.complex(complexKeysList.get(i)); - compexKeys[i] = key; - } - UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).reduce(true).group(true).keys(compexKeys); - ViewResponse result = queryViewForComplexKeys(reqBuilder); + PostViewOptions.Builder viewQuery = createUsagesByAttachmentQuery(filter); + @NotNull List complexKeysList = prepareKeys(attachments, filter); + PostViewOptions req = viewQuery.reduce(true).group(true).keys(complexKeysList).build(); + ViewResult result = queryViewForComplexKeys(req); return result.getRows().stream().collect(Collectors.toMap(key -> { - String json = key.getKey().toJson(); - String replace = json.replace("[","").replace("]","").replaceAll("\"",""); - List relIdAttachmentToUsageType = new ArrayList(Arrays.asList(replace.split(","))); + String json = key.getKey().toString(); + String replace = json.replace("[", "").replace("]", "").replaceAll("\"", ""); + List relIdAttachmentToUsageType = Arrays.stream(StringUtils.stripAll(replace.split(","))).toList(); return ImmutableMap.of(relIdAttachmentToUsageType.get(0), relIdAttachmentToUsageType.get(1)); - }, val -> ((Double) val.getValue()).intValue())); + }, val -> (Double.valueOf(val.getValue().toString())).intValue())); } - public List getUsageForAttachments(Map> attachments, String filter) { - ViewRequestBuilder viewQuery = createUsagesByAttachmentQuery(filter); - @NotNull List complexKeysList = prepareKeys(attachments, filter); - Key.ComplexKey[] compexKeys = new Key.ComplexKey[complexKeysList.size()]; - for (int i = 0; i < compexKeys.length; i++) { - Key.ComplexKey key = Key.complex(complexKeysList.get(i)); - compexKeys[i] = key; - } - MultipleRequestBuilder reqBuilder = viewQuery.newMultipleRequest(Key.Type.COMPLEX, Object.class).includeDocs(true).reduce(false).keys(compexKeys); - return multiRequestqueryView(reqBuilder); + PostViewOptions.Builder viewQuery = createUsagesByAttachmentQuery(filter); + @NotNull List complexKeysList = prepareKeys(attachments, filter); + PostViewOptions req = viewQuery.includeDocs(true).reduce(false).keys(complexKeysList).build(); + return queryView(req); } - private ViewRequestBuilder createUsagesByAttachmentQuery(String filter) { - ViewRequestBuilder viewQuery; + private PostViewOptions.Builder createUsagesByAttachmentQuery(String filter) { + PostViewOptions.Builder viewQuery; if (Strings.isNullOrEmpty(filter)) { - viewQuery = getConnector().createQuery(AttachmentUsage.class, "usagesByAttachment"); + viewQuery = getConnector().getPostViewQueryBuilder(AttachmentUsage.class, "usagesByAttachment"); } else { - viewQuery = getConnector().createQuery(AttachmentUsage.class, "usagesByAttachmentUsageType"); + viewQuery = getConnector().getPostViewQueryBuilder(AttachmentUsage.class, "usagesByAttachmentUsageType"); } return viewQuery; } @NotNull - private List prepareKeys(Map> attachments, String filter) { - List keys = Lists.newArrayList(); + private List prepareKeys(@NotNull Map> attachments, String filter) { + List keys = Lists.newArrayList(); for (Entry> entry : attachments.entrySet()) { for (String attachmentId : entry.getValue()) { if (Strings.isNullOrEmpty(filter)) { diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java similarity index 98% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java index edd89699e4..3887813356 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java @@ -29,8 +29,8 @@ import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.permissions.PermissionUtils; -import com.cloudant.client.api.model.Document; -import com.cloudant.client.api.model.Response; +import com.ibm.cloud.cloudant.v1.model.Document; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; import com.google.common.collect.Lists; import java.util.ArrayList; @@ -528,12 +528,12 @@ public Map deleteBulkRelease(List rel for(Release release : releaseList) { Document document = new Document(); document.setId(release.getId()); - document.setRevision(release.getRevision()); + document.setRev(release.getRevision()); document.setDeleted(true); documentList.add(document); } - List responseList = releaseRepository.executeBulk(documentList); - for (Response response : responseList) { + List responseList = releaseRepository.executeBulk(documentList); + for (DocumentResult response : responseList) { String documentId = response.getId(); String error = response.getError(); if (CommonUtils.isNullEmptyOrWhitespace(error)) { @@ -549,8 +549,8 @@ public Map deleteBulkRelease(List rel public Map updateBulkReleases(Collection collection) { Map resultState = new HashMap(); - List responseList = releaseRepository.executeBulk(collection); - for (Response response : responseList) { + List responseList = releaseRepository.executeBulk(collection); + for (DocumentResult response : responseList) { String documentId = response.getId(); String error = response.getError(); if (CommonUtils.isNullEmptyOrWhitespace(error)) { @@ -571,12 +571,12 @@ public Map deleteBulkComponent(List for(Component component : componentList) { Document document = new Document(); document.setId(component.getId()); - document.setRevision(component.getRevision()); + document.setRev(component.getRevision()); document.setDeleted(true); documentList.add(document); } - List responseList = releaseRepository.executeBulk(documentList); - for (Response response : responseList) { + List responseList = releaseRepository.executeBulk(documentList); + for (DocumentResult response : responseList) { String documentId = response.getId(); String error = response.getError(); if (CommonUtils.isNullEmptyOrWhitespace(error)) { @@ -592,8 +592,8 @@ public Map deleteBulkComponent(List public Map updateBulkComponent(Collection collection) { Map resultState = new HashMap(); - List responseList = componentRepository.executeBulk(collection); - for (Response response : responseList) { + List responseList = componentRepository.executeBulk(collection); + for (DocumentResult response : responseList) { String documentId = response.getId(); String error = response.getError(); if (CommonUtils.isNullEmptyOrWhitespace(error)) { diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java similarity index 94% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java index 13eb4b284c..53233a8329 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsDatabaseHandler.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.function.Supplier; import java.util.stream.Collectors; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; @@ -29,7 +28,7 @@ import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.thrift.RequestStatus; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import com.google.common.collect.ImmutableSet; /** @@ -48,8 +47,8 @@ public class ChangeLogsDatabaseHandler { .add("revision") .add("documentState").build(); - public ChangeLogsDatabaseHandler(Supplier httpClient, String dbName) throws MalformedURLException { - db = new DatabaseConnectorCloudant(httpClient, dbName); + public ChangeLogsDatabaseHandler(Cloudant client, String dbName) throws MalformedURLException { + db = new DatabaseConnectorCloudant(client, dbName); changeLogsRepository = new ChangeLogsRepository(db); } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java similarity index 95% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java index 8d06b06544..f5adaa9164 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ChangeLogsRepository.java @@ -18,7 +18,7 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogs; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; /** * CRUD access for the ChangeLogs class @@ -55,7 +55,7 @@ public class ChangeLogsRepository extends DatabaseRepositoryCloudantClient views = new HashMap(); + Map views = new HashMap<>(); views.put("byDocumentId", createMapReduce(BY_DOCUMENT_ID, null)); views.put("byParentDocumentId", createMapReduce(BY_PARENT_DOCUMENT_ID, null)); views.put("byUserEdited", createMapReduce(BY_USER_EDITED, null)); diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java similarity index 96% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java index 9b1f2af83d..50b114e678 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentDatabaseHandler.java @@ -10,8 +10,8 @@ */ package org.eclipse.sw360.datahandler.db; -import com.cloudant.client.api.CloudantClient; -import com.cloudant.client.api.model.Response; +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; import com.google.common.collect.*; import org.eclipse.sw360.common.utils.BackendUtils; @@ -76,6 +76,7 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.nio.ByteBuffer; import java.nio.file.*; @@ -83,7 +84,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.stream.*; import static com.google.common.base.Strings.isNullOrEmpty; @@ -165,9 +165,9 @@ public class ComponentDatabaseHandler extends AttachmentAwareDatabaseHandler { ClearingInformation._Fields.EXTERNAL_SUPPLIER_ID, ClearingInformation._Fields.EVALUATED, ClearingInformation._Fields.PROC_START); - public ComponentDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName, ComponentModerator moderator, ReleaseModerator releaseModerator, ProjectModerator projectModerator) throws MalformedURLException { - super(httpClient, dbName, attachmentDbName); - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(httpClient, dbName); + public ComponentDatabaseHandler(Cloudant client, String dbName, String attachmentDbName, ComponentModerator moderator, ReleaseModerator releaseModerator, ProjectModerator projectModerator) throws MalformedURLException { + super(client, dbName, attachmentDbName); + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories vendorRepository = new VendorRepository(db); @@ -183,36 +183,36 @@ public ComponentDatabaseHandler(Supplier httpClient, String dbNa this.projectModerator = projectModerator; // Create the attachment connector - attachmentConnector = new AttachmentConnector(httpClient, attachmentDbName, durationOf(30, TimeUnit.SECONDS)); - DatabaseConnectorCloudant dbChangeLogs = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_CHANGE_LOGS); + attachmentConnector = new AttachmentConnector(client, attachmentDbName, durationOf(30, TimeUnit.SECONDS)); + DatabaseConnectorCloudant dbChangeLogs = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_CHANGE_LOGS); this.dbHandlerUtil = new DatabaseHandlerUtil(dbChangeLogs); this.bulkDeleteUtil = new BulkDeleteUtil(this, componentRepository, releaseRepository, projectRepository, moderator, releaseModerator, attachmentConnector, attachmentDatabaseHandler, dbHandlerUtil); // Create the spdx document database handler - this.spdxDocumentDatabaseHandler = new SpdxDocumentDatabaseHandler(httpClient, DatabaseSettings.COUCH_DB_SPDX); + this.spdxDocumentDatabaseHandler = new SpdxDocumentDatabaseHandler(client, DatabaseSettings.COUCH_DB_SPDX); } - public ComponentDatabaseHandler(Supplier httpClient, String dbName, String changeLogsDbName, String attachmentDbName, ComponentModerator moderator, ReleaseModerator releaseModerator, ProjectModerator projectModerator) throws MalformedURLException { - this(httpClient, dbName, attachmentDbName, moderator, releaseModerator, projectModerator); - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(httpClient, changeLogsDbName); + public ComponentDatabaseHandler(Cloudant client, String dbName, String changeLogsDbName, String attachmentDbName, ComponentModerator moderator, ReleaseModerator releaseModerator, ProjectModerator projectModerator) throws MalformedURLException { + this(client, dbName, attachmentDbName, moderator, releaseModerator, projectModerator); + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, changeLogsDbName); this.dbHandlerUtil = new DatabaseHandlerUtil(db); } - public ComponentDatabaseHandler(Supplier supplier, String dbName, String attachmentDbName) throws MalformedURLException { - this(supplier, dbName, attachmentDbName, new ComponentModerator(), new ReleaseModerator(), new ProjectModerator()); + public ComponentDatabaseHandler(Cloudant client, String dbName, String attachmentDbName) throws MalformedURLException { + this(client, dbName, attachmentDbName, new ComponentModerator(), new ReleaseModerator(), new ProjectModerator()); } - public ComponentDatabaseHandler(Supplier supplier, String dbName, String changelogsDbName, String attachmentDbName) throws MalformedURLException { - this(supplier, dbName, attachmentDbName, new ComponentModerator(), new ReleaseModerator(), new ProjectModerator()); - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(supplier, changelogsDbName); + public ComponentDatabaseHandler(Cloudant client, String dbName, String changelogsDbName, String attachmentDbName) throws MalformedURLException { + this(client, dbName, attachmentDbName, new ComponentModerator(), new ReleaseModerator(), new ProjectModerator()); + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, changelogsDbName); this.dbHandlerUtil = new DatabaseHandlerUtil(db); } - public ComponentDatabaseHandler(Supplier httpClient, String dbName, String changeLogsDbName, String attachmentDbName, ThriftClients thriftClients) throws MalformedURLException { - this(httpClient, dbName, attachmentDbName, new ComponentModerator(thriftClients), new ReleaseModerator(thriftClients), new ProjectModerator(thriftClients)); + public ComponentDatabaseHandler(Cloudant client, String dbName, String changeLogsDbName, String attachmentDbName, ThriftClients thriftClients) throws MalformedURLException { + this(client, dbName, attachmentDbName, new ComponentModerator(thriftClients), new ReleaseModerator(thriftClients), new ProjectModerator(thriftClients)); } private void autosetReleaseClearingState(Release releaseAfter, Release releaseBefore) { @@ -225,8 +225,6 @@ private void autosetReleaseClearingState(Release releaseAfter, Release releaseBe long isrCountAfter = evaluateClearingStateForScanAvailable(releaseAfter); if (isrCountAfter > 0) { releaseAfter.setClearingState(ClearingState.SCAN_AVAILABLE); - } else { - releaseAfter.setClearingState(ClearingState.NEW_CLEARING); } if (newSecondBestCR.isPresent()) { @@ -455,27 +453,35 @@ private void setMainLicenses(Component component) { * Add new release to the database */ public AddDocumentRequestSummary addComponent(Component component, String user) throws SW360Exception { - if(isDuplicateUsingVcs(component, true)){ - final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() - .setRequestStatus(AddDocumentRequestStatus.DUPLICATE); - Set duplicates = componentRepository.getComponentIdsByVCS(component.getVcs(), true); - if (duplicates.size() == 1) { - duplicates.forEach(addDocumentRequestSummary::setId); + if (isNotNullEmptyOrWhitespace(component.getVcs())) { + String vcsUrl = component.getVcs(); + if (isDuplicateUsingVcs(vcsUrl, true)){ + final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() + .setRequestStatus(AddDocumentRequestStatus.DUPLICATE); + Set duplicates = componentRepository.getComponentIdsByVCS(component.getVcs(), true); + if (duplicates.size() == 1) { + duplicates.forEach(addDocumentRequestSummary::setId); + } + return addDocumentRequestSummary; } - return addDocumentRequestSummary; + if (!CommonUtils.isValidUrl(vcsUrl)) { + log.error("Invalid VCS URL: " + vcsUrl); + return new AddDocumentRequestSummary().setRequestStatus(AddDocumentRequestStatus.INVALID_INPUT); + } + } - }else if(isDuplicate(component, true)) { - final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() - .setRequestStatus(AddDocumentRequestStatus.DUPLICATE); - Set duplicates = componentRepository.getComponentIdsByName(component.getName(), true); - if (duplicates.size() == 1) { - duplicates.forEach(addDocumentRequestSummary::setId); + if (component.getName().trim().length() == 0) { + return new AddDocumentRequestSummary().setRequestStatus(AddDocumentRequestStatus.NAMINGERROR); + } else { + if (isDuplicate(component.getName(), true)) { + final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() + .setRequestStatus(AddDocumentRequestStatus.DUPLICATE); + Set duplicates = componentRepository.getComponentIdsByName(component.getName(), true); + if (duplicates.size() == 1) { + duplicates.forEach(addDocumentRequestSummary::setId); + } + return addDocumentRequestSummary; } - return addDocumentRequestSummary; - } - if(component.getName().trim().length() == 0) { - return new AddDocumentRequestSummary() - .setRequestStatus(AddDocumentRequestStatus.NAMINGERROR); } if (!isDependenciesExistInComponent(component)) { @@ -589,31 +595,27 @@ public AddDocumentRequestSummary addRelease(Release release, User user) throws S .setId(id); } - private boolean isDuplicate(Component component, boolean caseInsenstive){ - return isDuplicate(component.getName(), caseInsenstive); + private boolean isDuplicate(Component component, boolean caseInsensitive){ + return isDuplicate(component.getName(), caseInsensitive); } private boolean isDuplicate(Release release){ return isDuplicate(release.getName(), release.getVersion()); } - private boolean isDuplicate(String componentName, boolean caseInsenstive) { + public boolean isDuplicate(String componentName, boolean caseInsensitive) { if (isNullEmptyOrWhitespace(componentName)) { return false; } - Set duplicates = componentRepository.getComponentIdsByName(componentName, caseInsenstive); + Set duplicates = componentRepository.getComponentIdsByName(componentName.trim(), caseInsensitive); return duplicates.size()>0; } - private boolean isDuplicateUsingVcs(Component component, boolean caseInsenstive){ - return isDuplicateUsingVcs(component.getVcs(), caseInsenstive); - } - - private boolean isDuplicateUsingVcs(String vcsUrl, boolean caseInsenstive){ + private boolean isDuplicateUsingVcs(String vcsUrl, boolean caseInsensitive){ if (isNullEmptyOrWhitespace(vcsUrl)) { return false; } - Set duplicates = componentRepository.getComponentIdsByVCS(vcsUrl, caseInsenstive); + Set duplicates = componentRepository.getComponentIdsByVCS(vcsUrl, caseInsensitive); return duplicates.size()>0; } @@ -625,9 +627,9 @@ private boolean isDuplicate(String releaseName, String releaseVersion) { return duplicates.size()>0; } - private void isDuplicateComponent(List componentNames, boolean caseInsenstive) { + private void isDuplicateComponent(List componentNames, boolean caseInsensitive) { for (String name : componentNames) { - if(!isDuplicate(name, caseInsenstive)) + if(!isDuplicate(name, caseInsensitive)) listComponentName.add(name); } } @@ -694,13 +696,24 @@ public RequestStatus updateComponent(Component component, User user) throws SW36 public RequestStatus updateComponent(Component component, User user, boolean forceUpdate) throws SW360Exception { removeLeadingTrailingWhitespace(component); String name = component.getName(); + String vcs = component.getVcs(); + if (name == null || name.isEmpty()) { return RequestStatus.NAMINGERROR; } + + if (isNotNullEmptyOrWhitespace(vcs)) { + if (!CommonUtils.isValidUrl(vcs)) { + log.error("Invalid VCS URL: " + vcs); + return RequestStatus.INVALID_INPUT; + } + } + Set categories = component.getCategories(); if (categories == null || categories.isEmpty()) { component.setCategories(ImmutableSet.of(DEFAULT_CATEGORY)); } + // Prepare component for database prepareComponent(component); @@ -753,6 +766,16 @@ public RequestStatus updateComponent(Component component, User user, boolean for } + public Component getComponentByName(String name) { + Set components = componentRepository.getComponentIdsByName(name,true); + if (components != null && components.size() == 1) { + Component comp = componentRepository.get(components.iterator().next()); + return comp; + } else { + return null; + } + } + private boolean isDependenciesExistInComponent(Component component) { boolean isValidDependentIds = true; if (component.isSetReleaseIds()) { @@ -822,12 +845,17 @@ private void updateEccStatusForRelease(Component component) { } private boolean changeWouldResultInDuplicate(Component before, Component after) { - if (before.getName().equals(after.getName())) { - // sth else was changed, not one of the duplication relevant properties - return false; + String beforeVCS = isNullEmptyOrWhitespace(before.getVcs()) ? "" : before.getVcs().trim(); + String afterVCS = isNullEmptyOrWhitespace(after.getVcs()) ? "" : after.getVcs().trim(); + + if (before.getName().trim().equalsIgnoreCase(after.getName().trim())) { + if (beforeVCS.equalsIgnoreCase(afterVCS)) { + return false; + } + return isDuplicateUsingVcs(afterVCS, true); } - return isDuplicate(after, false); + return isDuplicate(after, true); } private boolean duplicateAttachmentExist(Component component) { @@ -837,7 +865,6 @@ private boolean duplicateAttachmentExist(Component component) { return false; } - private void updateComponentInternal(Component updated, Component current, User user) { updateModifiedFields(updated, user.getEmail()); // Update the database with the component @@ -1132,12 +1159,13 @@ public RequestStatus updateRelease(Release release, User user, Iterable referenceDocLogList = new LinkedList<>(); Set attachmentsAfter = release.getAttachments(); @@ -1343,7 +1371,7 @@ public RequestSummary updateReleases(Collection releases, User user, bo RequestSummary requestSummary = new RequestSummary(); if (allowUpdate || PermissionUtils.isAdmin(user)) { // Prepare component for database - final List documentOperationResults = componentRepository.executeBulk(storedReleases); + final List documentOperationResults = componentRepository.executeBulk(storedReleases); if (!documentOperationResults.isEmpty()) { @@ -2017,7 +2045,13 @@ public Map getAllComponentsIdMap() { } public List getAllComponentsWithVCS() { - final List components = componentRepository.getComponentsByVCS(); + final List componentsWithVCS = componentRepository.getComponentsByVCS(); + final List components = new ArrayList<>(); + for (Component component : componentsWithVCS) { + if (!CommonUtils.isNullOrEmptyCollection(component.getReleaseIds())) { + components.add(component); + } + } return components; } @@ -2709,9 +2743,9 @@ public RequestStatus updateReleasesWithSvmTrackingFeedback() { } } }); - List documentOperationResults = releaseRepository.executeBulk(releases); - documentOperationResults = documentOperationResults.stream().filter(res -> res.getError() != null || res.getStatusCode() != HttpStatus.SC_CREATED) - .collect(Collectors.toList()); + List documentOperationResults = releaseRepository.executeBulk(releases); + documentOperationResults = documentOperationResults.stream().filter(res -> res.getError() != null || !res.isOk()) + .toList(); if (documentOperationResults.isEmpty()) { log.info(String.format("SVMTF: updated %d releases", releases.size())); } else { @@ -2801,7 +2835,7 @@ public RequestSummary importBomFromAttachmentContent(User user, String attachmen try (final InputStream inputStream = attachmentStreamConnector.unsafeGetAttachmentStream(attachmentContent)) { final SpdxBOMImporterSink spdxBOMImporterSink = new SpdxBOMImporterSink(user, null, this); final SpdxBOMImporter spdxBOMImporter = new SpdxBOMImporter(spdxBOMImporterSink); - return spdxBOMImporter.importSpdxBOMAsRelease(inputStream, attachmentContent); + return spdxBOMImporter.importSpdxBOMAsRelease(inputStream, attachmentContent, user); } } catch (IOException e) { throw new SW360Exception(e.getMessage()); @@ -3069,7 +3103,6 @@ public RequestStatus uploadSourceCodeAttachmentToReleases() { components.forEach(c -> { String VCS = c.getVcs(); - log.info(String.format("SRC Upload: %s %s", c.getId(), VCS)); // Add more domains in the future and include the download logic accordingly if (VCS.toLowerCase().contains("github.com")) { for (String r_id : c.getReleaseIds()) { @@ -3085,6 +3118,7 @@ public RequestStatus uploadSourceCodeAttachmentToReleases() { releasesWithoutSRC.add(r.getId()); String version = r.getVersion(); Release originalReleaseData = r.deepCopy(); + log.info(String.format("SRC Upload: %s %s", c.getVcs(), version)); for (String format : formats) { String downloadURL = String.format(format, c.getVcs(), version); @@ -3108,6 +3142,8 @@ public RequestStatus uploadSourceCodeAttachmentToReleases() { log.error( "SRC Upload: Error while downloading the source code zip file for release:" + r.getId() + " " + e); + } catch (Exception e) { + log.error("An exception occured while uploading source:" + r.getId() + " " + e); } } } @@ -3143,7 +3179,7 @@ private boolean isValidURL(String url) { } else { return false; } - } catch (IOException e) { + } catch (Exception e) { log.error("Error while checking the validity of the URL " + url, e); return false; } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java similarity index 84% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java index 3f494454e1..ded82d1d4a 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentRepository.java @@ -18,12 +18,9 @@ import org.eclipse.sw360.datahandler.thrift.components.Component; import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequest; -import com.cloudant.client.api.views.ViewRequestBuilder; -import com.cloudant.client.api.views.ViewResponse; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResult; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -161,7 +158,7 @@ public class ComponentRepository extends SummaryAwareRepository { public ComponentRepository(DatabaseConnectorCloudant db, ReleaseRepository releaseRepository, VendorRepository vendorRepository) { super(Component.class, db, new ComponentSummary(releaseRepository, vendorRepository)); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("byCreatedOn", createMapReduce(BY_CREATED_ON, null)); views.put("usedAttachmentContents", createMapReduce(USED_ATTACHMENT_CONTENTS, null)); @@ -183,18 +180,19 @@ public ComponentRepository(DatabaseConnectorCloudant db, ReleaseRepository relea } public List getRecentComponentsSummary(int limit, User user) { - ViewRequestBuilder query = getConnector().createQuery(Component.class, "byCreatedOn"); - UnpaginatedRequestBuilder unPagnReques = query.newRequest(Key.Type.STRING, Object.class).includeDocs(true).descending(true); + PostViewOptions.Builder queryBuilder = getConnector().getPostViewQueryBuilder(Component.class, "byCreatedOn") + .includeDocs(true) + .descending(true); if (limit >= 0){ - unPagnReques.limit(limit); + queryBuilder.limit(limit); } - List components = new ArrayList(getFullDocsById(queryForIdsAsValue(unPagnReques))); + List components = new ArrayList<>(getFullDocsById(queryForIdsAsValue(queryBuilder.build()))); return makeSummaryWithPermissionsFromFullDocs(SummaryType.SUMMARY, components, user); } public Set getUsedAttachmentContents() { - return queryForIdsAsValue(getConnector().createQuery(Component.class, "usedAttachmentContents")); + return queryForIdsAsValue(getConnector().getPostViewQueryBuilder(Component.class, "usedAttachmentContents").build()); } public Collection getMyComponents(String user) { @@ -254,7 +252,7 @@ public Set getUsingComponents(String releaseId) { public Component getComponentFromFossologyUploadId(String fossologyUploadId) { final Set componentIdList = queryForIdsAsValue("byFossologyId", fossologyUploadId); - if (componentIdList != null && componentIdList.size() > 0) + if (componentIdList != null && !componentIdList.isEmpty()) return get(CommonUtils.getFirst(componentIdList)); return null; } @@ -277,56 +275,50 @@ public Set searchByExternalIds(Map> externalIds) public Map> getRecentComponentsSummary(User user, PaginationData pageData) { final int rowsPerPage = pageData.getRowsPerPage(); + final int offset = pageData.getDisplayStart(); Map> result = Maps.newHashMap(); List components = Lists.newArrayList(); final boolean ascending = pageData.isAscending(); final int sortColumnNo = pageData.getSortColumnNumber(); - ViewRequestBuilder query; + PostViewOptions.Builder query; switch (sortColumnNo) { - case -1: - query = getConnector().createQuery(Component.class, "byCreatedOn"); - break; - case 0: - query = getConnector().createQuery(Component.class, "byvendor"); - break; - case 1: - query = getConnector().createQuery(Component.class, "byname"); - break; - case 2: - query = getConnector().createQuery(Component.class, "bymainlicense"); - break; - case 3: - query = getConnector().createQuery(Component.class, "bycomponenttype"); - break; - default: - query = getConnector().createQuery(Component.class, "all"); - break; + case -1: + query = getConnector().getPostViewQueryBuilder(Component.class, "byCreatedOn"); + break; + case 0: + query = getConnector().getPostViewQueryBuilder(Component.class, "byvendor"); + break; + case 1: + query = getConnector().getPostViewQueryBuilder(Component.class, "byname"); + break; + case 2: + query = getConnector().getPostViewQueryBuilder(Component.class, "bymainlicense"); + break; + case 3: + query = getConnector().getPostViewQueryBuilder(Component.class, "bycomponenttype"); + break; + default: + query = getConnector().getPostViewQueryBuilder(Component.class, "all"); + break; } - ViewRequest request = null; + PostViewOptions request; if (rowsPerPage == -1) { - request = query.newRequest(Key.Type.STRING, Object.class).descending(!ascending).includeDocs(true).build(); + request = query.descending(!ascending).includeDocs(true).build(); } else { - request = query.newPaginatedRequest(Key.Type.STRING, Object.class).rowsPerPage(rowsPerPage) + request = query.limit(rowsPerPage).skip(offset) .descending(!ascending).includeDocs(true).build(); } - ViewResponse response = null; try { - response = request.getResponse(); - int pageNo = pageData.getDisplayStart() / rowsPerPage; - int i = 1; - while (i <= pageNo) { - response = response.nextPage(); - i++; - } - components = response.getDocsAs(Component.class); - } catch (Exception e) { + ViewResult response = getConnector().getPostViewQueryResponse(request); + components = getPojoFromViewResponse(response); + pageData.setTotalRowCount(response.getTotalRows()); + } catch (ServiceConfigurationError e) { log.error("Error getting recent components", e); } components = makeSummaryWithPermissionsFromFullDocs(SummaryType.SUMMARY, components, user); - pageData.setTotalRowCount(response.getTotalRowCount()); result.put(pageData, components); return result; } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentSearchHandler.java new file mode 100644 index 0000000000..b3ed808277 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ComponentSearchHandler.java @@ -0,0 +1,118 @@ +/* + * Copyright Siemens AG, 2013-2016. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.components.Component; +import org.eclipse.sw360.datahandler.thrift.users.RequestedAction; +import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.eclipse.sw360.common.utils.SearchUtils.OBJ_ARRAY_TO_STRING_INDEX; +import static org.eclipse.sw360.datahandler.permissions.PermissionUtils.makePermission; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +/** + * Class for accessing the Lucene connector on the CouchDB database + * + * @author cedric.bodet@tngtech.com + * @author alex.borodin@evosoft.com + */ +public class ComponentSearchHandler { + + private static final Logger log = LogManager.getLogger(ComponentSearchHandler.class); + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("components", + new NouveauIndexFunction( + "function(doc) {" + + OBJ_ARRAY_TO_STRING_INDEX + + " if(!doc.type || doc.type != 'component') return;" + + " arrayToStringIndex(doc.categories, 'categories');" + + " arrayToStringIndex(doc.languages, 'languages');" + + " arrayToStringIndex(doc.softwarePlatforms, 'softwarePlatforms');" + + " arrayToStringIndex(doc.operatingSystems, 'operatingSystems');" + + " arrayToStringIndex(doc.vendorNames, 'vendorNames');" + + " arrayToStringIndex(doc.mainLicenseIds, 'mainLicenseIds');" + + " if(doc.componentType && typeof(doc.componentType) == 'string' && doc.componentType.length > 0) {" + + " index('text', 'componentType', doc.componentType, {'store': true});" + + " }" + + " if(doc.name && typeof(doc.name) == 'string' && doc.name.length > 0) {" + + " index('text', 'name', doc.name, {'store': true});"+ + " }" + + " if(doc.createdBy && typeof(doc.createdBy) == 'string' && doc.createdBy.length > 0) {" + + " index('text', 'createdBy', doc.createdBy, {'store': true});"+ + " }" + + " if(doc.createdOn && doc.createdOn.length) {"+ + " var dt = new Date(doc.createdOn);"+ + " var formattedDt = `${dt.getFullYear()}${(dt.getMonth()+1).toString().padStart(2,'0')}${dt.getDate().toString().padStart(2,'0')}`;" + + " index('double', 'createdOn', Number(formattedDt), {'store': true});"+ + " }" + + " if(doc.businessUnit && typeof(doc.businessUnit) == 'string' && doc.businessUnit.length > 0) {" + + " index('text', 'businessUnit', doc.businessUnit, {'store': true});"+ + " }" + + "}")); + + + private final NouveauLuceneAwareDatabaseConnector connector; + + public ComponentSearchHandler(Cloudant cClient, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(cClient, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String text, final Map> subQueryRestrictions ){ + return connector.searchViewWithRestrictions(Component.class, luceneSearchView.getIndexName(), + text, subQueryRestrictions); + } + + public List searchAccessibleComponents(String text, final Map> subQueryRestrictions, User user ){ + List resultComponentList = connector.searchViewWithRestrictions(Component.class, + luceneSearchView.getIndexName(), text, subQueryRestrictions); + List componentList = new ArrayList(); + for (Component component : resultComponentList) { + if (makePermission(component, user).isActionAllowed(RequestedAction.READ)) { + componentList.add(component); + } + } + return componentList; + } + + public List searchWithAccessibility(String text, final Map> subQueryRestrictions, + User user ){ + List resultComponentList = connector.searchViewWithRestrictions(Component.class, + luceneSearchView.getIndexName(), text, subQueryRestrictions); + for (Component component : resultComponentList) { + makePermission(component, user).fillPermissionsInOther(component); + } + return resultComponentList; + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java similarity index 74% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java index bc4da43db7..fc3158c8b5 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ConfigContainerRepository.java @@ -14,11 +14,10 @@ import org.eclipse.sw360.datahandler.thrift.ConfigContainer; import org.eclipse.sw360.datahandler.thrift.ConfigFor; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,7 +29,7 @@ public class ConfigContainerRepository extends DatabaseRepositoryCloudantClient< public ConfigContainerRepository(DatabaseConnectorCloudant databaseConnector) { super(databaseConnector, ConfigContainer.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("byId", createMapReduce(BYID, null)); views.put("byConfigFor", createMapReduce(BYCONFIGFOR, null)); @@ -38,11 +37,11 @@ public ConfigContainerRepository(DatabaseConnectorCloudant databaseConnector) { } public ConfigContainer getByConfigFor(ConfigFor configFor) { - ViewRequestBuilder query = getConnector().createQuery(ConfigContainer.class, "byConfigFor"); - UnpaginatedRequestBuilder reqBuilder = query.newRequest(Key.Type.STRING, Object.class) - .keys(configFor.toString()).includeDocs(true); + PostViewOptions query = getConnector().getPostViewQueryBuilder(ConfigContainer.class, "byConfigFor") + .keys(Collections.singletonList(configFor.toString())) + .includeDocs(true).build(); - List configs = queryView(reqBuilder); + List configs = queryView(query); if (configs.size() != 1) { throw new IllegalStateException( "There are " + configs.size() + " configuration objects in the couch db for type " + configFor diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java similarity index 93% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java index 71f78a8161..88bb6d5c98 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/CustomPropertiesRepository.java @@ -16,7 +16,7 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.CustomProperties; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; import java.util.HashMap; import java.util.List; @@ -41,7 +41,7 @@ public class CustomPropertiesRepository extends DatabaseRepositoryCloudantClient public CustomPropertiesRepository(DatabaseConnectorCloudant db) { super(db, CustomProperties.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("customPropertiesByDocType", createMapReduce(CUSTOM_PROPERTIES_BY_DOCTYPE, null)); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java similarity index 99% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java index 38e69df0f4..413d97dff1 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/DatabaseHandlerUtil.java @@ -625,10 +625,14 @@ private static Runnable prepareChangeLogRunnable(T newDocVersi referenceDocLogList.stream().forEach(referenceDocLog -> { referenceDocLog.setDocumentId(changeLogParentId); changelog.debug(convertObjectToJson(referenceDocLog)); - changeLogRepository.add(referenceDocLog); + try { + changeLogRepository.add(referenceDocLog); + } catch (SW360Exception e) { + log.error("Error occurred while adding change log", e); + } }); } catch (Exception exp) { - log.error("Error occured while creating Change Logs", exp); + log.error("Error occurred while creating Change Logs", exp); } }; } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ModerationSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ModerationSearchHandler.java new file mode 100644 index 0000000000..005347f6e5 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ModerationSearchHandler.java @@ -0,0 +1,80 @@ +/* + * Copyright Siemens AG, 2021. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.eclipse.sw360.common.utils.SearchUtils.OBJ_ARRAY_TO_STRING_INDEX; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class ModerationSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("moderations", + new NouveauIndexFunction( + "function(doc) {" + + OBJ_ARRAY_TO_STRING_INDEX + + " if(!doc.type || doc.type != 'moderation' || !doc.documentId) return;" + + " arrayToStringIndex(doc.moderators, 'moderators');" + + " if(doc.documentName && typeof(doc.documentName) == 'string' && doc.documentName.length > 0) {" + + " index('text', 'documentName', doc.documentName, {'store': true});" + + " }" + + " if(doc.documentType && typeof(doc.documentType) == 'string' && doc.documentType.length > 0) {" + + " index('text', 'documentType', doc.documentType, {'store': true});" + + " }" + + " if(doc.componentType && typeof(doc.componentType) == 'string' && doc.componentType.length > 0) {" + + " index('text', 'componentType', doc.componentType, {'store': true});" + + " }" + + " if(doc.requestingUser && typeof(doc.requestingUser) == 'string' && doc.requestingUser.length > 0) {" + + " index('text', 'requestingUser', doc.requestingUser, {'store': true});" + + " }" + + " if(doc.requestingUserDepartment && typeof(doc.requestingUserDepartment) == 'string' && doc.requestingUserDepartment.length > 0) {" + + " index('text', 'requestingUserDepartment', doc.requestingUserDepartment, {'store': true});" + + " }" + + " if(doc.moderationState && typeof(doc.moderationState) == 'string' && doc.moderationState.length > 0) {" + + " index('text', 'moderationState', doc.moderationState, {'store': true});" + + " }" + + " if(doc.timestamp) {"+ + " var dt = new Date(doc.timestamp); "+ + " var formattedDt = `${dt.getFullYear()}${(dt.getMonth()+1).toString().padStart(2,'0')}${dt.getDate().toString().padStart(2,'0')}`;" + + " index('double', 'timestamp', Number(formattedDt), {'store': true});"+ + " }" + + "}")); + private final NouveauLuceneAwareDatabaseConnector connector; + + public ModerationSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String text, final Map> subQueryRestrictions ) { + return connector.searchViewWithRestrictions(ModerationRequest.class, luceneSearchView.getIndexName(), + text, subQueryRestrictions); + } +} diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationElementSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationElementSearchHandler.java new file mode 100644 index 0000000000..971ab0ca20 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationElementSearchHandler.java @@ -0,0 +1,69 @@ +/* + * Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. + * Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseInstanceCloudant; +import org.eclipse.sw360.datahandler.common.DatabaseSettings; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.licenses.ObligationElement; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class ObligationElementSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("obligationelements", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'obligationElement') {" + + " if (doc.langElement && typeof(doc.langElement) == 'string' && doc.langElement.length > 0) {" + + " index('text', 'langElement', doc.langElement, {'store': true});" + + " }" + + " if (doc.action && typeof(doc.action) == 'string' && doc.action.length > 0) {" + + " index('text', 'action', doc.action, {'store': true});" + + " }" + + " if (doc.object && typeof(doc.object) == 'string' && doc.object.length > 0) {" + + " index('text', 'object', doc.object, {'store': true});" + + " }" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public ObligationElementSearchHandler(Cloudant cClient, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(cClient, dbName); + // Creates the database connector and adds the lucene search view + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + connector.setResultLimit(DatabaseSettings.LUCENE_SEARCH_LIMIT); + } + + public List search(String searchText) { + return connector.searchView(ObligationElement.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java similarity index 90% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java index 31a1ca7537..6a54832dd0 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationListRepository.java @@ -16,9 +16,8 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.projects.ObligationList; -import org.ektorp.support.View; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; /** * CRUD access for the Project class @@ -38,7 +37,7 @@ public class ObligationListRepository extends DatabaseRepositoryCloudantClient views = new HashMap(); + Map views = new HashMap<>(); views.put("byProjectId", createMapReduce(BY_PROJECT_ID, null)); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationSearchHandler.java new file mode 100644 index 0000000000..f03433b1de --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ObligationSearchHandler.java @@ -0,0 +1,64 @@ +/* + * Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. + * Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.common.DatabaseSettings; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.licenses.Obligation; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class ObligationSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("obligations", + new NouveauIndexFunction( + "function(doc) {" + + " if(!doc.type || doc.type != 'obligation') return;" + + " if(doc.title !== undefined && doc.title != null && doc.title.length >0) {" + + " index('text', 'title', doc.title, {'store': true});" + + " }" + + " if(doc.text !== undefined && doc.text != null && doc.text.length >0) {" + + " index('text', 'text', doc.text, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public ObligationSearchHandler(Cloudant cClient, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(cClient, dbName); + // Creates the database connector and adds the lucene search view + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + connector.setResultLimit(DatabaseSettings.LUCENE_SEARCH_LIMIT); + } + + public List search(String searchText) { + return connector.searchView(Obligation.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java similarity index 92% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java index 687fa0e447..e8dbb9b06d 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageDatabaseHandler.java @@ -1,8 +1,8 @@ /* * Copyright Siemens Healthineers GmBH, 2023. Part of the SW360 Portal Project. * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 @@ -21,10 +21,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.stream.Collectors; -import org.apache.http.HttpStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.sw360.cyclonedx.CycloneDxBOMImporter; @@ -49,8 +47,8 @@ import org.eclipse.sw360.datahandler.thrift.packages.PackageManager; import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.CloudantClient; -import com.cloudant.client.api.model.Response; +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; import com.github.packageurl.MalformedPackageURLException; import com.github.packageurl.PackageURL; import com.google.common.collect.ImmutableList; @@ -77,29 +75,29 @@ public class PackageDatabaseHandler extends AttachmentAwareDatabaseHandler { Package._Fields.NAME, Package._Fields.VERSION, Package._Fields.VCS, Package._Fields.DESCRIPTION, Package._Fields.HOMEPAGE_URL, Package._Fields.PURL, Package._Fields.HASH); - public PackageDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName, String changeLogsDbName, + public PackageDatabaseHandler(Cloudant client, String dbName, String attachmentDbName, String changeLogsDbName, AttachmentDatabaseHandler attachmentDatabaseHandler, ComponentDatabaseHandler componentDatabaseHandler) throws MalformedURLException { super(attachmentDatabaseHandler); - db = new DatabaseConnectorCloudant(httpClient, dbName); + db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories packageRepository = new PackageRepository(db); projectRepository = new ProjectRepository(db); // Create the attachment connector - attachmentConnector = new AttachmentConnector(httpClient, attachmentDbName, Duration.durationOf(30, TimeUnit.SECONDS)); + attachmentConnector = new AttachmentConnector(client, attachmentDbName, Duration.durationOf(30, TimeUnit.SECONDS)); this.componentDatabaseHandler = componentDatabaseHandler; - DatabaseConnectorCloudant changeLogsDb = new DatabaseConnectorCloudant(httpClient, changeLogsDbName); + DatabaseConnectorCloudant changeLogsDb = new DatabaseConnectorCloudant(client, changeLogsDbName); this.databaseHandlerUtil = new DatabaseHandlerUtil(changeLogsDb); } - public PackageDatabaseHandler(Supplier httpClient, String dbName, String changeLogsDbName, String attachmentDbName) + public PackageDatabaseHandler(Cloudant client, String dbName, String changeLogsDbName, String attachmentDbName) throws MalformedURLException { - this(httpClient, dbName, attachmentDbName, changeLogsDbName, new AttachmentDatabaseHandler(httpClient, dbName, attachmentDbName), - new ComponentDatabaseHandler(httpClient, dbName, changeLogsDbName, attachmentDbName)); + this(client, dbName, attachmentDbName, changeLogsDbName, new AttachmentDatabaseHandler(client, dbName, attachmentDbName), + new ComponentDatabaseHandler(client, dbName, changeLogsDbName, attachmentDbName)); } public Package getPackageById(String id) throws SW360Exception { @@ -206,7 +204,7 @@ public AddDocumentRequestSummary addPackage(Package pkg, User user) throws SW360 preparePackage(pkg); List duplicatePackagesByPurl = getPackageByPurl(pkg.getPurl()); - if (duplicatePackagesByPurl.size() > 0) { + if (!duplicatePackagesByPurl.isEmpty()) { final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() .setRequestStatus(AddDocumentRequestStatus.DUPLICATE) .setMessage(SW360Constants.DUPLICATE_PACKAGE_BY_PURL); @@ -216,7 +214,7 @@ public AddDocumentRequestSummary addPackage(Package pkg, User user) throws SW360 return addDocumentRequestSummary; }else{ List duplicatePackages = getPackageByNameAndVersion(name, version); - if(duplicatePackages.size() > 0){ + if(!duplicatePackages.isEmpty()){ final AddDocumentRequestSummary addDocumentRequestSummary = new AddDocumentRequestSummary() .setRequestStatus(AddDocumentRequestStatus.DUPLICATE); if(duplicatePackages.size() == 1) { @@ -317,12 +315,12 @@ public RequestStatus updatePackage(Package updatedPkg, User user) throws SW360Ex // Ensure that release exists try { // once we are sure that release exists, update the package - Response resp = packageRepository.updateWithResponse(updatedPkg); + DocumentResult resp = packageRepository.updateWithResponse(updatedPkg); if (CommonUtils.isNotNullEmptyOrWhitespace(actualReleaseId)) { Release actualRelease = componentDatabaseHandler.getRelease(actualReleaseId, user); Set packageIds = CommonUtils.nullToEmptySet(actualRelease.getPackageIds()); - // Update the previously linked release, if it contain package id - if (resp.getStatusCode() == HttpStatus.SC_CREATED) { + // Update the previously linked release, if it contains package id + if (resp.isOk()) { if (packageIds.contains(packageId)) { packageIds.remove(packageId); actualRelease.setPackageIds(packageIds); @@ -339,7 +337,7 @@ public RequestStatus updatePackage(Package updatedPkg, User user) throws SW360Ex Release newRelease = componentDatabaseHandler.getRelease(newReleaseId, user); Set packageIds = CommonUtils.nullToEmptySet(newRelease.getPackageIds()); // Update the newly linked release, if it does not contain package id - if (resp.getStatusCode() == HttpStatus.SC_CREATED) { + if (resp.isOk()) { if (!packageIds.contains(packageId)) { newRelease.addToPackageIds(packageId); componentDatabaseHandler.updateRelease(newRelease, user, ThriftUtils.IMMUTABLE_OF_RELEASE, true); @@ -411,17 +409,29 @@ private boolean changeWouldResultInDuplicate(Package before, Package after) { return false; } List duplicates = getPackageByNameAndVersion(after.getName(), after.getVersion()); - return duplicates.size() > 0; + return !duplicates.isEmpty(); } - private List getPackageByNameAndVersion(String pkgName, String pkgVersion) { + public List searchByName(String name) { + return packageRepository.searchByName(name); + } + + public List searchByVersion(String version) { + return packageRepository.searchByVersion(version); + } + + public List searchByPackageManager(String packageManager) { + return packageRepository.searchByPackageManager(packageManager); + } + + public List getPackageByNameAndVersion(String pkgName, String pkgVersion) { if (isNullEmptyOrWhitespace(pkgName)) { return Collections.emptyList(); } return packageRepository.searchByNameAndVersion(pkgName, pkgVersion, true); } - private List getPackageByPurl(String purl) { + public List getPackageByPurl(String purl) { if (isNullEmptyOrWhitespace(purl)) { return Collections.emptyList(); } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java similarity index 74% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java index ae016087fc..14f9f6b30f 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageRepository.java @@ -21,13 +21,10 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.PaginationData; import org.eclipse.sw360.datahandler.thrift.packages.Package; -import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.ViewRequest; -import com.cloudant.client.api.views.ViewRequestBuilder; -import com.cloudant.client.api.views.ViewResponse; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResult; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -50,10 +47,11 @@ public class PackageRepository extends DatabaseRepositoryCloudantClient private static final String BY_LICENSE_IDS = "function(doc) { if (doc.type == 'package') { if (doc.licenseIds) { emit(doc.licenseIds.join(), doc._id); } else { emit('', doc._id); } } }"; private static final String BY_PURL = "function(doc) { if (doc.type == 'package') { emit(doc.purl.trim(), doc._id) } }"; private static final String BY_PURL_LOWERCASE = "function(doc) { if (doc.type == 'package') { emit(doc.purl.toLowerCase().trim(), doc._id) } }"; + private static final String BY_VERSION = "function(doc) { if (doc.type == 'package') { emit(doc.version.trim(), doc._id) } }"; public PackageRepository(DatabaseConnectorCloudant db) { super(db, Package.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("orphan", createMapReduce(ORPHAN, null)); views.put("byName", createMapReduce(BY_NAME, null)); @@ -65,6 +63,7 @@ public PackageRepository(DatabaseConnectorCloudant db) { views.put("byLicenseIds", createMapReduce(BY_LICENSE_IDS, null)); views.put("byPurl", createMapReduce(BY_PURL, null)); views.put("byPurlLowercase", createMapReduce(BY_PURL_LOWERCASE, null)); + views.put("byVersion", createMapReduce(BY_VERSION, null)); initStandardDesignDocument(views, db); } @@ -76,19 +75,19 @@ public List getPackagesByReleaseId(String id) { return queryView("byReleaseId", id); } - public List searchByName(String name, User user) { + public List searchByName(String name) { return queryView("byName", name); } - public List searchByNameLowerCase(String name, User user) { + public List searchByNameLowerCase(String name) { return queryView("byNameLowerCase", name.toLowerCase()); } - public List searchByPackageManager(String pkgType, User user) { - return queryView("byPackageManager", pkgType.toUpperCase()); + public List searchByPackageManager(String pkgType) { + return queryView("byPackageManager", pkgType.toLowerCase()); } - public List searchByCreator(String email, User user) { + public List searchByCreator(String email) { return queryView("byCreator", email); } @@ -96,6 +95,10 @@ public List searchByLicenseeId(String id) { return queryView("byLicenseIds", id); } + public List searchByVersion(String version) { + return queryView("byVersion", version); + } + public List searchByNameAndVersion(String name, String version, boolean caseInsenstive) { List packagesMatchingName; if (caseInsenstive) { @@ -121,52 +124,46 @@ public List searchByPurl(String purl, boolean caseInsenstive) { public Map> getPackagesWithPagination(PaginationData pageData) { final int rowsPerPage = pageData.getRowsPerPage(); + final int offset = pageData.getDisplayStart(); Map> result = Maps.newHashMap(); List packages = Lists.newArrayList(); final boolean ascending = pageData.isAscending(); final int sortColumnNo = pageData.getSortColumnNumber(); - ViewRequestBuilder query; + PostViewOptions.Builder query; switch (sortColumnNo) { - case -1: - query = getConnector().createQuery(Package.class, "byCreatedOn"); - break; - case 0: - query = getConnector().createQuery(Package.class, "byNameLowerCase"); - break; - case 3: - query = getConnector().createQuery(Package.class, "byLicenseIds"); - break; - case 4: - query = getConnector().createQuery(Package.class, "byPackageManager"); - break; - default: - query = getConnector().createQuery(Package.class, "all"); - break; + case -1: + query = getConnector().getPostViewQueryBuilder(Package.class, "byCreatedOn"); + break; + case 0: + query = getConnector().getPostViewQueryBuilder(Package.class, "byNameLowerCase"); + break; + case 3: + query = getConnector().getPostViewQueryBuilder(Package.class, "byLicenseIds"); + break; + case 4: + query = getConnector().getPostViewQueryBuilder(Package.class, "byPackageManager"); + break; + default: + query = getConnector().getPostViewQueryBuilder(Package.class, "all"); + break; } - ViewRequest request = null; + PostViewOptions request; if (rowsPerPage == -1) { - request = query.newRequest(Key.Type.STRING, Object.class).descending(!ascending).includeDocs(true).build(); + request = query.descending(!ascending).includeDocs(true).build(); } else { - request = query.newPaginatedRequest(Key.Type.STRING, Object.class).rowsPerPage(rowsPerPage) + request = query.limit(rowsPerPage).skip(offset) .descending(!ascending).includeDocs(true).build(); } - ViewResponse response = null; try { - response = request.getResponse(); - int pageNo = pageData.getDisplayStart() / rowsPerPage; - int i = 1; - while (i <= pageNo) { - response = response.nextPage(); - i++; - } - packages = response.getDocsAs(Package.class); + ViewResult response = getConnector().getPostViewQueryResponse(request); + packages = getPojoFromViewResponse(response); + pageData.setTotalRowCount(response.getTotalRows()); } catch (Exception e) { log.error("Error getting packages from repository: ", e); } - pageData.setTotalRowCount(response.getTotalRowCount()); result.put(pageData, packages); return result; } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageSearchHandler.java new file mode 100644 index 0000000000..4bcd131234 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/PackageSearchHandler.java @@ -0,0 +1,94 @@ +/* + * Copyright Siemens Healthineers GmBH, 2023. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.packages.Package; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.eclipse.sw360.common.utils.SearchUtils.OBJ_ARRAY_TO_STRING_INDEX; +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class PackageSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("packages", + new NouveauIndexFunction( + "function(doc) {" + + OBJ_ARRAY_TO_STRING_INDEX + + " if (!doc.type || doc.type != 'package') return;" + + " if (doc.name && typeof(doc.name) == 'string' && doc.name.length > 0) {" + + " index('text', 'name', doc.name, {'store': true});"+ + " }" + + " if (doc.version && typeof(doc.version) == 'string' && doc.version.length > 0) {" + + " index('text', 'version', doc.version, {'store': true});"+ + " }" + + " if (doc.purl && typeof(doc.purl) == 'string' && doc.purl.length > 0) {" + + " index('text', 'purl', doc.purl, {'store': true});"+ + " }" + + " if (doc.releaseId && typeof(doc.releaseId) == 'string' && doc.releaseId.length > 0) {" + + " index('text', 'releaseId', doc.releaseId, {'store': true});"+ + " }" + + " if (doc.vcs && typeof(doc.vcs) == 'string' && doc.vcs.length > 0) {" + + " index('text', 'vcs', doc.vcs, {'store': true});"+ + " }" + + " if (doc.packageManager && typeof(doc.packageManager) == 'string' && doc.packageManager.length > 0) {" + + " index('text', 'packageManager', doc.packageManager, {'store': true});"+ + " }" + + " if (doc.packageType && typeof(doc.packageType) == 'string' && doc.packageType.length > 0) {" + + " index('text', 'packageType', doc.packageType, {'store': true});"+ + " }" + + " if (doc.createdBy && typeof(doc.createdBy) == 'string' && doc.createdBy.length > 0) {" + + " index('text', 'createdBy', doc.createdBy, {'store': true});"+ + " }" + + " if(doc.createdOn && doc.createdOn.length) {"+ + " var dt = new Date(doc.createdOn);"+ + " var formattedDt = `${dt.getFullYear()}${(dt.getMonth()+1).toString().padStart(2,'0')}${dt.getDate().toString().padStart(2,'0')}`;" + + " index('double', 'createdOn', Number(formattedDt), {'store': true});"+ + " }" + + " arrayToStringIndex(doc.licenseIds, 'licenseIds');" + + "}")); + + + private final NouveauLuceneAwareDatabaseConnector connector; + + public PackageSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List searchPackagesWithRestrictions(String text, final Map> subQueryRestrictions) { + return connector.searchViewWithRestrictions(Package.class, luceneSearchView.getIndexName(), + text, subQueryRestrictions); + } + + public List searchPackages(String searchText) { + return connector.searchView(Package.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java similarity index 91% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java index 11e0b7d648..28573e4e1f 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java @@ -12,8 +12,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.*; @@ -70,9 +71,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -84,9 +85,9 @@ import static org.eclipse.sw360.datahandler.common.SW360Utils.getBUFromOrganisation; import static org.eclipse.sw360.datahandler.common.SW360Utils.getCreatedOn; import static org.eclipse.sw360.datahandler.common.SW360Utils.printName; +import static org.eclipse.sw360.datahandler.common.WrappedException.wrapSW360Exception; import static org.eclipse.sw360.datahandler.common.WrappedException.wrapTException; import static org.eclipse.sw360.datahandler.permissions.PermissionUtils.makePermission; -import org.apache.commons.io.IOUtils; import org.eclipse.sw360.exporter.ProjectExporter; import java.nio.ByteBuffer; @@ -109,6 +110,8 @@ public class ProjectDatabaseHandler extends AttachmentAwareDatabaseHandler { private static final boolean WITH_ALL_RELEASES = true; private static final boolean WITH_ROOT_RELEASES_ONLY = false; + private ExecutorService projectExecutor; + private final ProjectRepository repository; private final ProjectVulnerabilityRatingRepository pvrRepository; private final ObligationListRepository obligationRepository; @@ -152,35 +155,35 @@ public class ProjectDatabaseHandler extends AttachmentAwareDatabaseHandler { private Map cachedAllProjectsIdMap; private Instant cachedAllProjectsIdMapLoadingInstant; - public ProjectDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName) throws MalformedURLException { - this(httpClient, dbName, attachmentDbName, new ProjectModerator(), - new ComponentDatabaseHandler(httpClient,dbName,attachmentDbName), - new PackageDatabaseHandler(httpClient, dbName, DatabaseSettings.COUCH_DB_CHANGE_LOGS, attachmentDbName), - new AttachmentDatabaseHandler(httpClient, dbName, attachmentDbName)); + public ProjectDatabaseHandler(Cloudant client, String dbName, String attachmentDbName) throws MalformedURLException { + this(client, dbName, attachmentDbName, new ProjectModerator(), + new ComponentDatabaseHandler(client,dbName,attachmentDbName), + new PackageDatabaseHandler(client, dbName, DatabaseSettings.COUCH_DB_CHANGE_LOGS, attachmentDbName), + new AttachmentDatabaseHandler(client, dbName, attachmentDbName)); } - public ProjectDatabaseHandler(Supplier httpClient, String dbName, String changeLogDbName, String attachmentDbName) throws MalformedURLException { - this(httpClient, dbName, changeLogDbName, attachmentDbName, new ProjectModerator(), - new ComponentDatabaseHandler(httpClient, dbName, attachmentDbName), - new PackageDatabaseHandler(httpClient, dbName, changeLogDbName, attachmentDbName), - new AttachmentDatabaseHandler(httpClient, dbName, attachmentDbName)); + public ProjectDatabaseHandler(Cloudant client, String dbName, String changeLogDbName, String attachmentDbName) throws MalformedURLException { + this(client, dbName, changeLogDbName, attachmentDbName, new ProjectModerator(), + new ComponentDatabaseHandler(client, dbName, attachmentDbName), + new PackageDatabaseHandler(client, dbName, changeLogDbName, attachmentDbName), + new AttachmentDatabaseHandler(client, dbName, attachmentDbName)); } @VisibleForTesting - public ProjectDatabaseHandler(Supplier httpClient, String dbName, String changeLogsDbName, String attachmentDbName, ProjectModerator moderator, + public ProjectDatabaseHandler(Cloudant client, String dbName, String changeLogsDbName, String attachmentDbName, ProjectModerator moderator, ComponentDatabaseHandler componentDatabaseHandler, PackageDatabaseHandler packageDatabaseHandler, AttachmentDatabaseHandler attachmentDatabaseHandler) throws MalformedURLException { - this(httpClient, dbName, attachmentDbName, moderator, componentDatabaseHandler, packageDatabaseHandler, attachmentDatabaseHandler); - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(httpClient, changeLogsDbName); + this(client, dbName, attachmentDbName, moderator, componentDatabaseHandler, packageDatabaseHandler, attachmentDatabaseHandler); + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, changeLogsDbName); this.dbHandlerUtil = new DatabaseHandlerUtil(db); } @VisibleForTesting - public ProjectDatabaseHandler(Supplier httpClient, String dbName, String attachmentDbName, ProjectModerator moderator, + public ProjectDatabaseHandler(Cloudant client, String dbName, String attachmentDbName, ProjectModerator moderator, ComponentDatabaseHandler componentDatabaseHandler, PackageDatabaseHandler packageDatabaseHandler, AttachmentDatabaseHandler attachmentDatabaseHandler) throws MalformedURLException { super(attachmentDatabaseHandler); - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(httpClient, dbName); + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories repository = new ProjectRepository(db); @@ -195,11 +198,11 @@ public ProjectDatabaseHandler(Supplier httpClient, String dbName this.moderator = moderator; // Create the attachment connector - attachmentConnector = new AttachmentConnector(httpClient, attachmentDbName, Duration.durationOf(30, TimeUnit.SECONDS)); + attachmentConnector = new AttachmentConnector(client, attachmentDbName, Duration.durationOf(30, TimeUnit.SECONDS)); this.componentDatabaseHandler = componentDatabaseHandler; this.packageDatabaseHandler = packageDatabaseHandler; - DatabaseConnectorCloudant dbChangelogs = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_CHANGE_LOGS); + DatabaseConnectorCloudant dbChangelogs = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_CHANGE_LOGS); this.dbHandlerUtil = new DatabaseHandlerUtil(dbChangelogs); } @@ -247,12 +250,19 @@ public AddDocumentRequestSummary createClearingRequest(ClearingRequest clearingR if (!(ProjectClearingState.CLOSED.equals(project.getClearingState()) || Visibility.PRIVATE.equals(project.getVisbility()))) { clearingRequest.setProjectBU(project.getBusinessUnit()); + Project projectWithInfo = fillClearingStateSummaryIncludingSubprojectsForSingleProject(project, user); + int initialOpenReleases = SW360Utils.getOpenReleaseCount(projectWithInfo.releaseClearingStateSummary); + ClearingRequestSize initialSize = SW360Utils.determineCRSize(initialOpenReleases); + clearingRequest.setClearingSize(initialSize); + log.info(initialOpenReleases + " open releases found for project: " + project.getId() + "and initial size is: " + initialSize); String crId = moderator.createClearingRequest(clearingRequest, user); if (CommonUtils.isNotNullEmptyOrWhitespace(crId)) { project.setClearingRequestId(crId); clearingRequest.setId(crId); updateProject(project, user); sendMailForNewClearing(project, projectUrl, clearingRequest, user); + //set requestSummary message that creation of CR was successful + requestSummary.setMessage("Clearing request created successfully"); return requestSummary.setRequestStatus(AddDocumentRequestStatus.SUCCESS).setId(project.getClearingRequestId()); } else { log.error("Failed to create clearing request for project: " + project.getId()); @@ -949,7 +959,7 @@ private void deleteUsedReleaseRelations(String projectId) throws SW360Exception // HELPER FUNCTIONS // ////////////////////// - public List getLinkedProjects(Project project, boolean deep, User user) { + public List getLinkedProjects(Project project, boolean deep, User user) throws SW360Exception { Deque visitedIds = new ArrayDeque<>(); Map fakeRelations = new HashMap<>(); @@ -958,7 +968,7 @@ public List getLinkedProjects(Project project, boolean deep, User u return out; } - public List getLinkedProjects(Map relations, boolean depth, User user) { + public List getLinkedProjects(Map relations, boolean depth, User user) throws SW360Exception { List out; Deque visitedIds = new ArrayDeque<>(); @@ -968,7 +978,7 @@ public List getLinkedProjects(Map iterateProjectRelationShips(Map relations, - String parentNodeId, Deque visitedIds, int maxDepth, User user) { + String parentNodeId, Deque visitedIds, int maxDepth, User user) throws SW360Exception { List out = new ArrayList<>(); for (Map.Entry entry : relations.entrySet()) { Optional projectLinkOptional; @@ -986,7 +996,7 @@ private List iterateProjectRelationShips(Map createProjectLink(String id, ProjectProjectRelationship projectProjectRelationship, String parentNodeId, - Deque visitedIds, int maxDepth, User user) { + Deque visitedIds, int maxDepth, User user) throws SW360Exception { ProjectLink projectLink = null; if (!visitedIds.contains(id) && (maxDepth < 0 || visitedIds.size() < maxDepth)) { visitedIds.push(id); @@ -1133,7 +1143,12 @@ public List getProjectVulnerabilityRatingByProjectId public RequestStatus updateProjectVulnerabilityRating(ProjectVulnerabilityRating link) { if( ! link.isSetId()){ link.setId(SW360Constants.PROJECT_VULNERABILITY_RATING_ID_PREFIX + link.getProjectId()); - pvrRepository.add(link); + try { + pvrRepository.add(link); + } catch (SW360Exception e) { + log.error("Unable to update project vulnerability rating.", e); + return RequestStatus.FAILURE; + } } else { pvrRepository.update(link); } @@ -1836,7 +1851,7 @@ public RequestSummary importBomFromAttachmentContent(User user, String attachmen try (final InputStream inputStream = attachmentStreamConnector.unsafeGetAttachmentStream(attachmentContent)) { final SpdxBOMImporterSink spdxBOMImporterSink = new SpdxBOMImporterSink(user, this, componentDatabaseHandler); final SpdxBOMImporter spdxBOMImporter = new SpdxBOMImporter(spdxBOMImporterSink); - return spdxBOMImporter.importSpdxBOMAsProject(inputStream, attachmentContent); + return spdxBOMImporter.importSpdxBOMAsProject(inputStream, attachmentContent, user); } } catch (IOException e) { throw new SW360Exception(e.getMessage()); @@ -1844,6 +1859,10 @@ public RequestSummary importBomFromAttachmentContent(User user, String attachmen } public RequestSummary importCycloneDxFromAttachmentContent(User user, String attachmentContentId, String projectId) throws SW360Exception { + return importCycloneDxFromAttachmentContent(user, attachmentContentId, projectId, false); + } + + public RequestSummary importCycloneDxFromAttachmentContent(User user, String attachmentContentId, String projectId, boolean doNotReplacePackageAndRelease) throws SW360Exception { final AttachmentContent attachmentContent = attachmentConnector.getAttachmentContent(attachmentContentId); final Duration timeout = Duration.durationOf(30, TimeUnit.SECONDS); try { @@ -1852,7 +1871,7 @@ public RequestSummary importCycloneDxFromAttachmentContent(User user, String att .unsafeGetAttachmentStream(attachmentContent)) { final CycloneDxBOMImporter cycloneDxBOMImporter = new CycloneDxBOMImporter(this, componentDatabaseHandler, packageDatabaseHandler, attachmentConnector, user); - return cycloneDxBOMImporter.importFromBOM(inputStream, attachmentContent, projectId, user); + return cycloneDxBOMImporter.importFromBOM(inputStream, attachmentContent, projectId, user, doNotReplacePackageAndRelease); } } catch (IOException e) { log.error("Error while importing / parsing CycloneDX SBOM! ", e); @@ -2208,9 +2227,12 @@ protected List convertReleaseNodesToReleaseLinksParallel(List { try { - return fut.get(); + ReleaseLink releaseLink = fut.get(); + releaseLink.setIndex(index.getAndIncrement()); + return releaseLink; } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Error when convert releaseLink: " + e.getMessage()); } @@ -2225,60 +2247,77 @@ public List> getClearingStateForDependencyNetworkListView(St projectOrigin.put(projectId, SW360Utils.printName(projectById)); LinkedHashMap releaseOrigin = new LinkedHashMap<>(); Map linkedProjects = projectById.getLinkedProjects(); - + projectExecutor = Executors.newFixedThreadPool(5); String releaseNetwork = projectById.getReleaseRelationNetwork(); List listReleaseLinkJson; - try { - listReleaseLinkJson = mapper.readValue(releaseNetwork, new TypeReference>() { - }); - flattenLinkedReleaseOfRelease(listReleaseLinkJson, projectOrigin, releaseOrigin, clearingStatusList, user, isInaccessibleLinkMasked); - } catch (JsonProcessingException e) { - log.error("JsonProcessingException: " + e); + if (releaseNetwork != null) { + try { + listReleaseLinkJson = mapper.readValue(releaseNetwork, new TypeReference>() { + }); + flattenLinkedReleaseOfRelease(listReleaseLinkJson, projectOrigin, releaseOrigin, clearingStatusList, user, isInaccessibleLinkMasked); + } catch (JsonProcessingException e) { + log.error("JsonProcessingException: " + e); + } } if (linkedProjects != null && !linkedProjects.isEmpty()) { - flattenDependencyNetworkForLinkedProject(linkedProjects, projectOrigin, releaseOrigin, clearingStatusList, - user, isInaccessibleLinkMasked); + try { + flattenDependencyNetworkForLinkedProject(linkedProjects, projectOrigin, releaseOrigin, clearingStatusList, + user, isInaccessibleLinkMasked); + } catch (WrappedException.WrappedSW360Exception exception) { + throw new SW360Exception(exception.getCause()); + } } - + projectExecutor.shutdown(); return clearingStatusList; } private void flattenLinkedReleaseOfRelease(List listReleaseLinkJson, LinkedHashMap projectOrigin, LinkedHashMap releaseOrigin, List> clearingStatusList, User user, boolean isInaccessibleLinkMasked) { - listReleaseLinkJson.forEach(rl -> wrapTException(() -> { - String relation = ThriftEnumUtils.enumToString(ReleaseRelationship.valueOf(rl.getReleaseRelationship())); - String projectMailLineState = ThriftEnumUtils.enumToString(MainlineState.valueOf(rl.getMainlineState())); - String comment = rl.getComment(); - String releaseId = rl.getReleaseId(); - if (releaseOrigin.containsKey(releaseId)) - return; - Release rel = componentDatabaseHandler.getRelease(releaseId, user); - List listLinkedRelease = rl.getReleaseLink(); - if (!isInaccessibleLinkMasked || componentDatabaseHandler.isReleaseActionAllowed(rel, user, RequestedAction.READ)) { - releaseOrigin.put(releaseId, SW360Utils.printName(rel)); - Map row = createReleaseCSRow(relation, projectMailLineState, rel, clearingStatusList, user, comment); - if (CommonUtils.isNotEmpty(listLinkedRelease)) { - flattenLinkedReleaseOfRelease(listLinkedRelease, projectOrigin, releaseOrigin, - clearingStatusList, user, isInaccessibleLinkMasked); + final List> callables = new ArrayList<>(); + listReleaseLinkJson.forEach(rl -> { + Callable callableTask = () -> { + String relation = ThriftEnumUtils.enumToString(ReleaseRelationship.valueOf(rl.getReleaseRelationship())); + String projectMailLineState = ThriftEnumUtils.enumToString(MainlineState.valueOf(rl.getMainlineState())); + String comment = rl.getComment(); + String releaseId = rl.getReleaseId(); + LinkedHashMap cpReleaseOrigin = new LinkedHashMap<>(releaseOrigin); + if (cpReleaseOrigin.containsKey(releaseId)) + return null; + Release rel = componentDatabaseHandler.getRelease(releaseId, user); + List listLinkedRelease = rl.getReleaseLink(); + if (!isInaccessibleLinkMasked || componentDatabaseHandler.isReleaseActionAllowed(rel, user, RequestedAction.READ)) { + cpReleaseOrigin.put(releaseId, SW360Utils.printName(rel)); + Map row = createReleaseCSRow(relation, projectMailLineState, rel, clearingStatusList, user, comment); + if (CommonUtils.isNotEmpty(listLinkedRelease)) { + flattenLinkedReleaseOfRelease(listLinkedRelease, projectOrigin, cpReleaseOrigin, + clearingStatusList, user, isInaccessibleLinkMasked); + } + cpReleaseOrigin.remove(releaseId); + row.put("projectOrigin", String.join(" -> ", projectOrigin.values())); + row.put("releaseOrigin", String.join(" -> ", releaseOrigin.values())); + } else { + Map row = createInaccessibleReleaseCSRow(clearingStatusList); + row.put("projectOrigin", ""); + row.put("releaseOrigin", ""); } - releaseOrigin.remove(releaseId); - row.put("projectOrigin", String.join(" -> ", projectOrigin.values())); - row.put("releaseOrigin", String.join(" -> ", releaseOrigin.values())); - } else { - Map row = createInaccessibleReleaseCSRow(clearingStatusList); - row.put("projectOrigin", ""); - row.put("releaseOrigin", ""); - } - })); + return null; + }; + callables.add(callableTask); + }); + try { + projectExecutor.invokeAll(callables); + } catch (InterruptedException e) { + log.error(e.getMessage()); + } } private void flattenDependencyNetworkForLinkedProject(Map linkedProjects, LinkedHashMap projectOrigin, LinkedHashMap releaseOrigin, - List> clearingStatusList, User user, boolean isInaccessibleLinkMasked) { + List> clearingStatusList, User user, boolean isInaccessibleLinkMasked) throws WrappedException.WrappedSW360Exception { - linkedProjects.entrySet().stream().forEach(lp -> wrapTException(() -> { + linkedProjects.entrySet().stream().forEach(lp -> wrapSW360Exception(() -> { String projId = lp.getKey(); String relation = ThriftEnumUtils.enumToString(lp.getValue().getProjectRelationship()); if (projectOrigin.containsKey(projId)) @@ -2290,17 +2329,23 @@ private void flattenDependencyNetworkForLinkedProject(Map listReleaseLinkJson; - try { - listReleaseLinkJson = mapper.readValue(releaseNetwork, new TypeReference>() { - }); - flattenLinkedReleaseOfRelease(listReleaseLinkJson, projectOrigin, releaseOrigin, clearingStatusList, user, isInaccessibleLinkMasked); - } catch (JsonProcessingException e) { - log.error("JsonProcessingException: " + e); + if (releaseNetwork != null) { + try { + listReleaseLinkJson = mapper.readValue(releaseNetwork, new TypeReference>() { + }); + flattenLinkedReleaseOfRelease(listReleaseLinkJson, projectOrigin, releaseOrigin, clearingStatusList, user, isInaccessibleLinkMasked); + } catch (JsonProcessingException e) { + log.error("JsonProcessingException: " + e); + } } if (subprojects != null && !subprojects.isEmpty()) { - flattenClearingStatusForLinkedProject(subprojects, projectOrigin, releaseOrigin, clearingStatusList, - user, isInaccessibleLinkMasked); + try { + flattenDependencyNetworkForLinkedProject(subprojects, projectOrigin, releaseOrigin, clearingStatusList, + user, isInaccessibleLinkMasked); + } catch (WrappedException.WrappedSW360Exception exception) { + throw new SW360Exception(exception.getCause()); + } } projectOrigin.remove(projId); @@ -2309,11 +2354,11 @@ private void flattenDependencyNetworkForLinkedProject(Map createProjectLinkForDependencyNetwork(String id, ProjectProjectRelationship projectProjectRelationship, String parentNodeId, - Deque visitedIds, int maxDepth, User user, boolean withRelease, boolean withAllReleases) { + Deque visitedIds, int maxDepth, User user, boolean withRelease, boolean withAllReleases) throws SW360Exception { ProjectLink projectLink = null; if (!visitedIds.contains(id) && (maxDepth < 0 || visitedIds.size() < maxDepth)) { visitedIds.push(id); - Project project = repository.get(id); + Project project = getProjectById(id, user); if (project != null && (user == null || !makePermission(project, user).isActionAllowed(RequestedAction.READ))) { log.error("User " + (user == null ? "" : user.getEmail()) @@ -2331,7 +2376,7 @@ private Optional createProjectLinkForDependencyNetwork(String id, P releaseNodes = mapper.readValue(releaseNetwork, new TypeReference<>() { }); if (withAllReleases == WITH_ROOT_RELEASES_ONLY) { - linkedReleases = convertReleaseNodesToReleaseLinksSequentially(releaseNodes, id, user, "", 0); + linkedReleases = convertReleaseNodesToReleaseLinksParallel(releaseNodes, id, user); } else { List flattenedNetwork = new ArrayList<>(); Set visitedNodeIds = new HashSet<>(); @@ -2342,8 +2387,6 @@ private Optional createProjectLinkForDependencyNetwork(String id, P } } catch (JsonProcessingException e) { log.error("JsonProcessingException: " + e); - } catch (TException e) { - log.error(e.getMessage()); } projectLink.setLinkedReleases(nullToEmptyList(linkedReleases)); } @@ -2377,7 +2420,7 @@ private Optional createProjectLinkForDependencyNetwork(String id, P return Optional.ofNullable(projectLink); } - public List getLinkedProjectsWithoutReleases(Map relations, boolean depth, User user) { + public List getLinkedProjectsWithoutReleases(Map relations, boolean depth, User user) throws SW360Exception { List out; Deque visitedIds = new ArrayDeque<>(); @@ -2388,7 +2431,7 @@ public List getLinkedProjectsWithoutReleases(Map iterateProjectRelationShips(Map relations, String parentNodeId, Deque visitedIds, int maxDepth, - User user, boolean withRelease) { + User user, boolean withRelease) throws SW360Exception { List out = new ArrayList<>(); for (Map.Entry entry : relations.entrySet()) { Optional projectLinkOptional; @@ -2405,7 +2448,7 @@ private List iterateProjectRelationShips(Map getLinkedProjectsWithoutReleases(Project project, boolean deep, User user) { + public List getLinkedProjectsWithoutReleases(Project project, boolean deep, User user) throws SW360Exception { Deque visitedIds = new ArrayDeque<>(); Map fakeRelations = new HashMap<>(); @@ -2414,7 +2457,7 @@ public List getLinkedProjectsWithoutReleases(Project project, boole return out; } - public List getLinkedProjectsWithAllReleases(Project project, boolean deep, User user) { + public List getLinkedProjectsWithAllReleases(Project project, boolean deep, User user) throws SW360Exception { Deque visitedIds = new ArrayDeque<>(); Map fakeRelations = new HashMap<>(); @@ -2423,7 +2466,7 @@ public List getLinkedProjectsWithAllReleases(Project project, boole } private List iterateProjectRelationShipsWithAllReleases(Map relations, - String parentNodeId, Deque visitedIds, int maxDepth, User user) { + String parentNodeId, Deque visitedIds, int maxDepth, User user) throws SW360Exception { List out = new ArrayList<>(); for (Map.Entry entry : relations.entrySet()) { Optional projectLinkOptional = createProjectLinkForDependencyNetwork(entry.getKey(), entry.getValue(), @@ -2463,38 +2506,102 @@ private List flattenNodeNetwork(ReleaseNode node, Set visit protected ReleaseLink convertReleaseNodeToReleaseLink(ReleaseNode releaseNode, String projectId, User user, String parentId, int layer) throws TException { Release releaseById = componentDatabaseHandler.getRelease(releaseNode.getReleaseId(), user); + ReleaseLink releaseLink = new ReleaseLink(); + boolean isAccessible = componentDatabaseHandler.isReleaseActionAllowed(releaseById, user, RequestedAction.READ); releaseLink.setId(releaseNode.getReleaseId()); - releaseLink.setReleaseRelationship(ReleaseRelationship.valueOf(releaseNode.getReleaseRelationship())); - releaseLink.setMainlineState(MainlineState.valueOf(releaseNode.getMainlineState())); - releaseLink.setComment(releaseNode.getComment()); + releaseLink.setAccessible(isAccessible); + releaseLink.setName(isAccessible ? releaseById.getName() : ""); + releaseLink.setVersion(isAccessible ? releaseById.getVersion() : ""); + releaseLink.setLayer(layer); + releaseLink.setLongName(isAccessible ? SW360Utils.printFullname(releaseById) : "Restricted release"); releaseLink.setHasSubreleases(!releaseNode.getReleaseLink().isEmpty()); - releaseLink.setName(releaseById.getName()); - releaseLink.setVersion(releaseById.getVersion()); - releaseLink.setLongName(SW360Utils.printFullname(releaseById)); - releaseLink.setClearingState(releaseById.getClearingState()); - releaseLink.setLicenseIds(releaseById.getMainLicenseIds()); - releaseLink.setOtherLicenseIds(releaseById.getOtherLicenseIds()); - releaseLink.setAccessible(componentDatabaseHandler.isReleaseActionAllowed(releaseById, user, RequestedAction.READ)); releaseLink.setNodeId(releaseById.getId() + "_" + UUID.randomUUID()); releaseLink.setParentNodeId(parentId); - releaseLink.setLayer(layer); releaseLink.setProjectId(projectId); - releaseLink.setReleaseMainLineState(releaseById.getMainlineState()); - releaseLink.setAttachments(releaseById.getAttachments() != null ? Lists.newArrayList(releaseById.getAttachments()) : Collections.emptyList()); + releaseLink.setVendor((isAccessible && releaseById.getVendor() != null) ? releaseById.getVendor().getFullname() : ""); + + if (isAccessible) { + releaseLink.setReleaseRelationship(ReleaseRelationship.valueOf(releaseNode.getReleaseRelationship())); + releaseLink.setMainlineState(MainlineState.valueOf(releaseNode.getMainlineState())); + releaseLink.setComment(releaseNode.getComment()); + releaseLink.setClearingState(releaseById.getClearingState()); + releaseLink.setLicenseIds(releaseById.getMainLicenseIds()); + releaseLink.setOtherLicenseIds(releaseById.getOtherLicenseIds()); + releaseLink.setReleaseMainLineState(releaseById.getMainlineState()); + releaseLink.setAttachments(releaseById.getAttachments() != null ? Lists.newArrayList(releaseById.getAttachments()) : Collections.emptyList()); + if (releaseById.getComponentType() != null) { + releaseLink.setComponentType(releaseById.getComponentType()); + } else { + Component componentById = componentDatabaseHandler.getComponent(releaseById.getComponentId(), user); + releaseLink.setComponentType(componentById.getComponentType()); + } + } - if (releaseById.getVendor() != null) { - releaseLink.setVendor(releaseById.getVendor().getFullname()); - } else { - releaseLink.setVendor(""); + return releaseLink; + } + + public List getReleaseLinksOfProjectNetWorkByIndexPath(List indexPath, String projectId, User user) throws SW360Exception { + Project project = getProjectById(projectId, user); + + if (project == null) { + throw new SW360Exception("Project not found: " + projectId).setErrorCode(404); } - if (releaseById.getComponentType() != null) { - releaseLink.setComponentType(releaseById.getComponentType()); - } else { - Component componentById = componentDatabaseHandler.getComponent(releaseById.getComponentId(), user); - releaseLink.setComponentType(componentById.getComponentType()); + String releaseNetwork = project.getReleaseRelationNetwork(); + List linkedReleases = new ArrayList<>(); + try { + List releaseNodes = mapper.readValue(releaseNetwork, new TypeReference>() { + }); + ReleaseNode previousNode = releaseNodes.get(Integer.parseInt(indexPath.get(0))); + for (int i = 1; i < indexPath.size(); i++){ + previousNode = previousNode.getReleaseLink().get(Integer.parseInt(indexPath.get(i))); + } + linkedReleases = convertReleaseNodesToReleaseLinksParallel(previousNode.getReleaseLink(), projectId, user); + } catch (JsonProcessingException e) { + log.error("JsonProcessingException: " + e); + } catch (IndexOutOfBoundsException exception) { + throw new SW360Exception("Index path is incorrect").setErrorCode(400); } - return releaseLink; + + return linkedReleases; + } + + public List getLinkedReleasesInDependencyNetworkOfProject(String projectId, User sw360User) throws SW360Exception { + final Project projectById = getProjectById(projectId, sw360User); + if (projectById.getReleaseRelationNetwork() == null) { + return new ArrayList<>(); + } + List releaseNodes; + try { + releaseNodes = mapper.readValue(projectById.getReleaseRelationNetwork(), new TypeReference<>() { + }); + } catch (JsonProcessingException e) { + log.error("Error while parsing JSON data"); + return new ArrayList<>(); + } + + return releaseNodes.stream() + .map(releaseNode -> wrapSW360Exception(() -> createReleaseNodeWithDetail(releaseNode, sw360User))) + .collect(Collectors.toList()); + } + + public ReleaseNode createReleaseNodeWithDetail(ReleaseNode releaseNode, User sw360User) throws SW360Exception { + Release releaseById = componentDatabaseHandler.getRelease(releaseNode.getReleaseId(), sw360User); + boolean isActionAllowed = componentDatabaseHandler.isReleaseActionAllowed(releaseById, sw360User, RequestedAction.READ); + ReleaseNode detailReleaseNode = new ReleaseNode(); + detailReleaseNode.setReleaseId(releaseNode.getReleaseId()); + detailReleaseNode.setReleaseRelationship(releaseNode.getReleaseRelationship()); + detailReleaseNode.setMainlineState(releaseNode.getMainlineState()); + detailReleaseNode.setComment(releaseNode.getComment()); + detailReleaseNode.setReleaseVersion(isActionAllowed ? releaseById.getVersion() : ""); + detailReleaseNode.setReleaseName(isActionAllowed ? releaseById.getName() : ""); + detailReleaseNode.setComponentId(isActionAllowed ? releaseById.getComponentId() : ""); + detailReleaseNode.setReleaseLink( + releaseNode.getReleaseLink().stream() + .map(node -> wrapSW360Exception(() -> createReleaseNodeWithDetail(node, sw360User))) + .collect(Collectors.toList()) + ); + return detailReleaseNode; } } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java similarity index 81% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java index c109dd393a..6167e70f73 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectRepository.java @@ -10,7 +10,6 @@ */ package org.eclipse.sw360.datahandler.db; -import org.apache.thrift.TException; import org.eclipse.sw360.components.summary.ProjectSummary; import org.eclipse.sw360.components.summary.SummaryType; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; @@ -20,7 +19,6 @@ import org.eclipse.sw360.datahandler.permissions.PermissionUtils; import org.eclipse.sw360.datahandler.permissions.ProjectPermissions; import org.eclipse.sw360.datahandler.thrift.PaginationData; -import org.eclipse.sw360.datahandler.thrift.ThriftClients; import org.eclipse.sw360.datahandler.thrift.projects.Project; import org.eclipse.sw360.datahandler.thrift.projects.ProjectData; import org.eclipse.sw360.datahandler.thrift.projects.ProjectService; @@ -28,27 +26,21 @@ import org.eclipse.sw360.datahandler.thrift.users.UserGroup; import org.jetbrains.annotations.NotNull; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.query.PredicateExpression; -import com.cloudant.client.api.query.PredicatedOperation; -import com.cloudant.client.api.query.QueryBuilder; -import com.cloudant.client.api.query.QueryResult; -import com.cloudant.client.api.query.Selector; -import com.cloudant.client.api.query.Sort; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.ViewRequest; -import com.cloudant.client.api.views.ViewRequestBuilder; -import com.cloudant.client.api.views.ViewResponse; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostFindOptions; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResult; import com.google.common.base.Joiner; import com.google.common.collect.Maps; import java.util.*; import java.util.stream.Collectors; -import static com.cloudant.client.api.query.Expression.eq; -import static com.cloudant.client.api.query.Operation.and; -import static com.cloudant.client.api.query.Operation.or; import static com.google.common.base.Strings.isNullOrEmpty; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.elemMatch; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.eq; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.and; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.or; import static org.eclipse.sw360.datahandler.common.SW360Utils.getBUFromOrganisation; /** @@ -266,7 +258,7 @@ public class ProjectRepository extends SummaryAwareRepository { public ProjectRepository(DatabaseConnectorCloudant db) { super(Project.class, db, new ProjectSummary()); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("byname", createMapReduce(BY_NAME_VIEW, null)); views.put("bygroup", createMapReduce(BY_GROUP_VIEW, null)); views.put("bytag", createMapReduce(BY_TAG_VIEW, null)); @@ -396,115 +388,94 @@ public Map> getAccessibleProjectsSummary(User user List projects = new ArrayList<>(); Map> result = Maps.newHashMap(); - String query = null; - final Selector typeSelector = eq("type", "project"); - final Selector private_visibility_Selector = eq("visbility", "PRIVATE"); - final Selector createdBySelector = eq("createdBy", requestingUserEmail); - final Selector getAllPrivateProjects = and(private_visibility_Selector, createdBySelector); - final Selector everyone_visibility_Selector = eq("visbility", "EVERYONE"); - - final Selector isAProjectResponsible = eq("projectResponsible", requestingUserEmail); - final Selector isALeadArchitect = eq("leadArchitect", requestingUserEmail); - final Selector isAModerator = PredicatedOperation.elemMatch("moderators", - PredicateExpression.eq(requestingUserEmail)); - final Selector isAContributor = PredicatedOperation.elemMatch("contributors", - PredicateExpression.eq(requestingUserEmail)); - final Selector meAndModorator_visibility_Selector = eq("visbility", "ME_AND_MODERATORS"); - final Selector isUserBelongToMeAndModerator = and(meAndModorator_visibility_Selector, - or(createdBySelector, isAProjectResponsible, isALeadArchitect, isAModerator, isAContributor)); - - final Selector buAndModorator_visibility_Selector = eq("visbility", "BUISNESSUNIT_AND_MODERATORS"); - final Selector userBuSelector = eq("businessUnit", userBU); + PostFindOptions query = null; + final Map typeSelector = eq("type", "project"); + final Map private_visibility_Selector = eq("visbility", "PRIVATE"); + final Map createdBySelector = eq("createdBy", requestingUserEmail); + final Map getAllPrivateProjects = and(List.of(private_visibility_Selector, createdBySelector)); + final Map everyone_visibility_Selector = eq("visbility", "EVERYONE"); + + final Map isAProjectResponsible = eq("projectResponsible", requestingUserEmail); + final Map isALeadArchitect = eq("leadArchitect", requestingUserEmail); + final Map isAModerator = elemMatch("moderators", requestingUserEmail); + final Map isAContributor = elemMatch("contributors", requestingUserEmail); + final Map meAndModorator_visibility_Selector = eq("visbility", "ME_AND_MODERATORS"); + final Map isUserBelongToMeAndModerator = and(List.of(meAndModorator_visibility_Selector, + or(List.of(createdBySelector, isAProjectResponsible, isALeadArchitect, isAModerator, isAContributor)))); + + final Map buAndModorator_visibility_Selector = eq("visbility", "BUISNESSUNIT_AND_MODERATORS"); + final Map userBuSelector = eq("businessUnit", userBU); boolean isAdmin = PermissionUtils.isAdmin(user); boolean isClearingAdmin = PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user); - Selector isUserBelongToBuAndModerator = null; + Map isUserBelongToBuAndModerator; - Selector[] buSelectors = null; + List> buSelectors = new ArrayList<>(); Map> secondaryDepartmentsAndRoles = user.getSecondaryDepartmentsAndRoles(); if (!CommonUtils.isNullOrEmptyMap(secondaryDepartmentsAndRoles)) { Set secondaryUgs = secondaryDepartmentsAndRoles.keySet(); Set secondaryBus = secondaryUgs.stream().map(SW360Utils::getBUFromOrganisation) .collect(Collectors.toSet()); - buSelectors = new Selector[secondaryBus.size() + 2]; - int index = 0; for (String secondaryBU : secondaryBus) { - Selector buselector = eq("businessUnit", secondaryBU); - buSelectors[index] = buselector; - index++; + buSelectors.add(eq("businessUnit", secondaryBU)); } - } else { - buSelectors = new Selector[2]; } - buSelectors[buSelectors.length - 2] = isUserBelongToMeAndModerator; - buSelectors[buSelectors.length - 1] = userBuSelector; - isUserBelongToBuAndModerator = and(buAndModorator_visibility_Selector, or(buSelectors)); + buSelectors.add(isUserBelongToMeAndModerator); + buSelectors.add(userBuSelector); + isUserBelongToBuAndModerator = and(List.of(buAndModorator_visibility_Selector, or(buSelectors))); - Selector finalSelector = null; + Map finalSelector; if (PermissionUtils.IS_ADMIN_PRIVATE_ACCESS_ENABLED && isAdmin) { finalSelector = typeSelector; } else { if (isClearingAdmin) { - finalSelector = and(typeSelector, or(getAllPrivateProjects, everyone_visibility_Selector, - isUserBelongToMeAndModerator, buAndModorator_visibility_Selector)); + finalSelector = and(List.of(typeSelector, or(List.of(getAllPrivateProjects, everyone_visibility_Selector, + isUserBelongToMeAndModerator, buAndModorator_visibility_Selector)))); } else { - finalSelector = and(typeSelector, or(getAllPrivateProjects, everyone_visibility_Selector, - isUserBelongToMeAndModerator, isUserBelongToBuAndModerator)); + finalSelector = and(List.of(typeSelector, or(List.of(getAllPrivateProjects, everyone_visibility_Selector, + isUserBelongToMeAndModerator, isUserBelongToBuAndModerator)))); } } - QueryBuilder qb = new QueryBuilder(finalSelector); + PostFindOptions.Builder qb = getConnector().getQueryBuilder() + .selector(finalSelector); if (rowsPerPage != -1) { qb.limit(rowsPerPage); } qb.skip(pageData.getDisplayStart()); - ViewRequestBuilder queryView = null; + PostViewOptions.Builder queryView = null; switch (sortColumnNo) { - case 0: - qb = qb.useIndex("byName"); - qb = ascending ? qb.sort(Sort.asc("name")) : qb.sort(Sort.desc("name")); - query = qb.build(); - break; - case 1: - qb = qb.useIndex("byDesc"); - qb = ascending ? qb.sort(Sort.asc("description")) : qb.sort(Sort.desc("description")); - query = qb.build(); - break; - case 2: - qb = qb.useIndex("byProjectResponsible"); - qb = ascending ? qb.sort(Sort.asc("projectResponsible")) : qb.sort(Sort.desc("projectResponsible")); - query = qb.build(); - break; - case 3: - case 4: - queryView = getConnector().createQuery(Project.class, "byState"); - break; - default: - break; + case 0: + qb.useIndex(Collections.singletonList("byName")) + .addSort(Collections.singletonMap("name", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 1: + qb.useIndex(Collections.singletonList("byDesc")) + .addSort(Collections.singletonMap("description", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 2: + qb.useIndex(Collections.singletonList("byProjectResponsible")) + .addSort(Collections.singletonMap("projectResponsible", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 3: + case 4: + queryView = getConnector().getPostViewQueryBuilder(Project.class, "byState"); + break; + default: + break; } try { if (queryView != null) { - ViewRequest request = queryView.newPaginatedRequest(Key.Type.STRING, Object.class) - .rowsPerPage(rowsPerPage).descending(!ascending).includeDocs(true).build(); - ViewResponse response = request.getResponse(); - response = request.getResponse(); - int pageNo = pageData.getDisplayStart() / rowsPerPage; - List proj = new ArrayList(); - int count = pageNo == 0 ? rowsPerPage : (pageNo + 1) * rowsPerPage; - while (projects.size() < count) { - if (response != null) { - proj = response.getDocsAs(Project.class); - } - proj = proj.stream().filter(ProjectPermissions.isVisible(user)).collect(Collectors.toList()); - projects.addAll(proj.stream().collect(Collectors.toList())); - response = response.nextPage(); - if (response == null) { - break; - } + PostViewOptions request = queryView.limit(rowsPerPage).skip(pageData.getDisplayStart()) + .descending(!ascending).includeDocs(true).build(); + ViewResult response = getConnector().getPostViewQueryResponse(request); + if (response != null) { + projects = getPojoFromViewResponse(response); } - projects = projects.stream().skip(pageData.getDisplayStart()).limit(rowsPerPage).collect(Collectors.toList()); } else { - QueryResult queryResult = getConnector().getQueryResult(query, Project.class); - projects = queryResult.getDocs(); + projects = getConnector().getQueryResult(query, Project.class); } } catch (Exception e) { log.error("Error getting projects", e); diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectSearchHandler.java new file mode 100644 index 0000000000..2e75d3926d --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectSearchHandler.java @@ -0,0 +1,137 @@ +/* + * Copyright Siemens AG, 2013-2015. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.common.DatabaseSettings; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.projects.Project; +import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.eclipse.sw360.common.utils.SearchUtils.OBJ_ARRAY_TO_STRING_INDEX; +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class ProjectSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("projects", + new NouveauIndexFunction( + "function(doc) {" + + OBJ_ARRAY_TO_STRING_INDEX + + " if(!doc.type || doc.type != 'project') return;" + + " if(doc.businessUnit !== undefined && doc.businessUnit != null && doc.businessUnit.length >0) {" + + " index('text', 'businessUnit', doc.businessUnit, {'store': true});" + + " }" + + " if(doc.projectType !== undefined && doc.projectType != null && doc.projectType.length >0) {" + + " index('text', 'projectType', doc.projectType, {'store': true});" + + " }" + + " if(doc.projectResponsible !== undefined && doc.projectResponsible != null && doc.projectResponsible.length >0) {" + + " index('text', 'projectResponsible', doc.projectResponsible, {'store': true});" + + " }" + + " if(doc.name !== undefined && doc.name != null && doc.name.length >0) {" + + " index('text', 'name', doc.name, {'store': true});" + + " }" + + " if(doc.version !== undefined && doc.version != null && doc.version.length >0) {" + + " index('string', 'version', doc.version, {'store': true});" + + " }" + + " if(doc.state !== undefined && doc.state != null && doc.state.length >0) {" + + " index('text', 'state', doc.state, {'store': true});" + + " }" + + " if(doc.clearingState) {" + + " index('text', 'clearingState', doc.clearingState, {'store': true});" + + " }" + + " if(doc.tag !== undefined && doc.tag != null && doc.tag.length >0) {" + + " index('text', 'tag', doc.tag, {'store': true});" + + " }" + + " arrayToStringIndex(doc.additionalData, 'additionalData');" + + " if(doc.releaseRelationNetwork !== undefined && doc.releaseRelationNetwork != null && doc.releaseRelationNetwork.length > 0) {" + + " index('text', 'releaseRelationNetwork', doc.releaseRelationNetwork, {'store': true});" + + " }" + + "}") + .setFieldAnalyzer( + Map.of("version", "keyword") + ) + ); + + + private final NouveauLuceneAwareDatabaseConnector connector; + + public ProjectSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.setResultLimit(DatabaseSettings.LUCENE_SEARCH_LIMIT); + connector.addDesignDoc(searchView); + } + + public List search(String text, final Map> subQueryRestrictions, User user) { + return connector.searchProjectViewWithRestrictionsAndFilter(luceneSearchView.getIndexName(), text, + subQueryRestrictions, user); + } + + public List search(String searchText) { + return connector.searchView(Project.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } + + public List search(String text, final Map> subQueryRestrictions) { + return connector.searchViewWithRestrictions(Project.class, luceneSearchView.getIndexName(), + text, subQueryRestrictions); + } + + public Set searchByReleaseId(String id, User user) { + return searchByReleaseIds(Collections.singleton(id), user); + } + + public Set searchByReleaseIds(Set ids, User user) { + Map> filterMap = getFilterMapForSetReleaseIds(ids); + List projectsByReleaseIds; + if (user != null) { + projectsByReleaseIds = connector.searchProjectViewWithRestrictionsAndFilter(luceneSearchView.getIndexName(), + null, filterMap, user); + } else { + projectsByReleaseIds = connector.searchViewWithRestrictions(Project.class, luceneSearchView.getIndexName(), + null, filterMap); + } + return new HashSet<>(projectsByReleaseIds); + } + + private static Map> getFilterMapForSetReleaseIds(Set releaseIds) { + Map> filterMap = new HashMap<>(); + Set values = new HashSet<>(); + for(String releaseId : releaseIds) { + values.add("\"releaseId\":\"" + releaseId + "\""); + values.add("\"releaseId\": \"" + releaseId + "\""); + } + values = values.stream().map(NouveauLuceneAwareDatabaseConnector::prepareWildcardQuery).collect(Collectors.toSet()); + filterMap.put(Project._Fields.RELEASE_RELATION_NETWORK.getFieldName(), values); + return filterMap; + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java similarity index 94% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java index 629201caff..3029b2cbf1 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectVulnerabilityRatingRepository.java @@ -16,9 +16,8 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.vulnerabilities.ProjectVulnerabilityRating; -import org.ektorp.support.View; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; import java.util.HashMap; import java.util.List; @@ -59,7 +58,7 @@ public class ProjectVulnerabilityRatingRepository extends DatabaseRepositoryClou public ProjectVulnerabilityRatingRepository(DatabaseConnectorCloudant db) { super(db, ProjectVulnerabilityRating.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("projectVulnerabilityRating", createMapReduce(PROJECT_VULNERABILITY_LINK, null)); views.put("all", createMapReduce(ALL, null)); views.put("byReleaseId", createMapReduce(BYRELEASEID, null)); diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java similarity index 73% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java index 65e4b9bf1c..2a418d7777 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RelationsUsageRepository.java @@ -9,6 +9,7 @@ */ package org.eclipse.sw360.datahandler.db; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,10 +18,8 @@ import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; import org.eclipse.sw360.datahandler.thrift.projects.UsedReleaseRelations; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; /** * CRUD access for the RelationsUsageRepository class @@ -42,15 +41,15 @@ public class RelationsUsageRepository extends DatabaseRepositoryCloudantClient views = new HashMap(); + Map views = new HashMap<>(); views.put("byProjectId", createMapReduce(BY_PROJECT_ID, null)); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); } public List getUsedRelationsByProjectId(String projectId) { - ViewRequestBuilder viewQuery = getConnector().createQuery(UsedReleaseRelations.class, "byProjectId"); - UnpaginatedRequestBuilder req = viewQuery.newRequest(Key.Type.STRING, Object.class).includeDocs(true).reduce(false).keys(projectId); - return queryView(req); + PostViewOptions viewQuery = getConnector().getPostViewQueryBuilder(UsedReleaseRelations.class, "byProjectId") + .includeDocs(true).reduce(false).keys(Collections.singletonList(projectId)).build(); + return queryView(viewQuery); } } \ No newline at end of file diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java similarity index 83% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java index aee6803f4b..0a50317a29 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseRepository.java @@ -19,10 +19,9 @@ import org.eclipse.sw360.datahandler.thrift.PaginationData; import java.util.*; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.UnpaginatedRequestBuilder; -import com.cloudant.client.api.views.ViewRequestBuilder; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResult; import java.util.stream.Collectors; @@ -30,8 +29,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Lists; -import com.cloudant.client.api.views.ViewRequest; -import com.cloudant.client.api.views.ViewResponse; /** * CRUD access for the Release class @@ -169,7 +166,7 @@ public class ReleaseRepository extends SummaryAwareRepository { public ReleaseRepository(DatabaseConnectorCloudant db, VendorRepository vendorRepository) { super(Release.class, db, new ReleaseSummary(vendorRepository)); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("byname", createMapReduce(BY_NAME, null)); views.put("byCreatedOn", createMapReduce(BY_CREATED_ON, null)); @@ -214,10 +211,10 @@ public List getReleaseSummary() { } public List getRecentReleases() { - ViewRequestBuilder query = getConnector().createQuery(Release.class, "byCreatedOn"); // Get the 5 last documents - UnpaginatedRequestBuilder reqBuilder = query.newRequest(Key.Type.STRING, Object.class).limit(5).descending(true).includeDocs(false); - return makeSummary(SummaryType.SHORT, queryForIds(reqBuilder)); + PostViewOptions query = getConnector().getPostViewQueryBuilder(Release.class, "byCreatedOn") + .limit(5).descending(true).includeDocs(false).build(); + return makeSummary(SummaryType.SHORT, queryForIds(query)); } public List getSubscribedReleases(String email) { @@ -262,13 +259,10 @@ public List getReleasesFromVendorIds(Set ids) { } public Set getReleaseIdsFromVendorIds(Set ids) { - ViewRequestBuilder query = getConnector().createQuery(Release.class, "releaseIdsByVendorId"); - String[] arrayOfString = new String[ids.size()]; - int index = 0; - for (String str : ids) - arrayOfString[index++] = str; - UnpaginatedRequestBuilder reqBuild = query.newRequest(Key.Type.STRING, Object.class).keys(arrayOfString); - return queryForIds(reqBuild); + PostViewOptions query = getConnector().getPostViewQueryBuilder(Release.class, "releaseIdsByVendorId") + .keys(ids.stream().map(r -> (Object)r).toList()) + .build(); + return queryForIds(query); } public Set getReleasesByVendorId(String vendorId) { @@ -314,60 +308,55 @@ public Map> getAccessibleReleasesWithPagination(Us final boolean ascending = pageData.isAscending(); final int sortColumnNo = pageData.getSortColumnNumber(); - ViewRequestBuilder query; + PostViewOptions.Builder query; switch (sortColumnNo) { - case -1: - query = getConnector().createQuery(Release.class, "byCreatedOn"); - break; - case 0: - query = getConnector().createQuery(Release.class, "byStatus"); - break; - case 1: - query = getConnector().createQuery(Release.class, "byname"); - break; - case 2: - query = getConnector().createQuery(Release.class, "releaseByVersion"); - break; - case 3: - query = getConnector().createQuery(Release.class, "byCreatorGroup"); - break; - case 4: - query = getConnector().createQuery(Release.class, "byECCAssessorContactPerson"); - break; - case 5: - query = getConnector().createQuery(Release.class, "byECCAssessorGroup"); - break; - case 6: - query = getConnector().createQuery(Release.class, "byECCAssessmentDate"); - break; - default: - query = getConnector().createQuery(Release.class, "all"); - break; + case -1: + query = getConnector().getPostViewQueryBuilder(Release.class, "byCreatedOn"); + break; + case 0: + query = getConnector().getPostViewQueryBuilder(Release.class, "byStatus"); + break; + case 1: + query = getConnector().getPostViewQueryBuilder(Release.class, "byname"); + break; + case 2: + query = getConnector().getPostViewQueryBuilder(Release.class, "releaseByVersion"); + break; + case 3: + query = getConnector().getPostViewQueryBuilder(Release.class, "byCreatorGroup"); + break; + case 4: + query = getConnector().getPostViewQueryBuilder(Release.class, "byECCAssessorContactPerson"); + break; + case 5: + query = getConnector().getPostViewQueryBuilder(Release.class, "byECCAssessorGroup"); + break; + case 6: + query = getConnector().getPostViewQueryBuilder(Release.class, "byECCAssessmentDate"); + break; + default: + query = getConnector().getPostViewQueryBuilder(Release.class, "all"); + break; } - ViewRequest request = null; + PostViewOptions request = null; if (rowsPerPage == -1) { - request = query.newRequest(Key.Type.STRING, Object.class).descending(!ascending).includeDocs(true).build(); + request = query.descending(!ascending).includeDocs(true).build(); } else { - request = query.newPaginatedRequest(Key.Type.STRING, Object.class).rowsPerPage(rowsPerPage) + request = query.limit(rowsPerPage).skip(pageData.getDisplayStart()) .descending(!ascending).includeDocs(true).build(); } - ViewResponse response = null; try { - response = request.getResponse(); - int pageNo = pageData.getDisplayStart() / rowsPerPage; - int i = 1; - while (i <= pageNo) { - response = response.nextPage(); - i++; + ViewResult response = getConnector().getPostViewQueryResponse(request); + if (response != null) { + releases = getPojoFromViewResponse(response); + pageData.setTotalRowCount(response.getTotalRows()); } - releases = response.getDocsAs(Release.class); } catch (Exception e) { log.error("Error getting recent releases", e); } releases = makeSummaryWithPermissionsFromFullDocs(SummaryType.SUMMARY, releases, user); - pageData.setTotalRowCount(response.getTotalRowCount()); result.put(pageData, releases); return result; } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseSearchHandler.java new file mode 100644 index 0000000000..8a3bbdbc5a --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ReleaseSearchHandler.java @@ -0,0 +1,66 @@ +/* + * Copyright Siemens AG, 2018. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.components.Release; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +/** + * Lucene search for the Release class + * + * @author thomas.maier@evosoft.com + */ +public class ReleaseSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("releases", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'release') {" + + " if (doc.name && typeof(doc.name) == 'string' && doc.name.length > 0) {" + + " index('text', 'name', doc.name, {'store': true});" + + " }" + + " if (doc.version && typeof(doc.version) == 'string' && doc.version.length > 0) {" + + " index('text', 'version', doc.version, {'store': true});" + + " }" + + " index('text', 'id', doc._id, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public ReleaseSearchHandler(Cloudant cClient, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(cClient, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String searchText) { + return connector.searchView(Release.class, luceneSearchView.getIndexName(), prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java similarity index 93% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java index 8da2d775c9..b37c97ca50 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/RepositoryUtils.java @@ -15,7 +15,7 @@ import org.eclipse.sw360.datahandler.thrift.RequestSummary; import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.model.Response; +import com.ibm.cloud.cloudant.v1.model.DocumentResult; import java.util.*; @@ -30,7 +30,7 @@ public static RequestSummary doBulk(Collection objects, User user, DatabaseRe RequestSummary requestSummary = new RequestSummary(); if(PermissionUtils.isAdmin(user)) { // Prepare component for database - final List documentOperationResults = repository.executeBulk(objects); + final List documentOperationResults = repository.executeBulk(objects); requestSummary.setTotalElements(objects.size() ); requestSummary.setTotalAffectedElements(objects.size() - documentOperationResults.size()); diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/SvmConnector.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/SvmConnector.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/SvmConnector.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/SvmConnector.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java similarity index 71% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java index aaf83b4f67..f136846d96 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserRepository.java @@ -9,9 +9,10 @@ */ package org.eclipse.sw360.datahandler.db; -import static com.cloudant.client.api.query.Expression.eq; -import static com.cloudant.client.api.query.Operation.and; -import static com.cloudant.client.api.query.Operation.or; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.eq; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.and; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.exists; +import static org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant.or; import org.eclipse.sw360.components.summary.UserSummary; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; @@ -20,19 +21,14 @@ import org.eclipse.sw360.datahandler.thrift.PaginationData; import org.eclipse.sw360.datahandler.thrift.users.User; -import com.cloudant.client.api.model.DesignDocument.MapReduce; -import com.cloudant.client.api.query.Expression; -import com.cloudant.client.api.query.QueryBuilder; -import com.cloudant.client.api.query.QueryResult; -import com.cloudant.client.api.query.Selector; -import com.cloudant.client.api.query.Sort; -import com.cloudant.client.api.views.Key; -import com.cloudant.client.api.views.ViewRequest; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; +import com.ibm.cloud.cloudant.v1.model.PostViewOptions; +import com.ibm.cloud.cloudant.v1.model.PostFindOptions; +import com.ibm.cloud.cloudant.v1.model.ViewResultRow; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import java.io.IOException; import java.util.*; import java.util.stream.Collectors; @@ -120,7 +116,7 @@ public class UserRepository extends SummaryAwareRepository { public UserRepository(DatabaseConnectorCloudant databaseConnector) { super(User.class, databaseConnector, new UserSummary()); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("byExternalId", createMapReduce(BYEXTERNALID, null)); views.put("byApiToken", createMapReduce(BYAPITOKEN, null)); @@ -194,12 +190,16 @@ public Map> getUsersWithPagination(PaginationData pag private Set getResultBasedOnQuery(String queryName) { Set userResults = Sets.newHashSet(); - ViewRequest query = getConnector().createQuery(User.class, queryName) - .newRequest(Key.Type.STRING, Object.class).includeDocs(false).build(); + PostViewOptions query = getConnector().getPostViewQueryBuilder(User.class, queryName) + .includeDocs(false).build(); try { - userResults = Sets.newTreeSet(CommonUtils.nullToEmptyList(query.getResponse().getKeys()).stream() - .filter(Objects::nonNull).collect(Collectors.toList())); - } catch (IOException e) { + userResults = getConnector().getPostViewQueryResponse(query).getRows() + .stream() + .map(ViewResultRow::getKey) + .filter(Objects::nonNull) + .map(Object::toString) + .collect(Collectors.toSet()); + } catch (ServiceConfigurationError e) { log.error("Error getting record of users based on queryName - " + queryName, e); } return userResults; @@ -211,76 +211,76 @@ private Map> queryViewWithPagination(PaginationData p List users = Lists.newArrayList(); final boolean ascending = pageData.isAscending(); final int sortColumnNo = pageData.getSortColumnNumber(); - String query = null; - final Selector typeSelector = eq("type", "user"); - final Selector emptySecondaryDepartmentsAndRolesSelector = or( - Expression.exists("secondaryDepartmentsAndRoles", false), eq("secondaryDepartmentsAndRoles", "")); - QueryBuilder qb = new QueryBuilder(typeSelector); + PostFindOptions query = null; + final Map typeSelector = Collections.singletonMap("type", + Collections.singletonMap("$eq", "user")); + final Map emptySecondaryDepartmentsAndRolesSelector = or( + List.of(exists("secondaryDepartmentsAndRoles", false), eq("secondaryDepartmentsAndRoles", ""))); + PostFindOptions.Builder qb = getConnector().getQueryBuilder() + .selector(typeSelector); if (rowsPerPage != -1) { qb.limit(rowsPerPage); } qb.skip(pageData.getDisplayStart()); switch (sortColumnNo) { - case -1: - case 2: - qb = qb.useIndex("byEmailUser"); - qb = ascending ? qb.sort(Sort.asc("email")) : qb.sort(Sort.desc("email")); - query = qb.build(); - break; - case 0: - qb = qb.useIndex("byFirstName"); - qb = ascending ? qb.sort(Sort.asc("givenname")) : qb.sort(Sort.desc("givenname")); - query = qb.build(); - break; - case 1: - qb = qb.useIndex("byLastName"); - qb = ascending ? qb.sort(Sort.asc("lastname")) : qb.sort(Sort.desc("lastname")); - query = qb.build(); - break; - case 3: - qb = qb.useIndex("byActiveStatus"); - qb = ascending ? qb.sort(Sort.asc("deactivated")) : qb.sort(Sort.desc("deactivated")); - query = qb.build(); - break; - case 4: - qb = qb.useIndex("byDepartment"); - qb = ascending ? qb.sort(Sort.asc("department")) : qb.sort(Sort.desc("department")); - query = qb.build(); - break; - case 5: - qb = qb.useIndex("byUserGroup"); - qb = ascending ? qb.sort(Sort.asc("userGroup")) : qb.sort(Sort.desc("userGroup")); - query = qb.build(); - break; - case 6: - if (ascending) { - qb.skip(0); - } - qb = qb.useIndex("bySecondaryDepartmentsAndRoles"); - qb = ascending ? qb.sort(Sort.asc("secondaryDepartmentsAndRoles")) - : qb.sort(Sort.desc("secondaryDepartmentsAndRoles")); - query = qb.build(); - break; - default: - break; + case -1: + case 2: + qb.useIndex(Collections.singletonList("byEmailUser")) + .addSort(Collections.singletonMap("email", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 0: + qb.useIndex(Collections.singletonList("byFirstName")) + .addSort(Collections.singletonMap("givenname", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 1: + qb.useIndex(Collections.singletonList("byLastName")) + .addSort(Collections.singletonMap("lastname", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 3: + qb.useIndex(Collections.singletonList("byActiveStatus")) + .addSort(Collections.singletonMap("deactivated", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 4: + qb.useIndex(Collections.singletonList("byDepartment")) + .addSort(Collections.singletonMap("department", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 5: + qb.useIndex(Collections.singletonList("byUserGroup")) + .addSort(Collections.singletonMap("userGroup", ascending ? "asc" : "desc")); + query = qb.build(); + break; + case 6: + if (ascending) { + qb.skip(0); + } + qb.useIndex(Collections.singletonList("bySecondaryDepartmentsAndRoles")) + .addSort(Collections.singletonMap("secondaryDepartmentsAndRoles", ascending ? "asc" : "desc")); + query = qb.build(); + break; + default: + break; } try { - QueryResult queryResult = getConnector().getQueryResult(query, User.class); - users = queryResult.getDocs(); + users = getConnector().getQueryResult(query, User.class); if (sortColumnNo == 6) { - final Selector selectorSecondaryGroupsAndRoles = and(typeSelector, - emptySecondaryDepartmentsAndRolesSelector); - QueryBuilder emptySecondaryGroupsAndRolesQb = new QueryBuilder(selectorSecondaryGroupsAndRoles); + final Map selectorSecondaryGroupsAndRoles = and(List.of(typeSelector, + emptySecondaryDepartmentsAndRolesSelector)); + PostFindOptions.Builder emptySecondaryGroupsAndRolesQb = getConnector().getQueryBuilder() + .selector(selectorSecondaryGroupsAndRoles); emptySecondaryGroupsAndRolesQb.skip(pageData.getDisplayStart()); if (rowsPerPage != -1) { emptySecondaryGroupsAndRolesQb.limit(rowsPerPage); } - QueryResult queryResultWithoutSorting = getConnector() + List userList = getConnector() .getQueryResult(emptySecondaryGroupsAndRolesQb.build(), User.class); - List userList = queryResultWithoutSorting.getDocs(); if (ascending) { userList.addAll(users); users = userList; diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserSearchHandler.java new file mode 100644 index 0000000000..4a034f0e57 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/UserSearchHandler.java @@ -0,0 +1,102 @@ +/* + * Copyright Siemens AG, 2017. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareFuzzyQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class UserSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("users", + new NouveauIndexFunction("function(doc) {" + + " if (doc.type == 'user') { " + + " if (doc.givenname && typeof(doc.givenname) == 'string' && doc.givenname.length > 0) {" + + " index('text', 'givenname', doc.givenname, {'store': true});" + + " }" + + " if (doc.lastname && typeof(doc.lastname) == 'string' && doc.lastname.length > 0) {" + + " index('text', 'lastname', doc.lastname, {'store': true});" + + " }" + + " if (doc.email && typeof(doc.email) == 'string' && doc.email.length > 0) {" + + " index('text', 'email', doc.email, {'store': true});" + + " }" + + " }" + + "}")); + + private static final NouveauIndexDesignDocument luceneUserSearchView + = new NouveauIndexDesignDocument("usersearch", + new NouveauIndexFunction("function(doc) {" + + " if (!doc.type || doc.type != 'user') return;" + + " if (doc.givenname && typeof(doc.givenname) == 'string' && doc.givenname.length > 0) {" + + " index('text', 'givenname', doc.givenname, {'store': true});" + + " }" + + " if (doc.lastname && typeof(doc.lastname) == 'string' && doc.lastname.length > 0) {" + + " index('text', 'lastname', doc.lastname, {'store': true});" + + " }" + + " if (doc.email && typeof(doc.email) == 'string' && doc.email.length > 0) {" + + " index('text', 'email', doc.email, {'store': true});" + + " }" + + " if (doc.userGroup && typeof(doc.userGroup) == 'string' && doc.userGroup.length > 0) {" + + " index('text', 'userGroup', doc.userGroup, {'store': true});" + + " }" + + " if (doc.department && typeof(doc.department) == 'string' && doc.department.length > 0) {" + + " index('text', 'department', doc.department, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public UserSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + // Creates the database connector and adds the lucene search view + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + searchView.addNouveau(luceneUserSearchView, gson); + connector.addDesignDoc(searchView); + } + + private String cleanUp(String searchText) { + // Lucene seems to split email addresses at an '@' when indexing + // so in this case we only search for the username in front of the '@' + return searchText.split("@")[0]; + } + + public List searchByNameAndEmail(String searchText) { + // Query the search view for the provided text + if(searchText == null) { + searchText = ""; + } + String queryString = prepareFuzzyQuery(cleanUp(searchText)); + return connector.searchAndSortByScore(User.class, luceneSearchView.getIndexName(), queryString); + } + + public List search(String text, final Map> subQueryRestrictions) { + return connector.searchViewWithRestrictions(User.class, luceneUserSearchView.getIndexName(), text, subQueryRestrictions); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java similarity index 96% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java index c7902c34b1..dfee575e67 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorRepository.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient; @@ -25,7 +24,7 @@ import org.eclipse.sw360.datahandler.thrift.vendors.Vendor; import java.util.Set; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; /** * CRUD access for the Vendor class @@ -51,7 +50,7 @@ public class VendorRepository extends DatabaseRepositoryCloudantClient { public VendorRepository(DatabaseConnectorCloudant db) { super(db, Vendor.class); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); views.put("vendorbyshortname", createMapReduce(BY_LOWERCASE_VENDOR_SHORTNAME_VIEW, null)); views.put("vendorbyfullname", createMapReduce(BY_LOWERCASE_VENDOR_FULLNAME_VIEW, null)); diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorSearchHandler.java new file mode 100644 index 0000000000..6ce9d76f87 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/VendorSearchHandler.java @@ -0,0 +1,76 @@ +/* + * Copyright Siemens AG, 2013-2018. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.vendors.Vendor; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +/** + * Lucene search for the Vendor class + * + * @author cedric.bodet@tngtech.com + * @author johannes.najjar@tngtech.com + * @author gerrit.grenzebach@tngtech.com + */ +public class VendorSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("vendors", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'vendor') {" + + " if (typeof(doc.shortname) == 'string' && doc.shortname.length > 0) {" + + " index('text', 'shortname', doc.shortname, {'store': true});" + + " }" + + " if (typeof(doc.fullname) == 'string' && doc.fullname.length > 0) {" + + " index('text', 'fullname', doc.fullname, {'store': true});" + + " }" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public VendorSearchHandler(Cloudant client, String dbName) throws IOException { + // Creates the database connector and adds the lucene search view + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String searchText) { + // Query the search view for the provided text + return connector.searchView(Vendor.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } + + public List searchIds(String searchText) { + // Query the search view for the provided text + return connector.searchIds(Vendor.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java similarity index 95% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java index 57885c8ad2..a622d03e48 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentDatabaseHandler.java @@ -10,7 +10,7 @@ */ package org.eclipse.sw360.datahandler.db.spdx.document; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.common.DatabaseSettings; @@ -33,7 +33,6 @@ import java.net.MalformedURLException; import java.util.*; -import java.util.function.Supplier; import com.google.common.collect.Lists; import static org.eclipse.sw360.datahandler.common.SW360Assert.assertNotNull; @@ -61,22 +60,22 @@ public class SpdxDocumentDatabaseHandler { private final SpdxDocumentCreationInfoDatabaseHandler creationInfoDatabaseHandler; private final SpdxPackageInfoDatabaseHandler packageInfoDatabaseHandler; - public SpdxDocumentDatabaseHandler(Supplier httpClient, String dbName) throws MalformedURLException { - db = new DatabaseConnectorCloudant(httpClient, dbName); + public SpdxDocumentDatabaseHandler(Cloudant client, String dbName) throws MalformedURLException { + db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories SPDXDocumentRepository = new SpdxDocumentRepository(db); - sw360db = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_DATABASE); + sw360db = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_DATABASE); vendorRepository = new VendorRepository(sw360db); releaseRepository = new ReleaseRepository(sw360db, vendorRepository); // Create the moderator moderator = new SpdxDocumentModerator(); // Create the changelogs - dbChangeLogs = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_CHANGE_LOGS); + dbChangeLogs = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_CHANGE_LOGS); this.dbHandlerUtil = new DatabaseHandlerUtil(dbChangeLogs); - this.creationInfoDatabaseHandler = new SpdxDocumentCreationInfoDatabaseHandler(httpClient, dbName); - this.packageInfoDatabaseHandler = new SpdxPackageInfoDatabaseHandler(httpClient, dbName); + this.creationInfoDatabaseHandler = new SpdxDocumentCreationInfoDatabaseHandler(client, dbName); + this.packageInfoDatabaseHandler = new SpdxPackageInfoDatabaseHandler(client, dbName); } public List getSPDXDocumentSummary(User user) { diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java similarity index 90% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java index 25f024b187..6d9dac9db9 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentRepository.java @@ -16,7 +16,7 @@ import org.eclipse.sw360.datahandler.couchdb.SummaryAwareRepository; import org.eclipse.sw360.datahandler.thrift.spdx.spdxdocument.SPDXDocument; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; import java.util.HashMap; import java.util.List; @@ -28,7 +28,7 @@ public class SpdxDocumentRepository extends SummaryAwareRepository public SpdxDocumentRepository(DatabaseConnectorCloudant db) { super(SPDXDocument.class, db, new SpdxDocumentSummary()); - Map views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentSearchHandler.java new file mode 100644 index 0000000000..afe223335e --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/document/SpdxDocumentSearchHandler.java @@ -0,0 +1,57 @@ +/* + * Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. + * Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2022. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db.spdx.document; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.spdx.spdxdocument.SPDXDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class SpdxDocumentSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("SPDXDocument", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'SPDXDocument') {" + + " index('text', 'id', doc._id, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public SpdxDocumentSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String searchText) { + return connector.searchView(SPDXDocument.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java similarity index 96% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java index 9da2667d05..b63f952809 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoDatabaseHandler.java @@ -10,7 +10,7 @@ */ package org.eclipse.sw360.datahandler.db.spdx.documentcreationinfo; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.db.spdx.document.SpdxDocumentRepository; @@ -29,7 +29,6 @@ import java.net.MalformedURLException; import java.util.*; -import java.util.function.Supplier; import com.google.common.collect.Lists; import org.eclipse.sw360.datahandler.common.DatabaseSettings; @@ -53,8 +52,8 @@ public class SpdxDocumentCreationInfoDatabaseHandler { private DatabaseHandlerUtil dbHandlerUtil; private final SpdxDocumentCreationInfoModerator moderator; - public SpdxDocumentCreationInfoDatabaseHandler(Supplier httpClient, String dbName) throws MalformedURLException { - db = new DatabaseConnectorCloudant(httpClient, dbName); + public SpdxDocumentCreationInfoDatabaseHandler(Cloudant client, String dbName) throws MalformedURLException { + db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories SPDXDocumentCreationInfoRepository = new SpdxDocumentCreationInfoRepository(db); @@ -62,7 +61,7 @@ public SpdxDocumentCreationInfoDatabaseHandler(Supplier httpClie // Create the moderator moderator = new SpdxDocumentCreationInfoModerator(); // Create the changelogs - dbChangeLogs = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_CHANGE_LOGS); + dbChangeLogs = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_CHANGE_LOGS); this.dbHandlerUtil = new DatabaseHandlerUtil(dbChangeLogs); } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java similarity index 91% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java index 8978eda05f..925985db27 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoRepository.java @@ -16,7 +16,7 @@ import org.eclipse.sw360.datahandler.couchdb.SummaryAwareRepository; import org.eclipse.sw360.datahandler.thrift.spdx.documentcreationinformation.*; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; import java.util.HashMap; import java.util.List; @@ -28,7 +28,7 @@ public class SpdxDocumentCreationInfoRepository extends SummaryAwareRepository views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoSearchHandler.java new file mode 100644 index 0000000000..fd55f91122 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/documentcreationinfo/SpdxDocumentCreationInfoSearchHandler.java @@ -0,0 +1,57 @@ +/* + * Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. + * Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2022. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db.spdx.documentcreationinfo; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.spdx.documentcreationinformation.DocumentCreationInformation; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class SpdxDocumentCreationInfoSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("documentCreationInformation", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'documentCreationInformation') {" + + " index('text', 'id', doc._id, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public SpdxDocumentCreationInfoSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String searchText) { + return connector.searchView(DocumentCreationInformation.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java similarity index 96% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java index 4ee66bea41..5c2cb77958 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoDatabaseHandler.java @@ -10,7 +10,7 @@ */ package org.eclipse.sw360.datahandler.db.spdx.packageinfo; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.db.spdx.document.SpdxDocumentRepository; @@ -29,7 +29,6 @@ import java.net.MalformedURLException; import java.util.*; -import java.util.function.Supplier; import com.google.common.collect.Lists; import org.eclipse.sw360.datahandler.common.DatabaseSettings; @@ -53,8 +52,8 @@ public class SpdxPackageInfoDatabaseHandler { private DatabaseHandlerUtil dbHandlerUtil; private final SpdxPackageInfoModerator moderator; - public SpdxPackageInfoDatabaseHandler(Supplier httpClient, String dbName) throws MalformedURLException { - db = new DatabaseConnectorCloudant(httpClient, dbName); + public SpdxPackageInfoDatabaseHandler(Cloudant client, String dbName) throws MalformedURLException { + db = new DatabaseConnectorCloudant(client, dbName); // Create the repositories PackageInfoRepository = new SpdxPackageInfoRepository(db); @@ -63,13 +62,12 @@ public SpdxPackageInfoDatabaseHandler(Supplier httpClient, Strin // Create the moderator moderator = new SpdxPackageInfoModerator(); // Create the changelogs - dbChangeLogs = new DatabaseConnectorCloudant(httpClient, DatabaseSettings.COUCH_DB_CHANGE_LOGS); + dbChangeLogs = new DatabaseConnectorCloudant(client, DatabaseSettings.COUCH_DB_CHANGE_LOGS); this.dbHandlerUtil = new DatabaseHandlerUtil(dbChangeLogs); } public List getPackageInformationSummary(User user) { - List packageInfos = PackageInfoRepository.getPackageInformationSummary(); - return packageInfos; + return PackageInfoRepository.getPackageInformationSummary(); } public PackageInformation getPackageInformationById(String id, User user) throws SW360Exception { diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java similarity index 91% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java index 06554cd9c1..c4c526200b 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoRepository.java @@ -16,7 +16,7 @@ import org.eclipse.sw360.datahandler.couchdb.SummaryAwareRepository; import org.eclipse.sw360.datahandler.thrift.spdx.spdxpackageinfo.*; -import com.cloudant.client.api.model.DesignDocument.MapReduce; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce; import java.util.HashMap; import java.util.List; @@ -28,7 +28,7 @@ public class SpdxPackageInfoRepository extends SummaryAwareRepository views = new HashMap(); + Map views = new HashMap<>(); views.put("all", createMapReduce(ALL, null)); initStandardDesignDocument(views, db); } diff --git a/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoSearchHandler.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoSearchHandler.java new file mode 100644 index 0000000000..cf586fe9b2 --- /dev/null +++ b/backend/common/src/main/java/org/eclipse/sw360/datahandler/db/spdx/packageinfo/SpdxPackageInfoSearchHandler.java @@ -0,0 +1,57 @@ +/* + * Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. + * Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2022. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.datahandler.db.spdx.packageinfo; + +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.google.gson.Gson; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; +import org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector; +import org.eclipse.sw360.datahandler.thrift.spdx.spdxpackageinfo.PackageInformation; +import org.eclipse.sw360.nouveau.designdocument.NouveauDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexDesignDocument; +import org.eclipse.sw360.nouveau.designdocument.NouveauIndexFunction; + +import java.io.IOException; +import java.util.List; + +import static org.eclipse.sw360.datahandler.couchdb.lucene.NouveauLuceneAwareDatabaseConnector.prepareWildcardQuery; +import static org.eclipse.sw360.nouveau.LuceneAwareCouchDbConnector.DEFAULT_DESIGN_PREFIX; + +public class SpdxPackageInfoSearchHandler { + + private static final String DDOC_NAME = DEFAULT_DESIGN_PREFIX + "lucene"; + + private static final NouveauIndexDesignDocument luceneSearchView + = new NouveauIndexDesignDocument("packageInformation", + new NouveauIndexFunction( + "function(doc) {" + + " if(doc.type == 'packageInformation') { " + + " index('text', 'id', doc._id, {'store': true});" + + " }" + + "}")); + + private final NouveauLuceneAwareDatabaseConnector connector; + + public SpdxPackageInfoSearchHandler(Cloudant client, String dbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); + connector = new NouveauLuceneAwareDatabaseConnector(db, DDOC_NAME, dbName, db.getInstance().getGson()); + Gson gson = db.getInstance().getGson(); + NouveauDesignDocument searchView = new NouveauDesignDocument(); + searchView.setId(DDOC_NAME); + searchView.addNouveau(luceneSearchView, gson); + connector.addDesignDoc(searchView); + } + + public List search(String searchText) { + return connector.searchView(PackageInformation.class, luceneSearchView.getIndexName(), + prepareWildcardQuery(searchText)); + } +} diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ComponentModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ComponentModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ComponentModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ComponentModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/LicenseModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/LicenseModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/LicenseModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/LicenseModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ProjectModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ProjectModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ProjectModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ProjectModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ReleaseModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ReleaseModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ReleaseModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/ReleaseModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentCreationInfoModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentCreationInfoModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentCreationInfoModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentCreationInfoModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxDocumentModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxPackageInfoModerator.java b/backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxPackageInfoModerator.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxPackageInfoModerator.java rename to backend/common/src/main/java/org/eclipse/sw360/datahandler/entitlement/SpdxPackageInfoModerator.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/mail/MailConstants.java b/backend/common/src/main/java/org/eclipse/sw360/mail/MailConstants.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/mail/MailConstants.java rename to backend/common/src/main/java/org/eclipse/sw360/mail/MailConstants.java diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/mail/MailUtil.java b/backend/common/src/main/java/org/eclipse/sw360/mail/MailUtil.java similarity index 99% rename from backend/src-common/src/main/java/org/eclipse/sw360/mail/MailUtil.java rename to backend/common/src/main/java/org/eclipse/sw360/mail/MailUtil.java index 29ca213b10..5955c43eb3 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/mail/MailUtil.java +++ b/backend/common/src/main/java/org/eclipse/sw360/mail/MailUtil.java @@ -22,9 +22,9 @@ import org.eclipse.sw360.datahandler.thrift.projects.ClearingRequest; import org.eclipse.sw360.datahandler.thrift.users.User; -import javax.mail.*; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; +import jakarta.mail.*; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; import java.io.IOException; import java.util.Arrays; import java.util.IllegalFormatException; @@ -37,7 +37,7 @@ import static org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptySet; /** - * Provides the possiblity to send mail from SW360 + * Provides the possibility to send mail from SW360 * * @author birgit.heydenreich@tngtech.com */ diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java b/backend/common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java similarity index 92% rename from backend/src-common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java rename to backend/common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java index 0657780587..c03b1d3590 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java +++ b/backend/common/src/main/java/org/eclipse/sw360/projects/Sw360ThriftServlet.java @@ -15,9 +15,9 @@ import org.apache.thrift.protocol.TProtocolFactory; import org.apache.thrift.server.TServlet; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; /** diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java b/backend/common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java similarity index 89% rename from backend/src-common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java rename to backend/common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java index b2e6463bf2..7b9d4ac4a2 100644 --- a/backend/src-common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java +++ b/backend/common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporter.java @@ -11,7 +11,9 @@ */ package org.eclipse.sw360.spdx; +import com.google.gson.Gson; import org.eclipse.sw360.datahandler.common.SW360Constants; +import org.eclipse.sw360.datahandler.common.SW360Utils; import org.eclipse.sw360.datahandler.db.DatabaseHandlerUtil; import org.eclipse.sw360.datahandler.thrift.*; import org.eclipse.sw360.datahandler.thrift.attachments.Attachment; @@ -21,6 +23,7 @@ import org.eclipse.sw360.datahandler.thrift.components.Component; import org.eclipse.sw360.datahandler.thrift.components.ComponentType; import org.eclipse.sw360.datahandler.thrift.components.Release; +import org.eclipse.sw360.datahandler.thrift.components.ReleaseNode; import org.eclipse.sw360.datahandler.thrift.projects.Project; import org.eclipse.sw360.datahandler.thrift.spdx.annotations.Annotations; import org.eclipse.sw360.datahandler.thrift.spdx.documentcreationinformation.*; @@ -29,6 +32,7 @@ import org.eclipse.sw360.datahandler.thrift.spdx.snippetinformation.*; import org.eclipse.sw360.datahandler.thrift.spdx.spdxdocument.*; import org.eclipse.sw360.datahandler.thrift.spdx.spdxpackageinfo.*; +import org.eclipse.sw360.datahandler.thrift.users.User; import org.spdx.library.model.enumerations.Purpose; import org.spdx.library.model.enumerations.RelationshipType; import org.spdx.library.model.license.ExtractedLicenseInfo; @@ -116,9 +120,9 @@ public ImportBomRequestPreparation prepareImportSpdxBOMAsRelease(File targetFile return requestPreparation; } - public RequestSummary importSpdxBOMAsRelease(InputStream inputStream, AttachmentContent attachmentContent) + public RequestSummary importSpdxBOMAsRelease(InputStream inputStream, AttachmentContent attachmentContent, User user) throws SW360Exception, IOException { - return importSpdxBOM(inputStream, attachmentContent, SW360Constants.TYPE_RELEASE); + return importSpdxBOM(inputStream, attachmentContent, SW360Constants.TYPE_RELEASE, user); } private SpdxDocument openAsSpdx(File file){ @@ -131,17 +135,17 @@ private SpdxDocument openAsSpdx(File file){ } } - public RequestSummary importSpdxBOMAsProject(InputStream inputStream, AttachmentContent attachmentContent) + public RequestSummary importSpdxBOMAsProject(InputStream inputStream, AttachmentContent attachmentContent, User user) throws SW360Exception, IOException { - return importSpdxBOM(attachmentContent, SW360Constants.TYPE_PROJECT , inputStream); + return importSpdxBOM(attachmentContent, SW360Constants.TYPE_PROJECT , inputStream, user); } - private RequestSummary importSpdxBOM( AttachmentContent attachmentContent, String type, InputStream inputStream) + private RequestSummary importSpdxBOM( AttachmentContent attachmentContent, String type, InputStream inputStream, User user) throws SW360Exception, IOException { - return importSpdxBOM(inputStream, attachmentContent, type); + return importSpdxBOM(inputStream, attachmentContent, type, user); } - private RequestSummary importSpdxBOM(InputStream inputStream, AttachmentContent attachmentContent, String type) + private RequestSummary importSpdxBOM(InputStream inputStream, AttachmentContent attachmentContent, String type, User user) throws SW360Exception, IOException { final RequestSummary requestSummary = new RequestSummary(); List describedPackages = new ArrayList<>(); @@ -180,7 +184,7 @@ private RequestSummary importSpdxBOM(InputStream inputStream, AttachmentContent final SpdxPackage spdxElement = (SpdxPackage) packages.get(0); final Optional response; if (SW360Constants.TYPE_PROJECT.equals(type)) { - response = importAsProject(spdxElement, attachmentContent); + response = importAsProject(spdxElement, attachmentContent, user); } else if (SW360Constants.TYPE_RELEASE.equals(type)) { response = importAsRelease(spdxElement, attachmentContent, spdxDocument); } else { @@ -935,14 +939,27 @@ private Map makeReleaseIdToProjectRelationsh } - private Optional importAsProject(SpdxElement spdxElement, AttachmentContent attachmentContent) throws SW360Exception, InvalidSPDXAnalysisException { + private Optional importAsProject(SpdxElement spdxElement, AttachmentContent attachmentContent, User user) throws SW360Exception, InvalidSPDXAnalysisException { if (spdxElement instanceof SpdxPackage) { final SpdxPackage spdxPackage = (SpdxPackage) spdxElement; final Project project = creatProjectFromSpdxPackage(spdxPackage); final Relationship[] relationships = spdxPackage.getRelationships().toArray(new Relationship[spdxPackage.getRelationships().size()]); - List releases = importAsReleases(relationships); + List releases = new ArrayList<>(); + + if (!SW360Constants.ENABLE_FLEXIBLE_PROJECT_RELEASE_RELATIONSHIP) { + releases.addAll(importAsReleases(relationships)); + } else { + List releaseNodes = makeReleaseNodesFromRelationship(relationships, user); + releaseNodes.forEach(releaseNode -> { + SpdxBOMImporterSink.Response response = new SpdxBOMImporterSink.Response(releaseNode.releaseId); + response.setReleaseRelationship(ReleaseRelationship.valueOf(releaseNode.releaseRelationship)); + releases.add(response); + }); + project.setReleaseRelationNetwork(new Gson().toJson(releaseNodes)); + } + Map releaseIdToProjectRelationship = makeReleaseIdToProjectRelationship(releases); project.setReleaseIdToUsage(releaseIdToProjectRelationship); @@ -989,4 +1006,102 @@ private String getFileType(String fileName) { } return ext; } + + /** + * Create list of ReleaseNode (release node in dependency network) from SPDX relationships + * + * @param relationships SPDX relationships + * @param user SW360 user + * @return List of ReleaseNode + */ + private List makeReleaseNodesFromRelationship(Relationship[] relationships, User user) { + return Arrays.stream(relationships).map( + relationship -> { + try { + return buildReleaseNodeByRelationship(relationship, user); + } catch (SW360Exception | InvalidSPDXAnalysisException e) { + log.error(e.getMessage()); + return null; + } + } + ).filter(Objects::nonNull).collect(Collectors.toList()); + } + + /** + * Import as project release + * + * @param relatedSpdxElement related element in SPDX + * @return response + * @throws SW360Exception exception throws when build response + * @throws InvalidSPDXAnalysisException exception throws when build response + */ + private Optional importAsReleaseInProject(SpdxElement relatedSpdxElement) throws SW360Exception, InvalidSPDXAnalysisException { + if (relatedSpdxElement instanceof SpdxPackage) { + final SpdxPackage spdxPackage = (SpdxPackage) relatedSpdxElement; + + SpdxBOMImporterSink.Response component = importAsComponent(spdxPackage); + final String componentId = component.getId(); + + final Release release = createReleaseFromSpdxPackage(spdxPackage); + release.setComponentId(componentId); + + final SpdxBOMImporterSink.Response response = sink.addRelease(release); + response.addChild(component); + return Optional.of(response); + } else { + log.debug("Unsupported SpdxElement: " + relatedSpdxElement.getClass().getCanonicalName()); + return Optional.empty(); + } + } + + /** + * Build object to present a release node in dependency network by relationship + * + * @param relationship relationship in SPDX + * @param user user + * @return ReleaseNode + * @throws SW360Exception exception throws when build ReleaseNode + * @throws InvalidSPDXAnalysisException exception throws when build response + */ + private ReleaseNode buildReleaseNodeByRelationship(Relationship relationship, User user) throws SW360Exception, InvalidSPDXAnalysisException { + Map typeToSupplierMap = new HashMap<>(); + typeToSupplierMap.put(RelationshipType.CONTAINS, ReleaseRelationship.CONTAINED); + final RelationshipType relationshipType = relationship.getRelationshipType(); + + if (!typeToSupplierMap.containsKey(relationshipType)) { + log.info("Unsupported relationshipType:" + relationship.getRelationshipType().toString()); + return null; + } + + SpdxElement relatedSpdxElement = relationship.getRelatedSpdxElement().orElse(null); + if (relatedSpdxElement == null) { + return null; + } + + Optional response = importAsReleaseInProject(relatedSpdxElement); + + if (response.isEmpty()) { + return null; + } + + ReleaseNode releaseNode = new ReleaseNode(response.get().getId()); + releaseNode.setMainlineState(MainlineState.OPEN.toString()); + releaseNode.setReleaseRelationship(typeToSupplierMap.get(relationshipType).toString()); + releaseNode.setComment(""); + releaseNode.setCreateOn(SW360Utils.getCreatedOn()); + releaseNode.setCreateBy(user.getEmail()); + + List subNodes = relatedSpdxElement.getRelationships().parallelStream().map(spdxRelationShip -> { + try { + return buildReleaseNodeByRelationship(spdxRelationShip, user); + } catch (SW360Exception | InvalidSPDXAnalysisException e) { + log.error(e.getMessage()); + return null; + } + }).filter(Objects::nonNull).collect(Collectors.toList()); + + releaseNode.setReleaseLink(subNodes); + + return releaseNode; + } } diff --git a/backend/src-common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporterSink.java b/backend/common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporterSink.java similarity index 100% rename from backend/src-common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporterSink.java rename to backend/common/src/main/java/org/eclipse/sw360/spdx/SpdxBOMImporterSink.java diff --git a/backend/src-common/src/main/resources/ClosedOrRejectedCREmailTemplate.html b/backend/common/src/main/resources/ClosedOrRejectedCREmailTemplate.html similarity index 100% rename from backend/src-common/src/main/resources/ClosedOrRejectedCREmailTemplate.html rename to backend/common/src/main/resources/ClosedOrRejectedCREmailTemplate.html diff --git a/backend/src-common/src/main/resources/NewClearingRequestEmailTemplate.html b/backend/common/src/main/resources/NewClearingRequestEmailTemplate.html similarity index 100% rename from backend/src-common/src/main/resources/NewClearingRequestEmailTemplate.html rename to backend/common/src/main/resources/NewClearingRequestEmailTemplate.html diff --git a/backend/src-common/src/main/resources/NewCommentInCREmailTemplate.html b/backend/common/src/main/resources/NewCommentInCREmailTemplate.html similarity index 100% rename from backend/src-common/src/main/resources/NewCommentInCREmailTemplate.html rename to backend/common/src/main/resources/NewCommentInCREmailTemplate.html diff --git a/backend/src-common/src/main/resources/UpdateClearingRequestEmailTemplate.html b/backend/common/src/main/resources/UpdateClearingRequestEmailTemplate.html similarity index 100% rename from backend/src-common/src/main/resources/UpdateClearingRequestEmailTemplate.html rename to backend/common/src/main/resources/UpdateClearingRequestEmailTemplate.html diff --git a/backend/src-common/src/main/resources/UpdateProjectWithCREmailTemplate.html b/backend/common/src/main/resources/UpdateProjectWithCREmailTemplate.html similarity index 100% rename from backend/src-common/src/main/resources/UpdateProjectWithCREmailTemplate.html rename to backend/common/src/main/resources/UpdateProjectWithCREmailTemplate.html diff --git a/backend/src-common/src/main/resources/sw360.properties b/backend/common/src/main/resources/sw360.properties similarity index 94% rename from backend/src-common/src/main/resources/sw360.properties rename to backend/common/src/main/resources/sw360.properties index d236e8e0b1..d65daa5157 100644 --- a/backend/src-common/src/main/resources/sw360.properties +++ b/backend/common/src/main/resources/sw360.properties @@ -124,8 +124,13 @@ textForRejectedClearingRequest= your clearing request with id: %s for the projec enable.sw360.change.log=false sw360changelog.output.path=sw360changelog/sw360changelog auto.set.ecc.status=false -send.project.spreadsheet.export.to.mail.enabled=false -send.component.spreadsheet.export.to.mail.enabled=false + +##This property is used to enable mail request for projects/components report. +#send.project.spreadsheet.export.to.mail.enabled=false +#send.component.spreadsheet.export.to.mail.enabled=false ## This property is used to enable the bulk release deleting feature. #bulk.release.deleting.enabled=true + +## This property is used to disable the ISR generation in fossology process +disable.clearing.fossology.report.download=false \ No newline at end of file diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java b/backend/common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java similarity index 100% rename from backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java rename to backend/common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandlerTest.java b/backend/common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandlerTest.java similarity index 100% rename from backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandlerTest.java rename to backend/common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentAwareDatabaseHandlerTest.java diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandlerTest.java b/backend/common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandlerTest.java similarity index 100% rename from backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandlerTest.java rename to backend/common/src/test/java/org/eclipse/sw360/datahandler/db/AttachmentDatabaseHandlerTest.java diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java b/backend/common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java similarity index 94% rename from backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java rename to backend/common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java index 3990aa2b8e..e493d5982a 100644 --- a/backend/src-common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java +++ b/backend/common/src/test/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandlerTest.java @@ -95,7 +95,31 @@ public void setUp() throws Exception { .put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)) .put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)) .build()) - .setLinkedProjects(ImmutableMap.builder().put("P5", new ProjectProjectRelationship(ProjectRelationship.CONTAINED)).build()); + .setLinkedProjects(ImmutableMap.builder().put("P5", new ProjectProjectRelationship(ProjectRelationship.CONTAINED)).build()) + .setReleaseRelationNetwork( + """ + [ + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"r1", + "releaseRelationship":"CONTAINED" + }, + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"r2", + "releaseRelationship":"CONTAINED" + } + ], + """ + ); projects.add(p4); projects.add(new Project().setId("P5").setName("Project5").setBusinessUnit("AB CD EF").setCreatedBy("user1").setVisbility(Visibility.BUISNESSUNIT_AND_MODERATORS)); diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java b/backend/common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java similarity index 94% rename from backend/src-common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java rename to backend/common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java index 24eefb1d6f..803faf07cb 100644 --- a/backend/src-common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java +++ b/backend/common/src/test/java/org/eclipse/sw360/spdx/SpdxBOMImporterTest.java @@ -14,6 +14,7 @@ import org.eclipse.sw360.datahandler.thrift.components.Component; import org.eclipse.sw360.datahandler.thrift.components.Release; import org.eclipse.sw360.datahandler.thrift.projects.Project; +import org.eclipse.sw360.datahandler.thrift.users.User; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -38,6 +39,9 @@ public class SpdxBOMImporterTest { private SpdxBOMImporter spdxBOMImporter; + @Mock + private User user; + @Before public void before() throws Exception { spdxBOMImporter = new SpdxBOMImporter(spdxBOMImporterSink); @@ -75,7 +79,7 @@ public void after() throws Exception { @Test public void testProject() throws Exception { - final RequestSummary requestSummary = spdxBOMImporter.importSpdxBOMAsProject(inputStream, attachmentContent); + final RequestSummary requestSummary = spdxBOMImporter.importSpdxBOMAsProject(inputStream, attachmentContent, user); assertNotNull(requestSummary); verify(spdxBOMImporterSink, times(1)).addProject(ArgumentMatchers.any()); @@ -85,7 +89,7 @@ public void testProject() throws Exception { @Test public void testRelease() throws Exception { - final RequestSummary requestSummary = spdxBOMImporter.importSpdxBOMAsRelease(inputStream, attachmentContent); + final RequestSummary requestSummary = spdxBOMImporter.importSpdxBOMAsRelease(inputStream, attachmentContent, user); assertNotNull(requestSummary); verify(spdxBOMImporterSink, times(4)).addComponent(ArgumentMatchers.any()); diff --git a/backend/src-common/src/test/resources/bom.spdx b/backend/common/src/test/resources/bom.spdx similarity index 100% rename from backend/src-common/src/test/resources/bom.spdx rename to backend/common/src/test/resources/bom.spdx diff --git a/backend/src-common/src/test/resources/bom.spdx.rdf b/backend/common/src/test/resources/bom.spdx.rdf similarity index 100% rename from backend/src-common/src/test/resources/bom.spdx.rdf rename to backend/common/src/test/resources/bom.spdx.rdf diff --git a/backend/components/pom.xml b/backend/components/pom.xml new file mode 100644 index 0000000000..e6d70737b6 --- /dev/null +++ b/backend/components/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + + org.eclipse.sw360 + backend + 19.0.0 + + + backend-components + war + backend-components + components + + ${backend.deploy.dir} + + + + + org.eclipse.sw360 + backend-common + ${project.version} + + + diff --git a/backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java b/backend/components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java similarity index 95% rename from backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java rename to backend/components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java index cecd8b62a6..87fb1ab4f9 100644 --- a/backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java +++ b/backend/components/src/main/java/org/eclipse/sw360/components/ComponentHandler.java @@ -24,16 +24,14 @@ import org.eclipse.sw360.datahandler.thrift.components.ReleaseNode; import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.thrift.users.RequestedAction; -import org.ektorp.http.HttpClient; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import java.io.IOException; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Supplier; import static org.eclipse.sw360.datahandler.common.SW360Assert.*; @@ -50,24 +48,24 @@ public class ComponentHandler implements ComponentService.Iface { private final ReleaseSearchHandler releaseSearchHandler; public ComponentHandler() throws IOException { - this(DatabaseSettings.getConfiguredClient(), DatabaseSettings.getConfiguredHttpClient(), DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_CHANGE_LOGS, DatabaseSettings.COUCH_DB_ATTACHMENTS); + this(DatabaseSettings.getConfiguredClient(), DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_CHANGE_LOGS, DatabaseSettings.COUCH_DB_ATTACHMENTS); } - public ComponentHandler(Supplier cClient, Supplier hclient, String dbName, String changeLogsDBName, String attachmentDbName) throws IOException { + public ComponentHandler(Cloudant cClient, String dbName, String changeLogsDBName, String attachmentDbName) throws IOException { handler = new ComponentDatabaseHandler(cClient, dbName, changeLogsDBName, attachmentDbName); - componentSearchHandler = new ComponentSearchHandler(hclient, cClient, dbName); - releaseSearchHandler = new ReleaseSearchHandler(hclient, cClient, dbName); + componentSearchHandler = new ComponentSearchHandler(cClient, dbName); + releaseSearchHandler = new ReleaseSearchHandler(cClient, dbName); } // TODO use dependency injection instead of this constructors mess public ComponentHandler(ThriftClients thriftClients) throws IOException { - this(DatabaseSettings.getConfiguredHttpClient(), DatabaseSettings.getConfiguredClient(), DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_CHANGE_LOGS, DatabaseSettings.COUCH_DB_ATTACHMENTS, thriftClients); + this(DatabaseSettings.getConfiguredClient(), DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_CHANGE_LOGS, DatabaseSettings.COUCH_DB_ATTACHMENTS, thriftClients); } - public ComponentHandler(Supplier httpClient, Supplier client, String dbName, String changeLogsDBName, String attachmentDbName, ThriftClients thriftClients) throws IOException { + public ComponentHandler(Cloudant client, String dbName, String changeLogsDBName, String attachmentDbName, ThriftClients thriftClients) throws IOException { handler = new ComponentDatabaseHandler(client, dbName, changeLogsDBName, attachmentDbName, thriftClients); - componentSearchHandler = new ComponentSearchHandler(httpClient, client, dbName); - releaseSearchHandler = new ReleaseSearchHandler(httpClient, client, dbName); + componentSearchHandler = new ComponentSearchHandler(client, dbName); + releaseSearchHandler = new ReleaseSearchHandler(client, dbName); } ///////////////////// diff --git a/backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java b/backend/components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java similarity index 96% rename from backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java rename to backend/components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java index 5c2246ff8c..174be56449 100644 --- a/backend/src/src-components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java +++ b/backend/components/src/main/java/org/eclipse/sw360/components/ComponentServlet.java @@ -14,7 +14,6 @@ import org.eclipse.sw360.projects.Sw360ThriftServlet; import java.io.IOException; -import java.net.MalformedURLException; /** * Thrift Servlet instantiation diff --git a/backend/svc/svc-components/src/main/webapp/WEB-INF/web.xml b/backend/components/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-components/src/main/webapp/WEB-INF/web.xml rename to backend/components/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-components/src/main/webapp/index.jsp b/backend/components/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-components/src/main/webapp/index.jsp rename to backend/components/src/main/webapp/index.jsp diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java b/backend/components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java similarity index 95% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java rename to backend/components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java index 4e32c19fbe..1be53cac85 100644 --- a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java +++ b/backend/components/src/test/java/org/eclipse/sw360/components/ComponentHandlerTest.java @@ -44,8 +44,8 @@ public void setUp() throws Exception { assertTestDbNames(); deleteAllDatabases(); componentHandler = new ComponentHandler(DatabaseSettingsTest.getConfiguredClient(), - DatabaseSettingsTest.getConfiguredHttpClient(), DatabaseSettingsTest.COUCH_DB_DATABASE, - DatabaseSettingsTest.COUCH_DB_CHANGELOGS, DatabaseSettingsTest.COUCH_DB_ATTACHMENTS); + DatabaseSettingsTest.COUCH_DB_DATABASE, DatabaseSettingsTest.COUCH_DB_CHANGELOGS, + DatabaseSettingsTest.COUCH_DB_ATTACHMENTS); } @After diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/TestComponentClient.java b/backend/components/src/test/java/org/eclipse/sw360/components/TestComponentClient.java similarity index 100% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/TestComponentClient.java rename to backend/components/src/test/java/org/eclipse/sw360/components/TestComponentClient.java diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java b/backend/components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java similarity index 99% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java rename to backend/components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java index e91ac2723a..c35a71357c 100644 --- a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java +++ b/backend/components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java @@ -12,9 +12,9 @@ import org.eclipse.sw360.common.utils.BackendUtils; import org.eclipse.sw360.datahandler.TestUtils; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.common.CommonUtils; import org.eclipse.sw360.datahandler.common.DatabaseSettingsTest; -import org.eclipse.sw360.datahandler.couchdb.DatabaseConnector; import org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler; import org.eclipse.sw360.datahandler.db.BulkDeleteUtil; import org.eclipse.sw360.datahandler.entitlement.ComponentModerator; @@ -97,8 +97,8 @@ public class BulkDeleteUtilTest { private Map vendors; private ComponentDatabaseHandler handler; - private DatabaseConnector databaseConnector; - private DatabaseConnector changeLogsDatabaseConnector; + private DatabaseConnectorCloudant databaseConnector; + private DatabaseConnectorCloudant changeLogsDatabaseConnector; private BulkDeleteUtil bulkDeleteUtil; private int nextReleaseVersion = 0; @@ -127,8 +127,8 @@ public void setUp() throws Exception { TestUtils.createDatabase(DatabaseSettingsTest.getConfiguredClient(), changeLogsDbName); // Prepare the database - databaseConnector = new DatabaseConnector(DatabaseSettingsTest.getConfiguredHttpClient(), dbName); - changeLogsDatabaseConnector = new DatabaseConnector(DatabaseSettingsTest.getConfiguredHttpClient(), changeLogsDbName); + databaseConnector = new DatabaseConnectorCloudant(DatabaseSettingsTest.getConfiguredClient(), dbName); + changeLogsDatabaseConnector = new DatabaseConnectorCloudant(DatabaseSettingsTest.getConfiguredClient(), changeLogsDbName); // Prepare vendors for (Vendor vendor : vendors.values()) { @@ -1138,7 +1138,7 @@ public void checkDeletedReleaseListInLoop(int loopCount, List deletedRe assertTrue(CommonUtils.isNullOrEmptyMap(relationShip_c1)); } - private void createTestRecords001() { + private void createTestRecords001() throws SW360Exception { List components = new ArrayList(); Component component_dr_A = new Component().setId(COMPONENT_ID_A).setName("DR_A").setDescription("DR Component A").setCreatedBy(USER_EMAIL1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic1"))).setCreatedOn("2022-07-20"); @@ -1208,7 +1208,7 @@ private void createTestRecords001() { } - private void createTestRecords002() { + private void createTestRecords002() throws SW360Exception { List components = new ArrayList(); Component component_dr_A = new Component().setId(COMPONENT_ID_A).setName("DR_A").setDescription("DR Component A").setCreatedBy(USER_EMAIL1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic1"))).setCreatedOn("2022-07-20"); @@ -1300,7 +1300,7 @@ private void createTestRecords002() { } } - private void createTestRecords002(int maxLink, int depth, List releaseIdList, List componentIdList) { + private void createTestRecords002(int maxLink, int depth, List releaseIdList, List componentIdList) throws SW360Exception { //create root node String componentId = String.format("dr_%08x", treeNodeCreateReleaseCounter); treeNodeCreateReleaseCounter++; @@ -1323,7 +1323,7 @@ private void createTestRecords002(int maxLink, int depth, List releaseId createReleaseTree(releaseId, 0, releaseIdList, componentIdList); } - private void createReleaseTree(String parentId, int level, List outReleaseIdList, List< String> outComponentIdList) { + private void createReleaseTree(String parentId, int level, List outReleaseIdList, List< String> outComponentIdList) throws SW360Exception { //create a compoent String componentId = String.format("dr_%08x", treeNodeCreateReleaseCounter); treeNodeCreateReleaseCounter++; diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java b/backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java similarity index 99% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java rename to backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java index b0760eeea3..5920c59018 100644 --- a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java +++ b/backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentDatabaseHandlerTest.java @@ -15,9 +15,9 @@ import org.eclipse.sw360.common.utils.BackendUtils; import org.eclipse.sw360.datahandler.TestUtils; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.common.SW360Constants; import org.eclipse.sw360.datahandler.common.DatabaseSettingsTest; -import org.eclipse.sw360.datahandler.couchdb.DatabaseConnector; import org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler; import org.eclipse.sw360.datahandler.db.SvmConnector; import org.eclipse.sw360.datahandler.entitlement.ComponentModerator; @@ -141,7 +141,7 @@ public void setUp() throws Exception { TestUtils.createDatabase(DatabaseSettingsTest.getConfiguredClient(), dbName); // Prepare the database - DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettingsTest.getConfiguredHttpClient(), dbName); + DatabaseConnectorCloudant databaseConnector = new DatabaseConnectorCloudant(DatabaseSettingsTest.getConfiguredClient(), dbName); for (Vendor vendor : vendors.values()) { databaseConnector.add(vendor); diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java b/backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java similarity index 94% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java rename to backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java index 23e1bd44e5..5db44dbe5c 100644 --- a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java +++ b/backend/components/src/test/java/org/eclipse/sw360/components/db/ComponentSearchHandlerTest.java @@ -12,9 +12,8 @@ import com.google.common.collect.ImmutableSet; import org.eclipse.sw360.datahandler.TestUtils; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; import org.eclipse.sw360.datahandler.common.DatabaseSettingsTest; -import org.eclipse.sw360.datahandler.couchdb.DatabaseConnector; -import org.eclipse.sw360.datahandler.couchdb.DatabaseInstance; import org.eclipse.sw360.datahandler.db.ComponentSearchHandler; import org.eclipse.sw360.datahandler.thrift.ThriftClients; import org.eclipse.sw360.datahandler.thrift.components.Component; @@ -77,14 +76,14 @@ public void setUp() throws Exception { TestUtils.createDatabase(DatabaseSettingsTest.getConfiguredClient(), dbName); // Prepare the database - DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettingsTest.getConfiguredHttpClient(), dbName); + DatabaseConnectorCloudant databaseConnector = new DatabaseConnectorCloudant(DatabaseSettingsTest.getConfiguredClient(), dbName); for (Component component : components) { databaseConnector.add(component); } // Prepare the handler - searchHandler = new ComponentSearchHandler(DatabaseSettingsTest.getConfiguredHttpClient(), DatabaseSettingsTest.getConfiguredClient(), dbName); + searchHandler = new ComponentSearchHandler(DatabaseSettingsTest.getConfiguredClient(), dbName); } @After diff --git a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java b/backend/components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java similarity index 83% rename from backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java rename to backend/components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java index 5180369493..4c17abcfd5 100644 --- a/backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java +++ b/backend/components/src/test/java/org/eclipse/sw360/components/db/ProjectDatabaseHandlerTest.java @@ -14,8 +14,7 @@ import org.eclipse.sw360.datahandler.TestUtils; import org.eclipse.sw360.datahandler.common.DatabaseSettingsTest; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; -import org.eclipse.sw360.datahandler.common.DatabaseSettings; -import org.eclipse.sw360.datahandler.couchdb.DatabaseConnector; +import org.eclipse.sw360.datahandler.common.SW360Constants; import org.eclipse.sw360.datahandler.db.AttachmentDatabaseHandler; import org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler; import org.eclipse.sw360.datahandler.db.PackageDatabaseHandler; @@ -31,7 +30,6 @@ import org.eclipse.sw360.datahandler.thrift.components.ReleaseLink; import org.eclipse.sw360.datahandler.thrift.projects.*; import org.eclipse.sw360.datahandler.thrift.users.User; -import org.eclipse.sw360.datahandler.thrift.users.UserGroup; import org.eclipse.sw360.datahandler.thrift.vendors.Vendor; import org.junit.After; import org.junit.Before; @@ -40,10 +38,8 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; -import javax.xml.crypto.Data; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -53,8 +49,6 @@ import static org.eclipse.sw360.datahandler.TestUtils.assertTestString; import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class ProjectDatabaseHandlerTest { @@ -75,8 +69,7 @@ public class ProjectDatabaseHandlerTest { @Mock private ProjectModerator moderator; - @Mock - private User user; + private static final User user = new User().setEmail("admin@sw360.org").setDepartment("DEPARTMENT"); @Before public void setUp() throws Exception { @@ -106,9 +99,59 @@ public void setUp() throws Exception { projects = new ArrayList<>(); Project project1 = new Project().setId("P1").setName("project1").setLinkedProjects(ImmutableMap.of("P2", new ProjectProjectRelationship(ProjectRelationship.CONTAINED))).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER); projects.add(project1); - Project project2 = new Project().setId("P2").setName("project2").setLinkedProjects(ImmutableMap.of("P3", new ProjectProjectRelationship(ProjectRelationship.REFERRED), "P4", new ProjectProjectRelationship(ProjectRelationship.CONTAINED))).setReleaseIdToUsage(ImmutableMap.of("R1A", newDefaultProjectReleaseRelationship(), "R1B", newDefaultProjectReleaseRelationship())).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER); + Project project2 = new Project().setId("P2").setName("project2").setLinkedProjects(ImmutableMap.of("P3", new ProjectProjectRelationship(ProjectRelationship.REFERRED), "P4", new ProjectProjectRelationship(ProjectRelationship.CONTAINED))).setReleaseIdToUsage(ImmutableMap.of("R1A", newDefaultProjectReleaseRelationship(), "R1B", newDefaultProjectReleaseRelationship())).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER) + .setReleaseRelationNetwork( + """ + [ + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"R1A", + "releaseRelationship":"REFERRED" + }, + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"R1B", + "releaseRelationship":"REFERRED" + } + ] + """ + ); + projects.add(project2); - Project project3 = new Project().setId("P3").setName("project3").setLinkedProjects(ImmutableMap.of("P2", new ProjectProjectRelationship(ProjectRelationship.UNKNOWN))).setReleaseIdToUsage(ImmutableMap.of("R2A", newDefaultProjectReleaseRelationship(), "R2B", newDefaultProjectReleaseRelationship())).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER); + Project project3 = new Project().setId("P3").setName("project3").setLinkedProjects(ImmutableMap.of("P2", new ProjectProjectRelationship(ProjectRelationship.UNKNOWN))).setReleaseIdToUsage(ImmutableMap.of("R2A", newDefaultProjectReleaseRelationship(), "R2B", newDefaultProjectReleaseRelationship())).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER) + .setReleaseRelationNetwork( + """ + [ + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"R2A", + "releaseRelationship":"REFERRED" + }, + { + "comment": "", + "releaseLink":[], + "createBy":"admin@sw360.org", + "createOn":"2022-08-15", + "mainlineState":"MAINLINE", + "releaseId":"R2B", + "releaseRelationship":"REFERRED" + } + ] + """ + ); + projects.add(project3); Project project4 = new Project().setId("P4").setName("project4").setLinkedProjects(ImmutableMap.of("P1", new ProjectProjectRelationship(ProjectRelationship.UNKNOWN))).setVisbility(Visibility.EVERYONE).setProjectType(ProjectType.CUSTOMER); projects.add(project4); @@ -173,6 +216,37 @@ public void testGetLinkedProjects() throws Exception { ReleaseLink releaseLinkR2A = new ReleaseLink("R2A", "vendor", "component2", "releaseA", "vendor component2 releaseA", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R2A").setComponentType(ComponentType.COTS).setAccessible(true); ReleaseLink releaseLinkR2B = new ReleaseLink("R2B", "vendor", "component2", "releaseB", "vendor component2 releaseB", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R2B").setComponentType(ComponentType.COTS).setAccessible(true); + if (SW360Constants.ENABLE_FLEXIBLE_PROJECT_RELEASE_RELATIONSHIP) { + releaseLinkR1A.setParentNodeId(""); + releaseLinkR1A.setAttachments(new ArrayList<>()); + releaseLinkR1A.setProjectId("P2"); + releaseLinkR1A.setComment(""); + releaseLinkR1A.setIndex(0); + releaseLinkR1A.setLayer(0); + + releaseLinkR1B.setParentNodeId(""); + releaseLinkR1B.setAttachments(new ArrayList<>()); + releaseLinkR1B.setProjectId("P2"); + releaseLinkR1B.setComment(""); + releaseLinkR1B.setIndex(1); + releaseLinkR1B.setLayer(0); + + + releaseLinkR2A.setParentNodeId(""); + releaseLinkR2A.setAttachments(new ArrayList<>()); + releaseLinkR2A.setProjectId("P3"); + releaseLinkR2A.setComment(""); + releaseLinkR2A.setIndex(0); + releaseLinkR2A.setLayer(0); + + releaseLinkR2B.setParentNodeId(""); + releaseLinkR2B.setAttachments(new ArrayList<>()); + releaseLinkR2B.setProjectId("P3"); + releaseLinkR2B.setComment(""); + releaseLinkR2B.setIndex(1); + releaseLinkR2B.setLayer(0); + } + ProjectLink link3 = new ProjectLink("P3", "project3") .setRelation(ProjectRelationship.REFERRED) .setEnableSvm(true) diff --git a/backend/src/src-cvesearch/pom.xml b/backend/cvesearch/pom.xml similarity index 63% rename from backend/src/src-cvesearch/pom.xml rename to backend/cvesearch/pom.xml index 3181ecb22b..c0f42f83f0 100644 --- a/backend/src/src-cvesearch/pom.xml +++ b/backend/cvesearch/pom.xml @@ -16,28 +16,32 @@ org.eclipse.sw360 - backend-src - ${revision} + backend + 19.0.0 - src-cvesearch - jar - src-cvesearch + backend-cvesearch + war + backend-cvesearch + cvesearch + + ${backend.deploy.dir} + org.eclipse.sw360 - datahandler + backend-vulnerabilities-core ${project.version} - org.eclipse.sw360 - src-vulnerabilities - ${project.version} - + org.eclipse.sw360 + backend-common + ${project.version} + com.google.code.gson gson - + diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java similarity index 95% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java index 39563c222d..0b7b7f1290 100644 --- a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java +++ b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnector.java @@ -10,7 +10,7 @@ */ package org.eclipse.sw360.cvesearch.datasink; -import com.cloudant.client.api.CloudantClient; +import com.ibm.cloud.cloudant.v1.Cloudant; import com.google.common.base.Strings; import org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant; @@ -26,11 +26,9 @@ import org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability; import org.eclipse.sw360.vulnerabilities.common.VulnerabilityMapper; import org.eclipse.sw360.vulnerabilities.db.VulnerabilityDatabaseHandler; -import org.ektorp.http.HttpClient; import java.io.IOException; import java.util.*; -import java.util.function.Supplier; public class VulnerabilityConnector { @@ -52,11 +50,11 @@ public VulnerabilityConnector() throws IOException{ projectRepository = new ProjectRepository(db); } - public VulnerabilityConnector(Supplier cclient, Supplier hclient, String vmdbName, String dbName, String attchmntDbName) throws IOException { - DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(cclient, dbName); + public VulnerabilityConnector(Cloudant client, String vmdbName, String dbName, String attchmntDbName) throws IOException { + DatabaseConnectorCloudant db = new DatabaseConnectorCloudant(client, dbName); - vulnerabilityDatabaseHandler = new VulnerabilityDatabaseHandler(hclient, vmdbName); - projectDatabaseHandler = new ProjectDatabaseHandler(cclient, dbName, attchmntDbName); + vulnerabilityDatabaseHandler = new VulnerabilityDatabaseHandler(client, vmdbName); + projectDatabaseHandler = new ProjectDatabaseHandler(client, dbName, attchmntDbName); vendorRepository = new VendorRepository(db); releaseRepository = new ReleaseRepository(db, vendorRepository); componentRepository = new ComponentRepository(db, releaseRepository, vendorRepository); diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApi.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApi.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApi.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApi.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImpl.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImpl.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImpl.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImpl.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchData.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchData.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchData.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchData.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesser.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesser.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesser.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesser.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapper.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapper.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapper.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapper.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/Heuristic.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/Heuristic.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/Heuristic.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/Heuristic.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevels.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevels.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevels.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevels.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParser.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParser.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParser.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParser.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/ListCveSearchJsonParser.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/ListCveSearchJsonParser.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/ListCveSearchJsonParser.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/ListCveSearchJsonParser.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/SingleCveSearchJsonParser.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/SingleCveSearchJsonParser.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/SingleCveSearchJsonParser.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/json/SingleCveSearchJsonParser.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcher.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcher.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcher.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcher.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/Match.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/Match.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/Match.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/Match.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistance.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistance.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistance.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistance.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToReleaseVulnerabilityRelationTranslator.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToReleaseVulnerabilityRelationTranslator.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToReleaseVulnerabilityRelationTranslator.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToReleaseVulnerabilityRelationTranslator.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToVulnerabilityTranslator.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToVulnerabilityTranslator.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToVulnerabilityTranslator.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataToVulnerabilityTranslator.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslator.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslator.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslator.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslator.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/EntityTranslator.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/EntityTranslator.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/EntityTranslator.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/entitytranslation/EntityTranslator.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtils.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtils.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtils.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtils.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchHandler.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchHandler.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchHandler.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchHandler.java diff --git a/backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchServlet.java b/backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchServlet.java similarity index 100% rename from backend/src/src-cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchServlet.java rename to backend/cvesearch/src/main/java/org/eclipse/sw360/cvesearch/service/CveSearchServlet.java diff --git a/backend/src/src-cvesearch/src/main/resources/cvesearch.properties b/backend/cvesearch/src/main/resources/cvesearch.properties similarity index 100% rename from backend/src/src-cvesearch/src/main/resources/cvesearch.properties rename to backend/cvesearch/src/main/resources/cvesearch.properties diff --git a/backend/src/src-cvesearch/src/main/resources/sw360.properties b/backend/cvesearch/src/main/resources/sw360.properties similarity index 100% rename from backend/src/src-cvesearch/src/main/resources/sw360.properties rename to backend/cvesearch/src/main/resources/sw360.properties diff --git a/backend/svc/svc-cvesearch/src/main/webapp/WEB-INF/web.xml b/backend/cvesearch/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-cvesearch/src/main/webapp/WEB-INF/web.xml rename to backend/cvesearch/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-cvesearch/src/main/webapp/index.jsp b/backend/cvesearch/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-cvesearch/src/main/webapp/index.jsp rename to backend/cvesearch/src/main/webapp/index.jsp diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/TestWithCveSearchConnection.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/TestWithCveSearchConnection.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/TestWithCveSearchConnection.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/TestWithCveSearchConnection.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java similarity index 98% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java index 2f494e6efd..8b98778e65 100644 --- a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java +++ b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasink/VulnerabilityConnectorTest.java @@ -39,7 +39,7 @@ public class VulnerabilityConnectorTest { @Before public void setUp() throws Exception { - vulnerabilityConnector = new VulnerabilityConnector(DatabaseSettingsTest.getConfiguredClient(), DatabaseSettingsTest.getConfiguredHttpClient(), DatabaseSettingsTest.COUCH_DB_VM, DatabaseSettingsTest.COUCH_DB_DATABASE, DatabaseSettingsTest.COUCH_DB_ATTACHMENTS); + vulnerabilityConnector = new VulnerabilityConnector(DatabaseSettingsTest.getConfiguredClient(), DatabaseSettingsTest.COUCH_DB_VM, DatabaseSettingsTest.COUCH_DB_DATABASE, DatabaseSettingsTest.COUCH_DB_ATTACHMENTS); vulnerabilityConnector.vulnerabilityDatabaseHandler = vulnerabilityDatabaseHandler; statusToVulnerabilityMap = new HashMap<>(); for (UpdateType updateType: UpdateType.values()){ diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImplTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImplTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImplTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchApiImplTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchDataTestHelper.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchDataTestHelper.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchDataTestHelper.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchDataTestHelper.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesserTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesserTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesserTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchGuesserTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapperTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapperTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapperTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/CveSearchWrapperTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevelsTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevelsTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevelsTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/heuristics/SearchLevelsTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParserTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParserTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParserTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/json/CveSearchJsonParserTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcherTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcherTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcherTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ListMatcherTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistanceTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistanceTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistanceTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/datasource/matcher/ModifiedLevenshteinDistanceTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslatorTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslatorTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslatorTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/entitytranslation/CveSearchDataTranslatorTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtilsTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtilsTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtilsTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/helper/VulnerabilityUtilsTest.java diff --git a/backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/service/CveSearchHandlerTest.java b/backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/service/CveSearchHandlerTest.java similarity index 100% rename from backend/src/src-cvesearch/src/test/java/org/eclipse/sw360/cvesearch/service/CveSearchHandlerTest.java rename to backend/cvesearch/src/test/java/org/eclipse/sw360/cvesearch/service/CveSearchHandlerTest.java diff --git a/backend/src/src-cvesearch/src/test/resources/cvesearch.properties b/backend/cvesearch/src/test/resources/cvesearch.properties similarity index 100% rename from backend/src/src-cvesearch/src/test/resources/cvesearch.properties rename to backend/cvesearch/src/test/resources/cvesearch.properties diff --git a/backend/src/src-cvesearch/src/test/resources/sw360.properties b/backend/cvesearch/src/test/resources/sw360.properties similarity index 100% rename from backend/src/src-cvesearch/src/test/resources/sw360.properties rename to backend/cvesearch/src/test/resources/sw360.properties diff --git a/backend/src/src-fossology/pom.xml b/backend/fossology/pom.xml similarity index 75% rename from backend/src/src-fossology/pom.xml rename to backend/fossology/pom.xml index a6930023d9..d21ae078b9 100644 --- a/backend/src/src-fossology/pom.xml +++ b/backend/fossology/pom.xml @@ -14,15 +14,23 @@ 4.0.0 org.eclipse.sw360 - backend-src - ${revision} + backend + 19.0.0 - src-fossology - jar - src-fossology - + backend-fossology + war + backend-fossology + + ${backend.deploy.dir} + + fossology + + org.eclipse.sw360 + backend-common + ${project.version} + com.jcraft jsch @@ -52,4 +60,4 @@ jackson-databind - \ No newline at end of file + diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java similarity index 95% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java index cd796555ec..0fa7b984a1 100644 --- a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java +++ b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/FossologyHandler.java @@ -9,6 +9,7 @@ */ package org.eclipse.sw360.fossology; +import org.eclipse.sw360.common.utils.BackendUtils; import org.eclipse.sw360.datahandler.common.CommonUtils; import org.eclipse.sw360.datahandler.common.FossologyUtils; import org.eclipse.sw360.datahandler.common.SW360Utils; @@ -63,6 +64,7 @@ public class FossologyHandler implements FossologyService.Iface { private static final String SCAN_RESPONSE_STATUS_VALUE_PROCESSING = "Processing"; private static final String SCAN_RESPONSE_STATUS_VALUE_COMPLETED = "Completed"; private static final String SCAN_RESPONSE_STATUS_VALUE_FAILED = "Failed"; + boolean reportStep = false; @Autowired public FossologyHandler(ThriftClients thriftClients, FossologyRestConfig fossologyRestConfig, @@ -162,7 +164,9 @@ public ExternalToolProcess process(String releaseId, User user, String uploadDes handleUploadStep(componentClient, release, user, fossologyProcess, sourceAttachment, uploadDescription); } else if (FossologyUtils.FOSSOLOGY_STEP_NAME_SCAN.equals(furthestStep.getStepName())) { handleScanStep(componentClient, release, user, fossologyProcess); - } else if (FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT.equals(furthestStep.getStepName())) { + } else if(!BackendUtils.DISABLE_CLEARING_FOSSOLOGY_REPORT_DOWNLOAD && FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT.equals(furthestStep.getStepName())) { + handleReportStep(componentClient, release, user, fossologyProcess); + } else if(reportStep && FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT.equals(furthestStep.getStepName())) { handleReportStep(componentClient, release, user, fossologyProcess); } @@ -176,7 +180,7 @@ private void updateFossologyProcessInRelease(ExternalToolProcess fossologyProces // because our workflow in between might have taken some time, we have to // refetch the release to get the current version (as another thread might have // written changes to the release which results in a new version so that we - // would get a org.ektorp.UpdateConflictException on trying to write) + // would get a conflict error on trying to write) release = componentClient.getReleaseById(release.getId(), user); Iterator oldFossologyProcessIterator = SW360Utils .getNotOutdatedExternalToolProcessesForTool(release, ExternalTool.FOSSOLOGY).iterator(); @@ -221,7 +225,7 @@ private ClearingState calculateCurrentClearingState(Release release, ExternalToo switch (furthestStep.getStepStatus()) { case IN_WORK: case DONE: - result = ClearingState.UNDER_CLEARING; + result = ClearingState.SENT_TO_CLEARING_TOOL; break; case NEW: default: @@ -393,8 +397,10 @@ private void handleScanStep(Iface componentClient, Release release, User user, break; case DONE: // start report - fossologyProcess.addToProcessSteps(createFossologyProcessStep(user, FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT)); - handleReportStep(componentClient, release, user, fossologyProcess); + if(!BackendUtils.DISABLE_CLEARING_FOSSOLOGY_REPORT_DOWNLOAD) { + fossologyProcess.addToProcessSteps(createFossologyProcessStep(user, FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT)); + handleReportStep(componentClient, release, user, fossologyProcess); + } break; default: // do nothing, unknown status @@ -405,6 +411,7 @@ private void handleReportStep(Iface componentClient, Release release, User user, ExternalToolProcess fossologyProcess) throws TException { ExternalToolProcessStep furthestStep = fossologyProcess.getProcessSteps() .get(fossologyProcess.getProcessSteps().size() - 1); + switch (furthestStep.getStepStatus()) { case NEW: // generate report, set new state immediately to prevent other threads from @@ -425,6 +432,7 @@ private void handleReportStep(Iface componentClient, Release release, User user, // try to download report - since download might take a bit longer, we first set // the state to done so that no one else downloads the same report. if download // fails, we reset the state + furthestStep.setStepStatus(ExternalToolProcessStatus.DONE); updateFossologyProcessInRelease(fossologyProcess, release, user, componentClient); @@ -497,6 +505,9 @@ public RequestStatus triggerReportGenerationFossology(String releaseId, User use if (extToolProcess.getProcessSteps().size() > 2) { extToolProcess.getProcessSteps().get(extToolProcess.getProcessSteps().size() - 1) .setStepStatus(ExternalToolProcessStatus.NEW); + } else if (extToolProcess.getProcessSteps().size() == 2 && BackendUtils.DISABLE_CLEARING_FOSSOLOGY_REPORT_DOWNLOAD) { + extToolProcess.addToProcessSteps(createFossologyProcessStep(user, FossologyUtils.FOSSOLOGY_STEP_NAME_REPORT)); + reportStep = true; } else { log.info("Either the source of release with id {} is not yet uploaded or not yet scanned", releaseId); return RequestStatus.FAILURE; diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/FossologyServlet.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/FossologyServlet.java similarity index 100% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/FossologyServlet.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/FossologyServlet.java diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java similarity index 91% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java index c59b102e70..1a5f8c5069 100644 --- a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java +++ b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/SpringTServlet.java @@ -15,9 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; @RequestMapping("/thrift") diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyConfig.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyConfig.java similarity index 100% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyConfig.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyConfig.java diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java similarity index 87% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java index 8bb6e9b3ca..c1789394b4 100644 --- a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java +++ b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/config/FossologyRestConfig.java @@ -15,6 +15,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.eclipse.sw360.datahandler.thrift.SW360Exception; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,7 +43,7 @@ public class FossologyRestConfig { private boolean outdated; @Autowired - public FossologyRestConfig(ConfigContainerRepository repository) { + public FossologyRestConfig(ConfigContainerRepository repository) throws SW360Exception { this.repository = repository; // eager loading (or initial insert) get(); @@ -67,7 +68,12 @@ public String getFolderId() { } private String getFirstValue(String key) { - return get().getConfigKeyToValues().getOrDefault(key, new HashSet<>()).stream().findFirst().orElse(null); + try { + return get().getConfigKeyToValues().getOrDefault(key, new HashSet<>()).stream().findFirst().orElse(null); + } catch (SW360Exception e) { + log.error(e); + return null; + } } public ConfigContainer update(ConfigContainer newConfig) { @@ -97,7 +103,13 @@ public ConfigContainer update(ConfigContainer newConfig) { throw new IllegalStateException("The new FOSSology REST configuration does not contain a valid folder id."); } - ConfigContainer current = get(); + ConfigContainer current; + try { + current = get(); + } catch (SW360Exception e) { + log.error(e); + throw new IllegalStateException("Unable to get container config."); + } current.setConfigKeyToValues(newConfig.getConfigKeyToValues()); repository.update(current); @@ -108,7 +120,7 @@ public ConfigContainer update(ConfigContainer newConfig) { return current; } - public ConfigContainer get() { + public ConfigContainer get() throws SW360Exception { if (config == null || outdated) { try { config = repository.getByConfigFor(ConfigFor.FOSSOLOGY_REST); diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyInputStreamResource.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyInputStreamResource.java similarity index 100% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyInputStreamResource.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyInputStreamResource.java diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyResponse.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyResponse.java similarity index 100% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyResponse.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyResponse.java diff --git a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java similarity index 99% rename from backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java rename to backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java index c6cf11f16e..b9b279e69d 100644 --- a/backend/src/src-fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java +++ b/backend/fossology/src/main/java/org/eclipse/sw360/fossology/rest/FossologyRestClient.java @@ -103,7 +103,6 @@ public FossologyRestClient(ObjectMapper objectMapper, FossologyRestConfig restCo this.restConfig = restConfig; SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); - requestFactory.setBufferRequestBody(false); restTemplate.setRequestFactory(requestFactory); this.restTemplate = restTemplate; } diff --git a/backend/svc/svc-fossology/src/main/webapp/WEB-INF/web.xml b/backend/fossology/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-fossology/src/main/webapp/WEB-INF/web.xml rename to backend/fossology/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-fossology/src/main/webapp/index.jsp b/backend/fossology/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-fossology/src/main/webapp/index.jsp rename to backend/fossology/src/main/webapp/index.jsp diff --git a/backend/src/src-fossology/src/test/java/org/eclipse/sw360/fossology/FossologyHandlerLocalhostIntegrationTest.java b/backend/fossology/src/test/java/org/eclipse/sw360/fossology/FossologyHandlerLocalhostIntegrationTest.java similarity index 100% rename from backend/src/src-fossology/src/test/java/org/eclipse/sw360/fossology/FossologyHandlerLocalhostIntegrationTest.java rename to backend/fossology/src/test/java/org/eclipse/sw360/fossology/FossologyHandlerLocalhostIntegrationTest.java diff --git a/backend/src/src-fossology/src/test/java/org/eclipse/sw360/fossology/config/TestConfig.java b/backend/fossology/src/test/java/org/eclipse/sw360/fossology/config/TestConfig.java similarity index 100% rename from backend/src/src-fossology/src/test/java/org/eclipse/sw360/fossology/config/TestConfig.java rename to backend/fossology/src/test/java/org/eclipse/sw360/fossology/config/TestConfig.java diff --git a/backend/health/pom.xml b/backend/health/pom.xml new file mode 100644 index 0000000000..7c6377c14c --- /dev/null +++ b/backend/health/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + org.eclipse.sw360 + backend + 19.0.0 + + + backend-health + war + backend-health + + ${backend.deploy.dir} + + + health + + + + + org.eclipse.sw360 + backend-common + ${project.version} + + + junit + junit + test + + + + diff --git a/backend/src/src-health/src/main/java/org/eclipse/sw360/health/HealthHandler.java b/backend/health/src/main/java/org/eclipse/sw360/health/HealthHandler.java similarity index 82% rename from backend/src/src-health/src/main/java/org/eclipse/sw360/health/HealthHandler.java rename to backend/health/src/main/java/org/eclipse/sw360/health/HealthHandler.java index 2b6e1eb4b0..037b8d368b 100644 --- a/backend/src/src-health/src/main/java/org/eclipse/sw360/health/HealthHandler.java +++ b/backend/health/src/main/java/org/eclipse/sw360/health/HealthHandler.java @@ -9,15 +9,14 @@ */ package org.eclipse.sw360.health; +import com.ibm.cloud.cloudant.v1.Cloudant; import org.eclipse.sw360.datahandler.common.DatabaseSettings; import org.eclipse.sw360.datahandler.thrift.health.Health; import org.eclipse.sw360.datahandler.thrift.health.HealthService; import org.eclipse.sw360.health.db.HealthDatabaseHandler; -import org.ektorp.http.HttpClient; import java.net.MalformedURLException; import java.util.Set; -import java.util.function.Supplier; /** * Implementation of the thrift service "Health" @@ -27,11 +26,11 @@ public class HealthHandler implements HealthService.Iface { private final HealthDatabaseHandler handler; HealthHandler() throws MalformedURLException { - handler = new HealthDatabaseHandler(DatabaseSettings.getConfiguredHttpClient()); + handler = new HealthDatabaseHandler(DatabaseSettings.getConfiguredClient()); } - HealthHandler(Supplier httpClient) throws MalformedURLException { - handler = new HealthDatabaseHandler(httpClient); + HealthHandler(Cloudant client) throws MalformedURLException { + handler = new HealthDatabaseHandler(client); } @Override diff --git a/backend/src/src-health/src/main/java/org/eclipse/sw360/health/HealthServlet.java b/backend/health/src/main/java/org/eclipse/sw360/health/HealthServlet.java similarity index 100% rename from backend/src/src-health/src/main/java/org/eclipse/sw360/health/HealthServlet.java rename to backend/health/src/main/java/org/eclipse/sw360/health/HealthServlet.java diff --git a/backend/src/src-health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java b/backend/health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java similarity index 81% rename from backend/src/src-health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java rename to backend/health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java index 299086a83b..a034e8f9e2 100644 --- a/backend/src/src-health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java +++ b/backend/health/src/main/java/org/eclipse/sw360/health/db/HealthDatabaseHandler.java @@ -10,29 +10,28 @@ package org.eclipse.sw360.health.db; import com.google.common.collect.ImmutableSet; +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException; +import org.eclipse.sw360.datahandler.cloudantclient.DatabaseInstanceCloudant; import org.eclipse.sw360.datahandler.common.DatabaseSettings; -import org.eclipse.sw360.datahandler.couchdb.DatabaseInstance; import org.eclipse.sw360.datahandler.thrift.health.Health; import org.eclipse.sw360.datahandler.thrift.health.Status; -import org.ektorp.DbAccessException; -import org.ektorp.http.HttpClient; import java.net.MalformedURLException; import java.util.HashMap; import java.util.Set; -import java.util.function.Supplier; public class HealthDatabaseHandler { - private final DatabaseInstance db; + private final DatabaseInstanceCloudant db; public static final Set DATABASES_TO_CHECK = ImmutableSet.of( DatabaseSettings.COUCH_DB_ATTACHMENTS, DatabaseSettings.COUCH_DB_DATABASE, DatabaseSettings.COUCH_DB_USERS); - public HealthDatabaseHandler(Supplier httpClient) throws MalformedURLException { - db = new DatabaseInstance(httpClient.get()); + public HealthDatabaseHandler(Cloudant client) throws MalformedURLException { + db = new DatabaseInstanceCloudant(client); } public Health getHealth() { @@ -47,7 +46,7 @@ private Health getHealthOfDbs(Set dbsTocheck) { if (!db.checkIfDbExists(database)) { health.getDetails().put(database, String.format("The database '%s' does not exist.", database)); } - } catch (DbAccessException e) { + } catch (ServiceUnavailableException e) { health.getDetails().put(database, e.getMessage()); } } diff --git a/backend/svc/svc-health/src/main/webapp/WEB-INF/web.xml b/backend/health/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from backend/svc/svc-health/src/main/webapp/WEB-INF/web.xml rename to backend/health/src/main/webapp/WEB-INF/web.xml diff --git a/backend/svc/svc-health/src/main/webapp/index.jsp b/backend/health/src/main/webapp/index.jsp similarity index 100% rename from backend/svc/svc-health/src/main/webapp/index.jsp rename to backend/health/src/main/webapp/index.jsp diff --git a/backend/src/src-health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java b/backend/health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java similarity index 95% rename from backend/src/src-health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java rename to backend/health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java index 7420d37f12..a7c2612f9d 100644 --- a/backend/src/src-health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java +++ b/backend/health/src/test/java/org/eclipse/sw360/health/HealthHandlerTest.java @@ -33,7 +33,7 @@ public class HealthHandlerTest { @Test public void testGetHealthFailsUponMissingDB() throws MalformedURLException { TestUtils.deleteAllDatabases(); - HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredHttpClient()); + HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredClient()); final Health health = healthHandler.getHealthOfSpecificDbs(DATABASES_TO_CHECK); assertEquals(Status.DOWN, health.status); assertEquals(DATABASES_TO_CHECK.size(), health.getDetails().size()); @@ -45,7 +45,7 @@ public void testGetHealth() throws MalformedURLException { TestUtils.createDatabase(DatabaseSettingsTest.getConfiguredClient(), database); } - HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredHttpClient()); + HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredClient()); final Health health = healthHandler.getHealthOfSpecificDbs(DATABASES_TO_CHECK); assertEquals(Status.UP, health.status); assertEquals(new HashMap<>(), health.getDetails()); @@ -60,7 +60,7 @@ public void testGetHealthWithPartialDBMissing() throws MalformedURLException { final String couchDbDatabase = DatabaseSettingsTest.COUCH_DB_DATABASE; TestUtils.createDatabase(DatabaseSettingsTest.getConfiguredClient(), couchDbDatabase); - HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredHttpClient()); + HealthHandler healthHandler = new HealthHandler(DatabaseSettingsTest.getConfiguredClient()); final Health health = healthHandler.getHealthOfSpecificDbs(DATABASES_TO_CHECK); assertEquals(Status.ERROR, health.getStatus()); assertEquals(DATABASES_TO_CHECK.size() -1, health.getDetails().size()); diff --git a/backend/src/src-licenseinfo/pom.xml b/backend/licenseinfo/pom.xml similarity index 57% rename from backend/src/src-licenseinfo/pom.xml rename to backend/licenseinfo/pom.xml index 8168fd4c06..2ebc998bd0 100644 --- a/backend/src/src-licenseinfo/pom.xml +++ b/backend/licenseinfo/pom.xml @@ -13,32 +13,24 @@ org.eclipse.sw360 - backend-src - ${revision} + backend + 19.0.0 - src-licenseinfo - jar - src-licenseinfo + backend-licenseinfo + war + backend-licenseinfo + licenseinfo + + ${backend.deploy.dir} + org.eclipse.sw360 - src-attachments + backend-common ${project.version} - - org.spdx - tools-java - - - org.apache.logging.log4j - log4j-1.2-api - - - org.apache.commons - commons-lang3 - org.apache.velocity velocity-engine-core @@ -48,20 +40,8 @@ velocity-tools-generic - org.apache.poi - poi - - - org.apache.poi - poi-ooxml - - - net.sf.saxon - saxon-dom - - - junit - junit + org.dom4j + dom4j test @@ -69,11 +49,6 @@ junit-dataprovider test - - org.dom4j - dom4j - test - jaxen jaxen diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java similarity index 97% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java index 19176dd04a..57b2574de9 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java @@ -127,6 +127,16 @@ public LicenseInfoFile getLicenseInfoFile(Project project, User user, String out Map> releaseIdsToSelectedAttachmentIds, Map> excludedLicensesPerAttachment, String externalIds, String fileName) throws TException { + return getLicenseInfoFileWithoutReleaseVersion(project, user, outputGenerator, + releaseIdsToSelectedAttachmentIds, excludedLicensesPerAttachment, externalIds, fileName, false); + } + + @Override + public LicenseInfoFile getLicenseInfoFileWithoutReleaseVersion(Project project, User user, String outputGenerator, + Map> releaseIdsToSelectedAttachmentIds, + Map> excludedLicensesPerAttachment, String externalIds, String fileName, + boolean excludeReleaseVersion) + throws TException { assertNotNull(project); assertNotNull(user); assertNotNull(outputGenerator); @@ -170,7 +180,7 @@ public LicenseInfoFile getLicenseInfoFile(Project project, User user, String out } Object output = generator.generateOutputFile(projectLicenseInfoResults, project, obligationsResults, user, - filteredExtIdMap, obligationsStatusInfoMap, fileName); + filteredExtIdMap, obligationsStatusInfoMap, fileName, excludeReleaseVersion); if (output instanceof byte[]) { licenseInfoFile.setGeneratedOutput((byte[]) output); } else if (output instanceof String) { @@ -182,6 +192,7 @@ public LicenseInfoFile getLicenseInfoFile(Project project, User user, String out return licenseInfoFile; } + @Override public Map> evaluateAttachments(String releaseId, User user) throws TException { Release release = componentDatabaseHandler.getRelease(releaseId, user); Map parsedResults = new HashMap(); @@ -589,7 +600,7 @@ public List getLicenseInfoForAttachment(Release releas .filter(parser -> wrapTException(() -> parser.isApplicableTo(attachment, user, release))).collect(Collectors.toList()); if (applicableParsers.size() == 0) { - LOGGER.warn("No applicable parser has been found for the attachment selected for license information"); + LOGGER.warn("No applicable parser has been found for the attachment selected for license information " + attachmentContentId); return assignReleaseToLicenseInfoParsingResult( assignFileNameToLicenseInfoParsingResult( noSourceParsingResult("No applicable parser has been found for the attachment"), attachment.getFilename()), @@ -619,7 +630,7 @@ public List getLicenseInfoForAttachment(Release releas } @Override - public LicenseObligationsStatusInfo getProjectObligationStatus(Map obligationStatusMap, List licenseResults, + public LicenseObligationsStatusInfo getProjectObligationStatus(Map obligationStatusMap, List licenseResults, Map excludedReleaseIdToAcceptedCLI) { Map filteredObligationStatusMap = obligationStatusMap.isEmpty() @@ -722,15 +733,20 @@ private Map createLicenseToObligationMappingForRep return obligationStatusMap; } - Map attachmentIdToLicenseMap = licenseResults.stream() + Map attachmentIdToLicenseMap = licenseResults.parallelStream() .filter(LicenseInfoParsingResult::isSetAttachmentContentId) - .filter(LicenseInfoParsingResult::isSetLicenseInfo).collect(Collectors.toList()).stream() - .collect(Collectors.toMap(LicenseInfoParsingResult::getAttachmentContentId, Function.identity())); - - Map attachmentIdToObligationMap = obligationResults.stream() - .filter(ObligationParsingResult::isSetAttachmentContentId).filter(o -> o.getObligationsAtProjectSize() > 0) - .collect(Collectors.toList()).stream() - .collect(Collectors.toMap(ObligationParsingResult::getAttachmentContentId, Function.identity())); + .filter(LicenseInfoParsingResult::isSetLicenseInfo) + .collect(Collectors.toMap( + LicenseInfoParsingResult::getAttachmentContentId, + Function.identity(), + (existingValue, newValue) -> existingValue + )); + + Map attachmentIdToObligationMap = obligationResults.parallelStream() + .filter(ObligationParsingResult::isSetAttachmentContentId) + .filter(o -> o.getObligationsAtProjectSize() > 0) + .collect(Collectors.toMap(ObligationParsingResult::getAttachmentContentId, Function.identity(), + (existingValue, newValue) -> existingValue)); List licenseParsingResults = new ArrayList(); Map releaseIdToAcceptedCLI = Maps.newHashMap(); diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoServlet.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoServlet.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoServlet.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoServlet.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java similarity index 72% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java index 94d0e21a82..6a9bd149e9 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java @@ -66,7 +66,6 @@ public class DocxGenerator extends OutputGenerator { private static final String CAPTION_EXTID_TABLE_VALUE = "External Identifiers for this Product:"; private static final String CAPTION_EXTID_TABLE = "$caption-extid-table"; private static final String EXTERNAL_ID_TABLE = "$external-id-table"; - private static final String README_OSS_TEXT= "$readme-OSS-text"; private static final String UNKNOWN_LICENSE_NAME = "Unknown license name"; private static final String UNKNOWN_FILE_NAME = "Unknown file name"; private static final String UNKNOWN_LICENSE = "Unknown"; @@ -87,7 +86,7 @@ public class DocxGenerator extends OutputGenerator { private static final int PROJECT_OBLIGATIONS_TABLE_INDEX = 5; private static final int COMPONENT_OBLIGATIONS_TABLE_INDEX = 6; public static final int ADDITIONAL_REQ_TABLE_INDEX = 7; - public static int OBLIGATION_STATUS_TABLE_INDEX = 8; + public static final int OBLIGATION_STATUS_TABLE_INDEX = 8; private static final String EXT_ID_TABLE_HEADER_COL1 = "Identifier Name"; private static final String EXT_ID_TABLE_HEADER_COL2 = "Identifier Value"; @@ -101,7 +100,10 @@ public DocxGenerator(OutputFormatVariant outputFormatVariant, String description } @Override - public byte[] generateOutputFile(Collection projectLicenseInfoResults, Project project, Collection obligationResults, User user, Map externalIds, Map obligationsStatus, String fileName) throws SW360Exception { + public byte[] generateOutputFile(Collection projectLicenseInfoResults, Project project, + Collection obligationResults, User user, Map externalIds, + Map obligationsStatus, String fileName, boolean excludeReleaseVersion) + throws SW360Exception { String licenseInfoHeaderText = project.getLicenseInfoHeaderText(); ByteArrayOutputStream docxOutputStream = new ByteArrayOutputStream(); @@ -114,15 +116,16 @@ public byte[] generateOutputFile(Collection projectLic xwpfDocument = new XWPFDocument(new ByteArrayInputStream(docxTemplateFile.get())); if (docxTemplateFile.isPresent()) { fillDisclosureDocument( - xwpfDocument, - projectLicenseInfoResults, - project, - licenseInfoHeaderText, - false, - externalIds - ); + xwpfDocument, + projectLicenseInfoResults, + project, + licenseInfoHeaderText, + false, + externalIds, + excludeReleaseVersion); } else { - throw new SW360Exception("Could not load the template for xwpf document: " + DOCX_TEMPLATE_FILE); + throw new SW360Exception( + "Could not load the template for xwpf document: " + DOCX_TEMPLATE_FILE); } break; case REPORT: @@ -135,17 +138,17 @@ public byte[] generateOutputFile(Collection projectLic xwpfDocument = new XWPFDocument(new ByteArrayInputStream(docxTemplateFile.get())); if (docxTemplateFile.isPresent()) { fillReportDocument( - xwpfDocument, - projectLicenseInfoResults, - project, - licenseInfoHeaderText, - true, - obligationResults, - user, - obligationsStatus - ); + xwpfDocument, + projectLicenseInfoResults, + project, + licenseInfoHeaderText, + true, + obligationResults, + user, + obligationsStatus); } else { - throw new SW360Exception("Could not load the template for xwpf document: " + DOCX_TEMPLATE_REPORT_FILE); + throw new SW360Exception( + "Could not load the template for xwpf document: " + DOCX_TEMPLATE_REPORT_FILE); } break; default: @@ -164,33 +167,36 @@ public byte[] generateOutputFile(Collection projectLic } private void fillDisclosureDocument( - XWPFDocument document, - Collection projectLicenseInfoResults, - Project project, - String licenseInfoHeaderText, - boolean includeObligations, Map externalIds) throws XmlException, TException { - if (CommonUtils.isNotEmpty(projectLicenseInfoResults)) { - projectLicenseInfoResults = projectLicenseInfoResults.stream().filter(Objects::nonNull) + XWPFDocument document, + Collection projectLicenseInfoResults, + Project project, + String licenseInfoHeaderText, + boolean includeObligations, Map externalIds, boolean excludeReleaseVersion) + throws XmlException, TException { + if (CommonUtils.isNotEmpty(projectLicenseInfoResults)) { + projectLicenseInfoResults = projectLicenseInfoResults.stream().filter(Objects::nonNull) .sorted(Comparator.comparing(li -> getComponentLongName(li), String.CASE_INSENSITIVE_ORDER)) .collect(Collectors.toList()); - } - Map licenseToReferenceId = populatelicenseToReferenceId(projectLicenseInfoResults, Maps.newHashMap()); - String projectName = project.getName(); - String projectVersion = project.getVersion(); - - replaceText(document, "$license-info-header", CommonUtils.nullToEmptyString(licenseInfoHeaderText)); - replaceText(document, "$project-name", CommonUtils.nullToEmptyString(projectName)); - replaceText(document, "$project-version", CommonUtils.nullToEmptyString(projectVersion)); - fillExternalIds(document, externalIds); - - if (CommonUtils.isNullOrEmptyCollection(projectLicenseInfoResults)) { - printErrorForNoRelease(document, projectLicenseInfoResults); - return; - } + } + Map licenseToReferenceId = populatelicenseToReferenceId(projectLicenseInfoResults, + Maps.newHashMap()); + String projectName = project.getName(); + String projectVersion = project.getVersion(); + + replaceText(document, "$license-info-header", CommonUtils.nullToEmptyString(licenseInfoHeaderText)); + replaceText(document, "$project-name", CommonUtils.nullToEmptyString(projectName)); + replaceText(document, "$project-version", CommonUtils.nullToEmptyString(projectVersion)); + fillExternalIds(document, externalIds); + + if (CommonUtils.isNullOrEmptyCollection(projectLicenseInfoResults)) { + printErrorForNoRelease(document, projectLicenseInfoResults); + return; + } - fillReleaseBulletList(document, projectLicenseInfoResults); - fillReleaseDetailList(document, projectLicenseInfoResults, includeObligations, licenseToReferenceId); - fillLicenseList(document, projectLicenseInfoResults, licenseToReferenceId); + fillReleaseBulletList(document, projectLicenseInfoResults, excludeReleaseVersion); + fillReleaseDetailList(document, projectLicenseInfoResults, includeObligations, licenseToReferenceId, + excludeReleaseVersion); + fillLicenseList(document, projectLicenseInfoResults, licenseToReferenceId); } private void printErrorForNoRelease(XWPFDocument document, @@ -200,7 +206,9 @@ private void printErrorForNoRelease(XWPFDocument document, addFormattedText(errorRun, errorText, FONT_SIZE, false, ALERT_COLOR); } - private Map populatelicenseToReferenceId(Collection projectLicenseInfoResults, Map licenseToReferenceId) { + private Map populatelicenseToReferenceId( + Collection projectLicenseInfoResults, + Map licenseToReferenceId) { int referenceId = 1; List licenseNamesWithTexts = getSortedLicenseNameWithTexts(projectLicenseInfoResults); for (LicenseNameWithText licenseNamesWithText : licenseNamesWithTexts) { @@ -210,7 +218,7 @@ private Map populatelicenseToReferenceId(Collectio } private void fillExternalIds(XWPFDocument document, Map externalIdMap) { - if(!externalIdMap.isEmpty()) { + if (!externalIdMap.isEmpty()) { replaceText(document, CAPTION_EXTID_TABLE, CAPTION_EXTID_TABLE_VALUE); List list = document.getParagraphs().stream() .filter(x -> x.getParagraphText().equalsIgnoreCase(EXTERNAL_ID_TABLE)).collect(Collectors.toList()); @@ -235,94 +243,100 @@ private void fillExternalIds(XWPFDocument document, Map external removeParagraph(document, EXTERNAL_ID_TABLE); addNewLines(document, 1); } - }else { - removeParagraph(document,EXTERNAL_ID_TABLE); + } else { + removeParagraph(document, EXTERNAL_ID_TABLE); removeParagraph(document, CAPTION_EXTID_TABLE); } } private void setTableRowSize(XWPFTable table) { - for(int x = 0;x < table.getNumberOfRows(); x++){ + for (int x = 0; x < table.getNumberOfRows(); x++) { XWPFTableRow row = table.getRow(x); int numberOfCell = row.getTableCells().size(); - for(int y = 0; y < numberOfCell ; y++){ + for (int y = 0; y < numberOfCell; y++) { XWPFTableCell cell = row.getCell(y); cell.getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(TABLE_WIDTH)); } - } + } } private void fillReportDocument( - XWPFDocument document, - Collection projectLicenseInfoResults, - Project project, - String licenseInfoHeaderText, - boolean includeObligations, - Collection obligationResults, - User user, Map obligationsStatus) throws XmlException, TException { - - String businessUnit = project.getBusinessUnit(); - String projectName = project.getName(); - String projectVersion = project.getVersion(); - String clearingSummaryText = project.getClearingSummary(); - String specialRisksOSSText = project.getSpecialRisksOSS(); - String generalRisks3rdPartyText = CommonUtils.isNotNullEmptyOrWhitespace(project.getGeneralRisks3rdParty()) ? project.getGeneralRisks3rdParty() : "No commercial 3rd party software is used"; - String specialRisks3rdPartyText = CommonUtils.isNotNullEmptyOrWhitespace(project.getSpecialRisks3rdParty()) ? project.getSpecialRisks3rdParty() : "No commercial 3rd party software is used"; - String deliveryChannelsText = project.getDeliveryChannels(); - String remarksAdditionalRequirementsText = project.getRemarksAdditionalRequirements(); - String projectDescription = project.getDescription(); - // extract licenses that appear at least ADDITIONAL_REQ_THRESHOLD times - Set mostLicenses = extractMostCommonLicenses(obligationResults, ADDITIONAL_REQ_THRESHOLD); - - fillOwnerGroup(document, project); - fillAttendeesTable(document, project); - - replaceText(document, "$bunit", CommonUtils.nullToEmptyString(businessUnit)); - replaceText(document, "$license-info-header", CommonUtils.nullToEmptyString(licenseInfoHeaderText)); - replaceText(document, "$project-name", CommonUtils.nullToEmptyString(projectName)); - replaceText(document, "$project-version", CommonUtils.nullToEmptyString(projectVersion)); - replaceText(document, "$clearing-summary-text", CommonUtils.nullToEmptyString(clearingSummaryText)); - replaceText(document, "$special-risks-oss-addition-text", CommonUtils.nullToEmptyString(specialRisksOSSText)); - replaceText(document, "$general-risks-3rd-party-text", CommonUtils.nullToEmptyString(generalRisks3rdPartyText)); - replaceText(document, "$special-risks-3rd-party-text", CommonUtils.nullToEmptyString(specialRisks3rdPartyText)); - replaceText(document, "$delivery-channels-text", CommonUtils.nullToEmptyString(deliveryChannelsText)); - replaceText(document, "$remarks-additional-requirements-text", CommonUtils.nullToEmptyString(remarksAdditionalRequirementsText)); - replaceText(document, "$product-description", CommonUtils.nullToEmptyString(projectDescription)); - - String readme_oss = "Is generated by the Clearing office and provided in sw360 as attachment of the Project. It is stored here:"; - replaceText(document, "$readme-OSS-text", CommonUtils.nullToEmptyString(readme_oss)); - replaceText(document, "$list_comma_sep_licenses_above_threshold", String.join(", ", mostLicenses)); - - if (CommonUtils.isNullOrEmptyCollection(projectLicenseInfoResults)) { - printErrorForNoRelease(document, projectLicenseInfoResults); - return; - } else { - projectLicenseInfoResults = projectLicenseInfoResults.stream().filter(Objects::nonNull) + XWPFDocument document, + Collection projectLicenseInfoResults, + Project project, + String licenseInfoHeaderText, + boolean includeObligations, + Collection obligationResults, + User user, Map obligationsStatus) throws XmlException, TException { + + String businessUnit = project.getBusinessUnit(); + String projectName = project.getName(); + String projectVersion = project.getVersion(); + String clearingSummaryText = project.getClearingSummary(); + String specialRisksOSSText = project.getSpecialRisksOSS(); + String generalRisks3rdPartyText = CommonUtils.isNotNullEmptyOrWhitespace(project.getGeneralRisks3rdParty()) + ? project.getGeneralRisks3rdParty() + : "No commercial 3rd party software is used"; + String specialRisks3rdPartyText = CommonUtils.isNotNullEmptyOrWhitespace(project.getSpecialRisks3rdParty()) + ? project.getSpecialRisks3rdParty() + : "No commercial 3rd party software is used"; + String deliveryChannelsText = project.getDeliveryChannels(); + String remarksAdditionalRequirementsText = project.getRemarksAdditionalRequirements(); + String projectDescription = project.getDescription(); + // extract licenses that appear at least ADDITIONAL_REQ_THRESHOLD times + Set mostLicenses = extractMostCommonLicenses(obligationResults, ADDITIONAL_REQ_THRESHOLD); + + fillOwnerGroup(document, project); + fillAttendeesTable(document, project); + + replaceText(document, "$bunit", CommonUtils.nullToEmptyString(businessUnit)); + replaceText(document, "$license-info-header", CommonUtils.nullToEmptyString(licenseInfoHeaderText)); + replaceText(document, "$project-name", CommonUtils.nullToEmptyString(projectName)); + replaceText(document, "$project-version", CommonUtils.nullToEmptyString(projectVersion)); + replaceText(document, "$clearing-summary-text", CommonUtils.nullToEmptyString(clearingSummaryText)); + replaceText(document, "$special-risks-oss-addition-text", CommonUtils.nullToEmptyString(specialRisksOSSText)); + replaceText(document, "$general-risks-3rd-party-text", CommonUtils.nullToEmptyString(generalRisks3rdPartyText)); + replaceText(document, "$special-risks-3rd-party-text", CommonUtils.nullToEmptyString(specialRisks3rdPartyText)); + replaceText(document, "$delivery-channels-text", CommonUtils.nullToEmptyString(deliveryChannelsText)); + replaceText(document, "$remarks-additional-requirements-text", + CommonUtils.nullToEmptyString(remarksAdditionalRequirementsText)); + replaceText(document, "$product-description", CommonUtils.nullToEmptyString(projectDescription)); + + String readme_oss = "Is generated by the Clearing office and provided in sw360 as attachment of the Project. It is stored here:"; + replaceText(document, "$readme-OSS-text", CommonUtils.nullToEmptyString(readme_oss)); + replaceText(document, "$list_comma_sep_licenses_above_threshold", String.join(", ", mostLicenses)); + + if (CommonUtils.isNullOrEmptyCollection(projectLicenseInfoResults)) { + printErrorForNoRelease(document, projectLicenseInfoResults); + return; + } else { + projectLicenseInfoResults = projectLicenseInfoResults.stream().filter(Objects::nonNull) .sorted(Comparator.comparing(li -> getComponentShortName(li), String.CASE_INSENSITIVE_ORDER)) .collect(Collectors.toList()); - } - - fillSpecialOSSRisksTable(document, project, obligationResults); - fillDevelopmentDetailsTable(document, project, user, projectLicenseInfoResults); - fillOverview3rdPartyComponentTable(document, projectLicenseInfoResults); - List obligations = SW360Utils.getObligations(); - fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, - ObligationLevel.ORGANISATION_OBLIGATION, COMMON_RULES_TABLE_INDEX, NO_ORGANISATION_OBLIGATIONS); - fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, - ObligationLevel.PROJECT_OBLIGATION, PROJECT_OBLIGATIONS_TABLE_INDEX, NO_PROJECT_OBLIGATIONS); - fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, - ObligationLevel.COMPONENT_OBLIGATION, COMPONENT_OBLIGATIONS_TABLE_INDEX, NO_COMPONENT_OBLIGATIONS); - fillComponentObligationsTable(document, obligationResults, mostLicenses, project); + } - fillLinkedObligations(document, obligationsStatus); - // because of the impossible API component subsections must be the last thing in the docx file - // the rest of the sections must be generated after this - writeComponentSubsections(document, projectLicenseInfoResults, obligationResults); + fillSpecialOSSRisksTable(document, project, obligationResults); + fillDevelopmentDetailsTable(document, project, user, projectLicenseInfoResults); + fillOverview3rdPartyComponentTable(document, projectLicenseInfoResults); + List obligations = SW360Utils.getObligations(); + fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, + ObligationLevel.ORGANISATION_OBLIGATION, COMMON_RULES_TABLE_INDEX, NO_ORGANISATION_OBLIGATIONS); + fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, + ObligationLevel.PROJECT_OBLIGATION, PROJECT_OBLIGATIONS_TABLE_INDEX, NO_PROJECT_OBLIGATIONS); + fillProjectComponentOrganisationObligationsTable(document, obligationsStatus, obligations, + ObligationLevel.COMPONENT_OBLIGATION, COMPONENT_OBLIGATIONS_TABLE_INDEX, NO_COMPONENT_OBLIGATIONS); + fillComponentObligationsTable(document, obligationResults, mostLicenses, project); + + fillLinkedObligations(document, obligationsStatus); + // because of the impossible API component subsections must be the last thing in + // the docx file + // the rest of the sections must be generated after this + writeComponentSubsections(document, projectLicenseInfoResults, obligationResults); } private void fillOwnerGroup(XWPFDocument document, Project project) throws XmlException, TException { String businessUnit = ""; - if(project.isSetBusinessUnit()) { + if (project.isSetBusinessUnit()) { businessUnit = project.getBusinessUnit(); } replaceText(document, "$owner-group", CommonUtils.nullToEmptyString(businessUnit)); @@ -335,14 +349,14 @@ private void fillAttendeesTable(XWPFDocument document, Project project) throws X UserService.Iface userClient = new ThriftClients().makeUserClient(); - if(project.isSetProjectOwner() && !project.getProjectOwner().isEmpty()) { + if (project.isSetProjectOwner() && !project.getProjectOwner().isEmpty()) { User owner = null; try { owner = userClient.getByEmail(project.getProjectOwner()); } catch (TException te) { // a resulting null user object is handled below } - if(owner != null) { + if (owner != null) { XWPFTableRow row = table.insertNewTableRow(currentRow++); addFormattedTextInTableCell(row.addNewTableCell(), owner.getEmail()); addFormattedTextInTableCell(row.addNewTableCell(), owner.getDepartment()); @@ -350,30 +364,30 @@ private void fillAttendeesTable(XWPFDocument document, Project project) throws X } } - if(project.isSetRoles()) { - for(Map.Entry > rolRelationship : project.getRoles().entrySet()) { + if (project.isSetRoles()) { + for (Map.Entry> rolRelationship : project.getRoles().entrySet()) { String rol = rolRelationship.getKey(); Set emails = rolRelationship.getValue(); - for(String email : emails) { - if(email.isEmpty()) { + for (String email : emails) { + if (email.isEmpty()) { continue; } User user = null; try { - user = userClient.getByEmail(email); + user = userClient.getByEmail(email); } catch (TException te) { // a resulting null user object is handled below by replacing with email } XWPFTableRow row = table.insertNewTableRow(currentRow++); String name = email; - if(user != null && user.isSetFullname()) { + if (user != null && user.isSetFullname()) { name = user.getFullname(); } String department = "N.A."; - if(user != null) { + if (user != null) { department = user.getDepartment(); } @@ -385,32 +399,32 @@ private void fillAttendeesTable(XWPFDocument document, Project project) throws X } } - private void fillSpecialOSSRisksTable(XWPFDocument document, Project project, Collection obligationResults) throws XmlException, TException { + private void fillSpecialOSSRisksTable(XWPFDocument document, Project project, + Collection obligationResults) throws XmlException, TException { XWPFTable table = document.getTables().get(SPECIAL_OSS_RISKS_TABLE_INDEX); - final int[] currentRow = new int[]{0}; + final int[] currentRow = new int[] { 0 }; obligationResults.stream() .filter(opr -> opr.getStatus() == ObligationInfoRequestStatus.SUCCESS) .flatMap(opr -> opr.getObligationsAtProject().stream()) .distinct() - .forEach(o -> - { - currentRow[0] = currentRow[0] + 1; - XWPFTableRow row = table.insertNewTableRow(currentRow[0]); - addFormattedTextInTableCell(row.addNewTableCell(), o.getTopic()); - addFormattedTextInTableCell(row.addNewTableCell(), String.join(" ", o.getLicenseIDs())); - addFormattedTextInTableCell(row.addNewTableCell(), o.getText()); - } - ); + .forEach(o -> { + currentRow[0] = currentRow[0] + 1; + XWPFTableRow row = table.insertNewTableRow(currentRow[0]); + addFormattedTextInTableCell(row.addNewTableCell(), o.getTopic()); + addFormattedTextInTableCell(row.addNewTableCell(), String.join(" ", o.getLicenseIDs())); + addFormattedTextInTableCell(row.addNewTableCell(), o.getText()); + }); setTableBorders(table); } - private void fillOverview3rdPartyComponentTable(XWPFDocument document, Collection projectLicenseInfoResults) throws XmlException { + private void fillOverview3rdPartyComponentTable(XWPFDocument document, + Collection projectLicenseInfoResults) throws XmlException { XWPFTable table = document.getTables().get(THIRD_PARTY_COMPONENT_OVERVIEW_TABLE_INDEX); int currentRow = 1; - for(LicenseInfoParsingResult result : projectLicenseInfoResults) { - if(result.getStatus() != LicenseInfoRequestStatus.SUCCESS) { + for (LicenseInfoParsingResult result : projectLicenseInfoResults) { + if (result.getStatus() != LicenseInfoRequestStatus.SUCCESS) { continue; } @@ -426,8 +440,8 @@ private void fillOverview3rdPartyComponentTable(XWPFDocument document, Collectio addFormattedTextInTableCell(row.addNewTableCell(), licenseInfo.getComponentName()); String globalLicense = ""; - for(LicenseNameWithText l : licenseInfo.getLicenseNamesWithTexts()) { - if(l != null && "global".equals(l.getType())) { + for (LicenseNameWithText l : licenseInfo.getLicenseNamesWithTexts()) { + if (l != null && "global".equals(l.getType())) { globalLicense = l.getLicenseName(); break; } @@ -460,17 +474,23 @@ private static void formatHyperlink(CTR ctr) { CTRPr ctrpr = ctr.addNewRPr(); CTColor colour = CTColor.Factory.newInstance(); colour.setVal("0000FF"); - ctrpr.setColor(colour); + // Set the color using XWPFRun + XWPFRun run = new XWPFRun(ctr, null); + run.setColor("0000FF"); // Set the color to blue ctrpr.addNewU().setVal(STUnderline.SINGLE); - ctrpr.addNewSz().setVal(new BigInteger("18")); + ctrpr.addNewSz().setVal(BigInteger.valueOf(18L)); } - private static Optional obligationsForRelease(Release release, Collection obligationResults) { + private static Optional obligationsForRelease(Release release, + Collection obligationResults) { return obligationResults.stream().filter(opr -> opr.getRelease() == release).findFirst(); } - private void writeComponentSubsections(XWPFDocument document, Collection projectLicenseInfoResults, Collection obligationResults) throws SW360Exception, XmlException { - XmlCursor cursor = document.getTables().get(ADDITIONAL_REQ_TABLE_INDEX+getNoOfTablesCreated()).getCTTbl().newCursor(); + private void writeComponentSubsections(XWPFDocument document, + Collection projectLicenseInfoResults, + Collection obligationResults) throws SW360Exception, XmlException { + XmlCursor cursor = document.getTables().get(ADDITIONAL_REQ_TABLE_INDEX + getNoOfTablesCreated()).getCTTbl() + .newCursor(); cursor.toEndToken(); for (LicenseInfoParsingResult result : projectLicenseInfoResults) { @@ -508,7 +528,8 @@ private void writeComponentSubsections(XWPFDocument document, Collection obligationsResultOp = obligationsForRelease(result.getRelease(), obligationResults); + Optional obligationsResultOp = obligationsForRelease(result.getRelease(), + obligationResults); if (!obligationsResultOp.isPresent()) { continue; @@ -535,14 +556,16 @@ private void writeComponentSubsections(XWPFDocument document, Collection projectLicenseInfoResults) throws TException { + private void fillDevelopmentDetailsTable(XWPFDocument document, Project project, User user, + Collection projectLicenseInfoResults) throws TException { XWPFTable table = document.getTables().get(DEV_DETAIL_TABLE_INDEX); int currentRow = 1; - for(LicenseInfoParsingResult result : projectLicenseInfoResults) { + for (LicenseInfoParsingResult result : projectLicenseInfoResults) { if (result.getStatus() != LicenseInfoRequestStatus.SUCCESS) { - // this error handling is for extra safety since projectLicenseInfoResults is provided by the caller + // this error handling is for extra safety since projectLicenseInfoResults is + // provided by the caller // and we assume valid input so we silently ignoring it. continue; } @@ -556,7 +579,8 @@ private void fillDevelopmentDetailsTable(XWPFDocument document, Project project, addFormattedTextInTableCell(row.addNewTableCell(), r.getName()); - String operatingSystems = r.getOperatingSystemsSize() == 0 ? "N/A" : String.join(" ", r.getOperatingSystems()); + String operatingSystems = r.getOperatingSystemsSize() == 0 ? "N/A" + : String.join(" ", r.getOperatingSystems()); addFormattedTextInTableCell(row.addNewTableCell(), operatingSystems); String langs = r.getLanguagesSize() == 0 ? "N/A" : String.join(" ", r.getLanguages()); @@ -568,7 +592,8 @@ private void fillDevelopmentDetailsTable(XWPFDocument document, Project project, setTableBorders(table); } - protected static Set extractMostCommonLicenses(Collection obligationResults, long threshold) { + protected static Set extractMostCommonLicenses(Collection obligationResults, + long threshold) { return obligationResults.stream() .filter(opr -> opr.getStatus() == ObligationInfoRequestStatus.SUCCESS) .flatMap(opr -> opr.getObligationsAtProject().stream()) @@ -581,8 +606,9 @@ protected static Set extractMostCommonLicenses(Collection obligationsStatusAtProject, - List obligations,ObligationLevel oblLevel,int tableIndex,String emptyTableText) { + private void fillProjectComponentOrganisationObligationsTable(XWPFDocument document, + Map obligationsStatusAtProject, + List obligations, ObligationLevel oblLevel, int tableIndex, String emptyTableText) { XWPFTable table = document.getTables().get(tableIndex); final int[] currentRow = new int[] { 0 }; @@ -615,16 +641,19 @@ private void fillProjectComponentOrganisationObligationsTable(XWPFDocument docum setTableBorders(table); } - private void fillComponentObligationsTable(XWPFDocument document, Collection obligationResults, Set mostLicenses, Project project) throws XmlException, SW360Exception { + private void fillComponentObligationsTable(XWPFDocument document, + Collection obligationResults, Set mostLicenses, Project project) + throws XmlException, SW360Exception { final int[] currentRow = new int[] { 0, 0 }; - final Map> licenseIdToOblTopicText = new HashMap>(); + final Map> licenseIdToOblTopicText = new HashMap>(); obligationResults.stream() .filter(opr -> opr.getStatus() == ObligationInfoRequestStatus.SUCCESS) .flatMap(opr -> opr.getObligationsAtProject().stream()) .filter(o -> o.getLicenseIDs().stream() - .anyMatch(lid -> mostLicenses.parallelStream().anyMatch(mlid -> mlid.equals(lid.replace("\n", "").replace("\r", ""))))) - .forEach(o-> { + .anyMatch(lid -> mostLicenses.parallelStream() + .anyMatch(mlid -> mlid.equals(lid.replace("\n", "").replace("\r", ""))))) + .forEach(o -> { o.getLicenseIDs().stream().forEach(lid -> { Map oblTopicText = new HashMap(); oblTopicText.put(o.getTopic(), o.getText()); @@ -646,11 +675,12 @@ private void fillComponentObligationsTable(XWPFDocument document, Collection> entr, Project project) { + private void printSecondTableOnwards(XWPFDocument document, XmlCursor cursor, + Map.Entry> entr, Project project) { XWPFTable table = document.insertNewTbl(cursor); Map tctxt = entr.getValue(); int noOfRows = tctxt.size(); - final int[] currentRow = new int[]{noOfRows}; + final int[] currentRow = new int[] { noOfRows }; XWPFTableRow row = table.getRow(0); addFormattedTextInTableCell(row.getCell(0), "Obligation"); @@ -671,12 +701,13 @@ private void printSecondTableOnwards(XWPFDocument document, XmlCursor cursor, Ma setTableBorders(table); } - private XWPFTable printFirstTable(XWPFDocument document, Map> licenseIdToOblTopicText, Project project) { + private XWPFTable printFirstTable(XWPFDocument document, Map> licenseIdToOblTopicText, + Project project) { Set>> entry = licenseIdToOblTopicText.entrySet(); Map.Entry> entr1 = entry.iterator().next(); Map tctxt = entr1.getValue(); Map.Entry topictxt = tctxt.entrySet().iterator().next(); - final int[] currentRow = new int[]{1}; + final int[] currentRow = new int[] { 1 }; final XWPFTable table = document.getTables().get(ADDITIONAL_REQ_TABLE_INDEX); XWPFTableRow row = table.insertNewTableRow(1); @@ -690,7 +721,8 @@ private XWPFTable printFirstTable(XWPFDocument document, Map projectLicenseInfoResults) throws XmlException { + private void fillReleaseBulletList(XWPFDocument document, + Collection projectLicenseInfoResults, + boolean excludeReleaseVersion) throws XmlException { List releaseList = new ArrayList<>(); - for (LicenseInfoParsingResult result : projectLicenseInfoResults) { - releaseList.add(getComponentLongName(result)); + + if (excludeReleaseVersion) { + for (LicenseInfoParsingResult result : projectLicenseInfoResults) { + releaseList.add(getComponentLongNameWithoutVersion(result)); + } + } else { + for (LicenseInfoParsingResult result : projectLicenseInfoResults) { + releaseList.add(getComponentLongName(result)); + } } addBulletList(document, releaseList, true); addPageBreak(document); } - private void fillReleaseDetailList(XWPFDocument document, Collection projectLicenseInfoResults, boolean includeObligations, Map licenseToReferenceId) throws TException { + private void fillReleaseDetailList(XWPFDocument document, + Collection projectLicenseInfoResults, boolean includeObligations, + Map licenseToReferenceId, boolean excludeReleaseVersion) throws TException { addFormattedText(document.createParagraph().createRun(), "Detailed Releases Information", FONT_SIZE + 2, true); setText(document.createParagraph().createRun(), "Please note the following license conditions and copyright " + "notices applicable to Open Source Software and/or other components (or parts thereof):"); addNewLines(document, 0); - Map> sortedAcknowledgement = getAcknowledgement(projectLicenseInfoResults); + Map> sortedAcknowledgement = getAcknowledgement(projectLicenseInfoResults, + excludeReleaseVersion); for (LicenseInfoParsingResult parsingResult : projectLicenseInfoResults) { - addReleaseTitle(document, parsingResult); - addAcknowledgement(document, sortedAcknowledgement.get(getComponentLongName(parsingResult))); + addReleaseTitle(document, parsingResult, excludeReleaseVersion); + if (excludeReleaseVersion) { + addAcknowledgement(document, + sortedAcknowledgement.get(getComponentLongNameWithoutVersion(parsingResult))); + } else { + addAcknowledgement(document, sortedAcknowledgement.get(getComponentLongName(parsingResult))); + } if (parsingResult.getStatus() == LicenseInfoRequestStatus.SUCCESS) { addLicenses(document, parsingResult, includeObligations, licenseToReferenceId); addNewLines(document, 1); @@ -746,7 +795,8 @@ private void fillReleaseDetailList(XWPFDocument document, Collection acknowledgements) { - if(CollectionUtils.isNotEmpty(acknowledgements)) { + if (CollectionUtils.isNotEmpty(acknowledgements)) { XWPFRun ackRun = document.createParagraph().createRun(); addFormattedText(ackRun, "Acknowledgement", FONT_SIZE, true); for (String acknowledgement : acknowledgements) { @@ -766,18 +816,19 @@ private void addAcknowledgement(XWPFDocument document, Set acknowledgeme } private SortedMap> getAcknowledgement( - Collection projectLicenseInfoResults) { + Collection projectLicenseInfoResults, boolean excludeReleaseVersion) { Map> partitionedResults = projectLicenseInfoResults.stream() .collect(Collectors.partitioningBy(r -> r.getStatus() == LicenseInfoRequestStatus.SUCCESS)); List goodResults = partitionedResults.get(true); - return getSortedAcknowledgements(getSortedLicenseInfos(goodResults)); - + return getSortedAcknowledgements(getSortedLicenseInfos(goodResults, excludeReleaseVersion)); } - private void addReleaseTitle(XWPFDocument document, LicenseInfoParsingResult parsingResult) { - String releaseTitle = getComponentLongName(parsingResult); + private void addReleaseTitle(XWPFDocument document, LicenseInfoParsingResult parsingResult, + boolean excludeReleaseVersion) { + String releaseTitle = excludeReleaseVersion ? getComponentLongNameWithoutVersion(parsingResult) + : getComponentLongName(parsingResult); XWPFParagraph releaseTitleParagraph = document.createParagraph(); releaseTitleParagraph.setStyle(STYLE_HEADING); addBookmark(releaseTitleParagraph, releaseTitle, releaseTitle); @@ -794,7 +845,8 @@ private void addCopyrights(XWPFDocument document, LicenseInfoParsingResult parsi } } - private void addLicenses(XWPFDocument document, LicenseInfoParsingResult parsingResult, boolean includeObligations, Map licenseToReferenceId) + private void addLicenses(XWPFDocument document, LicenseInfoParsingResult parsingResult, boolean includeObligations, + Map licenseToReferenceId) throws TException { XWPFRun licensesTitleRun = document.createParagraph().createRun(); addNewLines(licensesTitleRun, 1); @@ -805,7 +857,8 @@ private void addLicenses(XWPFDocument document, LicenseInfoParsingResult parsing if (licenseInfo.isSetLicenseNamesWithTexts()) { List licenseNameWithTexts = licenseInfo.getLicenseNamesWithTexts().stream() .filter(licenseNameWithText -> !LicenseNameWithTextUtils.isEmpty(licenseNameWithText)) - .sorted(Comparator.comparing(LicenseNameWithText::getLicenseName,String.CASE_INSENSITIVE_ORDER)) + .sorted(Comparator.comparing(LicenseNameWithText::getLicenseName, + String.CASE_INSENSITIVE_ORDER)) .collect(Collectors.toList()); for (LicenseNameWithText licenseNameWithText : licenseNameWithTexts) { @@ -813,8 +866,10 @@ private void addLicenses(XWPFDocument document, LicenseInfoParsingResult parsing licensePara.setSpacingAfter(0); String licenseName = licenseNameWithText.isSetLicenseName() ? licenseNameWithText.getLicenseName() : UNKNOWN_LICENSE_NAME; - licenseNameWithCount.append(licenseName).append("(").append(licenseToReferenceId.get(licenseNameWithText)).append(")"); - addBookmarkHyperLink(licensePara, String.valueOf(licenseToReferenceId.get(licenseNameWithText)),licenseNameWithCount.toString()); + licenseNameWithCount.append(licenseName).append("(") + .append(licenseToReferenceId.get(licenseNameWithText)).append(")"); + addBookmarkHyperLink(licensePara, String.valueOf(licenseToReferenceId.get(licenseNameWithText)), + licenseNameWithCount.toString()); licenseNameWithCount.setLength(0); if (includeObligations) { addLicenseObligations(document, licenseName); @@ -879,8 +934,10 @@ private static List getLicenses() throws TException { return licenseClient.getLicenses(); } - private void fillLicenseList(XWPFDocument document, Collection projectLicenseInfoResults, Map licenseToReferenceId) { - List licenseNameWithTexts = OutputGenerator.getSortedLicenseNameWithTexts(projectLicenseInfoResults); + private void fillLicenseList(XWPFDocument document, Collection projectLicenseInfoResults, + Map licenseToReferenceId) { + List licenseNameWithTexts = OutputGenerator + .getSortedLicenseNameWithTexts(projectLicenseInfoResults); XWPFRun licenseHeaderRun = document.createParagraph().createRun(); addFormattedText(licenseHeaderRun, "License texts", FONT_SIZE + 2, true); addNewLines(document, 0); @@ -888,9 +945,11 @@ private void fillLicenseList(XWPFDocument document, Collection obligationsStatus) { - XWPFTable table = document.getTables().get(OBLIGATION_STATUS_TABLE_INDEX+getNoOfTablesCreated()); + XWPFTable table = document.getTables().get(OBLIGATION_STATUS_TABLE_INDEX + getNoOfTablesCreated()); final int[] currentRow = new int[] { 0 }; if (!obligationsStatus.isEmpty()) { @@ -957,4 +1016,4 @@ public int getNoOfTablesCreated() { public void setNoOfTablesCreated(int noOfTablesCreated) { this.noOfTablesCreated = noOfTablesCreated; } -} \ No newline at end of file +} diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java similarity index 80% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java index ac092c9a77..3ba3c7469b 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java @@ -29,21 +29,20 @@ public class DocxUtils { public static final String ALERT_COLOR = "e95850"; public static final String FONT_FAMILY = "Calibri"; public static final String STYLE_HEADING = "Heading2"; - public static final String STYLE_HEADING_3 = "Heading 3"; + public static final String STYLE_HEADING_3 = "Heading3"; private static final int BUFFER_SIZE = 16; private static final int ANCHOR_MAX_SIZE = 40; private static final String BOOKMARK_PREFIX = "bookmark_"; - private static String cTAbstractNumBulletXML = - "" - + "" - + "" - + "" - + "" - + ""; + private static String cTAbstractNumBulletXML = "" + + "" + + "" + + "" + + "" + + ""; private DocxUtils() { - //only static members + // only static members } public static void addNewLines(XWPFDocument document, int numberOfNewlines) { @@ -85,7 +84,8 @@ public static void addFormattedTextInTableCell(XWPFTableCell cell, String text) addFormattedText(run, text, "Arial", 9, false, null); } - public static void addFormattedText(XWPFRun run, String text, String fontFamily, int fontSize, boolean bold, String rrggbbColor) { + public static void addFormattedText(XWPFRun run, String text, String fontFamily, int fontSize, boolean bold, + String rrggbbColor) { run.setFontSize(fontSize); run.setFontFamily(fontFamily); run.setBold(bold); @@ -111,15 +111,16 @@ public static void replaceText(XWPFDocument document, String placeHolder, String replaceAllBodyElements(document.getBodyElements(), placeHolder, replaceText); for (XWPFTable table : document.getTables()) { - for(XWPFTableRow row : table.getRows()) { - for(XWPFTableCell cell : row.getTableCells()) { + for (XWPFTableRow row : table.getRows()) { + for (XWPFTableCell cell : row.getTableCells()) { replaceAllBodyElements(cell.getBodyElements(), placeHolder, replaceText); } } } } - private static void replaceAllBodyElements(List bodyElements, String placeHolder, String replaceText) { + private static void replaceAllBodyElements(List bodyElements, String placeHolder, + String replaceText) { for (IBodyElement bodyElement : bodyElements) { if (bodyElement.getElementType().compareTo(BodyElementType.PARAGRAPH) == 0) replaceParagraph((XWPFParagraph) bodyElement, placeHolder, replaceText); @@ -141,7 +142,8 @@ private static void replaceParagraph(XWPFParagraph paragraph, String placeHolder } } - public static void addBulletList(XWPFDocument document, List bulletListItems, boolean bulletListItemsAsLink) throws XmlException { + public static void addBulletList(XWPFDocument document, List bulletListItems, boolean bulletListItemsAsLink) + throws XmlException { CTNumbering cTNumbering = CTNumbering.Factory.parse(cTAbstractNumBulletXML); CTAbstractNum cTAbstractNum = cTNumbering.getAbstractNumArray(0); XWPFAbstractNum abstractNum = new XWPFAbstractNum(cTAbstractNum); @@ -175,17 +177,15 @@ public static void addHyperLink(XWPFParagraph paragraph, String hyperlinkAnchor, CTText ctText = CTText.Factory.newInstance(); ctText.setStringValue(hyperlinkText); CTR ctr = CTR.Factory.newInstance(); - ctr.setTArray(new CTText[]{ctText}); + ctr.setTArray(new CTText[] { ctText }); // format the hyperlink (underline + color) - CTRPr rpr = ctr.addNewRPr(); - CTColor colour = CTColor.Factory.newInstance(); - colour.setVal("0000FF"); - rpr.setColor(colour); - CTRPr rpr1 = ctr.addNewRPr(); - rpr1.addNewU().setVal(STUnderline.SINGLE); - - cLink.setRArray(new CTR[]{ctr}); + XWPFRun run = paragraph.createRun(); + run.setText(hyperlinkText); + run.setColor("0000FF"); // Set the color to blue + run.setUnderline(UnderlinePatterns.SINGLE); // Set underline + + cLink.setRArray(new CTR[] { ctr }); } public static void addBookmark(XWPFParagraph paragraph, String bookmarkAnchor, String bookmarkText) { diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java similarity index 85% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java index 43ea0abbb1..abf0bde184 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/JsonGenerator.java @@ -37,8 +37,9 @@ public JsonGenerator(OutputFormatVariant outputFormatVariant, String description } @Override - public String generateOutputFile(Collection projectLicenseInfoResults, Project project, Collection obligationResults, User user, Map externalIds, Map obligationsStatus, String fileName) throws SW360Exception { + public String generateOutputFile(Collection projectLicenseInfoResults, Project project, + Collection obligationResults, User user, Map externalIds, + Map obligationsStatus, String fileName, boolean excludeReleaseVersion) throws SW360Exception { return ""; - } -} \ No newline at end of file +} diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java similarity index 87% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java index 0e74779b01..8077b3fe61 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/OutputGenerator.java @@ -64,7 +64,11 @@ public abstract class OutputGenerator { this.outputVariant = variant; } - public abstract T generateOutputFile(Collection projectLicenseInfoResults, Project project, Collection obligationResults, User user, Map externalIds, Map obligationsStatus, String fileName) throws SW360Exception; + public abstract T generateOutputFile(Collection projectLicenseInfoResults, + Project project, Collection obligationResults, User user, + Map externalIds, Map obligationsStatus, String fileName, + boolean excludeReleaseVersion) + throws SW360Exception; public String getOutputType() { return outputType; @@ -100,6 +104,10 @@ public String getComponentLongName(LicenseInfoParsingResult li) { return SW360Utils.getReleaseFullname(li.getVendor(), li.getName(), li.getVersion()); } + public String getComponentLongNameWithoutVersion(LicenseInfoParsingResult li) { + return SW360Utils.getReleaseFullname(li.getVendor(), li.getName(), ""); + } + public String getComponentShortName(LicenseInfoParsingResult li) { return SW360Utils.getReleaseFullname("", li.getName(), li.getVersion()); } @@ -116,17 +124,25 @@ public VelocityContext getConfiguredVelocityContext() { return new VelocityContext(velocityToolManager.createContext()); } - @NotNull - protected SortedMap getSortedLicenseInfos(Collection projectLicenseInfoResults) { - Map licenseInfos = projectLicenseInfoResults.stream() - .collect(Collectors.toMap(this::getComponentLongName, li -> li, this::mergeLicenseInfoParsingResults)); - return sortStringKeyedMap(licenseInfos); - } + @NotNull + protected SortedMap getSortedLicenseInfos( + Collection projectLicenseInfoResults, boolean excludeReleaseVersion) { + Map licenseInfos = excludeReleaseVersion + ? projectLicenseInfoResults.stream() + .collect(Collectors.toMap(this::getComponentLongNameWithoutVersion, li -> li, + (l1, l2) -> mergeLicenseInfoParsingResults(l1, l2, true))) + : projectLicenseInfoResults.stream().collect(Collectors.toMap(this::getComponentLongName, li -> li, + (l1, l2) -> mergeLicenseInfoParsingResults(l1, l2, false))); + return sortStringKeyedMap(licenseInfos); + } @NotNull - protected LicenseInfoParsingResult mergeLicenseInfoParsingResults(LicenseInfoParsingResult r1, LicenseInfoParsingResult r2){ + protected LicenseInfoParsingResult mergeLicenseInfoParsingResults(LicenseInfoParsingResult r1, LicenseInfoParsingResult r2, boolean excludeReleaseVersion){ + String r1_name = excludeReleaseVersion ? getComponentLongNameWithoutVersion(r1) : getComponentLongName(r1); + String r2_name = excludeReleaseVersion ? getComponentLongNameWithoutVersion(r2) : getComponentLongName(r2); + if (r1.getStatus() != LicenseInfoRequestStatus.SUCCESS || r2.getStatus() != LicenseInfoRequestStatus.SUCCESS || - !getComponentLongName(r1).equals(getComponentLongName(r2))){ + !r1_name.equals(r2_name)){ throw new IllegalArgumentException("Only successful parsing results for the same release can be merged"); } @@ -230,8 +246,9 @@ private static SortedMap sortStringKeyedMap(Map unsort * @param externalIds * @return rendered template */ - protected String renderTemplateWithDefaultValues(Collection projectLicenseInfoResults, String file, - String projectTitle, String licenseInfoHeaderText, String obligationsText, Map externalIds) { + protected String renderTemplateWithDefaultValues(Collection projectLicenseInfoResults, + String file, String projectTitle, String licenseInfoHeaderText, String obligationsText, + Map externalIds, boolean excludeReleaseVersion) { VelocityContext vc = getConfiguredVelocityContext(); // set header vc.put(LICENSE_INFO_PROJECT_TITLE, projectTitle); @@ -254,12 +271,15 @@ protected String renderTemplateWithDefaultValues(Collection> partitionedResults = projectLicenseInfoResults.stream().collect(Collectors.partitioningBy(r -> r.getStatus() == LicenseInfoRequestStatus.SUCCESS)); List goodResults = partitionedResults.get(true); - Map> badResultsPerRelease = - partitionedResults.get(false).stream().collect(Collectors.groupingBy(this::getComponentLongName)); + + Map> badResultsPerRelease = excludeReleaseVersion + ? partitionedResults.get(false).stream() + .collect(Collectors.groupingBy(this::getComponentLongNameWithoutVersion)) + : partitionedResults.get(false).stream().collect(Collectors.groupingBy(this::getComponentLongName)); vc.put(LICENSE_INFO_ERROR_RESULTS_CONTEXT_PROPERTY, badResultsPerRelease); // be sure that the licenses inside a release are sorted by id. This looks nicer - SortedMap sortedLicenseInfos = getSortedLicenseInfos(goodResults); + SortedMap sortedLicenseInfos = getSortedLicenseInfos(goodResults, excludeReleaseVersion); // this will effectively change the objects in the collection and therefore the // objects in the sorted map above sortLicenseNamesWithinEachLicenseInfoById(sortedLicenseInfos.values(), licenseToReferenceId); diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java similarity index 76% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java index ecac32f6d6..553d8f654a 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/TextGenerator.java @@ -37,7 +37,10 @@ public TextGenerator(OutputFormatVariant outputFormatVariant, String outputDescr } @Override - public String generateOutputFile(Collection projectLicenseInfoResults, Project project, Collection obligationResults, User user, Map externalIds, Map obligationsStatus, String fileName) throws SW360Exception { + public String generateOutputFile(Collection projectLicenseInfoResults, Project project, + Collection obligationResults, User user, Map externalIds, + Map obligationsStatus, String fileName, + boolean excludeReleaseVersion) throws SW360Exception { String projectName = project.getName(); String projectVersion = project.getVersion(); String licenseInfoHeaderText = project.getLicenseInfoHeaderText(); @@ -45,14 +48,19 @@ public String generateOutputFile(Collection projectLic switch (getOutputVariant()) { case DISCLOSURE: - return generateDisclosure(projectLicenseInfoResults, projectName + " " + projectVersion, licenseInfoHeaderText, obligationsText, externalIds); + return generateDisclosure(projectLicenseInfoResults, projectName + " " + projectVersion, + licenseInfoHeaderText, obligationsText, externalIds, excludeReleaseVersion); default: throw new IllegalArgumentException("Unknown generator variant type: " + getOutputVariant()); } } - private String generateDisclosure(Collection projectLicenseInfoResults, String projectTitle, String licenseInfoHeaderText, String obligationsText, Map externalIds) { + + private String generateDisclosure(Collection projectLicenseInfoResults, + String projectTitle, String licenseInfoHeaderText, String obligationsText, + Map externalIds, boolean excludeReleaseVersion) { try { - return renderTemplateWithDefaultValues(projectLicenseInfoResults, TXT_TEMPLATE_FILE, projectTitle, licenseInfoHeaderText, obligationsText, externalIds); + return renderTemplateWithDefaultValues(projectLicenseInfoResults, TXT_TEMPLATE_FILE, projectTitle, + licenseInfoHeaderText, obligationsText, externalIds, excludeReleaseVersion); } catch (Exception e) { LOGGER.error("Could not generate text licenseinfo file for project " + projectTitle, e); return "License information could not be generated.\nAn exception occurred: " + e.toString(); diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java similarity index 79% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java index 73c117ef8d..e4d0054015 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/XhtmlGenerator.java @@ -38,7 +38,9 @@ public XhtmlGenerator(OutputFormatVariant outputFormatVariant, String descriptio } @Override - public String generateOutputFile(Collection projectLicenseInfoResults, Project project, Collection obligationResults, User user, Map externalIds, Map obligationsStatus, String fileName) throws SW360Exception { + public String generateOutputFile(Collection projectLicenseInfoResults, Project project, + Collection obligationResults, User user, Map externalIds, + Map obligationsStatus, String fileName, boolean excludeReleaseVersion) throws SW360Exception { String projectName = project.getName(); String projectVersion = project.getVersion(); String licenseInfoHeaderText = project.getLicenseInfoHeaderText(); @@ -46,15 +48,19 @@ public String generateOutputFile(Collection projectLic switch (getOutputVariant()) { case DISCLOSURE: - return generateDisclosure(projectLicenseInfoResults, projectName + " " + projectVersion, licenseInfoHeaderText, obligationsText, externalIds); + return generateDisclosure(projectLicenseInfoResults, projectName + " " + projectVersion, licenseInfoHeaderText, obligationsText, externalIds, excludeReleaseVersion); default: throw new IllegalArgumentException("Unknown generator variant type: " + getOutputVariant()); } } - private String generateDisclosure(Collection projectLicenseInfoResults, String projectTitle, String licenseInfoHeaderText, String obligationsText, Map externalIds) { + private String generateDisclosure(Collection projectLicenseInfoResults, + String projectTitle, String licenseInfoHeaderText, String obligationsText, Map externalIds, + boolean excludeReleaseVersion) { try { - return renderTemplateWithDefaultValues(projectLicenseInfoResults, XHTML_TEMPLATE_FILE, projectTitle, convertHeaderTextToHTML(licenseInfoHeaderText), convertHeaderTextToHTML(obligationsText), externalIds); + return renderTemplateWithDefaultValues(projectLicenseInfoResults, XHTML_TEMPLATE_FILE, projectTitle, + convertHeaderTextToHTML(licenseInfoHeaderText), convertHeaderTextToHTML(obligationsText), + externalIds, excludeReleaseVersion); } catch (Exception e) { LOGGER.error("Could not generate xhtml license info file for project " + projectTitle, e); return "License information could not be generated.\nAn exception occured: " + e.toString(); diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AbstractCLIParser.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AbstractCLIParser.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AbstractCLIParser.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AbstractCLIParser.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AttachmentContentProvider.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AttachmentContentProvider.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AttachmentContentProvider.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/AttachmentContentProvider.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CLIParser.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CLIParser.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CLIParser.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CLIParser.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CombinedCLIParser.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CombinedCLIParser.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CombinedCLIParser.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/CombinedCLIParser.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/LicenseInfoParser.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/LicenseInfoParser.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/LicenseInfoParser.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/LicenseInfoParser.java diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java similarity index 99% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java index 98ece9a9da..aa91500e41 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParser.java @@ -112,6 +112,7 @@ protected Optional openAsSpdx(AttachmentContent attachmentContent, } catch (SAXException e) { String msg = "failed to parse attachment=" + attachmentContent.getFilename() + " with id=" + attachmentContent.getId(); + log.error(msg, e); throw new SW360Exception(msg); } } diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java similarity index 99% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java index 63051547bb..a38e5e34bd 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/parsers/SPDXParserTools.java @@ -241,7 +241,7 @@ private static String findFirstSpdxChildContent(Node parent, String localName) { * Get license name of spdx:ExtractedLicensingInfo and spdx:ListedLicense. */ private static String getExtractedLicenseName(Node extractedLicenseInfo) { - String[] tagNames = { SPDX_NAME, SPDX_LICENSE_NAME_VERSION_1, SPDX_LICENSE_ID }; + String[] tagNames = {SPDX_LICENSE_ID, SPDX_NAME, SPDX_LICENSE_NAME_VERSION_1}; for (String tagName : tagNames) { String name = findFirstSpdxNodeContent(extractedLicenseInfo, tagName); if (!isNullEmptyOrWhitespace(name)) { diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/util/LicenseNameWithTextUtils.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/util/LicenseNameWithTextUtils.java similarity index 100% rename from backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/util/LicenseNameWithTextUtils.java rename to backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/util/LicenseNameWithTextUtils.java diff --git a/backend/src/src-licenseinfo/src/main/resources/DefaultLicenseInfoHeader.txt b/backend/licenseinfo/src/main/resources/DefaultLicenseInfoHeader.txt similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/DefaultLicenseInfoHeader.txt rename to backend/licenseinfo/src/main/resources/DefaultLicenseInfoHeader.txt diff --git a/backend/src/src-licenseinfo/src/main/resources/DefaultObligations.txt b/backend/licenseinfo/src/main/resources/DefaultObligations.txt similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/DefaultObligations.txt rename to backend/licenseinfo/src/main/resources/DefaultObligations.txt diff --git a/backend/src/src-licenseinfo/src/main/resources/sw360.properties b/backend/licenseinfo/src/main/resources/sw360.properties similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/sw360.properties rename to backend/licenseinfo/src/main/resources/sw360.properties diff --git a/backend/src/src-licenseinfo/src/main/resources/templateFrontpageContent.docx b/backend/licenseinfo/src/main/resources/templateFrontpageContent.docx similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/templateFrontpageContent.docx rename to backend/licenseinfo/src/main/resources/templateFrontpageContent.docx diff --git a/backend/src/src-licenseinfo/src/main/resources/templateReport.docx b/backend/licenseinfo/src/main/resources/templateReport.docx similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/templateReport.docx rename to backend/licenseinfo/src/main/resources/templateReport.docx diff --git a/backend/src/src-licenseinfo/src/main/resources/textLicenseInfoFile.vm b/backend/licenseinfo/src/main/resources/textLicenseInfoFile.vm similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/textLicenseInfoFile.vm rename to backend/licenseinfo/src/main/resources/textLicenseInfoFile.vm diff --git a/backend/src/src-licenseinfo/src/main/resources/velocity-tools.xml b/backend/licenseinfo/src/main/resources/velocity-tools.xml similarity index 100% rename from backend/src/src-licenseinfo/src/main/resources/velocity-tools.xml rename to backend/licenseinfo/src/main/resources/velocity-tools.xml diff --git a/backend/src/src-licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm b/backend/licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm similarity index 97% rename from backend/src/src-licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm rename to backend/licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm index c83af7ab4f..150907e40c 100644 --- a/backend/src/src-licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm +++ b/backend/licenseinfo/src/main/resources/xhtmlLicenseInfoFile.vm @@ -6,12 +6,12 @@ - + - - - -
- -
- -<%@ include file="/html/utils/includes/pageSpinner.jspf" %> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/fossyAdmin/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/fossyAdmin/view.jsp deleted file mode 100644 index 603ff50a06..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/fossyAdmin/view.jsp +++ /dev/null @@ -1,192 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.portal.portlets.admin.FossologyAdminPortlet" %> -<%@ page import="org.eclipse.sw360.portal.common.FossologyConnectionHelper" %> - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
- -
-
"> - -
-
- -
-
- - - - - - - - - - - -
- : - - -
-
-
-
-
- - - -
- - - - - - - - - - - - - - - -
-
- - " name="<%=PortalConstants.FOSSOLOGY_CONFIG_KEY_URL%>" - value="" /> -
- -
-
-
-
- - " name="<%=PortalConstants.FOSSOLOGY_CONFIG_KEY_FOLDER_ID%>" - value="" /> -
- -
-
-
-
- - " name="<%=PortalConstants.FOSSOLOGY_CONFIG_KEY_TOKEN%>" - value="" /> -
- -
-
-
-
-
-
-
-
-
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/importexport/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/importexport/view.jsp deleted file mode 100644 index f83e69dbb1..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/importexport/view.jsp +++ /dev/null @@ -1,156 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - -
-
-
"> - -
-
-
-
-

-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- -
-

-
-
-
- -
- -
-
-
- -
-
-
-
-
-
- -
- -
-
-
- -
-
-
-
-
-
- -
- -
-
-
- -
-
-
-
-
-
- -
- -
-
-
- -
-
-
-
-
-
- -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseAdmin/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseAdmin/view.jsp deleted file mode 100644 index 3e3e5a6620..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseAdmin/view.jsp +++ /dev/null @@ -1,293 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. - ~ Copyright Bosch Software Innovations GmbH, 2016. - ~ Copyright TOSHIBA CORPORATION, 2021. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. - ~ Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - -
-
-
-
-
- -
-
"> - -
-
-
-
-

-
-
- -
- -
-
-
- - -
-
- - -
- - -
-
-
-
-
-
- -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/add.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/add.jsp deleted file mode 100644 index 7a3ef356f2..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/add.jsp +++ /dev/null @@ -1,138 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp"%> - -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.LicenseType" %> - - - - - - -
-
-
-
-
- -
-
- -
-
-
- - - - - - - - - - - -
-
- - " name="<%=LicenseType._Fields.LICENSE_TYPE%>"/> -
- -
-
- -
-
-
-
-
-
-
-
-
- -
- -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/view.jsp deleted file mode 100644 index f4cfe6995b..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/licenseTypes/view.jsp +++ /dev/null @@ -1,217 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
(${licenseTypeList.size()})"> - (${licenseTypeList.size()}) -
-
- -
-
- - - - - -
-
-
- -
-
-
-<%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/oauthclient/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/oauthclient/view.jsp deleted file mode 100644 index 0417d74caf..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/oauthclient/view.jsp +++ /dev/null @@ -1,460 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - -
-
-
-
-
- -
-
()"> - () -
-
- -
-
- - - - - - - - - -
-
-
-
-
-
- -
-
- - - - - - - - - - - - -
-
- - " - class="form-control" required pattern=".*\S.*" placeholder=""/> -
- -
-
-
-
- - " - placeholder="" class="form-control" required - pattern=".*\S.*" /> -
- -
-
-
-
- -
- - -
- - -
-
-
- - " - class="form-control w-50 d-inline" required pattern="\d+" /> - -
-
-
- - " - class="form-control w-50 d-inline" required pattern="\d+" /> - -
-
- -
-
-
- <%@ include file="/html/utils/includes/pageSpinner.jspf" %> -
- -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/add.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/add.jsp deleted file mode 100644 index 58047fb72e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/add.jsp +++ /dev/null @@ -1,306 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017. - ~ Copyright TOSHIBA CORPORATION, 2021. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. - ~ Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp"%> - -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.Obligation" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.ObligationLevel" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.ObligationType" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.ObligationNode" %> - - - - - - - - - - -
-
-
-
-
- -
-
- -
-
-
- - - - - - - - - - - <%@ include file="obligationTextTree.jsp" %> - -
-
- - " name="<%=Obligation._Fields.TITLE%>"/> -
- -
-
- -
-
- -
- - -
-
- - - - - - -
-
-
-
-
-
-
-
- -
- -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/ajax/searchObligationElementsAjax.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/ajax/searchObligationElementsAjax.jsp deleted file mode 100644 index f8b12a38b4..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/ajax/searchObligationElementsAjax.jsp +++ /dev/null @@ -1,37 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp"%> - - - - - - - - - -
- " action="" object=""> -
- - - - - - - - - - - -
-
diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/obligationChangelog.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/obligationChangelog.jsp deleted file mode 100644 index 62ae06de7e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/obligationChangelog.jsp +++ /dev/null @@ -1,63 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@include file="/html/init.jsp" %> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - - - -
-
-
-
-
- -
-
"> - -
-
-
-
- -
-
-
-
-
- - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/searchObligationElements.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/searchObligationElements.jsp deleted file mode 100644 index 78b8c1e15b..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/includes/searchObligationElements.jsp +++ /dev/null @@ -1,67 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@include file="/html/init.jsp" %> - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - - -<%@ include file="/html/utils/includes/requirejs.jspf" %> -
-
" class="modal fade" tabindex="-1" role="dialog"> - -
-
\ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/obligationTextTree.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/obligationTextTree.jsp deleted file mode 100644 index cc9094fd6c..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/obligationTextTree.jsp +++ /dev/null @@ -1,494 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp"%> -<%@ page import="org.eclipse.sw360.portal.users.UserCacheHolder" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.Obligation" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.ObligationElement" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.ObligationNode" %> - - - - -
- -
- -
-
-
-
-
-
-
    -
  • - "> - - » - + - -
  • -
-
- -
- -
- -
-

-                                
-
-
-
-
- - -
- <%@ include file="/html/admin/obligations/includes/searchObligationElements.jsp" %> - <%@ include file="/html/utils/includes/requirejs.jspf" %> -
- - - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/view.jsp deleted file mode 100644 index 2082bbc915..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/obligations/view.jsp +++ /dev/null @@ -1,215 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
(${obligList.size()})"> - (${obligList.size()}) -
-
- -
-
- - - - - - - -
-
-
- -
-
-
-<%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/scheduleAdmin/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/scheduleAdmin/view.jsp deleted file mode 100644 index 85dfba3d39..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/scheduleAdmin/view.jsp +++ /dev/null @@ -1,321 +0,0 @@ -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %><%-- - ~ Copyright (c) Bosch Software Innovations GmbH 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
"> - -
-
- -
-
-

- - - - - - - - - - - - - -
${cvesearchOffset} (hh:mm:ss)
${cvesearchInterval} (hh:mm:ss)
${cvesearchNextSync}
-
-
- - -
-
-
-
-
-
-

- - - - - - - - - - - - - -
${srcUploadOffset} (hh:mm:ss)
${srcUploadInterval} (hh:mm:ss)
${srcUploadNextSync}
-
-
- - -
-
-
-
- -
-
-

SVM Vulnerabilities Sync

- - - - - - - - - - - - - -
Schedule Offset${svmSyncOffset} (hh:mm:ss)
Interval${svmSyncInterval} (hh:mm:ss)
Next Synchronization${svmSyncNextSync}
-
-
- - -
-
-
-
-
-
-

SVM Vulnerabilities Reverse Match

- - - - - - - - - - - - - -
Schedule Offset${svmMatchOffset} (hh:mm:ss)
Interval${svmMatchInterval} (hh:mm:ss)
Next Synchronization${svmMatchNextSync}
-
-
- - -
-
-
-
-
-
-

SVM Monitoring List Update

- - - - - - - - - - - - - -
Schedule Offset${svmListUpdateOffset} (hh:mm:ss)
Interval${svmListUpdateInterval} (hh:mm:ss)
Next Synchronization${svmListUpdateNextSync}
-
-
- - -
-
-
-
-
-
-

SVM Release Tracking Feedback

- - - - - - - - - - - - - -
Schedule Offset${trackingFeedbackOffset} (hh:mm:ss)
Interval${trackingFeedbackInterval} (hh:mm:ss)
Next Synchronization${trackingFeedbackNextSync}
-
-
- - -
-
-
-
-
-
-
-

- - - - - - - - - - - - - -
-
-
- - -
-
-
-
-
-
-

-
-
- - - - - - - - -
-
- -
-
-
-
-
diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/detail.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/detail.jsp deleted file mode 100644 index d88293d651..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/detail.jsp +++ /dev/null @@ -1,147 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%> - -<%@include file="/html/init.jsp"%> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants"%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil"%> -<%@ page import="javax.portlet.PortletRequest"%> - - - - - - - -<%@include file="/html/utils/includes/logError.jspf"%> - - - - - - -
-
-
- -
- ! .
- -
-
- -
- ! .
- -
-
-
-
- -
-
"> - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:
:
:
:
: - - - - -
:
: - - - - - - - , - - -
:
:
-
-
-
-
-
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/edit.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/edit.jsp deleted file mode 100644 index 1257faa71b..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/edit.jsp +++ /dev/null @@ -1,322 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> - -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil"%> -<%@ page import="javax.portlet.PortletRequest"%> -<%@ page import="org.eclipse.sw360.datahandler.common.SW360Constants"%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants"%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.User"%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.UserGroup"%> - -<%@ include file="/html/init.jsp"%> -<%@ include file="/html/utils/includes/logError.jspf"%> -<%@ include file="/html/utils/includes/requirejs.jspf"%> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - -
-
-
- - -
- ! .
- -
-
- -
- ! .
- -
-
-
-
-
- -
- -
"> - -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- " class="form-control" - value="" required pattern=".*\S.*" /> -
-
-
- - " value="" /> -
-
-
- - " name="<%=User._Fields.EMAIL%>" - placeholder="" required /> -
-
-
- - " - value="" /> -
-
-
- - " - value="" /> -
-
-
- - -
-
-
- - required pattern=".*\S.*" placeholder="" /> -
-
-
- - - <%@include file="/html/utils/includes/editSecondaryDepartmentAndRoles.jsp"%> -
- <%@include file="/html/utils/includes/editOauthClientId.jsp"%> -
-
-
-
-
-
-
- -
- -
- -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/view.jsp deleted file mode 100644 index 02e99ef201..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/user/view.jsp +++ /dev/null @@ -1,473 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants"%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.UserGroup"%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil"%> -<%@ page import="javax.portlet.PortletRequest"%> - -<%@ include file="/html/init.jsp"%> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
(${couchDbUserCount})"> - - (${couchDbUserCount}) -
-
- -
-
-

- -

- -
-
- <%@ include file="/html/utils/includes/pageSpinner.jspf"%> -
-

- -

- -
-
- <%@ include file="/html/utils/includes/pageSpinner.jspf"%> -
-

- -

-
-
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
- -
-
- - - - - - - - -
- - -
-
- -
-<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf"%> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/edit.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/edit.jsp deleted file mode 100644 index 7fd7fee66b..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/edit.jsp +++ /dev/null @@ -1,184 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp"%> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="com.liferay.portal.kernel.util.PortalUtil" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.vendors.Vendor" %> - - - - - - - - - - - - - - - - - - -
-
-
-
-
- -
-
"> - -
-
- -
-
-
- - - - - - - - - - - - - -
-
- - " name="<%=Vendor._Fields.FULLNAME%>" - value="" /> -
- -
-
-
-
- - " - name="<%=Vendor._Fields.SHORTNAME%>" - value="" /> - -
- -
-
-
-
- - " name="<%=Vendor._Fields.URL%>" - value="" /> -
- -
-
-
-
-
-
- -
-
- -

- - - - - - - - - - - -
-
-
-
-
-
-
- -
- -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/mergeVendor.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/mergeVendor.jsp deleted file mode 100644 index cf5a19d8b5..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/mergeVendor.jsp +++ /dev/null @@ -1,286 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - -
-
-
"> - -
-
-
-
-
-
    -

  • -

  • -

  • -
-
-
-
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
- - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/view.jsp deleted file mode 100644 index 152963d9b2..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/vendors/view.jsp +++ /dev/null @@ -1,210 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
(${vendorList.size()})"> - (${vendorList.size()}) -
-
- -
-
-
-
-
- -
-
-
- -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/view.jsp deleted file mode 100644 index 202dd372e5..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/admin/view.jsp +++ /dev/null @@ -1,79 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project. - - With contributions by Bosch Software Innovations GmbH, 2016-2017. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@include file="/html/init.jsp" %> - - - - -
-
-
"> - -
-
-
-
- -
-
-
diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/changelogs/elementView.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/changelogs/elementView.jsp deleted file mode 100644 index 313eec77ea..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/changelogs/elementView.jsp +++ /dev/null @@ -1,555 +0,0 @@ - -<%@include file="/html/init.jsp" %> - - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - - - - - - -
-
-
-
-
-
- <%@ include file="/html/utils/includes/pageSpinner.jspf" %> -
-
-
-
- -
-
-
-

-
- -
-
- -
-
- -
-
- - - - - -
- - - -
- - - - - - - - -
- - - -
- \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/departmentSearch.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/departmentSearch.jsp deleted file mode 100644 index 30d9f6ffa8..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/departmentSearch.jsp +++ /dev/null @@ -1,37 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp"%> - - - - - - - - - - "> - - - PRIMARY - - - - - - - "> - - - SECONDARY - - - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/vendorSearch.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/vendorSearch.jsp deleted file mode 100644 index d3292b6af8..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/ajax/vendorSearch.jsp +++ /dev/null @@ -1,29 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp"%> - - - - - - - - - - - "> - - - - - - - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkRelease.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkRelease.jsp deleted file mode 100644 index 857fb0be3a..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkRelease.jsp +++ /dev/null @@ -1,121 +0,0 @@ -<%-- - ~ Copyright (C) TOSHIBA CORPORATION, 2023. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> - - - - - - - - - -<%@ include file="/html/utils/includes/logError.jspf" %> - - - -
- -
- - - - - - - - - - <%@include file="/html/init.jsp" %> - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - "> - - - - - - - - - - - "> - - - - - - - - - - -
- - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkReleasePreview.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkReleasePreview.jsp deleted file mode 100644 index 956d4e44e6..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/deleteBulkReleasePreview.jsp +++ /dev/null @@ -1,117 +0,0 @@ -<%-- - ~ Copyright (C) TOSHIBA CORPORATION, 2023. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> - - - - - - - - - - -<%@ include file="/html/utils/includes/logError.jspf" %> - - - -
- -
- - - - - - - - - - <%@include file="/html/init.jsp" %> - - - - - - - - - - - - - - - - - - - - - -
- - - "> - - - - - - - - - - - "> - - - - - - - - - -
- - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detail.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detail.jsp deleted file mode 100644 index ec0ac1ee65..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detail.jsp +++ /dev/null @@ -1,47 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ With modifications by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - - - <%@include file="/html/components/includes/components/detailOverview.jspf"%> - - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detailRelease.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detailRelease.jsp deleted file mode 100644 index 8d52ac7585..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/detailRelease.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ With modifications by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="org.eclipse.sw360.datahandler.common.SW360Constants" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - - - - - - - - - - - - - - - - - - - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - - - - <%@include file="/html/components/includes/releases/detailOverview.jspf"%> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/edit.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/edit.jsp deleted file mode 100644 index 2d2916fce2..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/edit.jsp +++ /dev/null @@ -1,352 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.attachments.Attachment" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.portal.portlets.projects.ProjectPortlet" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.RequestedAction" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus" %> -<%@ page import="org.eclipse.sw360.portal.common.page.PortletReleasePage" %> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<%--These variables are used as a trick to allow referencing enum values in EL expressions below--%> - - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - - - - - - - <%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -
- -
- - - - <%@include file="/html/components/includes/vendors/searchVendor.jspf" %> - <%@include file="/html/components/includes/departments/searchDepartment.jspf" %> - - - -
\ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/editRelease.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/editRelease.jsp deleted file mode 100644 index bf1738b79e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/editRelease.jsp +++ /dev/null @@ -1,376 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.datahandler.common.SW360Constants" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.attachments.Attachment" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.spdx.spdxdocument.SPDXDocument" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.RequestedAction" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.attachments.CheckStatus" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - -<%-- use require js on this page --%> -<%@include file="/html/utils/includes/requirejs.jspf" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<%--These variables are used as a trick to allow referencing enum values in EL expressions below--%> - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - - - <%@ include file="/html/utils/includes/pageSpinner.jspf" %> -
- -
- - - - - <%@include file="/html/components/includes/vendors/searchVendor.jspf" %> - - - - - -
- - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/clearingStatus.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/clearingStatus.jspf deleted file mode 100644 index 883c863011..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/clearingStatus.jspf +++ /dev/null @@ -1,266 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.page.PortletReleasePage,org.eclipse.sw360.datahandler.thrift.attachments.AttachmentType" %> -<%@ page import="org.eclipse.sw360.portal.common.FossologyConnectionHelper" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> - - - - - - - - - - - -
- -
-
- -
-
- -<%@include file="/html/utils/includes/fossologyClearing.jspf"%> -<%@include file="/html/components/includes/releases/linkProject.jspf"%> - - - - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/detailOverview.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/detailOverview.jspf deleted file mode 100644 index 0f671b5faf..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/detailOverview.jspf +++ /dev/null @@ -1,231 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2016, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - - - - - - - - - - - - - - - - - - - - -<%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -
- -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/editBasicInfo.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/editBasicInfo.jspf deleted file mode 100644 index 449f9c4d0c..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/editBasicInfo.jspf +++ /dev/null @@ -1,297 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - -<%@ page import="org.eclipse.sw360.datahandler.thrift.CycloneDxComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.Visibility" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - " required pattern=".*\S.*" class="form-control" - value="" /> -
- -
-
-
-
- -
-
-
- - " required value=""/> -
- -
-
-
-
- - - - - - -
- -
-
-
-
- - - - - - -
-
- -
-
- - " placeholder=""/> -
-
-
- - " placeholder=""/> -
-
-
- - " value=""/> -
-
-
- - -
- -
- - - - -
-
-
- - " value=""/> -
-
-
- - " value=""/> -
-
-
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - " value=""/> -
-
-
- - " value=""/> -
-
-
- - -
-
- -
- -
- - - - - - - - - - - - - - - - - - - -
- - -
- - " value=""/> -
-
-
- - " value=""/> -
-
-
- - -
-
- -
- -
-
- - - - - - - -<%@include file="/html/utils/includes/mapEdit.jspf" %> - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/summary.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/summary.jspf deleted file mode 100644 index 46f8834138..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/summary.jspf +++ /dev/null @@ -1,217 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ With contributions by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> - - -
-

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
">
-
">
-
-
-
: - -
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    :
    : - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    :
    :
    :
    :
    :
    - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/vulnerabilities.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/vulnerabilities.jspf deleted file mode 100644 index b843db74df..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/components/vulnerabilities.jspf +++ /dev/null @@ -1,270 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2016-2017, 2019. Part of the SW360 Portal Project. - ~ With modifications from Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.RequestStatus" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.VerificationState" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - - - - - - - - - - - -
    -
    -
    - -
    -
    -
    -
    -

    -
    - -
    - -
    - - - -
    -
    -
    -
    -
    -
    -
    -

    -
      - -
    • - - of the vulnerabilities were matched by - -
    • -
      -
    -
    -
    -
    - -<%@include file="/html/utils/includes/vulnerabilityModal.jspf" %> - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/departments/searchDepartment.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/departments/searchDepartment.jspf deleted file mode 100644 index 7da8009962..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/departments/searchDepartment.jspf +++ /dev/null @@ -1,61 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - - - - - -
    -
    " class="modal fade" tabindex="-1" role="dialog" data-view-Department-url="<%=viewDepartmentURL%>"> - -
    -
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/clearingDetails.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/clearingDetails.jspf deleted file mode 100644 index ae6ab1398e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/clearingDetails.jspf +++ /dev/null @@ -1,584 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.portal.common.FossologyConnectionHelper" %> - - - - - - - - - - - - -<%@include file="/html/utils/includes/fossologyClearing.jspf"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    class="actions d-inline" > - - -
    - - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - : -
    -
    ">
    -
    ">
    -
    -
    -
    - - - - - - ! - - - ! - - - ! - - -
    General Assessment
    Critical Files Found
    Dependency Notes
    Export Restrictions Found
    Usage Restrictions Found
    Additional Notes
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - : -
    -
    ">
    -
    ">
    -
    -
    -
    : -
    - - - - - - - - - - - - - - - - - - - -
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    -
    :
    :
    :
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    - - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/commercialDetails.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/commercialDetails.jspf deleted file mode 100644 index 148e35aae8..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/commercialDetails.jspf +++ /dev/null @@ -1,85 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2015-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    :
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    :
    :
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/detailOverview.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/detailOverview.jspf deleted file mode 100644 index 26d75a9410..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/detailOverview.jspf +++ /dev/null @@ -1,310 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - - - - - - - - - - - - - - - - - - - - - - - - -<%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -<%@include file="/html/components/includes/releases/linkProject.jspf" %> - -
    - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/eccDetails.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/eccDetails.jspf deleted file mode 100644 index ddf62f6e1f..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/eccDetails.jspf +++ /dev/null @@ -1,61 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    :
    :
    :
    :
    :
    :
    :
    :
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editCommercialDetails.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editCommercialDetails.jspf deleted file mode 100644 index 33feddaeea..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editCommercialDetails.jspf +++ /dev/null @@ -1,129 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2015-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.COTSDetails" %> - - - - - - - - - - - - - - -
    -
    - " - checked="checked" - /> - -
    -
    - - -
    - - " - pattern="\d{4}-\d{2}-\d{2}" - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    - -
    - - - - - - - - - - - - - - - - -
    -
    - - " - value=""/> -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - - " - value=""/> -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseClearingInformation.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseClearingInformation.jspf deleted file mode 100644 index 8cefbacee9..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseClearingInformation.jspf +++ /dev/null @@ -1,316 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ClearingInformation" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - - " - value=""/> -
    -
    -
    - " - checked="checked" - /> - -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    - - - - - - - - - - - - - - - - - - -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - pattern="\d{4}-\d{2}-\d{2}" - value=""/> -
    -
    -
    - - " - pattern="\d{4}-\d{2}-\d{2}" - value=""/> -
    -
    - - - - - - - - - - - - - -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseECCInformation.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseECCInformation.jspf deleted file mode 100644 index 915bcb9bfe..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseECCInformation.jspf +++ /dev/null @@ -1,127 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ECCStatus" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.EccInformation" %> - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    -
    - - " - value=""/> -
    -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    - - -
    - - " - value=""/> -
    -
    -
    - - " - pattern="\d{4}-\d{2}-\d{2}" - readonly - value=""/> -
    -
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseInformation.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseInformation.jspf deleted file mode 100644 index bad5b65dd3..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseInformation.jspf +++ /dev/null @@ -1,216 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.datahandler.common.SW360Utils" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release"%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.MainlineState" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    - - " /> - - "> - - - - -
    -
    -
    - - " required pattern=".*\S.*" - value="" /> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - placeholder=""/> - - 'cpe:2.3:a:VENDORNAME:COMPONENTNAME:VERSION'"> - - - - -
    -
    -
    - - " - value=""/> -
    -
    -
    - - " - pattern="\d{4}-\d{2}-\d{2}" - value=""/> -
    -
    - -
    - - -
    - - " - value=""/> -
    -
    -
    - - " - value=""/> -
    -
    -
    - - "/> -
    -
    -
    - - - - - - -
    -
    -
    - - " required="" - - value="<%=SW360Utils.getCreatedOn()%>" - - - value="" - - readonly class="form-control"/> -
    -
    - - - - - -
    -
    - - " - value="" readonly class="form-control"/> -
    -
    -
    - -
    -
    -
    - - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseRepository.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseRepository.jspf deleted file mode 100644 index ada66fd0ab..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/editReleaseRepository.jspf +++ /dev/null @@ -1,48 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - -<%@ page import="org.eclipse.sw360.portal.users.UserCacheHolder" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Repository" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.RepositoryType" %> - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    -
    - - " - value=""/> -
    -
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/linkProject.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/linkProject.jspf deleted file mode 100644 index 6143dece47..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/linkProject.jspf +++ /dev/null @@ -1,90 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.util.WebKeys" %> -<%@include file="/html/init.jsp" %> - - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - - - - - - -
    -
    " class="modal fade" tabindex="-1" role="dialog"> - -
    -
    diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/edit.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/edit.jspf deleted file mode 100644 index 54749c7440..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/edit.jspf +++ /dev/null @@ -1,547 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - -<%@include file="/html/utils/includes/requirejs.jspf" %> - -
    -
    - - -
    - <%@include file="/html/components/includes/releases/spdx/includes/editDocumentCreationInformation.jsp" %> - <%@include file="/html/components/includes/releases/spdx/includes/editPackageInformation.jsp" %> - <%@include file="/html/components/includes/releases/spdx/includes/editSnippetInformation.jsp" %> - <%@include file="/html/components/includes/releases/spdx/includes/editOtherLicensingInformationDetected.jsp" %> - <%@include file="/html/components/includes/releases/spdx/includes/editRelationshipsBetweenSPDXElements.jsp"%> - <%@include file="/html/components/includes/releases/spdx/includes/editAnnotations.jsp" %> - - - -
    - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editAnnotations.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editAnnotations.jsp deleted file mode 100644 index da3205021c..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editAnnotations.jsp +++ /dev/null @@ -1,92 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - -
    12. Annotation Information
    -
    - - -
    -
    -
    - - - - - - - - - -
    -
    - -
    - - -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editDocumentCreationInformation.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editDocumentCreationInformation.jsp deleted file mode 100644 index da122a92e0..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editDocumentCreationInformation.jsp +++ /dev/null @@ -1,225 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    6. Document Creation Information
    -
    - -
    - - "> -
    -
    -
    - - "> -
    -
    - -
    - - "> -
    -
    -
    -
    - - "> -
    -
    -
    - - "> -
    -
    -
    - -
    -
    - - - - - - - - - -
    - - -
    -
    - - -
    -
    - -
    -
    - - -
    -
    -
    - -
    -
    - - "> -
    -
    -
    - -
    -
    - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    -
    - -
    -
    - - -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    -
    - - -
    -
    - - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editOtherLicensingInformationDetected.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editOtherLicensingInformationDetected.jsp deleted file mode 100644 index 9724a3fe2f..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editOtherLicensingInformationDetected.jsp +++ /dev/null @@ -1,103 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    10. Other Licensing Information Detected
    -
    -
    - - - - - - - - - -
    -
    - -
    - - -
    -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - - -
    -
    - - -
    -
    -
    -
    -
    - - -
    -
    -
    - - -
    -
    \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editPackageInformation.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editPackageInformation.jsp deleted file mode 100644 index dfda8b9a53..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editPackageInformation.jsp +++ /dev/null @@ -1,528 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    7. Package Information
    -
    -
    - - - - - - - - - -
    -
    - -
    - "> -
    -
    -
    - -
    - - "> -
    -
    -
    -
    - -
    - "> -
    -
    -
    - -
    - "> -
    -
    -
    -
    - -
    -
    - - - -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    - - - -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - -
    -
    - - - - -
    -
    -
    -
    -
    - -
    - - -
    -
    -
    -
    - -
    - -
    -
    - - - - - - - - - - - - - - - -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - - -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - - -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - - -
    -
    -
    - - -
    -
    -
    - - -
    -
    -
    - -
    -
    - - - - - - - - -
    - - -
    -
    - - - - -
    -
    - - -
    -
    - - -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editRelationshipsBetweenSPDXElements.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editRelationshipsBetweenSPDXElements.jsp deleted file mode 100644 index 41127302f9..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editRelationshipsBetweenSPDXElements.jsp +++ /dev/null @@ -1,71 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - -
    11. Relationship between SPDX Elements Information
    -
    - - -
    -
    -
    - - - - - - - - - -
    -
    - -
    - - - -
    -
    -
    -
    - - -
    -
    \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editSnippetInformation.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editSnippetInformation.jsp deleted file mode 100644 index feef5ca681..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/includes/editSnippetInformation.jsp +++ /dev/null @@ -1,200 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    9. Snippet Information
    -
    -
    - - - - - - - - - -
    -
    - -
    - - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - - - - -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - - -
    -
    -
    - -
    -
    - - -
    -
    - - - - -
    -
    -
    -
    -
    - - -
    -
    -
    - - -
    -
    -
    - - -
    -
    \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/view.jsp deleted file mode 100644 index d3aef97ece..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/spdx/view.jsp +++ /dev/null @@ -1,1256 +0,0 @@ -<%-- - ~ Copyright TOSHIBA CORPORATION, 2021. Part of the SW360 Portal Project. - ~ Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2021. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 6. Document Creation Information -
    -
    ">
    -
    ">
    -
    -
    -
    -
    6.1 SPDX version
    -
    - -
    -
    -
    6.2 Data license
    -
    - -
    -
    -
    6.3 SPDX identifier
    -
    - -
    -
    -
    6.4 Document name
    -
    - -
    -
    -
    6.5 SPDX document namespace
    -
    - -
    -
    -
    6.6 External document references
    -
    -
    -
    Index
    - -
    - -
    -
    External document ID
    -
    - -
    -
    -
    -
    External document
    -
    - -
    -
    -
    -
    Checksum
    -
    - - : - -
    -
    -
    -
    -
    -
    6.7 License list version
    -
    - -
    -
    -
    6.8 Creators
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    6.9 Created
    -
    - -
    -
    -
    6.10 Creator comment
    -
    - -
    -
    -
    6.11 Document comment
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 7. Package Information -
    -
    ">
    -
    ">
    -
    -
    -
    -
    7.1 Package name
    -
    - -
    -
    -
    7.2 Package SPDX identifier
    -
    - -
    -
    -
    7.3 Package version
    -
    - -
    -
    -
    7.4 Package file name
    -
    - -
    -
    -
    7.5 Package supplier
    -
    - -
    -
    -
    7.6 Package originator
    -
    - -
    -
    -
    7.7 Package download location
    -
    - -
    -
    -
    7.8 Files analyzed
    -
    - -
    -
    -
    7.9 Package verification code
    -
    -
    -
    Value
    -
    - -
    -
    -
    -
    Excluded files
    -

    - -
    -
    -

    -
    -
    - -
    -
    7.10 Package checksum
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    7.11 Package home page
    -
    - -
    -
    -
    7.12 Source information
    -
    - -
    -
    -
    7.13 Concluded license
    -
    - -
    -
    -
    7.14 All licenses information from files
    -

    - - - -

    -
    -
    7.15 Declared license
    -
    - -
    -
    -
    7.16 Comments on license
    -

    - -

    -
    -
    7.17 Copyright text
    -

    - -

    -
    -
    7.18 Package summary description
    -

    - -

    -
    -
    7.19 Package detailed description
    -

    - -

    -
    -
    7.20 Package comment
    -

    - -

    -
    -
    7.21 External references
    - -
    -
    -
    Index
    - -
    - -
    -
    Category
    -
    - -
    -
    -
    -
    Type
    -
    - -
    -
    -
    -
    Locator
    -
    - -
    -
    -
    -
    7.22 Comment
    -

    - -

    -
    -
    - -
    -
    -
    7.23 Package attribution text
    -

    - -
    -
    -

    -
    -
    7.24 Primary Package Purpose
    -
    - -
    -
    -
    7.25 Release Date
    -

    - -

    -
    -
    7.26 Built Date
    -

    - -

    -
    -
    7.27 Valid Until Date
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 9. Snippet Information -
    -
    ">
    -
    ">
    -
    -
    -
    -
    Index
    - -
    -
    9.1 Snippet SPDX identifier
    -
    - -
    -
    -
    9.2 Snippet from file SPDX identifier
    -
    - -
    -
    -
    9.3 & 9.4 Snippet ranges
    -
    - -
    -
    - -
    -
    -
    - -
    -
    ~
    -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -
    9.5 Snippet concluded license
    -
    - -
    -
    -
    9.6 License information in snippet
    -

    - -
    -
    -

    -
    -
    9.7 Snippet comments on license
    -

    - -

    -
    -
    9.8 Snippet copyright text
    -

    - -

    -
    -
    9.9 Snippet comment
    -

    - -

    -
    -
    9.10 Snippet name
    -

    - -

    -
    -
    9.11 Snippet attribution text
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 10. Other Licensing Information Detected -
    -
    ">
    -
    ">
    -
    -
    -
    -
    Index
    - -
    -
    10.1 License identifier
    -
    - -
    -
    -
    10.2 Extracted text
    -

    - -

    -
    -
    10.3 License name
    -
    - -
    -
    -
    10.4 License cross reference
    -

    - -
    -
    -

    -
    -
    10.5 License comment
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 11. Relationship between SPDX Elements Information -
    -
    ">
    -
    ">
    -
    -
    -
    -
    Source
    - -
    -
    Index
    - -
    -
    11.1 Relationship
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    11.2 Relationship comment
    -

    - -

    -
    -
    11.1 Relationship
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    11.2 Relationship comment
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - 12. Annotation Information -
    -
    ">
    -
    ">
    -
    -
    -
    -
    Source
    - -
    -
    Index
    - -
    -
    12.1 Annotator
    -

    - -

    - -
    -
    12.2 Annotation date
    -

    - -

    -
    -
    12.3 Annotation type
    -
    -
    -
    - -
    -
    -
    -
    -
    12.4 SPDX identifier reference
    -
    - -
    -
    -
    12.5 Annotation comment
    -

    - -

    -
    -
    12.1 Annotator
    -

    - -

    - -
    -
    12.2 Annotation date
    -

    - -

    -
    -
    12.3 Annotation type
    -
    -
    -
    - -
    -
    -
    -
    -
    12.4 SPDX identifier reference
    -
    - -
    -
    -
    12.5 Annotation comment
    -

    - -

    -
    - - - - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/summaryRelease.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/summaryRelease.jspf deleted file mode 100644 index d7e877c190..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/releases/summaryRelease.jspf +++ /dev/null @@ -1,156 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ With modifications by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    ">
    -
    ">
    -
    -
    -
    : - -
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : - -
    : - -
    :
    :
    :
    :
      - - - - - - - - - - - - - - -
      -
      - -
      -
      ">
      -
      ">
      -
      -
      -
      :
      -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> -<%@ include file="/html/utils/includes/licenseToSrcMapping.jspf" %> -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/addVendor.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/addVendor.jspf deleted file mode 100644 index 4d2ae0f3f9..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/addVendor.jspf +++ /dev/null @@ -1,68 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - -
      -
      " class="modal fade" tabindex="-1" role="dialog" data-add-vendor-url="<%=addVendorURL%>"> - -
      -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/searchVendor.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/searchVendor.jspf deleted file mode 100644 index 0f07d92afe..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/searchVendor.jspf +++ /dev/null @@ -1,69 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - -
      -
      " class="modal fade" tabindex="-1" role="dialog" data-view-vendor-url="<%=viewVendorURL%>"> - -
      -
      - -<%@include file="/html/components/includes/vendors/addVendor.jspf" %> diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/vendorDetail.jspf b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/vendorDetail.jspf deleted file mode 100644 index 89f24c6d5e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/includes/vendors/vendorDetail.jspf +++ /dev/null @@ -1,39 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> - - - - - - - - - - - - - - - - - - - - - -
      -
      - -
      -
      ">
      -
      ">
      -
      -
      -
      :
      :
      :
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeComponent.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeComponent.jsp deleted file mode 100644 index b305bed7e3..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeComponent.jsp +++ /dev/null @@ -1,439 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.User" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.common.ThriftEnumUtils" %> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - -
      -
      -
      ${sw360:printComponentName(component)}"> - -
      -
      -
      -
      -
      -
        -

      • -

      • -

      • -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeRelease.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeRelease.jsp deleted file mode 100644 index 0cbf274aa9..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/mergeRelease.jsp +++ /dev/null @@ -1,787 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.User" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.common.ThriftEnumUtils" %> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - -
      -
      -
      ${sw360:printReleaseName(release)}"> - -
      -
      -
      -
      -
      -
        -

      • -

      • -

      • -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/splitComponent.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/splitComponent.jsp deleted file mode 100644 index f63bf65917..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/splitComponent.jsp +++ /dev/null @@ -1,346 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.User" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.common.ThriftEnumUtils" %> - -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - -
      -
      -
      ${sw360:printComponentName(component)}"> - -
      -
      -
      -
      -
      -
        -

      • -

      • -

      • -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      - -
      - -
      -
      -
      -
      -
      -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/view.jsp deleted file mode 100644 index 5118fedf26..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/components/view.jsp +++ /dev/null @@ -1,529 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2019. Part of the SW360 Portal Project. - ~ With modifications by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.ComponentType" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.DateRange" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<%@ include file="/html/utils/includes/pageSpinner.jspf" %> - -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> -<%@ include file="/html/utils/includes/importBomForComponent.jspf" %> - - \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/ecc/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/ecc/view.jsp deleted file mode 100644 index b1481868d2..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/ecc/view.jsp +++ /dev/null @@ -1,104 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 ---%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@ include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - -
      -
      - -
      -
      -
      "> - -
      -
      - -
      -
      - -
      -
      -
      -
      -
      -
      - -<%--for javascript library loading --%> -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mycomponents/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mycomponents/view.jsp deleted file mode 100644 index 5d48901740..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mycomponents/view.jsp +++ /dev/null @@ -1,96 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ With contributions by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp" %> - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - -
      -

      ">

      -
      -
      - - - - - -
      -
      -
      -
      - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/myprojects/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/myprojects/view.jsp deleted file mode 100644 index fafaad0a1b..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/myprojects/view.jsp +++ /dev/null @@ -1,216 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ With contributions by Siemens Healthcare Diagnostics Inc, 2018. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp" %> - - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - -
      -

      - My Projects - - -

      -
      -
      - - - - - - -
      -
      -
      -
      - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mysubscriptions/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mysubscriptions/view.jsp deleted file mode 100644 index 3802894b4f..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mysubscriptions/view.jsp +++ /dev/null @@ -1,57 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.portal.portlets.Sw360Portlet" %> -<%@ page import="org.eclipse.sw360.portal.portlets.components.ComponentPortlet" %> - -<%@include file="/html/init.jsp" %> - - - - - - - -

      - -
      -
      -
      - -
    • -
      -
    • -
      -
      -
      -
      - - -
      -
      -
      -
        - -
      • -
        -
      • -
        -
      -
      -
      -
      - - -
      - -
      -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytaskassignments/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytaskassignments/view.jsp deleted file mode 100644 index f327e27337..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytaskassignments/view.jsp +++ /dev/null @@ -1,95 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp" %> - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - -
      -

      ">

      -
      -
      - - - - - -
      -
      -
      -
      - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytasksubmissions/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytasksubmissions/view.jsp deleted file mode 100644 index f54dd7a1a4..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/mytasksubmissions/view.jsp +++ /dev/null @@ -1,168 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp" %> - - - -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - - - - - - - - - -
      -

      ">

      -
      -
      - - - - - - -
      -
      -
      -
      - -
      - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentcomponents/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentcomponents/view.jsp deleted file mode 100644 index 9dfe9c9901..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentcomponents/view.jsp +++ /dev/null @@ -1,50 +0,0 @@ -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.portal.portlets.Sw360Portlet" %> -<%@ page import="org.eclipse.sw360.portal.portlets.components.ComponentPortlet" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.RequestedAction" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp" %> - - - - - - - - -

      -
      -
      - -
        - -
      • - - -
        -
        - - - -
        -
      • -
        -
      -
      - -
      -
      -
      -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentreleases/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentreleases/view.jsp deleted file mode 100644 index fcbc179196..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/recentreleases/view.jsp +++ /dev/null @@ -1,49 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="org.eclipse.sw360.portal.portlets.Sw360Portlet" %> -<%@ page import="org.eclipse.sw360.portal.portlets.components.ComponentPortlet" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.RequestedAction" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -<%@include file="/html/init.jsp" %> - - - - - - - -

      -
      -
      - -
        - -
      • - - - - - - - - -
      • -
        -
      -
      - -
      -
      -
      -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/success.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/success.jsp deleted file mode 100644 index fca2ef3ec0..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/success.jsp +++ /dev/null @@ -1,34 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2016, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@include file="/html/init.jsp" %> - - - - - -
      - - ${welcomePageGuideLine} - - -

      -

      - -

      -
      -
      - -
      - -
      -
      diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/view.jsp deleted file mode 100644 index e9d857763e..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/signup/view.jsp +++ /dev/null @@ -1,139 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@ page import="com.liferay.portal.kernel.servlet.SessionMessages" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.User" %> -<%@ page import="org.eclipse.sw360.datahandler.thrift.users.UserGroup" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> - -<%@include file="/html/init.jsp" %> - -<%-- the following is needed by liferay to display error messages--%> - - <%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> -<%-- - " /> ---%> - - - - - - - -
      - - ${welcomePageGuideLine} - - -

      -

      - -

      -
      -
      - -

      -
      - -
      -
      - -

      -
      -
      -
      - - " id="given_name"> -
      - -
      -
      -
      - - " id="last_name"> -
      - -
      -
      -
      - - " id="email"> -
      - -
      -
      -
      - - -
      - -
      -
      -
      - - -
      - -
      - - - - -
      -
      - - -
      - -
      -
      -
      - - -
      - -
      -
      -
      - - -
      - -
      -
      - -
      -
      -
      -
      - -<%@ include file="/html/utils/includes/requirejs.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/welcome/view.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/welcome/view.jsp deleted file mode 100644 index 62f935461d..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/homepage/welcome/view.jsp +++ /dev/null @@ -1,45 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2016, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@include file="/html/init.jsp" %> - - - -
      - - ${welcomePageGuideLine} - - -

      - <%-- Select Language --%> - - - - -
      -

      - -

      -
      -
      - -

      -
      - -
      -
      - -

      -
      - - -
      -
      -
      \ No newline at end of file diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/init.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/init.jsp deleted file mode 100644 index f5aafafff9..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/init.jsp +++ /dev/null @@ -1,25 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2013-2015. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> - -<%@ page contentType="text/html; charset=UTF-8" %> - -<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="core_rt"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> - -<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%> -<%@ taglib uri="http://liferay.com/tld/clay" prefix="clay" %> -<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%> -<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security"%> -<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%> -<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%> -<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util"%> - -<%@ taglib uri="http://example.com/tld/customTags.tld" prefix="sw360"%> diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/detail.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/detail.jsp deleted file mode 100644 index e89d52b1d4..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/detail.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%-- - ~ Copyright Siemens AG, 2013-2015, 2019. Part of the SW360 Portal Project. - ~ With modifications by Bosch Software Innovations GmbH, 2016. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@include file="/html/init.jsp" %> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - - - <%@include file="includes/detailOverview.jspf" %> - diff --git a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/edit.jsp b/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/edit.jsp deleted file mode 100644 index 78b6ad43f8..0000000000 --- a/frontend/sw360-portlet/src/main/resources/META-INF/resources/html/licenses/edit.jsp +++ /dev/null @@ -1,203 +0,0 @@ -<%-- - ~ Copyright Siemens AG, 2016-2017, 2019. Part of the SW360 Portal Project. - ~ - ~ This program and the accompanying materials are made - ~ available under the terms of the Eclipse Public License 2.0 - ~ which is available at https://www.eclipse.org/legal/epl-2.0/ - ~ - ~ SPDX-License-Identifier: EPL-2.0 - --%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> -<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %> -<%@ page import="javax.portlet.PortletRequest" %> -<%@ page import="java.util.ArrayList" %> - -<%@include file="/html/init.jsp"%> -<%-- the following is needed by liferay to display error messages--%> -<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<%@include file="/html/utils/includes/logError.jspf" %> - - -