Compare commits

..

250 Commits

Author SHA1 Message Date
Konstantinos Spyrou d1c3d48f7e Update src/main/java/eu/dnetlib/repo/manager/Application.java
Forgot solr import
2024-10-31 17:44:22 +01:00
Konstantinos Spyrou ada19c64b1 Update src/main/java/eu/dnetlib/repo/manager/Application.java
Excluded Solr autoconfiguration
2024-10-31 17:38:45 +01:00
Lampros Smyrnaios 17d0ac6c33 Merge pull request 'Resolve tickets 9114 and 9031' (#12) from develop into master
Reviewed-on: #12
2024-04-04 15:33:10 +02:00
Lampros Smyrnaios e4009b7903 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2024-04-04 16:16:31 +03:00
Lampros Smyrnaios 4f1e3a14d4 Fix conflicts in README. 2024-04-04 16:15:17 +03:00
Lampros Smyrnaios cb458553f0 - Update the "RepositoryServiceImpl.getCompatibilityClasses()" method to recognise additional "CRIS" modes.
- Catch exceptions thrown in "RepositoryServiceImpl.searchApi()".
- Code optimization.
- Update dependencies.
2024-04-03 14:59:43 +03:00
Lampros Smyrnaios c836de5761 Use the new DSM-2.0 API to obtain the "aggregation history" of a repository. 2024-03-22 11:51:22 +02:00
Lampros Smyrnaios 6dfe11484e - Add the Maven Central repository.
- Add/update/fix/cleanup dependencies.
- Add the "show-actuator"-config for springdoc.
- Remove obsolete configuration.
2024-03-15 13:58:38 +02:00
Lampros Smyrnaios 0deeb00ee5 - Replaced DSM's "AggregationInfo" with "CollectionInfoV2" in "eu.dnetlib.repo.manager.domain.AggregationInfo".
- Cleanup related dependencies.

Co-authored-by: Konstantinos Spyrou <spyroukon@gmail.com>
2024-03-13 18:20:45 +02:00
Lampros Smyrnaios b047caee26 Merge pull request 'Documentation cleanup.' (#11) from lsmyrnaios-patch-2 into master
Reviewed-on: #11
2024-03-11 12:27:21 +01:00
Lampros Smyrnaios 958e6b304e Documentation cleanup. 2024-03-11 12:26:30 +01:00
Antonis Lempesis 44610c172d Merge pull request 'Add/update documentation.' (#10) from lsmyrnaios-patch-1 into master
Reviewed-on: #10
2024-03-11 11:41:32 +01:00
Lampros Smyrnaios 547b3107a3 Add/update documentation. 2024-03-11 11:39:24 +01:00
Antonis Lempesis 4e7ba9d5cb Update 'README.md' 2024-03-11 10:51:15 +01:00
Antonis Lempesis 62aa87bd86 updated documentation 2024-03-11 10:50:21 +01:00
Lampros Smyrnaios 7853494a5b Remove obsolete paragraph. 2023-11-15 13:01:56 +02:00
Lampros Smyrnaios d1c336f4e7 Merge branch 'master' into develop 2023-11-14 18:50:30 +02:00
Lampros Smyrnaios 1c9ff0669a - Add information in the README, about the "Building", "Deployment", "Installation" and "Configuration" of the project.
- Eliminate a warning in the POM file, about a missing tag.
2023-11-14 18:45:45 +02:00
Antonis Lempesis cb8c68e8f9 Update 'README.md' 2023-11-14 15:25:37 +01:00
Antonis Lempesis 6f964e3d16 Update 'README.md' 2023-11-14 15:25:16 +01:00
Antonis Lempesis a673450f9c Update 'README.md' 2023-11-14 15:21:08 +01:00
Lampros Smyrnaios 224d058d89 Merge pull request 'merge master to develop' (#9) from master into develop
Reviewed-on: #9
2023-11-02 14:16:54 +01:00
Lampros Smyrnaios 91e0b66b28 Merge pull request 'Merge develop into master' (#6) from develop into master
Reviewed-on: #6
2023-11-02 14:05:14 +01:00
Lampros Smyrnaios c838f71227 merge from disable_compliance_failure_emails 2023-11-02 15:04:19 +02:00
Lampros Smyrnaios 0b8e4c4729 Update the Sushilite-R5 dependency from Nexus. 2023-11-02 14:39:10 +02:00
Lampros Smyrnaios a72c5b2fb8 - Update dependencies.
- Fix a file-extension in README.
2023-10-31 13:56:59 +02:00
Konstantinos Spyrou bd315848e0 fixed typo 2023-10-11 14:53:44 +03:00
Konstantinos Spyrou 4b5132358a created repository metrics calls and excluded them from authentication 2023-10-11 14:45:53 +03:00
Konstantinos Spyrou 39596cfcc1 added method to get if piwik is validated 2023-10-11 13:03:00 +03:00
Konstantinos Spyrou 5138605163 added method to get if piwik is validated 2023-10-11 13:00:48 +03:00
Lampros Smyrnaios 75e97ece26 Add info about the Swagger-UI-url in the README.md 2023-10-04 12:29:52 +03:00
TheQuaker 9da5fa5c1e Fix typo for DataType param 2023-09-29 15:36:55 +03:00
Lampros Smyrnaios 842468a175 Improve performance and error-handling in "InterfaceComplianceService.cleanUp()". 2023-09-27 12:24:22 +03:00
Lampros Smyrnaios 64fdff095d - Resolve a dependency-conflict.
- Update dependencies.
2023-09-25 15:01:31 +03:00
Lampros Smyrnaios 11460764a2 Merge pull request 'Disable sending emails about compliance failure.' (#5) from disable_compliance_failure_emails into master
Reviewed-on: #5
2023-07-24 12:47:31 +02:00
Lampros Smyrnaios 4e1f9cb965 Disable sending emails about compliance failure. 2023-07-24 13:45:24 +03:00
Lampros Smyrnaios 3cb8e7a5f6 - Update dependencies.
- Code polishing.
2023-07-05 13:16:48 +03:00
Lampros Smyrnaios eb42185991 - Update dependencies.
- Add notes for swagger-UI in README.
2023-06-06 19:27:02 +03:00
Lampros Smyrnaios a2a387be90 - Fix a security config for Swagger.
- Add the "displayRequestDuration" for "Try it out" requests in Swagger.
- Code polishing.
2023-06-02 14:23:54 +03:00
Lampros Smyrnaios dc469df9d6 Add JPA configuration. This fixes a missing Bean error. 2023-06-02 13:00:25 +03:00
Lampros Smyrnaios 8f6426eaf6 - Upgrade Spring and other dependencies.
- Migrate to SpringDoc, since SpringFox is dead.
2023-06-01 20:48:01 +03:00
Konstantinos Spyrou 6024e0c5b5 changed application type and replaced counters with gauges 2023-04-04 18:45:07 +03:00
Konstantinos Spyrou ab854a6624 changed application type and replaced counters with gauges 2023-04-04 18:43:48 +03:00
Lampros Smyrnaios 311442854a Add missing "sushiliteR5Endpoint" property. 2023-03-29 15:15:53 +03:00
Lampros Smyrnaios dfc4a4690e Update Json and Gson dependencies. 2023-03-29 12:11:19 +03:00
Lampros Smyrnaios 0ce67b6355 Avoid assigning an empty list, in case the "reportItems" is null, inside "SushiliteServiceImpl.getReportResults()". 2023-03-29 12:08:43 +03:00
Lampros Smyrnaios 54ebb35161 Detect the "504 Gateway Time-out" error from Sushilite-R5 and provide a mention to it, in the response-body. 2023-03-29 12:04:34 +03:00
Lampros Smyrnaios 97e85c2a75 Add suchilite-R5 support. 2023-03-28 15:08:20 +03:00
Lampros Smyrnaios 7cab17c133 Move Sushilite Service in its own package. Later, additional Sushilite Services will be added. 2023-03-22 13:35:20 +02:00
Lampros Smyrnaios d2973871a8 Inform the developer about the possibility of a "RestClientException" being thrown by various methods of "HttpUtils" and "RegistryCalls" classes. 2023-03-08 15:26:26 +02:00
Lampros Smyrnaios a0fd5f67a7 Fix the "NoSuchBeanDefinitionException: No bean named 'transactionManager' available", when trying to run the scheduled task -during initialization- for assigning pending user roles. 2023-03-08 13:57:29 +02:00
Lampros Smyrnaios 59fc344730 - Use the production AAI url, as the "beta" one has issues.
- Polish the application.yml
2023-03-02 16:15:54 +02:00
Antonis Lempesis 85f3d1c9dc Merge pull request 'reposByCountry' (#4) from reposByCountry into master
Reviewed-on: #4
2023-03-02 14:05:51 +01:00
Lampros Smyrnaios fe1a398773 - Show error-messages for Broker's errors.
- Code polishing.
2023-03-02 15:03:30 +02:00
Lampros Smyrnaios 3684f09970 Update application.yml 2023-03-02 15:03:06 +02:00
Lampros Smyrnaios 19fcda5ae1 Update the "getRepositoriesByCountry"-endpoint to return up to 10_000 repositories. 2023-03-02 15:02:52 +02:00
Konstantinos Spyrou e9fedc90d4 experimental: temp save role if assign fails 2023-02-17 20:40:51 +02:00
Konstantinos Spyrou 0ad86025b3 throw error when assigning role to a user who is not found in the aai registry 2023-02-17 17:35:18 +02:00
Konstantinos Spyrou bae9a132cb Merge branch 'develop' of code-repo.d4science.org:MaDgIK/uoa-repository-manager-service into develop 2023-02-17 16:17:56 +02:00
Konstantinos Spyrou b67e98976d Improved role functionality 2023-02-17 16:17:37 +02:00
Lampros Smyrnaios c006c7baa0 - Show error-messages for Broker's errors.
- Code polishing.
2023-02-15 18:31:13 +02:00
Lampros Smyrnaios 8f5aed3aab Update application.yml 2023-02-15 18:03:20 +02:00
Lampros Smyrnaios 0f0163dc2d Update the "getRepositoriesByCountry"-endpoint to return up to 10_000 repositories. 2023-02-15 17:14:02 +02:00
Antonis Lempesis 6041bb8f1f Add 'LICENSE.txt' 2023-02-14 20:39:36 +01:00
Konstantinos Spyrou 401de371b2 Merge branch 'develop' 2023-02-08 12:15:12 +02:00
Konstantinos Spyrou ccf826ee42 Merge branch 'master' of code-repo.d4science.org:MaDgIK/uoa-repository-manager-service 2023-02-08 12:14:57 +02:00
Konstantinos Spyrou 9ad28a2640 merge branch new_registry 2023-02-08 10:21:02 +02:00
Lampros Smyrnaios 06cea537bf Improve performance of "DashboardController.getCollectionMonitorSummary()"-endpoint.
Now, a single "getRepositoryAggregations"-call is made, which results in just one "DSM-aggregationhistory"-api-call. Previously, multiple api-calls where made, each requesting the whole "aggregationhistory"-data and then trimming it down to only a few results.
2023-02-03 14:19:43 +02:00
Lampros Smyrnaios c1abaad3e1 - Show a warning when the "indexedVersion" was not found in "DashboardServiceImpl.getRepositoriesSummaryInfo()".
- Code optimization and polishing.
2023-02-02 18:54:46 +02:00
Lampros Smyrnaios 3845a5103b - Fix a performance bug in "DashboardController.getCollectionMonitorSummary()", where the code for the "isIndexedVersion"-check, was re-checking 20 of the already-checked "aggregationInfo"-objects, in each new batch.
- Update some properties.
- Code polishing.
2023-02-02 18:47:04 +02:00
Lampros Smyrnaios 8bf0f76ad6 - Improve performance of "ValidatorController.getRuleSet()" endpoint.
- Improve exception-handling.
- Replace deprecated method-calls.
- Code polishing.
2023-01-31 16:57:37 +02:00
Lampros Smyrnaios a239164f97 - Ensure the "BufferedReader" and the "InputStream" get always closed in the end, in "Converter.readFile()".
- Code polishing.
2023-01-31 15:40:06 +02:00
Konstantinos Spyrou c2e5af87e8 changes in mail content 2023-01-31 15:26:19 +02:00
Konstantinos Spyrou 19923c19fc refactoring 2023-01-31 14:51:34 +02:00
Konstantinos Spyrou 1a3399f7d7 changed level in verbose logs 2023-01-31 14:35:48 +02:00
Konstantinos Spyrou fdd597cf02 changed 'validation set' to 'set' and 'guidelines' to 'selected guidelines' in message bodies 2023-01-31 12:25:41 +02:00
Konstantinos Spyrou 60f8c8cb82 use Compatibility Override field 2023-01-31 12:11:41 +02:00
Konstantinos Spyrou 699b45d62f Missed 3 methods in previous commit. Needs heavy refactoring.. 2023-01-30 20:04:11 +02:00
Konstantinos Spyrou 287f476bd2 messages sent to 'registeredBy' email are now sent to the currently authenticated user as well 2023-01-30 19:49:33 +02:00
Konstantinos Spyrou d3bcea79c0 Changes:
1. refactored method signatures
2. used desired compatibility level for 'Guidelines' field in emails
3. enabled async error logs
2023-01-30 18:56:34 +02:00
Lampros Smyrnaios de2ac5631f Fix return object of "getUrlsOfUserRepos" endpoint. 2023-01-30 16:25:21 +02:00
Lampros Smyrnaios 97d81ce478 - Add missing repositories in pom.xml.
- Update README.md
2023-01-30 15:31:06 +02:00
Lampros Smyrnaios b9cde0f1a9 Fix "SolrServerException: Server refused connection", during startup. 2023-01-30 13:44:15 +02:00
Lampros Smyrnaios 40aae5d750 Adjust logging-levels. 2023-01-25 14:05:30 +02:00
Konstantinos Spyrou 8c07950459 Merge pull request 'develop' (#3) from develop into master
Reviewed-on: #3
2023-01-23 17:36:04 +01:00
Konstantinos Spyrou 9e4817f2bd refactoring 2023-01-23 18:26:19 +02:00
Konstantinos Spyrou 4231480cbc disabled delete on interfaces 2023-01-23 17:57:44 +02:00
Konstantinos Spyrou 33694d17c1 disabled delete on interfaces 2023-01-23 17:57:18 +02:00
Konstantinos Spyrou 0aa604a192 refactoring 2023-01-23 17:54:51 +02:00
Konstantinos Spyrou caa1f1244a refactoring 2023-01-23 17:45:35 +02:00
Konstantinos Spyrou 63b99ea68e base url can be altered only if existing is null or empty 2023-01-20 19:19:02 +02:00
Konstantinos Spyrou ab03a5164d base url can be altered only if existing is null or empty 2023-01-20 19:17:06 +02:00
Konstantinos Spyrou 607c417e3f get all ids of user using email in registry 2023-01-20 19:15:59 +02:00
Konstantinos Spyrou aeca9ce38b Merge pull request 'check if CouId is null' (#2) from develop into master
Reviewed-on: #2
2023-01-19 14:40:37 +01:00
Antonis Lempesis 242014f2da Merge pull request 'develop' (#1) from develop into master
Reviewed-on: #1
2023-01-19 12:41:44 +01:00
Konstantinos Spyrou 7b7c6b0842 check if CouId is null 2023-01-19 13:41:37 +02:00
Konstantinos Spyrou 125b64ec3b check if CouId is null 2023-01-19 13:41:11 +02:00
Konstantinos Spyrou 415bb1e197 fixed conflict 2023-01-19 13:09:52 +02:00
Konstantinos Spyrou 95335461a2 getRolesWithStatus does not return null 2023-01-19 13:08:03 +02:00
Konstantinos Spyrou f88d9b8381 fixed deserialization issue caused from json to String 2023-01-19 12:29:12 +02:00
Konstantinos Spyrou cda2cd5557 fixed deserialization issue caused from json to String 2023-01-19 12:28:31 +02:00
Konstantinos Spyrou 0674a3c031 fixed null pointer exception 2023-01-19 12:16:42 +02:00
Konstantinos Spyrou 0ea91e909d Merge branch 'develop' of code-repo.d4science.org:MaDgIK/uoa-repository-manager-service into develop 2023-01-19 12:15:41 +02:00
Konstantinos Spyrou d5327aedea fixed null pointer exception 2023-01-19 12:15:30 +02:00
Konstantinos Spyrou 7c5020c205 update user roles using identifier instead of email 2023-01-18 16:54:18 +02:00
Lampros Smyrnaios df14f5eaab - Update a "URLEncoder.encode()" call, to reduce the ambiguity which comes with the platform's default encoding.
- Update a deprecated MediaType.
- Fix an ambiguous unicode character.
2023-01-17 20:21:00 +02:00
Konstantinos Spyrou e4d52c2323 refactoring project structure 2023-01-17 18:23:59 +02:00
Konstantinos Spyrou 139fb420d4 removed empty class 2023-01-17 18:21:20 +02:00
Konstantinos Spyrou 60ff3dce6e changes for new aai registry 2023-01-17 18:20:41 +02:00
Konstantinos Spyrou 40b20b1122 added LIMIT 1 when retrieving piwik site to avoid problems with existing duplicates in db 2023-01-17 17:56:18 +02:00
Konstantinos Spyrou 49cc3d74e8 fixed content type missmatch error when converting response from json to string in method getRepositoriesByCountry 2023-01-17 16:57:14 +02:00
Konstantinos Spyrou e551a7a783 replaced manual configuration with automatic 2023-01-17 16:53:37 +02:00
Konstantinos Spyrou 788dac69ad added tests for InterfaceComplianceRequest 2023-01-17 15:50:43 +02:00
Konstantinos Spyrou b1e1185765 fixed condition 2023-01-17 13:49:00 +02:00
Konstantinos Spyrou 817446df41 Created the functionality to alter an interface's compliance after its successful validation 2023-01-16 20:30:09 +02:00
Konstantinos Spyrou 87f610b06b merge conflict 2023-01-13 18:11:41 +02:00
Konstantinos Spyrou e947fe3fec 1. removed exceptions from emails
2. changed update repository interface
3. wip: after validation completes change interface compliance
2023-01-13 18:06:30 +02:00
Lampros Smyrnaios 96003f9f88 Optimize imports. 2023-01-13 12:55:15 +02:00
Lampros Smyrnaios d4e4624a3f Merge branch 'develop' of https://code-repo.d4science.org/MaDgIK/uoa-repository-manager-service into develop
# Conflicts:
#	src/main/java/eu/dnetlib/repo/manager/service/security/AuthoritiesMapper.java
#	src/main/java/eu/dnetlib/repo/manager/service/security/AuthoritiesUpdater.java
2023-01-13 12:22:28 +02:00
Lampros Smyrnaios eaa4083b04 - Code optimization and polishing.
- Improve error-checking and exception-handling.
2023-01-13 12:20:06 +02:00
Lampros Smyrnaios f136488b0e Improve performance by pre-compiling the regexes. 2023-01-12 19:23:42 +02:00
Konstantinos Spyrou 720ee5a9a4 fix: savePiwikInfo no longer creates duplicates 2023-01-12 16:38:29 +02:00
Konstantinos Spyrou 4dd0320255 removed script 2023-01-12 14:32:06 +02:00
Konstantinos Spyrou af0482a9fb Merge branch 'develop' of code-repo.d4science.org:MaDgIK/uoa-repository-manager-service into develop 2023-01-12 14:23:57 +02:00
Konstantinos Spyrou 830df7cb52 1. use sub for session instead of email 2. minor refactoring 2023-01-12 14:16:27 +02:00
Konstantinos Spyrou d8eac0ac10 replaced log4j2 with slf4j 2023-01-11 18:50:31 +02:00
Lampros Smyrnaios ceb53248ce Fix merge-commit, missing the improvement introduced in commit: 63c9caaf96 2022-12-21 13:44:58 +02:00
Konstantinos Spyrou 4850581c53 merge commit 2022-12-20 20:53:54 +02:00
Konstantinos Spyrou a5a4924c08 chenged methods retrieving AggregationInfo 2022-12-20 20:40:37 +02:00
Konstantinos Spyrou 6c2780927d changed objectMapper and restTemplate configuration 2022-12-20 20:27:13 +02:00
Lampros Smyrnaios 63c9caaf96 Improve performance of "AggregationServiceImpl.createYearMap()". 2022-12-14 17:12:27 +02:00
Lampros Smyrnaios a40c1b3e44 - Move all the Aggregation-related code from "RepositoryService" into the new "AggregationService".
- Add info about the thrown exceptions.
2022-12-14 17:09:38 +02:00
Lampros Smyrnaios 1a4df2b852 - Add "README.md"
- Code polishing.
2022-12-14 16:33:12 +02:00
Lampros Smyrnaios deae3b8b54 - Add error-checking and improve exceptions handling.
- Code polishing.
2022-12-07 13:37:55 +02:00
Lampros Smyrnaios f720446bdf Remove the obsolete "AggregationDetails" code and rename the related variables (which have already changed types). 2022-12-01 18:37:03 +02:00
Lampros Smyrnaios db88b2eecb Optimize imports. 2022-12-01 15:19:29 +02:00
Lampros Smyrnaios 4a32d0278b - Update the application.yml, which fixes runtime errors.
- Update the installAndRun.sh, to be able to only build the project (if desired to only produce the JAR), and also to handle errors better.
2022-12-01 14:56:52 +02:00
Konstantinos Spyrou b3758da868 replaced AggregationDetails with AggregationInfo class 2022-11-30 20:58:08 +02:00
Konstantinos Spyrou a792fd34c1 removed unnecessary operations 2022-11-30 17:33:09 +02:00
Lampros Smyrnaios 36b17e4ef1 Refactor the "Statistics" code:
- Merge the Aggregators' code inside "StatsServiceImpl.java".
 - Remove the Hystrix related code, since it wasn't really used.
- Add exceptions-handling and error-checking.
2022-11-30 13:03:17 +02:00
Konstantinos Spyrou 01ba340f47 created paging for searchRegisteredRepositories - temporarily inactive 2022-11-24 18:36:37 +02:00
Konstantinos Spyrou b533355c4f set log level to info 2022-11-24 18:33:40 +02:00
Konstantinos Spyrou 33d28cefc1 all registered users can perform validations 2022-11-24 18:33:21 +02:00
Konstantinos Spyrou c09cbbbcc0 created basic .gitignore 2022-11-24 15:58:30 +02:00
Konstantinos Spyrou 6a5c637f51 reformatted file 2022-11-24 15:55:09 +02:00
Lampros Smyrnaios 96d8ba8dde Fix url in application.yml 2022-11-23 18:49:35 +02:00
Lampros Smyrnaios dbe13a7ed1 - Fix memory leak.
- Add code's line-numbers in the logs.
2022-11-18 12:21:56 +02:00
Lampros Smyrnaios 83c77670ab Improve the "installAndRun.sh" script:
- Add the "java -jar" run command.
- Add more sanity checks for cmd-args.
- Code polishing.
2022-11-17 15:01:27 +02:00
Konstantinos Spyrou f41a5c8985 fixed prometheus test 2022-11-16 16:33:42 +02:00
Lampros Smyrnaios 83f9ce36ce Add a script to install and run the app.
(some missing dependencies will be deployed on a public repo soon)
2022-11-16 16:20:58 +02:00
Konstantinos Spyrou e99f334708 1. removed registeredBy from add/update interface controllers
2. changed authorization expression for interface validation
2022-11-10 17:34:23 +00:00
Konstantinos Spyrou cff16a2d7c refactored mails 2022-11-09 16:16:54 +00:00
Konstantinos Spyrou ee01491995 1. fixed auth expression when updating a repository
2. filter out ftp interfaces
2022-11-08 18:37:51 +00:00
Konstantinos Spyrou 1491d8e280 fixed remaining spel expressions 2022-11-03 12:35:05 +00:00
Konstantinos Spyrou 82cf64a3e3 fixed null equality in spel expression 2022-11-03 11:09:12 +00:00
Konstantinos Spyrou 0b322c87d6 fixed auth expression 2022-11-01 12:08:42 +00:00
Konstantinos Spyrou 0f73e95209 filter out only sword and rest 2022-10-10 16:04:06 +00:00
Antonis Lempesis 9ca8aed160 ignoring non aoi interfaces 2022-10-10 11:27:28 +00:00
Konstantinos Spyrou 9633710cec quick fix for Journal registration. Removed ValidationException and replaced with log. Should be revisited. 2022-10-06 10:29:21 +00:00
Konstantinos Spyrou a46e64f5b5 added date in logs 2022-09-07 13:49:23 +00:00
Konstantinos Spyrou 3c41f3206a fixed getting accessSets and accessFormats 2022-09-07 13:29:04 +00:00
Konstantinos Spyrou 0590efba9a CompatibilityClasses fix 2022-09-06 13:55:05 +00:00
Konstantinos Spyrou 2afd3ef412 fixed re3data lastCollectionDate 2022-08-05 13:24:32 +00:00
Konstantinos Spyrou c7b7d37ae3 svn merge -r62311:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/uoa-repository-manager-service/branches/new-datasource-model . 2022-08-05 08:48:16 +00:00
Konstantinos Spyrou 2a8294a958 reintroduced typology field 2022-07-22 10:34:26 +00:00
Antonis Lempesis d3f13fc8c2 correctly passing the repo id... 2022-06-02 13:18:04 +00:00
Antonis Lempesis d57782444d avoiding an OutOfBounds exception 2022-06-02 08:42:08 +00:00
Antonis Lempesis a61b259ca3 getting aggregations uising the correct dsm api method 2022-05-24 14:01:08 +00:00
Konstantinos Spyrou 94a8b1abf9 update lastConsentTermsOfUseDate instead of consentTermsOfUseDate 2022-05-24 09:15:52 +00:00
Konstantinos Spyrou 03dad9cb1e added lastConsentTermsOfUseDate 2022-05-24 08:28:39 +00:00
Konstantinos Spyrou bd31f55685 cris repository registration functionality 2022-04-20 10:26:28 +00:00
Konstantinos Spyrou 982d299b2d repository terms functionality 2022-03-15 11:33:49 +00:00
Antonis Lempesis 2a57236c9a removed basic hhtp authentication 2021-11-05 08:54:20 +00:00
Antonis Lempesis 9d38d86c03 merged properties branch 2021-10-26 11:46:08 +00:00
Antonis Lempesis b5f1c113c6 merged branch springboot - 61629:HEAD 2021-10-22 11:32:44 +00:00
Konstantinos Spyrou 746f3bbfbe created method to retrieve total registered datasources and added an entry in prometheus metrics 2021-10-12 13:30:38 +00:00
Konstantinos Spyrou 03e0b8f472 changed prometheus metrics names 2021-10-12 10:16:37 +00:00
Konstantinos Spyrou 1b6ca905da replaced hasAnyRole with hasAnyAuthority 2021-07-28 12:28:58 +00:00
Konstantinos Spyrou 4d7f3d7a64 fixed dependency version 2021-07-26 11:56:28 +00:00
Konstantinos Spyrou 500c379b8c created prometheus reports and /metrics 2021-07-26 11:34:42 +00:00
Konstantinos Spyrou 84df31c87a enabled emails 2021-07-22 13:52:50 +00:00
Antonis Lempesis 9e967cab33 using md5 instead of base64 encoding for new aggregator ids 2021-07-22 10:55:27 +00:00
Antonis Lempesis e603487103 merged branch aai_roles_new to trunk 2021-07-21 11:51:18 +00:00
Antonis Lempesis 25ff488405 returning fair guidelines as such 2021-04-16 08:16:09 +00:00
Antonis Lempesis a8143fe775 code cleanup 2021-04-05 10:35:28 +00:00
Antonis Lempesis fca5ada4c0 removed unnecessary dep to spring boot 2021-04-02 16:01:25 +00:00
Antonis Lempesis b19f53bf80 deleting angular app... 2021-03-30 12:24:40 +00:00
Antonis Koulalis 7b4fe01122 2021-03-10 16:17:49 +00:00
Antonis Lempesis 6d6b70f87b Correctly checking return type of POST method 2020-10-14 09:20:46 +00:00
Antonis Lempesis 2fbf8478d7 Fixed the comment sending code in EmailUtilsImpl 2020-10-01 10:58:31 +00:00
Ioannis Diplas 13fcb34fb6 Excluding dependency to conflicting validation version 2020-09-04 11:47:10 +00:00
Antonis Lempesis c2743a9420 using the new broker model 2020-09-03 09:51:52 +00:00
Antonis Lempesis 282b0b0d53 added the option to send emails to users 2020-07-30 11:49:24 +00:00
Antonis Lempesis 2e9657cb61 added the option to send emails to users 2020-07-29 11:35:35 +00:00
Antonis Lempesis b91330455d added extra logs 2020-06-05 08:39:43 +00:00
Antonis Lempesis ae95e76fbf opening /stats to all 2020-05-15 08:09:38 +00:00
Konstantinos Spyrou 984dd28d19 set description to jobResultEntry for cris 2020-03-26 19:23:08 +00:00
Konstantinos Spyrou fdc6a46bff updated cris rule results methods 2020-03-26 17:35:55 +00:00
Konstantinos Spyrou c0cbbbe9ef changes for cris validation 2020-03-18 22:39:25 +00:00
Ioannis Diplas 777d87c564 stats no longer require authentication 2020-03-16 23:20:55 +00:00
Antonis Lempesis 5a5742978f authentication changes 2020-03-10 12:04:59 +00:00
Ioannis Diplas 62c228ca42 Bug fix for CRIS reSubmition 2020-01-10 14:04:41 +00:00
Ioannis Diplas e33df7fe42 Clearing unnecessary "user" variables 2020-01-10 12:56:27 +00:00
Ioannis Diplas 4b6eb60fd7 changing properties file to beta 2019-12-18 13:30:58 +00:00
Stefania Martziou 61fec177ef More thorought implementation for the email notifications when registering/updating repositories 2019-12-18 13:11:36 +00:00
Ioannis Diplas 6edd5ffca7 Replacing XML with Java configuration 2019-12-18 11:09:03 +00:00
Ioannis Diplas bf0bdf50c1 New mapping for RepositorySnippet + Using SecurityContext to get the email of user 2019-12-18 10:04:22 +00:00
Ioannis Diplas 33e3975de3 Changing context of sendAdministratorRequestToEnableMetrics email 2019-12-16 14:13:33 +00:00
Ioannis Diplas 763285fdac Using RepositorySnippet for getDatasourcesOfUser 2019-12-16 12:43:08 +00:00
Ioannis Diplas b78350ec83 Fixing imports 2019-12-16 10:54:06 +00:00
Ioannis Diplas ebd68aa2c3 Using new function for getRepositoriesOfUser, now retuning repository snippet 2019-12-13 13:40:55 +00:00
Ioannis Diplas 192ba92c1e Fixing a logging issue 2019-12-03 09:33:55 +00:00
Ioannis Diplas 35acc1f3b9 Fixing a bug for null contentRules 2019-12-02 11:16:48 +00:00
Ioannis Diplas 0d60114c78 Bug fix for Security Expressions 2019-11-29 10:17:16 +00:00
Ioannis Diplas 1590f44b9f Bug fix 2019-11-29 09:58:55 +00:00
Ioannis Diplas 5430cca2b7 Changing Security Expression for getOpenaireId 2019-11-29 09:55:23 +00:00
Ioannis Diplas 13717263e6 Adding Security expression for getOpenAireId 2019-11-28 13:43:43 +00:00
Ioannis Diplas b94d136cfa Updating interfaces to not include IsSerializable 2019-11-28 11:25:56 +00:00
Antonis Lempesis 1fbfaa454f merged branch cris r57561-HEAD 2019-11-20 13:03:40 +00:00
Ioannis Diplas df23be95ae String comparison for NULL equity 2019-11-08 12:56:47 +00:00
Antonis Lempesis 02a532e2d1 fixed the piwik id identity 2019-11-07 09:45:58 +00:00
Ioannis Diplas c9d94fa4ab Changed security expressions to include the case that registeredBy is null 2019-10-29 10:16:13 +00:00
Ioannis Diplas 530aac4540 Moved permissions at the controller level 2019-10-11 11:53:48 +00:00
Ioannis Diplas dfcd57129f Adding job summary 2019-10-01 11:07:47 +00:00
Ioannis Diplas ca5651e630 Pushing fixes on summaries 2019-09-27 11:29:40 +00:00
Ioannis Diplas 9bc44f8f97 Usage summary custom return object with PiwikInfo and MetricsInfo 2019-09-27 09:46:21 +00:00
Ioannis Diplas 8f1e214a6b Implementing summaries for collection, usage and broker 2019-09-26 11:09:24 +00:00
Ioannis Diplas 61e7696832 fixing from & quantity values for export-to-csv functionality 2019-09-04 12:21:53 +00:00
Antonis Lempesis 835f973caf Added list of publications to events 2019-09-02 15:54:22 +00:00
Ioannis Diplas c94259da40 fixing from & quantity values for export-to-csv functionality 2019-08-30 09:02:38 +00:00
Ioannis Diplas ec3bfd1eaf Changing export-to-csv to return all the Piwik results 2019-08-30 08:33:13 +00:00
Antonis Lempesis 1f7a25d184 Checking if repository has a piwik site before creating an identity for it 2019-08-26 12:48:40 +00:00
Ioannis Diplas 7e21cdc153 When search field is applied, we count the total rows with this filter on 2019-08-01 11:55:17 +00:00
Ioannis Diplas ddf7152123 Cleaning up the code 2019-07-25 12:58:01 +00:00
Ioannis Diplas 8b1ad0b920 Triggering validation job from provide on Interface Update and Interface Add 2019-07-25 11:54:21 +00:00
Ioannis Diplas fa94488f3f Changed typo for descending order ENUM 2019-07-24 11:54:17 +00:00
Ioannis Diplas 5cc055f7c1 Changed typo for descending order ENUM 2019-07-24 11:35:09 +00:00
Ioannis Diplas 5f23a071f0 Fixing naming for csv 2019-07-23 09:47:20 +00:00
Ioannis Diplas be2b3f15fb Now exporting to csv 2019-07-23 09:39:08 +00:00
Ioannis Diplas 16b7099e75 Adding totals to final array 2019-07-23 08:07:39 +00:00
Ioannis Diplas aaf2677c11 Updated swagger info 2019-07-23 07:47:39 +00:00
Ioannis Diplas 9d332bd962 - Fixing some code-smells
- Implemented search of piwik repos
- Added site_id info on repository
2019-07-22 13:00:51 +00:00
Antonis Lempesis ed247a82f3 Merged dev-api branch to trunk. merge -r54925:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/uoa-repository-manager-service/branches/dev-api 2019-07-19 09:31:23 +00:00
Panagiotis Kanakakis 368538ddd4 UTF8 bug fix 2019-03-21 13:13:28 +00:00
Panagiotis Kanakakis 4bf9657682 Bug fix on repository service 2019-03-19 13:48:39 +00:00
Panagiotis Kanakakis ef1f000e5b Merge with dev branch 2019-02-28 12:37:38 +00:00
Panagiotis Kanakakis 2a24630a1d Delete wrong commited files 2019-02-16 10:47:48 +00:00
Panagiotis Kanakakis ef441e826c Meerge dev-api to trunk ( -r50861:54841 ) 2019-02-16 10:04:41 +00:00
Antonis Lempesis 5038a00b8b added jemnkins deploy info 2018-02-23 13:31:06 +00:00
Panagiotis Kanakakis ab23c7232f Moving branch folders to trunk. 2018-02-22 11:23:56 +00:00
184 changed files with 8730 additions and 4758 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore directories
.idea
target

View File

@ -1,9 +1,10 @@
FROM tomcat:7.0.90-jre8
#FROM tomcat:7.0.90-jre8
FROM tomcat:8.5.71-jre8-openjdk-bullseye
MAINTAINER "pkanakakis@di.uoa.gr"
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
COPY src/main/resources/application.properties /usr/local/tomcat/lib/dnet-override.properties
COPY validator.env /usr/local/tomcat/lib/dnet-override.properties
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/

176
LICENSE.txt Normal file
View File

@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

218
README.md Normal file
View File

@ -0,0 +1,218 @@
# OpenAIRE Provide - backend service
## Introduction
OpenAIRE PROVIDE is the content gateway service of OpenAIRE, where data providers are invited to connect scholarly content with OpenAIRE.<br>
OpenAIRE PROVIDE allows repositories, data archives, journals, aggregators, CRIS systems, to enter the OpenAIRE and European Open Science (EOSC) ecosystem and be accessible by millions of researchers, research institutes and networks, research funders, policy makers and citizens.<br>
OpenAIRE PROVIDE lowers any technological barriers, by supporting a series of integrations, therefore, enabling its users to visually access OpenAIRE's services that are responsible for the data harvesting process.
<br><br>
There are four distinctive steps from the initial express of interest for OpenAIRE PROVIDE to the actual content availability on OpenAIRE and EOSC.
<br>
The steps indicate the important subservices of OpenAIRE that perform the following functionalities:
- Validation of data sources with the OpenAIRE guidelines (via the OpenAIRE Validator)
- Registration of data sources to OpenAIRE and global interlinked networks provides links to content for text and data mining, view history of validations, status of harvesting Enrichment of metadata information that describes the data sources to be available through OpenAIRE.
- Subscribe and view/receive notifications to enrich the metadata or the content of the data source (via the OpenAIRE Broker)
- View usage statistics of Open research impact by subscribing to the OpenAIRE UsageCounts service; view aggregated, cleaned usage stats for repository access and broaden your mechanisms for impact assessment.
<br>
## Architecture
[...]
<br>
## Building
The backend is a [Maven](https://maven.apache.org/index.html) project. It has been tested using Java 8.
<br>
#### Manual Build Instructions
###### Requirements:
- Java 8
- Apache Maven 3+
###### Build Instructions:
1. Clone the repository and move inside the directory
<br> `git clone https://code-repo.d4science.org/MaDgIK/uoa-repository-manager-service.git && cd uoa-repository-manager-service`
2. Provide all not-set or redacted configurations, inside the **src/main/resources/application.yml** file.
3. Build Maven project
<br> `mvn clean package`
<br> Produces the file "./target/**uoa-repository-manager-service.jar**" which can be run with: - Run the app with: `java -jar ./target/uoa-repository-manager-service.jar`
#### Build using Docker
The repository contains a **Dockerfile** which can be used to build an image containing the compiled project.
###### Requirements:
- Docker
###### Build Instructions:
1. Clone the repository and move inside the directory
<br> `git clone https://code-repo.d4science.org/MaDgIK/uoa-repository-manager-service.git && cd uoa-repository-manager-service`
2. Provide all not-set or redacted configurations, inside the **src/main/resources/application.yml** file.
3. Build Docker image
<br> `docker build . -t <docker-image-name>`
<br>
## Configuration
The configuration can be set inside the **src/main/resources/application.yml** file.
### Server-related configuration.
```
server:
port: 8480
servlet:
context-path: /uoa-repository-manager-service
```
### Swagger UI - related configuration
```
springdoc:
swagger-ui:
disable-swagger-default-url: true
path: /swagger-ui.html
displayRequestDuration: true
api-docs:
path: /api-docs
```
### Datasource -related configuration
```
spring:
jpa:
hibernate:
ddl-auto: update
datasource:
url: ${services.provide.db.url}
username: ${services.provide.db.username}
password: ${services.provide.db.password}
driverClassName: ${services.provide.db.driverClassName}
```
### Configurations about the provide service.
```
services:
openaireServicesBaseUrl: https://beta.services.openaire.eu
provide:
dev-machine: 88.197.53.71 # VM-71
```
### Configuration about Authentication and authorization infrastructure (AAI).
```
aai:
baseURL: https://aai.openaire.eu
oidc:
domain: .openaire.eu # use empty value for local, otherwise: ".openaire.eu"
id: XX
issuer: ${services.provide.aai.baseURL}/oidc/
redirectURL: http://localhost:${server.port}${server.servlet.context-path}/openid_connect_login
secret: XX
webURL: http://localhost:4200/join
registry:
coid: XX
username: XX
password: XX
production: false
url: ${services.provide.aai.baseURL}/registry/
```
### Broker's configuration
```
broker:
api: api/
openaire: openaireBroker
port: 443
url: https://beta.broker.openaire.eu
```
### Client's configuration
```
clients:
dsm: ${services.provide.baseUrl}
search: ${services.openaireServicesBaseUrl}/search/v2/api
usageEvents: http://beta.lbs.openaire.eu:8080/ajax/summary
usagestats: ${services.openaireServicesBaseUrl}/usagestats
```
### Database configuration for Provide.
```
db:
driverClassName: org.postgresql.Driver
password: dnetPwd
url: jdbc:postgresql://${services.provide.dev-machine}:5432/repomanager
username: dnet
```
### Configuration for the IS LookUp service.
```
iSLookUpService:
url: https://dev-openaire.d4science.org:443/is/services/isLookUp
```
### Mail-server configuration.
```
mail:
authenticate: true
debug: false
from: XX
host: smtp.gmail.com
mode: ssl
password: XX
port: 465
replyTo: XX
username: XX
```
### Redis's configuration
```
redis:
host: vereniki.athenarc.gr
password: XX
port: 6379
```
### Usage statistics
```
usageStatisticsDiagramsBaseURL: https://beta.openaire.eu/stats3/
usageStatisticsNumbersBaseURL: ${services.openaireServicesBaseUrl}/usagestats/datasources/
usagestats:
adminEmail: XX
sushiliteEndpoint: ${services.openaireServicesBaseUrl}/usagestats/sushilite/
sushiliteR5Endpoint: ${services.openaireServicesBaseUrl}/usagestats_r5/sushilite/r5/
```
### Validator - related configuration.
```
validator:
results:
url: https://beta.provide.openaire.eu/compatibility/browseHistory/
validatorService:
url: http://${services.provide.dev-machine}:8080/uoa-validator-service/services/validatorWebService
```
### Miscellaneous
```
topic_types:
url: ${services.openaireServicesBaseUrl}/provision/mvc/vocabularies/dnet:topic_types.json
adminEmail: XX
analyticsURL: https://analytics.openaire.eu/addsite.php?
baseUrl: ${services.openaireServicesBaseUrl}/openaire
```
<br>
## Deployment
### Prerequisites
* install [PostgreSQL 9.5+](https://www.postgresql.org/)
* Run the app with: `java -jar ./target/uoa-repository-manager-service.jar --spring.config.location=application.yml`
<br>
## misc
### Notes for Swagger-UI:
- Access it through this url: http://localhost:8480/uoa-repository-manager-service/swagger-ui/index.html
- In order to request data from most endpoints, you have to be a "REGISTERED_USER", otherwise you will get a 403 error code.
- In order to be a registered user, you have to run the [UI-service](https://code-repo.d4science.org/MaDgIK/uoa-repository-manager-ui) , in the same machine, at the same time and login through a browser, using the following url: http://localhost:8480/uoa-repository-manager-service/openid_connect_login

560
pom.xml
View File

@ -4,101 +4,187 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet45-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath></relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-repository-manager-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<spring.boot.version>2.7.18</spring.boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>(1.2, 1.5]</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-runtime</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
</dependency>
<dependency>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-exporter-model</artifactId>
<version>[3.5.1, )</version>
<exclusions>
<exclusion>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus -->
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-utils</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.12.4</version>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-domain</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-commons</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-clients</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-runtime</artifactId>
<version>1.0.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-hcm</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite-r5</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-openaire-broker-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.16.0</version>
</dependency>
<dependency>
@ -106,107 +192,58 @@
<artifactId>oai4j</artifactId>
<version>[0.6b1,)</version>
</dependency>
<!-- TODO - Do we need this? -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
<version>2.7.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.3</version>
<version>2.42</version>
</dependency>
<!-- TODO - Do we need this? We already have: "com.google.code.gson:gson" -->
<dependency>
<groupId>org.aksw.gson</groupId>
<artifactId>gson-utils-core</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20080701</version>
<version>20240303</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
<version>1.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
<!--<dependency>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>1.29.366</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
<dependency>
<groupId>postgresql</groupId>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>LATEST</version>
<version>42.7.3</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>LATEST</version>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-client</artifactId>
<version>1.3.0</version>
<version>1.3.4</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@ -214,156 +251,136 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>1.3.1.RELEASE</version>
<type>pom</type>
<version>2.7.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
<version>${jedis.version}</version> <!-- This property comes from the parent-pom. -->
<!--<version>3.7.0</version>-->
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.5</version>
<version>3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.1.5.RELEASE</version>
<groupId>org.eurocris</groupId>
<artifactId>openaire-cris-validator</artifactId>
<version>1.0.1-SNAPSHOT</version>
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-1.2-api</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1-rev-1</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-bom</artifactId>
<version>2021.2.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
-->
<!--<plugin>-->
<!--<groupId>com.googlecode.maven-download-plugin</groupId>-->
<!--<artifactId>download-maven-plugin</artifactId>-->
<!--<version>1.3.0</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>process-resources</phase>-->
<!--<goals>-->
<!--<goal>wget</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<url>-->
<!--https://github.com/ostranme/swagger-ui-themes/archive/v3.0.0.zip-->
<!--</url>-->
<!--<unpack>true</unpack>-->
<!--<outputDirectory>${project.build.directory}</outputDirectory>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<sequential>
<echo>Add theme</echo>
<replace token="&lt;/head&gt;"
value="&lt;link href='webjars/springfox-swagger-ui/themes/2.x/theme-feeling-blue.css' rel=&quot;stylesheet&quot;/&gt;&lt;/head&gt;"
dir="${settings.localRepository}/io/springfox/springfox-swagger-ui/2.7.0/META-INF/resources">
<include name="swagger-ui.html"/>
</replace>
</sequential>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>
<!--<plugin>
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>1.29.366</version>
<version>2.37.1128</version>
<executions>
<execution>
<id>generate1</id>
<id>java to typeScript</id>
<goals>
<goal>generate</goal>
</goals>
@ -372,14 +389,14 @@
<outputFileType>implementationFile</outputFileType>
<mapClasses>asClasses</mapClasses>
<classPatterns>
<pattern>eu.dnetlib.domain.data.*</pattern>
<pattern>eu.dnetlib.domain.functionality.validator.*</pattern>
</classPatterns>
<outputFile>target/typeScriptClasses.ts</outputFile>
<outputFile>target/operation.ts</outputFile>
<outputKind>module</outputKind>
</configuration>
</execution>
</executions>
</plugin>-->
</plugin>
</plugins>
<finalName>uoa-repository-manager-service</finalName>
<resources>
@ -390,5 +407,76 @@
</resources>
</build>
<repositories>
<repository>
<id>central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>dnet45-bootstrap-snapshot</id>
<name>D-Net 45 Bootstrap Snapshot</name>
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
</repository>
<repository>
<id>dnet45-bootstrap-release</id>
<name>D-Net 45 Bootstrap Release</name>
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
<repository>
<id>dnet-deps</id>
<name>dnet-dependencies</name>
<url>https://maven.d4science.org/nexus/content/repositories/dnet-deps</url>
<layout>default</layout>
</repository>
<repository>
<id>dnet45-releases</id>
<name>D-Net 45 releases</name>
<url>https://maven.d4science.org/nexus/content/repositories/dnet45-releases</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>dnet45-snapshots</id>
<name>D-Net 45 snapshots</name>
<url>https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<!-- Use this when testing local JARs. -->
<!--<repository>
<id>libs</id>
<url>file:///${project.basedir}/libs</url>
</repository>-->
</repositories>
</project>

View File

@ -0,0 +1,17 @@
package eu.dnetlib.repo.manager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(exclude = SolrAutoConfiguration.class)
@EnableJpaRepositories
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,20 @@
package eu.dnetlib.repo.manager.components;
import eu.dnetlib.repo.manager.service.PendingUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ScheduledTasks {
@Autowired
PendingUserRoleService pendingUserRoleService;
@Scheduled(fixedRate = 3_600_000)
public void assignPendingRoles() {
pendingUserRoleService.assignRoles();
}
}

View File

@ -0,0 +1,172 @@
package eu.dnetlib.repo.manager.config;
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
import org.mitre.oauth2.model.RegisteredClient;
import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
import org.mitre.openid.connect.client.OIDCAuthenticationProvider;
import org.mitre.openid.connect.client.service.impl.*;
import org.mitre.openid.connect.config.ServerConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
import java.util.*;
@Configuration
@EnableWebSecurity
public class AaiSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("${services.provide.aai.oidc.webURL}")
private String logoutSuccessUrl;
@Value("${services.provide.aai.oidc.issuer}")
private String oidcIssuer;
@Value("${services.provide.aai.oidc.id}")
private String oidcId;
@Value("${services.provide.aai.oidc.secret}")
private String oidcSecret;
@Value("${services.provide.aai.oidc.redirectURL}")
private String oidcDevHome;
@Value("${services.provide.aai.oidc.webURL}")
private String webAppFrontEnd;
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return authenticationManager();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(openIdConnectAuthenticationProvider());
}
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/stats/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.regexMatchers("/actuator/.*").permitAll()
.regexMatchers("/repositories/.*/metrics/?.*").permitAll()
.regexMatchers("/metrics").permitAll()
.antMatchers("/api-docs/**","/swagger-ui/**").permitAll()
.anyRequest().authenticated()
.and()
.logout().logoutUrl("/openid_logout")
.clearAuthentication(true)
.invalidateHttpSession(true)
.deleteCookies()
.logoutSuccessUrl(logoutSuccessUrl)
.and()
.addFilterBefore(openIdConnectAuthenticationFilter(), AbstractPreAuthenticatedProcessingFilter.class)
;
}
@Bean
public OIDCAuthenticationProvider openIdConnectAuthenticationProvider() {
OIDCAuthenticationProvider oidcProvider = new OIDCAuthenticationProvider();
oidcProvider.setAuthoritiesMapper(authoritiesMapper());
return oidcProvider;
}
@Bean
public OpenAIREAuthoritiesMapper authoritiesMapper() {
OpenAIREAuthoritiesMapper authoritiesMapper = new OpenAIREAuthoritiesMapper();
return authoritiesMapper;
}
@Bean
public StaticServerConfigurationService staticServerConfigurationService() {
StaticServerConfigurationService staticServerConfigurationService = new StaticServerConfigurationService();
Map<String, ServerConfiguration> servers = new HashMap<>();
servers.put(oidcIssuer, serverConfiguration());
staticServerConfigurationService.setServers(servers);
return staticServerConfigurationService;
}
@Bean
public StaticClientConfigurationService staticClientConfigurationService() {
StaticClientConfigurationService staticClientConfigurationService = new StaticClientConfigurationService();
Map<String, RegisteredClient> clients = new HashMap<>();
clients.put(oidcIssuer, registeredClient());
staticClientConfigurationService.setClients(clients);
return staticClientConfigurationService;
}
@Bean
public RegisteredClient registeredClient() {
RegisteredClient registeredClient = new RegisteredClient();
registeredClient.setClientId(oidcId);
registeredClient.setClientSecret(oidcSecret);
registeredClient.setScope(new HashSet<>(Arrays.asList("openid", "eduperson_entitlement", "profile", "email")));
registeredClient.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC);
registeredClient.setRedirectUris(new HashSet<>(Collections.singletonList(oidcDevHome)));
return registeredClient;
}
@Bean
public StaticAuthRequestOptionsService staticAuthRequestOptionsService() {
return new StaticAuthRequestOptionsService();
}
@Bean
public PlainAuthRequestUrlBuilder plainAuthRequestUrlBuilder() {
return new PlainAuthRequestUrlBuilder();
}
@Bean
public ServerConfiguration serverConfiguration() {
ServerConfiguration serverConfiguration = new ServerConfiguration();
serverConfiguration.setIssuer(oidcIssuer);
serverConfiguration.setAuthorizationEndpointUri(oidcIssuer + "authorize");
serverConfiguration.setTokenEndpointUri(oidcIssuer + "token");
serverConfiguration.setUserInfoUri(oidcIssuer + "userinfo");
serverConfiguration.setJwksUri(oidcIssuer + "jwk");
serverConfiguration.setRevocationEndpointUri(oidcIssuer + "revoke");
return serverConfiguration;
}
@Bean
public OIDCAuthenticationFilter openIdConnectAuthenticationFilter() throws Exception {
OIDCAuthenticationFilter oidc = new OIDCAuthenticationFilter();
oidc.setAuthenticationManager(authenticationManagerBean());
oidc.setIssuerService(staticSingleIssuerService());
oidc.setServerConfigurationService(staticServerConfigurationService());
oidc.setClientConfigurationService(staticClientConfigurationService());
oidc.setAuthRequestOptionsService(staticAuthRequestOptionsService());
oidc.setAuthRequestUrlBuilder(plainAuthRequestUrlBuilder());
oidc.setAuthenticationSuccessHandler(frontEndRedirect());
return oidc;
}
@Bean
public StaticSingleIssuerService staticSingleIssuerService() {
StaticSingleIssuerService staticSingleIssuerService = new StaticSingleIssuerService();
staticSingleIssuerService.setIssuer(oidcIssuer);
return staticSingleIssuerService;
}
@Bean(initMethod = "init")
public FrontEndLinkURIAuthenticationSuccessHandler frontEndRedirect() {
FrontEndLinkURIAuthenticationSuccessHandler frontEnd = new FrontEndLinkURIAuthenticationSuccessHandler();
frontEnd.setFrontEndURI(webAppFrontEnd);
return frontEnd;
}
}

View File

@ -0,0 +1,27 @@
package eu.dnetlib.repo.manager.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import java.lang.reflect.Method;
@Configuration
@EnableAsync
public class AsyncConfiguration implements AsyncConfigurer {
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new AsyncUncaughtExceptionHandler() {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
logger.error("Async error", throwable);
}
};
}
}

View File

@ -1,55 +0,0 @@
package eu.dnetlib.repo.manager.config;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import java.util.Properties;
/**
* CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
* override the previous. It also supports property expansion like:
*
* <code>
* something = 1
* somethingelse = 2
* test = ${something}/${somethingelse}
* </code>
*
* <p>
* And if you override something to XX, then test will become XX/2
* </p>
*
*
* @author marko
*
*/
public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
private Properties properties;
public void afterPropertiesSet() throws Exception {
this.properties = mergeProperties();
// Convert the merged properties, if necessary.
convertProperties(this.properties);
logger.debug("Properties: " + properties);
}
@Override
protected void processProperties(final ConfigurableListableBeanFactory beanFactoryToProcess, final Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess, props);
}
public Properties getProperties() {
return properties;
}
public void setProperties(final Properties properties) {
super.setProperties(properties);
this.properties = properties;
}
}

View File

@ -1,75 +1,84 @@
package eu.dnetlib.repo.manager.config;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
@Configuration
@EnableRedisHttpSession
@EnableAspectJAutoProxy
@EnableCircuitBreaker
@PropertySource(value = {"classpath:application.properties"} )
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
public class Config {
private static Logger LOGGER = Logger.getLogger(Config.class);
@Value("${redis.host:194.177.192.121}")
private String host;
@Value("${redis.port:6379}")
private String port;
@Value("${redis.password}")
private String password;
@Value("${aai.mode}")
private String aai_mode;
@PostConstruct
private void init(){
LOGGER.info(host);
}
@Bean
JedisConnectionFactory connectionFactory() {
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(Integer.parseInt(port));
if(password != null) jedisConnectionFactory.setPassword(password);
return jedisConnectionFactory;
}
@Bean
public CookieSerializer cookieSerializer() {
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
serializer.setCookieName("openAIRESession");
serializer.setCookiePath("/");
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
serializer.setDomainName(".openaire.eu");
// serializer.setDomainName(".athenarc.gr");
LOGGER.info("Serializer : " + serializer);
return serializer;
}
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("Content-Type", "application/json");
return restTemplate;
}
}
package eu.dnetlib.repo.manager.config;
import eu.dnetlib.api.enabling.ISLookUpService;
import eu.dnetlib.api.functionality.ValidatorService;
import eu.dnetlib.clients.enabling.islookup.ws.ISLookUpClient;
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebService;
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebServiceClient;
import eu.dnetlib.domain.enabling.Vocabulary;
import gr.uoa.di.driver.enabling.ISLookUp;
import gr.uoa.di.driver.enabling.islookup.ISLookUpImpl;
import gr.uoa.di.driver.enabling.vocabulary.ISVocabularyLoader;
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
import gr.uoa.di.driver.util.ServiceLocator;
import gr.uoa.di.driver.util.StaticServiceLocator;
import gr.uoa.di.driver.xml.VocabularyXmlConverter;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages = {"org.eurocris.openaire.cris.validator.service"})
public class Config {
@Value("${services.provide.iSLookUpService.url}")
private String lookupURL;
@Value("${services.provide.validatorService.url}")
private String validatorUrl;
@Bean(name = "vocabularyLoader")
public VocabularyLoader createVocabularyLoader() throws Exception {
ISVocabularyLoader loader = new ISVocabularyLoader();
loader.setLookUp(createVocabularyLookUp());
return loader;
}
@Bean("validatorServiceLocator")
public ServiceLocator<ValidatorService> createValidatorServiceLocator() {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ValidatorWebService.class);
factory.setAddress(validatorUrl);
ValidatorWebService service = (ValidatorWebService) factory.create();
ValidatorWebServiceClient client = new ValidatorWebServiceClient();
client.setWebService(service);
StaticServiceLocator<ValidatorService> locator = new StaticServiceLocator<>();
locator.setService(client);
return locator;
}
// @Bean(name="vocabularyLookUp")
private ISLookUp<Vocabulary> createVocabularyLookUp() throws Exception {
ISLookUpImpl<Vocabulary> lookUp = new ISLookUpImpl<>();
lookUp.setLookupLocator(createIsLookupServiceLocator());
lookUp.setConverter(new VocabularyXmlConverter());
return lookUp;
}
private ServiceLocator<ISLookUpService> createIsLookupServiceLocator() throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService.class);
factory.setAddress(lookupURL);
eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService client = (eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService) factory.create();
ISLookUpClient service = new ISLookUpClient();
service.setWebService(client);
StaticServiceLocator<ISLookUpService> locator = new StaticServiceLocator<>();
locator.setService(service);
return locator;
}
}

View File

@ -0,0 +1,40 @@
package eu.dnetlib.repo.manager.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@Configuration
public class CustomRestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(0, mappingJacksonHttpMessageConverter());
return restTemplate;
}
@Bean
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(customObjectMapper());
return converter;
}
@Bean
public ObjectMapper customObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
// Do not fail when reading unknown properties
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// Do not fail when reading properties of different case
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
return objectMapper;
}
}

View File

@ -1,84 +1,57 @@
package eu.dnetlib.repo.manager.config;
import com.google.gson.JsonObject;
import org.apache.log4j.Logger;
import com.google.gson.JsonParser;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.session.FindByIndexNameSessionRepository;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import com.google.gson.*;
import java.util.Base64;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private String frontEndURI;
private static final Logger LOGGER = Logger
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
private static final Logger logger = LoggerFactory.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
public void init(){
LOGGER.debug("Front end uri : " + frontEndURI);
public void init() {
logger.debug("Front end uri : {}", frontEndURI);
}
@Value("${aai.mode}")
private String aai_mode;
@Value("${services.provide.aai.oidc.domain}")
private String domain;
private static final Pattern AUTH_REGEX = Pattern.compile("^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$");
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
JsonObject userInfo = new JsonObject();
if (authOIDC.getUserInfo().getSub() == null)
userInfo.addProperty("sub", "");
else
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
if(authOIDC.getUserInfo().getName() != null)
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
if (authOIDC.getUserInfo().getGivenName() == null)
userInfo.addProperty("firstname", "");
else
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
if (authOIDC.getUserInfo().getFamilyName() == null)
userInfo.addProperty("lastname", "");
else
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
userInfo.addProperty("role", "");
else
userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
.getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
openAIREUser.setMaxAge(14400);
openAIREUser.setPath("/");
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
openAIREUser .setDomain(".openaire.eu");
// openAIREUser.setDomain(".athenarc.gr");
response.addCookie(openAIREUser);
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getSub());
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
accessToken.setMaxAge(14400);
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
accessToken.setDomain(".openaire.eu");
Matcher matcher = AUTH_REGEX.matcher(authOIDC.getAccessTokenValue());
if (matcher.find()) {
long exp = new JsonParser().parse(new String(Base64.getDecoder().decode(matcher.group(2)))).getAsJsonObject().get("exp").getAsLong();
accessToken.setMaxAge((int) (exp - (new Date().getTime() / 1000)));
} else {
accessToken.setMaxAge(3600);
}
accessToken.setDomain(domain);
accessToken.setPath("/");
// accessToken.setDomain(".athenarc.gr");
response.addCookie(accessToken);
response.sendRedirect(frontEndURI);
}

View File

@ -0,0 +1,19 @@
package eu.dnetlib.repo.manager.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true,proxyTargetClass = true)
public class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {
@Bean
public CommonsMultipartResolver multipartResolver(){
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
multipartResolver.setMaxUploadSize(268435456);
return multipartResolver;
}
}

View File

@ -0,0 +1,17 @@
package eu.dnetlib.repo.manager.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
public class JPAConfig {
@Bean
public PlatformTransactionManager transactionManager() {
return new JpaTransactionManager();
}
}

View File

@ -0,0 +1,57 @@
package eu.dnetlib.repo.manager.config;
import eu.dnetlib.utils.MailLibrary;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MailConfig {
@Value("${services.provide.mail.host}")
private String host;
@Value("${services.provide.mail.port}")
private int port;
@Value("${services.provide.mail.authenticate}")
private boolean authenticate;
@Value("${services.provide.mail.username}")
private String username;
@Value("${services.provide.mail.password}")
private String password;
@Value("${services.provide.mail.from}")
private String from;
@Value("${services.provide.mail.replyTo}")
private String replyTo;
@Value("${services.provide.mail.mode}")
private String mode;
@Value("${services.provide.mail.debug}")
private boolean debug;
@Bean
public MailLibrary createMailLibrary() {
MailLibrary lib = new MailLibrary();
lib.setAuthenticate(authenticate);
lib.setDebug(debug);
lib.setFrom(from);
lib.setMailhost(host);
lib.setSmtpPort(port);
lib.setMode(mode);
lib.setReplyTo(replyTo);
lib.setUsername(username);
lib.setPassword(password);
lib.setMode(mode);
lib.init();
return lib;
}
}

View File

@ -0,0 +1,49 @@
package eu.dnetlib.repo.manager.config;
import com.google.gson.JsonArray;
import com.nimbusds.jwt.JWT;
import eu.dnetlib.repo.manager.service.security.AuthoritiesMapper;
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
import org.mitre.openid.connect.model.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Component
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
private static final Logger logger = LoggerFactory.getLogger(OpenAIREAuthoritiesMapper.class);
@Value("${services.provide.adminEmail}")
String adminEmail;
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(JWT jwtToken, UserInfo userInfo) {
JsonArray entitlements = null;
Set<GrantedAuthority> authorities = new HashSet<>();
if (userInfo != null && userInfo.getSource() != null) {
if (userInfo.getSource().getAsJsonArray("edu_person_entitlements") != null) {
entitlements = userInfo.getSource().getAsJsonArray("edu_person_entitlements");
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
}
logger.debug("user info: {}\nentitlements: {}", userInfo, entitlements);
// FIXME: delete this if statement when super administrators are set
if (userInfo.getEmail() != null && userInfo.getEmail().equals(adminEmail)) {
authorities.add(new SimpleGrantedAuthority("SUPER_ADMINISTRATOR"));
}
authorities.addAll(AuthoritiesMapper.map(entitlements));
}
return authorities;
}
}

View File

@ -0,0 +1,23 @@
package eu.dnetlib.repo.manager.config;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
@OpenAPIDefinition(
info = @Info(
title = "Repository Manager Dashboard API Documentation",
description = "Repository Manager Dashboard API Documentation",
version = "1.0",
termsOfService = "urn:tos",
license = @License(
name = "Apache 2.0",
url = "https://www.apache.org/licenses/LICENSE-2.0.html"
),
contact = @Contact(name = "", url = "", email = "")
)
)
public class OpenAPIConfiguration {
}

View File

@ -1,42 +0,0 @@
package eu.dnetlib.repo.manager.config;
import com.nimbusds.jwt.JWT;
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
import org.mitre.openid.connect.model.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.*;
public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper {
private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
final private static String ROLE_CLAIMS = "edu_person_entitlements";
private Map<String,SimpleGrantedAuthority> userRolesMap;
OpenAireProviderAuthoritiesMapper(Map<String,String> userRoles) {
userRolesMap = new HashMap<>();
userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
}
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
Set<GrantedAuthority> out = new HashSet<>();
out.add(new SimpleGrantedAuthority("ROLE_USER"));
if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
if (authority != null) {
logger.debug("Role mapped " + role);
out.add(authority);
}
});
}
return out;
}
}

View File

@ -0,0 +1,59 @@
package eu.dnetlib.repo.manager.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;
import javax.annotation.PostConstruct;
@Configuration
@EnableRedisHttpSession
public class RedisConfiguration {
private static final Logger logger = LoggerFactory.getLogger(RedisConfiguration.class);
@Value("${services.provide.redis.host}")
private String host;
@Value("${services.provide.redis.port:6379}")
private String port;
@Value("${services.provide.redis.password}")
private String password;
@Value("${services.provide.aai.oidc.domain}")
private String domain;
@PostConstruct
private void init() {
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
}
@Bean
public JedisConnectionFactory connectionFactory() {
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(Integer.parseInt(port));
jedisConnectionFactory.setUsePool(true);
if (password != null) jedisConnectionFactory.setPassword(password);
return jedisConnectionFactory;
}
@Bean
public CookieSerializer cookieSerializer() {
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
serializer.setCookieName("openAIRESession");
serializer.setCookiePath("/");
serializer.setDomainName(domain);
logger.info("Cookie Serializer : {}", serializer);
return serializer;
}
}

View File

@ -1,109 +0,0 @@
package eu.dnetlib.repo.manager.config;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.XmlWebApplicationContext;
import javax.servlet.ServletContext;
import java.util.Properties;
public class RepoManagerContextLoaderListener extends ContextLoaderListener {
private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
public RepoManagerContextLoaderListener() {
super();
}
public RepoManagerContextLoaderListener(WebApplicationContext context) {
super(context);
}
@Override
protected WebApplicationContext createWebApplicationContext(
ServletContext servletContext)
throws BeansException {
logger.debug("Creating web application context");
Properties props = this.loadProperties();
String repoMode = props.getProperty("services.validator.mode.repo");
String userMode = props.getProperty("services.validator.mode.user");
Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
logger.info("User mode: " + userMode);
logger.info("Repo mode: " + repoMode);
logger.info("Standalone mode: " + standaloneMode);
// logger.info("Dnet workflow enabled: " + repoMode);
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
ctx.setServletContext(servletContext);
String userApiContext = null;
if (userMode.equalsIgnoreCase("local"))
userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
else if (userMode.equalsIgnoreCase("ldap"))
userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
String[] springContextCore = new String[] {
"classpath:META-INF/cxf/cxf.xml",
"classpath:META-INF/cxf/cxf-extension-soap.xml",
"classpath:META-INF/cxf/cxf-extension-jaxws.xml",
"classpath:META-INF/cxf/cxf-servlet.xml",
"classpath*:/cxf.xml",
"classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
"classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
"classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-struts.xml",
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-emailer.xml",
// "classpath*:/eu/dnetlib/validator/web/config/springContext-validator.xml",
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
// "classpath*:/eu/dnetlib/validator/commons/dao/springContext-*.xml",
"classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
"classpath*:/" + userApiContext
};
String[] springContextForStandalone = new String[] {
};
String[] springContextForIS = new String[] {
"classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
"classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
"classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
"classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
"classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
"classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
};
if (standaloneMode) {
logger.debug("Loading contexts for standalone mode");
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
} else {
logger.debug("Loading contexts for dnet");
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
}
ctx.refresh();
logger.debug("done");
return ctx;
}
private Properties loadProperties() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
});
CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
Properties props = pLoader.getProperties();
ctx.destroy();
ctx.close();
return props;
}
}

View File

@ -1,66 +0,0 @@
package eu.dnetlib.repo.manager.config;
import eu.dnetlib.repo.manager.controllers.*;
import eu.dnetlib.repo.manager.service.MonitorService;
import eu.dnetlib.repo.manager.service.PiWikService;
import eu.dnetlib.repo.manager.service.RepositoryService;
import eu.dnetlib.repo.manager.service.ValidatorService;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
/**
* Created by panagiotis on 16/11/2017.
*/
@Configuration
@EnableSwagger2
@EnableWebMvc
@EnableCircuitBreaker
@ComponentScan(basePackageClasses = {
RepositoryController.class,
MonitorController.class,
ValidatorController.class,
PiWikController.class,
BrokerController.class,
StatsController.class,
UserController.class,
SushiliteController.class
},basePackages = "eu.dnetlib.repo.manager.*")
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.pathMapping("/")
.apiInfo(getApiInfo());
}
private ApiInfo getApiInfo() {
return new ApiInfo("Repository Manager Dashboard API Documentation",
"Repository Manager Dashboard API Documentation",
"1.0",
"urn:tos",
new Contact("", "", ""),
"Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList<VendorExtension>());
}
}

View File

@ -1,16 +1,18 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.domain.Term;
import eu.dnetlib.repo.manager.domain.broker.*;
import eu.dnetlib.repo.manager.exception.BrokerException;
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
import eu.dnetlib.repo.manager.shared.BrokerException;
import eu.dnetlib.repo.manager.shared.Term;
import eu.dnetlib.repo.manager.shared.broker.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
@ -19,31 +21,29 @@ import java.util.Map;
@RestController
@RequestMapping(value = "/broker")
@Api(description = "Broker API", tags = {"broker"})
@Tag(name="broker", description="Broker API")
public class BrokerController{
@Autowired
BrokerServiceImpl brokerService;
private BrokerServiceImpl brokerService;
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
@ApiParam(value = "User email", required = true) String user,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public DatasourcesBroker getDatasourcesOfUser(
@RequestParam("includeShared")
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
@Parameter(description = "Include shared datasources (default = false)", required = true) String includeShared,
@RequestParam("includeByOthers")
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
@Parameter(description = "Include datasources of other (default = false)", required = true) String includeByOthers) throws JSONException {
return brokerService.getDatasourcesOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), includeShared, includeByOthers);
}
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
public List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
return brokerService.getTopicsForDatasource(datasourceName);
}
@ -51,8 +51,8 @@ public class BrokerController{
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
EventsPage advancedShowEvents(@PathVariable("page") String page,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public EventsPage advancedShowEvents(@PathVariable("page") String page,
@PathVariable("size") String size,
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
return brokerService.advancedShowEvents(page, size, advQueryObject);
@ -62,29 +62,29 @@ public class BrokerController{
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
@RequestParam("topic") String topic,
@RequestParam("page") String page,
@RequestParam("size") String size) throws BrokerException, JSONException{
return brokerService.showEvents(datasourceName, topic, page, size);
}
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
@RequestMapping(value = "/getSimpleSubscriptionsOfUser" ,
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
return brokerService.getSimpleSubscriptionsOfUser(userEmail);
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser() throws BrokerException{
return brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
}
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER') ")
Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
@PreAuthorize("hasAuthority('REGISTERED_USER') ")
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
return brokerService.subscribe(obj);
}
@ -92,16 +92,16 @@ public class BrokerController{
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
return brokerService.unsubscribe(subscriptionId);
}
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
return brokerService.getSubscription(subscriptionId);
}
@ -109,26 +109,18 @@ public class BrokerController{
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
Map<String, Term> getDnetTopics() throws BrokerException{
public Map<String, Term> getDnetTopics() throws BrokerException{
return brokerService.getDnetTopics();
}
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
@PathVariable("page") String page,
@PathVariable("size") String size) throws BrokerException{
return brokerService.getNotificationsBySubscriptionId(subscriptionId, page, size);
}
/*@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody*/
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException{
return brokerService.getSubscriptionsOfUser(userEmail);
}
}

View File

@ -1,31 +1,96 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.repo.manager.domain.BrokerSummary;
import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary;
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
import eu.dnetlib.repo.manager.service.DashboardService;
import io.swagger.annotations.Api;
import eu.dnetlib.repo.manager.domain.UsageSummary;
import eu.dnetlib.repo.manager.exception.BrokerException;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.service.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/dashboard")
@Api(description = "Dashboard API", tags = {"dashboard"})
@Tag(name="dashboard", description = "Dashboard API")
public class DashboardController {
@Autowired
DashboardService dashboardService;
private DashboardService dashboardService;
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
@Autowired
private RepositoryService repositoryService;
@Autowired
private AggregationService aggregationService;
@Autowired
private BrokerService brokerService;
@Autowired
private PiWikService piWikService;
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
@PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException {
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(
@PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException {
return dashboardService.getRepositoriesSummaryInfo(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
}
@RequestMapping(value = "/collectionMonitorSummary/{repoId}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public CollectionMonitorSummary getCollectionMonitorSummary(
@PathVariable("repoId") String repoId,
@RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException {
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId);
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
// Set the "aggregationInfo" for the first <number of> requested aggregations, in order to create a "summary".
collectionMonitorSummary.setAggregationInfo(aggregationInfoList.subList(0, Math.min(summarySize, aggregationInfoList.size())));
// Search for the last indexed version and set the "collectionMonitorSummary".
for ( AggregationInfo aggregationInfo : aggregationInfoList ) {
if ( aggregationInfo.isIndexedVersion() ) {
collectionMonitorSummary.setLastIndexedVersion(aggregationInfo);
break;
}
}
return collectionMonitorSummary;
}
@RequestMapping(value = "/usageSummary/{repoId}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public UsageSummary getUsageSummary(
@PathVariable("repoId") String repoId
) throws RepositoryServiceException {
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
}
@RequestMapping(value = "/brokerSummary/{ds_name}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public BrokerSummary getBrokerSummary(
@PathVariable("ds_name") String datasourceName) throws BrokerException {
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
}
}

View File

@ -2,18 +2,21 @@ package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.api.functionality.ValidatorServiceException;
import eu.dnetlib.repo.manager.exception.BrokerException;
import eu.dnetlib.repo.manager.exception.EndPointException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.exception.ServerError;
import eu.dnetlib.repo.manager.shared.BrokerException;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
import java.net.UnknownHostException;
@ -23,43 +26,42 @@ import java.net.UnknownHostException;
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GenericControllerAdvice {
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
private Logger logger = LoggerFactory.getLogger(GenericControllerAdvice.class);
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseBody
ServerError securityException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
public ServerError securityException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(), ex);
}
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(AccessDeniedException.class)
@ResponseBody
ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
public ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(), ex);
}
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(UnknownHostException.class)
@ResponseBody
ServerError unknownHostException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
public ServerError unknownHostException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(), ex);
}
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class})
@ExceptionHandler({JSONException.class, BrokerException.class, ValidatorServiceException.class})
@ResponseBody
ServerError internalException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
public ServerError internalException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(), ex);
}
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
@ExceptionHandler(EndPointException.class)
@ResponseBody
ServerError endPointException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
public ServerError endPointException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(), ex);
}
}

View File

@ -0,0 +1,47 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
import eu.dnetlib.repo.manager.service.InterfaceComplianceService;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("compliance")
public class InterfaceComplianceRequestController {
private final InterfaceComplianceService service;
public InterfaceComplianceRequestController(InterfaceComplianceService service) {
this.service = service;
}
@GetMapping("{repositoryId}/{interfaceId}")
public InterfaceComplianceRequest get(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
return service.getById(id).orElse(null);
}
@GetMapping()
public Iterable<InterfaceComplianceRequest> get() {
return service.get();
}
@PostMapping()
public InterfaceComplianceRequest add(@RequestBody InterfaceComplianceRequestDTO requestDTO) {
requestDTO.setSubmissionDate(new Date());
return service.create(InterfaceComplianceRequest.from(requestDTO));
}
@DeleteMapping("{repositoryId}/{interfaceId}")
public void delete(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
this.service.delete(id);
}
}

View File

@ -2,52 +2,51 @@ package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.api.functionality.ValidatorServiceException;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import eu.dnetlib.repo.manager.domain.JobsOfUser;
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
import eu.dnetlib.repo.manager.shared.JobsOfUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.log4j.Logger;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/monitor")
@Api(description = "Monitor API", tags = {"monitor"})
@Tag(name="monitor", description="Monitor API")
public class MonitorController {
private static final Logger LOGGER = Logger
.getLogger(MonitorController.class);
private static final Logger logger = LoggerFactory.getLogger(MonitorController.class);
@Autowired
MonitorServiceImpl monitorService;
private MonitorServiceImpl monitorService;
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
@RequestParam(value = "jobType", required = false)
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus,
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public JobsOfUser getJobsOfUser(@RequestParam(value = "jobType", required = false)
@Parameter(description = "Equals to filter job type on validation history page") String jobType,
@RequestParam("offset") @Parameter(name = "Page number", required = true) String offset,
@RequestParam(value = "limit", required = false,defaultValue = "10") @Parameter(description = "Null value") String limit,
@RequestParam(value = "dateFrom", required = false) @Parameter(description = "Null value") String dateFrom,
@RequestParam(value = "dateTo", required = false) @Parameter(description = "Null value") String dateTo,
@RequestParam("validationStatus") @Parameter(description = "Equals to filter validation jobs", required = false) String validationStatus,
@RequestParam("includeJobsTotal") @Parameter(description = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
return monitorService.getJobsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
}
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
@RequestBody String jobType,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public int getJobsOfUserPerValidationStatus(@RequestBody String jobType,
@RequestBody String validationStatus) throws JSONException {
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
return monitorService.getJobsOfUserPerValidationStatus(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, validationStatus);
}
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)

View File

@ -1,68 +1,184 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.repo.manager.domain.OrderByField;
import eu.dnetlib.repo.manager.domain.OrderByType;
import eu.dnetlib.repo.manager.domain.Paging;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(value = "/piwik")
@Api(description = "Piwik API", tags = {"piwik"})
@Tag(name="piwik", description = "Piwik API")
public class PiWikController {
@Autowired
PiWikServiceImpl piWikService;
private static final Logger logger = LoggerFactory.getLogger(PiWikController.class);
@Autowired
private PiWikServiceImpl piWikService;
@RequestMapping(value = "/validated", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Boolean isPiwikValidated(@RequestParam("repositoryId") String repositoryId) {
PiwikInfo info = piWikService.getPiwikSiteForRepo(repositoryId);
if (info != null) {
return info.isValidated();
}
return false;
}
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repositoryId) or (@repositoryService.getRepositoryById(#repositoryId).registeredby==null and hasAuthority('REGISTERED_USER'))")
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
return piWikService.getPiwikSiteForRepo(repositoryId);
}
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') " +
"and #piwikInfo.requestorEmail == authentication.userInfo.email)")
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#piwikInfo.repositoryId) or (@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredby==null and hasAuthority('REGISTERED_USER'))")
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
return piWikService.savePiwikInfo(piwikInfo);
}
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
List<PiwikInfo> getPiwikSitesForRepos(){
return piWikService.getPiwikSitesForRepos();
@Parameters({
@Parameter(name = "from", description = "number"),
@Parameter(name = "quantity", description = "number"),
@Parameter(name = "order", description = "eu.dnetlib.repo.manager.domain.OrderByType"),
@Parameter(name = "orderField", description = "eu.dnetlib.repo.manager.domain.OrderByField"),
@Parameter(name = "searchField", description = "string")
})
public Paging<PiwikInfo> getPiwikSitesForRepos(
@RequestParam(value = "from", required=false, defaultValue = "0") int from,
@RequestParam(value = "quantity", required=false, defaultValue = "100") int quantity,
@RequestParam(value = "order", required=false, defaultValue = "DSC") OrderByType orderType,
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField
){
Paging<PiwikInfo> results = new Paging<>();
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField);
results.setFrom(from);
results.setTo(from + returning.size());
results.setTotal(piWikService.getPiwikSitesTotals(searchField));
results.setResults(returning);
return results;
}
@Parameters({
@Parameter(name = "from", description = "number"),
@Parameter(name = "quantity", description = "number"),
@Parameter(name = "order", description = "eu.dnetlib.repo.manager.domain.OrderByType"),
@Parameter(name = "searchField", description = "eu.dnetlib.repo.manager.domain.OrderByField"),
@Parameter(name = "orderField", description = "string")
})
@RequestMapping(value = "/getPiwikSitesForRepos/csv" , method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public FileSystemResource getPiwikSitesForReposToCsv(
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
@RequestParam(value = "quantity",required=false,defaultValue = "10000") int quantity,
@RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType,
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField,
HttpServletResponse response,
HttpServletRequest request
) throws IOException {
Path p = Files.createTempFile("exportingCsv-", new Date().toString());
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,0,10000,searchField);
try (PrintWriter writer = new PrintWriter(p.toFile())) {
StringBuilder sb = new StringBuilder();
sb.append(" Repository ID , Repository name, Country, Site ID, Authentication token, Creation date, Requestor full name, Requestor email, Validated, Validation date, Comment \n");
for(PiwikInfo piwikInfo : returning){
sb.append(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId() + ",")
.append(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName() + ",")
.append(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry() + ",")
.append(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId() + ",")
.append(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken() + ",")
.append(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString() + ",")
.append(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName() + ",")
.append(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail() + ",")
.append(piwikInfo.isValidated()).append(",")
.append(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString() + ",")
.append(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment() + "\n");
}
writer.write(sb.toString());
} catch (FileNotFoundException e) {
logger.error(e.getMessage());
}
String mimeType = request.getServletContext().getMimeType(p.toFile().getAbsolutePath());
if (mimeType == null) {
mimeType = "application/octet-stream";
}
response.setContentType(mimeType);
response.setContentLength((int) p.toFile().length());
String headerKey = "Content-Disposition";
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");//dd/MM/yyyy
Date now = new Date();
String strDate = sdfDate.format(now);
String headerValue = String.format("attachment; filename=\"csv-%s.csv\"",
strDate);
response.setHeader(headerKey, headerValue);
return new FileSystemResource(p.toFile());
}
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
return piWikService.approvePiwikSite(repositoryId);
}
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
String getOpenaireId(String repositoryid){
return piWikService.getOpenaireId(repositoryid);
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repositoryId) or (@repositoryService.getRepositoryById(#repositoryId).registeredby==null and hasAuthority('REGISTERED_USER'))")
public String getOpenaireId(@PathVariable("repositoryId") String repositoryId){
return piWikService.getOpenaireId(repositoryId);
}
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
return piWikService.markPiwikSiteAsValidated(repositoryId);
}
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
@RequestParam("repoWebsite") String repoWebsite,
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {

View File

@ -0,0 +1,66 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.service.PiWikService;
import eu.dnetlib.repo.manager.service.RepositoryService;
import io.micrometer.core.instrument.binder.jvm.DiskSpaceMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.common.TextFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
@RestController
@RequestMapping(value = "/actuator/prometheus", produces = "application/openmetrics-text; version=1.0.0; charset=utf-8")
public class PrometheusController {
private static final Logger logger = LoggerFactory.getLogger(PrometheusController.class);
private final PiWikService piWikService;
private final RepositoryService repositoryService;
@Autowired
public PrometheusController(PiWikService piWikService, RepositoryService repositoryService) {
this.piWikService = piWikService;
this.repositoryService = repositoryService;
}
@RequestMapping(method = RequestMethod.GET)
public String getPiwikMetrics() {
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
registry.gauge("provide_repositories_registered", repositoryService.getTotalRegisteredRepositories());
registry.gauge("provide_usagecounts_repositories_registered", piWikService.getTotal());
registry.gauge("provide_usagecounts_repositories_validated", piWikService.getValidated(true));
return registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
}
@RequestMapping(method = RequestMethod.GET, path = "metrics", produces = MediaType.TEXT_PLAIN_VALUE)
public String getMetrics() {
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
new JvmThreadMetrics().bindTo(registry);
try (JvmGcMetrics jvmGcMetrics = new JvmGcMetrics() ) {
jvmGcMetrics.bindTo(registry);
} catch (Exception e) {
logger.error("", e);
}
new JvmMemoryMetrics().bindTo(registry);
new DiskSpaceMetrics(new File("/")).bindTo(registry);
new ProcessorMetrics().bindTo(registry); // metrics related to the CPU stats
new UptimeMetrics().bindTo(registry);
return registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
}
}

View File

@ -1,33 +1,64 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.domain.data.RepositoryInterface;
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.repo.manager.domain.*;
import eu.dnetlib.repo.manager.domain.dto.RepositoryTerms;
import eu.dnetlib.repo.manager.domain.dto.User;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl;
import eu.dnetlib.repo.manager.shared.*;
import io.swagger.annotations.Api;
import eu.dnetlib.repo.manager.service.AggregationService;
import eu.dnetlib.repo.manager.service.PiWikService;
import eu.dnetlib.repo.manager.service.RepositoryService;
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
import eu.dnetlib.repo.manager.utils.JsonUtils;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.Path;
import java.io.IOException;
import javax.ws.rs.core.Response;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/repository")
@Api(description = "Repository API", tags = {"repository"})
@RequestMapping(value = "/repositories")
@Tag(name="repositories", description="Repository API")
public class RepositoryController {
@Autowired
RepositoryServiceImpl repositoryService;
private static final Logger logger = LoggerFactory.getLogger(RepositoryController.class);
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
private final RepositoryService repositoryService;
private final AggregationService aggregationService;
private final AuthorizationService authorizationService;
private final PiWikService piWikService;
@Autowired
RepositoryController(RepositoryService repositoryService,
AggregationService aggregationService,
AuthorizationService authorizationService,
PiWikService piWikService) {
this.repositoryService = repositoryService;
this.aggregationService = aggregationService;
this.authorizationService = authorizationService;
this.piWikService = piWikService;
}
@RequestMapping(value = "/countries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Country[] getCountries() {
return repositoryService.getCountries();
@ -38,32 +69,48 @@ public class RepositoryController {
@ResponseBody
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
@PathVariable("mode") String mode,
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
@RequestParam(value = "managed", required = false) Boolean managed) {
return repositoryService.getRepositoriesByCountry(country, mode, managed);
}
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
@RequestMapping(value = "/snippets/user", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
@PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException {
return repositoryService.getRepositoriesOfUser(userEmail, page, size);
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(@RequestParam(name = "page", defaultValue = "0") int page,
@RequestParam(name = "size", defaultValue = "1000") int pageSize) throws Exception {
return repositoryService.getRepositoriesSnippetsOfUser(String.valueOf(page), String.valueOf(pageSize));
}
@RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}",method = RequestMethod.GET,
@RequestMapping(value = "/terms", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name="country", required=false) String country,
@RequestParam(name="typology", required=false) String typology,
@RequestParam(name="englishName", required=false) String englishName,
@RequestParam(name="officialName", required=false) String officialName,
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public void updateRepositoriesTerms(@RequestBody List<RepositoryTerms> repositoriesTerms) throws Exception {
Date date = new Date();
if (repositoriesTerms != null) {
for (RepositoryTerms terms : repositoriesTerms) {
Repository repository = repositoryService.getRepositoryById(terms.getId());
repository.setConsentTermsOfUse(terms.getConsentTermsOfUse());
repository.setFullTextDownload(terms.getFullTextDownload());
repository.setLastConsentTermsOfUseDate(date);
repositoryService.updateRepository(repository, SecurityContextHolder.getContext().getAuthentication());
}
}
}
@RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name = "country", required = false) String country,
@RequestParam(name = "typology", required = false) String typology,
@RequestParam(name = "englishName", required = false) String englishName,
@RequestParam(name = "officialName", required = false) String officialName,
@RequestParam("requestSortBy") String requestSortBy,
@RequestParam("order") String order,
@PathVariable("page") int page,
@PathVariable("size") int pageSize) throws Exception {
@PathVariable("size") int pageSize) {
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
}
@ -71,22 +118,29 @@ public class RepositoryController {
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
return repositoryService.getRepositoryById(id);
@PostAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredby==null and hasAuthority('REGISTERED_USER'))")
public Repository getRepositoryById(@PathVariable("id") String id) throws ResourceNotFoundException {
Repository repo = repositoryService.getRepositoryById(id);
if (repo != null)
logger.info("Returning repository {} registered by {}", repo.getId(), repo.getRegisteredby());
else
logger.info("Requested repository {} not found", id);
return repo;
}
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
return repositoryService.getRepositoryAggregations(id);
public List<AggregationInfo> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
return aggregationService.getRepositoryAggregations(id, 0, 20);
}
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
return repositoryService.getRepositoryAggregationsByYear(id);
public Map<String, List<AggregationInfo>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
return aggregationService.getRepositoryAggregationsByYear(id);
}
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
@ -94,127 +148,180 @@ public class RepositoryController {
@ResponseBody
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
@PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException {
@PathVariable("size") String size) {
return repositoryService.getRepositoriesByName(name, page, size);
}
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
@PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredby==null and hasAuthority('REGISTERED_USER'))")
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) {
return repositoryService.getRepositoryInterface(id);
}
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
// @PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
// @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')")
public Repository addRepository(@RequestParam("datatype") String datatype,
@RequestBody Repository repository) throws Exception {
@RequestBody Repository repository) {
return repositoryService.addRepository(datatype, repository);
}
@Deprecated
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<String> getDnetCountries(){
public List<String> getDnetCountries() {
return repositoryService.getDnetCountries();
}
@Deprecated
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<String> getTypologies(){
public List<String> getTypologies() {
return repositoryService.getTypologies();
}
@Deprecated
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<Timezone> getTimezones(){
public List<Timezone> getTimezones() {
return repositoryService.getTimezones();
}
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) {
return repositoryService.updateRepository(repository, authentication);
}
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
public void deleteRepositoryInterface(@RequestParam("id") String id ,
@RequestParam("registeredBy") String registeredBy){
repositoryService.deleteRepositoryInterface(id, registeredBy);
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOfInterface(#id)")
public void deleteRepositoryInterface(@RequestParam("id") String id,
@RequestParam("registeredBy") String registeredBy) {
// repositoryService.deleteRepositoryInterface(id, registeredBy);
logger.warn("User attempted delete on Interface with ID: {}", id);
}
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
@RequestParam("repoId") String repoId,
@RequestParam("registeredBy") String registeredBy,
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
}
@RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
@PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException {
return repositoryService.getUrlsOfUserRepos(userEmail, page, size);
}
@RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
return repositoryService.getDatasourceVocabularies(mode);
}
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
return repositoryService.getCompatibilityClasses(mode);
}
@RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
return repositoryService.getDatasourceClasses(mode);
}
@RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
return repositoryService.getMetricsInfoForRepository(repoId);
}
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
return repositoryService.getListLatestUpdate(mode);
@RequestParam("repoId") String id,
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
@RequestParam(value = "comment", required = false) String comment,
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface, desiredCompatibilityLevel);
}
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
@RequestParam("registeredBy") String registeredBy,
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String id,
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
@RequestParam(value = "comment", required = false) String comment,
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
return repositoryService.updateRepositoryInterface(id, comment, repositoryInterface, desiredCompatibilityLevel);
}
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public List<String> getUrlsOfUserRepos(@PathVariable("page") String page, @PathVariable("size") String size) {
return repositoryService.getUrlsOfUserRepos(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
}
@RequestMapping(value = "/getCompatibilityClasses/{mode}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
return repositoryService.getCompatibilityClasses(mode);
}
@RequestMapping(value = "/getDatasourceClasses/{mode}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
return repositoryService.getDatasourceClasses(mode);
}
@RequestMapping(value = "/getMetricsInfoForRepository/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public MetricsInfo getMetricsInfoForRepository(@PathVariable("id") String id) throws RepositoryServiceException {
return repositoryService.getMetricsInfoForRepository(id);
}
@RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) {
return repositoryService.getListLatestUpdate(mode);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Get all the admins of the repository
*/
@RequestMapping(method = RequestMethod.GET, path = "{id}/admins")
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public ResponseEntity<List<User>> getAdminsOfARepo(@PathVariable("id") String id) {
return new ResponseEntity<>(authorizationService.getAdminsOfRepo(id), HttpStatus.OK);
}
/**
* Subscribe to repo by email
*/
@RequestMapping(method = RequestMethod.POST, path = "{id}/admins")
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public Response subscribeByEmail(@PathVariable("id") String id, @RequestBody String email) throws ResourceNotFoundException {
authorizationService.addAdmin(id, email);
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(javax.ws.rs.core.MediaType.APPLICATION_JSON).build();
}
/**
* Unsubscribe from repo by email
*/
@RequestMapping(method = RequestMethod.DELETE, path = "{id}/admins/{email:.+}")
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
public ResponseEntity<Void> unsubscribeByEmail(@PathVariable("id") String id, @PathVariable("email") String email) throws ResourceNotFoundException {
authorizationService.removeAdmin(id, email);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Returns whether the Piwik Site of a repository is enabled and validated.
*/
@RequestMapping(value = "{repositoryId}/metrics/valid", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public boolean getMetricsEnabledAndValidated(@PathVariable("repositoryId") String repositoryId) {
PiwikInfo info = piWikService.getPiwikSiteForRepo(repositoryId);
return info != null && info.isValidated();
}
/**
* Returns repository Metrics.
*/
@RequestMapping(value = "{repositoryId}/metrics", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public MetricsInfo getMetricsInfo(@PathVariable("repositoryId") String id) throws RepositoryServiceException {
return repositoryService.getMetricsInfoForRepository(id);
}
}

View File

@ -1,8 +1,7 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.service.StatsServiceImpl;
import io.swagger.annotations.Api;
import org.json.JSONException;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@ -14,16 +13,15 @@ import java.util.Map;
@RestController
@RequestMapping(value = "/stats")
@Api(description = "Stats API", tags = {"statistics"})
@Tag(name="statistics", description = "Stats API")
public class StatsController {
@Autowired
StatsServiceImpl statsService;
private StatsServiceImpl statsService;
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map getStatistics() throws JSONException {
public Map getStatistics(){
return statsService.getStatistics();
}
}

View File

@ -1,8 +1,8 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.service.SushiliteServiceImpl;
import eu.dnetlib.repo.manager.service.sushilite.SushiliteServiceImpl;
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
@ -10,16 +10,15 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/sushilite")
@Api(description = "Sushi-Lite API", tags = {"sushilite"})
@Tag(name="sushilite", description = "Sushi-Lite API")
public class SushiliteController {
@Autowired
SushiliteServiceImpl sushiliteService;
private SushiliteServiceImpl sushiliteService;
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
@PathVariable("pageSize") String pageSize,
@RequestParam(value = "Report") String Report,

View File

@ -0,0 +1,52 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.service.sushilite.SushiliteR5ServiceImpl;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/sushiliteR5")
@Tag(name="sushiliteR5", description = "Sushi-Lite R5 API")
public class SushiliteR5Controller {
private static final Logger logger = LoggerFactory.getLogger(SushiliteR5Controller.class);
@Autowired
private SushiliteR5ServiceImpl sushiliteR5Service;
@RequestMapping(value = "/getReportResults", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public ResponseEntity<?> getReportResults(@RequestParam(value = "Report") String report,
@RequestParam(value = "Release", required=false, defaultValue="5") String release,
@RequestParam(value = "RequestorID",required=false, defaultValue="anonymous") String requestorID,
@RequestParam(value = "BeginDate",required=false, defaultValue="") String beginDate,
@RequestParam(value = "EndDate",required=false, defaultValue="") String endDate,
@RequestParam(value = "RepositoryIdentifier", required=false, defaultValue="") String repositoryIdentifier,
@RequestParam(value = "DatasetIdentifier", required=false, defaultValue="") String datasetIdentifier,
@RequestParam(value = "ItemIdentifier",required=false, defaultValue="") String itemIdentifier,
@RequestParam(value = "MetricType",required=false) List<String> metricTypes,
@RequestParam(value = "DataType",required=false, defaultValue="") String dataType,
@RequestParam(value = "Granularity", required = false, defaultValue ="Monthly") String granularity,
@RequestParam(value = "Pretty",required=false, defaultValue="") String pretty) {
try {
return sushiliteR5Service.getReportResults(report, release, requestorID, beginDate, endDate, repositoryIdentifier, datasetIdentifier, itemIdentifier, metricTypes, dataType, granularity, pretty);
} catch (JSONException je) {
logger.error("", je);
return ResponseEntity.internalServerError().build();
}
}
}

View File

@ -1,7 +1,7 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.repo.manager.service.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@ -11,14 +11,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/user")
@Api(description = "User API", tags = {"user"})
@Tag(name="user", description = "User API")
public class UserController {
@Autowired
UserServiceImpl userService;
private UserServiceImpl userService;
@RequestMapping(value = "/login" , method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public ResponseEntity<Object> login() {
return userService.login();
}

View File

@ -0,0 +1,108 @@
//package eu.dnetlib.repo.manager.controllers;
//
//import eu.dnetlib.repo.manager.domain.dto.Role;
//import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
//import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
//import eu.dnetlib.repo.manager.service.security.AuthorizationService;
//import eu.dnetlib.repo.manager.service.security.RoleMappingService;
//import eu.dnetlib.repo.manager.utils.JsonUtils;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.*;
//
//import javax.ws.rs.core.MediaType;
//import javax.ws.rs.core.Response;
//import java.util.Collection;
//
////@RestController
////@RequestMapping(value = "/role-management")
////@Api(description = "Role Management", value = "role-management")
//public class UserRoleController {
//
// private final AaiRegistryService aaiRegistryService;
// private final AuthoritiesUpdater authoritiesUpdater;
// private final RoleMappingService roleMappingService;
// private final AuthorizationService authorizationService;
//
// @Autowired
// UserRoleController(AaiRegistryService aaiRegistryService,
// AuthoritiesUpdater authoritiesUpdater,
// RoleMappingService roleMappingService,
// AuthorizationService authorizationService) {
// this.aaiRegistryService = aaiRegistryService;
// this.authoritiesUpdater = authoritiesUpdater;
// this.roleMappingService = roleMappingService;
// this.authorizationService = authorizationService;
// }
//
// /**
// * Get the role with the given id.
// **/
// @RequestMapping(method = RequestMethod.GET, path = "/role/{id}")
//// @PreAuthorize("hasAnyAuthority('REGISTERED_USER', 'SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
// public Response getRole(@RequestParam(value = "type", defaultValue = "datasource") String type, @PathVariable("id") String id) {
// int roleId = aaiRegistryService.getCouId(type, id);
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role id is: " + roleId).toString()).type(MediaType.APPLICATION_JSON).build();
// }
//
// /**
// * Create a new role with the given name and description.
// **/
// @RequestMapping(method = RequestMethod.POST, path = "/role")
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR')")
// public Response createRole(@RequestBody Role role) {
// aaiRegistryService.createRole(role);
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build();
// }
//
// /**
// * Subscribe to a type(Community, etc.) with id(ee, egi, etc.)
// */
// @ApiOperation(value = "subscribe")
// @RequestMapping(method = RequestMethod.POST, path = "/subscribe/{type}/{id}")
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
// public Response subscribe(@PathVariable("type") String type, @PathVariable("id") String id) {
// Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
// if (coPersonId == null) {
// coPersonId = aaiRegistryService.getCoPersonIdsByEmail();
// }
// Integer couId = aaiRegistryService.getCouId(type, id);
// if (couId != null) {
// aaiRegistryService.assignMemberRole(coPersonId, couId);
//
// // Add role to current authorities
// authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(id));
//
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(MediaType.APPLICATION_JSON).build();
// } else {
// return Response.status(HttpStatus.NOT_FOUND.value()).entity(JsonUtils.createResponse("Role has not been found").toString()).type(MediaType.APPLICATION_JSON).build();
// }
// }
// /////////////////////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////
//
// @RequestMapping(method = RequestMethod.GET, path = "/users/couid/{id}")
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
// public ResponseEntity<String> getUsersByCouId(@PathVariable("id") Integer id) {
//// calls.getUserByCoId()
// return ResponseEntity.ok(aaiRegistryService.getUsersByCouId(id).toString());
// }
//
//
// @RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
// public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
// return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
// }
//
//
// @RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
// @PreAuthorize("hasAuthority('REGISTERED_USER')")
// public ResponseEntity<Collection<String>> getRoleNames() {
// return ResponseEntity.ok(authorizationService.getUserRoles());
// }
//
//}

View File

@ -1,50 +1,55 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.api.functionality.ValidatorServiceException;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
import eu.dnetlib.domain.functionality.validator.JobForValidation;
import eu.dnetlib.domain.functionality.validator.RuleSet;
import java.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
import eu.dnetlib.repo.manager.service.EmailUtils;
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/validator")
@Api(description = "Validator API", tags = {"validator"})
@Tag(name="validator", description = "Validator API")
public class ValidatorController {
@Autowired
ValidatorServiceImpl validatorService;
private ValidatorServiceImpl validatorService;
@Autowired
private EmailUtils emailUtils;
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
@PreAuthorize("hasAuthority('REGISTERED_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
return validatorService.submitJobForValidation(jobForValidation);
}
@RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
@RequestMapping(value = "/reSubmitJobForValidation/{jobId}",method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
return validatorService.reSubmitJobForValidation(email, jobId);
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
return validatorService.reSubmitJobForValidation(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobId);
}
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ -73,17 +78,16 @@ public class ValidatorController {
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('ROLE_USER')")
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
@RequestParam(value = "jobType", required = false)
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
@PreAuthorize("hasAuthority('REGISTERED_USER')")
public List<StoredJob> getStoredJobsNew(@RequestParam(value = "jobType", required = false)
@Parameter(description = "Equals to filter job type on validation history page") String jobType,
@RequestParam("offset") @Parameter(description = "Page number", required = true) String offset,
@RequestParam(value = "limit", required = false,defaultValue = "10") @Parameter(description = "Null value") String limit,
@RequestParam(value = "dateFrom", required = false) @Parameter(description = "Null value") String dateFrom,
@RequestParam(value = "dateTo", required = false) @Parameter(description = "Null value") String dateTo,
@RequestParam("validationStatus") @Parameter(description = "Equals to filter validation jobs", required = true) String validationStatus
) throws ValidatorServiceException {
return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus);
return validatorService.getStoredJobsNew(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, offset, limit, dateFrom, dateTo, validationStatus);
}
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ -94,9 +98,31 @@ public class ValidatorController {
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
return validatorService.getInterfaceInformation(baseUrl);
}
@RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<StoredJob> getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException {
return validatorService.getJobsSummary(repoId,size);
}
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public void validationCompleted(
@RequestParam(value = "repoId") String repoId,
@RequestParam(value = "interfaceId") String interfaceId,
@RequestParam(value = "jobId") String jobId,
@RequestParam(value = "issuerEmail") String issuerEmail,
@RequestParam(value = "isUpdate") boolean isUpdate,
@RequestParam(value = "isSuccess") boolean isSuccess,
@RequestParam(value = "scoreUsage") int scoreUsage,
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
validatorService.onComplete(repoId, interfaceId, jobId, issuerEmail, isUpdate, isSuccess, scoreUsage, scoreContent);
}
}

View File

@ -0,0 +1,188 @@
package eu.dnetlib.repo.manager.domain;
import java.util.Date;
import java.util.Set;
public class ApiDetails {
protected String id = null;
protected String protocol = null;
protected String datasource = null;
protected String contentdescription = null;
protected String eoscDatasourceType = null;
protected String compatibility;
protected String compatibilityOverride;
protected Integer lastCollectionTotal;
protected Date lastCollectionDate;
protected Integer lastAggregationTotal;
protected Date lastAggregationDate;
protected Integer lastDownloadTotal;
protected Date lastDownloadDate;
protected String baseurl;
protected Boolean removable = false;
protected Set<ApiParamDetails> apiParams;
protected String metadataIdentifierPath = "";
@Deprecated
protected String typology = null;
public String getId() {
return id;
}
public String getProtocol() {
return protocol;
}
public String getDatasource() {
return datasource;
}
public String getContentdescription() {
return contentdescription;
}
public String getCompatibility() {
return compatibility;
}
public Integer getLastCollectionTotal() {
return lastCollectionTotal;
}
public Date getLastCollectionDate() {
return lastCollectionDate;
}
public Integer getLastAggregationTotal() {
return lastAggregationTotal;
}
public Date getLastAggregationDate() {
return lastAggregationDate;
}
public Integer getLastDownloadTotal() {
return lastDownloadTotal;
}
public Date getLastDownloadDate() {
return lastDownloadDate;
}
public String getBaseurl() {
return baseurl;
}
public ApiDetails setId(final String id) {
this.id = id;
return this;
}
public ApiDetails setProtocol(final String protocol) {
this.protocol = protocol;
return this;
}
public ApiDetails setDatasource(final String datasource) {
this.datasource = datasource;
return this;
}
public ApiDetails setContentdescription(final String contentdescription) {
this.contentdescription = contentdescription;
return this;
}
public ApiDetails setCompatibility(final String compatibility) {
this.compatibility = compatibility;
return this;
}
public ApiDetails setLastCollectionTotal(final Integer lastCollectionTotal) {
this.lastCollectionTotal = lastCollectionTotal;
return this;
}
public ApiDetails setLastCollectionDate(final Date lastCollectionDate) {
this.lastCollectionDate = lastCollectionDate;
return this;
}
public ApiDetails setLastAggregationTotal(final Integer lastAggregationTotal) {
this.lastAggregationTotal = lastAggregationTotal;
return this;
}
public ApiDetails setLastAggregationDate(final Date lastAggregationDate) {
this.lastAggregationDate = lastAggregationDate;
return this;
}
public ApiDetails setLastDownloadTotal(final Integer lastDownloadTotal) {
this.lastDownloadTotal = lastDownloadTotal;
return this;
}
public ApiDetails setLastDownloadDate(final Date lastDownloadDate) {
this.lastDownloadDate = lastDownloadDate;
return this;
}
public ApiDetails setBaseurl(final String baseurl) {
this.baseurl = baseurl;
return this;
}
public Set<ApiParamDetails> getApiParams() {
return apiParams;
}
public void setApiParams(final Set<ApiParamDetails> apiParams) {
this.apiParams = apiParams;
}
public String getCompatibilityOverride() {
return compatibilityOverride;
}
public ApiDetails setCompatibilityOverride(final String compatibilityOverride) {
this.compatibilityOverride = compatibilityOverride;
return this;
}
public Boolean getRemovable() {
return removable;
}
public ApiDetails setRemovable(final Boolean removable) {
this.removable = removable;
return this;
}
public String getMetadataIdentifierPath() {
return metadataIdentifierPath;
}
public ApiDetails setMetadataIdentifierPath(final String metadataIdentifierPath) {
this.metadataIdentifierPath = metadataIdentifierPath;
return this;
}
public String getEoscDatasourceType() {
return eoscDatasourceType;
}
public ApiDetails setEoscDatasourceType(final String eoscDatasourceType) {
this.eoscDatasourceType = eoscDatasourceType;
return this;
}
public String getTypology() {
return typology;
}
public ApiDetails setTypology(final String typology) {
this.typology = typology;
return this;
}
}

View File

@ -0,0 +1,19 @@
package eu.dnetlib.repo.manager.domain;
import java.util.List;
public class ApiDetailsResponse extends Response {
private List<ApiDetails> api;
public List<ApiDetails> getApi() {
return api;
}
public ApiDetailsResponse setApi(final List<ApiDetails> api) {
this.api = api;
return this;
}
}

View File

@ -0,0 +1,25 @@
package eu.dnetlib.repo.manager.domain;
public class ApiParamDetails {
protected String param;
protected String value;
public String getParam() {
return param;
}
public void setParam(final String param) {
this.param = param;
}
public String getValue() {
return value;
}
public void setValue(final String value) {
this.value = value;
}
}

View File

@ -0,0 +1,36 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
import eu.dnetlib.repo.manager.domain.broker.SimpleSubscriptionDesc;
import java.util.List;
import java.util.Map;
public class BrokerSummary {
private Map<String, List<SimpleSubscriptionDesc>> userSubs;
private List<BrowseEntry> topicsForDatasource;
public BrokerSummary(){}
public BrokerSummary(Map<String, List<SimpleSubscriptionDesc>> userSubs, List<BrowseEntry> topicsForDatasource) {
this.userSubs = userSubs;
this.topicsForDatasource = topicsForDatasource;
}
public Map<String, List<SimpleSubscriptionDesc>> getUserSubs() {
return userSubs;
}
public void setUserSubs(Map<String, List<SimpleSubscriptionDesc>> userSubs) {
this.userSubs = userSubs;
}
public List<BrowseEntry> getTopicsForDatasource() {
return topicsForDatasource;
}
public void setTopicsForDatasource(List<BrowseEntry> topicsForDatasource) {
this.topicsForDatasource = topicsForDatasource;
}
}

View File

@ -0,0 +1,34 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import java.util.List;
public class CollectionMonitorSummary {
private List<AggregationInfo> aggregationInfo;
private AggregationInfo lastIndexedVersion;
public CollectionMonitorSummary(){}
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
this.aggregationInfo = aggregationInfo;
this.lastIndexedVersion = lastIndexedVersion;
}
public List<AggregationInfo> getAggregationInfo() {
return aggregationInfo;
}
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
this.aggregationInfo = aggregationInfo;
}
public AggregationInfo getLastIndexedVersion() {
return lastIndexedVersion;
}
public void setLastIndexedVersion(AggregationInfo lastIndexedVersion) {
this.lastIndexedVersion = lastIndexedVersion;
}
}

View File

@ -1,12 +1,12 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by nikonas on 23/12/15.
*/
public class Constants implements IsSerializable {
public class Constants{
public static final String MODE_LOCAL = "local";
public static final String MODE_DNET = "dnet";
@ -32,6 +32,7 @@ public class Constants implements IsSerializable {
public static final String VALIDATION_MODE_LITERATURE = "literature";
public static final String VALIDATION_MODE_DATA = "data";
public static final String VALIDATION_MODE_CRIS = "cris";
public static final String VALIDATION_MODE_FAIR = "fair";
public static final String VALIDATION_JOB_TYPE_COMPATIBILITY_TEST = "Compatibility Test";
public static final String VALIDATION_JOB_TYPE_REGISTRATION_REQUEST = "Registration Request";

View File

@ -1,4 +1,4 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
public class Country {

View File

@ -0,0 +1,321 @@
package eu.dnetlib.repo.manager.domain;
import javax.persistence.Transient;
import java.util.Date;
import java.util.Set;
public class DatasourceDetails {
protected String id;
@Transient
protected String openaireId;
protected String officialname;
protected String englishname;
protected String websiteurl;
protected String logourl;
protected String contactemail;
protected Double latitude = 0.0;
protected Double longitude = 0.0;
protected Double timezone = 0.0;
protected String namespaceprefix;
protected String languages;
protected Date dateofvalidation;
protected String eoscDatasourceType;
protected Date dateofcollection;
protected String platform;
protected String activationId;
protected String description;
protected String issn;
protected String eissn;
protected String lissn;
protected String registeredby;
protected String subjects;
protected String aggregator = "OPENAIRE";
protected String collectedfrom;
protected Boolean managed;
protected Boolean consentTermsOfUse;
protected Boolean fullTextDownload;
protected Date consentTermsOfUseDate;
protected Date lastConsentTermsOfUseDate;
protected Set<OrganizationDetails> organizations;
protected Set<IdentitiesDetails> identities;
protected String status;
protected String typology;
protected Date registrationdate;
public DatasourceDetails() {
// no arg constructor
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(String openaireId) {
this.openaireId = openaireId;
}
public String getOfficialname() {
return officialname;
}
public void setOfficialname(String officialname) {
this.officialname = officialname;
}
public String getEnglishname() {
return englishname;
}
public void setEnglishname(String englishname) {
this.englishname = englishname;
}
public String getWebsiteurl() {
return websiteurl;
}
public void setWebsiteurl(String websiteurl) {
this.websiteurl = websiteurl;
}
public String getLogourl() {
return logourl;
}
public void setLogourl(String logourl) {
this.logourl = logourl;
}
public String getContactemail() {
return contactemail;
}
public void setContactemail(String contactemail) {
this.contactemail = contactemail;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public String getNamespaceprefix() {
return namespaceprefix;
}
public void setNamespaceprefix(String namespaceprefix) {
this.namespaceprefix = namespaceprefix;
}
public String getLanguages() {
return languages;
}
public void setLanguages(String languages) {
this.languages = languages;
}
public Date getDateofvalidation() {
return dateofvalidation;
}
public void setDateofvalidation(Date dateofvalidation) {
this.dateofvalidation = dateofvalidation;
}
public String getEoscDatasourceType() {
return eoscDatasourceType;
}
public void setEoscDatasourceType(String eoscDatasourceType) {
this.eoscDatasourceType = eoscDatasourceType;
}
public Date getDateofcollection() {
return dateofcollection;
}
public void setDateofcollection(Date dateofcollection) {
this.dateofcollection = dateofcollection;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getActivationId() {
return activationId;
}
public void setActivationId(String activationId) {
this.activationId = activationId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIssn() {
return issn;
}
public void setIssn(String issn) {
this.issn = issn;
}
public String getEissn() {
return eissn;
}
public void setEissn(String eissn) {
this.eissn = eissn;
}
public String getLissn() {
return lissn;
}
public void setLissn(String lissn) {
this.lissn = lissn;
}
public String getRegisteredby() {
return registeredby;
}
public void setRegisteredby(String registeredby) {
this.registeredby = registeredby;
}
public String getSubjects() {
return subjects;
}
public void setSubjects(String subjects) {
this.subjects = subjects;
}
public String getAggregator() {
return aggregator;
}
public void setAggregator(String aggregator) {
this.aggregator = aggregator;
}
public String getCollectedfrom() {
return collectedfrom;
}
public void setCollectedfrom(String collectedfrom) {
this.collectedfrom = collectedfrom;
}
public Boolean getManaged() {
return managed;
}
public void setManaged(Boolean managed) {
this.managed = managed;
}
public Boolean getConsentTermsOfUse() {
return consentTermsOfUse;
}
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
this.consentTermsOfUse = consentTermsOfUse;
}
public Boolean getFullTextDownload() {
return fullTextDownload;
}
public void setFullTextDownload(Boolean fullTextDownload) {
this.fullTextDownload = fullTextDownload;
}
public Date getConsentTermsOfUseDate() {
return consentTermsOfUseDate;
}
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) {
this.consentTermsOfUseDate = consentTermsOfUseDate;
}
public Date getLastConsentTermsOfUseDate() {
return lastConsentTermsOfUseDate;
}
public void setLastConsentTermsOfUseDate(Date lastConsentTermsOfUseDate) {
this.lastConsentTermsOfUseDate = lastConsentTermsOfUseDate;
}
public Set<OrganizationDetails> getOrganizations() {
return organizations;
}
public void setOrganizations(Set<OrganizationDetails> organizations) {
this.organizations = organizations;
}
public Set<IdentitiesDetails> getIdentities() {
return identities;
}
public void setIdentities(Set<IdentitiesDetails> identities) {
this.identities = identities;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTypology() {
return typology;
}
public void setTypology(String typology) {
this.typology = typology;
}
public Date getRegistrationdate() {
return registrationdate;
}
public void setRegistrationdate(Date registrationdate) {
this.registrationdate = registrationdate;
}
}

View File

@ -0,0 +1,24 @@
package eu.dnetlib.repo.manager.domain;
import com.google.common.collect.Lists;
import java.util.List;
public class DatasourceResponse extends Response {
private List<DatasourceDetails> datasourceInfo = Lists.newArrayList();
public DatasourceResponse addDatasourceInfo(final DatasourceDetails datasourceInfo) {
getDatasourceInfo().add(datasourceInfo);
return this;
}
public List<DatasourceDetails> getDatasourceInfo() {
return datasourceInfo;
}
public DatasourceResponse setDatasourceInfo(final List<DatasourceDetails> datasourceInfo) {
this.datasourceInfo = datasourceInfo;
return this;
}
}

View File

@ -1,7 +1,4 @@
package eu.dnetlib.repo.manager.shared;
import com.google.gwt.user.client.rpc.IsSerializable;
import eu.dnetlib.domain.data.Repository;
package eu.dnetlib.repo.manager.domain;
import java.util.ArrayList;
import java.util.List;
@ -9,7 +6,7 @@ import java.util.List;
/**
* Created by nikonas on 14/1/16.
*/
public class DatasourcesCollection implements IsSerializable{
public class DatasourcesCollection{
private List<Repository> datasourcesOfUser;
private List<Repository> sharedDatasources;

View File

@ -0,0 +1,79 @@
package eu.dnetlib.repo.manager.domain;
import com.google.common.collect.Lists;
import com.google.gson.GsonBuilder;
import java.util.List;
import java.util.Queue;
import java.util.stream.Collectors;
public class Header {
private long total;
private int page;
private int size;
private long time;
private int statusCode;
private List<String> errors = Lists.newArrayList();
private Queue<Throwable> exceptions = Lists.newLinkedList();
public static Header newInsance() {
return new Header();
}
public Header() {
}
public long getTime() {
return time;
}
public Header setTime(final long time) {
this.time = time;
return this;
}
public int getStatusCode() {
return statusCode;
}
public Header setStatusCode(final int statusCode) {
this.statusCode = statusCode;
return this;
}
public long getTotal() {
return total;
}
public int getPage() {
return page;
}
public int getSize() {
return size;
}
public Header setPage(final int page) {
this.page = page;
return this;
}
public Header setSize(final int size) {
this.size = size;
return this;
}
public Header setTotal(final long total) {
this.total = total;
return this;
}
public Queue<Throwable> getExceptions() {
return exceptions;
}
public Header setExceptions(final Queue<Throwable> exceptions) {
this.exceptions = exceptions;
return this;
}
public List<String> getErrors() {
return getExceptions().stream()
.map(Throwable::getMessage)
.collect(Collectors.toList());
}
public Header setErrors(final List<String> errors) {
this.errors = errors;
return this;
}
public String toJson() {
return new GsonBuilder().setPrettyPrinting().create().toJson(this);
}
}

View File

@ -0,0 +1,29 @@
package eu.dnetlib.repo.manager.domain;
public class IdentitiesDetails {
private String pid;
private String issuertype;
public IdentitiesDetails() {
// no arg constructor
}
public String getPid() {
return pid;
}
public String getIssuertype() {
return issuertype;
}
public IdentitiesDetails setPid(final String pid) {
this.pid = pid;
return this;
}
public IdentitiesDetails setIssuertype(final String issuertype) {
this.issuertype = issuertype;
return this;
}
}

View File

@ -0,0 +1,95 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Transient;
import java.util.Date;
@Entity
@IdClass(InterfaceComplianceRequestId.class)
public class InterfaceComplianceRequest {
@Id
String repositoryId;
@Id
String interfaceId;
String desiredCompatibilityLevel;
Date submissionDate;
public InterfaceComplianceRequest() {
this.submissionDate = new Date();
}
public InterfaceComplianceRequest(String repositoryId, String interfaceId, String desiredCompatibilityLevel) {
this.submissionDate = new Date();
this.repositoryId = repositoryId;
this.interfaceId = interfaceId;
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public static InterfaceComplianceRequest from(InterfaceComplianceRequestDTO dto) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
request.setRepositoryId(dto.getRepositoryId());
request.setInterfaceId(dto.getInterfaceId());
if (dto.getSubmissionDate() != null) {
request.setSubmissionDate(dto.getSubmissionDate());
} else {
request.setSubmissionDate(new Date());
}
request.setDesiredCompatibilityLevel(dto.getDesiredCompatibilityLevel());
return request;
}
@Transient
public InterfaceComplianceRequestId getId() {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.repositoryId = this.repositoryId;
id.interfaceId = this.interfaceId;
return id;
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public String getDesiredCompatibilityLevel() {
return desiredCompatibilityLevel;
}
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public Date getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(Date submissionDate) {
this.submissionDate = submissionDate;
}
@Override
public String toString() {
return "InterfaceComplianceRequest{" +
"repositoryId='" + repositoryId + '\'' +
", interfaceId='" + interfaceId + '\'' +
", desiredCompatibilityLevel='" + desiredCompatibilityLevel + '\'' +
", submissionDate=" + submissionDate +
'}';
}
}

View File

@ -0,0 +1,50 @@
package eu.dnetlib.repo.manager.domain;
import java.io.Serializable;
public class InterfaceComplianceRequestId implements Serializable {
String repositoryId;
String interfaceId;
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public static InterfaceComplianceRequestId of(String repositoryId, String interfaceId) {
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
id.setRepositoryId(repositoryId);
id.setInterfaceId(interfaceId);
return id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof InterfaceComplianceRequestId)) return false;
InterfaceComplianceRequestId that = (InterfaceComplianceRequestId) o;
if (getRepositoryId() != null ? !getRepositoryId().equals(that.getRepositoryId()) : that.getRepositoryId() != null)
return false;
return getInterfaceId() != null ? getInterfaceId().equals(that.getInterfaceId()) : that.getInterfaceId() == null;
}
@Override
public int hashCode() {
int result = getRepositoryId() != null ? getRepositoryId().hashCode() : 0;
result = 31 * result + (getInterfaceId() != null ? getInterfaceId().hashCode() : 0);
return result;
}
}

View File

@ -1,13 +1,12 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.List;
/**
* Created by nikonas on 7/1/16.
*/
public class InterfaceInformation implements IsSerializable {
public class InterfaceInformation{
private boolean identified;
private List<String> sets;

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
import eu.dnetlib.domain.functionality.validator.StoredJob;
import java.util.List;
@ -8,7 +8,7 @@ import java.util.List;
/**
* Created by nikonas on 29/3/16.
*/
public class JobsOfUser implements IsSerializable {
public class JobsOfUser {
private int totalJobs;
private int totalJobsSuccessful;

View File

@ -1,11 +1,11 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefania on 11/6/17.
*/
public class MetricsInfo implements IsSerializable {
public class MetricsInfo {
private MetricsNumbers metricsNumbers;
private String diagramsBaseURL;

View File

@ -1,14 +1,13 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.List;
/**
* Created by stefania on 11/7/17.
*/
public class MetricsNumbers implements IsSerializable {
public class MetricsNumbers{
private List<String> downloads;
private List<String> views;

View File

@ -0,0 +1,26 @@
package eu.dnetlib.repo.manager.domain;
public enum OrderByField {
REPOSITORY_NAME("repositoryname"),
REPOSITORY_ID("repositoryid"),
SITE_ID("siteid"),
CREATION_DATE("creationdate"),
VALIDATION_DATE("validationdate"),
REQUESTOR_NAME("requestorname"),
REQUESTOR_EMAIL("requestoremail"),
VALIDATED("validated"),
COUNTRY("country");
private final String text;
OrderByField(String text) {
this.text = text;
}
@Override
public String toString() {
return text;
}
}

View File

@ -0,0 +1,18 @@
package eu.dnetlib.repo.manager.domain;
public enum OrderByType {
ASC("ASC"),
DSC("DESC");
private final String text;
OrderByType(String text) {
this.text = text;
}
@Override
public String toString() {
return text;
}
}

View File

@ -1,8 +1,8 @@
package eu.dnetlib.repo.manager.domain;
import java.io.Serializable;
public class Organization implements Serializable {
public class Organization{
private String country;
private String legalname;
private String websiteurl;

View File

@ -0,0 +1,54 @@
package eu.dnetlib.repo.manager.domain;
public class OrganizationDetails {
private String legalshortname;
private String legalname;
private String websiteurl;
private String logourl;
private String country;
public OrganizationDetails() {
// no arg constructor
}
public String getLegalshortname() {
return legalshortname;
}
public void setLegalshortname(String legalshortname) {
this.legalshortname = legalshortname;
}
public String getLegalname() {
return legalname;
}
public void setLegalname(String legalname) {
this.legalname = legalname;
}
public String getWebsiteurl() {
return websiteurl;
}
public void setWebsiteurl(String websiteurl) {
this.websiteurl = websiteurl;
}
public String getLogourl() {
return logourl;
}
public void setLogourl(String logourl) {
this.logourl = logourl;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}

View File

@ -0,0 +1,89 @@
package eu.dnetlib.repo.manager.domain;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
public class Paging<T> {
private int total;
private int from;
private int to;
private List<T> results;
public Paging(int total, int from, int to, List<T> results) {
this.total = total;
this.from = from;
this.to = to;
this.results = results;
}
public Paging(@NotNull Paging<T> page) {
this.total = page.getTotal();
this.from = page.getFrom();
this.to = page.getTo();
this.results = page.getResults();
}
public <K> Paging(@NotNull Paging<K> page, List<T> results) {
this.total = page.getTotal();
this.from = page.getFrom();
this.to = page.getTo();
this.results = results;
}
public Paging() {
this.total = 0;
this.from = 0;
this.to = 0;
this.results = new ArrayList<>();
}
public static <K> Paging<K> of(Header header, List<K> results) {
Paging<K> paging = new Paging<>();
paging.setFrom(header.getPage() * header.getSize());
paging.setTo(paging.getFrom() + header.getSize() - 1);
if (paging.getTo() > header.getTotal()) {
paging.setTo((int) header.getTotal() - 1);
}
paging.setTotal((int) header.getTotal());
paging.setResults(results);
return paging;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getFrom() {
return from;
}
public void setFrom(int from) {
this.from = from;
}
public int getTo() {
return to;
}
public void setTo(int to) {
this.to = to;
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
}

View File

@ -0,0 +1,53 @@
package eu.dnetlib.repo.manager.domain;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class PendingUserRole {
@Id
long id;
int coPersonId;
int couId;
public PendingUserRole() {
// no-arg constructor
}
public PendingUserRole(int coPersonId, int couId) {
this.coPersonId = coPersonId;
this.couId = couId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getCoPersonId() {
return coPersonId;
}
public void setCoPersonId(int coPersonId) {
this.coPersonId = coPersonId;
}
public int getCouId() {
return couId;
}
public void setCouId(int couId) {
this.couId = couId;
}
@Override
public String toString() {
return "PendingUserRole{" +
"coPersonId=" + coPersonId +
", couId=" + couId +
'}';
}
}

View File

@ -0,0 +1,92 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.domain.data.DataCollectionType;
import eu.dnetlib.domain.data.PiwikInfo;
import java.util.ArrayList;
import java.util.List;
/**
* The domain object for the Repository resource data structure
*
*/
public class Repository extends DatasourceDetails {
private static final long serialVersionUID = -7241644234046760972L;
private List<RepositoryInterface> interfaces = new ArrayList<>();
private static List<DataCollectionType> dataCollectionTypes = new ArrayList<>();
private PiwikInfo piwikInfo;
public Repository() {
}
public List<RepositoryInterface> getInterfaces() {
return interfaces;
}
public void setInterfaces(List<RepositoryInterface> interfaces) {
this.interfaces = interfaces;
}
public Double getTimezone() {
return timezone;
}
public void setTimezone(Double timezone) throws IllegalArgumentException {
if (timezone < -12 || timezone > 12 || (timezone % 0.5) != 0) {
String t = String.valueOf(timezone);
throw new IllegalArgumentException(
"timezone must be in the range [-12.0, 12.0] and must me divided by 0.5. Value given is "
+ t);
}
this.timezone = timezone;
}
public List<DataCollectionType> getDataCollectionTypes() {
return dataCollectionTypes;
}
public void setDataCollectionTypes(
List<DataCollectionType> dataCollectionTypes) {
this.dataCollectionTypes = dataCollectionTypes;
}
public PiwikInfo getPiwikInfo() {
return piwikInfo;
}
public void setPiwikInfo(PiwikInfo piwikInfo) {
this.piwikInfo = piwikInfo;
}
@Override
public int hashCode() {
return officialname.hashCode();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Repository))
return false;
else
return this.equals((Repository) o);
}
public boolean equals(Repository r) {
// TODO: fill with required fields...
if (this.getEnglishname() != null && r.getEnglishname() == null) {
return false;
} else if (this.getEnglishname() == null
&& r.getEnglishname() != null) {
return false;
} else if (this.getEnglishname() != null
&& r.getEnglishname() != null) {
return this.getEnglishname().equals(r.getEnglishname());
}
return true;
}
}

View File

@ -0,0 +1,57 @@
package eu.dnetlib.repo.manager.domain;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public class RepositoryInterface extends ApiDetails {
private static final long serialVersionUID = 8013272950607614479L;
public void updateApiParam(String param, String value) {
for (ApiParamDetails entry : apiParams) {
if (entry.getParam().equals(param)) {
entry.setValue(value);
return;
}
}
ApiParamDetails newSet = new ApiParamDetails();
newSet.setParam(param);
newSet.setValue(value);
this.apiParams.add(newSet);
}
public void setAccessSet(String accessSet) {
if (accessSet != null) {
updateApiParam("set", accessSet);
}
}
public String getAccessSet() {
Map<String, String> map;
if (apiParams != null) {
map = apiParams.stream()
.filter(Objects::nonNull)
.filter(k -> k.getParam() != null && k.getValue() != null)
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
return map.get("set");
}
return null;
}
public void setAccessFormat(String accessFormat) {
updateApiParam("format", accessFormat);
}
public String getAccessFormat() {
Map<String, String> map;
if (apiParams != null) {
map = apiParams.stream()
.filter(Objects::nonNull)
.filter(k -> k.getParam() != null && k.getValue() != null)
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
return map.get("format");
}
return null;
}
}

View File

@ -1,19 +1,36 @@
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
public class RepositorySnippet implements IsSerializable {
import eu.dnetlib.domain.data.PiwikInfo;
import java.util.Date;
import java.util.Set;
public class RepositorySnippet {
// Do not refactor names to keep compatibility with external api.
private String id;
private String officialname;
private String englishname;
private String websiteurl;
private String typology;
private String registeredby;
private Organization[] organizations;
private String registrationdate;
public RepositorySnippet() {}
private String registeredby;
private Date registrationdate;
private String eoscDatasourceType;
private String logoUrl;
private String description;
private Boolean consentTermsOfUse;
private Date consentTermsOfUseDate;
private Date lastConsentTermsOfUseDate;
private Boolean fullTextDownload;
private Set<OrganizationDetails> organizations;
private String typology;
private PiwikInfo piwikInfo;
public RepositorySnippet() {
}
public String getId() {
return id;
@ -63,19 +80,82 @@ public class RepositorySnippet implements IsSerializable {
this.typology = typology;
}
public Organization[] getOrganizations() {
public Set<OrganizationDetails> getOrganizations() {
return organizations;
}
public void setOrganizations(Organization[] organizations) {
public void setOrganizations(Set<OrganizationDetails> organizations) {
this.organizations = organizations;
}
public String getRegistrationdate() {
public Date getRegistrationdate() {
return registrationdate;
}
public void setRegistrationdate(String registrationdate) {
public void setRegistrationdate(Date registrationdate) {
this.registrationdate = registrationdate;
}
public PiwikInfo getPiwikInfo() {
return piwikInfo;
}
public void setPiwikInfo(PiwikInfo piwikInfo) {
this.piwikInfo = piwikInfo;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Boolean getFullTextDownload() {
return fullTextDownload;
}
public void setFullTextDownload(Boolean fullTextDownload) {
this.fullTextDownload = fullTextDownload;
}
public Boolean getConsentTermsOfUse() {
return consentTermsOfUse;
}
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
this.consentTermsOfUse = consentTermsOfUse;
}
public Date getConsentTermsOfUseDate() {
return consentTermsOfUseDate;
}
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) {
this.consentTermsOfUseDate = consentTermsOfUseDate;
}
public Date getLastConsentTermsOfUseDate() {
return lastConsentTermsOfUseDate;
}
public void setLastConsentTermsOfUseDate(Date lastConsentTermsOfUseDate) {
this.lastConsentTermsOfUseDate = lastConsentTermsOfUseDate;
}
public String getEoscDatasourceType() {
return eoscDatasourceType;
}
public void setEoscDatasourceType(String eoscDatasourceType) {
this.eoscDatasourceType = eoscDatasourceType;
}
}

View File

@ -1,10 +1,10 @@
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;
public class RepositorySummaryInfo implements IsSerializable {
public class RepositorySummaryInfo{
String id;
String repositoryName;

View File

@ -7,6 +7,7 @@ public class RequestFilter{
private String registeredby = null;
private String typology = null;
private String eoscDatasourceType = null;
private String country = null;
private String id = null;
private String officialname = null;
@ -28,6 +29,14 @@ public class RequestFilter{
this.typology = typology;
}
public String getEoscDatasourceType() {
return eoscDatasourceType;
}
public void setEoscDatasourceType(String eoscDatasourceType) {
this.eoscDatasourceType = eoscDatasourceType;
}
public String getRegisteredby() {
return registeredby;
}

View File

@ -0,0 +1,20 @@
package eu.dnetlib.repo.manager.domain;
public class Response {
private Header header;
public Response() {
this.header = new Header();
}
public Header getHeader() {
return header;
}
public Response setHeader(final Header header) {
this.header = header;
return this;
}
}

View File

@ -1,16 +1,16 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by panagiotis on 15/1/2018.
*/
public class Term implements IsSerializable {
public class Term {
public String englishName;
public String nativeName;
public String encoding;
public String code;
private String englishName;
private String nativeName;
private String encoding;
private String code;
public Term(String englishName, String nativeName, String encoding, String code) {
this.englishName = englishName;

View File

@ -0,0 +1,16 @@
package eu.dnetlib.repo.manager.domain;
public class Timezone{
private String name;
private double offset;
public Timezone(){
}
public Timezone(String name, double offset) {
super();
this.name = name;
this.offset = offset;
}
}

View File

@ -1,11 +1,11 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefania on 3/8/16.
*/
public class Triple<K, V, L> extends Tuple<K, V> implements IsSerializable {
public class Triple<K, V, L> extends Tuple<K, V> {
private L third;

View File

@ -1,11 +1,11 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefania on 12/18/15.
*/
public class Tuple<K, V> implements IsSerializable {
public class Tuple<K, V> {
private K first;
private V second;

View File

@ -0,0 +1,33 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.domain.data.PiwikInfo;
public class UsageSummary {
private MetricsInfo metricsInfo;
private PiwikInfo piwikInfo;
public UsageSummary() {
}
public UsageSummary(MetricsInfo metricsInfo, PiwikInfo piwikInfo) {
this.metricsInfo = metricsInfo;
this.piwikInfo = piwikInfo;
}
public MetricsInfo getMetricsInfo() {
return metricsInfo;
}
public void setMetricsInfo(MetricsInfo metricsInfo) {
this.metricsInfo = metricsInfo;
}
public PiwikInfo getPiwikInfo() {
return piwikInfo;
}
public void setPiwikInfo(PiwikInfo piwikInfo) {
this.piwikInfo = piwikInfo;
}
}

View File

@ -1,11 +1,11 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.domain;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefania on 3/8/16.
*/
public class Vocabulary implements IsSerializable {
public class Vocabulary {
private String id;
private String name;

View File

@ -1,11 +1,11 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.ArrayList;
import java.util.List;
public class AdvQueryObject implements IsSerializable {
public class AdvQueryObject {
private String datasource = "";
private String topic = "";

View File

@ -1,14 +1,12 @@
package eu.dnetlib.repo.manager.shared.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 26/10/2016.
*/
public class BrowseEntry implements Comparable<BrowseEntry>, IsSerializable{
public class BrowseEntry implements Comparable<BrowseEntry>{
public String value;
public Long size;
private String value;
private Long size;
public BrowseEntry() {
}

View File

@ -0,0 +1,10 @@
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 17/3/2017.
*/
public enum ConditionOperator {
EXACT, MATCH_ANY, MATCH_ALL, RANGE
}

View File

@ -1,11 +1,9 @@
package eu.dnetlib.repo.manager.shared.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 17/3/2017.
*/
public class ConditionParams implements IsSerializable {
public class ConditionParams {
private String value;
private String otherValue;

View File

@ -1,14 +1,14 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
import eu.dnetlib.repo.manager.shared.Tuple;
import eu.dnetlib.repo.manager.domain.Tuple;
import java.util.List;
/**
* Created by stefanos on 31/10/2016.
*/
public class DatasourcesBroker implements IsSerializable {
public class DatasourcesBroker {
private List<Tuple<BrowseEntry, String>> datasourcesOfUser;
private List<Tuple<BrowseEntry, String>> sharedDatasources;

View File

@ -1,27 +1,26 @@
package eu.dnetlib.repo.manager.shared.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.domain.broker;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import java.util.List;
/**
* Created by stefanos on 26/10/2016.
*/
public class EventsPage implements IsSerializable{
public class EventsPage{
private String datasource;
private String topic;
private long currPage;
private long totalPages;
private long total;
private List<OpenAireEventPayload> values;
private List<OaBrokerEventPayload> values;
public EventsPage() {
}
public EventsPage(final String datasource, final String topic, final long currPage, final long totalPages, final long total,
final List<OpenAireEventPayload> values) {
final List<OaBrokerEventPayload> values) {
this.datasource = datasource;
this.topic = topic;
this.currPage = currPage;
@ -70,11 +69,11 @@ public class EventsPage implements IsSerializable{
this.total = total;
}
public List<OpenAireEventPayload> getValues() {
public List<OaBrokerEventPayload> getValues() {
return values;
}
public void setValues(List<OpenAireEventPayload> values) {
public void setValues(List<OaBrokerEventPayload> values) {
this.values = values;
}
}

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.ArrayList;
import java.util.List;
@ -8,7 +8,7 @@ import java.util.List;
/**
* Created by stefanos on 17/3/2017.
*/
public class MapConditions implements IsSerializable {
public class MapConditions {
private String field;
private MapValueType fieldType;

View File

@ -1,10 +1,9 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefanos on 17/3/2017.
*/
public enum MapValueType implements IsSerializable {
public enum MapValueType {
STRING, INTEGER, FLOAT, DATE, BOOLEAN, LIST_STRING, LIST_INTEGER, LIST_FLOAT, LIST_DATE, LIST_BOOLEAN;
}

View File

@ -0,0 +1,10 @@
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 10-Mar-17.
*/
public enum NotificationFrequency {
never, realtime, daily, weekly, monthly
}

View File

@ -0,0 +1,10 @@
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 10-Mar-17.
*/
public enum NotificationMode {
MOCK, EMAIL
}

View File

@ -1,12 +1,11 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by stefanos on 10-Mar-17.
*/
public class OpenaireSubscription implements IsSerializable {
public class OpenaireSubscription {
private String subscriber;
private NotificationFrequency frequency;

View File

@ -1,11 +1,9 @@
package eu.dnetlib.repo.manager.shared.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 26/10/2016.
*/
public class Range implements IsSerializable {
public class Range{
private String min;
private String max;

View File

@ -1,13 +1,13 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;
/**
* Created by stefanos on 10-Mar-17.
*/
public class SimpleSubscriptionDesc implements IsSerializable {
public class SimpleSubscriptionDesc {
private String id;
private String datasource;

View File

@ -1,17 +1,15 @@
package eu.dnetlib.repo.manager.shared.broker;
package eu.dnetlib.repo.manager.domain.broker;
/**
* Created by stefanos on 10-Mar-17.
*/
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;
import java.util.List;
public class Subscription implements IsSerializable {
public class Subscription{
private String subscriptionId;

View File

@ -0,0 +1,47 @@
package eu.dnetlib.repo.manager.domain.dto;
import java.util.Date;
public class InterfaceComplianceRequestDTO {
String repositoryId;
String interfaceId;
String desiredCompatibilityLevel;
Date submissionDate;
public InterfaceComplianceRequestDTO() {
// no-arg constructor
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getInterfaceId() {
return interfaceId;
}
public void setInterfaceId(String interfaceId) {
this.interfaceId = interfaceId;
}
public String getDesiredCompatibilityLevel() {
return desiredCompatibilityLevel;
}
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
}
public Date getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(Date submissionDate) {
this.submissionDate = submissionDate;
}
}

View File

@ -0,0 +1,64 @@
package eu.dnetlib.repo.manager.domain.dto;
import java.util.Date;
public class RepositoryTerms {
private String id;
private String name;
private Boolean consentTermsOfUse;
private Boolean fullTextDownload;
private Date consentTermsOfUseDate;
private Date lastConsentTermsOfUseDate;
public RepositoryTerms() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getConsentTermsOfUse() {
return consentTermsOfUse;
}
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
this.consentTermsOfUse = consentTermsOfUse;
}
public Boolean getFullTextDownload() {
return fullTextDownload;
}
public void setFullTextDownload(Boolean fullTextDownload) {
this.fullTextDownload = fullTextDownload;
}
public Date getConsentTermsOfUseDate() {
return consentTermsOfUseDate;
}
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) {
this.consentTermsOfUseDate = consentTermsOfUseDate;
}
public Date getLastConsentTermsOfUseDate() {
return lastConsentTermsOfUseDate;
}
public void setLastConsentTermsOfUseDate(Date lastConsentTermsOfUseDate) {
this.lastConsentTermsOfUseDate = lastConsentTermsOfUseDate;
}
}

View File

@ -0,0 +1,32 @@
package eu.dnetlib.repo.manager.domain.dto;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Role {
String name;
String description;
public Role() {}
public Role(String name, String description) {
this.name = name;
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,61 @@
package eu.dnetlib.repo.manager.domain.dto;
import org.mitre.openid.connect.model.UserInfo;
public class User {
private String sub;
private String firstName;
private String lastName;
private String email;
public User() {}
public User(String sub, String firstName, String lastName, String email) {
this.sub = sub;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public static User from(UserInfo userInfo) {
User user = new User();
user.setSub(user.getSub());
user.setFirstName(userInfo.getGivenName());
user.setLastName(userInfo.getFamilyName());
user.setEmail(userInfo.getEmail());
return user;
}
public String getSub() {
return sub;
}
public void setSub(String sub) {
this.sub = sub;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.exception;
/**

View File

@ -1,8 +1,5 @@
package eu.dnetlib.repo.manager.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.io.IOException;
//@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)

View File

@ -1,13 +1,11 @@
package eu.dnetlib.repo.manager.shared;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.exception;
/**
* Created by nikonas on 7/12/15.
*/
public class RepositoryServiceException extends Exception implements IsSerializable {
public class RepositoryServiceException extends Exception {
public enum ErrorCode implements IsSerializable {
public enum ErrorCode{
REPOSITORY_ALREADY_EXISTS,
SQL_ERROR,
NOT_ACTIVATED,

View File

@ -0,0 +1,13 @@
package eu.dnetlib.repo.manager.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.CONFLICT)
public class ResourceConflictException extends RuntimeException {
public ResourceConflictException(String message) {
super(message);
}
}

View File

@ -9,6 +9,10 @@ public class ResourceNotFoundException extends Exception {
super("Resource Not Found");
}
public ResourceNotFoundException(String message) {
super(message);
}
public ResourceNotFoundException(String id, String resourceType) {
super(resourceType + " with id " + id + " was not found");
}

View File

@ -1,13 +1,13 @@
package eu.dnetlib.repo.manager.shared;
package eu.dnetlib.repo.manager.exception;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Created by nikonas on 7/12/15.
*/
public class UserAccessException extends Exception implements IsSerializable {
public class UserAccessException extends Exception {
public enum ErrorCode implements IsSerializable {
public enum ErrorCode {
USER_ALREADY_EXISTS,
SQL_ERROR,
INVALID_USERNAME,

View File

@ -1,13 +1,11 @@
package eu.dnetlib.repo.manager.shared;
import com.google.gwt.user.client.rpc.IsSerializable;
package eu.dnetlib.repo.manager.exception;
/**
* Created by nikonas on 7/12/15.
*/
public class ValidationServiceException extends Exception implements IsSerializable {
public class ValidationServiceException extends Exception{
public enum ErrorCode implements IsSerializable {
public enum ErrorCode{
NO_ADMIN_EMAILS,
NOT_VALID_BASEURL,
GENERAL_ERROR, NOT_VALID_SET

View File

@ -0,0 +1,15 @@
package eu.dnetlib.repo.manager.repository;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.Set;
@Repository
public interface InterfaceComplianceRequestsRepository extends CrudRepository<InterfaceComplianceRequest, InterfaceComplianceRequestId> {
Set<InterfaceComplianceRequest> findAllBySubmissionDateBefore(Date submittedBefore);
}

View File

@ -0,0 +1,9 @@
package eu.dnetlib.repo.manager.repository;
import eu.dnetlib.repo.manager.domain.PendingUserRole;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface PendingUserRoleRepository extends CrudRepository<PendingUserRole, Long> {
}

View File

@ -0,0 +1,17 @@
package eu.dnetlib.repo.manager.service;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import org.json.JSONException;
import java.util.List;
import java.util.Map;
public interface AggregationService {
<T extends AggregationInfo> List<T> getRepositoryAggregations(String id) throws JSONException;
<T extends AggregationInfo> List<T> getRepositoryAggregations(String id, int from, int size) throws JSONException;
<T extends AggregationInfo> Map<String, List<T>> getRepositoryAggregationsByYear(String id) throws JSONException;
}

Some files were not shown because too many files have changed in this diff Show More