Compare commits
174 Commits
properties
...
master
Author | SHA1 | Date |
---|---|---|
Konstantinos Spyrou | d1c3d48f7e | |
Konstantinos Spyrou | ada19c64b1 | |
Lampros Smyrnaios | 17d0ac6c33 | |
Lampros Smyrnaios | e4009b7903 | |
Lampros Smyrnaios | 4f1e3a14d4 | |
Lampros Smyrnaios | cb458553f0 | |
Lampros Smyrnaios | c836de5761 | |
Lampros Smyrnaios | 6dfe11484e | |
Lampros Smyrnaios | 0deeb00ee5 | |
Lampros Smyrnaios | b047caee26 | |
Lampros Smyrnaios | 958e6b304e | |
Antonis Lempesis | 44610c172d | |
Lampros Smyrnaios | 547b3107a3 | |
Antonis Lempesis | 4e7ba9d5cb | |
Antonis Lempesis | 62aa87bd86 | |
Lampros Smyrnaios | 7853494a5b | |
Lampros Smyrnaios | d1c336f4e7 | |
Lampros Smyrnaios | 1c9ff0669a | |
Antonis Lempesis | cb8c68e8f9 | |
Antonis Lempesis | 6f964e3d16 | |
Antonis Lempesis | a673450f9c | |
Lampros Smyrnaios | 224d058d89 | |
Lampros Smyrnaios | 91e0b66b28 | |
Lampros Smyrnaios | c838f71227 | |
Lampros Smyrnaios | 0b8e4c4729 | |
Lampros Smyrnaios | a72c5b2fb8 | |
Konstantinos Spyrou | bd315848e0 | |
Konstantinos Spyrou | 4b5132358a | |
Konstantinos Spyrou | 39596cfcc1 | |
Konstantinos Spyrou | 5138605163 | |
Lampros Smyrnaios | 75e97ece26 | |
TheQuaker | 9da5fa5c1e | |
Lampros Smyrnaios | 842468a175 | |
Lampros Smyrnaios | 64fdff095d | |
Lampros Smyrnaios | 11460764a2 | |
Lampros Smyrnaios | 4e1f9cb965 | |
Lampros Smyrnaios | 3cb8e7a5f6 | |
Lampros Smyrnaios | eb42185991 | |
Lampros Smyrnaios | a2a387be90 | |
Lampros Smyrnaios | dc469df9d6 | |
Lampros Smyrnaios | 8f6426eaf6 | |
Konstantinos Spyrou | 6024e0c5b5 | |
Konstantinos Spyrou | ab854a6624 | |
Lampros Smyrnaios | 311442854a | |
Lampros Smyrnaios | dfc4a4690e | |
Lampros Smyrnaios | 0ce67b6355 | |
Lampros Smyrnaios | 54ebb35161 | |
Lampros Smyrnaios | 97e85c2a75 | |
Lampros Smyrnaios | 7cab17c133 | |
Lampros Smyrnaios | d2973871a8 | |
Lampros Smyrnaios | a0fd5f67a7 | |
Lampros Smyrnaios | 59fc344730 | |
Antonis Lempesis | 85f3d1c9dc | |
Lampros Smyrnaios | fe1a398773 | |
Lampros Smyrnaios | 3684f09970 | |
Lampros Smyrnaios | 19fcda5ae1 | |
Konstantinos Spyrou | e9fedc90d4 | |
Konstantinos Spyrou | 0ad86025b3 | |
Konstantinos Spyrou | bae9a132cb | |
Konstantinos Spyrou | b67e98976d | |
Lampros Smyrnaios | c006c7baa0 | |
Lampros Smyrnaios | 8f5aed3aab | |
Lampros Smyrnaios | 0f0163dc2d | |
Antonis Lempesis | 6041bb8f1f | |
Konstantinos Spyrou | 401de371b2 | |
Konstantinos Spyrou | ccf826ee42 | |
Konstantinos Spyrou | 9ad28a2640 | |
Lampros Smyrnaios | 06cea537bf | |
Lampros Smyrnaios | c1abaad3e1 | |
Lampros Smyrnaios | 3845a5103b | |
Lampros Smyrnaios | 8bf0f76ad6 | |
Lampros Smyrnaios | a239164f97 | |
Konstantinos Spyrou | c2e5af87e8 | |
Konstantinos Spyrou | 19923c19fc | |
Konstantinos Spyrou | 1a3399f7d7 | |
Konstantinos Spyrou | fdd597cf02 | |
Konstantinos Spyrou | 60f8c8cb82 | |
Konstantinos Spyrou | 699b45d62f | |
Konstantinos Spyrou | 287f476bd2 | |
Konstantinos Spyrou | d3bcea79c0 | |
Lampros Smyrnaios | de2ac5631f | |
Lampros Smyrnaios | 97d81ce478 | |
Lampros Smyrnaios | b9cde0f1a9 | |
Lampros Smyrnaios | 40aae5d750 | |
Konstantinos Spyrou | 8c07950459 | |
Konstantinos Spyrou | 9e4817f2bd | |
Konstantinos Spyrou | 4231480cbc | |
Konstantinos Spyrou | 33694d17c1 | |
Konstantinos Spyrou | 0aa604a192 | |
Konstantinos Spyrou | caa1f1244a | |
Konstantinos Spyrou | 63b99ea68e | |
Konstantinos Spyrou | ab03a5164d | |
Konstantinos Spyrou | 607c417e3f | |
Konstantinos Spyrou | aeca9ce38b | |
Antonis Lempesis | 242014f2da | |
Konstantinos Spyrou | 7b7c6b0842 | |
Konstantinos Spyrou | 125b64ec3b | |
Konstantinos Spyrou | 415bb1e197 | |
Konstantinos Spyrou | 95335461a2 | |
Konstantinos Spyrou | f88d9b8381 | |
Konstantinos Spyrou | cda2cd5557 | |
Konstantinos Spyrou | 0674a3c031 | |
Konstantinos Spyrou | 0ea91e909d | |
Konstantinos Spyrou | d5327aedea | |
Konstantinos Spyrou | 7c5020c205 | |
Lampros Smyrnaios | df14f5eaab | |
Konstantinos Spyrou | e4d52c2323 | |
Konstantinos Spyrou | 139fb420d4 | |
Konstantinos Spyrou | 60ff3dce6e | |
Konstantinos Spyrou | 40b20b1122 | |
Konstantinos Spyrou | 49cc3d74e8 | |
Konstantinos Spyrou | e551a7a783 | |
Konstantinos Spyrou | 788dac69ad | |
Konstantinos Spyrou | b1e1185765 | |
Konstantinos Spyrou | 817446df41 | |
Konstantinos Spyrou | 87f610b06b | |
Konstantinos Spyrou | e947fe3fec | |
Lampros Smyrnaios | 96003f9f88 | |
Lampros Smyrnaios | d4e4624a3f | |
Lampros Smyrnaios | eaa4083b04 | |
Lampros Smyrnaios | f136488b0e | |
Konstantinos Spyrou | 720ee5a9a4 | |
Konstantinos Spyrou | 4dd0320255 | |
Konstantinos Spyrou | af0482a9fb | |
Konstantinos Spyrou | 830df7cb52 | |
Konstantinos Spyrou | d8eac0ac10 | |
Lampros Smyrnaios | ceb53248ce | |
Konstantinos Spyrou | 4850581c53 | |
Konstantinos Spyrou | a5a4924c08 | |
Konstantinos Spyrou | 6c2780927d | |
Lampros Smyrnaios | 63c9caaf96 | |
Lampros Smyrnaios | a40c1b3e44 | |
Lampros Smyrnaios | 1a4df2b852 | |
Lampros Smyrnaios | deae3b8b54 | |
Lampros Smyrnaios | f720446bdf | |
Lampros Smyrnaios | db88b2eecb | |
Lampros Smyrnaios | 4a32d0278b | |
Konstantinos Spyrou | b3758da868 | |
Konstantinos Spyrou | a792fd34c1 | |
Lampros Smyrnaios | 36b17e4ef1 | |
Konstantinos Spyrou | 01ba340f47 | |
Konstantinos Spyrou | b533355c4f | |
Konstantinos Spyrou | 33d28cefc1 | |
Konstantinos Spyrou | c09cbbbcc0 | |
Konstantinos Spyrou | 6a5c637f51 | |
Lampros Smyrnaios | 96d8ba8dde | |
Lampros Smyrnaios | dbe13a7ed1 | |
Lampros Smyrnaios | 83c77670ab | |
Konstantinos Spyrou | f41a5c8985 | |
Lampros Smyrnaios | 83f9ce36ce | |
Konstantinos Spyrou | e99f334708 | |
Konstantinos Spyrou | cff16a2d7c | |
Konstantinos Spyrou | ee01491995 | |
Konstantinos Spyrou | 1491d8e280 | |
Konstantinos Spyrou | 82cf64a3e3 | |
Konstantinos Spyrou | 0b322c87d6 | |
Konstantinos Spyrou | 0f73e95209 | |
Antonis Lempesis | 9ca8aed160 | |
Konstantinos Spyrou | 9633710cec | |
Konstantinos Spyrou | a46e64f5b5 | |
Konstantinos Spyrou | 3c41f3206a | |
Konstantinos Spyrou | 0590efba9a | |
Konstantinos Spyrou | 2afd3ef412 | |
Konstantinos Spyrou | c7b7d37ae3 | |
Konstantinos Spyrou | 2a8294a958 | |
Antonis Lempesis | d3f13fc8c2 | |
Antonis Lempesis | d57782444d | |
Antonis Lempesis | a61b259ca3 | |
Konstantinos Spyrou | 94a8b1abf9 | |
Konstantinos Spyrou | 03dad9cb1e | |
Konstantinos Spyrou | bd31f55685 | |
Konstantinos Spyrou | 982d299b2d | |
Antonis Lempesis | 2a57236c9a | |
Antonis Lempesis | 9d38d86c03 |
|
@ -0,0 +1,4 @@
|
|||
# Ignore directories
|
||||
.idea
|
||||
target
|
||||
|
|
@ -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
|
|
@ -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
|
477
pom.xml
477
pom.xml
|
@ -6,23 +6,25 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.4</version>
|
||||
<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>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<spring.boot.version>2.5.4</spring.boot.version>
|
||||
<spring.boot.version>2.7.18</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -30,126 +32,125 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<!--<scope>provided</scope>-->
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
||||
<version>2.2.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
-->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
<version>3.0.0</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>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
<version>1.12.4</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>
|
||||
<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>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<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>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>${log4j.version}</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>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -157,27 +158,33 @@
|
|||
<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>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>2.2</version>
|
||||
<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>
|
||||
|
@ -185,102 +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>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>xerces</groupId>-->
|
||||
<!-- <artifactId>xercesImpl</artifactId>-->
|
||||
<!-- <version>2.11.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.4</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/postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc3</version>
|
||||
<version>42.7.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.tomcat</groupId>-->
|
||||
<!-- <artifactId>tomcat-catalina</artifactId>-->
|
||||
<!-- <version>9.0.22</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</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>
|
||||
|
@ -291,55 +254,40 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<version>2.7.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
<!--<version>3.7.0</version>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>com.netflix.hystrix</groupId>
|
||||
<artifactId>hystrix-core</artifactId>
|
||||
<version>1.5.18</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.netflix.rxjava</groupId>
|
||||
<artifactId>rxjava-core</artifactId>
|
||||
<version>0.20.7</version>
|
||||
</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>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
||||
<dependency>
|
||||
|
@ -350,23 +298,23 @@
|
|||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<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</version>
|
||||
<version>2.3.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1-rev-1</version>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -381,51 +329,20 @@
|
|||
<!-- </exclusions>-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.26.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Enable micrometer >> -->
|
||||
<!-- <dependency> <!– TODO: remove this with ActuatorConfig class –>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-actuator</artifactId>-->
|
||||
<!-- <version>1.3.5.RELEASE</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
|
||||
<!-- <version>2.1.18.RELEASE</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.micrometer</groupId>-->
|
||||
<!-- <artifactId>micrometer-core</artifactId>-->
|
||||
<!-- <version>1.7.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- << Enable micrometer -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-bom</artifactId>
|
||||
<version>2021.0.2</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<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>
|
||||
|
@ -434,7 +351,7 @@
|
|||
<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>
|
||||
|
@ -444,21 +361,23 @@
|
|||
<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>
|
||||
</plugin>
|
||||
-->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>2.16.538</version>
|
||||
<version>2.37.1128</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>java to typeScript</id>
|
||||
|
@ -489,29 +408,75 @@
|
|||
</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>
|
||||
<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>
|
||||
<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>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
<!-- Use this when testing local JARs. -->
|
||||
<!--<repository>
|
||||
<id>libs</id>
|
||||
<url>file:///${project.basedir}/libs</url>
|
||||
</repository>-->
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package eu.dnetlib.repo.manager;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,6 @@ 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.LoginUrlAuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -64,16 +63,15 @@ public class AaiSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.csrf().disable()
|
||||
.authorizeRequests()
|
||||
.regexMatchers("/actuator/.*").permitAll()
|
||||
.regexMatchers("/repositories/.*/metrics/?.*").permitAll()
|
||||
.regexMatchers("/metrics").permitAll()
|
||||
.antMatchers("/api-docs/**","/swagger-ui/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
// .anonymous().disable()
|
||||
.httpBasic()
|
||||
.authenticationEntryPoint(authenticationEntryPoint())
|
||||
.and()
|
||||
.logout().logoutUrl("/openid_logout")
|
||||
.clearAuthentication(true)
|
||||
.invalidateHttpSession(true)
|
||||
.deleteCookies("openAIRESession")
|
||||
.deleteCookies()
|
||||
.logoutSuccessUrl(logoutSuccessUrl)
|
||||
.and()
|
||||
.addFilterBefore(openIdConnectAuthenticationFilter(), AbstractPreAuthenticatedProcessingFilter.class)
|
||||
|
@ -144,12 +142,6 @@ public class AaiSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
return serverConfiguration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LoginUrlAuthenticationEntryPoint authenticationEntryPoint() {
|
||||
return new LoginUrlAuthenticationEntryPoint("/openid_connect_login");
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public OIDCAuthenticationFilter openIdConnectAuthenticationFilter() throws Exception {
|
||||
OIDCAuthenticationFilter oidc = new OIDCAuthenticationFilter();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
|
@ -16,12 +16,12 @@ public class AsyncConfiguration implements AsyncConfigurer {
|
|||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return new AsyncUncaughtExceptionHandler() {
|
||||
private final Logger logger = Logger.getLogger(getClass());
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
||||
//logger.error("Async error", throwable);
|
||||
logger.error("Async error", throwable);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,21 @@ 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.*;
|
||||
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}")
|
||||
@Value("${services.provide.validatorService.url}")
|
||||
private String validatorUrl;
|
||||
|
||||
@Bean(name="vocabularyLoader")
|
||||
@Bean(name = "vocabularyLoader")
|
||||
public VocabularyLoader createVocabularyLoader() throws Exception {
|
||||
ISVocabularyLoader loader = new ISVocabularyLoader();
|
||||
|
||||
|
@ -78,4 +81,4 @@ public class Config {
|
|||
|
||||
return locator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
public class DatasourceConfiguration {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(DatasourceConfiguration.class);
|
||||
|
||||
@Value("${services.provide.db.driverClassName}")
|
||||
private String driverClassname;
|
||||
|
||||
@Value("${services.provide.db.url}")
|
||||
private String URL;
|
||||
|
||||
@Value("${services.provide.db.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${services.provide.db.password}")
|
||||
private String password;
|
||||
|
||||
@Bean
|
||||
public BasicDataSource dataSource(){
|
||||
BasicDataSource basicDataSource = new BasicDataSource();
|
||||
basicDataSource.setDriverClassName(driverClassname);
|
||||
basicDataSource.setUrl(URL);
|
||||
basicDataSource.setUsername(username);
|
||||
basicDataSource.setPassword(password);
|
||||
basicDataSource.setMaxIdle(10);
|
||||
basicDataSource.setMaxActive(100);
|
||||
basicDataSource.setMaxWait(1000);
|
||||
basicDataSource.setValidationQuery("SELECT 1;");
|
||||
basicDataSource.setTestOnBorrow(true);
|
||||
basicDataSource.setTestOnReturn(true);
|
||||
basicDataSource.setTestWhileIdle(true);
|
||||
basicDataSource.setTimeBetweenEvictionRunsMillis(1200000);
|
||||
basicDataSource.setMinEvictableIdleTimeMillis(1800000);
|
||||
basicDataSource.setMinEvictableIdleTimeMillis(5);
|
||||
basicDataSource.setPoolPreparedStatements(true);
|
||||
basicDataSource.setDefaultAutoCommit(true);
|
||||
|
||||
return basicDataSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSourceTransactionManager txManager(){
|
||||
DataSourceTransactionManager txManager = new DataSourceTransactionManager();
|
||||
txManager.setDataSource(dataSource());
|
||||
return txManager;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
|
@ -22,25 +23,26 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
|||
|
||||
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);
|
||||
logger.debug("Front end uri : {}", frontEndURI);
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
|
||||
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getSub());
|
||||
|
||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||
String regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$";
|
||||
Matcher matcher = Pattern.compile(regex).matcher(authOIDC.getAccessTokenValue());
|
||||
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)));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,22 +3,23 @@ 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.apache.log4j.Logger;
|
||||
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.context.annotation.ComponentScan;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@ComponentScan
|
||||
@Component
|
||||
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(OpenAIREAuthoritiesMapper.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(OpenAIREAuthoritiesMapper.class);
|
||||
|
||||
@Value("${services.provide.adminEmail}")
|
||||
String adminEmail;
|
||||
|
@ -33,7 +34,7 @@ public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
|||
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
|
||||
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
|
||||
}
|
||||
logger.debug("user info: " + userInfo + "\nentitlements: " + entitlements);
|
||||
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)) {
|
||||
|
|
|
@ -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 {
|
||||
}
|
|
@ -1,26 +1,22 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
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
|
||||
@ComponentScan(basePackages = {
|
||||
"org.eurocris.openaire.cris.validator.service",
|
||||
"eu.dnetlib.repo.manager.*"})
|
||||
public class RedisConfiguration {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(RedisConfiguration.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(RedisConfiguration.class);
|
||||
|
||||
@Value("${services.provide.redis.host}")
|
||||
private String host;
|
||||
|
@ -35,18 +31,18 @@ public class RedisConfiguration {
|
|||
private String domain;
|
||||
|
||||
@PostConstruct
|
||||
private void init(){
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
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));
|
||||
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);
|
||||
if (password != null) jedisConnectionFactory.setPassword(password);
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
|
@ -56,18 +52,8 @@ public class RedisConfiguration {
|
|||
serializer.setCookieName("openAIRESession");
|
||||
serializer.setCookiePath("/");
|
||||
serializer.setDomainName(domain);
|
||||
LOGGER.info("Serializer : " + serializer);
|
||||
logger.info("Cookie 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.repo.manager.controllers.*;
|
||||
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
|
||||
@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>());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
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 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;
|
||||
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/broker")
|
||||
@Api(description = "Broker API", tags = {"broker"})
|
||||
@Tag(name="broker", description="Broker API")
|
||||
public class BrokerController{
|
||||
|
||||
@Autowired
|
||||
|
@ -33,9 +33,9 @@ public class BrokerController{
|
|||
@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 {
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.service.BrokerService;
|
||||
import eu.dnetlib.repo.manager.service.DashboardService;
|
||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
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.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;
|
||||
|
@ -18,7 +21,7 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/dashboard")
|
||||
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||
@Tag(name="dashboard", description = "Dashboard API")
|
||||
public class DashboardController {
|
||||
|
||||
@Autowired
|
||||
|
@ -27,49 +30,51 @@ public class DashboardController {
|
|||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private AggregationService aggregationService;
|
||||
|
||||
@Autowired
|
||||
private BrokerService brokerService;
|
||||
|
||||
@Autowired
|
||||
private PiWikService piWikService;
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
@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,
|
||||
@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 size) throws JSONException {
|
||||
@RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException {
|
||||
|
||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId);
|
||||
|
||||
List<AggregationDetails> aggregationDetails = repositoryService.getRepositoryAggregations(repoId,0,size);
|
||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||
collectionMonitorSummary.setAggregationDetails(aggregationDetails);
|
||||
size=0;
|
||||
do {
|
||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId,size,size+50);
|
||||
for(AggregationDetails aggregationDetail : aggregationDetails){
|
||||
if(aggregationDetail.getIndexedVersion()){
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||
break;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
size+=30;
|
||||
}while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion()==null);
|
||||
}
|
||||
|
||||
return collectionMonitorSummary;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/usageSummary/{repoId}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
|
@ -79,16 +84,13 @@ public class DashboardController {
|
|||
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/brokerSummary/{ds_name}" , method = RequestMethod.GET,
|
||||
@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));
|
||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package eu.dnetlib.repo.manager.controllers;
|
|||
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
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 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;
|
||||
|
@ -26,42 +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
|
||||
public ServerError securityException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseBody
|
||||
public ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(UnknownHostException.class)
|
||||
@ResponseBody
|
||||
public ServerError unknownHostException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),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
|
||||
public ServerError internalException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
||||
@ExceptionHandler(EndPointException.class)
|
||||
@ResponseBody
|
||||
public ServerError endPointException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -4,11 +4,12 @@ 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 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;
|
||||
|
@ -17,11 +18,10 @@ 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
|
||||
private MonitorServiceImpl monitorService;
|
||||
|
@ -31,13 +31,13 @@ public class MonitorController {
|
|||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public JobsOfUser getJobsOfUser(@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 {
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ 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.domain.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
|
@ -30,40 +31,49 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/piwik")
|
||||
@Api(description = "Piwik API", tags = {"piwik"})
|
||||
@Tag(name="piwik", description = "Piwik API")
|
||||
public class PiWikController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PiWikController.class);
|
||||
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'))")
|
||||
@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("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#piwikInfo.repositoryId) or (@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy=='null' and hasAuthority('REGISTERED_USER'))")
|
||||
@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)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||
@ApiImplicitParam(name = "orderField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||
@ApiImplicitParam(name = "searchField", dataType = "string", paramType = "query"),
|
||||
@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 = "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
|
||||
|
||||
|
@ -76,12 +86,13 @@ public class PiWikController {
|
|||
results.setResults(returning);
|
||||
return results;
|
||||
}
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||
@ApiImplicitParam(name = "searchField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||
@ApiImplicitParam(name = "orderField", dataType = "string", paramType = "query"),
|
||||
|
||||
@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
|
||||
|
@ -103,25 +114,22 @@ public class PiWikController {
|
|||
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()+ ",")+
|
||||
(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName()+ ",")+
|
||||
(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry()+ ",")+
|
||||
(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId()+ ",") +
|
||||
(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken()+ ",")+
|
||||
(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString()+ ",") +
|
||||
(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName()+ ",") +
|
||||
(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail()+ ",")+
|
||||
piwikInfo.isValidated() + "," +
|
||||
(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString()+ ",") +
|
||||
(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment()+ "\n")
|
||||
|
||||
);
|
||||
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());
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,7 +149,6 @@ public class PiWikController {
|
|||
strDate);
|
||||
response.setHeader(headerKey, headerValue);
|
||||
|
||||
|
||||
return new FileSystemResource(p.toFile());
|
||||
|
||||
}
|
||||
|
@ -156,7 +163,7 @@ public class PiWikController {
|
|||
|
||||
@RequestMapping(value = "/getOpenaireId/{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'))")
|
||||
@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);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package eu.dnetlib.repo.manager.controllers;
|
|||
|
||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl;
|
||||
import io.micrometer.core.instrument.binder.jvm.DiskSpaceMetrics;
|
||||
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
|
||||
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
|
||||
|
@ -12,8 +11,8 @@ 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.apache.log4j.Logger;
|
||||
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.web.bind.annotation.RequestMapping;
|
||||
|
@ -24,9 +23,9 @@ import java.io.File;
|
|||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/actuator/prometheus")
|
||||
public class PrometheusController { // TODO: remove this with migration to Spring Boot 2
|
||||
private static final Logger LOGGER = Logger.getLogger(PrometheusController.class);
|
||||
@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;
|
||||
|
@ -37,12 +36,12 @@ public class PrometheusController { // TODO: remove this with migration to Sprin
|
|||
this.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String getPiwikMetrics() {
|
||||
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
||||
registry.counter("provide_repositories_registered").increment(repositoryService.getTotalRegisteredRepositories());
|
||||
registry.counter("provide_usagecounts_repositories_registered").increment(piWikService.getTotal());
|
||||
registry.counter("provide_usagecounts_repositories_validated").increment(piWikService.getValidated(true));
|
||||
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);
|
||||
}
|
||||
|
@ -51,7 +50,11 @@ public class PrometheusController { // TODO: remove this with migration to Sprin
|
|||
public String getMetrics() {
|
||||
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
||||
new JvmThreadMetrics().bindTo(registry);
|
||||
new JvmGcMetrics().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
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
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.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.annotations.Api;
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
|
@ -23,25 +28,34 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/repositories")
|
||||
@Api(description = "Repository API", tags = {"repositories"})
|
||||
@Tag(name="repositories", description="Repository API")
|
||||
public class RepositoryController {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(RepositoryController.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(RepositoryController.class);
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
private final AggregationService aggregationService;
|
||||
|
||||
private final AuthorizationService authorizationService;
|
||||
|
||||
private final PiWikService piWikService;
|
||||
|
||||
@Autowired
|
||||
RepositoryController(RepositoryService repositoryService,
|
||||
AuthorizationService authorizationService) {
|
||||
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)
|
||||
|
@ -55,7 +69,7 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -63,8 +77,26 @@ public class RepositoryController {
|
|||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser() throws Exception {
|
||||
return repositoryService.getRepositoriesSnippetsOfUser("0", "100");
|
||||
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 = "/terms", method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@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,
|
||||
|
@ -78,7 +110,7 @@ public class RepositoryController {
|
|||
@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);
|
||||
}
|
||||
|
@ -86,29 +118,29 @@ public class RepositoryController {
|
|||
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@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 JSONException, ResourceNotFoundException {
|
||||
@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 " + repo.getId() + " registered by " + repo.getRegisteredBy());
|
||||
logger.info("Returning repository {} registered by {}", repo.getId(), repo.getRegisteredby());
|
||||
else
|
||||
logger.info("Requested repository " + id + " not found");
|
||||
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, 0, 20);
|
||||
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,
|
||||
|
@ -116,15 +148,15 @@ 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
|
||||
@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) 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);
|
||||
}
|
||||
|
||||
|
@ -134,11 +166,12 @@ public class RepositoryController {
|
|||
// @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
|
||||
|
@ -146,6 +179,7 @@ public class RepositoryController {
|
|||
return repositoryService.getDnetCountries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
@ -153,6 +187,7 @@ public class RepositoryController {
|
|||
return repositoryService.getTypologies();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
@ -163,8 +198,8 @@ public class RepositoryController {
|
|||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOfInterface(#repository.id)")
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -172,7 +207,8 @@ public class RepositoryController {
|
|||
@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);
|
||||
// repositoryService.deleteRepositoryInterface(id, registeredBy);
|
||||
logger.warn("User attempted delete on Interface with ID: {}", id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||
|
@ -181,10 +217,10 @@ public class RepositoryController {
|
|||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String id,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
||||
@RequestParam(value = "comment", required = false) String comment,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
return repositoryService.addRepositoryInterface(datatype, id, registeredBy, comment, repositoryInterface);
|
||||
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface, desiredCompatibilityLevel);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||
|
@ -192,10 +228,10 @@ public class RepositoryController {
|
|||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String id,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
||||
@RequestParam(value = "comment", required = false) String comment,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
return repositoryService.updateRepositoryInterface(id, registeredBy, comment, repositoryInterface);
|
||||
return repositoryService.updateRepositoryInterface(id, comment, repositoryInterface, desiredCompatibilityLevel);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
|
||||
|
@ -206,13 +242,6 @@ public class RepositoryController {
|
|||
return repositoryService.getUrlsOfUserRepos(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), 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
|
||||
|
@ -238,7 +267,7 @@ public class RepositoryController {
|
|||
@RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getListLatestUpdate(mode);
|
||||
}
|
||||
|
||||
|
@ -273,4 +302,26 @@ public class RepositoryController {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.StatsServiceImpl;
|
||||
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.web.bind.annotation.RequestMapping;
|
||||
|
@ -13,14 +13,13 @@ import java.util.Map;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/stats")
|
||||
@Api(description = "Stats API", tags = {"statistics"})
|
||||
@Tag(name="statistics", description = "Stats API")
|
||||
public class StatsController {
|
||||
|
||||
@Autowired
|
||||
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(){
|
||||
return statsService.getStatistics();
|
||||
|
|
|
@ -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,10 +10,9 @@ 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
|
||||
private SushiliteServiceImpl sushiliteService;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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,7 +11,7 @@ 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
|
||||
|
|
|
@ -1,110 +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.Api;
|
||||
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.getCoPersonIdByEmail();
|
||||
}
|
||||
Integer couId = aaiRegistryService.getCouId(type, id);
|
||||
if (couId != null) {
|
||||
Integer role = aaiRegistryService.getRoleId(coPersonId, couId);
|
||||
aaiRegistryService.assignMemberRole(coPersonId, couId, role);
|
||||
|
||||
// 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.getUserRoles(email));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public ResponseEntity<Collection<String>> getRoleNames() {
|
||||
return ResponseEntity.ok(authorizationService.getUserRoles());
|
||||
}
|
||||
|
||||
}
|
||||
//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());
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -5,12 +5,12 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
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.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;
|
||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/validator")
|
||||
@Api(description = "Validator API", tags = {"validator"})
|
||||
@Tag(name="validator", description = "Validator API")
|
||||
public class ValidatorController {
|
||||
|
||||
@Autowired
|
||||
|
@ -80,12 +80,12 @@ public class ValidatorController {
|
|||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(@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
|
||||
@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(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
||||
}
|
||||
|
@ -112,8 +112,8 @@ public class ValidatorController {
|
|||
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public void validationCompleted(
|
||||
@RequestParam(value = "interfaceId") String interfaceId,
|
||||
@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,
|
||||
|
@ -121,7 +121,7 @@ public class ValidatorController {
|
|||
@RequestParam(value = "scoreUsage") int scoreUsage,
|
||||
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
||||
|
||||
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
||||
validatorService.onComplete(repoId, interfaceId, jobId, issuerEmail, isUpdate, isSuccess, scoreUsage, scoreContent);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class AggregationDetails{
|
||||
|
||||
|
||||
private String aggregationStage;
|
||||
private Date date;
|
||||
private int numberOfRecords;
|
||||
private String collectionMode;
|
||||
private Boolean indexedVersion;
|
||||
|
||||
public AggregationDetails() {
|
||||
}
|
||||
|
||||
public String getAggregationStage() {
|
||||
return aggregationStage;
|
||||
}
|
||||
|
||||
public String getCollectionMode() {
|
||||
return collectionMode;
|
||||
}
|
||||
|
||||
public void setCollectionMode(String collectionMode) {
|
||||
this.collectionMode = collectionMode;
|
||||
}
|
||||
|
||||
public void setAggregationStage(String aggregationStage) {
|
||||
this.aggregationStage = aggregationStage;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public int getNumberOfRecords() {
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
||||
public void setNumberOfRecords(int numberOfRecords) {
|
||||
this.numberOfRecords = numberOfRecords;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(getDate());
|
||||
return String.valueOf(calendar.get(Calendar.YEAR));
|
||||
}
|
||||
|
||||
public Boolean getIndexedVersion() {
|
||||
return indexedVersion;
|
||||
}
|
||||
|
||||
public void setIndexedVersion(Boolean indexedVersion) {
|
||||
this.indexedVersion = indexedVersion;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Aggregations{
|
||||
|
||||
private List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
private AggregationDetails lastCollection;
|
||||
private AggregationDetails lastTransformation;
|
||||
|
||||
public Aggregations() {
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationHistory() {
|
||||
return aggregationHistory;
|
||||
}
|
||||
|
||||
public void setAggregationHistory(List<AggregationDetails> aggregationHistory) {
|
||||
this.aggregationHistory = aggregationHistory;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastCollection() {
|
||||
return lastCollection;
|
||||
}
|
||||
|
||||
public void setLastCollection(AggregationDetails lastCollection) {
|
||||
this.lastCollection = lastCollection;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastTransformation() {
|
||||
return lastTransformation;
|
||||
}
|
||||
|
||||
public void setLastTransformation(AggregationDetails lastTransformation) {
|
||||
this.lastTransformation = lastTransformation;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +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<AggregationDetails> aggregationDetails;
|
||||
private List<AggregationInfo> aggregationInfo;
|
||||
|
||||
private AggregationDetails lastIndexedVersion;
|
||||
private AggregationInfo lastIndexedVersion;
|
||||
|
||||
public CollectionMonitorSummary(){}
|
||||
|
||||
public CollectionMonitorSummary(List<AggregationDetails> aggregationDetails, AggregationDetails lastIndexedVersion) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
|
||||
this.aggregationInfo = aggregationInfo;
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationDetails() {
|
||||
return aggregationDetails;
|
||||
public List<AggregationInfo> getAggregationInfo() {
|
||||
return aggregationInfo;
|
||||
}
|
||||
|
||||
public void setAggregationDetails(List<AggregationDetails> aggregationDetails) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
|
||||
this.aggregationInfo = aggregationInfo;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastIndexedVersion() {
|
||||
public AggregationInfo getLastIndexedVersion() {
|
||||
return lastIndexedVersion;
|
||||
}
|
||||
|
||||
public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) {
|
||||
public void setLastIndexedVersion(AggregationInfo lastIndexedVersion) {
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/17/15.
|
||||
*/
|
||||
public class DatasourceRegistrationState extends WizardState {
|
||||
|
||||
private String mode;
|
||||
private String selectedRepositoryId;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
public DatasourceRegistrationState() {
|
||||
}
|
||||
|
||||
public DatasourceRegistrationState(String mode, String selectedRepositoryId, Repository repository) {
|
||||
this.mode = mode;
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getSelectedRepositoryId() {
|
||||
return selectedRepositoryId;
|
||||
}
|
||||
|
||||
public void setSelectedRepositoryId(String selectedRepositoryId) {
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 21/12/15.
|
||||
*/
|
||||
public class DatasourceVocabularies{
|
||||
|
||||
private Map<String, String> countries;
|
||||
private List<Timezone> timezones;
|
||||
private Map<String, String> datasourceClasses;
|
||||
private List<String> typologies;
|
||||
private Map<String, String> compatibilityLevels;
|
||||
|
||||
public DatasourceVocabularies() {
|
||||
}
|
||||
|
||||
public Map<String, String> getCountries() {
|
||||
return countries;
|
||||
}
|
||||
|
||||
public void setCountries(Map<String, String> countries) {
|
||||
this.countries = countries;
|
||||
}
|
||||
|
||||
public List<Timezone> getTimezones() {
|
||||
return timezones;
|
||||
}
|
||||
|
||||
public void setTimezones(List<Timezone> timezones) {
|
||||
this.timezones = timezones;
|
||||
}
|
||||
|
||||
public Map<String, String> getDatasourceClasses() {
|
||||
return datasourceClasses;
|
||||
}
|
||||
|
||||
public void setDatasourceClasses(Map<String, String> datasourceClasses) {
|
||||
this.datasourceClasses = datasourceClasses;
|
||||
}
|
||||
|
||||
public List<String> getTypologies() {
|
||||
return typologies;
|
||||
}
|
||||
|
||||
public void setTypologies(List<String> typologies) {
|
||||
this.typologies = typologies;
|
||||
}
|
||||
|
||||
public Map<String, String> getCompatibilityLevels() {
|
||||
return compatibilityLevels;
|
||||
}
|
||||
|
||||
public void setCompatibilityLevels(Map<String, String> compatibilityLevels) {
|
||||
this.compatibilityLevels = compatibilityLevels;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,18 @@ public class Paging<T> {
|
|||
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;
|
||||
}
|
||||
|
@ -74,4 +86,4 @@ public class Paging<T> {
|
|||
public void setResults(List<T> results) {
|
||||
this.results = results;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ package eu.dnetlib.repo.manager.domain;
|
|||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
public class RepositorySnippet {
|
||||
|
||||
|
@ -12,15 +13,18 @@ public class RepositorySnippet {
|
|||
private String officialname;
|
||||
private String englishname;
|
||||
private String websiteurl;
|
||||
private String typology;
|
||||
|
||||
private String registeredby;
|
||||
private Organization[] organizations;
|
||||
private String registrationdate;
|
||||
private Date registrationdate;
|
||||
private String eoscDatasourceType;
|
||||
private String logoUrl;
|
||||
private String description;
|
||||
private String fullTextDownload;
|
||||
private String consentTermsOfUse;
|
||||
private Boolean consentTermsOfUse;
|
||||
private Date consentTermsOfUseDate;
|
||||
private Date lastConsentTermsOfUseDate;
|
||||
private Boolean fullTextDownload;
|
||||
private Set<OrganizationDetails> organizations;
|
||||
private String typology;
|
||||
|
||||
|
||||
private PiwikInfo piwikInfo;
|
||||
|
@ -76,19 +80,18 @@ public class RepositorySnippet {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -116,19 +119,19 @@ public class RepositorySnippet {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFullTextDownload() {
|
||||
public Boolean getFullTextDownload() {
|
||||
return fullTextDownload;
|
||||
}
|
||||
|
||||
public void setFullTextDownload(String fullTextDownload) {
|
||||
public void setFullTextDownload(Boolean fullTextDownload) {
|
||||
this.fullTextDownload = fullTextDownload;
|
||||
}
|
||||
|
||||
public String getConsentTermsOfUse() {
|
||||
public Boolean getConsentTermsOfUse() {
|
||||
return consentTermsOfUse;
|
||||
}
|
||||
|
||||
public void setConsentTermsOfUse(String consentTermsOfUse) {
|
||||
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
|
||||
this.consentTermsOfUse = consentTermsOfUse;
|
||||
}
|
||||
|
||||
|
@ -139,4 +142,20 @@ public class RepositorySnippet {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class ValidationState extends WizardState {
|
||||
|
||||
private JobForValidation jobForValidation = new JobForValidation();
|
||||
|
||||
public JobForValidation getJobForValidation() {
|
||||
return jobForValidation;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class WizardState {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
|
||||
/**
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
|
@ -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);
|
||||
}
|
|
@ -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> {
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.repo.manager.utils.DateUtils.getYear;
|
||||
|
||||
@Service("aggregationService")
|
||||
public class AggregationServiceImpl implements AggregationService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AggregationServiceImpl.class);
|
||||
|
||||
|
||||
@Value("${services.provide.clients.dsm}")
|
||||
private String baseAddress;
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
|
||||
public AggregationServiceImpl(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends AggregationInfo> List<T> getRepositoryAggregations(String id) {
|
||||
|
||||
logger.debug("Retrieving aggregations for repository with id : " + id);
|
||||
UriComponents uriComponents = getAggregationHistory(id);
|
||||
|
||||
AggregationHistoryResponseV2 rs = restTemplate.getForObject(uriComponents.toUri(), AggregationHistoryResponseV2.class);
|
||||
|
||||
return rs != null ? (List<T>) rs.getAggregationInfo() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AggregationInfo> List<T> getRepositoryAggregations(String id, int from, int size) {
|
||||
|
||||
List<T> res = getRepositoryAggregations(id);
|
||||
|
||||
return res.subList(from, Math.min(from + size, res.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AggregationInfo> Map<String, List<T>> getRepositoryAggregationsByYear(String id) {
|
||||
logger.debug("Retrieving aggregations (by year) for repository with id : " + id);
|
||||
|
||||
List<T> aggregationHistory = getRepositoryAggregations(id);
|
||||
|
||||
return aggregationHistory.isEmpty() ? new HashMap<>() : createYearMap(aggregationHistory);
|
||||
}
|
||||
|
||||
private <T extends AggregationInfo> Map<String, List<T>> createYearMap(List<T> aggregationHistory) {
|
||||
|
||||
return aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationInfo::getDate).reversed())
|
||||
.collect(Collectors.groupingBy(item -> getYear(item.getDate())));
|
||||
}
|
||||
|
||||
|
||||
private UriComponents getAggregationHistory(String repoId) {
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/dsm/2.0/aggregationhistory/")
|
||||
.path(repoId)
|
||||
.build().expand(repoId).encode();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
|
|
@ -2,21 +2,20 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
|
@ -25,8 +24,12 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("brokerService")
|
||||
public class BrokerServiceImpl implements BrokerService {
|
||||
|
@ -40,15 +43,14 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
@Value("${services.provide.topic_types.url}")
|
||||
private String topicsURL;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
.getLogger(BrokerServiceImpl.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(BrokerServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private HashMap<String, Term> topics = new HashMap<String, Term>();
|
||||
private final HashMap<String, Term> topics = new HashMap<>();
|
||||
|
||||
@PostConstruct
|
||||
private void initDnetTopicsMap() {
|
||||
|
@ -56,14 +58,14 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.set("Content-Type", "application/json");
|
||||
|
||||
LOGGER.debug("Init dnet topics!");
|
||||
logger.debug("Init dnet topics!");
|
||||
try (InputStream is = new URL(topicsURL).openStream()) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(is);
|
||||
for (JsonNode term : root.path("terms"))
|
||||
topics.put(term.path("code").textValue(), parseTerm(term));
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Exception on initDnetTopicsMap", e);
|
||||
logger.error("Exception on initDnetTopicsMap", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
|
||||
|
||||
@Override
|
||||
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws JSONException {
|
||||
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) {
|
||||
long start = System.currentTimeMillis();
|
||||
DatasourcesBroker ret = new DatasourcesBroker();
|
||||
try {
|
||||
|
@ -89,10 +91,10 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Exception on getDatasourcesOfUser", e);
|
||||
logger.error("Exception on getDatasourcesOfUser", e);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("Getting datasources of user in " + (end - start) + "ms");
|
||||
logger.debug("Getting datasources of user in " + (end - start) + "ms");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -112,6 +114,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
|
@ -121,18 +124,19 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
@Override
|
||||
public EventsPage advancedShowEvents(String page,
|
||||
String size,
|
||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException, IOException {
|
||||
AdvQueryObject advQueryObject) throws BrokerException {
|
||||
|
||||
final String service = "/events/{page}/{pageSize}";
|
||||
|
||||
long pageNum = Long.parseLong(page);
|
||||
advQueryObject.setPage(pageNum);
|
||||
|
||||
Map<String, Long> uriParams = new HashMap<>();
|
||||
uriParams.put("page", Long.parseLong(page));
|
||||
uriParams.put("page", pageNum);
|
||||
uriParams.put("pageSize", Long.parseLong(size));
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
advQueryObject.setPage(Long.parseLong(page));
|
||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
|
@ -140,10 +144,10 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
new ParameterizedTypeReference<EventsPage>() {
|
||||
}
|
||||
new ParameterizedTypeReference<EventsPage>() {}
|
||||
);
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -156,7 +160,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
for (RepositorySnippet repo : repositories) {
|
||||
BrowseEntry temp = new BrowseEntry();
|
||||
temp.setValue(repo.getOfficialname());
|
||||
temp.setSize(new Long(0));
|
||||
temp.setSize(0L);
|
||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
||||
temp.setSize(temp.getSize() + e.getSize());
|
||||
}
|
||||
|
@ -165,15 +169,9 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
|
||||
// sort the collection by the second field of the tuple which is size
|
||||
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() {
|
||||
@Override
|
||||
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) {
|
||||
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue());
|
||||
}
|
||||
});
|
||||
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||
long stop = System.currentTimeMillis();
|
||||
System.out.println("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
||||
|
||||
logger.debug("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
@ -181,7 +179,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
public EventsPage showEvents(String datasourceName,
|
||||
String topic,
|
||||
String page,
|
||||
String size) throws BrokerException, JSONException {
|
||||
String size) throws BrokerException {
|
||||
|
||||
final String service = "/events";
|
||||
|
||||
|
@ -199,6 +197,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -210,29 +209,29 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
|
||||
final String service = "/subscriptions";
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail).build().encode().toUri();
|
||||
|
||||
LOGGER.debug(builder.build().encode().toUri());
|
||||
logger.debug("{}", uri);
|
||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
uri,
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException {
|
||||
Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) { //throws BrokerException {
|
||||
throw new NotImplementedException();
|
||||
// return null;
|
||||
//Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,6 +256,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
|
@ -279,6 +279,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return new ResponseEntity<>("OK", HttpStatus.OK);
|
||||
|
@ -301,6 +302,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -330,6 +332,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
||||
import eu.dnetlib.repo.manager.domain.MetricsNumbers;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
||||
import org.apache.log4j.Logger;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.utils.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -12,11 +19,14 @@ import java.util.List;
|
|||
@Service("dashboardService")
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DashboardServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private AggregationService aggregationService;
|
||||
|
||||
@Autowired
|
||||
private BrokerService brokerService;
|
||||
|
||||
|
@ -28,54 +38,55 @@ public class DashboardServiceImpl implements DashboardService {
|
|||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
||||
for (RepositorySnippet repository : repositoriesOfUser) {
|
||||
for (RepositorySnippet repository : repositoriesOfUser)
|
||||
{
|
||||
String repoId = repository.getId();
|
||||
String repoOfficialName = repository.getOfficialname();
|
||||
|
||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||
repositorySummaryInfo.setId(repository.getId());
|
||||
repositorySummaryInfo.setRepositoryName(repository.getOfficialname());
|
||||
repositorySummaryInfo.setId(repoId);
|
||||
repositorySummaryInfo.setRepositoryName(repoOfficialName);
|
||||
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
||||
|
||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it possible that we will find an indexed version there?
|
||||
boolean isIndexedVersionFound = false;
|
||||
long start = System.currentTimeMillis();
|
||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
||||
for (AggregationDetails aggregationDetails : aggregationDetailsList) {
|
||||
if (aggregationDetails.getIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, 20);
|
||||
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||
if (aggregationInfo.isIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
||||
isIndexedVersionFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("Got repo aggregations in " + (end - start) + "ms");
|
||||
if ( isIndexedVersionFound )
|
||||
logger.debug("Got repo aggregations in " + (end - start) + "ms");
|
||||
else
|
||||
logger.warn("Could not find repo aggregations, after " + (end - start) + "ms!");
|
||||
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
||||
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||
|
||||
MetricsNumbers metricsNumbers = repositoryService.getMetricsInfoForRepository(repoId).getMetricsNumbers();
|
||||
repositorySummaryInfo.setTotalDownloads(metricsNumbers.getTotalDownloads());
|
||||
repositorySummaryInfo.setTotalViews(metricsNumbers.getTotalViews());
|
||||
} catch (RepositoryServiceException e) {
|
||||
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
||||
logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialname());
|
||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repoOfficialName);
|
||||
Long totalEvents = 0L;
|
||||
for (BrowseEntry browseEntry : events)
|
||||
totalEvents += browseEntry.getSize();
|
||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||
|
||||
|
||||
} catch (BrokerException e) {
|
||||
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
||||
logger.error("Exception getting broker events for repository: {}, {} ", repoId, repoOfficialName, e);
|
||||
}
|
||||
|
||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Something baad happened!", e);
|
||||
}
|
||||
|
|
|
@ -1,97 +1,108 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EmailUtils {
|
||||
|
||||
@Async
|
||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo);
|
||||
|
||||
@Async
|
||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo);
|
||||
|
||||
@Async
|
||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo);
|
||||
|
||||
@Async
|
||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo);
|
||||
|
||||
/****USER REGISTRATION REQUEST EMAILS****/
|
||||
@Async
|
||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||
|
||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
||||
@Async
|
||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
||||
@Async
|
||||
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
||||
@Async
|
||||
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
/****FAILURE UPDATE RESULTS EMAILS****/
|
||||
@Async
|
||||
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||
|
||||
/****FAILURE UPDATE INTERFACE COMPLIANCE****/
|
||||
@Async
|
||||
void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
|
||||
|
||||
@Async
|
||||
void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
|
||||
|
||||
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
|
||||
@Async
|
||||
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||
|
||||
/****GENERAL FAILURE OF VALIDATOR****/
|
||||
@Async
|
||||
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||
|
||||
|
||||
@Async
|
||||
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
||||
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||
|
||||
@Async
|
||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
|
||||
|
||||
@Async
|
||||
void sendUponJobCompletion(String repoId,
|
||||
String repoInterfaceId,
|
||||
String compatibility,
|
||||
int scoreUsage,
|
||||
int scoreContent,
|
||||
boolean isSuccess,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,96 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceConflictException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
|
||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class InterfaceComplianceService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(InterfaceComplianceService.class);
|
||||
|
||||
|
||||
private final InterfaceComplianceRequestsRepository repository;
|
||||
private final EmailUtils emailUtils;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
public InterfaceComplianceService(InterfaceComplianceRequestsRepository repository,
|
||||
EmailUtils emailUtils,
|
||||
AuthorizationService authorizationService,
|
||||
RepositoryService repositoryService) {
|
||||
this.repository = repository;
|
||||
this.emailUtils = emailUtils;
|
||||
this.authorizationService = authorizationService;
|
||||
this.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * *") // every day at 00:00
|
||||
public void cleanUp() {
|
||||
Set<InterfaceComplianceRequest> requests = getOutdated();
|
||||
|
||||
// TODO - In case we want to send the emails, uncomment the following code.
|
||||
/*for ( InterfaceComplianceRequest request : requests )
|
||||
{
|
||||
String repoId = request.getRepositoryId();
|
||||
String interfaceId = request.getInterfaceId();
|
||||
try {
|
||||
Map<String, RepositoryInterface> repositoryInterfaceMap = repositoryService.getRepositoryInterface(repoId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ApiDetails::getId, i -> i));
|
||||
RepositoryInterface iFace = repositoryInterfaceMap.get(interfaceId);
|
||||
if ( iFace == null ) {
|
||||
logger.error("The repository-interface \"" + interfaceId + "\" does not exist! | the request had the \"repoId\": \"" + repoId + "\"");
|
||||
continue;
|
||||
}
|
||||
Repository repo = repositoryService.getRepositoryById(repoId);
|
||||
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(repoId);
|
||||
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
|
||||
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
logger.error("Error for request with \"repoId\": \"" + repoId + "\" and \"interfaceId\": \"" + interfaceId + "\"", e);
|
||||
} // Continue to the next request.
|
||||
}*/
|
||||
|
||||
repository.deleteAll(requests);
|
||||
}
|
||||
|
||||
private Set<InterfaceComplianceRequest> getOutdated() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DATE, -7); // 7-days-old
|
||||
return this.repository.findAllBySubmissionDateBefore(calendar.getTime());
|
||||
}
|
||||
|
||||
public Optional<InterfaceComplianceRequest> getById(InterfaceComplianceRequestId id) {
|
||||
return this.repository.findById(id);
|
||||
}
|
||||
|
||||
public Iterable<InterfaceComplianceRequest> get() {
|
||||
return this.repository.findAll();
|
||||
}
|
||||
|
||||
public InterfaceComplianceRequest create(InterfaceComplianceRequest request) {
|
||||
Optional<InterfaceComplianceRequest> existing = getById(request.getId());
|
||||
if (existing.isPresent()) {
|
||||
logger.warn("New Request: {}\nExisting request: {}", request, existing.get());
|
||||
throw new ResourceConflictException("A request for altering compliance already exists. Desired Compatibility value: " + existing.get().getDesiredCompatibilityLevel());
|
||||
}
|
||||
|
||||
return this.repository.save(request);
|
||||
}
|
||||
|
||||
public void delete(InterfaceComplianceRequestId id) {
|
||||
this.repository.deleteById(id);
|
||||
}
|
||||
}
|
|
@ -7,10 +7,11 @@ import eu.dnetlib.repo.manager.domain.Constants;
|
|||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eurocris.openaire.cris.validator.model.Job;
|
||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -22,6 +23,8 @@ import java.util.stream.Collectors;
|
|||
@Service("monitorService")
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private MapJobDao crisJobs;
|
||||
|
||||
|
@ -41,9 +44,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
}
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public JobsOfUser getJobsOfUser(String user,
|
||||
String jobType,
|
||||
|
@ -52,10 +52,7 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus,
|
||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
|
||||
LOGGER.debug("Getting jobs of user : " + user);
|
||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||
String includeJobsTotal) throws ValidatorServiceException, NumberFormatException {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||
|
@ -98,7 +95,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50)) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +139,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return retJobs;
|
||||
|
||||
}
|
||||
|
||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
|
@ -154,7 +149,7 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
public int getJobsOfUserPerValidationStatus(String user,
|
||||
String jobType,
|
||||
String validationStatus) throws JSONException {
|
||||
LOGGER.debug("Getting job with validation status : " + validationStatus);
|
||||
logger.debug("Getting job with validation status : " + validationStatus);
|
||||
|
||||
if (jobType.equalsIgnoreCase("cris")) {
|
||||
return crisJobs.getJobs(user, validationStatus).size();
|
||||
|
@ -163,20 +158,19 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
try {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException {
|
||||
LOGGER.debug("Getting job summary with id : " + jobId);
|
||||
public StoredJob getJobSummary(String jobId, String groupBy) {
|
||||
logger.debug("Getting job summary with id : " + jobId);
|
||||
StoredJob job = null;
|
||||
try {
|
||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||
|
@ -192,4 +186,5 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
return job;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.PendingUserRole;
|
||||
import eu.dnetlib.repo.manager.repository.PendingUserRoleRepository;
|
||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PendingUserRoleService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PendingUserRoleService.class);
|
||||
private final PendingUserRoleRepository pendingUserRoleRepository;
|
||||
private final AaiRegistryService aaiRegistryService;
|
||||
|
||||
public PendingUserRoleService(PendingUserRoleRepository pendingUserRoleRepository,
|
||||
AaiRegistryService aaiRegistryService) {
|
||||
this.pendingUserRoleRepository = pendingUserRoleRepository;
|
||||
this.aaiRegistryService = aaiRegistryService;
|
||||
}
|
||||
|
||||
public void assignRoles() {
|
||||
Iterable<PendingUserRole> roles = pendingUserRoleRepository.findAll();
|
||||
for (PendingUserRole role : roles) {
|
||||
logger.debug("Attempt to assign role: {}", role);
|
||||
try {
|
||||
aaiRegistryService.assignMemberRole(role.getCoPersonId(), role.getCouId());
|
||||
pendingUserRoleRepository.deleteById(role.getId());
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not assign role to user. Pending Role: {}\n", role, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ package eu.dnetlib.repo.manager.service;
|
|||
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.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -2,12 +2,13 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -32,6 +33,9 @@ import java.util.Map;
|
|||
@Service("piwikService")
|
||||
public class PiWikServiceImpl implements PiWikService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PiWikServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
@ -47,20 +51,20 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
@Qualifier("emailUtils")
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PiWikServiceImpl.class);
|
||||
|
||||
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
|
||||
private static final String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ? LIMIT 1;";
|
||||
|
||||
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
||||
private static final String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
|
||||
private static final String UPDATE_PIWIK_INFO = "update piwik_site set siteid = ?, creationdate = now(), requestorname = ?, requestoremail = ?, validated = ?, repositoryname = ?, country = ?, authenticationtoken = ? where repositoryid = ?";
|
||||
|
||||
private final static String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
||||
private static final String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
|
||||
|
||||
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||
private static final String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
||||
|
||||
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
||||
private static final String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||
|
||||
private final RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
||||
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
||||
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||
|
||||
|
@ -78,9 +82,15 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
||||
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||
if (getPiwikSiteForRepo(piwikInfo.getRepositoryId()) == null) {
|
||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
||||
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||
} else {
|
||||
jdbcTemplate.update(UPDATE_PIWIK_INFO, new Object[]{piwikInfo.getSiteId(), piwikInfo.getRequestorName(), piwikInfo.getRequestorEmail(),
|
||||
piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken(), piwikInfo.getRepositoryId()},
|
||||
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||
}
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
|
@ -168,10 +178,10 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOGGER.error("Error while approving piwik site: ", e);
|
||||
logger.error("Error while approving piwik site: ", e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||
logger.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
return new ResponseEntity<>("OK", HttpStatus.OK);
|
||||
|
@ -183,9 +193,9 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
String repoWebsite,
|
||||
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
try {
|
||||
String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
||||
String url = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
||||
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
||||
Map map = new ObjectMapper().readValue(new URL(URL), Map.class);
|
||||
Map map = new ObjectMapper().readValue(new URL(url), Map.class);
|
||||
String siteId = null;
|
||||
if (map.get("value") != null) {
|
||||
siteId = map.get("value").toString();
|
||||
|
@ -202,13 +212,13 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
LOGGER.error("Error while creating piwikScript URL", uee);
|
||||
logger.error("Error while creating piwikScript URL", uee);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Error while creating piwik site", ioe);
|
||||
logger.error("Error while creating piwik site", ioe);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
logger.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
return piwikInfo;
|
||||
|
@ -216,12 +226,12 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
|
||||
@Override
|
||||
public Integer getTotal() {
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, new Object[]{}, Integer.class);
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, Integer.class, new Object[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValidated(boolean validated) {
|
||||
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where validated = ?";
|
||||
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, new Object[]{validated}, Integer.class);
|
||||
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, Integer.class, validated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -17,56 +15,51 @@ public interface RepositoryService {
|
|||
// TODO: move this elsewhere
|
||||
Country[] getCountries();
|
||||
|
||||
List<Repository> getRepositories(List<String> ids) throws JSONException;
|
||||
List<Repository> getRepositories(List<String> ids);
|
||||
|
||||
List<Repository> getRepositories(List<String> ids, int page, int size) throws JSONException;
|
||||
List<Repository> getRepositories(List<String> ids, int page, int size);
|
||||
|
||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception;
|
||||
|
||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception;
|
||||
|
||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
|
||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed);
|
||||
|
||||
// TODO: remove?
|
||||
List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException, IOException;
|
||||
List<Repository> getRepositoriesOfUser(String page, String size);
|
||||
|
||||
// TODO: remove?
|
||||
List<Repository> getRepositoriesOfUser(String userEmail,
|
||||
String page,
|
||||
String size) throws JSONException, IOException;
|
||||
List<Repository> getRepositoriesOfUser(String userEmail, String page, String size);
|
||||
|
||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size) throws Exception;
|
||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size);
|
||||
|
||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception;
|
||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size);
|
||||
|
||||
RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException;
|
||||
RepositorySnippet getRepositorySnippetById(String id) throws ResourceNotFoundException;
|
||||
|
||||
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
||||
|
||||
List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException;
|
||||
|
||||
Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
|
||||
Repository getRepositoryById(String id) throws ResourceNotFoundException;
|
||||
|
||||
List<Repository> getRepositoriesByName(String name,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
String size);
|
||||
|
||||
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order,
|
||||
int page, int pageSize) throws Exception;
|
||||
int page, int pageSize);
|
||||
|
||||
int getTotalRegisteredRepositories();
|
||||
Integer getTotalRegisteredRepositories();
|
||||
|
||||
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
|
||||
List<RepositoryInterface> getRepositoryInterface(String id);
|
||||
|
||||
Repository addRepository(String datatype, Repository repository) throws Exception;
|
||||
Repository addRepository(String datatype, Repository repository);
|
||||
|
||||
void deleteRepositoryInterface(String id, String registeredBy);
|
||||
|
||||
RepositoryInterface addRepositoryInterface(String datatype,
|
||||
String repoId,
|
||||
String registeredBy,
|
||||
String comment, RepositoryInterface repositoryInterface) throws Exception;
|
||||
String comment,
|
||||
RepositoryInterface repositoryInterface,
|
||||
String desiredCompatibilityLevel) throws Exception;
|
||||
|
||||
List<String> getDnetCountries();
|
||||
|
||||
|
@ -74,13 +67,9 @@ public interface RepositoryService {
|
|||
|
||||
List<Timezone> getTimezones();
|
||||
|
||||
Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
|
||||
Repository updateRepository(Repository repository, Authentication authentication);
|
||||
|
||||
List<String> getUrlsOfUserRepos(String user_email,
|
||||
String page,
|
||||
String size);
|
||||
|
||||
List<String> getDatasourceVocabularies(String mode);
|
||||
List<String> getUrlsOfUserRepos(String userEmail, String page, String size);
|
||||
|
||||
Map<String, String> getCompatibilityClasses(String mode);
|
||||
|
||||
|
@ -90,8 +79,9 @@ public interface RepositoryService {
|
|||
|
||||
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
|
||||
|
||||
Map<String, String> getListLatestUpdate(String mode) throws JSONException;
|
||||
Map<String, String> getListLatestUpdate(String mode);
|
||||
|
||||
RepositoryInterface updateRepositoryInterface(String repoId, String registeredBy, String comment, RepositoryInterface repositoryInterface) throws Exception;
|
||||
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface, String desiredCompatibilityLevel) throws ResourceNotFoundException, ValidatorServiceException;
|
||||
|
||||
void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,17 +1,27 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service("statsService")
|
||||
public class StatsServiceImpl implements StatsService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatsServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
|
@ -24,27 +34,215 @@ public class StatsServiceImpl implements StatsService {
|
|||
|
||||
@Override
|
||||
public Map getStatistics() {
|
||||
|
||||
UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate);
|
||||
DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate);
|
||||
AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate);
|
||||
LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate);
|
||||
JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate);
|
||||
PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate);
|
||||
DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate);
|
||||
SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate);
|
||||
LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate);
|
||||
|
||||
Map<String,Object> stats = new HashMap<>();
|
||||
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
||||
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
||||
stats.put("literature",literatureHystrixCommand.execute());
|
||||
stats.put("journal",journalHystrixCommand.execute());
|
||||
stats.put("publications",publicationHystrixCommand.execute());
|
||||
stats.put("datasets",datasetsHystrixCommand.execute());
|
||||
stats.put("software",softwareHystrixCommand.execute());
|
||||
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
||||
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
||||
stats.put("aggregators", this.getAggregatorsStats());
|
||||
stats.put("dataRepositories", this.getDataRepositoriesMetadata());
|
||||
stats.put("literature", this.getLiteratureStats());
|
||||
stats.put("journal", this.getJournalsStats());
|
||||
stats.put("publications", this.getPublicationStats());
|
||||
stats.put("datasets", this.getDatasetsStats());
|
||||
stats.put("software", this.getSoftwareStats());
|
||||
stats.put("lastYearUsagestats", this.getLastYearUsageStats());
|
||||
stats.put("usagestats", this.getUsageStatsTotal());
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
private String getAggregatorsStats()
|
||||
{
|
||||
String url = baseAddress + "/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" ( datasourcetypename exact Institutional Repository Aggregator " +
|
||||
" or datasourcetypename exact Publication Repository Aggregator )";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
try {
|
||||
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
} catch ( RestClientException rce ) {
|
||||
logger.error(rce.getMessage());
|
||||
return null;
|
||||
} catch ( Exception e ) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getDataRepositoriesMetadata()
|
||||
{
|
||||
String url = baseAddress + "/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" datasourcetypename exact Data Repository ";
|
||||
|
||||
return getMetadataTotals(url);
|
||||
}
|
||||
|
||||
|
||||
private String getLiteratureStats()
|
||||
{
|
||||
String url = baseAddress + "/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" ( datasourcetypename exact Institutional Repository " +
|
||||
" or datasourcetypename exact Publication Repository )";
|
||||
|
||||
return getMetadataTotals(url);
|
||||
}
|
||||
|
||||
|
||||
private String getJournalsStats()
|
||||
{
|
||||
String url = baseAddress + "/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" datasourcetypename exact Journal";
|
||||
|
||||
return getMetadataTotals(url);
|
||||
}
|
||||
|
||||
|
||||
private String getPublicationStats()
|
||||
{
|
||||
String url = baseAddress + "/publications/count";
|
||||
|
||||
return getCommonStats(url);
|
||||
}
|
||||
|
||||
|
||||
private String getDatasetsStats()
|
||||
{
|
||||
String url = baseAddress + "/datasets/count";
|
||||
|
||||
return getCommonStats(url);
|
||||
}
|
||||
|
||||
|
||||
private String getSoftwareStats()
|
||||
{
|
||||
String url = baseAddress + "/software/count";
|
||||
|
||||
return getCommonStats(url);
|
||||
}
|
||||
|
||||
|
||||
private Map<String,Object> getLastYearUsageStats()
|
||||
{
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
||||
.build().encode();
|
||||
|
||||
try {
|
||||
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
|
||||
List yearly_stats = (List) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("yearly_stats");
|
||||
Map lastYear = (Map) yearly_stats.get(yearly_stats.size() - 2);
|
||||
Integer downloads = (Integer) lastYear.get("downloads");
|
||||
Integer views = (Integer) lastYear.get("views");
|
||||
Integer year = (Integer) lastYear.get("year");
|
||||
|
||||
Map<String, Object> usagestats = new HashMap<>();
|
||||
usagestats.put("number", String.valueOf(downloads + views));
|
||||
usagestats.put("year", year);
|
||||
return usagestats;
|
||||
} catch ( RestClientException rce ) {
|
||||
logger.error(rce.getMessage());
|
||||
return null;
|
||||
} catch ( Exception e ) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Integer getUsageStatsTotal()
|
||||
{
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsEvents)
|
||||
.build().encode();
|
||||
|
||||
try {
|
||||
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map statsTotals = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("totals");
|
||||
if ( statsTotals == null ) {
|
||||
logger.error("The statsTotals was null!");
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO - Will we ever need the following lines?
|
||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
// JSONObject resultSet = new JSONObject(rs);
|
||||
// JSONObject totals = resultSet.getJSONObject("totals");
|
||||
|
||||
return (Integer) statsTotals.get("events");
|
||||
} catch ( RestClientException rce ) {
|
||||
logger.error(rce.getMessage());
|
||||
return null;
|
||||
} catch ( Exception e ) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getMetadataTotals(String url) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
try {
|
||||
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("meta");
|
||||
if ( metadata == null ) {
|
||||
logger.error("The metadata was null!");
|
||||
return null;
|
||||
}
|
||||
return String.valueOf(metadata.get("total"));
|
||||
} catch ( RestClientException rce ) {
|
||||
logger.error(rce.getMessage());
|
||||
return null;
|
||||
} catch ( Exception e ) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getCommonStats(String url) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
try {
|
||||
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map stats = (Map<?, ?>) rs.getBody();
|
||||
if ( stats == null ) {
|
||||
logger.error("The stats was null!");
|
||||
return null;
|
||||
}
|
||||
return String.valueOf(stats.get("total"));
|
||||
} catch ( RestClientException rce ) {
|
||||
logger.error(rce.getMessage());
|
||||
return null;
|
||||
} catch ( Exception e ) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service("sushiliteService")
|
||||
public class SushiliteServiceImpl implements SushiliteService {
|
||||
|
||||
|
||||
@Value("${services.provide.usagestats.sushiliteEndpoint}")
|
||||
private String usagestatsSushiliteEndpoint;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public ReportResponseWrapper getReportResults(String page,
|
||||
String pageSize,
|
||||
String Report,
|
||||
String Release,
|
||||
String RequestorID,
|
||||
String BeginDate,
|
||||
String EndDate,
|
||||
String RepositoryIdentifier,
|
||||
String ItemIdentifier,
|
||||
String ItemDataType,
|
||||
String Granularity,
|
||||
String Pretty) {
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/")
|
||||
.queryParam("Report", Report)
|
||||
.queryParam("Release", Release)
|
||||
.queryParam("RequestorID", RequestorID)
|
||||
.queryParam("BeginDate", BeginDate)
|
||||
.queryParam("EndDate", EndDate)
|
||||
.queryParam("RepositoryIdentifier", RepositoryIdentifier)
|
||||
.queryParam("ItemIdentifier", ItemIdentifier)
|
||||
.queryParam("ItemDataType", ItemDataType)
|
||||
.queryParam("Granularity", Granularity)
|
||||
.queryParam("Pretty", Pretty);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
ResponseEntity<ReportResponseWrapper> resp;
|
||||
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<ReportResponseWrapper>() {
|
||||
});
|
||||
|
||||
// check remote api's response
|
||||
System.out.println("sushi responded status " + resp.getStatusCode());
|
||||
|
||||
// get the items corresponding to the requested page
|
||||
List<ReportItem> requestedItemList = new ArrayList<>();
|
||||
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
|
||||
try {
|
||||
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size();
|
||||
int size = Integer.parseInt(pageSize);
|
||||
int offset = Integer.parseInt(page)*size;
|
||||
|
||||
if (offset < totalItems ) {
|
||||
int upperIndex = offset+size;
|
||||
if (upperIndex > totalItems) {
|
||||
upperIndex = totalItems;
|
||||
}
|
||||
requestedItemList = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
//emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReportResponseWrapper newReportResponse = resp.getBody();
|
||||
newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList);
|
||||
|
||||
|
||||
return newReportResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
@ -16,21 +18,24 @@ import java.util.stream.Collectors;
|
|||
@Service("userService")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
.getLogger(UserServiceImpl.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> login() {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
LOGGER.debug("User authentication : " + authentication);
|
||||
logger.debug("User authentication : " + authentication);
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
body.put("sub",authentication.getSub());
|
||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
||||
body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
|
||||
else
|
||||
body.put("name",authentication.getUserInfo().getName());
|
||||
|
||||
body.put("email",authentication.getUserInfo().getEmail());
|
||||
UserInfo userInfo = authentication.getUserInfo();
|
||||
String userName = userInfo.getName();
|
||||
|
||||
if ( userName == null || userName.isEmpty() )
|
||||
body.put("name", userInfo.getGivenName() + " " + userInfo.getFamilyName());
|
||||
else
|
||||
body.put("name", userName);
|
||||
|
||||
body.put("email",userInfo.getEmail());
|
||||
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
body.put("role",roles);
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
@ -42,4 +42,6 @@ public interface ValidatorService {
|
|||
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
|
||||
|
||||
List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException;
|
||||
|
||||
void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.*;
|
||||
import eu.dnetlib.repo.manager.domain.Constants;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.Rule;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eurocris.openaire.cris.validator.model.Job;
|
||||
import org.eurocris.openaire.cris.validator.service.JobExecutor;
|
||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -25,6 +27,7 @@ import javax.annotation.PostConstruct;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -52,10 +55,9 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||
private final Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(ValidatorServiceImpl.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ValidatorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
@ -66,20 +68,30 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
@Autowired
|
||||
private MapJobDao crisJobs;
|
||||
|
||||
@Autowired
|
||||
InterfaceComplianceService interfaceComplianceService;
|
||||
|
||||
|
||||
public static final Pattern OPENAIRE_DATA_REGEX = Pattern.compile("^openaire[1-9].0_data$");
|
||||
public static final Pattern OPENAIRE_OR_DRIVER_REGEX = Pattern.compile("^(?:openaire[1-9].0|driver)$");
|
||||
public static final Pattern OPENAIRE_CRIS_REGEX = Pattern.compile("^openaire[1-9].0_cris$");
|
||||
public static final Pattern FAIR_REGEX = Pattern.compile(".*fair$");
|
||||
|
||||
@PostConstruct
|
||||
private void loadRules(){
|
||||
LOGGER.debug("PostConstruct method! Load rules!");
|
||||
logger.debug("PostConstruct method! Load rules!");
|
||||
try {
|
||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||
String key = "";
|
||||
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
||||
String guidelinesAcronym = ruleSet.getGuidelinesAcronym();
|
||||
if ( OPENAIRE_DATA_REGEX.matcher(guidelinesAcronym).matches() )
|
||||
key = Constants.VALIDATION_MODE_DATA;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
||||
else if ( OPENAIRE_OR_DRIVER_REGEX.matcher(guidelinesAcronym).matches() )
|
||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
||||
else if ( OPENAIRE_CRIS_REGEX.matcher(guidelinesAcronym).matches() )
|
||||
key = Constants.VALIDATION_MODE_CRIS;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches(".*fair$"))
|
||||
else if ( FAIR_REGEX.matcher(guidelinesAcronym).matches() )
|
||||
key = Constants.VALIDATION_MODE_FAIR;
|
||||
|
||||
if (rulesetMap.containsKey(key))
|
||||
|
@ -121,26 +133,23 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
|
||||
logger.debug("Submit job for validation with id : {}", jobForValidation.getDatasourceId());
|
||||
try {
|
||||
try {
|
||||
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(), jobForValidation);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error sending email ", e);
|
||||
}
|
||||
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(), jobForValidation);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (jobForValidation.getSelectedContentRules()!=null && jobForValidation.getSelectedContentRules().size() == 1 &&
|
||||
jobForValidation.getSelectedContentRules().contains(-1000)) {
|
||||
jobForValidation.getSelectedContentRules().contains(-1000)
|
||||
|| jobForValidation.getDesiredCompatibilityLevel().equals("openaire-cris_1.1")) {
|
||||
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
||||
} else {
|
||||
this.getValidationService().submitValidationJob(jobForValidation);
|
||||
|
@ -148,18 +157,18 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// this.getValidationService().submitValidationJob(jobForValidation);
|
||||
} catch (Exception e) {
|
||||
throw new ValidatorServiceException(e);
|
||||
} catch (Exception e) { // FIXME: replaced exception with log
|
||||
// throw new ValidatorServiceException(e);
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return jobForValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
||||
String jobId) throws JSONException, ValidatorServiceException {
|
||||
LOGGER.debug("Resubmit validation job with id : " + jobId);
|
||||
logger.debug("Resubmit validation job with id : {}", jobId);
|
||||
StoredJob job = monitorApi.getJobSummary(jobId, "all");
|
||||
Set<Integer> contentRules = new HashSet<Integer>();
|
||||
Set<Integer> usageRules = new HashSet<Integer>();
|
||||
|
@ -176,7 +185,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (ruleSet != null){
|
||||
if (ruleSet != null) {
|
||||
for (int ruleId : job.getRules()) {
|
||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||
contentRules.add(ruleId);
|
||||
|
@ -194,51 +203,51 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets(String mode) {
|
||||
LOGGER.info("Getting rulesets for mode: " + mode);
|
||||
logger.info("Getting ruleSets for mode: {}", mode);
|
||||
return rulesetMap.get(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSetsOfRepository(String url) {
|
||||
LOGGER.debug("Getting sets of repository with url : " + url);
|
||||
|
||||
logger.debug("Getting sets of repository with url : {}", url);
|
||||
List<String> sets = null;
|
||||
|
||||
try {
|
||||
sets = OaiTools.getSetsOfRepo(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Exception on getSetsOfRepository" , e);
|
||||
logger.error("Exception on getSetsOfRepository", e);
|
||||
}
|
||||
|
||||
return sets;
|
||||
return sets; // It may be null.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifyRepo(String url) {
|
||||
LOGGER.debug("Identify repository with url : " + url);
|
||||
logger.debug("Identify repository with url : {}", url);
|
||||
try {
|
||||
return OaiTools.identifyRepository(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while identifying repository with url: " + url, e);
|
||||
logger.error("Error while identifying repository with url: " + url, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleSet getRuleSet(String acronym) {
|
||||
LOGGER.debug("Getting ruleset with acronym : " + acronym);
|
||||
logger.debug("Getting ruleset with acronym : {}", acronym);
|
||||
RuleSet ruleSet = null;
|
||||
try {
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
||||
for ( RuleSet rSet : ruleSets ) {
|
||||
if ( rSet.getGuidelinesAcronym().equals(acronym) ) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ruleSet != null )
|
||||
break;
|
||||
}
|
||||
return ruleSet;
|
||||
return ruleSet; // It may be null.
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting ruleset", e);
|
||||
logger.error("Error getting ruleset", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +286,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
@Override
|
||||
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
||||
try {
|
||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
||||
logger.debug("Getting interface information with url: {}", baseUrl);
|
||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||
if (interfaceInformation.isIdentified())
|
||||
|
@ -285,14 +294,35 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
return interfaceInformation;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting interface information with url: " + baseUrl, e);
|
||||
logger.error("Error getting interface information with url: " + baseUrl, e);
|
||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getJobsSummary(String repoId, int limit) throws JSONException, ValidatorServiceException {
|
||||
return getValidationService().getJobSummary(repositoryService.getRepositoryInterface(repoId).stream().map(RepositoryInterface::getBaseUrl).collect(Collectors.toList()),limit);
|
||||
return getValidationService().getJobSummary(
|
||||
repositoryService.getRepositoryInterface(repoId)
|
||||
.stream()
|
||||
.map(RepositoryInterface::getBaseurl)
|
||||
.collect(Collectors.toList()), limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
|
||||
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
|
||||
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
|
||||
String compatibility = null;
|
||||
if (request.isPresent()) {
|
||||
compatibility = request.get().getDesiredCompatibilityLevel();
|
||||
logger.info("Changing compatibility level. Request: {}", request);
|
||||
|
||||
if (scoreContent > 50) {
|
||||
repositoryService.updateInterfaceCompliance(repoId, interfaceId, request.get().getDesiredCompatibilityLevel());
|
||||
}
|
||||
interfaceComplianceService.delete(requestId);
|
||||
}
|
||||
emailUtils.sendUponJobCompletion(repoId,interfaceId,compatibility,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,28 +11,36 @@ import java.util.Map;
|
|||
public interface AaiRegistryService {
|
||||
|
||||
/**
|
||||
* 1.1 Get CoPersonId by authenticated user's Email
|
||||
* 1.1 Get CoPersonId List by authenticated user's Email
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer getCoPersonIdByEmail();
|
||||
List<Integer> getCoPersonIdsByEmail();
|
||||
|
||||
/**
|
||||
* 1.2 Get CoPersonId by Email
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
Integer getCoPersonIdByEmail(String email);
|
||||
|
||||
/**
|
||||
* 1. Get CoPersonId List by Email
|
||||
* 1.2 Get CoPersonId List by Email
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
List<Integer> getCoPersonIdsByEmail(String email);
|
||||
|
||||
/**
|
||||
* 1.3 Get a list of User Identifiers by Email
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
List<String> getUserIdentifiersByEmail(String email);
|
||||
|
||||
/**
|
||||
* 1.3 Get a list of User Identifiers by Email
|
||||
*
|
||||
* @param coPersonId
|
||||
* @return
|
||||
*/
|
||||
List<String> getUserIdentifiersByCoPersonId(Integer coPersonId);
|
||||
|
||||
/**
|
||||
* 2. Get CoPersonId by AAI identifier
|
||||
*
|
||||
|
@ -97,6 +105,14 @@ public interface AaiRegistryService {
|
|||
*/
|
||||
JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status);
|
||||
|
||||
/**
|
||||
* 5.3 Get User non admin active roles
|
||||
*
|
||||
* @param coPersonIds
|
||||
* @return
|
||||
*/
|
||||
JsonArray getRolesWithStatus(List<Integer> coPersonIds, RoleStatus status);
|
||||
|
||||
/**
|
||||
* 6. Get Role id of User base on couId.
|
||||
*
|
||||
|
@ -188,9 +204,8 @@ public interface AaiRegistryService {
|
|||
*
|
||||
* @param coPersonId
|
||||
* @param couId
|
||||
* @param id
|
||||
*/
|
||||
void assignMemberRole(Integer coPersonId, Integer couId, Integer id);
|
||||
void assignMemberRole(Integer coPersonId, Integer couId);
|
||||
|
||||
/**
|
||||
* 16. Remove a member role from a User
|
||||
|
|
|
@ -3,38 +3,38 @@ package eu.dnetlib.repo.manager.service.aai.registry;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.nimbusds.jose.util.StandardCharset;
|
||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||
import eu.dnetlib.repo.manager.service.aai.registry.utils.HttpUtils;
|
||||
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
|
||||
import eu.dnetlib.repo.manager.utils.HttpUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
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.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class RegistryCalls implements AaiRegistryService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(RegistryCalls.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
|
||||
|
||||
private final String coid;
|
||||
public final HttpUtils httpUtils;
|
||||
public final RegistryUtils jsonUtils;
|
||||
private final String coid;
|
||||
|
||||
@Autowired
|
||||
RegistryCalls(@Value("${services.provide.aai.registry.coid:2}") String coid,
|
||||
HttpUtils httpUtils, RegistryUtils registryUtils) {
|
||||
this.coid = coid;
|
||||
RegistryCalls(HttpUtils httpUtils, RegistryUtils registryUtils, @Value("${services.provide.aai.registry.coid}") String coid) {
|
||||
this.httpUtils = httpUtils;
|
||||
this.jsonUtils = registryUtils;
|
||||
this.coid = coid;
|
||||
}
|
||||
|
||||
private String mapType(String type, boolean communityMap) {
|
||||
|
@ -47,15 +47,39 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getCoPersonIdByEmail() {
|
||||
public List<String> getUserIdentifiersByEmail(String email) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (Integer coPersonId : getCoPersonIdsByEmail(email)) {
|
||||
ids.addAll(getUserIdentifiersByCoPersonId(coPersonId));
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUserIdentifiersByCoPersonId(Integer coPersonId) throws RestClientException {
|
||||
List<String> ids = new ArrayList<>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
|
||||
JsonElement response = httpUtils.get("identifiers.json", params);
|
||||
if (response != null) {
|
||||
JsonArray infos = response.getAsJsonObject().get("Identifiers").getAsJsonArray();
|
||||
infos.forEach(info -> {
|
||||
JsonObject jsonInfo = info.getAsJsonObject();
|
||||
if (!jsonInfo.get("Deleted").getAsBoolean()) {
|
||||
ids.add(jsonInfo.get("Identifier").getAsString());
|
||||
}
|
||||
});
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getCoPersonIdsByEmail() {
|
||||
try {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
String email = authentication.getUserInfo().getEmail();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("mail", email);
|
||||
JsonElement response = httpUtils.get("co_people.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
||||
return getCoPersonIdsByEmail(email);
|
||||
} catch (Exception e) {
|
||||
logger.error("Get User info: An error occurred ", e);
|
||||
return null;
|
||||
|
@ -63,26 +87,11 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getCoPersonIdByEmail(String email) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("mail", email);
|
||||
JsonElement response = httpUtils.get("co_people.json", params);
|
||||
if (response != null) {
|
||||
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray();
|
||||
if (coPeople.size() > 0) {
|
||||
return coPeople.get(0).getAsJsonObject().get("Id").getAsInt();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getCoPersonIdsByEmail(String email) {
|
||||
public List<Integer> getCoPersonIdsByEmail(String email) throws RestClientException {
|
||||
List<Integer> coPersonIds = new ArrayList<>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("mail", email);
|
||||
params.put("coid", coid);
|
||||
JsonElement response = httpUtils.get("co_people.json", params);
|
||||
if (response != null) {
|
||||
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray();
|
||||
|
@ -98,31 +107,31 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
try {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
String sub = authentication.getUserInfo().getSub();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("search.identifier", sub);
|
||||
JsonElement response = httpUtils.get("co_people.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
||||
return getCoPersonIdByIdentifier(sub);
|
||||
} catch (Exception e) {
|
||||
logger.error("Get User info: An error occurred ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getCoPersonIdByIdentifier(String sub) {
|
||||
public Integer getCoPersonIdByIdentifier(String sub) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("search.identifier", sub);
|
||||
params.put("coid", coid);
|
||||
JsonElement response = httpUtils.get("co_people.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getCous(String name) {
|
||||
public JsonArray getCous(String name) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
if (name != null) {
|
||||
params.put("name", URLEncoder.encode(name).toLowerCase());
|
||||
try {
|
||||
params.put("name", URLEncoder.encode(name, StandardCharset.UTF_8.name()).toLowerCase());
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
logger.error(uee.getMessage());
|
||||
return new JsonArray();
|
||||
}
|
||||
}
|
||||
JsonElement response = httpUtils.get("cous.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("Cous").getAsJsonArray() : new JsonArray();
|
||||
|
@ -155,8 +164,9 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getRoles(Integer coPersonId) {
|
||||
public JsonArray getRoles(Integer coPersonId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("co_person_roles.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("CoPersonRoles").getAsJsonArray() : new JsonArray();
|
||||
|
@ -164,14 +174,19 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
|
||||
@Override
|
||||
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
||||
JsonArray roles = getRoles(coPersonId);
|
||||
if (status == null) {
|
||||
return roles;
|
||||
}
|
||||
return getRolesWithStatus(Collections.singletonList(coPersonId), status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getRolesWithStatus(List<Integer> coPersonIds, RoleStatus status) {
|
||||
JsonArray roles = new JsonArray();
|
||||
coPersonIds.parallelStream().forEach(coPersonId -> roles.addAll(getRoles(coPersonId)));
|
||||
JsonArray activeRoles = new JsonArray();
|
||||
for (JsonElement role : roles) {
|
||||
if (role.getAsJsonObject().get("Status").getAsString().equalsIgnoreCase(status.toString())) {
|
||||
activeRoles.add(role);
|
||||
if (status != null) {
|
||||
for (JsonElement role : roles) {
|
||||
if (role.getAsJsonObject().get("Status").getAsString().equalsIgnoreCase(status.toString())) {
|
||||
activeRoles.add(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
return activeRoles;
|
||||
|
@ -190,7 +205,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getUserGroups(Integer coPersonId) {
|
||||
public JsonArray getUserGroups(Integer coPersonId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("co_groups.json", params);
|
||||
|
@ -198,7 +213,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getUserAdminGroup(Integer coPersonId, Integer couId) {
|
||||
public JsonObject getUserAdminGroup(Integer coPersonId, Integer couId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("co_groups.json", params);
|
||||
|
@ -215,9 +230,8 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getCouGroups(Integer couId) {
|
||||
public JsonArray getCouGroups(Integer couId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("coid", coid);
|
||||
params.put("couid", couId.toString());
|
||||
JsonElement response = httpUtils.get("co_groups.json", params);
|
||||
return (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
||||
|
@ -235,7 +249,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getGroupMembers(Integer coGroupId) {
|
||||
public JsonArray getGroupMembers(Integer coGroupId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("cogroupid", coGroupId.toString());
|
||||
JsonElement response = httpUtils.get("co_group_members.json", params);
|
||||
|
@ -244,7 +258,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
|
||||
|
||||
@Override
|
||||
public JsonArray getUserEmailByCouId(Integer couId, boolean admin) {
|
||||
public JsonArray getUserEmailByCouId(Integer couId, boolean admin) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
if (couId == null) {
|
||||
throw new IllegalArgumentException("Provided 'couId' is null");
|
||||
|
@ -275,7 +289,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getUsersByCouId(Integer couId) {
|
||||
public JsonArray getUsersByCouId(Integer couId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("couid", couId.toString());
|
||||
JsonElement response = httpUtils.get("co_person_roles.json", params);
|
||||
|
@ -296,8 +310,11 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
JsonArray infos = getUserEmailByCouId(couId, false);
|
||||
|
||||
infos.forEach(info -> {
|
||||
JsonObject jsonInfo = info.getAsJsonObject();
|
||||
|
||||
User user = new User();
|
||||
user.setEmail(info.getAsJsonObject().get("email").getAsString());
|
||||
user.setEmail(jsonInfo.get("email").getAsString());
|
||||
// TODO: should add firstname and lastname and sub of user
|
||||
|
||||
users.add(user);
|
||||
});
|
||||
|
@ -305,7 +322,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getUserNamesByCouId(Integer couId, boolean admin) {
|
||||
public JsonArray getUserNamesByCouId(Integer couId, boolean admin) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("couid", couId.toString());
|
||||
if (admin) {
|
||||
|
@ -315,16 +332,17 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray() : new JsonArray();
|
||||
JsonArray names = new JsonArray();
|
||||
infos.forEach(info -> {
|
||||
JsonObject jsonInfo = info.getAsJsonObject();
|
||||
JsonObject user = new JsonObject();
|
||||
user.addProperty("name", info.getAsJsonObject().get("Given").getAsString() + " " + info.getAsJsonObject().get("Family").getAsString());
|
||||
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
||||
user.addProperty("name", jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString());
|
||||
user.addProperty("memberSince", jsonInfo.get("Created").getAsString());
|
||||
names.add(user);
|
||||
});
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getUserIdByCouId(Integer couId, boolean admin) {
|
||||
public JsonArray getUserIdByCouId(Integer couId, boolean admin) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("couid", couId.toString());
|
||||
if (admin) {
|
||||
|
@ -334,38 +352,36 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray() : new JsonArray();
|
||||
JsonArray emails = new JsonArray();
|
||||
infos.forEach(info -> {
|
||||
JsonObject jsonInfo = info.getAsJsonObject();
|
||||
JsonObject user = new JsonObject();
|
||||
user.addProperty("id", info.getAsJsonObject().get("Identifier").getAsString());
|
||||
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
||||
user.addProperty("id", jsonInfo.get("Identifier").getAsString());
|
||||
user.addProperty("memberSince", jsonInfo.get("Created").getAsString());
|
||||
emails.add(user);
|
||||
});
|
||||
return emails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignMemberRole(Integer coPersonId, Integer couId, Integer id) {
|
||||
public void assignMemberRole(Integer coPersonId, Integer couId) throws RestClientException {
|
||||
httpUtils.post("co_person_roles.json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) throws RestClientException {
|
||||
if (id != null) {
|
||||
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
||||
} else {
|
||||
httpUtils.post("co_person_roles.json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
||||
httpUtils.put("co_person_roles/" + id + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) {
|
||||
if (id != null) {
|
||||
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer createRole(Role role) {
|
||||
public Integer createRole(Role role) throws RestClientException {
|
||||
JsonElement element = httpUtils.post("cous.json", jsonUtils.createNewCou(role));
|
||||
return element.getAsJsonObject().get("Id").getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserEmail(Integer coPersonId) {
|
||||
public String getUserEmail(Integer coPersonId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("email_addresses.json", params);
|
||||
|
@ -374,16 +390,20 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUserNames(Integer coPersonId) {
|
||||
public String getUserNames(Integer coPersonId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("names.json", params);
|
||||
JsonObject info = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray().get(0).getAsJsonObject() : null;
|
||||
return (info != null) ? info.getAsJsonObject().get("Given").getAsString() + " " + info.getAsJsonObject().get("Family").getAsString() : null;
|
||||
if (info != null) {
|
||||
JsonObject jsonInfo = info.getAsJsonObject();
|
||||
return jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString();
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserId(Integer coPersonId) {
|
||||
public String getUserId(Integer coPersonId) throws RestClientException {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("copersonid", coPersonId.toString());
|
||||
JsonElement response = httpUtils.get("identifiers.json", params);
|
||||
|
@ -392,7 +412,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void assignAdminRole(Integer coPersonId, Integer couId) {
|
||||
public void assignAdminRole(Integer coPersonId, Integer couId) throws RestClientException {
|
||||
JsonObject group = getCouAdminGroup(couId);
|
||||
if (group != null) {
|
||||
httpUtils.post("co_group_members.json", jsonUtils.coGroupMembers(group.get("Id").getAsInt(), coPersonId, true));
|
||||
|
@ -400,7 +420,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeAdminRole(Integer coPersonId, Integer couId) {
|
||||
public void removeAdminRole(Integer coPersonId, Integer couId) throws RestClientException {
|
||||
JsonObject adminGroup = this.getCouAdminGroup(couId);
|
||||
JsonArray admins = this.getGroupMembers(adminGroup.get("Id").getAsInt());
|
||||
Integer id = null;
|
||||
|
@ -410,7 +430,7 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
}
|
||||
}
|
||||
if (id != null) {
|
||||
httpUtils.delete("co_group_members/" + id.toString() + ".json");
|
||||
httpUtils.delete("co_group_members/" + id + ".json");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,8 +446,9 @@ public class RegistryCalls implements AaiRegistryService {
|
|||
int total = couIds.size();
|
||||
for (JsonElement cou : cous) {
|
||||
if (count < total) {
|
||||
if (idNameMap.containsKey(cou.getAsJsonObject().get("Id").getAsInt())) {
|
||||
idNameMap.put(cou.getAsJsonObject().get("Id").getAsInt(), cou.getAsJsonObject().get("Name").getAsString());
|
||||
JsonObject jsonCou = cou.getAsJsonObject();
|
||||
if (idNameMap.containsKey(jsonCou.get("Id").getAsInt())) {
|
||||
idNameMap.put(jsonCou.get("Id").getAsInt(), jsonCou.get("Name").getAsString());
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
package eu.dnetlib.repo.manager.utils;
|
||||
package eu.dnetlib.repo.manager.service.aai.registry.utils;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class HttpUtils {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(HttpUtils.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
||||
|
||||
@Value("${services.provide.aai.registry.url}")
|
||||
private String registryUrl;
|
||||
|
@ -27,7 +33,7 @@ public class HttpUtils {
|
|||
@Value("${services.provide.aai.registry.password}")
|
||||
private String password;
|
||||
|
||||
public JsonElement post(String path, JsonObject body) {
|
||||
public JsonElement post(String path, JsonObject body) throws RestClientException {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = createHeaders(user, password);
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -36,7 +42,7 @@ public class HttpUtils {
|
|||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
public JsonElement put(String path, JsonObject body) {
|
||||
public JsonElement put(String path, JsonObject body) throws RestClientException {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = createHeaders(user, password);
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -45,53 +51,53 @@ public class HttpUtils {
|
|||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
public JsonElement get(String path, Map<String, String> params) {
|
||||
public JsonElement get(String path, Map<String, String> params) throws RestClientException {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = registryUrl + path + ((params != null) ? createParams(params) : null);
|
||||
String url = createUrl(registryUrl + path, params);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
||||
(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
public JsonElement delete(String path) {
|
||||
public JsonElement delete(String path) throws RestClientException {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = registryUrl + path;
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
||||
(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
|
||||
private String createParams(Map<String, String> params) {
|
||||
StringBuilder ret = new StringBuilder("?");
|
||||
int count = 0;
|
||||
for (Map.Entry<String, String> param : params.entrySet()) {
|
||||
ret.append(param.getKey()).append("=").append(param.getValue());
|
||||
count++;
|
||||
if (count != params.entrySet().size()) {
|
||||
ret.append("&");
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
private String createUrl(String baseAddress, Map<String, String> params) {
|
||||
LinkedMultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
|
||||
params.forEach((k, v) -> multiValueMap.put(k, Collections.singletonList(v)));
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress)
|
||||
.queryParams(multiValueMap)
|
||||
.build().encode();
|
||||
return uriComponents.toString();
|
||||
}
|
||||
|
||||
private HttpHeaders createHeaders(String username, String password) {
|
||||
return new HttpHeaders() {{
|
||||
String auth = username + ":" + password;
|
||||
byte[] encodedAuth = Base64.encodeBase64(
|
||||
auth.getBytes(Charset.forName("US-ASCII")));
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.US_ASCII));
|
||||
String authHeader = "Basic " + new String(encodedAuth);
|
||||
set("Authorization", authHeader);
|
||||
}};
|
||||
}
|
||||
|
||||
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
||||
if (responseEntity != null && responseEntity.getBody() != null) {
|
||||
logger.info(responseEntity.getBody());
|
||||
|
||||
if (responseEntity == null)
|
||||
return null;
|
||||
|
||||
String responseBody = responseEntity.getBody();
|
||||
if (responseBody != null) {
|
||||
logger.trace(responseBody);
|
||||
|
||||
try {
|
||||
return new JsonParser().parse(responseEntity.getBody());
|
||||
return new JsonParser().parse(responseBody);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not parse response body", e);
|
||||
logger.warn("Could not parse response body", e); // Will return null.
|
||||
}
|
||||
}
|
||||
return null;
|
|
@ -6,6 +6,8 @@ import eu.dnetlib.repo.manager.domain.dto.Role;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class RegistryUtils {
|
||||
|
||||
|
@ -29,8 +31,11 @@ public class RegistryUtils {
|
|||
coPersonRole.addProperty("Title", "");
|
||||
coPersonRole.addProperty("O", "Openaire");
|
||||
coPersonRole.addProperty("Status", status);
|
||||
coPersonRole.addProperty("ValidFrom", "");
|
||||
coPersonRole.addProperty("ValidThrough", "");
|
||||
if(status.equals("Active")) {
|
||||
coPersonRole.addProperty("ValidFrom", new Date().toString());
|
||||
} else {
|
||||
coPersonRole.addProperty("ValidThrough", new Date().toString());
|
||||
}
|
||||
coPersonRoles.add(coPersonRole);
|
||||
role.addProperty("RequestType", "CoPersonRoles");
|
||||
role.addProperty("Version", version);
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AggregatorsHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
String baseAddress;
|
||||
|
||||
public AggregatorsHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress + "/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" ( datasourcetypename exact Institutional Repository Aggregator " +
|
||||
" or datasourcetypename exact Publication Repository Aggregator )";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DataRepositoriesHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate ;
|
||||
private String baseAddress;
|
||||
|
||||
public DataRepositoriesHystrixCommand(String baseAddress,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() {
|
||||
String url = baseAddress+"/resources" +
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" datasourcetypename exact Data Repository ";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page",0)
|
||||
.queryParam("size",0)
|
||||
.queryParam("format","json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
||||
Map metadata = (Map) ((Map)rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DatasetsHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
String baseAddress;
|
||||
|
||||
public DatasetsHystrixCommand(String baseAddress,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.restTemplate = restTemplate;
|
||||
this.baseAddress = baseAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress+"/datasets/count";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) (rs.getBody());
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class JournalHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public JournalHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress+"/resources"+
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" datasourcetypename exact Journal";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LastYearUsageStatsHystrixCommand extends HystrixCommand<Map> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
String usagestatsBaseAddress;
|
||||
|
||||
public LastYearUsageStatsHystrixCommand(String usagestatsBaseAddress,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.usagestatsBaseAddress = usagestatsBaseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map run() throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
||||
|
||||
List yearly_stats = (List) ((Map)rs.getBody()).get("yearly_stats");
|
||||
Map lastYear = (Map) yearly_stats.get(yearly_stats.size()-1);
|
||||
Integer downloads = (Integer) lastYear.get("downloads");
|
||||
Integer views = (Integer) lastYear.get("views");
|
||||
Integer year = (Integer) lastYear.get("year");
|
||||
|
||||
Map<String,Object> usagestats = new HashMap<>();
|
||||
usagestats.put("number",String.valueOf(downloads+views));
|
||||
usagestats.put("year",year);
|
||||
|
||||
return usagestats;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LiteratureHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public LiteratureHystrixCommand(String baseAddress , RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress+"/resources"+
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" ( datasourcetypename exact Institutional Repository " +
|
||||
" or datasourcetypename exact Publication Repository )";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PublicationHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public PublicationHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress + "/publications/count";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) (rs.getBody());
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SoftwareHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
String baseAddress;
|
||||
RestTemplate restTemplate;
|
||||
|
||||
public SoftwareHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() {
|
||||
String url = baseAddress + "/software/count";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) (rs.getBody());
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UsageStatsTotalHystrixCommand extends HystrixCommand<Integer> {
|
||||
|
||||
RestTemplate restTemplate ;
|
||||
String usagestatsEvents;
|
||||
|
||||
public UsageStatsTotalHystrixCommand(String usagestatsEvents,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.usagestatsEvents = usagestatsEvents;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer run() {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsEvents)
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
||||
Map metadata = (Map) ((Map)rs.getBody()).get("totals");
|
||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
// JSONObject resultSet = new JSONObject(rs);
|
||||
// JSONObject totals = resultSet.getJSONObject("totals");
|
||||
return (Integer) metadata.get("events");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
package eu.dnetlib.repo.manager.service.security;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
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.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
@ -14,26 +17,13 @@ import java.util.stream.Collectors;
|
|||
@Service("roleMappingService")
|
||||
public class AaiRoleMappingService implements RoleMappingService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AaiRoleMappingService.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AaiRoleMappingService.class);
|
||||
|
||||
@Value("${services.provide.aai.registry.production:true}")
|
||||
private boolean production;
|
||||
|
||||
|
||||
private String createRepoRoleName(String prefix, String repoId) {
|
||||
return prefix + "." + repoId.replace(":", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepoNameWithoutType(String fullName, String prefix) {
|
||||
if (fullName != null && prefix != null && fullName.startsWith(prefix)) {
|
||||
return fullName.substring(prefix.length());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepoIdByRoleId(String roleId) {
|
||||
public String getRepositoryId(String roleId) {
|
||||
if (!roleActive(roleId)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -41,43 +31,46 @@ public class AaiRoleMappingService implements RoleMappingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRepoIdsByRoleIds(Collection<String> roleIds) {
|
||||
public Collection<String> getRepositoryIds(Collection<String> roleIds) {
|
||||
return roleIds
|
||||
.stream()
|
||||
//.filter(this::roleActive) // implicitly executed in the next statement
|
||||
.map(this::getRepoIdByRoleId)
|
||||
.map(this::getRepositoryId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleIdByRepoId(String repoId) {
|
||||
String roleId = "";
|
||||
public String getRole(String repoId) {
|
||||
String role = null;
|
||||
String prefix = (production ? "" : "beta.") + "datasource";
|
||||
if (repoId != null) {
|
||||
roleId = createRepoRoleName(prefix, repoId);
|
||||
return roleId;
|
||||
} else {
|
||||
return null;
|
||||
role = createRole(prefix, repoId);
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRoleIdsByRepoIds(Collection<String> repoIds) {
|
||||
public Collection<String> getRoles(Collection<String> repoIds) {
|
||||
return repoIds
|
||||
.stream()
|
||||
.map(this::getRoleIdByRepoId)
|
||||
.map(this::getRole)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertAuthorityIdToRepoId(String authorityId) {
|
||||
String repo = "";
|
||||
if (authorityId != null && roleActive(authorityId)) {
|
||||
repo = authorityId
|
||||
.replaceFirst(".*datasource\\.", "")
|
||||
public String authorityToRepositoryId(GrantedAuthority authority) {
|
||||
String repo = null;
|
||||
String auth = null;
|
||||
try {
|
||||
auth = URLDecoder.decode(authority.getAuthority(), "UTF-8").toLowerCase();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
|
||||
if (auth != null && roleActive(auth)) {
|
||||
repo = auth
|
||||
.replaceFirst(".*datasource\\_", "")
|
||||
.replace("$", ":")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
@ -85,12 +78,26 @@ public class AaiRoleMappingService implements RoleMappingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String convertAuthorityToRepoId(GrantedAuthority authority) {
|
||||
return convertAuthorityIdToRepoId(authority.toString());
|
||||
public GrantedAuthority repositoryIdToAuthority(String repoId) {
|
||||
String role = null;
|
||||
try {
|
||||
role = URLEncoder.encode(convertRepoIdToAuthorityId(repoId), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
return new SimpleGrantedAuthority(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertRepoIdToAuthorityId(String repoId) {
|
||||
private String createRole(String prefix, String repoId) {
|
||||
return prefix + "." + repoId.replace(":", "$");
|
||||
}
|
||||
|
||||
private boolean roleActive(String roleId) {
|
||||
return (production && !roleId.toLowerCase().startsWith("beta"))
|
||||
|| (!production && roleId.toLowerCase().startsWith("beta"));
|
||||
}
|
||||
|
||||
private String convertRepoIdToAuthorityId(String repoId) {
|
||||
StringBuilder roleBuilder = new StringBuilder();
|
||||
String role = "";
|
||||
if (repoId != null) {
|
||||
|
@ -101,20 +108,4 @@ public class AaiRoleMappingService implements RoleMappingService {
|
|||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertRepoIdToEncodedAuthorityId(String repoId) {
|
||||
return URLEncoder.encode(convertRepoIdToAuthorityId(repoId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleGrantedAuthority convertRepoIdToAuthority(String repoId) {
|
||||
String role = convertRepoIdToEncodedAuthorityId(repoId);
|
||||
return new SimpleGrantedAuthority(role);
|
||||
}
|
||||
|
||||
private boolean roleActive(String roleId) {
|
||||
return (production && !roleId.toLowerCase().startsWith("beta."))
|
||||
|| (!production && roleId.toLowerCase().startsWith("beta."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package eu.dnetlib.repo.manager.service.security;
|
|||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.nimbusds.jose.util.StandardCharset;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -13,8 +16,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class AuthoritiesMapper {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AuthoritiesMapper.class);
|
||||
private static final String ENTITLEMENT_REGEX = "urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu";
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesMapper.class);
|
||||
private static final Pattern ENTITLEMENT_REGEX = Pattern.compile("urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu");
|
||||
|
||||
private AuthoritiesMapper() {
|
||||
}
|
||||
|
@ -25,22 +28,24 @@ public class AuthoritiesMapper {
|
|||
return authorities;
|
||||
}
|
||||
|
||||
public static List<String> entitlementRoles(JsonArray entitlements) {
|
||||
public static List<String> entitlementRoles(JsonArray entitlements) throws UnsupportedEncodingException {
|
||||
List<String> roles = new ArrayList<>();
|
||||
if (entitlements != null) {
|
||||
for (JsonElement obj : entitlements) {
|
||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
||||
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||
if (matcher.find()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
||||
sb.append(matcher.group(1));
|
||||
String group1 = matcher.group(1);
|
||||
if (group1 != null && group1.length() > 0) {
|
||||
sb.append(group1);
|
||||
}
|
||||
if (matcher.group(2).length() > 0) {
|
||||
String group2 = matcher.group(2);
|
||||
if (group2.length() > 0) {
|
||||
sb.append(":");
|
||||
sb.append(matcher.group(2));
|
||||
sb.append(group2);
|
||||
}
|
||||
String role = sb.toString().replace("+", " ");
|
||||
roles.add(URLDecoder.decode(role));
|
||||
roles.add(URLDecoder.decode(role, StandardCharset.UTF_8.name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,18 +55,20 @@ public class AuthoritiesMapper {
|
|||
private static void entityRoles(JsonArray entitlements, Set<GrantedAuthority> authorities) {
|
||||
if (entitlements != null) {
|
||||
for (JsonElement obj : entitlements) {
|
||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
||||
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||
if (matcher.find()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
||||
sb.append(matcher.group(1).replace("+-+", "_").replaceAll("[+.]", "_").toUpperCase());
|
||||
String group1 = matcher.group(1);
|
||||
if (group1 != null && group1.length() > 0) {
|
||||
sb.append(group1.replace("+-+", "_").replaceAll("[+.]", "_").toUpperCase());
|
||||
}
|
||||
if (matcher.group(2).length() > 0) {
|
||||
String group2 = matcher.group(2);
|
||||
if (group2.length() > 0) {
|
||||
sb.append("_");
|
||||
if (matcher.group(2).equals("admins")) {
|
||||
if (group2.equals("admins")) {
|
||||
sb.append("MANAGER");
|
||||
} else {
|
||||
sb.append(matcher.group(2).toUpperCase());
|
||||
sb.append(group2.toUpperCase());
|
||||
}
|
||||
}
|
||||
authorities.add(new SimpleGrantedAuthority(sb.toString()));
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.service.security;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
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.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
@ -9,9 +10,8 @@ import org.springframework.security.core.context.SecurityContext;
|
|||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.common.exceptions.UnauthorizedClientException;
|
||||
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
||||
import org.springframework.session.Session;
|
||||
//import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.session.FindByIndexNameSessionRepository;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -22,27 +22,25 @@ import java.util.Map;
|
|||
@Service
|
||||
public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AuthoritiesUpdater.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesUpdater.class);
|
||||
|
||||
@Autowired
|
||||
FindByIndexNameSessionRepository sessions;
|
||||
|
||||
public void update(String email, Collection<? extends GrantedAuthority> authorities) {
|
||||
public void update(String id, Update update) {
|
||||
if (sessions != null) {
|
||||
Map<String, Session> map = sessions.
|
||||
findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, email);
|
||||
Map map = sessions.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, id);
|
||||
if (map != null) {
|
||||
logger.debug(map.values().toArray().length);
|
||||
for (Session session : map.values()) {
|
||||
for ( Object sessionObject : map.values()) {
|
||||
Session session = (Session) sessionObject;
|
||||
logger.debug(session.getId());
|
||||
if (!session.isExpired()) {
|
||||
SecurityContext securityContext = session.getAttribute(SPRING_SECURITY_CONTEXT_KEY);
|
||||
Authentication authentication = securityContext.getAuthentication();
|
||||
if (authentication instanceof OIDCAuthenticationToken) {
|
||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||
logger.debug(authorities);
|
||||
securityContext.setAuthentication(new OIDCAuthenticationToken(authOIDC.getSub(), authOIDC.getIssuer(),
|
||||
authOIDC.getUserInfo(), authorities, authOIDC.getIdToken(),
|
||||
authOIDC.getUserInfo(), update.authorities(authOIDC.getAuthorities()), authOIDC.getIdToken(),
|
||||
authOIDC.getAccessTokenValue(), authOIDC.getRefreshTokenValue()));
|
||||
logger.debug("Update authorities");
|
||||
session.setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
|
||||
|
@ -54,13 +52,8 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public void update(String email, Update update) {
|
||||
Collection<? extends GrantedAuthority> authorities = update.authorities(SecurityContextHolder.getContext().getAuthentication().getAuthorities());
|
||||
this.update(email, authorities);
|
||||
}
|
||||
|
||||
public void addRole(String email, GrantedAuthority role) {
|
||||
this.update(email, old -> {
|
||||
public void addRole(String id, GrantedAuthority role) {
|
||||
this.update(id, old -> {
|
||||
HashSet<GrantedAuthority> authorities = new HashSet<>(old);
|
||||
authorities.add(role);
|
||||
return authorities;
|
||||
|
@ -71,14 +64,14 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
|||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth instanceof OIDCAuthenticationToken) {
|
||||
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
||||
this.addRole(oidcAuth.getUserInfo().getEmail(), role);
|
||||
this.addRole(oidcAuth.getUserInfo().getSub(), role);
|
||||
} else {
|
||||
throw new UnauthorizedClientException("User auth is not instance of OIDCAuthenticationToken");
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRole(String email, GrantedAuthority role) {
|
||||
this.update(email, old -> {
|
||||
public void removeRole(String id, GrantedAuthority role) {
|
||||
this.update(id, old -> {
|
||||
HashSet<GrantedAuthority> authorities = new HashSet<>(old);
|
||||
authorities.remove(role);
|
||||
return authorities;
|
||||
|
@ -89,7 +82,7 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
|||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth instanceof OIDCAuthenticationToken) {
|
||||
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
||||
this.removeRole(oidcAuth.getUserInfo().getEmail(), role);
|
||||
this.removeRole(oidcAuth.getUserInfo().getSub(), role);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue