diff --git a/.github/workflows/check-junit-test.yml b/.github/workflows/check-junit-test.yml index f953642c9eb..4331f156cf5 100644 --- a/.github/workflows/check-junit-test.yml +++ b/.github/workflows/check-junit-test.yml @@ -51,6 +51,5 @@ jobs: uses: ./.github/workflows/test-analysis.yml with: test_profile: ${{ needs.get_profiles.outputs.profiles }} - report_context: development mvn_opts: ${{ inputs.mvn_opts }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index a6d37f1e39c..50c396dd7cc 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -9,34 +9,26 @@ on: jobs: build: - uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop with: maven_opts: -P storage-hadoop,hdp3.1,RClient,opencga-storage-hadoop-deps -Dopencga.war.name=opencga -Dcheckstyle.skip -pl '!:opencga-storage-hadoop-deps-emr6.1,!:opencga-storage-hadoop-deps-hdp2.6' - deploy-docker-ext-tools: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x - needs: build - with: - cli: python3 ./build/cloud/docker/docker-build.py push --images ext-tools --tag ${{ needs.build.outputs.version }} - secrets: inherit - test: uses: ./.github/workflows/test-analysis.yml - needs: deploy-docker-ext-tools - secrets: inherit + needs: build with: test_profile: runShortTests,runMediumTests - report_context: development + secrets: inherit deploy-maven: - uses: opencb/java-common-libs/.github/workflows/deploy-maven-repository-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/deploy-maven-repository-workflow.yml@develop needs: test with: maven_opts: -P storage-hadoop,hdp3.1 -Dopencga.war.name=opencga secrets: inherit deploy-docker: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop needs: test with: cli: python3 ./build/cloud/docker/docker-build.py push --images base,init diff --git a/.github/workflows/docker-aws-emr.yml b/.github/workflows/docker-aws-emr.yml index 98157167216..b44a777134d 100644 --- a/.github/workflows/docker-aws-emr.yml +++ b/.github/workflows/docker-aws-emr.yml @@ -8,15 +8,13 @@ on: jobs: build: - uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop with: maven_opts: -P storage-hadoop,emr6.1 -Dopencga.war.name=opencga deploy-docker: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop needs: build with: cli: python3 ./build/cloud/docker/docker-build.py push --images base,init secrets: inherit -# DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} -# DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} diff --git a/.github/workflows/docker-tools.yml b/.github/workflows/docker-ext-tools.yml similarity index 74% rename from .github/workflows/docker-tools.yml rename to .github/workflows/docker-ext-tools.yml index 32e938c5a2d..6ded6d96fbe 100644 --- a/.github/workflows/docker-tools.yml +++ b/.github/workflows/docker-ext-tools.yml @@ -1,4 +1,4 @@ -name: Deploy Docker Tools +name: Deploy Docker Ext-Tools on: push: @@ -8,17 +8,14 @@ on: - TASK-* paths: - opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile - workflow_dispatch: jobs: build: - uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@release-4.8.x - with: - maven_opts: + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop deploy-docker-ext-tools: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop needs: build with: cli: python3 ./build/cloud/docker/docker-build.py push --images ext-tools --tag ${{ needs.build.outputs.version }} - secrets: inherit + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/long-test-analysis.yml b/.github/workflows/long-test-analysis.yml index f516eb25029..c898c4dfa0b 100644 --- a/.github/workflows/long-test-analysis.yml +++ b/.github/workflows/long-test-analysis.yml @@ -1,15 +1,17 @@ name: Long test for run only on weekend -#Every Saturday at 01:10 + +## Every Saturday at 01:10 on: schedule: - cron: '10 1 * * 6' + workflow_dispatch: jobs: test: uses: ./.github/workflows/test-analysis.yml secrets: inherit with: - test_profile: runLongTests,runMediumTests,runShortTests - report_context: development + test_profile: runShortTests,runMediumTests,runLongTests, + diff --git a/.github/workflows/manual-deploy-docker.yml b/.github/workflows/manual-deploy-docker.yml new file mode 100644 index 00000000000..3c9660bbb2c --- /dev/null +++ b/.github/workflows/manual-deploy-docker.yml @@ -0,0 +1,50 @@ +name: Manual deploy Docker base +on: + workflow_dispatch: + inputs: + branch: + description: "The branch, tag or SHA of the source code to build docker." + type: string + required: true + tag: + description: "The tag for the new docker." + type: string + required: true + +jobs: + build: + name: Build Java app + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.get_project_version.outputs.version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: '10' + ref: "${{ inputs.branch }}" + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + cache: 'maven' + - name: Install dependencies branches + run: | + if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then + chmod +x ./.github/workflows/scripts/get_same_branch.sh + ./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} + fi + - name: Maven Build (skip tests) + run: mvn -T 2 clean install -DskipTests + - uses: actions/upload-artifact@v3 + with: + name: build-folder + path: build + + + deploy-docker: + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop + needs: build + with: + cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag ${{ inputs.tag }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/manual-deploy-ext-tools.yml b/.github/workflows/manual-deploy-ext-tools.yml new file mode 100644 index 00000000000..3f64fd392de --- /dev/null +++ b/.github/workflows/manual-deploy-ext-tools.yml @@ -0,0 +1,50 @@ +name: Manual deploy Docker Ext-Tools +on: + workflow_dispatch: + inputs: + branch: + description: "The branch, tag or SHA of the source code to build docker." + type: string + required: true + tag: + description: "The tag for the new docker." + type: string + required: true + +jobs: + build: + name: Build Java app + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.get_project_version.outputs.version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: '10' + ref: "${{ inputs.branch }}" + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + cache: 'maven' + - name: Install dependencies branches + run: | + if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then + chmod +x ./.github/workflows/scripts/get_same_branch.sh + ./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} + fi + - name: Maven Build (skip tests) + run: mvn -T 2 clean install -DskipTests + - uses: actions/upload-artifact@v3 + with: + name: build-folder + path: build + + + deploy-docker-ext-tools: + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop + needs: build + with: + cli: python3 ./build/cloud/docker/docker-build.py push --images ext-tools --tag ${{ inputs.tag }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pull-request-merge.yml b/.github/workflows/pull-request-merge.yml index ff9fbdc3c1e..3e3e5bb46b9 100644 --- a/.github/workflows/pull-request-merge.yml +++ b/.github/workflows/pull-request-merge.yml @@ -3,14 +3,17 @@ name: "Pull Request Merge Workflow" on: pull_request: branches: - - "develop" - - "release-*" + - develop + - release-* types: - closed jobs: + build: + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop + delete-docker: - uses: opencb/java-common-libs/.github/workflows/delete-docker-hub-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/delete-docker-hub-workflow.yml@develop with: cli: python3 ./build/cloud/docker/docker-build.py delete --images base --tag ${{ github.head_ref }} secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c69bdad248..b7fccc7fa3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,54 +8,38 @@ on: jobs: build: - uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop with: maven_opts: -P storage-hadoop,hdp3.1,RClient,opencga-storage-hadoop-deps -Dopencga.war.name=opencga -Dcheckstyle.skip -pl '!:opencga-storage-hadoop-deps-emr6.1,!:opencga-storage-hadoop-deps-hdp2.6' - deploy-docker-ext-tools: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x - needs: build - with: - cli: python3 ./build/cloud/docker/docker-build.py push --images ext-tools --tag ${{ needs.build.outputs.version }} - secrets: inherit - - test: - uses: ./.github/workflows/test-analysis.yml - needs: deploy-docker-ext-tools - secrets: inherit - with: - test_profile: runShortTests,runMediumTests - report_context: xetabase - deploy-maven: - uses: opencb/java-common-libs/.github/workflows/deploy-maven-repository-workflow.yml@release-4.8.x - needs: test + uses: opencb/java-common-libs/.github/workflows/deploy-maven-repository-workflow.yml@develop + needs: build with: maven_opts: -P storage-hadoop,hdp3.1 -Dopencga.war.name=opencga secrets: inherit deploy-docker: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x - needs: test + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop + needs: build with: cli: python3 ./build/cloud/docker/docker-build.py push --images base,init secrets: inherit - - deploy-python: - uses: opencb/java-common-libs/.github/workflows/deploy-python-workflow.yml@release-4.8.x - needs: test + uses: opencb/java-common-libs/.github/workflows/deploy-python-workflow.yml@develop + needs: build with: cli: ./clients/python/python-build.sh push artifact: build-folder secrets: inherit release: - uses: opencb/java-common-libs/.github/workflows/release-github-workflow.yml@release-4.8.x - needs: [ build,test ] + uses: opencb/java-common-libs/.github/workflows/release-github-workflow.yml@develop + needs: [ build, deploy-maven, deploy-docker, deploy-python ] with: artifact: build-folder file: | opencga-client-${{ needs.build.outputs.version }}.tar.gz clients/R/opencgaR_${{ needs.build.outputs.version }}.tar.gz + diff --git a/.github/workflows/scripts/get_same_branch.sh b/.github/workflows/scripts/get_same_branch.sh new file mode 100644 index 00000000000..f217d21e70c --- /dev/null +++ b/.github/workflows/scripts/get_same_branch.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +BRANCH_NAME=$1 + +if [[ -z $BRANCH_NAME ]]; then + echo "The first parameter is mandatory and must be a valid branch name." + exit 1 +fi + +if [[ $BRANCH_NAME != "TASK-"* ]]; then + echo "No need to check dependencies." + exit 0 +fi + +function install(){ + local REPO=$1 + cd /home/runner/work/ || exit 2 + git clone https://github.com/opencb/"$REPO".git -b "$BRANCH_NAME" + if [ -d "./$REPO" ]; then + cd "$REPO" || exit 2 + echo "Branch name $BRANCH_NAME already exists." + mvn clean install -DskipTests + else + echo "$CURRENT Branch is NOT EQUALS $BRANCH_NAME " + fi +} + +install "java-common-libs" +install "biodata" +install "cellbase" diff --git a/.github/workflows/task.yml b/.github/workflows/task.yml index 1b522b40511..51888a9179d 100644 --- a/.github/workflows/task.yml +++ b/.github/workflows/task.yml @@ -6,9 +6,11 @@ on: - TASK-* workflow_dispatch: +# WARNING Develop branch needed for prod + jobs: build: - uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop with: maven_opts: -P storage-hadoop,hdp3.1,RClient,opencga-storage-hadoop-deps -Dopencga.war.name=opencga -Dcheckstyle.skip -pl '!:opencga-storage-hadoop-deps-emr6.1,!:opencga-storage-hadoop-deps-hdp2.6' @@ -18,37 +20,10 @@ jobs: secrets: inherit with: test_profile: runShortTests - report_context: development - - deploy-maven: - name: Deploy in maven only for renamed versions - uses: opencb/java-common-libs/.github/workflows/deploy-maven-repository-workflow.yml@release-4.8.x - needs: [ build, test ] - if: contains( needs.build.outputs.version ,'TASK') - secrets: inherit deploy-docker: - uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@release-4.8.x + uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop needs: test with: cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag ${{ github.ref_name }} secrets: inherit - - # The following jobs are to see that the previous 'if' doesn't fail and that the maven deploy is executed because it is true - snapshot-version: - name: Check SNAPSHOT version - needs: [ build, test ] - if: contains(needs.build.outputs.version ,'SNAPSHOT') - runs-on: ubuntu-22.04 - steps: - - name: test-version-from-check - run: echo "Project version is " ${{ needs.build.outputs.version }} - - task-version: - name: Check TASK version - needs: [ build, test ] - if: contains(needs.build.outputs.version ,'TASK') - runs-on: ubuntu-22.04 - steps: - - name: test-version-from-check - run: echo "Project version is " ${{ needs.build.outputs.version }} diff --git a/.github/workflows/test-analysis.yml b/.github/workflows/test-analysis.yml index 240db1ece4c..a83cea15dc9 100644 --- a/.github/workflows/test-analysis.yml +++ b/.github/workflows/test-analysis.yml @@ -1,30 +1,20 @@ name: Build and test the project + on: workflow_call: inputs: test_profile: type: string required: true - report_context: - type: string - required: true mvn_opts: type: string + required: false default: "" secrets: SONAR_TOKEN: required: true - SSH_TESTING_SERVER_HOST: - required: true - SSH_TESTING_SERVER_PORT: - required: true - SSH_TESTING_SERVER_USER: - required: true - SSH_TESTING_SERVER_PASSWORD: - required: true -env: - xb_version: "1.6.3" + jobs: analysis: name: Execute Sonar Analysis @@ -39,11 +29,20 @@ jobs: distribution: 'temurin' java-version: '11' cache: 'maven' + - name: Install dependencies branches + run: | + if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then + chmod +x ./.github/workflows/scripts/get_same_branch.sh + ./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} + else + echo "./.github/workflows/scripts/get_same_branch.sh does not exist." + fi - name: Test and Analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: mvn -T 2 clean install -P storage-hadoop,hdp3.1,${{ inputs.test_profile }} -DskipTests -Dcheckstyle.skip org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=opencb_opencga + test: name: Execute JUnit and Jacoco tests runs-on: ubuntu-22.04 @@ -57,6 +56,14 @@ jobs: distribution: 'temurin' java-version: '8' cache: 'maven' + - name: Install dependencies branches + run: | + if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then + chmod +x ./.github/workflows/scripts/get_same_branch.sh + ./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} + else + echo "./.github/workflows/scripts/get_same_branch.sh does not exist." + fi - name: Install Samtools run: sudo apt-get install samtools python3-deeptools - name: Start MongoDB v6.0 @@ -65,31 +72,15 @@ jobs: mongodb-version: 6.0 mongodb-replica-set: rs-test - name: Run Junit tests - run: mvn -B verify surefire-report:report -P storage-hadoop,hdp3.1,${{ inputs.test_profile }} -Dcheckstyle.skip -Popencga-storage-hadoop-deps -pl '!:opencga-storage-hadoop-deps-emr6.1,!:opencga-storage-hadoop-deps-hdp2.6' ${{ inputs.mvn_opts }} - - name: Upload result dir - uses: actions/upload-artifact@v3 - with: - name: workdir - path: "**/target/site" - publish-test: - name: Publish test results - runs-on: ubuntu-22.04 - needs: test - strategy: - matrix: - module: [ "opencga-app", "opencga-catalog", "opencga-client", "opencga-clinical", "opencga-core", "opencga-master", "opencga-server", "opencga-storage", "opencga-storage/opencga-storage-app", "opencga-storage/opencga-storage-benchmark", "opencga-storage/opencga-storage-core", "opencga-storage/opencga-storage-hadoop", "opencga-storage/opencga-storage-server", "opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core", "opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-deps" ] - steps: - - name: Download result dir - uses: actions/download-artifact@v3 - with: - name: workdir - - name: Deploy unit tests web recursively to remote - uses: garygrossgarten/github-action-scp@release + run: mvn -B verify surefire-report:report --fail-never -P storage-hadoop,hdp3.1,${{ inputs.test_profile }} -Dcheckstyle.skip -Popencga-storage-hadoop-deps -pl '!:opencga-storage-hadoop-deps-emr6.1,!:opencga-storage-hadoop-deps-hdp2.6' ${{ inputs.mvn_opts }} + - name: Publish Test Report + uses: scacap/action-surefire-report@v1 + ## Skip cancelled() + ## https://docs.github.com/en/actions/learn-github-actions/expressions#cancelled + if: success() || failure() with: - local: ${{ matrix.module }}/target/site - remote: /var/www/html/reports/${{ inputs.report_context }}/${{ env.xb_version }}/${{ github.ref_name }}/opencga/${{ github.sha }}/unit/${{ matrix.module }} - host: ${{ secrets.SSH_TESTING_SERVER_HOST}} - port: ${{ secrets.SSH_TESTING_SERVER_PORT}} - username: ${{ secrets.SSH_TESTING_SERVER_USER }} - password: ${{ secrets.SSH_TESTING_SERVER_PASSWORD }} - concurrency: 2 + check_name: "Surefire tests report" + report_paths: './**/surefire-reports/TEST-*.xml' + commit: '${{ github.sha }}' + fail_on_test_failures: true + diff --git a/misc/sync_dependency.sh b/misc/sync_dependency.sh deleted file mode 100755 index 316bbc39d3b..00000000000 --- a/misc/sync_dependency.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/bash - -function yellow (){ - echo "$(tput setaf 3)$1$(tput setaf 7)" -} -function green (){ - echo "$(tput setaf 2)$1$(tput setaf 7)" -} -function cyan (){ - echo "$(tput setaf 6)$1$(tput setaf 7)" -} - -function printUsage(){ - echo "" - yellow "Release an OpenCB project." - echo "" - echo "Usage: $(basename $0) --biodata|-b|--java-common-libs|-j" - echo "" - cyan "Options:" - green " -j --java-common-libs STRING Update java-common-libs dependency" - green " -b --biodata STRING Update biodata dependency" - echo "" -} - -## Check if the repo status is clean. -function check_repo_clean() { - GIT_STATUS=$(git status --short) - if [ -n "$GIT_STATUS" ]; then - yellow "Repository is not clean:" - yellow "$GIT_STATUS" - exit - fi -} - -## This function removes TASK-XXX- if exists, otherwise it adds it. -function toggle_version() { - local BRANCH=$1 - if [[ "$POM_DEPENDENCY_VERSION" == *"$BRANCH"* ]]; then - ## Remove TASK-XXX- from the current version - ## Example: remove 'TASK-1234-' from 2.6.0-TASK-1234-SNAPSHOT - NEW_VERSION=${POM_DEPENDENCY_VERSION/"$BRANCH-"} - else - ## Add 'TASK-XXX-' to the current version - ## Example: 2.6.0-SNAPSHOT --> 2.6.0-TASK-1234-SNAPSHOT - CLEAN_RELEASE_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 1) - TAG_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 2) - NEW_VERSION="$CLEAN_RELEASE_VERSION-$BRANCH-$TAG_VERSION" - fi -} - -## Change version in the dependency. -## Usage: update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME" -function update_dependency() { - ## Save current directory - local pwd=$PWD - cd "$1" || exit 2 - check_repo_clean - git checkout "$3" - ## Check branch exists - local BRANCH=$(git branch --show-current) - if [ "$BRANCH" != "$3" ]; then - yellow "Branch '$3' does not exist" - exit - fi - ## Rename and commit new version - mvn versions:set -DnewVersion="$2" -DgenerateBackupPoms=false - git commit -am "Update version to $2" - ## Restore directory - cd "$pwd" || exit 2 -} - -## At least one parameter is required. -if [ -z "$1" ]; then - printUsage - exit 1 -fi - -while [[ $# -gt 0 ]]; do - key="$1" - if [ -n "$2" ]; then - DEPENDENCY_REPO="$2" - fi - case $key in - -h | --help) - printUsage - exit 0 - ;; - -j | --java-common-libs) - LIB="JAVA_COMMONS_LIB" - if [ -z "$DEPENDENCY_REPO" ]; then - DEPENDENCY_REPO="../java-common-libs" - else - shift - fi - shift # past argument - ;; - -b | --biodata) - LIB="BIODATA" - if [ -z "$DEPENDENCY_REPO" ]; then - DEPENDENCY_REPO="../biodata" - else - shift - fi - shift # past argument - ;; - *) # unknown option - echo "Unknown option $key" - printUsage - exit 1 - ;; - esac -done - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -CURRENT_DIR=$PWD -cd "$SCRIPT_DIR" || exit 2 -cd .. -BRANCH_NAME=$(git branch --show-current) -if [[ "$BRANCH_NAME" == "TASK-"* ]]; then - check_repo_clean "$BRANCH_NAME" -else - yellow "[$BRANCH_NAME] The branch name must start with TASK-" - yellow "$GIT_STATUS" - exit -fi - -function update_library(){ - local LIBRARY="$1" - POM_DEPENDENCY_VERSION=$(grep -m 1 "$LIBRARY" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1) - toggle_version "$BRANCH_NAME" - update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME" - mvn versions:set-property -Dproperty=java-common-libs.version -DnewVersion="$NEW_VERSION" -DgenerateBackupPoms=false - git commit -am "Update '$LIBRARY' dependency to $NEW_VERSION" -} - - -if [ "$LIB" = "JAVA_COMMONS_LIB" ];then - update_library java-common-libs.version -fi -if [ "$LIB" = "BIODATA" ];then - update_library biodata.version -fi - -yellow "The new dependency version is $NEW_VERSION" -cd "$CURRENT_DIR" || exit 2 diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java index 02ab7d9b5d8..4fe57ad701b 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java @@ -79,8 +79,8 @@ protected InterpretationMethod getInterpretationMethod(String name) { .setName(name) .setDependencies(Collections.singletonList(new Software() .setName("OpenCGA") - .setVersion(GitRepositoryState.get().getBuildVersion()) - .setCommit(GitRepositoryState.get().getCommitId()))); + .setVersion(GitRepositoryState.getInstance().getBuildVersion()) + .setCommit(GitRepositoryState.getInstance().getCommitId()))); return method; } @@ -114,8 +114,8 @@ protected void saveInterpretation(String studyId, ClinicalAnalysis clinicalAnaly // Interpretation method InterpretationMethod method = new InterpretationMethod(getId(), null, null, - Collections.singletonList(new Software().setName("OpenCGA").setVersion(GitRepositoryState.get().getBuildVersion()) - .setCommit(GitRepositoryState.get().getCommitId()))); + Collections.singletonList(new Software().setName("OpenCGA").setVersion(GitRepositoryState.getInstance().getBuildVersion()) + .setCommit(GitRepositoryState.getInstance().getCommitId()))); // Analyst ClinicalAnalyst analyst = clinicalInterpretationManager.getAnalyst(token); diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java index 07e35a78504..39fa4fd581c 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java @@ -137,8 +137,8 @@ protected void run() throws ToolException { protected void saveInterpretation(String studyId, ClinicalAnalysis clinicalAnalysis) throws ToolException, StorageEngineException, CatalogException, IOException { // Interpretation method - InterpretationMethod method = new InterpretationMethod(getId(), GitRepositoryState.get().getBuildVersion(), - GitRepositoryState.get().getCommitId(), Collections.singletonList( + InterpretationMethod method = new InterpretationMethod(getId(), GitRepositoryState.getInstance().getBuildVersion(), + GitRepositoryState.getInstance().getCommitId(), Collections.singletonList( new Software() .setName("Exomiser") .setRepository("Docker: " + ExomiserWrapperAnalysisExecutor.DOCKER_IMAGE_NAME) diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java index cd2ada565fa..40f829ecd6c 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java @@ -58,7 +58,7 @@ public class CircosLocalAnalysisExecutor extends CircosAnalysisExecutor implements StorageToolExecutor { public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" - + GitRepositoryState.get().getBuildVersion(); + + GitRepositoryState.getInstance().getBuildVersion(); private VariantStorageManager storageManager; private File snvsFile; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java index 027bb8dc9a8..4246e142d55 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java @@ -61,7 +61,7 @@ public class GenomePlotLocalAnalysisExecutor extends GenomePlotAnalysisExecutor implements StorageToolExecutor { public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" - + GitRepositoryState.get().getBuildVersion(); + + GitRepositoryState.getInstance().getBuildVersion(); private GenomePlotConfig plotConfig; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java index 4c96ad7b3b0..f85e0a1873a 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java @@ -16,31 +16,21 @@ package org.opencb.opencga.analysis.variant.hrdetect; -import htsjdk.samtools.reference.BlockCompressedIndexedFastaSequenceFile; -import htsjdk.samtools.reference.FastaSequenceIndex; -import htsjdk.samtools.reference.ReferenceSequence; -import htsjdk.samtools.util.GZIIndex; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.opencb.biodata.models.variant.StudyEntry; import org.opencb.biodata.models.variant.Variant; -import org.opencb.biodata.models.variant.avro.VariantType; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; -import org.opencb.commons.datastore.core.QueryResultWriter; import org.opencb.commons.exec.Command; import org.opencb.commons.utils.DockerUtils; -import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.StorageToolExecutor; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.exceptions.ToolException; import org.opencb.opencga.core.exceptions.ToolExecutorException; -import org.opencb.opencga.core.response.OpenCGAResult; -import org.opencb.opencga.core.response.VariantQueryResult; import org.opencb.opencga.core.tools.annotations.ToolExecutor; import org.opencb.opencga.core.tools.variant.HRDetectAnalysisExecutor; -import org.opencb.opencga.core.tools.variant.MutationalSignatureAnalysisExecutor; import org.opencb.opencga.storage.core.exceptions.StorageEngineException; import org.opencb.opencga.storage.core.variant.adaptors.VariantQueryParam; import org.opencb.opencga.storage.core.variant.adaptors.iterators.VariantDBIterator; @@ -53,14 +43,12 @@ import java.nio.file.Paths; import java.util.*; -import static org.opencb.opencga.analysis.variant.mutationalSignature.MutationalSignatureAnalysis.CATALOGUES_FILENAME_DEFAULT; - @ToolExecutor(id="opencga-local", tool = HRDetectAnalysis.ID, framework = ToolExecutor.Framework.LOCAL, source = ToolExecutor.Source.STORAGE) public class HRDetectLocalAnalysisExecutor extends HRDetectAnalysisExecutor implements StorageToolExecutor { - public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); + public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.getInstance().getBuildVersion(); private final static String CNV_FILENAME = "cnv.tsv"; private final static String INDEL_FILENAME = "indel.vcf"; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/manager/VariantStorageManager.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/manager/VariantStorageManager.java index 806fbb6d818..48b5cf87114 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/manager/VariantStorageManager.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/manager/VariantStorageManager.java @@ -49,6 +49,7 @@ import org.opencb.opencga.catalog.managers.StudyManager; import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.cellbase.CellBaseValidator; +import org.opencb.opencga.core.common.ExceptionUtils; import org.opencb.opencga.core.common.UriUtils; import org.opencb.opencga.core.config.storage.CellBaseConfiguration; import org.opencb.opencga.core.config.storage.SampleIndexConfiguration; @@ -564,7 +565,10 @@ public OpenCGAResult setCellbaseConfiguration(String project, CellBaseConfi String annotationSaveId, String token) throws CatalogException, StorageEngineException { StopWatch stopwatch = StopWatch.createStarted(); - return secureOperationByProject("configureCellbase", project, new ObjectMap(), token, engine -> { + return secureOperationByProject("configureCellbase", project, new ObjectMap() + .append("cellbaseConfiguration", cellbaseConfiguration) + .append("annotate", annotate) + .append("annotationSaveId", annotationSaveId), token, engine -> { OpenCGAResult result = new OpenCGAResult<>(); result.setResultType(Job.class.getCanonicalName()); result.setResults(new ArrayList<>()); @@ -1225,7 +1229,7 @@ private R secureTool(String toolId, boolean isOperation, ObjectMap params, S throw e; } catch (Exception e) { exception = e; - throw new StorageEngineException("Error executing operation " + toolId, e); + throw new StorageEngineException("Error executing operation '" + toolId + "' : " + e.getMessage(), e); } finally { if (result instanceof DataResult) { auditAttributes.append("dbTime", ((DataResult) result).getTime()); @@ -1237,6 +1241,8 @@ private R secureTool(String toolId, boolean isOperation, ObjectMap params, S if (exception != null) { auditAttributes.append("errorType", exception.getClass()); auditAttributes.append("errorMessage", exception.getMessage()); + auditAttributes.append("errorMessageFull", ExceptionUtils.prettyExceptionMessage(exception, false, true)); + auditAttributes.append("exceptionStackTrace", ExceptionUtils.prettyExceptionStackTrace(exception)); status = new AuditRecord.Status(AuditRecord.Status.Result.ERROR, new Error(-1, exception.getClass().getName(), exception.getMessage())); } else { diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java index f2bf45cf487..c542521329a 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java @@ -64,11 +64,12 @@ public class MutationalSignatureLocalAnalysisExecutor extends MutationalSignatureAnalysisExecutor implements StorageToolExecutor { - public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); - private static final String SVCLASS = "SVCLASS"; private static final String EXT_SVTYPE = "EXT_SVTYPE"; + public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + + GitRepositoryState.getInstance().getBuildVersion(); + private Path opencgaHome; private Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java index 27d6c54d7b3..21f619cc5a4 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java @@ -32,7 +32,7 @@ public String getDockerImageName() { } public String getDockerImageVersion() { - return GitRepositoryState.get().getBuildVersion(); + return GitRepositoryState.getInstance().getBuildVersion(); } private Logger privateLogger = LoggerFactory.getLogger(DockerWrapperAnalysisExecutor.class); diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java index 0884482ef80..f45e8e77ec2 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java @@ -5,10 +5,8 @@ import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.NodeConfig; -import org.apache.solr.core.SolrResourceLoader; import org.junit.rules.ExternalResource; import org.opencb.commons.datastore.solr.SolrManager; -import org.opencb.opencga.analysis.variant.manager.VariantStorageManager; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.config.storage.StorageConfiguration; @@ -40,8 +38,8 @@ protected void before() throws Throwable { Path rootDir = getTmpRootDir(); - String mainConfigSet = "opencga-rga-configset-" + GitRepositoryState.get().getBuildVersion(); - String auxConfigSet = "opencga-rga-aux-configset-" + GitRepositoryState.get().getBuildVersion(); + String mainConfigSet = "opencga-rga-configset-" + GitRepositoryState.getInstance().getBuildVersion(); + String auxConfigSet = "opencga-rga-aux-configset-" + GitRepositoryState.getInstance().getBuildVersion(); copyConfigSetConfiguration(mainConfigSet, "managed-schema"); copyConfigSetConfiguration(auxConfigSet, "aux-managed-schema"); diff --git a/opencga-app/app/cloud/docker/opencga-base/Dockerfile b/opencga-app/app/cloud/docker/opencga-base/Dockerfile index 3d2c1e4db7c..d3eee2266d2 100644 --- a/opencga-app/app/cloud/docker/opencga-base/Dockerfile +++ b/opencga-app/app/cloud/docker/opencga-base/Dockerfile @@ -1,5 +1,6 @@ -## Based on Debian 11 (bullseye) -FROM openjdk:8-jre +## Based on Ubuntu 22.04 (jammy) +## We are now using OpenJDK 8u372 to support "cgroup v2", see https://developers.redhat.com/articles/2023/04/19/openjdk-8u372-feature-cgroup-v2-support# +FROM eclipse-temurin:8u372-b07-jre-jammy ARG BUILD_PATH="." @@ -7,14 +8,20 @@ ENV OPENCGA_HOME=/opt/opencga ENV OPENCGA_CONFIG_DIR=${OPENCGA_HOME}/conf RUN apt-get update && apt-get -y upgrade && apt-get install -y lsb-release sshpass ca-certificates curl gnupg jq ncurses-bin && \ - # Install Docker repository - curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ - $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ - # Install MongoDB repository - wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - && \ - echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list && \ - apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io mongodb-org-shell && \ + ## Install Docker repository + install -m 0755 -d /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ + chmod a+r /etc/apt/keyrings/docker.gpg && \ + echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "jammy")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ + ## Install MongoDB 6.0 repository + curl -fsSL https://pgp.mongodb.com/server-6.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-server-6.0.gpg && \ + echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list && \ + ## Install docker and mongodb packages + apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io mongodb-mongosh && \ + ## Install yq + wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && \ + chmod +x /usr/local/bin/yq && \ + ## Clean downloaded packages to make images smaller rm -rf /var/lib/apt/lists/* && \ adduser --disabled-password --uid 1001 opencga diff --git a/opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile b/opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile index 364a2994a24..5558259e3f5 100644 --- a/opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile +++ b/opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile @@ -33,4 +33,4 @@ RUN git fetch origin --tags && \ rm -rf /var/lib/apt/lists/* /tmp/* /opt/opencga/signature.tools.lib/.git && \ strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 -WORKDIR /opt/opencga \ No newline at end of file +WORKDIR /opt/opencga diff --git a/opencga-app/app/cloud/docker/opencga-init/Dockerfile b/opencga-app/app/cloud/docker/opencga-init/Dockerfile index f7efd322ac9..60b60f278b7 100644 --- a/opencga-app/app/cloud/docker/opencga-init/Dockerfile +++ b/opencga-app/app/cloud/docker/opencga-init/Dockerfile @@ -8,25 +8,22 @@ ARG INIT_PATH=cloud/docker/opencga-init/ COPY ${INIT_PATH} /opt/opencga/init/ COPY ${BUILD_PATH}/conf/* /opt/opencga/init/test/ - -# Mount volume to copy config into +## Mount volume to copy config into VOLUME /opt/volume USER root -# Install local dependencies -RUN apt install python3 && \ - echo "deb http://ftp.de.debian.org/debian bullseye main" | tee -a /etc/apt/sources.list.d/sources.list && \ - apt-get update && apt-get -y upgrade && \ - apt install -y python3-pip && \ + +## Install local dependencies +RUN apt-get update && apt-get -y upgrade && apt-get install -y python3 python3-pip && \ pip3 install --upgrade pip setuptools && \ pip3 install -r /opt/opencga/init/requirements.txt && \ chmod +x /opt/opencga/init/setup.sh /opt/opencga/init/setup-hadoop.sh && \ echo ">Running init container configuration tests" && \ cd /opt/opencga/init/test && python3 test_override_yaml.py -v && rm -r /opt/opencga/init/test - +## Run Docker images as non root USER opencga -# It is the responsibility of the setup.sh -# script to initialise the volume correctly -# and apply any runtime config transforms. -ENTRYPOINT [ "/bin/sh","/opt/opencga/init/setup.sh" ] + +## It is the responsibility of the setup.sh script to initialise the volume correctly +## and apply any runtime config transforms. +ENTRYPOINT [ "/bin/sh", "/opt/opencga/init/setup.sh" ] diff --git a/opencga-app/app/misc/clients/rest_client_generator.py b/opencga-app/app/misc/clients/rest_client_generator.py index 8239fa55709..bfb3b78489f 100644 --- a/opencga-app/app/misc/clients/rest_client_generator.py +++ b/opencga-app/app/misc/clients/rest_client_generator.py @@ -198,6 +198,9 @@ def get_method_name(self, endpoint, category): # /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretationId}/merge elif self.all_arg([items[0], items[2]]) and not self.any_arg([items[1], items[3]]): method_name = '_'.join([items[3], items[1]]) + # /{apiVersion}/admin/users/{user}/groups/update + elif self.all_arg([items[1]]) and not self.any_arg([items[0], items[2], items[3]]): + method_name = '_'.join([items[0], items[3], items[2]]) elif len(items) == 5: # e.g. /{apiVersion}/files/{file}/annotationSets/{annotationSet}/annotations/update if self.all_arg([items[0], items[2]]) and not self.any_arg([items[1], items[3], items[4]]): diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java index 89832e53260..28787847b65 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java @@ -800,8 +800,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Admin (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-admin.sh [-h|--help] [--version] [options]"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java index 2bb78fb51c3..2dc1f8d638b 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java @@ -30,7 +30,7 @@ */ public class AdminMain { - public static final String VERSION = GitRepositoryState.get().getBuildVersion(); + public static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public static void main(String[] args) { @@ -71,8 +71,8 @@ public static void main(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); System.exit(0); } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java index ceaab6ea98d..a360eaa2f1e 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java @@ -167,7 +167,7 @@ private String parseVersion(String version) { public static String getDefaultVersion() { String version; - version = GitRepositoryState.get().getBuildVersion(); + version = GitRepositoryState.getInstance().getBuildVersion(); // Remove extra information version = version.split("-")[0]; return version; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java index f11d519c846..132ad854c82 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java @@ -468,8 +468,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Analysis (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-internal.sh [-h|--help] [--version] [options]"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java index a1aaf7466f3..98d8b965357 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java @@ -28,7 +28,7 @@ */ public class InternalMain { - public static final String VERSION = GitRepositoryState.get().getBuildVersion(); + public static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public static void main(String[] args) { System.exit(privateMain(args)); @@ -48,8 +48,8 @@ public static int privateMain(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); return 0; } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java index fa69afab38d..6627d4d82f1 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java @@ -1,5 +1,5 @@ /* -* Copyright 2015-2023-04-18 OpenCB +* Copyright 2015-2023-08-30 OpenCB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public abstract class OpenCgaCompleter implements Completer { .map(Candidate::new) .collect(toList()); - private List adminList = asList( "audit-group-by","catalog-index-stats","catalog-install","catalog-jwt","users-create","users-import","users-search","users-sync") + private List adminList = asList( "audit-group-by","catalog-index-stats","catalog-install","catalog-jwt","users-create","users-import","users-search","users-sync","update-groups-users") .stream() .map(Candidate::new) .collect(toList()); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java index c18998aabcc..b619c612c32 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java @@ -1,5 +1,5 @@ /* -* Copyright 2015-2023-04-18 OpenCB +* Copyright 2015-2023-08-30 OpenCB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -188,6 +188,7 @@ public OpencgaCliOptionsParser() { adminSubCommands.addCommand("users-import", adminCommandOptions.importUsersCommandOptions); adminSubCommands.addCommand("users-search", adminCommandOptions.searchUsersCommandOptions); adminSubCommands.addCommand("users-sync", adminCommandOptions.syncUsersCommandOptions); + adminSubCommands.addCommand("update-groups-users", adminCommandOptions.usersUpdateGroupsCommandOptions); individualsCommandOptions = new IndividualsCommandOptions(commonCommandOptions, jCommander); jCommander.addCommand("individuals", individualsCommandOptions); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaMain.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaMain.java index 4fa055dde8c..296b1be2d75 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaMain.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaMain.java @@ -17,6 +17,7 @@ package org.opencb.opencga.app.cli.main; import org.apache.commons.lang3.ArrayUtils; +import org.opencb.commons.utils.PrintUtils; import org.opencb.opencga.app.cli.CliOptionsParser; import org.opencb.opencga.app.cli.GeneralCliOptions; import org.opencb.opencga.app.cli.main.processors.CommandProcessor; @@ -48,6 +49,7 @@ public static void main(String[] args) { parser.printUsage(); System.exit(0); } + PrintUtils.printSpace(); checkLogLevel(args); checkMode(args); logger.debug(Arrays.toString(args)); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java index 9ab6c51ed00..a16efb4df47 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java @@ -19,11 +19,13 @@ import org.opencb.opencga.app.cli.main.options.AdminCommandOptions; import java.util.Map; +import org.opencb.opencga.catalog.utils.ParamUtils.AddRemoveAction; import org.opencb.opencga.core.models.admin.GroupSyncParams; import org.opencb.opencga.core.models.admin.InstallationParams; import org.opencb.opencga.core.models.admin.JWTParams; import org.opencb.opencga.core.models.admin.UserCreateParams; import org.opencb.opencga.core.models.admin.UserImportParams; +import org.opencb.opencga.core.models.admin.UserUpdateGroup; import org.opencb.opencga.core.models.common.Enums.Resource; import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.Group; @@ -87,6 +89,9 @@ public void execute() throws Exception { case "users-sync": queryResponse = syncUsers(); break; + case "update-groups-users": + queryResponse = usersUpdateGroups(); + break; default: logger.error("Subcommand not valid"); break; @@ -288,4 +293,35 @@ private RestResponse syncUsers() throws Exception { } return openCGAClient.getAdminClient().syncUsers(groupSyncParams); } + + private RestResponse usersUpdateGroups() throws Exception { + logger.debug("Executing usersUpdateGroups in Admin command line"); + + AdminCommandOptions.UsersUpdateGroupsCommandOptions commandOptions = adminCommandOptions.usersUpdateGroupsCommandOptions; + + ObjectMap queryParams = new ObjectMap(); + queryParams.putIfNotNull("action", commandOptions.action); + + + UserUpdateGroup userUpdateGroup = null; + if (commandOptions.jsonDataModel) { + userUpdateGroup = new UserUpdateGroup(); + RestResponse res = new RestResponse<>(); + res.setType(QueryType.VOID); + PrintUtils.println(getObjectAsJSON(userUpdateGroup)); + return res; + } else if (commandOptions.jsonFile != null) { + userUpdateGroup = JacksonUtils.getDefaultObjectMapper() + .readValue(new java.io.File(commandOptions.jsonFile), UserUpdateGroup.class); + } else { + ObjectMap beanParams = new ObjectMap(); + putNestedIfNotNull(beanParams, "studyIds",commandOptions.studyIds, true); + putNestedIfNotNull(beanParams, "groupIds",commandOptions.groupIds, true); + + userUpdateGroup = JacksonUtils.getDefaultObjectMapper().copy() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) + .readValue(beanParams.toJson(), UserUpdateGroup.class); + } + return openCGAClient.getAdminClient().usersUpdateGroups(commandOptions.user, userUpdateGroup, queryParams); + } } \ No newline at end of file diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AdminCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AdminCommandOptions.java index ae9c1397750..f246d8a36d8 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AdminCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AdminCommandOptions.java @@ -41,6 +41,7 @@ public class AdminCommandOptions { public ImportUsersCommandOptions importUsersCommandOptions; public SearchUsersCommandOptions searchUsersCommandOptions; public SyncUsersCommandOptions syncUsersCommandOptions; + public UsersUpdateGroupsCommandOptions usersUpdateGroupsCommandOptions; public AdminCommandOptions(CommonCommandOptions commonCommandOptions, JCommander jCommander) { @@ -55,6 +56,7 @@ public AdminCommandOptions(CommonCommandOptions commonCommandOptions, JCommander this.importUsersCommandOptions = new ImportUsersCommandOptions(); this.searchUsersCommandOptions = new SearchUsersCommandOptions(); this.syncUsersCommandOptions = new SyncUsersCommandOptions(); + this.usersUpdateGroupsCommandOptions = new UsersUpdateGroupsCommandOptions(); } @@ -278,4 +280,30 @@ public class SyncUsersCommandOptions { } + @Parameters(commandNames = {"update-groups-users"}, commandDescription ="Add or remove users from existing groups") + public class UsersUpdateGroupsCommandOptions { + + @ParametersDelegate + public CommonCommandOptions commonOptions = commonCommandOptions; + + @Parameter(names = {"--json-file"}, description = "File with the body data in JSON format. Note, that using this parameter will ignore all the other parameters.", required = false, arity = 1) + public String jsonFile; + + @Parameter(names = {"--json-data-model"}, description = "Show example of file structure for body data.", help = true, arity = 0) + public Boolean jsonDataModel = false; + + @Parameter(names = {"--user", "-u"}, description = "User ID", required = true, arity = 1) + public String user; + + @Parameter(names = {"--action"}, description = "Action to be performed: ADD or REMOVE user to/from groups", required = false, arity = 1) + public String action = "ADD"; + + @Parameter(names = {"--study-ids"}, description = "The body web service studyIds parameter", required = false, arity = 1) + public String studyIds; + + @Parameter(names = {"--group-ids"}, description = "The body web service groupIds parameter", required = false, arity = 1) + public String groupIds; + + } + } \ No newline at end of file diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java index fc752daaf98..0b37bec1c1c 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java @@ -925,8 +925,8 @@ public class RunGwasCommandOptions { @Parameter(names = {"--phenotype"}, description = "The body web service phenotype parameter", required = false, arity = 1) public String phenotype; - @Parameter(names = {"--index"}, description = "The body web service index parameter", required = false, arity = 1) - public Boolean index; + @Parameter(names = {"--index"}, description = "The body web service index parameter", required = false, help = true, arity = 0) + public boolean index = false; @Parameter(names = {"--index-score-id"}, description = "The body web service indexScoreId parameter", required = false, arity = 1) public String indexScoreId; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java index 46af3e8eeb9..4454887584b 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java @@ -18,16 +18,16 @@ public class CommandLineUtils { private static final Logger logger = LoggerFactory.getLogger(CommandLineUtils.class); public static String getVersionString() { - String res = PrintUtils.getKeyValueAsFormattedString("\tOpenCGA CLI version: ", "\t" + GitRepositoryState.get().getBuildVersion() + "\n"); - res += PrintUtils.getKeyValueAsFormattedString("\tGit version:", "\t\t" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId() + "\n"); + String res = PrintUtils.getKeyValueAsFormattedString("\tOpenCGA CLI version: ", "\t" + GitRepositoryState.getInstance().getBuildVersion() + "\n"); + res += PrintUtils.getKeyValueAsFormattedString("\tGit version:", "\t\t" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId() + "\n"); res += PrintUtils.getKeyValueAsFormattedString("\tProgram:", "\t\tOpenCGA (OpenCB)" + "\n"); res += PrintUtils.getKeyValueAsFormattedString("\tDescription: ", "\t\tBig Data platform for processing and analysing NGS data" + "\n"); return res; } public static String getHelpVersionString() { - String res = PrintUtils.getHelpVersionFormattedString("OpenCGA CLI version: ", "\t" + GitRepositoryState.get().getBuildVersion() + "\n"); - res += PrintUtils.getHelpVersionFormattedString("Git version:", "\t\t" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId() + "\n"); + String res = PrintUtils.getHelpVersionFormattedString("OpenCGA CLI version: ", "\t" + GitRepositoryState.getInstance().getBuildVersion() + "\n"); + res += PrintUtils.getHelpVersionFormattedString("Git version:", "\t\t" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId() + "\n"); res += PrintUtils.getHelpVersionFormattedString("Program:", "\t\tOpenCGA (OpenCB)" + "\n"); res += PrintUtils.getHelpVersionFormattedString("Description: ", "\t\tBig Data platform for processing and analysing NGS data" + "\n"); return res; @@ -90,7 +90,7 @@ public static String[] processShortCuts(String[] args) { break; case "--build-version": case "build-version": - println(GitRepositoryState.get().getBuildVersion()); + println(GitRepositoryState.getInstance().getBuildVersion()); break; case "logout": return ArrayUtils.addAll(new String[]{"users"}, args); @@ -99,7 +99,7 @@ public static String[] processShortCuts(String[] args) { if (args.length > 1 && args[1].equals("studies")) { println(String.join(", ", OpencgaMain.getShell().getSessionManager().getSession().getStudies()), Color.GREEN); } else { - printWarn("Opencga version " + GitRepositoryState.get().getBuildVersion() + " can only list studies"); + printWarn("Opencga version " + GitRepositoryState.getInstance().getBuildVersion() + " can only list studies"); } } else { printWarn("List studies is only available in Shell mode"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java index 1c2099ec471..15d7b63e6ec 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java @@ -150,7 +150,7 @@ public void print(JobTop top) { jobTable.restoreCursorPosition(); jobTable.println("OpenCGA jobs TOP"); - jobTable.println(" Version " + GitRepositoryState.get().getBuildVersion()); + jobTable.println(" Version " + GitRepositoryState.getInstance().getBuildVersion()); jobTable.println(" " + TextOutputWriter.SIMPLE_DATE_FORMAT.format(Date.from(Instant.now()))); jobTable.println(); jobTable.print(Enums.ExecutionStatus.RUNNING + ": " + top.getStats().getRunning() + ", "); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java index 640a687f7c3..f822716041e 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java @@ -111,7 +111,7 @@ private void init() { private Session createEmptySession() { Session session = new Session(); session.setHost(host); - session.setVersion(GitRepositoryState.get().getBuildVersion()); + session.setVersion(GitRepositoryState.getInstance().getBuildVersion()); session.setTimestamp(System.currentTimeMillis()); session.setStudies(new ArrayList()); session.setCurrentStudy(NO_STUDY); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java index d23d2345681..d9e270c3d9f 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java @@ -35,8 +35,8 @@ public static void completeInternalStatus(Document document) { completeStatus(internal); Document status = internal.get("status", Document.class); - status.put("version", GitRepositoryState.get().getBuildVersion()); - status.put("commit", GitRepositoryState.get().getCommitId()); + status.put("version", GitRepositoryState.getInstance().getBuildVersion()); + status.put("commit", GitRepositoryState.getInstance().getCommitId()); String id = status.getString("id"); if (StringUtils.isEmpty(id)) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/StudyDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/StudyDBAdaptor.java index 65077320bb7..f74d1a843b7 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/StudyDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/StudyDBAdaptor.java @@ -25,6 +25,7 @@ import org.opencb.opencga.catalog.exceptions.CatalogAuthorizationException; import org.opencb.opencga.catalog.exceptions.CatalogDBException; import org.opencb.opencga.catalog.exceptions.CatalogParameterException; +import org.opencb.opencga.catalog.utils.ParamUtils; import org.opencb.opencga.core.models.common.Enums; import org.opencb.opencga.core.models.project.Project; import org.opencb.opencga.core.models.study.*; @@ -287,9 +288,28 @@ OpenCGAResult removeUsersFromAllGroups(long studyId, List users) * @param groupList List containing possible groups that are synced and where the user should be added to. * @param authOrigin Authentication origin of the synced groups. * @return OpenCGAResult object. - * @throws CatalogDBException CatalogDBException. + * @throws CatalogDBException CatalogDBException + * @throws CatalogParameterException CatalogParameterException + * @throws CatalogAuthorizationException CatalogAuthorizationException */ - OpenCGAResult resyncUserWithSyncedGroups(String user, List groupList, String authOrigin) throws CatalogDBException; + OpenCGAResult resyncUserWithSyncedGroups(String user, List groupList, String authOrigin) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException; + + /** + * ADD or REMOVE user to list of provided groups. + * + * @param user User id. + * @param studyUids List of study uids. + * @param groupList List of group ids. + * @param action Update action [ADD, REMOVE] + * @return OpenCGAResult object. + * @throws CatalogDBException CatalogDBException + * @throws CatalogParameterException CatalogParameterException + * @throws CatalogAuthorizationException CatalogAuthorizationException + */ + OpenCGAResult updateUserFromGroups(String user, List studyUids, List groupList, + ParamUtils.AddRemoveAction action) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException; /** * Create the permission rule to the list of permission rules defined for the entry in the studyId. diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java index edab86e2f36..fff9a1ed3b3 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java @@ -522,8 +522,8 @@ private void addToMembersGroupInStudy(long studyId, List members, Client .collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(userList)) { // We first add the member to the @members group in case they didn't belong already - dbAdaptorFactory.getCatalogStudyDBAdaptor().addUsersToGroup(studyId, CatalogAuthorizationManager.MEMBERS_GROUP, - userList, clientSession); + dbAdaptorFactory.getCatalogStudyDBAdaptor().addUsersToGroup(clientSession, studyId, CatalogAuthorizationManager.MEMBERS_GROUP, + userList); } } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java index bb542490cdc..295a84f2093 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java @@ -55,7 +55,7 @@ public class MetaMongoDBAdaptor extends MongoDBAdaptor implements MetaDBAdaptor Filters.eq(ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID), Filters.eq(OLD_ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID)); private final MongoDBCollection metaCollection; - private static final String VERSION = GitRepositoryState.get().getBuildVersion(); + private static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public MetaMongoDBAdaptor(MongoDBCollection metaMongoDBCollection, Configuration configuration, MongoDBAdaptorFactory dbAdaptorFactory) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java index 7b88fb6ce1f..d2e01a601be 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java @@ -29,7 +29,6 @@ import org.opencb.commons.datastore.core.*; import org.opencb.commons.datastore.mongodb.MongoDBCollection; import org.opencb.commons.datastore.mongodb.MongoDBIterator; -import org.opencb.commons.utils.ListUtils; import org.opencb.opencga.catalog.db.api.*; import org.opencb.opencga.catalog.db.mongodb.converters.StudyConverter; import org.opencb.opencga.catalog.db.mongodb.converters.VariableSetConverter; @@ -40,6 +39,7 @@ import org.opencb.opencga.catalog.utils.Constants; import org.opencb.opencga.catalog.utils.ParamUtils; import org.opencb.opencga.catalog.utils.UuidUtils; +import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.common.TimeUtils; import org.opencb.opencga.core.config.Configuration; import org.opencb.opencga.core.models.cohort.Cohort; @@ -482,8 +482,8 @@ public OpenCGAResult setUsersToGroup(long studyId, String groupId, List(result); } - void addUsersToGroup(long studyId, String groupId, List members, ClientSession clientSession) throws CatalogDBException { - if (ListUtils.isEmpty(members)) { + void addUsersToGroup(ClientSession clientSession, long studyId, String groupId, List members) throws CatalogDBException { + if (CollectionUtils.isEmpty(members)) { return; } @@ -491,7 +491,7 @@ void addUsersToGroup(long studyId, String groupId, List members, ClientS .append(PRIVATE_UID, studyId) .append(QueryParams.GROUP_ID.key(), groupId); Document update = new Document("$addToSet", new Document("groups.$.userIds", new Document("$each", members))); - DataResult result = studyCollection.update(clientSession, query, update, null); + DataResult result = studyCollection.update(clientSession, query, update, null); if (result.getNumMatches() != 1) { throw new CatalogDBException("Unable to add members to group " + groupId + ". The group does not exist."); @@ -500,7 +500,7 @@ void addUsersToGroup(long studyId, String groupId, List members, ClientS @Override public OpenCGAResult addUsersToGroup(long studyId, String groupId, List members) throws CatalogDBException { - if (ListUtils.isEmpty(members)) { + if (CollectionUtils.isEmpty(members)) { throw new CatalogDBException("List of 'members' is missing or empty."); } @@ -589,56 +589,145 @@ public OpenCGAResult syncGroup(long studyId, String groupId, Group.Sync s return new OpenCGAResult<>(studyCollection.update(query, updates, null)); } - // TODO: Make this transactional @Override public OpenCGAResult resyncUserWithSyncedGroups(String user, List groupList, String authOrigin) - throws CatalogDBException { + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { if (StringUtils.isEmpty(user)) { throw new CatalogDBException("Missing user field"); } - // 1. Take the user out from all synced groups - Document query = new Document() - .append(QueryParams.GROUPS.key(), new Document("$elemMatch", new Document() - .append("userIds", user) - .append("syncedFrom.authOrigin", authOrigin) - )); - Bson pull = Updates.pull("groups.$.userIds", user); - - // Pull the user while it still belongs to a synced group - QueryOptions multi = new QueryOptions(MongoDBCollection.MULTI, true); - DataResult update; - do { - update = studyCollection.update(query, pull, multi); - } while (update.getNumUpdated() > 0); - - // 2. Add user to all synced groups - if (groupList != null && groupList.size() > 0) { - // Add the user to all the synced groups matching - query = new Document() + return runTransaction(clientSession -> { + // 1. Take the user out from all synced groups + Document query = new Document() .append(QueryParams.GROUPS.key(), new Document("$elemMatch", new Document() - .append("userIds", new Document("$ne", user)) - .append("syncedFrom.remoteGroup", new Document("$in", groupList)) + .append("userIds", user) .append("syncedFrom.authOrigin", authOrigin) )); - Document push = new Document("$addToSet", new Document("groups.$.userIds", user)); + Bson pull = Updates.pull("groups.$.userIds", user); + + // Pull the user while it still belongs to a synced group + QueryOptions multi = new QueryOptions(MongoDBCollection.MULTI, true); + DataResult update; do { - update = studyCollection.update(query, push, multi); + update = studyCollection.update(clientSession, query, pull, multi); } while (update.getNumUpdated() > 0); - // We need to be updated with the internal @members group, so we fetch all the studies where the user has been added - // and attempt to add it to the each @members group - query = new Document() - .append(QueryParams.GROUP_USER_IDS.key(), user) - .append(QueryParams.GROUP_SYNCED_FROM_AUTH_ORIGIN.key(), authOrigin); - DataResult studyDataResult = studyCollection.find(query, studyConverter, new QueryOptions(QueryOptions.INCLUDE, - QueryParams.UID.key())); - for (Study study : studyDataResult.getResults()) { - addUsersToGroup(study.getUid(), "@members", Arrays.asList(user)); + // 2. Add user to all synced groups + if (groupList != null && groupList.size() > 0) { + // Add the user to all the synced groups matching + query = new Document() + .append(QueryParams.GROUPS.key(), new Document("$elemMatch", new Document() + .append("userIds", new Document("$ne", user)) + .append("syncedFrom.remoteGroup", new Document("$in", groupList)) + .append("syncedFrom.authOrigin", authOrigin) + )); + Document push = new Document("$addToSet", new Document("groups.$.userIds", user)); + do { + update = studyCollection.update(clientSession, query, push, multi); + } while (update.getNumUpdated() > 0); + + // We need to be updated with the internal @members group, so we fetch all the studies where the user has been added + // and attempt to add it to all @members groups + query = new Document() + .append(QueryParams.GROUP_USER_IDS.key(), user) + .append(QueryParams.GROUP_SYNCED_FROM_AUTH_ORIGIN.key(), authOrigin); + DataResult studyDataResult = studyCollection.find(clientSession, query, studyConverter, + new QueryOptions(QueryOptions.INCLUDE, QueryParams.UID.key())); + for (Study study : studyDataResult.getResults()) { + addUsersToGroup(clientSession, study.getUid(), "@members", Collections.singletonList(user)); + } } + + return OpenCGAResult.empty(Group.class); + }); + } + + @Override + public OpenCGAResult updateUserFromGroups(String user, List studyUids, List groupList, + ParamUtils.AddRemoveAction action) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + + if (StringUtils.isEmpty(user)) { + throw new CatalogParameterException("Missing user parameter"); + } + if (action == null) { + throw new CatalogParameterException("Missing action parameter"); + } + if (CollectionUtils.isEmpty(groupList)) { + throw new CatalogParameterException("Missing list of groups"); } - return OpenCGAResult.empty(); + // Fix group ids + List fixedGroupList = groupList.stream() + .map((group) -> { + if (!group.startsWith("@")) { + return "@" + group; + } + return group; + }) + .collect(Collectors.toList()); + + QueryOptions multi = new QueryOptions(MongoDBCollection.MULTI, true); + + return runTransaction(clientSession -> { + switch (action) { + case ADD: + Document addQuery = new Document() + // Do not apply changes in the admin study + .append(QueryParams.FQN.key(), new Document("$ne", ParamConstants.ADMIN_STUDY_FQN)) + // Add the user to all the groups matching the list + .append(QueryParams.GROUPS.key(), new Document("$elemMatch", new Document() + .append("userIds", new Document("$ne", user)) + .append("id", new Document("$in", fixedGroupList)) + )); + if (studyUids != null) { + addQuery.put(QueryParams.UID.key(), new Document("$in", studyUids)); + } + + Document push = new Document("$addToSet", new Document("groups.$.userIds", user)); + DataResult update; + do { + update = studyCollection.update(clientSession, addQuery, push, multi); + } while (update.getNumUpdated() > 0); + + // We need to be updated with the internal @members group, so we fetch all the studies where the user has been added + // and attempt to add it to all @members groups + addQuery = new Document() + .append(QueryParams.GROUP_USER_IDS.key(), user) + .append(QueryParams.GROUP_ID.key(), new Document("$in", fixedGroupList)); + if (studyUids != null) { + addQuery.put(QueryParams.UID.key(), new Document("$in", studyUids)); + } + + DataResult studyDataResult = studyCollection.find(clientSession, addQuery, studyConverter, + new QueryOptions(QueryOptions.INCLUDE, QueryParams.UID.key())); + for (Study study : studyDataResult.getResults()) { + addUsersToGroup(clientSession, study.getUid(), "@members", Collections.singletonList(user)); + } + break; + case REMOVE: + // 1. Take the user out from all groups + Document removeQuery = new Document() + .append(QueryParams.GROUPS.key(), new Document("$elemMatch", new Document() + .append("userIds", user) + .append("id", new Document("$in", fixedGroupList)) + )); + if (studyUids != null) { + removeQuery.put(QueryParams.UID.key(), new Document("$in", studyUids)); + } + Bson pull = Updates.pull("groups.$.userIds", user); + DataResult pullUpdate; + do { + pullUpdate = studyCollection.update(clientSession, removeQuery, pull, multi); + } while (pullUpdate.getNumUpdated() > 0); + + break; + default: + break; + } + + return OpenCGAResult.empty(Group.class); + }); } @Override diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AdminManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AdminManager.java index 3bffa773511..b57426ebf04 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AdminManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AdminManager.java @@ -1,9 +1,9 @@ package org.opencb.opencga.catalog.managers; +import org.apache.commons.collections4.CollectionUtils; import org.opencb.commons.datastore.core.ObjectMap; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; -import org.opencb.opencga.core.models.audit.AuditRecord; import org.opencb.opencga.catalog.auth.authorization.AuthorizationManager; import org.opencb.opencga.catalog.db.DBAdaptorFactory; import org.opencb.opencga.catalog.db.api.UserDBAdaptor; @@ -12,12 +12,18 @@ import org.opencb.opencga.catalog.utils.ParamUtils; import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.config.Configuration; +import org.opencb.opencga.core.models.audit.AuditRecord; import org.opencb.opencga.core.models.common.Enums; +import org.opencb.opencga.core.models.study.Group; +import org.opencb.opencga.core.models.study.Study; import org.opencb.opencga.core.models.user.User; import org.opencb.opencga.core.response.OpenCGAResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.List; + public class AdminManager extends AbstractManager { private final CatalogIOManager catalogIOManager; @@ -72,4 +78,97 @@ public OpenCGAResult userSearch(Query query, QueryOptions options, String } } + public OpenCGAResult updateGroups(String userId, List studyIds, List groupIds, + ParamUtils.AddRemoveAction action, String token) throws CatalogException { + ObjectMap auditParams = new ObjectMap() + .append("userId", userId) + .append("studyIds", studyIds) + .append("groupIds", groupIds) + .append("action", action) + .append("token", token); + String authenticatedUser = catalogManager.getUserManager().getUserId(token); + try { + authorizationManager.checkIsInstallationAdministrator(authenticatedUser); + + // Check userId exists + Query query = new Query(UserDBAdaptor.QueryParams.ID.key(), userId); + OpenCGAResult count = userDBAdaptor.count(query); + if (count.getNumMatches() == 0) { + throw new CatalogException("User '" + userId + "' not found."); + } + + boolean membersPassed = groupIds.stream().anyMatch(g -> g.startsWith("@") + ? ParamConstants.MEMBERS_GROUP.equals(g) + : ParamConstants.MEMBERS_GROUP.equals("@" + g)); + if (action.equals(ParamUtils.AddRemoveAction.REMOVE) && membersPassed) { + // TODO: If @members is added for REMOVAL, we should also automatically remove all permissions. + throw new CatalogException("Operation not supported for '@members' group."); + } + + // Check studyIds exist + List studies = catalogManager.getStudyManager().resolveIds(studyIds, authenticatedUser); + List studyUids = new ArrayList<>(studies.size()); + for (Study study : studies) { + if (ParamConstants.ADMIN_STUDY_FQN.equals(study.getFqn())) { + if (CollectionUtils.isNotEmpty(studyIds)) { + // Only fail if the user is passing the list of study ids + throw new CatalogException("Cannot perform this operation on administration study '" + study.getFqn() + "'."); + } + } else { + studyUids.add(study.getUid()); + } + } + + OpenCGAResult result = studyDBAdaptor.updateUserFromGroups(userId, studyUids, groupIds, action); + + auditManager.audit(userId, Enums.Action.UPDATE_USERS_FROM_STUDY_GROUP, Enums.Resource.STUDY, "", "", "", "", auditParams, + new AuditRecord.Status(AuditRecord.Status.Result.SUCCESS)); + return result; + } catch (CatalogException e) { + auditManager.audit(userId, Enums.Action.UPDATE_USERS_FROM_STUDY_GROUP, Enums.Resource.STUDY, "", "", "", "", auditParams, + new AuditRecord.Status(AuditRecord.Status.Result.ERROR, e.getError())); + throw e; + } + } + + /** + * Add a user to all the remote groups he/she may belong for a particular authentication origin. + * Also remove the user from other groups he/she may have been associated in the past for the same authentication origin. + * + * @param userId User id. + * @param remoteGroupIds List of group ids the user must be associated with. + * @param authenticationOriginId The authentication origin the groups must be associated to. + * @param token Administrator token. + * @return An empty OpenCGAResult. + * @throws CatalogException If the token is invalid or belongs to a user other thant the Administrator and if userId does not exist. + */ + public OpenCGAResult syncRemoteGroups(String userId, List remoteGroupIds, + String authenticationOriginId, String token) throws CatalogException { + ObjectMap auditParams = new ObjectMap() + .append("userId", userId) + .append("remoteGroupIds", remoteGroupIds) + .append("authenticationOriginId", authenticationOriginId) + .append("token", token); + String authenticatedUser = catalogManager.getUserManager().getUserId(token); + try { + authorizationManager.checkIsInstallationAdministrator(authenticatedUser); + + // Check userId exists + Query query = new Query(UserDBAdaptor.QueryParams.ID.key(), userId); + OpenCGAResult count = userDBAdaptor.count(query); + if (count.getNumMatches() == 0) { + throw new CatalogException("User '" + userId + "' not found."); + } + OpenCGAResult result = studyDBAdaptor.resyncUserWithSyncedGroups(userId, remoteGroupIds, authenticationOriginId); + + auditManager.audit(userId, Enums.Action.UPDATE_USERS_FROM_STUDY_GROUP, Enums.Resource.STUDY, "", "", "", "", auditParams, + new AuditRecord.Status(AuditRecord.Status.Result.SUCCESS)); + return result; + } catch (CatalogException e) { + auditManager.audit(userId, Enums.Action.UPDATE_USERS_FROM_STUDY_GROUP, Enums.Resource.STUDY, "", "", "", "", auditParams, + new AuditRecord.Status(AuditRecord.Status.Result.ERROR, e.getError())); + throw e; + } + } + } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java index 1f0a9ae40c6..b95d3b0ff0e 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java @@ -184,7 +184,7 @@ public void audit(String operationId, String userId, Enums.Action action, Enums. public void audit(String operationId, String userId, Enums.Action action, Enums.Resource resource, String resourceId, String resourceUuid, String studyId, String studyUuid, ObjectMap params, AuditRecord.Status status, ObjectMap attributes) { - String apiVersion = GitRepositoryState.get().getBuildVersion(); + String apiVersion = GitRepositoryState.getInstance().getBuildVersion(); Date date = TimeUtils.getDate(); String auditId = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java index 6be7ad1be28..b1c2df87d1f 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java @@ -268,7 +268,7 @@ public DataResult facetedQuery(Study study, String collection, Query //***************** PRIVATE ****************/ private void populateConfigCollectionMap() { - String version = GitRepositoryState.get().getBuildVersion(); + String version = GitRepositoryState.getInstance().getBuildVersion(); CONFIGS_COLLECTION.put(DATABASE_PREFIX + COHORT_SOLR_COLLECTION, COHORT_CONF_SET + "-" + version); CONFIGS_COLLECTION.put(DATABASE_PREFIX + FILE_SOLR_COLLECTION, FILE_CONF_SET + "-" + version); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java index 16a638e0e2d..bb59584363b 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java @@ -125,7 +125,7 @@ public void validate(TemplateManifest manifest) throws CatalogException { } // Check version - GitRepositoryState gitRepositoryState = GitRepositoryState.get(); + GitRepositoryState gitRepositoryState = GitRepositoryState.getInstance(); String version = gitRepositoryState.getBuildVersion(); String versionShort; if (version.contains("-")) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java index 6459083abab..b56966a44e8 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java @@ -25,7 +25,7 @@ public class PedigreeGraphUtils { public static final String PEDIGREE_JSON_FILENAME = "ped_coords.json"; public static final String PEDIGREE_TSV_FILENAME = "ped_coords.tsv"; - public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); + public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.getInstance().getBuildVersion(); public static PedigreeGraph getPedigreeGraph(Family family, Path openCgaHome, Path scratchDir) throws IOException { PedigreeGraph pedigreeGraph = new PedigreeGraph(); diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptorTest.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptorTest.java index f8c7b20e550..5791005394c 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptorTest.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptorTest.java @@ -26,6 +26,7 @@ import org.opencb.opencga.catalog.exceptions.CatalogDBException; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.catalog.exceptions.CatalogParameterException; +import org.opencb.opencga.catalog.utils.ParamUtils; import org.opencb.opencga.core.models.study.*; import org.opencb.opencga.core.testclassification.duration.MediumTests; @@ -208,7 +209,7 @@ public void removeUsersFromAllGroups() throws CatalogDBException, CatalogParamet } @Test - public void resyncUserWithSyncedGroups() throws CatalogDBException { + public void resyncUserWithSyncedGroups() throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { // We create synced groups and not synced groups in study 5 Group group = new Group("@notSyncedGroup", Arrays.asList("user1", "user2", "user3")); catalogStudyDBAdaptor.createGroup(5L, group); @@ -275,4 +276,74 @@ public void resyncUserWithSyncedGroups() throws CatalogDBException { .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup2", "@syncedGroup3", "@members"))); } + @Test + public void updateUserToGroups() throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + // We create synced groups and not synced groups in study 5 + Group group = new Group("@notSyncedGroup", Collections.emptyList()); + catalogStudyDBAdaptor.createGroup(5L, group); + group.setId("@syncedGroup1"); + group.setSyncedFrom(new Group.Sync("origin1", "@syncedGroup1")); + catalogStudyDBAdaptor.createGroup(5L, group); + group.setId("@syncedGroup2"); + group.setSyncedFrom(new Group.Sync("origin1", "@syncedGroup2")); + catalogStudyDBAdaptor.createGroup(5L, group); + group.setId("@syncedGroup3"); + group.setSyncedFrom(new Group.Sync("otherOrigin", "@syncedGroup3")); + catalogStudyDBAdaptor.createGroup(5L, group); + + // We create the same synced groups and not synced groups in study 9 + group = new Group("@notSyncedGroup", Collections.emptyList()); + catalogStudyDBAdaptor.createGroup(9L, group); + group.setId("@syncedGroup1"); + group.setSyncedFrom(new Group.Sync("origin1", "@syncedGroup1")); + catalogStudyDBAdaptor.createGroup(9L, group); + group.setId("@syncedGroup2"); + group.setSyncedFrom(new Group.Sync("origin1", "@syncedGroup2")); + catalogStudyDBAdaptor.createGroup(9L, group); + group.setId("@syncedGroup3"); + group.setSyncedFrom(new Group.Sync("otherOrigin", "@syncedGroup3")); + catalogStudyDBAdaptor.createGroup(9L, group); + group = new Group("@otherNotSyncedGroup", Collections.emptyList()); + catalogStudyDBAdaptor.createGroup(9L, group); + + catalogStudyDBAdaptor.updateUserFromGroups("user2", null, Arrays.asList("syncedGroup1", "notSyncedGroup"), ParamUtils.AddRemoveAction.ADD); + DataResult groupsStudy1 = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user2")); + DataResult groupsStudy2 = catalogStudyDBAdaptor.getGroup(9L, null, Arrays.asList("user2")); + assertEquals(groupsStudy1.getNumResults(), groupsStudy2.getNumResults()); + assertEquals(3, groupsStudy1.getNumResults()); + assertTrue(groupsStudy1.getResults().stream().map(Group::getId).collect(Collectors.toList()) + .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup1", "@members"))); + assertEquals(3, groupsStudy2.getNumResults()); + assertTrue(groupsStudy2.getResults().stream().map(Group::getId).collect(Collectors.toList()) + .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup1", "@members"))); + + catalogStudyDBAdaptor.updateUserFromGroups("user2", null, Arrays.asList("syncedGroup1", "notSyncedGroup"), ParamUtils.AddRemoveAction.REMOVE); + groupsStudy1 = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user2")); + groupsStudy2 = catalogStudyDBAdaptor.getGroup(9L, null, Arrays.asList("user2")); + assertEquals(1, groupsStudy1.getNumResults()); + assertEquals(1, groupsStudy2.getNumResults()); + assertEquals("@members", groupsStudy1.first().getId()); + assertEquals("@members", groupsStudy2.first().getId()); + + catalogStudyDBAdaptor.updateUserFromGroups("user2", Arrays.asList(5L, 9L), Arrays.asList("syncedGroup1", "notSyncedGroup"), ParamUtils.AddRemoveAction.ADD); + groupsStudy1 = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user2")); + groupsStudy2 = catalogStudyDBAdaptor.getGroup(9L, null, Arrays.asList("user2")); + assertEquals(groupsStudy1.getNumResults(), groupsStudy2.getNumResults()); + assertEquals(3, groupsStudy1.getNumResults()); + assertTrue(groupsStudy1.getResults().stream().map(Group::getId).collect(Collectors.toList()) + .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup1", "@members"))); + assertEquals(3, groupsStudy2.getNumResults()); + assertTrue(groupsStudy2.getResults().stream().map(Group::getId).collect(Collectors.toList()) + .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup1", "@members"))); + + catalogStudyDBAdaptor.updateUserFromGroups("user2", Collections.singletonList(5L), Arrays.asList("syncedGroup1", "notSyncedGroup"), ParamUtils.AddRemoveAction.REMOVE); + groupsStudy1 = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user2")); + groupsStudy2 = catalogStudyDBAdaptor.getGroup(9L, null, Arrays.asList("user2")); + assertEquals(1, groupsStudy1.getNumResults()); + assertEquals("@members", groupsStudy1.first().getId()); + assertEquals(3, groupsStudy2.getNumResults()); + assertTrue(groupsStudy2.getResults().stream().map(Group::getId).collect(Collectors.toList()) + .containsAll(Arrays.asList("@notSyncedGroup", "@syncedGroup1", "@members"))); + } + } diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java index cc0a758e602..677262d5cf8 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java @@ -41,7 +41,7 @@ public void before() throws Exception { Path rootDir = getOpencgaHome(); - String version = GitRepositoryState.get().getBuildVersion(); + String version = GitRepositoryState.getInstance().getBuildVersion(); // Copy configuration copyConfiguration("cohort-managed-schema", CatalogSolrManager.COHORT_CONF_SET + "-" + version); diff --git a/opencga-client/src/main/R/R/Admin-methods.R b/opencga-client/src/main/R/R/Admin-methods.R index 11b7d569372..5d46536451d 100644 --- a/opencga-client/src/main/R/R/Admin-methods.R +++ b/opencga-client/src/main/R/R/Admin-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -28,6 +28,7 @@ #' | importUsers | /{apiVersion}/admin/users/import | body[*] | #' | searchUsers | /{apiVersion}/admin/users/search | include, exclude, limit, skip, count, user, account, authenticationId | #' | syncUsers | /{apiVersion}/admin/users/sync | body[*] | +#' | usersUpdateGroups | /{apiVersion}/admin/users/{user}/groups/update | user[*], action, body[*] | #' #' @md #' @seealso \url{http://docs.opencb.org/display/opencga/Using+OpenCGA} and the RESTful API documentation @@ -35,7 +36,7 @@ #' [*]: Required parameter #' @export -setMethod("adminClient", "OpencgaR", function(OpencgaR, endpointName, params=NULL, ...) { +setMethod("adminClient", "OpencgaR", function(OpencgaR, user, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/admin/audit/groupBy: @@ -100,5 +101,13 @@ setMethod("adminClient", "OpencgaR", function(OpencgaR, endpointName, params=NUL #' @param data JSON containing the parameters. syncUsers=fetchOpenCGA(object=OpencgaR, category="admin", categoryId=NULL, subcategory="users", subcategoryId=NULL, action="sync", params=params, httpMethod="POST", as.queryParam=NULL, ...), + + #' @section Endpoint /{apiVersion}/admin/users/{user}/groups/update: + #' Add or remove users from existing groups. + #' @param user User ID. + #' @param action Action to be performed: ADD or REMOVE user to/from groups. Allowed values: ['ADD REMOVE'] + #' @param data JSON containing the parameters. + usersUpdateGroups=fetchOpenCGA(object=OpencgaR, category="admin/users", categoryId=user, subcategory="groups", + subcategoryId=NULL, action="update", params=params, httpMethod="POST", as.queryParam=NULL, ...), ) }) \ No newline at end of file diff --git a/opencga-client/src/main/R/R/Alignment-methods.R b/opencga-client/src/main/R/R/Alignment-methods.R index 00be80c77b7..206b0aa2646 100644 --- a/opencga-client/src/main/R/R/Alignment-methods.R +++ b/opencga-client/src/main/R/R/Alignment-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/AllGenerics.R b/opencga-client/src/main/R/R/AllGenerics.R index 7c9d2230cf6..8e9baedd284 100644 --- a/opencga-client/src/main/R/R/AllGenerics.R +++ b/opencga-client/src/main/R/R/AllGenerics.R @@ -1,6 +1,6 @@ # ############################################################################## ## UserClient -setGeneric("userClient", function(OpencgaR, filterId, users, user, endpointName, params=NULL, ...) +setGeneric("userClient", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...) standardGeneric("userClient")) # ############################################################################## @@ -10,17 +10,17 @@ setGeneric("projectClient", function(OpencgaR, projects, project, endpointName, # ############################################################################## ## StudyClient -setGeneric("studyClient", function(OpencgaR, members, templateId, studies, variableSet, group, study, endpointName, params=NULL, ...) +setGeneric("studyClient", function(OpencgaR, members, variableSet, studies, group, study, templateId, endpointName, params=NULL, ...) standardGeneric("studyClient")) # ############################################################################## ## FileClient -setGeneric("fileClient", function(OpencgaR, folder, file, members, files, annotationSet, endpointName, params=NULL, ...) +setGeneric("fileClient", function(OpencgaR, files, members, file, annotationSet, folder, endpointName, params=NULL, ...) standardGeneric("fileClient")) # ############################################################################## ## JobClient -setGeneric("jobClient", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...) +setGeneric("jobClient", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...) standardGeneric("jobClient")) # ############################################################################## @@ -30,17 +30,17 @@ setGeneric("sampleClient", function(OpencgaR, members, sample, samples, annotati # ############################################################################## ## IndividualClient -setGeneric("individualClient", function(OpencgaR, members, individual, annotationSet, individuals, endpointName, params=NULL, ...) +setGeneric("individualClient", function(OpencgaR, members, individuals, annotationSet, individual, endpointName, params=NULL, ...) standardGeneric("individualClient")) # ############################################################################## ## FamilyClient -setGeneric("familyClient", function(OpencgaR, members, families, family, annotationSet, endpointName, params=NULL, ...) +setGeneric("familyClient", function(OpencgaR, members, family, annotationSet, families, endpointName, params=NULL, ...) standardGeneric("familyClient")) # ############################################################################## ## CohortClient -setGeneric("cohortClient", function(OpencgaR, members, cohort, annotationSet, cohorts, endpointName, params=NULL, ...) +setGeneric("cohortClient", function(OpencgaR, members, annotationSet, cohort, cohorts, endpointName, params=NULL, ...) standardGeneric("cohortClient")) # ############################################################################## @@ -60,7 +60,7 @@ setGeneric("variantClient", function(OpencgaR, endpointName, params=NULL, ...) # ############################################################################## ## ClinicalClient -setGeneric("clinicalClient", function(OpencgaR, clinicalAnalysis, members, interpretation, clinicalAnalyses, interpretations, endpointName, params=NULL, ...) +setGeneric("clinicalClient", function(OpencgaR, interpretations, members, interpretation, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...) standardGeneric("clinicalClient")) # ############################################################################## @@ -80,6 +80,6 @@ setGeneric("ga4ghClient", function(OpencgaR, file, study, endpointName, params=N # ############################################################################## ## AdminClient -setGeneric("adminClient", function(OpencgaR, endpointName, params=NULL, ...) +setGeneric("adminClient", function(OpencgaR, user, endpointName, params=NULL, ...) standardGeneric("adminClient")) diff --git a/opencga-client/src/main/R/R/Clinical-methods.R b/opencga-client/src/main/R/R/Clinical-methods.R index c590dab0b25..f0652ba64dd 100644 --- a/opencga-client/src/main/R/R/Clinical-methods.R +++ b/opencga-client/src/main/R/R/Clinical-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -58,7 +58,7 @@ #' [*]: Required parameter #' @export -setMethod("clinicalClient", "OpencgaR", function(OpencgaR, clinicalAnalysis, members, interpretation, clinicalAnalyses, interpretations, endpointName, params=NULL, ...) { +setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, members, interpretation, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/analysis/clinical/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Cohort-methods.R b/opencga-client/src/main/R/R/Cohort-methods.R index 3d1c6034484..2bcb87bbbbc 100644 --- a/opencga-client/src/main/R/R/Cohort-methods.R +++ b/opencga-client/src/main/R/R/Cohort-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -39,7 +39,7 @@ #' [*]: Required parameter #' @export -setMethod("cohortClient", "OpencgaR", function(OpencgaR, members, cohort, annotationSet, cohorts, endpointName, params=NULL, ...) { +setMethod("cohortClient", "OpencgaR", function(OpencgaR, members, annotationSet, cohort, cohorts, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/cohorts/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Family-methods.R b/opencga-client/src/main/R/R/Family-methods.R index b4bdd82fbc5..5993bbe8de9 100644 --- a/opencga-client/src/main/R/R/Family-methods.R +++ b/opencga-client/src/main/R/R/Family-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -38,7 +38,7 @@ #' [*]: Required parameter #' @export -setMethod("familyClient", "OpencgaR", function(OpencgaR, members, families, family, annotationSet, endpointName, params=NULL, ...) { +setMethod("familyClient", "OpencgaR", function(OpencgaR, members, family, annotationSet, families, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/families/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/File-methods.R b/opencga-client/src/main/R/R/File-methods.R index d97412f4788..0ef0d2c83d8 100644 --- a/opencga-client/src/main/R/R/File-methods.R +++ b/opencga-client/src/main/R/R/File-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -54,7 +54,7 @@ #' [*]: Required parameter #' @export -setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, file, members, files, annotationSet, endpointName, params=NULL, ...) { +setMethod("fileClient", "OpencgaR", function(OpencgaR, files, members, file, annotationSet, folder, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/files/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/GA4GH-methods.R b/opencga-client/src/main/R/R/GA4GH-methods.R index defcc45b18f..534e75260ad 100644 --- a/opencga-client/src/main/R/R/GA4GH-methods.R +++ b/opencga-client/src/main/R/R/GA4GH-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Individual-methods.R b/opencga-client/src/main/R/R/Individual-methods.R index 1ded4cea574..019acd410c2 100644 --- a/opencga-client/src/main/R/R/Individual-methods.R +++ b/opencga-client/src/main/R/R/Individual-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -39,7 +39,7 @@ #' [*]: Required parameter #' @export -setMethod("individualClient", "OpencgaR", function(OpencgaR, members, individual, annotationSet, individuals, endpointName, params=NULL, ...) { +setMethod("individualClient", "OpencgaR", function(OpencgaR, members, individuals, annotationSet, individual, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/individuals/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Job-methods.R b/opencga-client/src/main/R/R/Job-methods.R index 9a6319a293c..f85fe4840f7 100644 --- a/opencga-client/src/main/R/R/Job-methods.R +++ b/opencga-client/src/main/R/R/Job-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -40,7 +40,7 @@ #' [*]: Required parameter #' @export -setMethod("jobClient", "OpencgaR", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...) { +setMethod("jobClient", "OpencgaR", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/jobs/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Meta-methods.R b/opencga-client/src/main/R/R/Meta-methods.R index cfd47fb4f17..d4de1c866b8 100644 --- a/opencga-client/src/main/R/R/Meta-methods.R +++ b/opencga-client/src/main/R/R/Meta-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Operation-methods.R b/opencga-client/src/main/R/R/Operation-methods.R index 8869d0ff5a3..902a0403f47 100644 --- a/opencga-client/src/main/R/R/Operation-methods.R +++ b/opencga-client/src/main/R/R/Operation-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Panel-methods.R b/opencga-client/src/main/R/R/Panel-methods.R index ea88beb1bfa..e7d661d3a2c 100644 --- a/opencga-client/src/main/R/R/Panel-methods.R +++ b/opencga-client/src/main/R/R/Panel-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Project-methods.R b/opencga-client/src/main/R/R/Project-methods.R index 88420d4beb6..b4ab8a5b98e 100644 --- a/opencga-client/src/main/R/R/Project-methods.R +++ b/opencga-client/src/main/R/R/Project-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Sample-methods.R b/opencga-client/src/main/R/R/Sample-methods.R index fa8bc1e707a..89b2d7b5876 100644 --- a/opencga-client/src/main/R/R/Sample-methods.R +++ b/opencga-client/src/main/R/R/Sample-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/R/R/Study-methods.R b/opencga-client/src/main/R/R/Study-methods.R index 425059d2d03..754fa677dea 100644 --- a/opencga-client/src/main/R/R/Study-methods.R +++ b/opencga-client/src/main/R/R/Study-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -46,7 +46,7 @@ #' [*]: Required parameter #' @export -setMethod("studyClient", "OpencgaR", function(OpencgaR, members, templateId, studies, variableSet, group, study, endpointName, params=NULL, ...) { +setMethod("studyClient", "OpencgaR", function(OpencgaR, members, variableSet, studies, group, study, templateId, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/studies/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/User-methods.R b/opencga-client/src/main/R/R/User-methods.R index 9faadad0488..7fb54a32ff1 100644 --- a/opencga-client/src/main/R/R/User-methods.R +++ b/opencga-client/src/main/R/R/User-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. @@ -38,7 +38,7 @@ #' [*]: Required parameter #' @export -setMethod("userClient", "OpencgaR", function(OpencgaR, filterId, users, user, endpointName, params=NULL, ...) { +setMethod("userClient", "OpencgaR", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/users/login: diff --git a/opencga-client/src/main/R/R/Variant-methods.R b/opencga-client/src/main/R/R/Variant-methods.R index e9e2f67edeb..0b7a706cb8f 100644 --- a/opencga-client/src/main/R/R/Variant-methods.R +++ b/opencga-client/src/main/R/R/Variant-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-04-18 +# Autogenerated on: 2023-08-30 # # Manual changes to this file may cause unexpected behavior in your application. # Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java index 4baf9a8229e..2a375bb7b83 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java @@ -25,6 +25,7 @@ import org.opencb.opencga.core.models.admin.JWTParams; import org.opencb.opencga.core.models.admin.UserCreateParams; import org.opencb.opencga.core.models.admin.UserImportParams; +import org.opencb.opencga.core.models.admin.UserUpdateGroup; import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.Group; import org.opencb.opencga.core.models.user.User; @@ -35,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -44,7 +45,7 @@ /** * This class contains methods for the Admin webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: admin */ public class AdminClient extends AbstractParentClient { @@ -165,4 +166,19 @@ public RestResponse syncUsers(GroupSyncParams data) throws ClientExceptio params.put("body", data); return execute("admin", null, "users", null, "sync", params, POST, Group.class); } + + /** + * Add or remove users from existing groups. + * @param user User ID. + * @param data JSON containing the parameters. + * @param params Map containing any of the following optional parameters. + * action: Action to be performed: ADD or REMOVE user to/from groups. + * @return a RestResponse object. + * @throws ClientException ClientException if there is any server error. + */ + public RestResponse usersUpdateGroups(String user, UserUpdateGroup data, ObjectMap params) throws ClientException { + params = params != null ? params : new ObjectMap(); + params.put("body", data); + return execute("admin/users", user, "groups", null, "update", params, POST, Group.class); + } } diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java index c153146ca4e..08257cc1a1a 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java @@ -40,7 +40,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -49,7 +49,7 @@ /** * This class contains methods for the Alignment webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: analysis/alignment */ public class AlignmentClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java index 9da4bc7e24c..32ab712003e 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java @@ -51,7 +51,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -60,7 +60,7 @@ /** * This class contains methods for the ClinicalAnalysis webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: analysis/clinical */ public class ClinicalAnalysisClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java index 11bfc04c972..547601b9329 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java @@ -37,7 +37,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -46,7 +46,7 @@ /** * This class contains methods for the Cohort webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: cohorts */ public class CohortClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java index fc47e555d99..ad5ea1a7047 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java @@ -35,7 +35,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -44,7 +44,7 @@ /** * This class contains methods for the DiseasePanel webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: panels */ public class DiseasePanelClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java index 072933ac1e2..d113cbdaf09 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -45,7 +45,7 @@ /** * This class contains methods for the Family webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: families */ public class FamilyClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java index 553e0983a27..72be6ed305b 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java @@ -43,7 +43,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -52,7 +52,7 @@ /** * This class contains methods for the File webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: files */ public class FileClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java index a4bc5b7f11c..fbb84f972a4 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java @@ -27,7 +27,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -36,7 +36,7 @@ /** * This class contains methods for the GA4GH webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: ga4gh */ public class GA4GHClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java index 3b41baf7ae6..5803d125e54 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -45,7 +45,7 @@ /** * This class contains methods for the Individual webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: individuals */ public class IndividualClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java index 334c154ae53..27245d4011c 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java @@ -37,7 +37,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -46,7 +46,7 @@ /** * This class contains methods for the Job webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: jobs */ public class JobClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java index ac4c311a0bb..c2c015b670d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java @@ -28,7 +28,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -37,7 +37,7 @@ /** * This class contains methods for the Meta webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: meta */ public class MetaClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java index 9a3094cb554..47aeec33622 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java @@ -32,7 +32,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -41,7 +41,7 @@ /** * This class contains methods for the Project webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: projects */ public class ProjectClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java index efeca3bd4b3..d2dd71bc2f3 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -45,7 +45,7 @@ /** * This class contains methods for the Sample webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: samples */ public class SampleClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java index 47f1ce2dbc9..53502e91c7e 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java @@ -45,7 +45,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -54,7 +54,7 @@ /** * This class contains methods for the Study webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: studies */ public class StudyClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java index bdf3eb4f232..eda89cb9228 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -45,7 +45,7 @@ /** * This class contains methods for the User webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: users */ public class UserClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java index 5b135d4d38e..0d25391978a 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java @@ -62,7 +62,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -71,7 +71,7 @@ /** * This class contains methods for the Variant webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: analysis/variant */ public class VariantClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java index e15498be36d..ae6bef9d18d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java @@ -50,7 +50,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-04-18 +* Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -59,7 +59,7 @@ /** * This class contains methods for the VariantOperation webservices. - * Client version: 2.8.0-SNAPSHOT + * Client version: 2.11.0-SNAPSHOT * PATH: operation */ public class VariantOperationClient extends AbstractParentClient { diff --git a/opencga-client/src/main/javascript/Admin.js b/opencga-client/src/main/javascript/Admin.js index 53c4f4e9c41..26d6d454012 100644 --- a/opencga-client/src/main/javascript/Admin.js +++ b/opencga-client/src/main/javascript/Admin.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. @@ -116,4 +116,15 @@ export default class Admin extends OpenCGAParentClass { return this._post("admin", null, "users", null, "sync", data); } + /** Add or remove users from existing groups + * @param {String} user - User ID. + * @param {Object} data - JSON containing the parameters. + * @param {Object} [params] - The Object containing the following optional parameters: + * @param {"ADD REMOVE"} [params.action = "ADD"] - Action to be performed: ADD or REMOVE user to/from groups. The default value is ADD. + * @returns {Promise} Promise object in the form of RestResponse instance. + */ + usersUpdateGroups(user, data, params) { + return this._post("admin/users", user, "groups", null, "update", data, params); + } + } \ No newline at end of file diff --git a/opencga-client/src/main/javascript/Alignment.js b/opencga-client/src/main/javascript/Alignment.js index bc3b7eb2c02..33aa92db017 100644 --- a/opencga-client/src/main/javascript/Alignment.js +++ b/opencga-client/src/main/javascript/Alignment.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/ClinicalAnalysis.js b/opencga-client/src/main/javascript/ClinicalAnalysis.js index 30c195691ca..4434d811346 100644 --- a/opencga-client/src/main/javascript/ClinicalAnalysis.js +++ b/opencga-client/src/main/javascript/ClinicalAnalysis.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Cohort.js b/opencga-client/src/main/javascript/Cohort.js index 56f11ab10fa..cb53c5278a3 100644 --- a/opencga-client/src/main/javascript/Cohort.js +++ b/opencga-client/src/main/javascript/Cohort.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/DiseasePanel.js b/opencga-client/src/main/javascript/DiseasePanel.js index c8a18d38ab6..a4bc253c0bd 100644 --- a/opencga-client/src/main/javascript/DiseasePanel.js +++ b/opencga-client/src/main/javascript/DiseasePanel.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Family.js b/opencga-client/src/main/javascript/Family.js index eef6b77e11e..e971b3b2e81 100644 --- a/opencga-client/src/main/javascript/Family.js +++ b/opencga-client/src/main/javascript/Family.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/File.js b/opencga-client/src/main/javascript/File.js index 66ca23ddf1e..b3219c4f08a 100644 --- a/opencga-client/src/main/javascript/File.js +++ b/opencga-client/src/main/javascript/File.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/GA4GH.js b/opencga-client/src/main/javascript/GA4GH.js index e6fb38143ac..ec01beb21de 100644 --- a/opencga-client/src/main/javascript/GA4GH.js +++ b/opencga-client/src/main/javascript/GA4GH.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Individual.js b/opencga-client/src/main/javascript/Individual.js index 2487febccf8..71eb45dbafd 100644 --- a/opencga-client/src/main/javascript/Individual.js +++ b/opencga-client/src/main/javascript/Individual.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Job.js b/opencga-client/src/main/javascript/Job.js index e76d111f0b5..1e1cc91bc52 100644 --- a/opencga-client/src/main/javascript/Job.js +++ b/opencga-client/src/main/javascript/Job.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Meta.js b/opencga-client/src/main/javascript/Meta.js index b0208dd1cfd..24dfe87c63d 100644 --- a/opencga-client/src/main/javascript/Meta.js +++ b/opencga-client/src/main/javascript/Meta.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Project.js b/opencga-client/src/main/javascript/Project.js index 06abda04b57..e240c25cb46 100644 --- a/opencga-client/src/main/javascript/Project.js +++ b/opencga-client/src/main/javascript/Project.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Sample.js b/opencga-client/src/main/javascript/Sample.js index 2c4fdd8956a..03c6a5b8d8f 100644 --- a/opencga-client/src/main/javascript/Sample.js +++ b/opencga-client/src/main/javascript/Sample.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Study.js b/opencga-client/src/main/javascript/Study.js index 029d4133c82..e99e8c7606b 100644 --- a/opencga-client/src/main/javascript/Study.js +++ b/opencga-client/src/main/javascript/Study.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/User.js b/opencga-client/src/main/javascript/User.js index fd3b9adaf52..bfed2a7bfec 100644 --- a/opencga-client/src/main/javascript/User.js +++ b/opencga-client/src/main/javascript/User.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/Variant.js b/opencga-client/src/main/javascript/Variant.js index f5f8b2e09a1..ae9365d5448 100644 --- a/opencga-client/src/main/javascript/Variant.js +++ b/opencga-client/src/main/javascript/Variant.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/javascript/VariantOperation.js b/opencga-client/src/main/javascript/VariantOperation.js index 604e09d9ccf..f9837f69e25 100644 --- a/opencga-client/src/main/javascript/VariantOperation.js +++ b/opencga-client/src/main/javascript/VariantOperation.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-04-18 + * Autogenerated on: 2023-08-30 * * Manual changes to this file may cause unexpected behavior in your application. * Manual changes to this file will be overwritten if the code is regenerated. diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py index 7048467edf6..e982694d126 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Admin(_ParentRestClient): """ This class contains methods for the 'Admin' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/admin """ @@ -128,3 +128,16 @@ def sync_users(self, data=None, **options): return self._post(category='admin', resource='sync', subcategory='users', data=data, **options) + def users_update_groups(self, user, data=None, **options): + """ + Add or remove users from existing groups. + PATH: /{apiVersion}/admin/users/{user}/groups/update + + :param dict data: JSON containing the parameters. (REQUIRED) + :param str user: User ID. (REQUIRED) + :param str action: Action to be performed: ADD or REMOVE user to/from + groups. Allowed values: ['ADD REMOVE'] + """ + + return self._post(category='admin/users', resource='update', query_id=user, subcategory='groups', data=data, **options) + diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py index 826ae8b6957..b94f350449a 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Alignment(_ParentRestClient): """ This class contains methods for the 'Analysis - Alignment' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/analysis/alignment """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py index e6ced9ecbf3..ca4e1438978 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class ClinicalAnalysis(_ParentRestClient): """ This class contains methods for the 'Analysis - Clinical' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/analysis/clinical """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py index 6c685b9772a..fef4cafa48d 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Cohort(_ParentRestClient): """ This class contains methods for the 'Cohorts' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/cohorts """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py index 4ec0b95c8fa..8382900c307 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class DiseasePanel(_ParentRestClient): """ This class contains methods for the 'Disease Panels' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/panels """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py index ab94612b324..0637f728a08 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Family(_ParentRestClient): """ This class contains methods for the 'Families' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/families """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py index 0db45804764..816cdf83c0b 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class File(_ParentRestClient): """ This class contains methods for the 'Files' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/files """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py index 0b1c0df4afa..6f62ec62786 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class GA4GH(_ParentRestClient): """ This class contains methods for the 'GA4GH' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/ga4gh """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py index e4830dbe5ab..3982f010208 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Individual(_ParentRestClient): """ This class contains methods for the 'Individuals' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/individuals """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py index fe0a9ec74d3..313cf0df796 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Job(_ParentRestClient): """ This class contains methods for the 'Jobs' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/jobs """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py index 96982cc0e3d..189a5ab62ea 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Meta(_ParentRestClient): """ This class contains methods for the 'Meta' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/meta """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py index d28ecf4d846..0784b20594c 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Project(_ParentRestClient): """ This class contains methods for the 'Projects' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/projects """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py index dca81d4e863..258189685ef 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Sample(_ParentRestClient): """ This class contains methods for the 'Samples' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/samples """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py index 53849f904d7..3726c1e0a3a 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Study(_ParentRestClient): """ This class contains methods for the 'Studies' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/studies """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py index 0a446be7d9a..80ac433566b 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class User(_ParentRestClient): """ This class contains methods for the 'Users' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/users """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py index cc233157566..32dfa804648 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class Variant(_ParentRestClient): """ This class contains methods for the 'Analysis - Variant' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/analysis/variant """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py index 80eb4b8c973..4070484d219 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-04-18 + Autogenerated on: 2023-08-30 Manual changes to this file may cause unexpected behavior in your application. Manual changes to this file will be overwritten if the code is regenerated. @@ -14,7 +14,7 @@ class VariantOperation(_ParentRestClient): """ This class contains methods for the 'Operations - Variant Storage' webservices - Client version: 2.8.0-SNAPSHOT + Client version: 2.11.0-SNAPSHOT PATH: /{apiVersion}/operation """ diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/cellbase/CellBaseValidator.java b/opencga-core/src/main/java/org/opencb/opencga/core/cellbase/CellBaseValidator.java index a2c5da2dc72..467dabf7b75 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/cellbase/CellBaseValidator.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/cellbase/CellBaseValidator.java @@ -1,6 +1,8 @@ package org.opencb.opencga.core.cellbase; +import io.jsonwebtoken.JwtException; import org.apache.commons.lang3.StringUtils; +import org.opencb.biodata.models.variant.avro.VariantAnnotation; import org.opencb.cellbase.client.rest.CellBaseClient; import org.opencb.cellbase.core.config.SpeciesConfiguration; import org.opencb.cellbase.core.config.SpeciesProperties; @@ -8,6 +10,7 @@ import org.opencb.cellbase.core.result.CellBaseDataResponse; import org.opencb.cellbase.core.token.DataAccessTokenManager; import org.opencb.cellbase.core.token.DataAccessTokenSources; +import org.opencb.commons.datastore.core.QueryOptions; import org.opencb.opencga.core.common.VersionUtils; import org.opencb.opencga.core.config.storage.CellBaseConfiguration; import org.slf4j.Logger; @@ -15,9 +18,10 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.Optional; +import java.util.stream.Collectors; public class CellBaseValidator { @@ -46,6 +50,7 @@ private CellBaseClient newCellBaseClient(CellBaseConfiguration cellBaseConfigura toCellBaseSpeciesName(species), assembly, cellBaseConfiguration.getDataRelease(), + cellBaseConfiguration.getToken(), cellBaseConfiguration.toClientConfiguration()); } @@ -94,17 +99,33 @@ public CellBaseConfiguration getCellBaseConfiguration() { return new CellBaseConfiguration(getURL(), getVersion(), getDataRelease(), getToken()); } - public String getLatestActiveDataRelease() throws IOException { + public String getDefaultDataRelease() throws IOException { if (supportsDataRelease()) { - Optional dataRelease = cellBaseClient.getMetaClient().dataReleases() - .allResults() - .stream() - .filter(DataRelease::isActive) - .max(Comparator.comparing(DataRelease::getDate)); - if (!dataRelease.isPresent()) { + List dataReleases = cellBaseClient.getMetaClient().dataReleases() + .allResults(); + DataRelease dataRelease = null; + if (supportsDataReleaseActiveByDefaultIn()) { + // ActiveByDefault versions are stored in form `v.` , i.e. v5.5 , v5.7, ... + String majorMinor = "v" + getVersionFromServerMajorMinor(); + List drs = dataReleases + .stream() + .filter(dr -> dr.getActiveByDefaultIn() != null && dr.getActiveByDefaultIn().contains(majorMinor)) + .collect(Collectors.toList()); + if (drs.size() == 1) { + dataRelease = drs.get(0); + } else if (drs.size() > 1) { + throw new IllegalArgumentException("More than one default active data releases found on cellbase " + this); + } + } else { + dataRelease = dataReleases + .stream() + .filter(DataRelease::isActive) + .max(Comparator.comparing(DataRelease::getDate)).orElse(null); + } + if (dataRelease == null) { throw new IllegalArgumentException("No active data releases found on cellbase " + this); } else { - return String.valueOf(dataRelease.get().getRelease()); + return String.valueOf(dataRelease.getRelease()); } } else { return null; @@ -120,7 +141,7 @@ public void validate() throws IOException { validate(false); } - public CellBaseConfiguration validate(boolean autoComplete) throws IOException { + private CellBaseConfiguration validate(boolean autoComplete) throws IOException { CellBaseConfiguration cellBaseConfiguration = getCellBaseConfiguration(); String inputVersion = getVersion(); CellBaseDataResponse species; @@ -149,7 +170,7 @@ public CellBaseConfiguration validate(boolean autoComplete) throws IOException { String dataRelease = getDataRelease(); if (dataRelease == null) { if (autoComplete) { - cellBaseConfiguration.setDataRelease(getLatestActiveDataRelease()); + cellBaseConfiguration.setDataRelease(getDefaultDataRelease()); } else { throw new IllegalArgumentException("Missing DataRelease for cellbase " + "url: '" + getURL() + "'" @@ -173,6 +194,41 @@ public CellBaseConfiguration validate(boolean autoComplete) throws IOException { } } } + String token = getToken(); + if (StringUtils.isEmpty(token)) { + cellBaseConfiguration.setToken(null); + } else { + // Check it's supported + if (!supportsToken(serverVersion)) { + throw new IllegalArgumentException("Token not supported for cellbase " + + "url: '" + getURL() + "'" + + ", version: '" + inputVersion + "'"); + } + + // Check it's an actual token + DataAccessTokenManager tokenManager = new DataAccessTokenManager(); + try { + tokenManager.decode(token); + } catch (JwtException e) { + throw new IllegalArgumentException("Malformed token for cellbase " + + "url: '" + getURL() + "'" + + ", version: '" + inputVersion + + "', species: '" + getSpecies() + + "', assembly: '" + getAssembly() + "'"); + } + + // Check it's a valid token + CellBaseDataResponse response = cellBaseClient.getVariantClient() + .getAnnotationByVariantIds(Collections.singletonList("1:1:N:C"), new QueryOptions(), true); + if (response.firstResult() == null) { + throw new IllegalArgumentException("Invalid token for cellbase " + + "url: '" + getURL() + "'" + + ", version: '" + inputVersion + + "', species: '" + getSpecies() + + "', assembly: '" + getAssembly() + "'"); + } + } + return cellBaseConfiguration; } @@ -202,10 +258,24 @@ public boolean supportsDataRelease() throws IOException { } public static boolean supportsDataRelease(String serverVersion) { - // Data Release support starts at versio 5.1.0 + // Data Release support starts at version 5.1.0 return VersionUtils.isMinVersion("5.1.0", serverVersion); } + public boolean supportsDataReleaseActiveByDefaultIn() throws IOException { + return supportsDataReleaseActiveByDefaultIn(getVersionFromServer()); + } + + public static boolean supportsDataReleaseActiveByDefaultIn(String serverVersion) { + // Data Release Default Active In Version support starts at version 5.5.0 , TASK-4157 + return VersionUtils.isMinVersion("5.5.0", serverVersion, true); + } + + public static boolean supportsToken(String serverVersion) { + // Tokens support starts at version 5.4.0 + return VersionUtils.isMinVersion("5.4.0", serverVersion); + } + public String getVersionFromServerMajor() throws IOException { return major(getVersionFromServer()); } @@ -217,10 +287,13 @@ public String getVersionFromServerMajorMinor() throws IOException { } private static String major(String version) { +// return String.valueOf(new VersionUtils.Version(version).getMajor()); return version.split("\\.")[0]; } private static String majorMinor(String version) { +// VersionUtils.Version v = new VersionUtils.Version(version); +// return v.getMajor() + "." + v.getMinor(); String[] split = version.split("\\."); if (split.length > 1) { version = split[0] + "." + split[1]; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java index 80f1563dec6..790d8adcbe0 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java @@ -32,6 +32,7 @@ public class GitRepositoryState { public static final String DEFAULT_RESOURCE_NAME = "git.properties"; private static GitRepositoryState gitRepositoryState; + private static Properties properties; private static final Logger logger = LoggerFactory.getLogger(GitRepositoryState.class); private String tags; // =${git.tags} // comma separated tag names @@ -57,9 +58,16 @@ public class GitRepositoryState { private String buildHost; // =${git.build.host} private String buildVersion; // =${git.build.version} - public static GitRepositoryState get() { + public static String get(String key) { + if (properties == null) { + getInstance(); + } + return properties.getProperty(key); + } + + public static GitRepositoryState getInstance() { if (gitRepositoryState == null) { - Properties properties = new Properties(); + properties = new Properties(); InputStream stream = null; try { stream = GitRepositoryState.class.getClassLoader().getResourceAsStream(DEFAULT_RESOURCE_NAME); diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/common/VersionUtils.java b/opencga-core/src/main/java/org/opencb/opencga/core/common/VersionUtils.java index fb70ed94cb9..4e32c6ada32 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/common/VersionUtils.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/common/VersionUtils.java @@ -13,7 +13,11 @@ public static List order(List versions) { } public static boolean isMinVersion(String minVersion, String version) { - return new Version(minVersion).compareTo(new Version(version)) <= 0; + return isMinVersion(minVersion, version, false); + } + + public static boolean isMinVersion(String minVersion, String version, boolean ignorePreReleaseVersioning) { + return new Version(minVersion).compareTo(new Version(version), ignorePreReleaseVersioning) <= 0; } public static class Version implements Comparable { @@ -48,6 +52,12 @@ public static class Version implements Comparable { return o1.other.compareTo(o2.other); }); + public static final Comparator COMPARATOR_NO_PR = Comparator + .comparingInt(Version::getMajor) + .thenComparingInt(Version::getMinor) + .thenComparingInt(Version::getPatch) + .thenComparingInt(Version::getRepatch); + public Version(String version) { String[] split = StringUtils.split(version, ".", 4); major = Integer.parseInt(split[0]); @@ -81,6 +91,14 @@ public int compareTo(Version o) { return COMPARATOR.compare(this, o); } + public int compareTo(Version o, boolean ignorePreReleaseVersioning) { + if (ignorePreReleaseVersioning) { + return COMPARATOR_NO_PR.compare(this, o); + } else { + return COMPARATOR.compare(this, o); + } + } + public int getMajor() { return major; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java b/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java index 53f0014dd27..a647bbd8b43 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java @@ -44,7 +44,7 @@ public static void main(String[] args) { config.setType(DocFactory.DocFactoryType.MARKDOWN); config.setOutputDir("/workspace/opencga/docs/data-models/"); config.setGithubServerURL("https://github.com/opencb/opencga/tree/" - + GitRepositoryState.get().getBranch() + "/opencga-core"); + + GitRepositoryState.getInstance().getBranch() + "/opencga-core"); config.setJsondir("/workspace/opencga/opencga-core/src/main/resources/doc/json"); config.setGitbookServerURL("https://docs.opencga.opencb.org/data-models"); try { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java index a0a67ee823a..99fb1bedeaa 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java @@ -31,7 +31,7 @@ public class Metadata { public Metadata() { - this(GitRepositoryState.get().getBuildVersion(), TimeUtils.getTime()); + this(GitRepositoryState.getInstance().getBuildVersion(), TimeUtils.getTime()); } public Metadata(String version, String creationDate) { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/admin/UserUpdateGroup.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/admin/UserUpdateGroup.java new file mode 100644 index 00000000000..ce05d03ccc2 --- /dev/null +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/admin/UserUpdateGroup.java @@ -0,0 +1,43 @@ +package org.opencb.opencga.core.models.admin; + +import java.util.List; + +public class UserUpdateGroup { + private List studyIds; + private List groupIds; + + public UserUpdateGroup() { + } + + public UserUpdateGroup(List studyIds, List groupIds) { + this.studyIds = studyIds; + this.groupIds = groupIds; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("UserUpdateGroup{"); + sb.append("studyIds=").append(studyIds); + sb.append(", groupIds=").append(groupIds); + sb.append('}'); + return sb.toString(); + } + + public List getStudyIds() { + return studyIds; + } + + public UserUpdateGroup setStudyIds(List studyIds) { + this.studyIds = studyIds; + return this; + } + + public List getGroupIds() { + return groupIds; + } + + public UserUpdateGroup setGroupIds(List groupIds) { + this.groupIds = groupIds; + return this; + } +} diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java index 732cb04adaf..a934efdc3ee 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java @@ -120,8 +120,8 @@ protected void init(String statusId, String statusName, String description) { super.name = statusName; super.description = description; super.date = TimeUtils.getTime(); - this.version = GitRepositoryState.get().getBuildVersion(); - this.commit = GitRepositoryState.get().getCommitId(); + this.version = GitRepositoryState.getInstance().getBuildVersion(); + this.commit = GitRepositoryState.getInstance().getCommitId(); } @Override diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java b/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java index da1778bf650..dc811356a1a 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java @@ -61,8 +61,8 @@ public Status(Type name, String step, Date date) { public static Status initStatus() { Status status = new Status(); - status.version = GitRepositoryState.get().getBuildVersion(); - status.commit = GitRepositoryState.get().getCommitId(); + status.version = GitRepositoryState.getInstance().getBuildVersion(); + status.commit = GitRepositoryState.getInstance().getCommitId(); return status; } diff --git a/opencga-core/src/test/java/org/opencb/opencga/core/cellbase/CellBaseValidatorTest.java b/opencga-core/src/test/java/org/opencb/opencga/core/cellbase/CellBaseValidatorTest.java index 36db80985f0..36026700237 100644 --- a/opencga-core/src/test/java/org/opencb/opencga/core/cellbase/CellBaseValidatorTest.java +++ b/opencga-core/src/test/java/org/opencb/opencga/core/cellbase/CellBaseValidatorTest.java @@ -1,6 +1,8 @@ package org.opencb.opencga.core.cellbase; +import org.apache.commons.lang3.StringUtils; import org.junit.Assert; +import org.junit.Assume; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -70,4 +72,45 @@ public void testNoActiveReleases() throws IOException { thrown.expectMessage("No active data releases found on cellbase"); CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.1", null, null), "mmusculus", "GRCm38", true); } + + @Test + public void testToken() throws IOException { + String token = System.getenv("CELLBASE_HGMD_TOKEN"); + Assume.assumeTrue(StringUtils.isNotEmpty(token)); + CellBaseConfiguration validated = CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.4", null, token), "hsapiens", "grch38", true); + Assert.assertNotNull(validated.getToken()); + } + + @Test + public void testTokenNotSupported() throws IOException { + String token = System.getenv("CELLBASE_HGMD_TOKEN"); + Assume.assumeTrue(StringUtils.isNotEmpty(token)); + thrown.expectMessage("Token not supported"); + CellBaseConfiguration validated = CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.1", null, token), "hsapiens", "grch38", true); + Assert.assertNotNull(validated.getToken()); + } + + @Test + public void testTokenEmpty() throws IOException { + String token = ""; + CellBaseConfiguration validated = CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.1", null, token), "hsapiens", "grch38", true); + Assert.assertNull(validated.getToken()); + } + + @Test + public void testMalformedToken() throws IOException { + thrown.expectMessage("Malformed token for cellbase"); + String token = "MALFORMED_TOKEN"; + CellBaseConfiguration validated = CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.4", null, token), "hsapiens", "grch38", true); + Assert.assertNotNull(validated.getToken()); + } + + @Test + public void testUnsignedToken() throws IOException { + thrown.expectMessage("Invalid token for cellbase"); + String token = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImhnbWQiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJ2ZXJzaW9uIjoiMS4wIiwic3ViIjoiWkVUVEEiLCJpYXQiOjE2OTMyMTY5MDd9.invalidsignature"; + CellBaseConfiguration validated = CellBaseValidator.validate(new CellBaseConfiguration(ParamConstants.CELLBASE_URL, "v5.4", null, token), "hsapiens", "grch38", true); + Assert.assertNotNull(validated.getToken()); + } + } \ No newline at end of file diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java index 84ae7f75aae..cff66f13e62 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java @@ -28,7 +28,7 @@ public class RestApi { private List categories; public RestApi() { - this(GitRepositoryState.get().getBuildVersion(), GitRepositoryState.get().getCommitId(), new ArrayList<>()); + this(GitRepositoryState.getInstance().getBuildVersion(), GitRepositoryState.getInstance().getCommitId(), new ArrayList<>()); } public RestApi(String version, String commit, List categories) { diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java index 2ac80dfd288..72857bc2aec 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java @@ -218,6 +218,8 @@ protected static String getMethodName(String subpath) { // methodName = items[3] + "_" + items[1] + "_" + items[2]; } else if (items[0].contains("}") && items[2].contains("}") && (!items[1].contains("}")) && (!items[3].contains("}"))) { methodName = items[3] + "_" + items[1]; + } else if (items[1].contains("}") && (!items[0].contains("}") && !items[2].contains("}") && !items[3].contains("}"))) { + methodName = items[0] + "_" + items[3] + "_" + items[2]; } } else if (items.length == 5) { if (items[0].contains("}") && items[2].contains("}") && (!items[1].contains("}")) && (!items[3].contains("}")) diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java index e075e938983..528853faeb6 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java @@ -80,9 +80,9 @@ public MetaWSServer(@Context UriInfo uriInfo, @Context HttpServletRequest httpSe public Response getAbout() { Map info = new HashMap<>(5); info.put("Program", "OpenCGA (OpenCB)"); - info.put("Version", GitRepositoryState.get().getBuildVersion()); - info.put("Git branch", GitRepositoryState.get().getBranch()); - info.put("Git commit", GitRepositoryState.get().getCommitId()); + info.put("Version", GitRepositoryState.getInstance().getBuildVersion()); + info.put("Git branch", GitRepositoryState.getInstance().getBranch()); + info.put("Git commit", GitRepositoryState.getInstance().getCommitId()); info.put("Description", "Big Data platform for processing and analysing NGS data"); OpenCGAResult queryResult = new OpenCGAResult(); queryResult.setTime(0); diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java index d152cf17277..03a39102d9e 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java @@ -260,8 +260,8 @@ static void init(String opencgaHomeStr) { } logger.info("| OpenCGA REST successfully started!"); - logger.info("| - Version " + GitRepositoryState.get().getBuildVersion()); - logger.info("| - Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + logger.info("| - Version " + GitRepositoryState.getInstance().getBuildVersion()); + logger.info("| - Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); logger.info("========================================================================\n"); } @@ -428,8 +428,8 @@ private static void addErrorEvent(RestResponse response, Throwable e) { } public static void setFederationServer(OpenCGAResult result, String baseuri) { - result.setFederationNode(new FederationNode(baseuri, GitRepositoryState.get().getCommitId(), - GitRepositoryState.get().getBuildVersion())); + result.setFederationNode(new FederationNode(baseuri, GitRepositoryState.getInstance().getCommitId(), + GitRepositoryState.getInstance().getBuildVersion())); } public static void logResponse(Response.StatusType statusInfo, RestResponse queryResponse, long startTime, diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/admin/AdminWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/admin/AdminWSServer.java index f07c7ad3ecb..835c9632af1 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/admin/AdminWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/admin/AdminWSServer.java @@ -16,8 +16,6 @@ package org.opencb.opencga.server.rest.admin; -import org.opencb.opencga.core.models.user.AuthenticationResponse; -import org.opencb.opencga.core.tools.annotations.*; import org.apache.commons.lang3.StringUtils; import org.opencb.commons.datastore.core.DataResult; import org.opencb.commons.datastore.core.ObjectMap; @@ -31,6 +29,7 @@ import org.opencb.opencga.analysis.sample.SampleIndexTask; import org.opencb.opencga.catalog.db.api.MetaDBAdaptor; import org.opencb.opencga.catalog.exceptions.CatalogException; +import org.opencb.opencga.catalog.utils.ParamUtils; import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.exceptions.VersionException; import org.opencb.opencga.core.models.admin.*; @@ -39,8 +38,10 @@ import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.Group; import org.opencb.opencga.core.models.user.Account; +import org.opencb.opencga.core.models.user.AuthenticationResponse; import org.opencb.opencga.core.models.user.User; import org.opencb.opencga.core.response.OpenCGAResult; +import org.opencb.opencga.core.tools.annotations.*; import org.opencb.opencga.server.rest.OpenCGAWSServer; import javax.servlet.http.HttpServletRequest; @@ -153,6 +154,22 @@ public Response remoteImport(@ApiParam(value = "JSON containing the parameters", } } + @POST + @Path("/users/{user}/groups/update") + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Add or remove users from existing groups", response = Group.class) + public Response updateGroups( + @ApiParam(value = ParamConstants.USER_DESCRIPTION) @PathParam(ParamConstants.USER) String user, + @ApiParam(value = "Action to be performed: ADD or REMOVE user to/from groups", allowableValues = "ADD,REMOVE", + defaultValue = "ADD") @QueryParam("action") ParamUtils.AddRemoveAction action, + @ApiParam(value = "JSON containing the parameters", required = true) UserUpdateGroup updateParams) { + try { + return createOkResponse(catalogManager.getAdminManager().updateGroups(user, updateParams.getStudyIds(), updateParams.getGroupIds(), action, token)); + } catch (Exception e) { + return createErrorResponse(e); + } + } + @POST @Path("/users/sync") @ApiOperation(value = "Synchronise a group of users from an authentication origin with a group in a study from catalog", response = Group.class, diff --git a/opencga-server/src/main/resources/parserAbstractMethods.template b/opencga-server/src/main/resources/parserAbstractMethods.template index a06cc76c2f1..4d25b76e871 100644 --- a/opencga-server/src/main/resources/parserAbstractMethods.template +++ b/opencga-server/src/main/resources/parserAbstractMethods.template @@ -18,8 +18,8 @@ if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java index 85313d4e4c3..0825354d734 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java @@ -48,8 +48,8 @@ public static int privateMain(String[] args) { String parsedCommand = adminCliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (adminCliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); return 0; } else if (adminCliOptionsParser.getGeneralOptions().help) { adminCliOptionsParser.printUsage(); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java index 05da1e97637..9f7ec6fd321 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java @@ -48,9 +48,9 @@ public static int privateMain(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); -// System.out.println(GitRepositoryState.get()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); +// System.out.println(GitRepositoryState.getInstance()); return 0; } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java index 9c430b284c1..fb567276992 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java @@ -82,8 +82,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Storage (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-storage.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java index 7aedfbd4e85..86a4bcca419 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java @@ -76,8 +76,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Storage Admin (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-storage-admin.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java index 1ec92d91ea9..d2114731bc1 100644 --- a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java +++ b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java @@ -48,7 +48,7 @@ public VariantMetadata toVariantMetadata(VariantQueryProjection variantQueryProj // .setDate(Date.from(Instant.now()).toString()) .setCreationDate(TimeUtils.getTime()) .setStudies(studies) - .setVersion(GitRepositoryState.get().getDescribeShort()) + .setVersion(GitRepositoryState.getInstance().getDescribeShort()) .setSpecies(species) .build(); diff --git a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/variant/adaptors/VariantField.java b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/variant/adaptors/VariantField.java index d0eb0a335e6..8c208b1cd30 100644 --- a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/variant/adaptors/VariantField.java +++ b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/variant/adaptors/VariantField.java @@ -71,6 +71,7 @@ public enum VariantField { ANNOTATION_CONSERVATION(ANNOTATION, "annotation.conservation"), ANNOTATION_CANCER_HOTSPOTS(ANNOTATION, "annotation.cancerHotspots"), ANNOTATION_GENE_EXPRESSION(ANNOTATION, "annotation.geneExpression"), + ANNOTATION_PHARMACOGENOMICS(ANNOTATION, "annotation.pharmacogenomics"), ANNOTATION_GENE_TRAIT_ASSOCIATION(ANNOTATION, "annotation.geneTraitAssociation"), ANNOTATION_GENE_DRUG_INTERACTION(ANNOTATION, "annotation.geneDrugInteraction"), ANNOTATION_GENE_CANCER_ASSOCIATIONS(ANNOTATION, "annotation.geneCancerAssociations"), diff --git a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/utils/CellBaseUtilsTest.java b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/utils/CellBaseUtilsTest.java index ccb8106a2c0..1f679ace47e 100644 --- a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/utils/CellBaseUtilsTest.java +++ b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/utils/CellBaseUtilsTest.java @@ -67,7 +67,8 @@ public static List data() { new Object[]{"https://ws.zettagenomics.com/cellbase/", "v5.1", "grch38", "1"}, new Object[]{"https://ws.zettagenomics.com/cellbase/", "v5.1", "grch38", "2"}, new Object[]{"https://uk.ws.zettagenomics.com/cellbase/", "v5.2", "grch37", "1"}, - new Object[]{"https://uk.ws.zettagenomics.com/cellbase/", "v5.2", "grch38", "2"}); + new Object[]{"https://uk.ws.zettagenomics.com/cellbase/", "v5.2", "grch38", "2"}, + new Object[]{"https://uk.ws.zettagenomics.com/cellbase/", "v5.4", "grch38", "3"}); } @Parameter(0) diff --git a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/DummyTestAnnotator.java b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/DummyTestAnnotator.java index 33e2860868d..b36e8fa90ad 100644 --- a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/DummyTestAnnotator.java +++ b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/DummyTestAnnotator.java @@ -59,7 +59,7 @@ public List annotate(List variants) throws VariantAn public ProjectMetadata.VariantAnnotationMetadata getVariantAnnotationMetadata() throws VariantAnnotatorException { return new ProjectMetadata.VariantAnnotationMetadata(-1, null, null, new ProjectMetadata.VariantAnnotatorProgram("MyAnnotator", key, null), - Collections.singletonList(new ObjectMap("data", "genes")), null, null); + Collections.singletonList(new ObjectMap("data", "genes")), null,null); } } diff --git a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java index 122ef2da4af..031360d3298 100644 --- a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java +++ b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java @@ -63,7 +63,7 @@ protected void before() throws Throwable { Path rootDir = getTmpRootDir(); - String configSet = "opencga-variant-configset-" + GitRepositoryState.get().getBuildVersion(); + String configSet = "opencga-variant-configset-" + GitRepositoryState.getInstance().getBuildVersion(); // Copy configuration getResourceUri("configsets/variantsCollection/solrconfig.xml", "configsets/" + configSet + "/solrconfig.xml"); diff --git a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java index 7ba0a4faf85..ef8f97152ad 100644 --- a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java +++ b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java @@ -51,7 +51,7 @@ public MRExecutor init(ObjectMap options) { public static String getJarWithDependencies(ObjectMap options) throws StorageEngineException { String jar = options.getString(MR_JAR_WITH_DEPENDENCIES.key(), null); if (jar == null) { - jar = "opencga-storage-hadoop-core-" + GitRepositoryState.get().getBuildVersion() + "-jar-with-dependencies.jar"; + jar = "opencga-storage-hadoop-core-" + GitRepositoryState.getInstance().getBuildVersion() + "-jar-with-dependencies.jar"; // throw new StorageEngineException("Missing option " + MR_JAR_WITH_DEPENDENCIES); } if (!Paths.get(jar).isAbsolute()) { diff --git a/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java b/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java index efd41c2b319..256df4315ee 100644 --- a/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java +++ b/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java @@ -76,8 +76,8 @@ public static void printVersion() { private static Map getVersionMap() { Map versionMap = new HashMap<>(); - versionMap.put("OpenCGA Test version:", GitRepositoryState.get().getBuildVersion()); - versionMap.put("Git version:", "" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + versionMap.put("OpenCGA Test version:", GitRepositoryState.getInstance().getBuildVersion()); + versionMap.put("Git version:", "" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); versionMap.put("Program:", "OpenCGA-test (OpenCB)"); versionMap.put("Description:", "Data generation application for the openCGA platform"); return versionMap; diff --git a/pom.xml b/pom.xml index 6cdcc114b77..c0b9f02fd71 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 2.11.0-SNAPSHOT pom OpenCGA - OenCGA projects implements a big data platform for genomic data analysis + OpenCGA projects implements a big data platform for genomic data analysis http://docs.opencb.org/display/opencga/ @@ -42,12 +42,12 @@ - 2.8.3 - 2.8.3 - 5.4.0 - 2.8.0 - 4.8.0 - 2.8.3 + 2.11.0_dev + 2.11.0_dev + 5.7.0-SNAPSHOT + 2.11.0-SNAPSHOT + 4.11.0-SNAPSHOT + 2.11.0-SNAPSHOT 0.2.0