From fabcbaf5118643d710e92c9cfe50c715643f29ae Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 31 Mar 2023 09:41:44 +0200 Subject: [PATCH 1/6] created common module --- libs/dnet-exporter-model/mvnw | 233 ++++++++++++++++++++++++++++++ libs/dnet-exporter-model/mvnw.cmd | 145 +++++++++++++++++++ libs/dnet-exporter-model/pom.xml | 35 +++++ libs/pom.xml | 1 + 4 files changed, 414 insertions(+) create mode 100755 libs/dnet-exporter-model/mvnw create mode 100644 libs/dnet-exporter-model/mvnw.cmd create mode 100644 libs/dnet-exporter-model/pom.xml diff --git a/libs/dnet-exporter-model/mvnw b/libs/dnet-exporter-model/mvnw new file mode 100755 index 00000000..a1ba1bf5 --- /dev/null +++ b/libs/dnet-exporter-model/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/libs/dnet-exporter-model/mvnw.cmd b/libs/dnet-exporter-model/mvnw.cmd new file mode 100644 index 00000000..2b934e89 --- /dev/null +++ b/libs/dnet-exporter-model/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/libs/dnet-exporter-model/pom.xml b/libs/dnet-exporter-model/pom.xml new file mode 100644 index 00000000..17588ca1 --- /dev/null +++ b/libs/dnet-exporter-model/pom.xml @@ -0,0 +1,35 @@ + + + + + eu.dnetlib.dhp + libs + 3.3.4-SNAPSHOT + ../ + + + 4.0.0 + + dnet-exporter-model + jar + + dnet-exporter-model + Model classes for D-Net Exporter API + + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + diff --git a/libs/pom.xml b/libs/pom.xml index 1873ecbe..54599a55 100644 --- a/libs/pom.xml +++ b/libs/pom.xml @@ -14,6 +14,7 @@ dnet-apps-common + dnet-exporter-model dnet-openaire-broker-common dnet-broker-apps-common -- 2.17.1 From ecb5ffca5a7c4327f332bda404621e75ba0ccfb0 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 31 Mar 2023 14:53:52 +0200 Subject: [PATCH 2/6] moved some classes into the model module --- apps/dnet-exporter-api/pom.xml | 10 +- .../common/AbstractExporterController.java | 8 +- .../eu/dnetlib/openaire/common/ISClient.java | 4 +- .../dnetlib/openaire/common/ISClientImpl.java | 57 ++++---- .../community/CommunityApiController.java | 13 +- .../openaire/community/CommunityApiCore.java | 14 +- .../openaire/community/CommunityClient.java | 3 + .../community/CommunityClientImpl.java | 5 + .../openaire/community/CommunityCommon.java | 20 ++- .../community/CommunityMappingUtils.java | 17 ++- .../context/ContextApiController.java | 4 + .../openaire/context/ContextApiCore.java | 7 + .../openaire/context/ContextMappingUtils.java | 6 +- .../openaire/dsm/DsmApiController.java | 10 +- .../openaire/dsm/DsmApiControllerV2.java | 4 +- .../java/eu/dnetlib/openaire/dsm/DsmCore.java | 10 +- .../openaire/dsm/dao/DatasourceDao.java | 6 +- .../openaire/dsm/dao/DatasourceDaoImpl.java | 10 +- .../dsm/dao/DatasourceIndexClient.java | 4 +- .../dsm/dao/DatasourceIndexClientImpl.java | 122 ++++++++++-------- .../openaire/dsm/dao/DatasourceSpecs.java | 2 +- .../openaire/dsm/dao/MongoLoggerClient.java | 3 +- .../dsm/dao/MongoLoggerClientImpl.java | 2 +- .../openaire/dsm/dao/ObjectStoreClient.java | 2 +- .../dsm/dao/ObjectStoreClientImpl.java | 13 +- .../openaire/dsm/dao/ResponseUtils.java | 4 +- .../openaire/dsm/dao/VocabularyClient.java | 3 +- .../dsm/dao/VocabularyClientImpl.java | 3 +- .../domain/AggregationHistoryResponseV1.java | 2 + .../domain/AggregationHistoryResponseV2.java | 1 + .../dsm/domain/ApiDetailsResponse.java | 1 + .../dsm/domain/DatasourceDetailResponse.java | 2 + .../dsm/domain/DatasourceResponse.java | 2 + .../dsm/domain/DatasourceSearchResponse.java | 2 + .../dsm/domain/DatasourceSnippetResponse.java | 2 + .../funders/{domain => }/ConversionUtils.java | 5 +- .../dnetlib/openaire/funders/FunderDao.java | 6 +- .../funders/FundersApiController.java | 5 +- .../community/CommunityApiControllerTest.java | 2 + .../SelectionCriteriaTest.java | 4 + .../context/ContextMappingUtilsTest.java | 2 + .../dsm/DatasourceApiControllerTest.java | 2 +- .../funders/FunderContextClientTest.java | 4 +- libs/dnet-exporter-model/TODO.txt | 16 +++ libs/dnet-exporter-model/pom.xml | 6 + .../exceptions}/CommunityException.java | 8 +- .../CommunityNotFoundException.java | 8 +- .../exceptions}/ContextException.java | 8 +- .../exceptions}/ContextNotFoundException.java | 8 +- .../exporter/exceptions/DsmException.java | 36 ++++++ .../exceptions/DsmForbiddenException.java | 23 ++++ .../exceptions/DsmNotFoundException.java | 23 ++++ .../exceptions/DsmRuntimeException.java | 23 ++++ .../exceptions}/FundersApiException.java | 2 +- .../community/CommunityContentprovider.java | 13 +- .../model}/community/CommunityDetails.java | 11 +- .../CommunityOpenAIRECommunities.java | 2 +- .../community/CommunityOrganization.java | 2 +- .../model}/community/CommunityProject.java | 2 +- .../model}/community/CommunityStatus.java | 2 +- .../model}/community/CommunitySummary.java | 2 +- .../CommunityWritableProperties.java | 13 +- .../community/CommunityZenodoCommunity.java | 2 +- .../selectioncriteria/Constraint.java | 2 +- .../selectioncriteria/Constraints.java | 2 +- .../selectioncriteria/SelectionCriteria.java | 13 +- .../exporter/model}/context/Category.java | 2 +- .../model}/context/CategorySummary.java | 2 +- .../exporter/model}/context/Concept.java | 2 +- .../model}/context/ConceptSummary.java | 2 +- .../exporter/model}/context/Context.java | 9 +- .../model}/context/ContextSummary.java | 2 +- .../exporter/model}/context/Param.java | 2 +- .../openaire/exporter/model/dsm}/Header.java | 22 ++-- .../exporter/model/dsm}/Response.java | 2 +- .../exporter/model/dsm}/SimpleResponse.java | 2 +- .../model/funders}/ExtendedFunderDetails.java | 3 +- .../model/funders}/FunderDetails.java | 2 +- .../model/funders}/FundingStream.java | 2 +- .../exporter/model}/vocabularies/Country.java | 2 +- .../exporter/model}/vocabularies/Term.java | 2 +- .../model}/vocabularies/Vocabulary.java | 2 +- 82 files changed, 447 insertions(+), 248 deletions(-) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/{domain => }/ConversionUtils.java (91%) create mode 100644 libs/dnet-exporter-model/TODO.txt rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions}/CommunityException.java (52%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions}/CommunityNotFoundException.java (52%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions}/ContextException.java (51%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions}/ContextNotFoundException.java (51%) create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions}/FundersApiException.java (89%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityContentprovider.java (84%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityDetails.java (84%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityOpenAIRECommunities.java (95%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityOrganization.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityProject.java (97%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityStatus.java (87%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunitySummary.java (98%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityWritableProperties.java (90%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/CommunityZenodoCommunity.java (94%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/selectioncriteria/Constraint.java (90%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/selectioncriteria/Constraints.java (87%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/community/selectioncriteria/SelectionCriteria.java (62%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/Category.java (95%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/CategorySummary.java (91%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/Concept.java (95%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/ConceptSummary.java (94%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/Context.java (92%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/ContextSummary.java (92%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/context/Param.java (86%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/Header.java (77%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/Response.java (90%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/SimpleResponse.java (87%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders}/ExtendedFunderDetails.java (93%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders}/FunderDetails.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders}/FundingStream.java (86%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/vocabularies/Country.java (89%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/vocabularies/Term.java (87%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model}/vocabularies/Vocabulary.java (94%) diff --git a/apps/dnet-exporter-api/pom.xml b/apps/dnet-exporter-api/pom.xml index b4fa6397..b365bded 100644 --- a/apps/dnet-exporter-api/pom.xml +++ b/apps/dnet-exporter-api/pom.xml @@ -26,6 +26,11 @@ org.springframework.boot spring-boot-starter-cache + + eu.dnetlib.dhp + dnet-exporter-model + ${project.version} + eu.dnetlib cnr-rmi-api @@ -120,12 +125,13 @@ 3.4.2 - + + org.springframework.boot spring-boot-starter-test diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java index 711b7eb2..026fbe4f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java @@ -16,10 +16,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.enabling.datasources.common.DsmForbiddenException; -import eu.dnetlib.enabling.datasources.common.DsmNotFoundException; -import eu.dnetlib.openaire.dsm.domain.Response; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; +import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.Response; /** * Created by claudio on 18/07/2017. diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java index d4ed2f32..3ed78e44 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java @@ -4,9 +4,9 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.openaire.context.Context; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.context.Context; public interface ISClient { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java index 67397331..4a0c628a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java @@ -28,13 +28,13 @@ import com.google.common.escape.Escaper; import com.google.common.xml.XmlEscapers; import eu.dnetlib.DnetOpenaireExporterProperties; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.enabling.datasources.common.DsmRuntimeException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; -import eu.dnetlib.openaire.context.Context; import eu.dnetlib.openaire.context.ContextMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException; +import eu.dnetlib.openaire.exporter.model.context.Context; /** * Created by claudio on 20/10/2016. @@ -105,35 +105,34 @@ public class ISClientImpl implements ISClient { } } - @Override @CacheEvict(value = { "context-cache", "context-cache-funder" }, allEntries = true) - public void updateContextParam(final String id, final String name, final String value, boolean toEscape) { - if(getSize(id, name) > 0){ + public void updateContextParam(final String id, final String name, final String value, final boolean toEscape) { + if (getSize(id, name) > 0) { try { _quickSeachProfile(getXQuery(id, name, value, toEscape)); } catch (final ISLookUpException e) { throw new DsmRuntimeException(String.format("unable to update context param [id: %s, name: %s, value: %s]", id, name, value), e); } - } - else{ + } else { try { - _quickSeachProfile(getInsertXQuery(id, name, value,toEscape)); + _quickSeachProfile(getInsertXQuery(id, name, value, toEscape)); } catch (final ISLookUpException e) { throw new DsmRuntimeException(String.format("unable to insert context param [id: %s, name: %s, value: %s]", id, name, value), e); } } - } - private int getSize(String id, String name) { + private int getSize(final String id, final String name) { int size = 0; try { - size = _quickSeachProfile(String.format("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') where $x//context[@id='%s']/param[@name='%s'] return $x", id, name)).size(); - } catch (ISLookUpException e) { + size = _quickSeachProfile(String + .format("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') where $x//context[@id='%s']/param[@name='%s'] return $x", id, name)) + .size(); + } catch (final ISLookUpException e) { throw new DsmRuntimeException("unable to execute search query", e); } return size; @@ -222,26 +221,27 @@ public class ISClientImpl implements ISClient { /// HELPERS - private String getInsertXQuery(final String id, final String paramName, final String paramValue, final boolean toEscape) { String value; - if(toEscape) + if (toEscape) { value = escape(XmlEscapers.xmlContentEscaper(), paramValue); - else + } else { value = paramValue; + } if (StringUtils.isNotBlank(value)) { return String.format("update insert %s into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + - "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, value, id); + "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, value, id); } else { return String.format("update insert into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + - "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, id); + "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, id); } } private String getXQuery(final String id, final String name, final String paramValue, final boolean toEscape) { String value = paramValue; - if (toEscape) + if (toEscape) { value = escape(XmlEscapers.xmlContentEscaper(), paramValue); + } if (StringUtils.isNotBlank(value)) { return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + @@ -252,15 +252,16 @@ public class ISClientImpl implements ISClient { } } -// private String getXQueryNoEscape(final String id, final String name, final String value) { -// if (StringUtils.isNotBlank(value)) { -// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + -// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with %s", id, name, name, value); -// } else { -// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + -// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with ", id, name, name); -// } -// } + // private String getXQueryNoEscape(final String id, final String name, final String value) { + // if (StringUtils.isNotBlank(value)) { + // return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + + // "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with %s", id, name, name, + // value); + // } else { + // return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" + + // "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with ", id, name, name); + // } + // } private String getConceptXQuery(final String id, final String name, final String value) { final Escaper esc = XmlEscapers.xmlContentEscaper(); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java index c5207180..1a9782d9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java @@ -10,7 +10,18 @@ import static eu.dnetlib.openaire.common.ExporterConstants.W; import java.util.List; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.web.bind.annotation.CrossOrigin; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java index 09cb2a28..3b855352 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java @@ -4,7 +4,19 @@ import java.util.*; import java.util.stream.Collectors; import com.google.gson.Gson; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; + +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java index dbc18fc5..f0aae66c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java @@ -3,6 +3,9 @@ package eu.dnetlib.openaire.community; import java.util.Map; import java.util.Set; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException; + public interface CommunityClient { Map> getInverseZenodoCommunityMap() throws CommunityException, CommunityNotFoundException; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java index 96ac59a6..b2ff7b78 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java @@ -8,6 +8,11 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; + import java.util.*; @Component diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java index d23bc881..96613c42 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java @@ -4,11 +4,21 @@ import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.gson.Gson; import eu.dnetlib.openaire.common.ISClient; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; -import eu.dnetlib.openaire.context.Category; -import eu.dnetlib.openaire.context.Concept; -import eu.dnetlib.openaire.context.Context; -import eu.dnetlib.openaire.context.Param; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.model.context.Category; +import eu.dnetlib.openaire.exporter.model.context.Concept; +import eu.dnetlib.openaire.exporter.model.context.Context; +import eu.dnetlib.openaire.exporter.model.context.Param; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java index 073f3b1c..b5d9cae9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java @@ -7,10 +7,19 @@ import java.util.stream.Stream; import com.google.common.escape.Escaper; import com.google.common.xml.XmlEscapers; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; -import eu.dnetlib.openaire.context.Concept; -import eu.dnetlib.openaire.context.Context; -import eu.dnetlib.openaire.context.Param; + +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunityStatus; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.model.context.Concept; +import eu.dnetlib.openaire.exporter.model.context.Context; +import eu.dnetlib.openaire.exporter.model.context.Param; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiController.java index 98fdb46b..f8fcc9e9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiController.java @@ -12,6 +12,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import eu.dnetlib.openaire.exporter.exceptions.ContextException; +import eu.dnetlib.openaire.exporter.model.context.CategorySummary; +import eu.dnetlib.openaire.exporter.model.context.ConceptSummary; +import eu.dnetlib.openaire.exporter.model.context.ContextSummary; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiCore.java index 9cd2e859..f33712c8 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextApiCore.java @@ -15,6 +15,13 @@ import com.google.common.base.Splitter; import com.google.common.collect.Lists; import eu.dnetlib.openaire.common.ISClient; +import eu.dnetlib.openaire.exporter.exceptions.ContextException; +import eu.dnetlib.openaire.exporter.model.context.Category; +import eu.dnetlib.openaire.exporter.model.context.CategorySummary; +import eu.dnetlib.openaire.exporter.model.context.Concept; +import eu.dnetlib.openaire.exporter.model.context.ConceptSummary; +import eu.dnetlib.openaire.exporter.model.context.Context; +import eu.dnetlib.openaire.exporter.model.context.ContextSummary; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.context", havingValue = "true") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextMappingUtils.java index c3537343..e7311c2a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextMappingUtils.java @@ -20,7 +20,11 @@ import org.dom4j.Node; import com.google.common.base.Functions; import com.google.common.collect.Lists; -import eu.dnetlib.openaire.funders.domain.FunderDetails; +import eu.dnetlib.openaire.exporter.model.context.Category; +import eu.dnetlib.openaire.exporter.model.context.Concept; +import eu.dnetlib.openaire.exporter.model.context.Context; +import eu.dnetlib.openaire.exporter.model.context.Param; +import eu.dnetlib.openaire.exporter.model.funders.FunderDetails; public class ContextMappingUtils { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java index b93ea3ad..d08d2350 100755 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java @@ -24,9 +24,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.enabling.datasources.common.DsmForbiddenException; -import eu.dnetlib.enabling.datasources.common.DsmNotFoundException; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.OperationManager; import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV1; @@ -41,8 +38,11 @@ import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; -import eu.dnetlib.openaire.dsm.domain.SimpleResponse; -import eu.dnetlib.openaire.vocabularies.Country; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; +import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; +import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java index a612c043..70977f45 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java @@ -15,12 +15,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV2; import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.SimpleResponse; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java index 806de5d5..2cad2a0f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java @@ -30,9 +30,6 @@ import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; import eu.dnetlib.enabling.datasources.common.AggregationInfo; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.enabling.datasources.common.DsmForbiddenException; -import eu.dnetlib.enabling.datasources.common.DsmNotFoundException; import eu.dnetlib.openaire.common.ISClient; import eu.dnetlib.openaire.community.CommunityClient; import eu.dnetlib.openaire.dsm.dao.DatasourceDao; @@ -55,11 +52,14 @@ import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.SimpleResponse; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry; -import eu.dnetlib.openaire.vocabularies.Country; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; +import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; +import eu.dnetlib.openaire.exporter.model.vocabularies.Country; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java index 5f40524d..b126bf13 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java @@ -5,13 +5,11 @@ import java.util.List; import org.springframework.data.domain.Page; import eu.dnetlib.enabling.datasources.common.Api; -import eu.dnetlib.enabling.datasources.common.Datasource; -import eu.dnetlib.enabling.datasources.common.DatasourceManagerCommon; -import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; -import eu.dnetlib.openaire.vocabularies.Country; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.vocabularies.Country; public interface DatasourceDao, API extends Api> extends DatasourceManagerCommon { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java index 0f9cf5aa..7372d10e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java @@ -30,9 +30,6 @@ import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; import eu.dnetlib.DnetOpenaireExporterProperties; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.enabling.datasources.common.DsmForbiddenException; -import eu.dnetlib.enabling.datasources.common.DsmNotFoundException; import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; @@ -40,8 +37,11 @@ import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.ApiParamDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; -import eu.dnetlib.openaire.vocabularies.Country; -import eu.dnetlib.openaire.vocabularies.Vocabulary; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; +import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.vocabularies.Country; +import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; /** * Created by claudio on 20/10/2016. diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClient.java index 79d8e5e8..fd16995a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClient.java @@ -2,9 +2,9 @@ package eu.dnetlib.openaire.dsm.dao; import java.util.Queue; -import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; public interface DatasourceIndexClient { @@ -12,6 +12,4 @@ public interface DatasourceIndexClient { String getLastIndexingDate(final IndexDsInfo info) throws DsmException; - - } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java index 659c67a0..01cc9245 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java @@ -5,19 +5,15 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Queue; -import java.util.concurrent.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.*; -import eu.dnetlib.DnetOpenaireExporterProperties; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.miscutils.functional.hash.Hashing; -import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; -import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.logging.Log; @@ -33,6 +29,21 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import eu.dnetlib.DnetOpenaireExporterProperties; +import eu.dnetlib.miscutils.functional.hash.Hashing; +import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; +import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; +import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; + /** * Created by claudio on 20/10/2016. */ @@ -54,9 +65,8 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { @PostConstruct public void init() { - executor = MoreExecutors.listeningDecorator( - new ScheduledThreadPoolExecutor(5, - new ThreadFactoryBuilder().setNameFormat("datasource-index-client-%d").build())); + executor = MoreExecutors.listeningDecorator(new ScheduledThreadPoolExecutor(5, + new ThreadFactoryBuilder().setNameFormat("datasource-index-client-%d").build())); } @PreDestroy @@ -64,7 +74,7 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { indexClientMap.forEach((name, client) -> { try { client.close(); - } catch (IOException e) { + } catch (final IOException e) { log.warn(String.format("unable to gracefully shutdown client for index %s", name)); } }); @@ -78,41 +88,37 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { final CountDownLatch latch = new CountDownLatch(2); final IndexRecordsInfo indexRecordInfo = new IndexRecordsInfo(); - Futures.addCallback( - executor.submit(() -> setDateAndTotal(dsId, collectedFrom, indexClient)), - new FutureCallback() { + Futures.addCallback(executor.submit(() -> setDateAndTotal(dsId, collectedFrom, indexClient)), new FutureCallback() { - @Override - public void onSuccess(final IndexRecordsInfo info) { - indexRecordInfo - .setTotal(info.getTotal()) - .setDate(info.getDate()); - latch.countDown(); - } + @Override + public void onSuccess(final IndexRecordsInfo info) { + indexRecordInfo + .setTotal(info.getTotal()) + .setDate(info.getDate()); + latch.countDown(); + } - @Override - public void onFailure(final Throwable e) { - errors.offer(e); - latch.countDown(); - } - }, executor); + @Override + public void onFailure(final Throwable e) { + errors.offer(e); + latch.countDown(); + } + }, executor); - Futures.addCallback( - executor.submit(() -> setFunded(dsId, collectedFrom, indexClient)), - new FutureCallback() { + Futures.addCallback(executor.submit(() -> setFunded(dsId, collectedFrom, indexClient)), new FutureCallback() { - @Override - public void onSuccess(final Long numFound) { - indexRecordInfo.setFunded(numFound); - latch.countDown(); - } + @Override + public void onSuccess(final Long numFound) { + indexRecordInfo.setFunded(numFound); + latch.countDown(); + } - @Override - public void onFailure(final Throwable e) { - errors.offer(e); - latch.countDown(); - } - }, executor); + @Override + public void onFailure(final Throwable e) { + errors.offer(e); + latch.countDown(); + } + }, executor); waitLatch(latch, errors, config.getRequestTimeout()); return indexRecordInfo; @@ -135,23 +141,23 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { } private Long setFunded( - final String dsId, - final String collectedFrom, - final CloudSolrClient indexClient) throws DsmException { + final String dsId, + final String collectedFrom, + final CloudSolrClient indexClient) throws DsmException { final String query = - String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\" AND relprojectid:*", collectedFrom); + String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\" AND relprojectid:*", collectedFrom); log.debug(String.format("query: %s", query)); try { return indexClient.query(new SolrQuery(query).setRows(0)).getResults().getNumFound(); - } catch (Throwable e) { + } catch (final Throwable e) { throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("Error querying index for funded results '%s'", dsId), e); } } private IndexRecordsInfo setDateAndTotal( - final String dsId, - final String collectedFrom, - final CloudSolrClient indexClient) throws DsmException { + final String dsId, + final String collectedFrom, + final CloudSolrClient indexClient) throws DsmException { try { final String query = String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\"", collectedFrom); log.debug(String.format("query: %s", query)); @@ -166,9 +172,9 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { // query: %s", queryTotal)); // } return new IndexRecordsInfo() - .setDate(getDate(doc)) - .setTotal(rsp.getResults().getNumFound()); - } catch (Throwable e) { + .setDate(getDate(doc)) + .setTotal(rsp.getResults().getNumFound()); + } catch (final Throwable e) { throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("Error querying index for date and total '%s'", dsId), e); } } @@ -176,8 +182,10 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { @SuppressWarnings("unchecked") private String getDate(final SolrDocument doc) throws DsmException { final List dsversion = (List) doc.get(DSVERSION); - if (dsversion == null || dsversion.isEmpty()) { throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), - String.format("cannot find %s in matched solr document", DSVERSION)); } + if (dsversion == null || dsversion.isEmpty()) { + throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), + String.format("cannot find %s in matched solr document", DSVERSION)); + } final Date date = Iterables.getLast(dsversion); return DateFormatUtils.format(date, DsmMappingUtils.DATE_FORMAT); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java index ba110c16..8e22477c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java @@ -16,13 +16,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.data.jpa.domain.Specification; -import eu.dnetlib.enabling.datasources.common.DsmRuntimeException; import eu.dnetlib.openaire.dsm.domain.FilterName; import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; +import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException; public class DatasourceSpecs { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java index b68a9689..0a141057 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java @@ -2,9 +2,8 @@ package eu.dnetlib.openaire.dsm.dao; import java.util.List; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; -import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; public interface MongoLoggerClient { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java index caf6b62d..48346f15 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java @@ -43,7 +43,6 @@ import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties.Datasource; import eu.dnetlib.enabling.datasources.common.AggregationInfo; import eu.dnetlib.enabling.datasources.common.AggregationStage; -import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.miscutils.datetime.DateUtils; import eu.dnetlib.openaire.common.Utils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; @@ -53,6 +52,7 @@ import eu.dnetlib.openaire.dsm.domain.CollectionInfoV2; import eu.dnetlib.openaire.dsm.domain.CollectionMode; import eu.dnetlib.openaire.dsm.domain.TransformationInfoV1; import eu.dnetlib.openaire.dsm.domain.TransformationInfoV2; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.info.JdbcInfoDao; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java index 131fa713..76f11741 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java @@ -1,6 +1,6 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.enabling.datasources.common.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; public interface ObjectStoreClient { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java index 78763134..d3f77dca 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java @@ -1,8 +1,5 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; -import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; -import eu.dnetlib.enabling.datasources.common.DsmException; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -10,6 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; +import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; +import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; + @Component @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") public class ObjectStoreClientImpl implements ObjectStoreClient { @@ -22,14 +23,12 @@ public class ObjectStoreClientImpl implements ObjectStoreClient { @Override public Long getObjectStoreSize(final String objectStoreId) throws DsmException { log.debug("get size for objectStore " + objectStoreId); - if (StringUtils.isBlank(objectStoreId)) { - return 0L; - } + if (StringUtils.isBlank(objectStoreId)) { return 0L; } try { final long size = objectStoreService.getSize(objectStoreId); log.debug("got objectStore size: " + size); return size; - } catch (ObjectStoreServiceException e) { + } catch (final ObjectStoreServiceException e) { throw new DsmException("unable to get size for objectStore " + objectStoreId); } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java index cdc4c581..941ee574 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java @@ -13,8 +13,8 @@ import eu.dnetlib.openaire.dsm.domain.DatasourceInfo; import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; -import eu.dnetlib.openaire.dsm.domain.Header; -import eu.dnetlib.openaire.dsm.domain.SimpleResponse; +import eu.dnetlib.openaire.exporter.model.dsm.Header; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; public class ResponseUtils { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java index 2ed99c55..c6ffe096 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java @@ -1,7 +1,6 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.openaire.vocabularies.Vocabulary; +import eu.dnetlib.openaire.exporter.exceptions.DsmException; public interface VocabularyClient { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java index 3a9ad1b8..fe2acfc8 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java @@ -2,7 +2,8 @@ package eu.dnetlib.openaire.dsm.dao; import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.openaire.vocabularies.Vocabulary; +import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java index 9bc9e70d..6ab84899 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java @@ -4,6 +4,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.Response; + @JsonAutoDetect @Deprecated public class AggregationHistoryResponseV1 extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java index e68eddc2..b13e35a4 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java @@ -5,6 +5,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; import eu.dnetlib.enabling.datasources.common.AggregationInfo; +import eu.dnetlib.openaire.exporter.model.dsm.Response; @JsonAutoDetect public class AggregationHistoryResponseV2 extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java index cecb20c1..b65f6e42 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java @@ -4,6 +4,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.Response; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java index e59cb037..b011d889 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java @@ -4,6 +4,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.Response; + @JsonAutoDetect public class DatasourceDetailResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceResponse.java index 9aba8b8a..255e89b4 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceResponse.java @@ -5,6 +5,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.google.common.collect.Lists; +import eu.dnetlib.openaire.exporter.model.dsm.Response; + @JsonAutoDetect public class DatasourceResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java index 2be76532..e8d3aacb 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java @@ -4,6 +4,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.Response; + @JsonAutoDetect public class DatasourceSearchResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java index 522d5653..ba84462b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java @@ -4,6 +4,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.Response; + @JsonAutoDetect public class DatasourceSnippetResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ConversionUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/ConversionUtils.java similarity index 91% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ConversionUtils.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/ConversionUtils.java index 75aae566..be41be45 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ConversionUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/ConversionUtils.java @@ -1,8 +1,11 @@ -package eu.dnetlib.openaire.funders.domain; +package eu.dnetlib.openaire.funders; import java.io.StringReader; import java.util.stream.Collectors; +import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails; +import eu.dnetlib.openaire.exporter.model.funders.FunderDetails; +import eu.dnetlib.openaire.exporter.model.funders.FundingStream; import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry; import eu.dnetlib.openaire.funders.domain.db.FundingPathDbEntry; import org.dom4j.Document; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FunderDao.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FunderDao.java index 7c53b2c3..9c79afc5 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FunderDao.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FunderDao.java @@ -8,9 +8,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Component; -import eu.dnetlib.openaire.funders.domain.ConversionUtils; -import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails; -import eu.dnetlib.openaire.funders.domain.FunderDetails; +import eu.dnetlib.openaire.exporter.exceptions.FundersApiException; +import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails; +import eu.dnetlib.openaire.exporter.model.funders.FunderDetails; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiController.java index f4e598b3..d1533826 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiController.java @@ -13,8 +13,9 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; -import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails; -import eu.dnetlib.openaire.funders.domain.FunderDetails; +import eu.dnetlib.openaire.exporter.exceptions.FundersApiException; +import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails; +import eu.dnetlib.openaire.exporter.model.funders.FunderDetails; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/CommunityApiControllerTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/CommunityApiControllerTest.java index 43974fd9..94d9ee7f 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/CommunityApiControllerTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/CommunityApiControllerTest.java @@ -19,6 +19,8 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; + /** * Created by Alessia Bardi on 2019-04-04. * diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteriaTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteriaTest.java index 0d9420ff..c034a636 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteriaTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteriaTest.java @@ -2,6 +2,10 @@ package eu.dnetlib.openaire.community.selectioncriteria; import com.google.gson.Gson; import eu.dnetlib.data.bulktag.selectioncriteria.Selection; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.Constraint; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.Constraints; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; + import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/context/ContextMappingUtilsTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/context/ContextMappingUtilsTest.java index 3a30f10f..7ff98dec 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/context/ContextMappingUtilsTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/context/ContextMappingUtilsTest.java @@ -13,6 +13,8 @@ import org.junit.jupiter.api.Test; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import eu.dnetlib.openaire.exporter.model.context.Context; + /** * Created by Alessia Bardi on 2019-04-04. * diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java index 39a6875d..80cfe152 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java @@ -23,7 +23,7 @@ import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; -import eu.dnetlib.openaire.vocabularies.Country; +import eu.dnetlib.openaire.exporter.model.vocabularies.Country; @SpringBootTest @WebMvcTest(DsmApiController.class) diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/funders/FunderContextClientTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/funders/FunderContextClientTest.java index 3e0ca5af..8869dba4 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/funders/FunderContextClientTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/funders/FunderContextClientTest.java @@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import eu.dnetlib.openaire.context.Context; import eu.dnetlib.openaire.context.ContextMappingUtils; -import eu.dnetlib.openaire.funders.domain.FunderDetails; +import eu.dnetlib.openaire.exporter.model.context.Context; +import eu.dnetlib.openaire.exporter.model.funders.FunderDetails; public class FunderContextClientTest { diff --git a/libs/dnet-exporter-model/TODO.txt b/libs/dnet-exporter-model/TODO.txt new file mode 100644 index 00000000..c5253ee8 --- /dev/null +++ b/libs/dnet-exporter-model/TODO.txt @@ -0,0 +1,16 @@ + +DsmApiControllerV2 + SimpleDatasourceInfo + AggregationHistoryResponseV2 + +DsmApiController + DatasourceDetailResponse + AggregationHistoryResponseV1 + DatasourceSnippetResponse + RegisteredDatasourceInfo + ApiDetailsResponse + DatasourceDetails + DatasourceDetailsWithApis + DatasourceDetailsUpdate + ApiDetails + RequestFilter diff --git a/libs/dnet-exporter-model/pom.xml b/libs/dnet-exporter-model/pom.xml index 17588ca1..dc5e670b 100644 --- a/libs/dnet-exporter-model/pom.xml +++ b/libs/dnet-exporter-model/pom.xml @@ -23,6 +23,12 @@ mockito-junit-jupiter test + + + org.springdoc + springdoc-openapi-common + 1.6.10 + org.springframework.boot diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityException.java similarity index 52% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityException.java index db2cc2bd..d9dd0592 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityException.java @@ -1,13 +1,7 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.exceptions; import java.io.IOException; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseBody -@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) public class CommunityException extends Exception { /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityNotFoundException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityNotFoundException.java similarity index 52% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityNotFoundException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityNotFoundException.java index 53eb016b..5f75fe14 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityNotFoundException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/CommunityNotFoundException.java @@ -1,11 +1,5 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.exceptions; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseBody -@ResponseStatus(value = HttpStatus.NOT_FOUND) public class CommunityNotFoundException extends Exception { /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextException.java similarity index 51% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextException.java index 7d092b96..49794b93 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextException.java @@ -1,13 +1,7 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.exceptions; import java.io.IOException; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseBody -@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) public class ContextException extends Exception { /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextNotFoundException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextNotFoundException.java similarity index 51% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextNotFoundException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextNotFoundException.java index ba87774c..06222c1f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextNotFoundException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/ContextNotFoundException.java @@ -1,11 +1,5 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.exceptions; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseBody -@ResponseStatus(value = HttpStatus.NOT_FOUND) public class ContextNotFoundException extends Exception { /** diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java new file mode 100644 index 00000000..0ac3608b --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java @@ -0,0 +1,36 @@ +package eu.dnetlib.openaire.exporter.exceptions; + +public class DsmException extends Exception { + + private static final long serialVersionUID = -8173126561260106405L; + + private int code; + + public DsmException(final int code, final String msg) { + super(msg); + this.code = code; + } + + public DsmException(final int code, final Throwable e) { + super(e); + this.code = code; + } + + public DsmException(final int code, final String msg, final Throwable e) { + super(msg, e); + this.code = code; + } + + public DsmException(final String msg) { + this(500, msg); + } + + public int getCode() { + return code; + } + + public void setCode(final int code) { + this.code = code; + } + +} diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java new file mode 100644 index 00000000..03a436aa --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java @@ -0,0 +1,23 @@ +package eu.dnetlib.openaire.exporter.exceptions; + +public class DsmForbiddenException extends DsmException { + + private static final long serialVersionUID = -6538032715005339181L; + + public DsmForbiddenException(final int code, final String msg) { + super(code, msg); + } + + public DsmForbiddenException(final int code, final Throwable e) { + super(code, e); + } + + public DsmForbiddenException(final int code, final String msg, final Throwable e) { + super(code, msg, e); + } + + public DsmForbiddenException(final String msg) { + this(403, msg); + } + +} diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java new file mode 100644 index 00000000..d9f01052 --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java @@ -0,0 +1,23 @@ +package eu.dnetlib.openaire.exporter.exceptions; + +public class DsmNotFoundException extends DsmException { + + private static final long serialVersionUID = 1327980530652540728L; + + public DsmNotFoundException(final int code, final String msg) { + super(code, msg); + } + + public DsmNotFoundException(final int code, final Throwable e) { + super(code, e); + } + + public DsmNotFoundException(final int code, final String msg, final Throwable e) { + super(code, msg, e); + } + + public DsmNotFoundException(final String msg) { + this(404, msg); + } + +} diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java new file mode 100644 index 00000000..e12894fe --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java @@ -0,0 +1,23 @@ +package eu.dnetlib.openaire.exporter.exceptions; + +public class DsmRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 6755159618210324144L; + + public DsmRuntimeException() { + super(); + } + + public DsmRuntimeException(final String message, final Throwable cause) { + super(message, cause); + } + + public DsmRuntimeException(final String message) { + super(message); + } + + public DsmRuntimeException(final Throwable cause) { + super(cause); + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/FundersApiException.java similarity index 89% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/FundersApiException.java index c8f2f024..e5e84260 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/FundersApiException.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.funders; +package eu.dnetlib.openaire.exporter.exceptions; public class FundersApiException extends Exception { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityContentprovider.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityContentprovider.java similarity index 84% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityContentprovider.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityContentprovider.java index f17df06f..f550d544 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityContentprovider.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityContentprovider.java @@ -1,11 +1,12 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import javax.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.google.gson.Gson; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; import io.swagger.v3.oas.annotations.media.Schema; @JsonAutoDetect @@ -90,7 +91,11 @@ public class CommunityContentprovider { public String toJson() { if (selectioncriteria == null) { return ""; } - return new Gson().toJson(selectioncriteria); + try { + return new ObjectMapper().writeValueAsString(selectioncriteria); + } catch (final JsonProcessingException e) { + throw new RuntimeException(e); + } } public String toXML() { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityDetails.java similarity index 84% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityDetails.java index 7625582a..40f6c8b9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityDetails.java @@ -1,11 +1,11 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; import io.swagger.v3.oas.annotations.media.Schema; @JsonAutoDetect @@ -29,7 +29,6 @@ public class CommunityDetails extends CommunitySummary { @Schema(description = "list of advanced criteria to associate results to this community") private SelectionCriteria advancedConstraint; - public CommunityDetails() {} public CommunityDetails(final CommunitySummary summary) { @@ -68,7 +67,7 @@ public class CommunityDetails extends CommunitySummary { return fos; } - public void setFos(List fos) { + public void setFos(final List fos) { this.fos = fos; } @@ -76,7 +75,7 @@ public class CommunityDetails extends CommunitySummary { return sdg; } - public void setSdg(List sdg) { + public void setSdg(final List sdg) { this.sdg = sdg; } @@ -84,7 +83,7 @@ public class CommunityDetails extends CommunitySummary { return advancedConstraint; } - public void setAdvancedConstraint(SelectionCriteria advancedConstraint) { + public void setAdvancedConstraint(final SelectionCriteria advancedConstraint) { this.advancedConstraint = advancedConstraint; } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOpenAIRECommunities.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOpenAIRECommunities.java similarity index 95% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOpenAIRECommunities.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOpenAIRECommunities.java index 662f7b19..fc61c091 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOpenAIRECommunities.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOpenAIRECommunities.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import java.util.ArrayList; import java.util.List; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOrganization.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOrganization.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOrganization.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOrganization.java index 32e4ec2f..14652277 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityOrganization.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityOrganization.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import javax.validation.constraints.NotNull; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityProject.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityProject.java similarity index 97% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityProject.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityProject.java index 0a3b2800..a1833cd2 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityProject.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityProject.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityStatus.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityStatus.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityStatus.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityStatus.java index 2213feb1..3c7b376a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityStatus.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityStatus.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunitySummary.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunitySummary.java similarity index 98% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunitySummary.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunitySummary.java index ff3ed2c7..16e072be 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunitySummary.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunitySummary.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import java.util.Date; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityWritableProperties.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityWritableProperties.java similarity index 90% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityWritableProperties.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityWritableProperties.java index db6d3e5e..934633a8 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityWritableProperties.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityWritableProperties.java @@ -1,14 +1,12 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; import io.swagger.v3.oas.annotations.media.Schema; -import javax.persistence.criteria.Selection; - @JsonAutoDetect public class CommunityWritableProperties { @@ -36,7 +34,6 @@ public class CommunityWritableProperties { @Schema(description = "Advanced constraint for the association of results to the community") private SelectionCriteria advancedConstraint; - @Schema(description = "status of the community, drives its visibility") private CommunityStatus status; @@ -62,7 +59,7 @@ public class CommunityWritableProperties { return fos; } - public void setFos(List fos) { + public void setFos(final List fos) { this.fos = fos; } @@ -70,7 +67,7 @@ public class CommunityWritableProperties { return sdg; } - public void setSdg(List sdg) { + public void setSdg(final List sdg) { this.sdg = sdg; } @@ -78,7 +75,7 @@ public class CommunityWritableProperties { return advancedConstraint; } - public void setAdvancedConstraint(SelectionCriteria advancedConstraint) { + public void setAdvancedConstraint(final SelectionCriteria advancedConstraint) { this.advancedConstraint = advancedConstraint; } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityZenodoCommunity.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityZenodoCommunity.java similarity index 94% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityZenodoCommunity.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityZenodoCommunity.java index 072faf29..4bae4957 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityZenodoCommunity.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/CommunityZenodoCommunity.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community; +package eu.dnetlib.openaire.exporter.model.community; import javax.validation.constraints.NotNull; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraint.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraint.java similarity index 90% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraint.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraint.java index 31c71535..830b7c9c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraint.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraint.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.selectioncriteria; +package eu.dnetlib.openaire.exporter.model.community.selectioncriteria; import java.io.Serializable; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraints.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraints.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraints.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraints.java index a899095f..393301e6 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/Constraints.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/Constraints.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.selectioncriteria; +package eu.dnetlib.openaire.exporter.model.community.selectioncriteria; import java.io.Serializable; import java.util.List; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteria.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/SelectionCriteria.java similarity index 62% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteria.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/SelectionCriteria.java index 0214e41a..f93c105a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/selectioncriteria/SelectionCriteria.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/community/selectioncriteria/SelectionCriteria.java @@ -1,10 +1,11 @@ -package eu.dnetlib.openaire.community.selectioncriteria; +package eu.dnetlib.openaire.exporter.model.community.selectioncriteria; import java.io.Serializable; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.google.gson.Gson; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @JsonAutoDetect public class SelectionCriteria implements Serializable { @@ -27,7 +28,11 @@ public class SelectionCriteria implements Serializable { } public static SelectionCriteria fromJson(final String json) { - return new Gson().fromJson(json, SelectionCriteria.class); - + try { + return new ObjectMapper().readValue(json, SelectionCriteria.class); + } catch (final JsonProcessingException e) { + throw new RuntimeException(e); + } } + } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Category.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Category.java similarity index 95% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Category.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Category.java index 1c029777..9cb3cdb4 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Category.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Category.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; import java.util.List; import java.util.Map; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/CategorySummary.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/CategorySummary.java similarity index 91% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/CategorySummary.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/CategorySummary.java index c2acb200..46d18321 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/CategorySummary.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/CategorySummary.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; public class CategorySummary { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Concept.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Concept.java similarity index 95% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Concept.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Concept.java index ddbcdec1..dd2e8f0e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Concept.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Concept.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; import java.util.List; import java.util.Map; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ConceptSummary.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ConceptSummary.java similarity index 94% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ConceptSummary.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ConceptSummary.java index 58600836..85f5941d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ConceptSummary.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ConceptSummary.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; import java.util.List; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Context.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Context.java similarity index 92% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Context.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Context.java index badc1ff1..ff9b42b7 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Context.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Context.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; import java.util.Date; import java.util.List; @@ -44,8 +44,6 @@ public class Context { return categories; } - - public Context setId(final String id) { this.id = id; return this; @@ -66,17 +64,15 @@ public class Context { return this; } - public Date getLastUpdateDate() { return lastUpdateDate; } - public Context setLastUpdateDate(Date lastUpdateDate) { + public Context setLastUpdateDate(final Date lastUpdateDate) { this.lastUpdateDate = lastUpdateDate; return this; } - public Context setParams(final Map> params) { this.params = params; return this; @@ -88,4 +84,3 @@ public class Context { } } - diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextSummary.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ContextSummary.java similarity index 92% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextSummary.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ContextSummary.java index 9e974a3d..0576dd8c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/ContextSummary.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/ContextSummary.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; public class ContextSummary { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Param.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Param.java similarity index 86% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Param.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Param.java index e83a6fd2..071fb5cd 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/context/Param.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/context/Param.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.context; +package eu.dnetlib.openaire.exporter.model.context; public class Param { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Header.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Header.java similarity index 77% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Header.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Header.java index 4db04905..4bcbfc9a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Header.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Header.java @@ -1,13 +1,14 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; +import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.google.common.collect.Lists; -import com.google.gson.GsonBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @JsonAutoDetect public class Header { @@ -22,10 +23,8 @@ public class Header { private int statusCode; - private List errors = Lists.newArrayList(); - @JsonIgnore - private Queue exceptions = Lists.newLinkedList(); + private Queue exceptions = new LinkedList<>(); public static Header newInsance() { return new Header(); @@ -93,13 +92,12 @@ public class Header { .collect(Collectors.toList()); } - public Header setErrors(final List errors) { - this.errors = errors; - return this; - } - public String toJson() { - return new GsonBuilder().setPrettyPrinting().create().toJson(this); + try { + return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this); + } catch (final JsonProcessingException e) { + throw new RuntimeException(e); + } } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Response.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Response.java similarity index 90% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Response.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Response.java index abba2c54..662807da 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/Response.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/Response.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleResponse.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleResponse.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleResponse.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleResponse.java index 73381faf..6d9b3466 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleResponse.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleResponse.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ExtendedFunderDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/ExtendedFunderDetails.java similarity index 93% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ExtendedFunderDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/ExtendedFunderDetails.java index d6cc54d2..723feafb 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/ExtendedFunderDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/ExtendedFunderDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.funders.domain; +package eu.dnetlib.openaire.exporter.model.funders; import java.util.List; @@ -31,4 +31,3 @@ public class ExtendedFunderDetails extends FunderDetails { } } - diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FunderDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FunderDetails.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FunderDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FunderDetails.java index 04335b09..5180e193 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FunderDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FunderDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.funders.domain; +package eu.dnetlib.openaire.exporter.model.funders; import java.util.Date; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FundingStream.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FundingStream.java similarity index 86% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FundingStream.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FundingStream.java index 1efd0aa7..863a443b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/domain/FundingStream.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/funders/FundingStream.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.funders.domain; +package eu.dnetlib.openaire.exporter.model.funders; public class FundingStream { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Country.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Country.java similarity index 89% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Country.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Country.java index 73c54763..3aff3c84 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Country.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Country.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.vocabularies; +package eu.dnetlib.openaire.exporter.model.vocabularies; /** * Created by claudio on 15/09/2017. diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Term.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Term.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Term.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Term.java index 30adc410..07b82a84 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Term.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Term.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.vocabularies; +package eu.dnetlib.openaire.exporter.model.vocabularies; /** * Created by claudio on 15/09/2017. diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Vocabulary.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Vocabulary.java similarity index 94% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Vocabulary.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Vocabulary.java index 54c6e090..67243420 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/vocabularies/Vocabulary.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/vocabularies/Vocabulary.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.vocabularies; +package eu.dnetlib.openaire.exporter.model.vocabularies; import java.util.List; import java.util.Map; -- 2.17.1 From 57d5496855cf0e1f75283ed2123091ed5cc33cbb Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 31 Mar 2023 16:13:52 +0200 Subject: [PATCH 3/6] moved some classes into the model module --- .../openaire/dsm/DsmApiController.java | 4 +- .../openaire/dsm/DsmApiControllerV2.java | 4 +- .../java/eu/dnetlib/openaire/dsm/DsmCore.java | 10 ++-- .../openaire/dsm/dao/MongoLoggerClient.java | 2 +- .../dsm/dao/MongoLoggerClientImpl.java | 12 ++-- .../openaire/dsm/dao/ResponseUtils.java | 4 +- .../dsm/dao/utils/DsmMappingUtils.java | 4 +- .../dsm/domain/DatasourceDetailResponse.java | 1 + .../dsm/domain/DatasourceDetailsUpdate.java | 1 + .../dsm/domain/DatasourceDetailsWithApis.java | 1 + .../dsm/domain/DatasourceSearchResponse.java | 1 + .../dsm/domain/DatasourceSnippetExtended.java | 1 + .../dsm/DatasourceApiControllerTest.java | 2 +- libs/dnet-exporter-model/TODO.txt | 8 --- libs/dnet-exporter-model/pom.xml | 17 ++++-- .../dsm}/AggregationHistoryResponseV1.java | 4 +- .../dsm}/AggregationHistoryResponseV2.java | 5 +- .../exporter/model/dsm/AggregationInfo.java | 56 +++++++++++++++++++ .../model/dsm}/AggregationInfoV1.java | 4 +- .../exporter/model/dsm/AggregationStage.java | 25 +++++++++ .../exporter/model/dsm}/CollectionInfoV1.java | 2 +- .../exporter/model/dsm}/CollectionInfoV2.java | 5 +- .../exporter/model/dsm}/CollectionMode.java | 2 +- .../model/dsm}/DatasourceDetails.java | 2 +- .../dsm}/DatasourceIgnoredProperties.java | 2 +- .../exporter/model/dsm}/DatasourceInfo.java | 3 +- .../model/dsm}/IdentitiesDetails.java | 2 +- .../model/dsm}/OrganizationDetails.java | 2 +- .../dsm}/OrganizationIgnoredProperties.java | 2 +- .../model/dsm}/SimpleDatasourceInfo.java | 2 +- .../model/dsm}/TransformationInfoV1.java | 2 +- .../model/dsm}/TransformationInfoV2.java | 4 +- 32 files changed, 133 insertions(+), 63 deletions(-) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/AggregationHistoryResponseV1.java (85%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/AggregationHistoryResponseV2.java (77%) create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfo.java rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/AggregationInfoV1.java (68%) create mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationStage.java rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/CollectionInfoV1.java (89%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/CollectionInfoV2.java (72%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/CollectionMode.java (78%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceDetails.java (99%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceIgnoredProperties.java (98%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceInfo.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/IdentitiesDetails.java (90%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/OrganizationDetails.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/OrganizationIgnoredProperties.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/SimpleDatasourceInfo.java (98%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/TransformationInfoV1.java (80%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/TransformationInfoV2.java (63%) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java index d08d2350..cf995d11 100755 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java @@ -26,11 +26,9 @@ import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.OperationManager; -import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV1; import eu.dnetlib.openaire.dsm.domain.ApiDetails; import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; @@ -41,6 +39,8 @@ import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import io.swagger.v3.oas.annotations.Operation; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java index 70977f45..68107164 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java @@ -17,9 +17,9 @@ import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; -import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV2; -import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java index 2cad2a0f..e17b5bb9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java @@ -37,13 +37,9 @@ import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.dao.VocabularyClient; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV1; -import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV2; -import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1; import eu.dnetlib.openaire.dsm.domain.ApiDetails; import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; @@ -51,13 +47,17 @@ import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; -import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry; import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java index 0a141057..59d773ce 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java @@ -2,8 +2,8 @@ package eu.dnetlib.openaire.dsm.dao; import java.util.List; -import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1; import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; public interface MongoLoggerClient { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java index 48346f15..a176be01 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java @@ -46,13 +46,13 @@ import eu.dnetlib.enabling.datasources.common.AggregationStage; import eu.dnetlib.miscutils.datetime.DateUtils; import eu.dnetlib.openaire.common.Utils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1; -import eu.dnetlib.openaire.dsm.domain.CollectionInfoV1; -import eu.dnetlib.openaire.dsm.domain.CollectionInfoV2; -import eu.dnetlib.openaire.dsm.domain.CollectionMode; -import eu.dnetlib.openaire.dsm.domain.TransformationInfoV1; -import eu.dnetlib.openaire.dsm.domain.TransformationInfoV2; import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV2; +import eu.dnetlib.openaire.exporter.model.dsm.CollectionMode; +import eu.dnetlib.openaire.exporter.model.dsm.TransformationInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.TransformationInfoV2; import eu.dnetlib.openaire.info.JdbcInfoDao; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java index 941ee574..fa849ea0 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java @@ -8,11 +8,11 @@ import com.google.common.collect.Lists; import eu.dnetlib.openaire.dsm.domain.ApiDetails; import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; -import eu.dnetlib.openaire.dsm.domain.DatasourceInfo; import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.Header; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java index 7e6d80b2..3d3ee56d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java @@ -15,13 +15,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; import eu.dnetlib.openaire.dsm.domain.ApiDetails; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; -import eu.dnetlib.openaire.dsm.domain.OrganizationDetails; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; public class DsmMappingUtils { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java index b011d889..1d55a20d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java @@ -4,6 +4,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.Response; @JsonAutoDetect diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java index 750813bb..eef03063 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java @@ -8,6 +8,7 @@ import javax.validation.constraints.NotBlank; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.IdentitiesDetails; import io.swagger.v3.oas.annotations.media.Schema; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java index 8e0c3d09..bf41287b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java @@ -5,6 +5,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import io.swagger.v3.oas.annotations.media.Schema; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java index e8d3aacb..5c31dab1 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSearchResponse.java @@ -4,6 +4,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.Response; @JsonAutoDetect diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java index 819fe307..3454f8e3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java @@ -8,6 +8,7 @@ import javax.validation.constraints.NotBlank; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; import io.swagger.v3.oas.annotations.media.Schema; @JsonAutoDetect diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java index 80cfe152..b5ede79a 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/DatasourceApiControllerTest.java @@ -21,8 +21,8 @@ import org.springframework.test.web.servlet.MockMvc; import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetails; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; @SpringBootTest diff --git a/libs/dnet-exporter-model/TODO.txt b/libs/dnet-exporter-model/TODO.txt index c5253ee8..aa4feea2 100644 --- a/libs/dnet-exporter-model/TODO.txt +++ b/libs/dnet-exporter-model/TODO.txt @@ -1,15 +1,7 @@ - -DsmApiControllerV2 - SimpleDatasourceInfo - AggregationHistoryResponseV2 - DsmApiController - DatasourceDetailResponse - AggregationHistoryResponseV1 DatasourceSnippetResponse RegisteredDatasourceInfo ApiDetailsResponse - DatasourceDetails DatasourceDetailsWithApis DatasourceDetailsUpdate ApiDetails diff --git a/libs/dnet-exporter-model/pom.xml b/libs/dnet-exporter-model/pom.xml index dc5e670b..970daafb 100644 --- a/libs/dnet-exporter-model/pom.xml +++ b/libs/dnet-exporter-model/pom.xml @@ -18,18 +18,23 @@ - - org.mockito - mockito-junit-jupiter - test - - org.springdoc springdoc-openapi-common 1.6.10 + + jakarta.persistence + jakarta.persistence-api + + + + org.mockito + mockito-junit-jupiter + test + + org.springframework.boot spring-boot-starter-test diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV1.java similarity index 85% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV1.java index 6ab84899..84efaa3c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV1.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV1.java @@ -1,11 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.Response; - @JsonAutoDetect @Deprecated public class AggregationHistoryResponseV1 extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV2.java similarity index 77% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV2.java index b13e35a4..1a7779d1 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationHistoryResponseV2.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationHistoryResponseV2.java @@ -1,12 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; -import eu.dnetlib.openaire.exporter.model.dsm.Response; - @JsonAutoDetect public class AggregationHistoryResponseV2 extends Response { diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfo.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfo.java new file mode 100644 index 00000000..a2d1b7b5 --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfo.java @@ -0,0 +1,56 @@ +package eu.dnetlib.openaire.exporter.model.dsm; + +public abstract class AggregationInfo { + + private int numberOfRecords; + + private String date; + + private AggregationStage aggregationStage; + + private boolean indexedVersion = false; + + private boolean completedSuccessfully = true; + + public AggregationInfo() {} + + public int getNumberOfRecords() { + return numberOfRecords; + } + + public void setNumberOfRecords(final int numberOfRecords) { + this.numberOfRecords = numberOfRecords; + } + + public String getDate() { + return date; + } + + public void setDate(final String date) { + this.date = date; + } + + public AggregationStage getAggregationStage() { + return aggregationStage; + } + + public void setAggregationStage(final AggregationStage aggregationStage) { + this.aggregationStage = aggregationStage; + } + + public boolean isIndexedVersion() { + return indexedVersion; + } + + public void setIndexedVersion(final boolean indexedVersion) { + this.indexedVersion = indexedVersion; + } + + public boolean isCompletedSuccessfully() { + return completedSuccessfully; + } + + public void setCompletedSuccessfully(final boolean completedSuccessfully) { + this.completedSuccessfully = completedSuccessfully; + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationInfoV1.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfoV1.java similarity index 68% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationInfoV1.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfoV1.java index d33ec120..3d70cae7 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/AggregationInfoV1.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationInfoV1.java @@ -1,9 +1,7 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonIgnore; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; - public class AggregationInfoV1 extends AggregationInfo { @Override diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationStage.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationStage.java new file mode 100644 index 00000000..e2a79bf7 --- /dev/null +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/AggregationStage.java @@ -0,0 +1,25 @@ +package eu.dnetlib.openaire.exporter.model.dsm; + +public enum AggregationStage { + + COLLECT, + TRANSFORM; + + public static AggregationStage parse(final String s) { + switch (s) { + case "collect": + case "collection": + case "COLLECT": + case "COLLECTION": + return AggregationStage.COLLECT; + case "transform": + case "transformation": + case "TRANSFORM": + case "TRANSFORMATION": + case "transformDatasets": + case "transformPublications": + return AggregationStage.TRANSFORM; + } + throw new IllegalArgumentException("invalid AggregationStage: " + s); + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV1.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV1.java similarity index 89% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV1.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV1.java index 34a8961d..6c15c896 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV1.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV1.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV2.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV2.java similarity index 72% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV2.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV2.java index b1cba57d..a9edb7a1 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionInfoV2.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionInfoV2.java @@ -1,10 +1,7 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; -import io.swagger.v3.oas.annotations.media.Schema; - /** * Created by claudio on 29/11/2016. */ diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionMode.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionMode.java similarity index 78% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionMode.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionMode.java index 5d8702d7..a2d972d9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/CollectionMode.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/CollectionMode.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetails.java similarity index 99% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetails.java index 0d27e3bc..b9b31cdf 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.sql.Date; import java.util.Set; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceIgnoredProperties.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceIgnoredProperties.java similarity index 98% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceIgnoredProperties.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceIgnoredProperties.java index f00a734c..498d9144 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceIgnoredProperties.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceIgnoredProperties.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.sql.Date; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceInfo.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceInfo.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceInfo.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceInfo.java index 07399122..4b2a40ea 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceInfo.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceInfo.java @@ -1,10 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; import io.swagger.v3.oas.annotations.media.Schema; @JsonAutoDetect diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/IdentitiesDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/IdentitiesDetails.java similarity index 90% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/IdentitiesDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/IdentitiesDetails.java index 48cba1e9..7d1ccd33 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/IdentitiesDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/IdentitiesDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationDetails.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationDetails.java index 1abc52d4..0b7c92d2 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import javax.validation.constraints.NotBlank; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationIgnoredProperties.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationIgnoredProperties.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationIgnoredProperties.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationIgnoredProperties.java index 3212fb66..256c0de2 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationIgnoredProperties.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/OrganizationIgnoredProperties.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.Date; import java.util.Set; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleDatasourceInfo.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleDatasourceInfo.java similarity index 98% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleDatasourceInfo.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleDatasourceInfo.java index 997f3894..9c9fc799 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/SimpleDatasourceInfo.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/SimpleDatasourceInfo.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.LinkedHashMap; import java.util.Map; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV1.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV1.java similarity index 80% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV1.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV1.java index d119964d..4990daec 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV1.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV1.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV2.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV2.java similarity index 63% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV2.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV2.java index 2d5a6fa4..df74986c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/TransformationInfoV2.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/TransformationInfoV2.java @@ -1,9 +1,7 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; - /** * Created by claudio on 29/11/2016. */ -- 2.17.1 From a04e719a57599792d4a6c79bd80f73e4a5833594 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 3 Apr 2023 08:33:39 +0200 Subject: [PATCH 4/6] moved some classes to new module --- .../java/eu/dnetlib/openaire/dsm/DsmApiController.java | 6 +++--- .../src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java | 8 ++++---- .../java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java | 2 +- .../eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java | 2 +- .../java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java | 4 ++-- .../java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java | 4 ++-- .../dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java | 2 +- .../openaire/dsm/domain/DatasourceDetailsWithApis.java | 1 + .../openaire/dsm/dao/utils/DsmMappingUtilsTest.java | 2 +- libs/dnet-exporter-model/TODO.txt | 4 +--- .../dnetlib/openaire/exporter/model/dsm}/ApiDetails.java | 2 +- .../openaire/exporter/model/dsm}/ApiDetailsResponse.java | 6 +----- .../exporter/model/dsm}/ApiIgnoredProperties.java | 2 +- .../openaire/exporter/model/dsm}/ApiParamDetails.java | 2 +- .../dnetlib/openaire/exporter/model/dsm}/FilterName.java | 2 +- .../dnetlib/openaire/exporter/model/dsm}/FilterType.java | 2 +- .../openaire/exporter/model/dsm}/RequestFilter.java | 2 +- 17 files changed, 24 insertions(+), 29 deletions(-) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/ApiDetails.java (98%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/ApiDetailsResponse.java (69%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/ApiIgnoredProperties.java (96%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/ApiParamDetails.java (87%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/FilterName.java (95%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/FilterType.java (59%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/RequestFilter.java (89%) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java index cf995d11..b62f49e0 100755 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java @@ -26,21 +26,21 @@ import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.OperationManager; -import eu.dnetlib.openaire.dsm.domain.ApiDetails; -import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import io.swagger.v3.oas.annotations.Operation; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java index e17b5bb9..68681b23 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java @@ -29,7 +29,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; import eu.dnetlib.openaire.common.ISClient; import eu.dnetlib.openaire.community.CommunityClient; import eu.dnetlib.openaire.dsm.dao.DatasourceDao; @@ -37,14 +36,11 @@ import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.dao.VocabularyClient; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.domain.ApiDetails; -import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; @@ -55,8 +51,12 @@ import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java index b126bf13..7ef08195 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java @@ -5,10 +5,10 @@ import java.util.List; import org.springframework.data.domain.Page; import eu.dnetlib.enabling.datasources.common.Api; -import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; public interface DatasourceDao, API extends Api> extends DatasourceManagerCommon { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java index 7372d10e..d320901d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java @@ -30,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; import eu.dnetlib.DnetOpenaireExporterProperties; -import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; @@ -40,6 +39,7 @@ import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java index 8e22477c..13a7e13d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java @@ -16,13 +16,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.data.jpa.domain.Specification; -import eu.dnetlib.openaire.dsm.domain.FilterName; -import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException; +import eu.dnetlib.openaire.exporter.model.dsm.FilterName; +import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; public class DatasourceSpecs { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java index fa849ea0..f3e20cc0 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java @@ -5,12 +5,12 @@ import java.util.Queue; import com.google.common.collect.Lists; -import eu.dnetlib.openaire.dsm.domain.ApiDetails; -import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.Header; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java index 3d3ee56d..9335fc77 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java @@ -14,12 +14,12 @@ import org.springframework.beans.BeanWrapperImpl; import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; -import eu.dnetlib.openaire.dsm.domain.ApiDetails; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java index bf41287b..58df040d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java @@ -5,6 +5,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtilsTest.java b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtilsTest.java index eb11e14d..9b051d6d 100644 --- a/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtilsTest.java +++ b/apps/dnet-exporter-api/src/test/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtilsTest.java @@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import eu.dnetlib.openaire.dsm.domain.ApiDetails; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; +import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; class DsmMappingUtilsTest { diff --git a/libs/dnet-exporter-model/TODO.txt b/libs/dnet-exporter-model/TODO.txt index aa4feea2..8a879752 100644 --- a/libs/dnet-exporter-model/TODO.txt +++ b/libs/dnet-exporter-model/TODO.txt @@ -1,8 +1,6 @@ DsmApiController DatasourceSnippetResponse RegisteredDatasourceInfo - ApiDetailsResponse DatasourceDetailsWithApis DatasourceDetailsUpdate - ApiDetails - RequestFilter + diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetails.java similarity index 98% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetails.java index 4768d9a0..917d2d1c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.sql.Date; import java.util.Set; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetailsResponse.java similarity index 69% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetailsResponse.java index b65f6e42..38aa7a28 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiDetailsResponse.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiDetailsResponse.java @@ -1,13 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.Response; -import io.swagger.v3.oas.annotations.media.Schema; - - @JsonAutoDetect public class ApiDetailsResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiIgnoredProperties.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiIgnoredProperties.java similarity index 96% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiIgnoredProperties.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiIgnoredProperties.java index d674f260..995c2e16 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiIgnoredProperties.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiIgnoredProperties.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiParamDetails.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiParamDetails.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiParamDetails.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiParamDetails.java index 158bd72a..3977a568 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/ApiParamDetails.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/ApiParamDetails.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; public class ApiParamDetails { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterName.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterName.java similarity index 95% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterName.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterName.java index 2dbd67eb..2a7ab8a8 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterName.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterName.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterType.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterType.java similarity index 59% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterType.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterType.java index a028e350..70b4e7a0 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/FilterType.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/FilterType.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; public enum FilterType { exact, diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestFilter.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestFilter.java similarity index 89% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestFilter.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestFilter.java index fe160844..9edb5f71 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestFilter.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestFilter.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.HashMap; -- 2.17.1 From ca382e6b6c8f46735f2de3fceb701a92a616d539 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 3 Apr 2023 12:22:22 +0200 Subject: [PATCH 5/6] moved remaining classes --- apps/dnet-exporter-api/pom.xml | 3 +- .../common/AbstractExporterController.java | 22 +-- .../eu/dnetlib/openaire/common/ISClient.java | 5 +- .../dnetlib/openaire/common/ISClientImpl.java | 8 +- .../openaire/dsm/DsmApiController.java | 66 ++++--- .../openaire/dsm/DsmApiControllerV2.java | 4 +- .../java/eu/dnetlib/openaire/dsm/DsmCore.java | 175 +++++++++++------- .../openaire/dsm/dao/DatasourceDao.java | 13 +- .../openaire/dsm/dao/DatasourceDaoImpl.java | 44 ++--- .../dsm/dao/DatasourceIndexClient.java | 6 +- .../dsm/dao/DatasourceIndexClientImpl.java | 11 +- .../openaire/dsm/dao/DatasourceSpecs.java | 6 +- .../openaire/dsm/dao/MongoLoggerClient.java | 7 +- .../dsm/dao/MongoLoggerClientImpl.java | 14 +- .../openaire/dsm/dao/ObjectStoreClient.java | 4 +- .../dsm/dao/ObjectStoreClientImpl.java | 6 +- .../openaire/dsm/dao/ResponseUtils.java | 6 +- .../openaire/dsm/dao/VocabularyClient.java | 7 +- .../dsm/dao/VocabularyClientImpl.java | 18 +- .../dsm/dao/utils/DsmMappingUtils.java | 4 +- libs/dnet-exporter-model/TODO.txt | 6 - ...DsmException.java => DsmApiException.java} | 10 +- .../exceptions/DsmForbiddenException.java | 23 --- .../exceptions/DsmNotFoundException.java | 23 --- .../exceptions/DsmRuntimeException.java | 23 --- .../model/dsm}/DatasourceDetailResponse.java | 5 +- .../model/dsm}/DatasourceDetailsUpdate.java | 3 +- .../model/dsm}/DatasourceDetailsWithApis.java | 4 +- .../model/dsm}/DatasourceSnippetExtended.java | 3 +- .../model/dsm}/DatasourceSnippetResponse.java | 4 +- .../model/dsm}/RegisteredDatasourceInfo.java | 2 +- .../exporter/model/dsm}/RequestSort.java | 2 +- .../exporter/model/dsm}/RequestSortOrder.java | 2 +- 33 files changed, 229 insertions(+), 310 deletions(-) delete mode 100644 libs/dnet-exporter-model/TODO.txt rename libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/{DsmException.java => DsmApiException.java} (56%) delete mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java delete mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java delete mode 100644 libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceDetailResponse.java (77%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceDetailsUpdate.java (97%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceDetailsWithApis.java (82%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceSnippetExtended.java (97%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/DatasourceSnippetResponse.java (85%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/RegisteredDatasourceInfo.java (97%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/RequestSort.java (76%) rename {apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain => libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm}/RequestSortOrder.java (73%) diff --git a/apps/dnet-exporter-api/pom.xml b/apps/dnet-exporter-api/pom.xml index b365bded..72ebd904 100644 --- a/apps/dnet-exporter-api/pom.xml +++ b/apps/dnet-exporter-api/pom.xml @@ -125,12 +125,11 @@ 3.4.2 - org.springframework.boot diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java index 026fbe4f..486ee096 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/AbstractExporterController.java @@ -16,9 +16,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; -import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; -import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; import eu.dnetlib.openaire.exporter.model.dsm.Response; /** @@ -30,29 +28,13 @@ public abstract class AbstractExporterController { @ResponseBody @ExceptionHandler({ - DsmException.class + DsmApiException.class }) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) public ErrorMessage handleDSMException(final Exception e) { return _handleError(e); } - @ResponseBody - @ExceptionHandler(DsmForbiddenException.class) - @ResponseStatus(value = HttpStatus.FORBIDDEN) - public ErrorMessage handleForbiddenException(final Exception e) { - return _handleError(e); - } - - @ResponseBody - @ExceptionHandler({ - DsmNotFoundException.class - }) - @ResponseStatus(value = HttpStatus.NOT_FOUND) - public ErrorMessage handleNotFoundException(final Exception e) { - return _handleError(e); - } - @ResponseBody @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java index 3ed78e44..b4b279a3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClient.java @@ -5,14 +5,13 @@ import java.util.List; import java.util.Map; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.model.context.Context; public interface ISClient { - IndexDsInfo calculateCurrentIndexDsInfo() throws DsmException; + IndexDsInfo calculateCurrentIndexDsInfo() throws Exception; - String getObjectStoreId(String dsId) throws DsmException; + String getObjectStoreId(String dsId) throws Exception; Map getFunderContextMap() throws IOException; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java index 4a0c628a..4636bdd8 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java @@ -28,12 +28,12 @@ import com.google.common.escape.Escaper; import com.google.common.xml.XmlEscapers; import eu.dnetlib.DnetOpenaireExporterProperties; +import eu.dnetlib.enabling.datasources.common.DsmException; +import eu.dnetlib.enabling.datasources.common.DsmRuntimeException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import eu.dnetlib.openaire.context.ContextMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; -import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException; import eu.dnetlib.openaire.exporter.model.context.Context; /** @@ -52,7 +52,7 @@ public class ISClientImpl implements ISClient { @Override @Cacheable("indexdsinfo-cache") - public IndexDsInfo calculateCurrentIndexDsInfo() throws DsmException { + public IndexDsInfo calculateCurrentIndexDsInfo() throws Exception { log.warn("calculateCurrentIndexDsInfo(): not using cache"); final String[] arr; try { @@ -67,7 +67,7 @@ public class ISClientImpl implements ISClient { @Override @Cacheable("objectstoreid-cache") - public String getObjectStoreId(final String dsId) throws DsmException { + public String getObjectStoreId(final String dsId) throws Exception { log.warn(String.format("getObjectStoreId(%s): not using cache", dsId)); try { final String xqueryTemplate = _getQuery(config.getFindObjectStore()); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java index b62f49e0..2c98a229 100755 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiController.java @@ -26,21 +26,19 @@ import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.OperationManager; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; -import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; -import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.RequestSort; -import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; -import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; -import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsWithApis; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse; +import eu.dnetlib.openaire.exporter.model.dsm.RegisteredDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSort; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import io.swagger.v3.oas.annotations.Operation; @@ -69,7 +67,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public List listCountries() throws DsmException { + public List listCountries() throws DsmApiException { return dsmCore.listCountries(); } @@ -88,7 +86,7 @@ public class DsmApiController extends AbstractExporterController { @RequestParam final RequestSortOrder order, @RequestBody final RequestFilter requestFilter, @PathVariable final int page, - @PathVariable final int size) throws DsmException { + @PathVariable final int size) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final DatasourceDetailResponse rsp = dsmCore.searchDsDetails(requestSortBy, order, requestFilter, page, size); return prepareResponse(page, size, stop, rsp); @@ -104,7 +102,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public AggregationHistoryResponseV1 aggregationHistory(@PathVariable final String dsId) throws DsmException { + public AggregationHistoryResponseV1 aggregationHistory(@PathVariable final String dsId) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final AggregationHistoryResponseV1 rsp = dsmCore.aggregationhistoryV1(dsId); return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp); @@ -125,7 +123,7 @@ public class DsmApiController extends AbstractExporterController { @RequestParam final RequestSortOrder order, @RequestBody final RequestFilter requestFilter, @PathVariable final int page, - @PathVariable final int size) throws DsmException { + @PathVariable final int size) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final DatasourceSnippetResponse rsp = dsmCore.searchSnippet(requestSortBy, order, requestFilter, page, size); return prepareResponse(page, size, stop, rsp); @@ -147,7 +145,7 @@ public class DsmApiController extends AbstractExporterController { @RequestParam final RequestSortOrder order, @RequestBody final RequestFilter requestFilter, @PathVariable final int page, - @PathVariable final int size) throws DsmException { + @PathVariable final int size) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final DatasourceSnippetResponse rsp = dsmCore.searchRegistered(requestSortBy, order, requestFilter, page, size); return prepareResponse(page, size, stop, rsp); @@ -198,7 +196,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public ApiDetailsResponse getApi( - @PathVariable final String dsId) throws DsmException { + @PathVariable final String dsId) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final ApiDetailsResponse rsp = dsmCore.getApis(dsId); @@ -218,7 +216,7 @@ public class DsmApiController extends AbstractExporterController { public List searchBaseUrls( @RequestBody final RequestFilter requestFilter, @PathVariable final int page, - @PathVariable final int size) throws DsmException { + @PathVariable final int size) throws DsmApiException { return dsmCore.findBaseURLs(requestFilter, page, size); } @@ -233,7 +231,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "403", description = "Api not removable"), @ApiResponse(responseCode = "500", description = "DSM Server error") }) - public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException { + public void deleteApi(@PathVariable final String apiId) throws DsmApiException { dsmCore.deleteApi(apiId); } @@ -247,7 +245,7 @@ public class DsmApiController extends AbstractExporterController { }) public void setManaged( @RequestParam final String id, - @RequestParam final boolean managed) throws DsmException { + @RequestParam final boolean managed) throws DsmApiException { dsmCore.setManaged(id, managed); } @@ -260,7 +258,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public boolean isManaged(@PathVariable final String id) throws DsmException { + public boolean isManaged(@PathVariable final String id) throws DsmApiException { return dsmCore.isManaged(id); } @@ -273,10 +271,10 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "400", description = "Malformed request"), @ApiResponse(responseCode = "500", description = "Unexpected error") }) - public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException { + public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmApiException { if (dsmCore.exist(datasource)) { // TODO further check that the DS doesn't have any API - throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", datasource.getId())); + throw new DsmApiException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", datasource.getId())); } dsmCore.save(datasource); } @@ -290,10 +288,10 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "400", description = "Malformed request"), @ApiResponse(responseCode = "500", description = "Unexpected error") }) - public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException { - if (d.getDatasource() == null) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); } + public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmApiException { + if (d.getDatasource() == null) { throw new DsmApiException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); } if (dsmCore.exist(d.getDatasource())) { // TODO further check that the DS doesn't have any API - throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", d.getDatasource().getId())); + throw new DsmApiException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", d.getDatasource().getId())); } dsmCore.save(d); } @@ -307,7 +305,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public void updateDatasource( - @RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException { + @RequestBody final DatasourceDetailsUpdate ds) throws DsmApiException { dsmCore.updateDatasource(ds); } @@ -323,7 +321,7 @@ public class DsmApiController extends AbstractExporterController { public void updateBaseUrl( @RequestParam final String dsId, @RequestParam final String apiId, - @RequestParam final String baseUrl) throws DsmException { + @RequestParam final String baseUrl) throws DsmApiException { dsmCore.updateApiBaseurl(dsId, apiId, baseUrl); } @@ -340,7 +338,7 @@ public class DsmApiController extends AbstractExporterController { @RequestParam final String dsId, @RequestParam final String apiId, @RequestParam final String compliance, - @RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmException { + @RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmApiException { dsmCore.updateApiCompatibility(dsId, apiId, compliance, override); } @@ -356,7 +354,7 @@ public class DsmApiController extends AbstractExporterController { public void updateOaiSetl( @RequestParam final String dsId, @RequestParam final String apiId, - @RequestParam final String oaiSet) throws DsmException { + @RequestParam final String oaiSet) throws DsmApiException { dsmCore.updateApiOaiSet(dsId, apiId, oaiSet); } @@ -369,8 +367,8 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public void addApi(@RequestBody final ApiDetails api) throws DsmException { - if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); } + public void addApi(@RequestBody final ApiDetails api) throws DsmApiException { + if (StringUtils.isBlank(api.getDatasource())) { throw new DsmApiException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); } dsmCore.addApi(api); } @@ -387,7 +385,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public int getOps() throws DsmException { + public int getOps() throws DsmApiException { return operationManager.getOpSize(); } @@ -399,7 +397,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public int killOps() throws DsmException { + public int killOps() throws DsmApiException { return operationManager.dropAll(); } @@ -411,7 +409,7 @@ public class DsmApiController extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public void dropCache() throws DsmException { + public void dropCache() throws DsmApiException { dsmCore.dropCaches(); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java index 68107164..2f250a3c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmApiControllerV2.java @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; @@ -95,7 +95,7 @@ public class DsmApiControllerV2 extends AbstractExporterController { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public AggregationHistoryResponseV2 aggregationHistory(@PathVariable final String dsId) throws DsmException { + public AggregationHistoryResponseV2 aggregationHistory(@PathVariable final String dsId) throws DsmApiException { final StopWatch stop = StopWatch.createStarted(); final AggregationHistoryResponseV2 rsp = dsmCore.aggregationhistoryV2(dsId); return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java index 68681b23..c3ba1a8b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/DsmCore.java @@ -9,6 +9,7 @@ import java.nio.charset.Charset; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -29,37 +30,42 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; +import com.google.common.collect.Lists; + +import eu.dnetlib.enabling.datasources.common.DsmException; +import eu.dnetlib.enabling.datasources.common.DsmForbiddenException; +import eu.dnetlib.enabling.datasources.common.DsmNotFoundException; import eu.dnetlib.openaire.common.ISClient; import eu.dnetlib.openaire.community.CommunityClient; +import eu.dnetlib.openaire.dsm.dao.CountryTermRepository; import eu.dnetlib.openaire.dsm.dao.DatasourceDao; import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient; import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.dao.VocabularyClient; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; -import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; -import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo; -import eu.dnetlib.openaire.dsm.domain.RequestSort; -import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; -import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException; -import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsWithApis; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse; +import eu.dnetlib.openaire.exporter.model.dsm.RegisteredDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSort; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder; import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.vocabularies.Country; +import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") @@ -79,19 +85,24 @@ public class DsmCore { @Autowired private DatasourceDao dsDao; + @Autowired + private CountryTermRepository countryTermRepository; + @Autowired private JdbcTemplate jdbcTemplate; @Autowired private CommunityClient communityClient; - public List listCountries() throws DsmException { - try { - return dsDao.listCountries(); - } catch (final Throwable e) { - log.error("error listing countries", e); - throw e; - } + public List listCountries() throws DsmApiException { + final List countries = Lists.newArrayList(); + final Vocabulary v = vocabularyClient.getCountries(); + countries.addAll(countryTermRepository.findAll() + .stream() + .filter(Objects::nonNull) + .map(t -> new Country(t.getTerm(), v.getEnglishName(t.getTerm()))) + .collect(Collectors.toList())); + return countries; } public DatasourceDetailResponse searchDsDetails(final RequestSort requestSortBy, @@ -99,14 +110,14 @@ public class DsmCore { final RequestFilter requestFilter, final int page, final int size) - throws DsmException { + throws DsmApiException { try { final Page dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size); return ResponseUtils.detailsResponse(dsPage.map(d -> asDetails(d)).getContent(), dsPage.getTotalElements()); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error("error searching datasources", e); - throw e; + throw new DsmApiException(e.getCode(), "error searching datasources", e); } } @@ -115,13 +126,13 @@ public class DsmCore { final RequestFilter requestFilter, final int page, final int size) - throws DsmException { + throws DsmApiException { try { final Page dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size); return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements()); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error("error searching datasources", e); - throw e; + throw new DsmApiException(e.getCode(), "error searching datasources", e); } } @@ -130,26 +141,26 @@ public class DsmCore { final RequestFilter requestFilter, final int page, final int size) - throws DsmException { + throws DsmApiException { try { final Page dsPage = dsDao.searchRegistered(requestSortBy, order, requestFilter, page, size); return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements()); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error("error searching datasources", e); - throw e; + throw new DsmApiException(e.getCode(), "error searching datasources", e); } } - public List findBaseURLs(final RequestFilter requestFilter, final int page, final int size) throws DsmException { + public List findBaseURLs(final RequestFilter requestFilter, final int page, final int size) throws DsmApiException { try { return dsDao.findApiBaseURLs(requestFilter, page, size); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error("error searching datasource base urls", e); - throw e; + throw new DsmApiException(e.getCode(), "error searching datasource base urls", e); } } - public ApiDetailsResponse getApis(final String dsId) throws DsmException { + public ApiDetailsResponse getApis(final String dsId) throws DsmApiException { try { final DatasourceDbEntry ds = dsDao.getDs(dsId); final List apis = dsDao.getApis(dsId); @@ -159,37 +170,49 @@ public class DsmCore { .map(a -> a.setTypology(ds.getTypology())) .collect(Collectors.toList()); return ResponseUtils.apiResponse(api, api.size()); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error(String.format("error searching datasource api %s", dsId), e); - throw e; + throw new DsmApiException(e.getCode(), String.format("error searching datasource api %s", dsId), e); } } - public void setManaged(final String dsId, final boolean managed) throws DsmException { + public void setManaged(final String dsId, final boolean managed) throws DsmApiException { log.info(String.format("updated ds '%s' managed with '%s'", dsId, managed)); - dsDao.setManaged(dsId, managed); + try { + dsDao.setManaged(dsId, managed); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public boolean isManaged(final String dsId) throws DsmException { - return dsDao.isManaged(dsId); + public boolean isManaged(final String dsId) throws DsmApiException { + try { + return dsDao.isManaged(dsId); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public boolean exist(final DatasourceDetails d) throws DsmException { - return dsDao.existDs(d.getId()); + public boolean exist(final DatasourceDetails d) throws DsmApiException { + try { + return dsDao.existDs(d.getId()); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public void save(final DatasourceDetails d) throws DsmException { + public void save(final DatasourceDetails d) throws DsmApiException { try { dsDao.saveDs(asDbEntry(d)); log.info("DS saved, " + d.getId()); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error(ExceptionUtils.getStackTrace(e)); - throw e; + throw new DsmApiException(e.getCode(), e.getMessage(), e); } } @Transactional - public void save(final DatasourceDetailsWithApis d) throws DsmException { + public void save(final DatasourceDetailsWithApis d) throws DsmApiException { try { dsDao.saveDs(asDbEntry(d.getDatasource())); final List apis = d.getApis(); @@ -199,15 +222,13 @@ public class DsmCore { addApi(api); } } - } catch ( - - final Throwable e) { + } catch (final DsmException e) { log.error(ExceptionUtils.getStackTrace(e)); - throw e; + throw new DsmApiException(e.getCode(), e.getMessage(), e); } } - public void updateDatasource(final DatasourceDetailsUpdate d) throws DsmException, DsmNotFoundException { + public void updateDatasource(final DatasourceDetailsUpdate d) throws DsmApiException { try { // initialize with current values from DB final DatasourceDbEntry ds = dsDao.getDs(d.getId()); @@ -228,46 +249,72 @@ public class DsmCore { } dsDao.saveDs(ds); - } catch (final Throwable e) { + } catch (final DsmException e) { log.error(ExceptionUtils.getStackTrace(e)); - throw e; + throw new DsmApiException(e.getCode(), e.getMessage(), e); } } // TODO remove if unused - public void deleteDs(final String dsId) throws DsmException { + public void deleteDs(final String dsId) throws DsmApiException { log.info(String.format("deleted datasource '%s'", dsId)); - dsDao.deleteDs(dsId); + try { + dsDao.deleteDs(dsId); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } // API - public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmException { - dsDao.upsertApiOaiSet(apiId, oaiSet); + public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmApiException { + try { + dsDao.upsertApiOaiSet(apiId, oaiSet); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public void updateApiBaseurl(final String dsId, final String apiId, final String baseUrl) throws DsmException { + public void updateApiBaseurl(final String dsId, final String apiId, final String baseUrl) throws DsmApiException { log.info(String.format("updated api '%s' baseurl with '%s'", apiId, baseUrl)); - dsDao.updateApiBaseUrl(apiId, baseUrl); + try { + dsDao.updateApiBaseUrl(apiId, baseUrl); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public void updateApiCompatibility(final String dsId, final String apiId, final String compliance, final boolean override) throws DsmException { + public void updateApiCompatibility(final String dsId, final String apiId, final String compliance, final boolean override) throws DsmApiException { log.info(String.format("updated api '%s' compliance with '%s'", apiId, compliance)); - dsDao.updateCompliance(null, apiId, compliance, override); + try { + dsDao.updateCompliance(null, apiId, compliance, override); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public void addApi(final ApiDetails api) throws DsmException { + public void addApi(final ApiDetails api) throws DsmApiException { if (StringUtils.isBlank(api.getId())) { api.setId(createId(api)); log.info(String.format("missing api id, created '%s'", api.getId())); } - dsDao.addApi(asDbEntry(api)); - log.info("API saved, id: " + api.getId()); + try { + dsDao.addApi(asDbEntry(api)); + log.info("API saved, id: " + api.getId()); + } catch (final DsmException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } - public void deleteApi(final String apiId) throws DsmForbiddenException, DsmNotFoundException { + public void deleteApi(final String apiId) throws DsmApiException { // TODO handle the api removal in case of associated workflows. - dsDao.deleteApi(null, apiId); + try { + dsDao.deleteApi(null, apiId); + } catch (final DsmForbiddenException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } catch (final DsmNotFoundException e) { + throw new DsmApiException(e.getCode(), e.getMessage(), e); + } } public void dropCaches() { @@ -316,14 +363,14 @@ public class DsmCore { } @Deprecated - public AggregationHistoryResponseV1 aggregationhistoryV1(final String dsId) throws DsmException { + public AggregationHistoryResponseV1 aggregationhistoryV1(final String dsId) throws DsmApiException { final List history = mongoLoggerClient.getAggregationHistoryV1(dsId); final AggregationHistoryResponseV1 rsp = new AggregationHistoryResponseV1(history); rsp.setHeader(ResponseUtils.header(history.size())); return rsp; } - public AggregationHistoryResponseV2 aggregationhistoryV2(final String dsId) throws DsmException { + public AggregationHistoryResponseV2 aggregationhistoryV2(final String dsId) throws DsmApiException { final List history = mongoLoggerClient.getAggregationHistoryV2(dsId); final AggregationHistoryResponseV2 rsp = new AggregationHistoryResponseV2(history); rsp.setHeader(ResponseUtils.header(history.size())); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java index 7ef08195..a0f2dce3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDao.java @@ -5,18 +5,17 @@ import java.util.List; import org.springframework.data.domain.Page; import eu.dnetlib.enabling.datasources.common.Api; -import eu.dnetlib.openaire.dsm.domain.RequestSort; -import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.enabling.datasources.common.Datasource; +import eu.dnetlib.enabling.datasources.common.DatasourceManagerCommon; +import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; -import eu.dnetlib.openaire.exporter.model.vocabularies.Country; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSort; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder; public interface DatasourceDao, API extends Api> extends DatasourceManagerCommon { // DATASOURCE - List listCountries() throws DsmException; - boolean existDs(final String dsId) throws DsmException; Page search(RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, int page, int size) throws DsmException; @@ -53,6 +52,4 @@ public interface DatasourceDao, API extends Api listCountries() throws DsmException { - final List countries = Lists.newArrayList(); - final Vocabulary v = vocabularyClient.getCountries(); - countries.addAll(countryTermRepository.findAll() - .stream() - .filter(Objects::nonNull) - .map(t -> new Country(t.getTerm(), v.getEnglishName(t.getTerm()))) - .collect(Collectors.toList())); - return countries; - } + // @Autowired + // private VocabularyClient vocabularyClient; @Override public Page search(final RequestSort requestSortBy, @@ -239,13 +221,11 @@ public class DatasourceDaoImpl implements DatasourceDao errors) throws DsmException; + IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue errors) throws DsmApiException; - String getLastIndexingDate(final IndexDsInfo info) throws DsmException; + String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException; } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java index 01cc9245..aca12611 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceIndexClientImpl.java @@ -38,11 +38,12 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.ThreadFactoryBuilder; import eu.dnetlib.DnetOpenaireExporterProperties; +import eu.dnetlib.enabling.datasources.common.DsmException; import eu.dnetlib.miscutils.functional.hash.Hashing; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; /** * Created by claudio on 20/10/2016. @@ -81,7 +82,7 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { } @Override - public IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue errors) throws DsmException { + public IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue errors) throws DsmApiException { try { final String collectedFrom = StringUtils.substringBefore(dsId, SEPARATOR) + SEPARATOR + Hashing.md5(StringUtils.substringAfter(dsId, SEPARATOR)); final CloudSolrClient indexClient = getIndexClient(info); @@ -123,12 +124,12 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { waitLatch(latch, errors, config.getRequestTimeout()); return indexRecordInfo; } catch (final Throwable e) { - throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("error reading index info", dsId), e); + throw new DsmApiException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("error reading index info", dsId), e); } } @Override - public String getLastIndexingDate(final IndexDsInfo info) throws DsmException { + public String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException { try { final SolrQuery query = new SolrQuery("oaftype:datasource").setRows(1); final QueryResponse rsp = getIndexClient(info).query(query); @@ -136,7 +137,7 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient { final String dsversion = doc.get("__dsversion").toString(); return StringUtils.substringBefore(dsversion, "T"); } catch (SolrServerException | IOException e) { - throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Error querying index DS profile: " + info, e); + throw new DsmApiException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Error querying index DS profile: " + info, e); } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java index 13a7e13d..7d4e8819 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceSpecs.java @@ -16,13 +16,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.data.jpa.domain.Specification; -import eu.dnetlib.openaire.dsm.domain.RequestSort; -import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; +import eu.dnetlib.enabling.datasources.common.DsmRuntimeException; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; -import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException; import eu.dnetlib.openaire.exporter.model.dsm.FilterName; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSort; +import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder; public class DatasourceSpecs { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java index 59d773ce..9553f7d6 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClient.java @@ -2,14 +2,15 @@ package eu.dnetlib.openaire.dsm.dao; import java.util.List; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; public interface MongoLoggerClient { - List getAggregationHistoryV1(final String dsId) throws DsmException; + List getAggregationHistoryV1(final String dsId) throws DsmApiException; - List getAggregationHistoryV2(final String dsId) throws DsmException; + List getAggregationHistoryV2(final String dsId) throws DsmApiException; void dropCache(); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java index a176be01..3e3be8f2 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/MongoLoggerClientImpl.java @@ -41,13 +41,13 @@ import com.mongodb.client.MongoCollection; import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties.Datasource; -import eu.dnetlib.enabling.datasources.common.AggregationInfo; -import eu.dnetlib.enabling.datasources.common.AggregationStage; import eu.dnetlib.miscutils.datetime.DateUtils; import eu.dnetlib.openaire.common.Utils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; +import eu.dnetlib.openaire.exporter.model.dsm.AggregationStage; import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV2; import eu.dnetlib.openaire.exporter.model.dsm.CollectionMode; @@ -93,19 +93,19 @@ public class MongoLoggerClientImpl implements MongoLoggerClient { @Override @Cacheable("dsm-aggregationhistory-cache-v1") @Deprecated - public List getAggregationHistoryV1(final String dsId) throws DsmException { + public List getAggregationHistoryV1(final String dsId) throws DsmApiException { return getAggregationHistory(dsId, queryForAggregationHistoryV1(dsId, "(collect|transform)"), getMapperV1()); } @Override @Cacheable("dsm-aggregationhistory-cache-v2") - public List getAggregationHistoryV2(final String dsId) throws DsmException { + public List getAggregationHistoryV2(final String dsId) throws DsmApiException { return getAggregationHistory(dsId, queryForAggregationHistoryV2(dsId, "(collect|transform)"), getMapperV2()); } private List getAggregationHistory(final String dsId, final Bson queryForAggregationHistory, - final Function mapper) throws DsmException { + final Function mapper) throws DsmApiException { log.warn(String.format("getAggregationHistory(dsId = %s): not using cache", dsId)); final Datasource conf = config.getDatasource(); try { @@ -132,7 +132,7 @@ public class MongoLoggerClientImpl implements MongoLoggerClient { return aggregationInfos; } catch (final Throwable e) { - throw new DsmException(HttpStatus.SC_INTERNAL_SERVER_ERROR, String.format("error reading aggregation history for '%s'", dsId), e); + throw new DsmApiException(HttpStatus.SC_INTERNAL_SERVER_ERROR, String.format("error reading aggregation history for '%s'", dsId), e); } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java index 76f11741..510418a7 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClient.java @@ -1,9 +1,9 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; public interface ObjectStoreClient { - Long getObjectStoreSize(final String objectStoreId) throws DsmException; + Long getObjectStoreSize(final String objectStoreId) throws DsmApiException; } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java index d3f77dca..c6950d6e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ObjectStoreClientImpl.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") @@ -21,7 +21,7 @@ public class ObjectStoreClientImpl implements ObjectStoreClient { private ObjectStoreService objectStoreService; @Override - public Long getObjectStoreSize(final String objectStoreId) throws DsmException { + public Long getObjectStoreSize(final String objectStoreId) throws DsmApiException { log.debug("get size for objectStore " + objectStoreId); if (StringUtils.isBlank(objectStoreId)) { return 0L; } try { @@ -29,7 +29,7 @@ public class ObjectStoreClientImpl implements ObjectStoreClient { log.debug("got objectStore size: " + size); return size; } catch (final ObjectStoreServiceException e) { - throw new DsmException("unable to get size for objectStore " + objectStoreId); + throw new DsmApiException("unable to get size for objectStore " + objectStoreId); } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java index f3e20cc0..8672515a 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/ResponseUtils.java @@ -5,14 +5,14 @@ import java.util.Queue; import com.google.common.collect.Lists; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse; -import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; -import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetExtended; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse; import eu.dnetlib.openaire.exporter.model.dsm.Header; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java index c6ffe096..9fed2d01 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClient.java @@ -1,12 +1,13 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.openaire.exporter.exceptions.DsmException; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; +import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; public interface VocabularyClient { - Vocabulary getCountries() throws DsmException; + Vocabulary getCountries() throws DsmApiException; - Vocabulary getDatasourceTypologies() throws DsmException; + Vocabulary getDatasourceTypologies() throws DsmApiException; void dropCache(); diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java index fe2acfc8..f3fbf35e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/VocabularyClientImpl.java @@ -1,9 +1,5 @@ package eu.dnetlib.openaire.dsm.dao; -import eu.dnetlib.DnetOpenaireExporterProperties; -import eu.dnetlib.enabling.datasources.common.DsmException; -import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -14,6 +10,10 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import eu.dnetlib.DnetOpenaireExporterProperties; +import eu.dnetlib.openaire.exporter.exceptions.DsmApiException; +import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; + /** * Created by claudio on 15/09/2017. */ @@ -27,24 +27,22 @@ public class VocabularyClientImpl implements VocabularyClient { @Override @Cacheable("vocabularies-cache") - public Vocabulary getCountries() throws DsmException { + public Vocabulary getCountries() throws DsmApiException { return _getVocabulary(config.getVocabularies().getCountriesEndpoint(), Vocabulary.class); } @Override @Cacheable("vocabularies-cache") - public Vocabulary getDatasourceTypologies() throws DsmException { + public Vocabulary getDatasourceTypologies() throws DsmApiException { return _getVocabulary(config.getVocabularies().getDatasourceTypologiesEndpoint(), Vocabulary.class); } - private T _getVocabulary(final String endpoint, Class clazz) throws DsmException { + private T _getVocabulary(final String endpoint, final Class clazz) throws DsmApiException { final RestTemplate rt = new RestTemplate(); log.info("get vocabulary from " + endpoint); final ResponseEntity rsp = rt.getForEntity(endpoint, clazz); - if (!rsp.getStatusCode().is2xxSuccessful()) { - throw new DsmException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint); - } + if (!rsp.getStatusCode().is2xxSuccessful()) { throw new DsmApiException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint); } return rsp.getBody(); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java index 9335fc77..cb8cd0bb 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/utils/DsmMappingUtils.java @@ -14,13 +14,13 @@ import org.springframework.beans.BeanWrapperImpl; import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; -import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; -import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate; +import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetExtended; import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; public class DsmMappingUtils { diff --git a/libs/dnet-exporter-model/TODO.txt b/libs/dnet-exporter-model/TODO.txt deleted file mode 100644 index 8a879752..00000000 --- a/libs/dnet-exporter-model/TODO.txt +++ /dev/null @@ -1,6 +0,0 @@ -DsmApiController - DatasourceSnippetResponse - RegisteredDatasourceInfo - DatasourceDetailsWithApis - DatasourceDetailsUpdate - diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmApiException.java similarity index 56% rename from libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmApiException.java index 0ac3608b..79a3fba3 100644 --- a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmException.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmApiException.java @@ -1,27 +1,27 @@ package eu.dnetlib.openaire.exporter.exceptions; -public class DsmException extends Exception { +public class DsmApiException extends Exception { private static final long serialVersionUID = -8173126561260106405L; private int code; - public DsmException(final int code, final String msg) { + public DsmApiException(final int code, final String msg) { super(msg); this.code = code; } - public DsmException(final int code, final Throwable e) { + public DsmApiException(final int code, final Throwable e) { super(e); this.code = code; } - public DsmException(final int code, final String msg, final Throwable e) { + public DsmApiException(final int code, final String msg, final Throwable e) { super(msg, e); this.code = code; } - public DsmException(final String msg) { + public DsmApiException(final String msg) { this(500, msg); } diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java deleted file mode 100644 index 03a436aa..00000000 --- a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmForbiddenException.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.dnetlib.openaire.exporter.exceptions; - -public class DsmForbiddenException extends DsmException { - - private static final long serialVersionUID = -6538032715005339181L; - - public DsmForbiddenException(final int code, final String msg) { - super(code, msg); - } - - public DsmForbiddenException(final int code, final Throwable e) { - super(code, e); - } - - public DsmForbiddenException(final int code, final String msg, final Throwable e) { - super(code, msg, e); - } - - public DsmForbiddenException(final String msg) { - this(403, msg); - } - -} diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java deleted file mode 100644 index d9f01052..00000000 --- a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmNotFoundException.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.dnetlib.openaire.exporter.exceptions; - -public class DsmNotFoundException extends DsmException { - - private static final long serialVersionUID = 1327980530652540728L; - - public DsmNotFoundException(final int code, final String msg) { - super(code, msg); - } - - public DsmNotFoundException(final int code, final Throwable e) { - super(code, e); - } - - public DsmNotFoundException(final int code, final String msg, final Throwable e) { - super(code, msg, e); - } - - public DsmNotFoundException(final String msg) { - this(404, msg); - } - -} diff --git a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java deleted file mode 100644 index e12894fe..00000000 --- a/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/exceptions/DsmRuntimeException.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.dnetlib.openaire.exporter.exceptions; - -public class DsmRuntimeException extends RuntimeException { - - private static final long serialVersionUID = 6755159618210324144L; - - public DsmRuntimeException() { - super(); - } - - public DsmRuntimeException(final String message, final Throwable cause) { - super(message, cause); - } - - public DsmRuntimeException(final String message) { - super(message); - } - - public DsmRuntimeException(final Throwable cause) { - super(cause); - } - -} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailResponse.java similarity index 77% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailResponse.java index 1d55a20d..a91f0f11 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailResponse.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailResponse.java @@ -1,12 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; -import eu.dnetlib.openaire.exporter.model.dsm.Response; - @JsonAutoDetect public class DatasourceDetailResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsUpdate.java similarity index 97% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsUpdate.java index eef03063..1894f84c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsUpdate.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.sql.Date; import java.util.Set; @@ -8,7 +8,6 @@ import javax.validation.constraints.NotBlank; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.IdentitiesDetails; import io.swagger.v3.oas.annotations.media.Schema; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsWithApis.java similarity index 82% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsWithApis.java index 58df040d..c451e449 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsWithApis.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceDetailsWithApis.java @@ -1,12 +1,10 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; -import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import io.swagger.v3.oas.annotations.media.Schema; /** diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetExtended.java similarity index 97% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetExtended.java index 3454f8e3..aefdc8f3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetExtended.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetExtended.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.Date; import java.util.Set; @@ -8,7 +8,6 @@ import javax.validation.constraints.NotBlank; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; import io.swagger.v3.oas.annotations.media.Schema; @JsonAutoDetect diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetResponse.java similarity index 85% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetResponse.java index ba84462b..b5d28a21 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceSnippetResponse.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/DatasourceSnippetResponse.java @@ -1,11 +1,9 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import eu.dnetlib.openaire.exporter.model.dsm.Response; - @JsonAutoDetect public class DatasourceSnippetResponse extends Response { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RegisteredDatasourceInfo.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RegisteredDatasourceInfo.java similarity index 97% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RegisteredDatasourceInfo.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RegisteredDatasourceInfo.java index 5bd17cc2..9b0613c2 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RegisteredDatasourceInfo.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RegisteredDatasourceInfo.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; public class RegisteredDatasourceInfo { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSort.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSort.java similarity index 76% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSort.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSort.java index bf0c0cbd..57adce9f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSort.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSort.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSortOrder.java b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSortOrder.java similarity index 73% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSortOrder.java rename to libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSortOrder.java index 2423a991..49b4f860 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/domain/RequestSortOrder.java +++ b/libs/dnet-exporter-model/src/main/java/eu/dnetlib/openaire/exporter/model/dsm/RequestSortOrder.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.dsm.domain; +package eu.dnetlib.openaire.exporter.model.dsm; import com.fasterxml.jackson.annotation.JsonAutoDetect; -- 2.17.1 From 785746a501e614db8e363b750315f3f903ef58f1 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 12 Apr 2023 10:36:44 +0200 Subject: [PATCH 6/6] removed invali line --- apps/dnet-exporter-api/src/main/resources/application.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/dnet-exporter-api/src/main/resources/application.properties b/apps/dnet-exporter-api/src/main/resources/application.properties index 340eb274..9d1b9961 100644 --- a/apps/dnet-exporter-api/src/main/resources/application.properties +++ b/apps/dnet-exporter-api/src/main/resources/application.properties @@ -22,7 +22,6 @@ management.endpoints.web.base-path = / management.endpoints.web.path-mapping.prometheus = metrics management.endpoints.web.path-mapping.health = health -apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java # ENABLE / DISABLE CONTROLLERS openaire.exporter.enable.dsm = true openaire.exporter.enable.community = true -- 2.17.1