Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Ioannis Diplas | cba5f4ec17 | |
Ioannis Diplas | ee78250918 | |
Ioannis Diplas | 22605ad0ad |
|
@ -1,4 +0,0 @@
|
||||||
# Ignore directories
|
|
||||||
.idea
|
|
||||||
target
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#FROM tomcat:7.0.90-jre8
|
FROM tomcat:7.0.90-jre8
|
||||||
FROM tomcat:8.5.71-jre8-openjdk-bullseye
|
|
||||||
MAINTAINER "pkanakakis@di.uoa.gr"
|
MAINTAINER "pkanakakis@di.uoa.gr"
|
||||||
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
|
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
|
||||||
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
|
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
|
||||||
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
|
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
|
||||||
COPY validator.env /usr/local/tomcat/lib/dnet-override.properties
|
COPY src/main/resources/application.properties /usr/local/tomcat/lib/dnet-override.properties
|
||||||
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
|
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
|
||||||
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
|
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
|
||||||
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
|
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
|
||||||
|
|
176
LICENSE.txt
176
LICENSE.txt
|
@ -1,176 +0,0 @@
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
218
README.md
218
README.md
|
@ -1,218 +0,0 @@
|
||||||
# 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
|
|
430
pom.xml
430
pom.xml
|
@ -4,187 +4,101 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>dnet45-parent</artifactId>
|
||||||
<version>2.7.18</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath></relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-repository-manager-service</artifactId>
|
<artifactId>uoa-repository-manager-service</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<spring.boot.version>2.7.18</spring.boot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>${spring.boot.version}</version>
|
<version>${spring.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
<artifactId>hibernate-validator-annotation-processor</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>4.1.0.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<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>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
</exclusion>
|
<version>(1.2, 1.5]</version>
|
||||||
<exclusion>
|
<scope>compile</scope>
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.gwt</groupId>
|
|
||||||
<artifactId>gwt-user</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>dnet-runtime</artifactId>
|
<artifactId>dnet-runtime</artifactId>
|
||||||
<version>1.0.2-SNAPSHOT</version>
|
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion> <!-- declare the exclusion here -->
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>geronimo-javamail_1.4_spec</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-hcm</artifactId>
|
<artifactId>uoa-utils</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.dnetlib</groupId>
|
||||||
|
<artifactId>uoa-domain</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion> <!-- declare the exclusion here -->
|
||||||
<groupId>log4j</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>eu.dnetlib</groupId>
|
|
||||||
<artifactId>dnet-openaire-usage-stats-sushilite-r5</artifactId>
|
|
||||||
<version>1.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.dnetlib.dhp</groupId>
|
|
||||||
<artifactId>dnet-openaire-broker-common</artifactId>
|
|
||||||
<version>3.1.1-SNAPSHOT</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib-nodep</artifactId>
|
<artifactId>cglib-nodep</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>2.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.dnetlib</groupId>
|
||||||
|
<artifactId>uoa-commons</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.dnetlib</groupId>
|
||||||
|
<artifactId>uoa-clients</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.dnetlib</groupId>
|
||||||
|
<artifactId>uoa-hcm</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.16.0</version>
|
<version>2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -192,58 +106,99 @@
|
||||||
<artifactId>oai4j</artifactId>
|
<artifactId>oai4j</artifactId>
|
||||||
<version>[0.6b1,)</version>
|
<version>[0.6b1,)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TODO - Do we need this? -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xalan</groupId>
|
<groupId>xalan</groupId>
|
||||||
<artifactId>xalan</artifactId>
|
<artifactId>xalan</artifactId>
|
||||||
<version>2.7.3</version>
|
<version>2.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>xerces</groupId>
|
||||||
<artifactId>jersey-client</artifactId>
|
<artifactId>xercesImpl</artifactId>
|
||||||
<version>2.42</version>
|
<version>2.11.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-jdbc</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>1.19.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- TODO - Do we need this? We already have: "com.google.code.gson:gson" -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.aksw.gson</groupId>
|
<groupId>org.aksw.gson</groupId>
|
||||||
<artifactId>gson-utils-core</artifactId>
|
<artifactId>gson-utils-core</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20240303</version>
|
<version>20080701</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<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>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>42.7.3</version>
|
<version>9.1-901.jdbc3</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-catalina</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
<version>1.5</version>
|
<version>LATEST</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mitre</groupId>
|
<groupId>org.mitre</groupId>
|
||||||
<artifactId>openid-connect-client</artifactId>
|
<artifactId>openid-connect-client</artifactId>
|
||||||
<version>1.3.4</version>
|
<version>1.3.0</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -251,43 +206,43 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.session</groupId>
|
<groupId>org.springframework.session</groupId>
|
||||||
<artifactId>spring-session-data-redis</artifactId>
|
<artifactId>spring-session-data-redis</artifactId>
|
||||||
<version>2.7.4</version>
|
<version>1.3.1.RELEASE</version>
|
||||||
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>redis.clients</groupId>
|
<groupId>redis.clients</groupId>
|
||||||
<artifactId>jedis</artifactId>
|
<artifactId>jedis</artifactId>
|
||||||
<version>${jedis.version}</version> <!-- This property comes from the parent-pom. -->
|
<version>2.9.0</version>
|
||||||
<!--<version>3.7.0</version>-->
|
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.thetransactioncompany</groupId>
|
<groupId>com.thetransactioncompany</groupId>
|
||||||
<artifactId>cors-filter</artifactId>
|
<artifactId>cors-filter</artifactId>
|
||||||
<version>3.0</version>
|
<version>2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-hystrix</artifactId>
|
||||||
|
<version>1.1.5.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.ws</groupId>
|
<groupId>javax.xml.ws</groupId>
|
||||||
<artifactId>jaxws-api</artifactId>
|
<artifactId>jaxws-api</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -298,105 +253,49 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>2.3.9</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
|
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>2.3.0.1</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.activation</groupId>
|
<groupId>javax.activation</groupId>
|
||||||
<artifactId>activation</artifactId>
|
<artifactId>activation</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1-rev-1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eurocris</groupId>
|
|
||||||
<artifactId>openaire-cris-validator</artifactId>
|
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
|
||||||
<!-- <exclusions>-->
|
|
||||||
<!-- <exclusion>-->
|
|
||||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
|
||||||
<!-- <artifactId>log4j-1.2-api</artifactId>-->
|
|
||||||
<!-- </exclusion>-->
|
|
||||||
<!-- </exclusions>-->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.session</groupId>
|
|
||||||
<artifactId>spring-session-bom</artifactId>
|
|
||||||
<version>2021.2.3</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!--
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>2.6</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</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.37.1128</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>java to typeScript</id>
|
|
||||||
<goals>
|
|
||||||
<goal>generate</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<jsonLibrary>jackson2</jsonLibrary>
|
|
||||||
<outputFileType>implementationFile</outputFileType>
|
|
||||||
<mapClasses>asClasses</mapClasses>
|
|
||||||
<classPatterns>
|
|
||||||
<pattern>eu.dnetlib.domain.functionality.validator.*</pattern>
|
|
||||||
</classPatterns>
|
|
||||||
<outputFile>target/operation.ts</outputFile>
|
|
||||||
<outputKind>module</outputKind>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>uoa-repository-manager-service</finalName>
|
<finalName>uoa-repository-manager-service</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -407,76 +306,5 @@
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>central</id>
|
|
||||||
<name>Maven Central</name>
|
|
||||||
<url>https://repo.maven.apache.org/maven2</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-snapshot</id>
|
|
||||||
<name>D-Net 45 Bootstrap Snapshot</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-release</id>
|
|
||||||
<name>D-Net 45 Bootstrap Release</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet-deps</id>
|
|
||||||
<name>dnet-dependencies</name>
|
|
||||||
<url>https://maven.d4science.org/nexus/content/repositories/dnet-deps</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-releases</id>
|
|
||||||
<name>D-Net 45 releases</name>
|
|
||||||
<url>https://maven.d4science.org/nexus/content/repositories/dnet45-releases</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-snapshots</id>
|
|
||||||
<name>D-Net 45 snapshots</name>
|
|
||||||
<url>https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- Use this when testing local JARs. -->
|
|
||||||
<!--<repository>
|
|
||||||
<id>libs</id>
|
|
||||||
<url>file:///${project.basedir}/libs</url>
|
|
||||||
</repository>-->
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
|
|
||||||
import org.mitre.oauth2.model.RegisteredClient;
|
|
||||||
import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
|
|
||||||
import org.mitre.openid.connect.client.OIDCAuthenticationProvider;
|
|
||||||
import org.mitre.openid.connect.client.service.impl.*;
|
|
||||||
import org.mitre.openid.connect.config.ServerConfiguration;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebSecurity
|
|
||||||
public class AaiSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.webURL}")
|
|
||||||
private String logoutSuccessUrl;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.issuer}")
|
|
||||||
private String oidcIssuer;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.id}")
|
|
||||||
private String oidcId;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.secret}")
|
|
||||||
private String oidcSecret;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.redirectURL}")
|
|
||||||
private String oidcDevHome;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.webURL}")
|
|
||||||
private String webAppFrontEnd;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Override
|
|
||||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
||||||
return authenticationManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(AuthenticationManagerBuilder auth) {
|
|
||||||
auth.authenticationProvider(openIdConnectAuthenticationProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configure(WebSecurity web) {
|
|
||||||
web.ignoring().antMatchers("/stats/**");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
http
|
|
||||||
.csrf().disable()
|
|
||||||
.authorizeRequests()
|
|
||||||
.regexMatchers("/actuator/.*").permitAll()
|
|
||||||
.regexMatchers("/repositories/.*/metrics/?.*").permitAll()
|
|
||||||
.regexMatchers("/metrics").permitAll()
|
|
||||||
.antMatchers("/api-docs/**","/swagger-ui/**").permitAll()
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
.and()
|
|
||||||
.logout().logoutUrl("/openid_logout")
|
|
||||||
.clearAuthentication(true)
|
|
||||||
.invalidateHttpSession(true)
|
|
||||||
.deleteCookies()
|
|
||||||
.logoutSuccessUrl(logoutSuccessUrl)
|
|
||||||
.and()
|
|
||||||
.addFilterBefore(openIdConnectAuthenticationFilter(), AbstractPreAuthenticatedProcessingFilter.class)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OIDCAuthenticationProvider openIdConnectAuthenticationProvider() {
|
|
||||||
OIDCAuthenticationProvider oidcProvider = new OIDCAuthenticationProvider();
|
|
||||||
oidcProvider.setAuthoritiesMapper(authoritiesMapper());
|
|
||||||
return oidcProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OpenAIREAuthoritiesMapper authoritiesMapper() {
|
|
||||||
OpenAIREAuthoritiesMapper authoritiesMapper = new OpenAIREAuthoritiesMapper();
|
|
||||||
return authoritiesMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public StaticServerConfigurationService staticServerConfigurationService() {
|
|
||||||
StaticServerConfigurationService staticServerConfigurationService = new StaticServerConfigurationService();
|
|
||||||
Map<String, ServerConfiguration> servers = new HashMap<>();
|
|
||||||
servers.put(oidcIssuer, serverConfiguration());
|
|
||||||
staticServerConfigurationService.setServers(servers);
|
|
||||||
return staticServerConfigurationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public StaticClientConfigurationService staticClientConfigurationService() {
|
|
||||||
StaticClientConfigurationService staticClientConfigurationService = new StaticClientConfigurationService();
|
|
||||||
Map<String, RegisteredClient> clients = new HashMap<>();
|
|
||||||
clients.put(oidcIssuer, registeredClient());
|
|
||||||
staticClientConfigurationService.setClients(clients);
|
|
||||||
return staticClientConfigurationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RegisteredClient registeredClient() {
|
|
||||||
RegisteredClient registeredClient = new RegisteredClient();
|
|
||||||
registeredClient.setClientId(oidcId);
|
|
||||||
registeredClient.setClientSecret(oidcSecret);
|
|
||||||
registeredClient.setScope(new HashSet<>(Arrays.asList("openid", "eduperson_entitlement", "profile", "email")));
|
|
||||||
registeredClient.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC);
|
|
||||||
registeredClient.setRedirectUris(new HashSet<>(Collections.singletonList(oidcDevHome)));
|
|
||||||
return registeredClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public StaticAuthRequestOptionsService staticAuthRequestOptionsService() {
|
|
||||||
return new StaticAuthRequestOptionsService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PlainAuthRequestUrlBuilder plainAuthRequestUrlBuilder() {
|
|
||||||
return new PlainAuthRequestUrlBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ServerConfiguration serverConfiguration() {
|
|
||||||
ServerConfiguration serverConfiguration = new ServerConfiguration();
|
|
||||||
serverConfiguration.setIssuer(oidcIssuer);
|
|
||||||
serverConfiguration.setAuthorizationEndpointUri(oidcIssuer + "authorize");
|
|
||||||
serverConfiguration.setTokenEndpointUri(oidcIssuer + "token");
|
|
||||||
serverConfiguration.setUserInfoUri(oidcIssuer + "userinfo");
|
|
||||||
serverConfiguration.setJwksUri(oidcIssuer + "jwk");
|
|
||||||
serverConfiguration.setRevocationEndpointUri(oidcIssuer + "revoke");
|
|
||||||
return serverConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OIDCAuthenticationFilter openIdConnectAuthenticationFilter() throws Exception {
|
|
||||||
OIDCAuthenticationFilter oidc = new OIDCAuthenticationFilter();
|
|
||||||
oidc.setAuthenticationManager(authenticationManagerBean());
|
|
||||||
oidc.setIssuerService(staticSingleIssuerService());
|
|
||||||
oidc.setServerConfigurationService(staticServerConfigurationService());
|
|
||||||
oidc.setClientConfigurationService(staticClientConfigurationService());
|
|
||||||
oidc.setAuthRequestOptionsService(staticAuthRequestOptionsService());
|
|
||||||
oidc.setAuthRequestUrlBuilder(plainAuthRequestUrlBuilder());
|
|
||||||
oidc.setAuthenticationSuccessHandler(frontEndRedirect());
|
|
||||||
return oidc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public StaticSingleIssuerService staticSingleIssuerService() {
|
|
||||||
StaticSingleIssuerService staticSingleIssuerService = new StaticSingleIssuerService();
|
|
||||||
staticSingleIssuerService.setIssuer(oidcIssuer);
|
|
||||||
return staticSingleIssuerService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(initMethod = "init")
|
|
||||||
public FrontEndLinkURIAuthenticationSuccessHandler frontEndRedirect() {
|
|
||||||
FrontEndLinkURIAuthenticationSuccessHandler frontEnd = new FrontEndLinkURIAuthenticationSuccessHandler();
|
|
||||||
frontEnd.setFrontEndURI(webAppFrontEnd);
|
|
||||||
return frontEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableAsync
|
|
||||||
public class AsyncConfiguration implements AsyncConfigurer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
|
||||||
return new AsyncUncaughtExceptionHandler() {
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
|
||||||
logger.error("Async error", throwable);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
|
||||||
|
* override the previous. It also supports property expansion like:
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* something = 1
|
||||||
|
* somethingelse = 2
|
||||||
|
* test = ${something}/${somethingelse}
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* And if you override something to XX, then test will become XX/2
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author marko
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
|
||||||
|
|
||||||
|
private Properties properties;
|
||||||
|
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
this.properties = mergeProperties();
|
||||||
|
|
||||||
|
// Convert the merged properties, if necessary.
|
||||||
|
convertProperties(this.properties);
|
||||||
|
|
||||||
|
logger.debug("Properties: " + properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProperties(final Properties properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,84 +1,74 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
import eu.dnetlib.api.enabling.ISLookUpService;
|
import org.apache.log4j.Logger;
|
||||||
import eu.dnetlib.api.functionality.ValidatorService;
|
|
||||||
import eu.dnetlib.clients.enabling.islookup.ws.ISLookUpClient;
|
|
||||||
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebService;
|
|
||||||
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebServiceClient;
|
|
||||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
|
||||||
import gr.uoa.di.driver.enabling.ISLookUp;
|
|
||||||
import gr.uoa.di.driver.enabling.islookup.ISLookUpImpl;
|
|
||||||
import gr.uoa.di.driver.enabling.vocabulary.ISVocabularyLoader;
|
|
||||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
|
||||||
import gr.uoa.di.driver.util.ServiceLocator;
|
|
||||||
import gr.uoa.di.driver.util.StaticServiceLocator;
|
|
||||||
import gr.uoa.di.driver.xml.VocabularyXmlConverter;
|
|
||||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.*;
|
||||||
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
|
@Configuration
|
||||||
@ComponentScan(basePackages = {"org.eurocris.openaire.cris.validator.service"})
|
@EnableRedisHttpSession
|
||||||
|
@EnableAspectJAutoProxy
|
||||||
|
@EnableCircuitBreaker
|
||||||
|
@PropertySource(value = {"classpath:application.properties"} )
|
||||||
|
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
@Value("${services.provide.iSLookUpService.url}")
|
private static Logger logger = Logger.getLogger(Config.class);
|
||||||
private String lookupURL;
|
|
||||||
|
|
||||||
@Value("${services.provide.validatorService.url}")
|
@Value("${redis.host:194.177.192.121}")
|
||||||
private String validatorUrl;
|
private String host;
|
||||||
|
|
||||||
@Bean(name = "vocabularyLoader")
|
@Value("${redis.port:6379}")
|
||||||
public VocabularyLoader createVocabularyLoader() throws Exception {
|
private String port;
|
||||||
ISVocabularyLoader loader = new ISVocabularyLoader();
|
|
||||||
|
|
||||||
loader.setLookUp(createVocabularyLookUp());
|
@Value("${redis.password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
return loader;
|
@Value("${aai.mode}")
|
||||||
|
private String aaiMode;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
private void init(){
|
||||||
|
logger.info(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("validatorServiceLocator")
|
@Bean
|
||||||
public ServiceLocator<ValidatorService> createValidatorServiceLocator() {
|
JedisConnectionFactory connectionFactory() {
|
||||||
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
logger.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||||
|
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
||||||
factory.setServiceClass(ValidatorWebService.class);
|
jedisConnectionFactory.setHostName(host);
|
||||||
factory.setAddress(validatorUrl);
|
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
||||||
|
if(password != null) jedisConnectionFactory.setPassword(password);
|
||||||
ValidatorWebService service = (ValidatorWebService) factory.create();
|
return jedisConnectionFactory;
|
||||||
|
|
||||||
ValidatorWebServiceClient client = new ValidatorWebServiceClient();
|
|
||||||
client.setWebService(service);
|
|
||||||
|
|
||||||
StaticServiceLocator<ValidatorService> locator = new StaticServiceLocator<>();
|
|
||||||
locator.setService(client);
|
|
||||||
|
|
||||||
return locator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Bean(name="vocabularyLookUp")
|
@Bean
|
||||||
private ISLookUp<Vocabulary> createVocabularyLookUp() throws Exception {
|
public CookieSerializer cookieSerializer() {
|
||||||
ISLookUpImpl<Vocabulary> lookUp = new ISLookUpImpl<>();
|
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
||||||
|
serializer.setCookieName("openAIRESession");
|
||||||
lookUp.setLookupLocator(createIsLookupServiceLocator());
|
serializer.setCookiePath("/");
|
||||||
lookUp.setConverter(new VocabularyXmlConverter());
|
if(aaiMode.equalsIgnoreCase("production") || aaiMode.equalsIgnoreCase("beta"))
|
||||||
|
serializer.setDomainName(".openaire.eu");
|
||||||
return lookUp;
|
logger.info("Serializer : " + serializer);
|
||||||
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceLocator<ISLookUpService> createIsLookupServiceLocator() throws Exception {
|
@Bean
|
||||||
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
public RestTemplate restTemplate() {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
factory.setServiceClass(eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService.class);
|
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||||
factory.setAddress(lookupURL);
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService client = (eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService) factory.create();
|
httpHeaders.set("Content-Type", "application/json");
|
||||||
|
return restTemplate;
|
||||||
ISLookUpClient service = new ISLookUpClient();
|
|
||||||
service.setWebService(client);
|
|
||||||
|
|
||||||
StaticServiceLocator<ISLookUpService> locator = new StaticServiceLocator<>();
|
|
||||||
locator.setService(service);
|
|
||||||
|
|
||||||
return locator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
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,55 +1,86 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
import org.springframework.session.FindByIndexNameSessionRepository;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Base64;
|
import java.net.URLEncoder;
|
||||||
import java.util.Date;
|
import com.google.gson.*;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||||
|
|
||||||
private String frontEndURI;
|
private String frontEndURI;
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
private static final Logger logger = Logger
|
||||||
|
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
logger.debug("Front end uri : {}", frontEndURI);
|
logger.debug("Front end uri : " + frontEndURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.domain}")
|
@Value("${aai.mode}")
|
||||||
private String domain;
|
private String aaiMode;
|
||||||
|
|
||||||
|
private final static String ENCODING = "UTF-8";
|
||||||
private static final Pattern AUTH_REGEX = Pattern.compile("^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
|
|
||||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||||
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getSub());
|
JsonObject userInfo = new JsonObject();
|
||||||
|
|
||||||
|
if (authOIDC.getUserInfo().getSub() == null)
|
||||||
|
userInfo.addProperty("sub", "");
|
||||||
|
else
|
||||||
|
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), ENCODING));
|
||||||
|
|
||||||
|
|
||||||
|
if(authOIDC.getUserInfo().getName() != null)
|
||||||
|
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), ENCODING));
|
||||||
|
|
||||||
|
if (authOIDC.getUserInfo().getGivenName() == null)
|
||||||
|
userInfo.addProperty("firstname", "");
|
||||||
|
else
|
||||||
|
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), ENCODING) + "");
|
||||||
|
|
||||||
|
if (authOIDC.getUserInfo().getFamilyName() == null)
|
||||||
|
userInfo.addProperty("lastname", "");
|
||||||
|
else
|
||||||
|
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), ENCODING) + "");
|
||||||
|
|
||||||
|
userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
|
||||||
|
if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
|
||||||
|
userInfo.addProperty("role", "");
|
||||||
|
else
|
||||||
|
userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
|
||||||
|
.getSource().getAsJsonArray("edu_person_entitlements").toString(), ENCODING) + "");
|
||||||
|
|
||||||
|
|
||||||
|
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
|
||||||
|
openAIREUser.setMaxAge(14400);
|
||||||
|
openAIREUser.setPath("/");
|
||||||
|
openAIREUser.setHttpOnly(true);
|
||||||
|
|
||||||
|
if(aaiMode.equalsIgnoreCase("production") || aaiMode.equalsIgnoreCase("beta"))
|
||||||
|
openAIREUser .setDomain(".openaire.eu");
|
||||||
|
response.addCookie(openAIREUser);
|
||||||
|
|
||||||
|
|
||||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||||
Matcher matcher = AUTH_REGEX.matcher(authOIDC.getAccessTokenValue());
|
accessToken.setMaxAge(14400);
|
||||||
if (matcher.find()) {
|
accessToken.setHttpOnly(true);
|
||||||
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)));
|
if(aaiMode.equalsIgnoreCase("production") || aaiMode.equalsIgnoreCase("beta"))
|
||||||
} else {
|
accessToken.setDomain(".openaire.eu");
|
||||||
accessToken.setMaxAge(3600);
|
|
||||||
}
|
|
||||||
accessToken.setDomain(domain);
|
|
||||||
accessToken.setPath("/");
|
accessToken.setPath("/");
|
||||||
|
|
||||||
response.addCookie(accessToken);
|
response.addCookie(accessToken);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
|
||||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true,proxyTargetClass = true)
|
|
||||||
public class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CommonsMultipartResolver multipartResolver(){
|
|
||||||
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
|
|
||||||
multipartResolver.setMaxUploadSize(268435456);
|
|
||||||
return multipartResolver;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import eu.dnetlib.utils.MailLibrary;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class MailConfig {
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.host}")
|
|
||||||
private String host;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.port}")
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.authenticate}")
|
|
||||||
private boolean authenticate;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.username}")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.from}")
|
|
||||||
private String from;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.replyTo}")
|
|
||||||
private String replyTo;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.mode}")
|
|
||||||
private String mode;
|
|
||||||
|
|
||||||
@Value("${services.provide.mail.debug}")
|
|
||||||
private boolean debug;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MailLibrary createMailLibrary() {
|
|
||||||
MailLibrary lib = new MailLibrary();
|
|
||||||
|
|
||||||
lib.setAuthenticate(authenticate);
|
|
||||||
lib.setDebug(debug);
|
|
||||||
lib.setFrom(from);
|
|
||||||
lib.setMailhost(host);
|
|
||||||
lib.setSmtpPort(port);
|
|
||||||
lib.setMode(mode);
|
|
||||||
lib.setReplyTo(replyTo);
|
|
||||||
lib.setUsername(username);
|
|
||||||
lib.setPassword(password);
|
|
||||||
lib.setMode(mode);
|
|
||||||
|
|
||||||
lib.init();
|
|
||||||
|
|
||||||
return lib;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.nimbusds.jwt.JWT;
|
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesMapper;
|
|
||||||
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(OpenAIREAuthoritiesMapper.class);
|
|
||||||
|
|
||||||
@Value("${services.provide.adminEmail}")
|
|
||||||
String adminEmail;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<? extends GrantedAuthority> mapAuthorities(JWT jwtToken, UserInfo userInfo) {
|
|
||||||
JsonArray entitlements = null;
|
|
||||||
Set<GrantedAuthority> authorities = new HashSet<>();
|
|
||||||
if (userInfo != null && userInfo.getSource() != null) {
|
|
||||||
if (userInfo.getSource().getAsJsonArray("edu_person_entitlements") != null) {
|
|
||||||
entitlements = userInfo.getSource().getAsJsonArray("edu_person_entitlements");
|
|
||||||
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
|
|
||||||
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
|
|
||||||
}
|
|
||||||
logger.debug("user info: {}\nentitlements: {}", userInfo, entitlements);
|
|
||||||
|
|
||||||
// FIXME: delete this if statement when super administrators are set
|
|
||||||
if (userInfo.getEmail() != null && userInfo.getEmail().equals(adminEmail)) {
|
|
||||||
authorities.add(new SimpleGrantedAuthority("SUPER_ADMINISTRATOR"));
|
|
||||||
}
|
|
||||||
|
|
||||||
authorities.addAll(AuthoritiesMapper.map(entitlements));
|
|
||||||
}
|
|
||||||
return authorities;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
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 {
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
|
import com.nimbusds.jwt.JWT;
|
||||||
|
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
||||||
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
|
||||||
|
|
||||||
|
private final static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||||
|
|
||||||
|
private Map<String,SimpleGrantedAuthority> userRolesMap;
|
||||||
|
|
||||||
|
OpenAireProviderAuthoritiesMapper(Map<String,String> userRoles) {
|
||||||
|
userRolesMap = new HashMap<>();
|
||||||
|
userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
|
||||||
|
Set<GrantedAuthority> out = new HashSet<>();
|
||||||
|
out.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||||
|
|
||||||
|
if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
|
||||||
|
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
|
||||||
|
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
|
||||||
|
if (authority != null) {
|
||||||
|
logger.debug(String.format("Role mapped %s",role));
|
||||||
|
out.add(authority);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
|
||||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
|
||||||
import org.springframework.session.web.http.CookieSerializer;
|
|
||||||
import org.springframework.session.web.http.DefaultCookieSerializer;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableRedisHttpSession
|
|
||||||
public class RedisConfiguration {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RedisConfiguration.class);
|
|
||||||
|
|
||||||
@Value("${services.provide.redis.host}")
|
|
||||||
private String host;
|
|
||||||
|
|
||||||
@Value("${services.provide.redis.port:6379}")
|
|
||||||
private String port;
|
|
||||||
|
|
||||||
@Value("${services.provide.redis.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.domain}")
|
|
||||||
private String domain;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void init() {
|
|
||||||
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public JedisConnectionFactory connectionFactory() {
|
|
||||||
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
|
||||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
|
||||||
jedisConnectionFactory.setHostName(host);
|
|
||||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
|
||||||
jedisConnectionFactory.setUsePool(true);
|
|
||||||
if (password != null) jedisConnectionFactory.setPassword(password);
|
|
||||||
return jedisConnectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CookieSerializer cookieSerializer() {
|
|
||||||
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
|
||||||
serializer.setCookieName("openAIRESession");
|
|
||||||
serializer.setCookiePath("/");
|
|
||||||
serializer.setDomainName(domain);
|
|
||||||
logger.info("Cookie Serializer : {}", serializer);
|
|
||||||
return serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
||||||
|
private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
|
||||||
|
|
||||||
|
|
||||||
|
public RepoManagerContextLoaderListener() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RepoManagerContextLoaderListener(WebApplicationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected WebApplicationContext createWebApplicationContext(
|
||||||
|
ServletContext servletContext)
|
||||||
|
throws BeansException {
|
||||||
|
logger.debug("Creating web application context");
|
||||||
|
Properties props = this.loadProperties();
|
||||||
|
String repoMode = props.getProperty("services.validator.mode.repo");
|
||||||
|
String userMode = props.getProperty("services.validator.mode.user");
|
||||||
|
Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
|
||||||
|
|
||||||
|
logger.info("User mode: " + userMode);
|
||||||
|
logger.info("Repo mode: " + repoMode);
|
||||||
|
logger.info("Standalone mode: " + standaloneMode);
|
||||||
|
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
|
||||||
|
|
||||||
|
ctx.setServletContext(servletContext);
|
||||||
|
|
||||||
|
String userApiContext = null;
|
||||||
|
if (userMode.equalsIgnoreCase("local"))
|
||||||
|
userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
|
||||||
|
else if (userMode.equalsIgnoreCase("ldap"))
|
||||||
|
userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
|
||||||
|
|
||||||
|
String[] springContextCore = new String[] {
|
||||||
|
"classpath:META-INF/cxf/cxf.xml",
|
||||||
|
"classpath:META-INF/cxf/cxf-extension-soap.xml",
|
||||||
|
"classpath:META-INF/cxf/cxf-extension-jaxws.xml",
|
||||||
|
"classpath:META-INF/cxf/cxf-servlet.xml",
|
||||||
|
"classpath*:/cxf.xml",
|
||||||
|
"classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
|
||||||
|
"classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
|
||||||
|
"classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
|
||||||
|
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
|
||||||
|
"classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
|
||||||
|
"classpath*:/" + userApiContext
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
String[] springContextForStandalone = new String[] {
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] springContextForIS = new String[] {
|
||||||
|
"classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
|
||||||
|
"classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
|
||||||
|
"classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
|
||||||
|
"classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
|
||||||
|
"classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
|
||||||
|
"classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (standaloneMode) {
|
||||||
|
logger.debug("Loading contexts for standalone mode");
|
||||||
|
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
|
||||||
|
} else {
|
||||||
|
logger.debug("Loading contexts for dnet");
|
||||||
|
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.refresh();
|
||||||
|
|
||||||
|
logger.debug("done");
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Properties loadProperties() {
|
||||||
|
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
|
||||||
|
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
|
||||||
|
});
|
||||||
|
|
||||||
|
CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
|
||||||
|
Properties props = pLoader.getProperties();
|
||||||
|
|
||||||
|
ctx.destroy();
|
||||||
|
ctx.close();
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.controllers.*;
|
||||||
|
import eu.dnetlib.repo.manager.service.MonitorService;
|
||||||
|
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||||
|
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||||
|
import eu.dnetlib.repo.manager.service.ValidatorService;
|
||||||
|
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||||
|
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.service.VendorExtension;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by panagiotis on 16/11/2017.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
@EnableWebMvc
|
||||||
|
@EnableCircuitBreaker
|
||||||
|
@ComponentScan(basePackageClasses = {
|
||||||
|
RepositoryController.class,
|
||||||
|
MonitorController.class,
|
||||||
|
ValidatorController.class,
|
||||||
|
PiWikController.class,
|
||||||
|
BrokerController.class,
|
||||||
|
StatsController.class,
|
||||||
|
UserController.class,
|
||||||
|
SushiliteController.class
|
||||||
|
},basePackages = "eu.dnetlib.repo.manager.*")
|
||||||
|
public class SwaggerConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket productApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.any())
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build()
|
||||||
|
.pathMapping("/")
|
||||||
|
.apiInfo(getApiInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo getApiInfo() {
|
||||||
|
return new ApiInfo("Repository Manager Dashboard API Documentation",
|
||||||
|
"Repository Manager Dashboard API Documentation",
|
||||||
|
"1.0",
|
||||||
|
"urn:tos",
|
||||||
|
new Contact("", "", ""),
|
||||||
|
"Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
|
||||||
|
new ArrayList<VendorExtension>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,18 +1,16 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
|
||||||
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import eu.dnetlib.repo.manager.shared.Term;
|
||||||
|
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -21,22 +19,24 @@ import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/broker")
|
@RequestMapping(value = "/broker")
|
||||||
@Tag(name="broker", description="Broker API")
|
@Api(description = "Broker API", tags = {"broker"})
|
||||||
public class BrokerController{
|
public class BrokerController{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrokerServiceImpl brokerService;
|
private BrokerServiceImpl brokerService;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
|
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public DatasourcesBroker getDatasourcesOfUser(
|
public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
|
||||||
|
@ApiParam(value = "User email", required = true) String user,
|
||||||
@RequestParam("includeShared")
|
@RequestParam("includeShared")
|
||||||
@Parameter(description = "Include shared datasources (default = false)", required = true) String includeShared,
|
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
|
||||||
@RequestParam("includeByOthers")
|
@RequestParam("includeByOthers")
|
||||||
@Parameter(description = "Include datasources of other (default = false)", required = true) String includeByOthers) throws JSONException {
|
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
|
||||||
return brokerService.getDatasourcesOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), includeShared, includeByOthers);
|
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
|
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
|
||||||
|
@ -51,7 +51,7 @@ public class BrokerController{
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public EventsPage advancedShowEvents(@PathVariable("page") String page,
|
public EventsPage advancedShowEvents(@PathVariable("page") String page,
|
||||||
@PathVariable("size") String size,
|
@PathVariable("size") String size,
|
||||||
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
|
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
|
||||||
|
@ -62,7 +62,7 @@ public class BrokerController{
|
||||||
method = RequestMethod.GET,
|
method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
||||||
@RequestParam("topic") String topic,
|
@RequestParam("topic") String topic,
|
||||||
@RequestParam("page") String page,
|
@RequestParam("page") String page,
|
||||||
|
@ -70,20 +70,20 @@ public class BrokerController{
|
||||||
return brokerService.showEvents(datasourceName, topic, page, size);
|
return brokerService.showEvents(datasourceName, topic, page, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getSimpleSubscriptionsOfUser" ,
|
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
|
||||||
method = RequestMethod.GET,
|
method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser() throws BrokerException{
|
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
|
||||||
return brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
|
return brokerService.getSimpleSubscriptionsOfUser(userEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
|
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER') ")
|
@PreAuthorize("hasRole('ROLE_USER') ")
|
||||||
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
||||||
return brokerService.subscribe(obj);
|
return brokerService.subscribe(obj);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class BrokerController{
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||||
return brokerService.unsubscribe(subscriptionId);
|
return brokerService.unsubscribe(subscriptionId);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class BrokerController{
|
||||||
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
|
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||||
return brokerService.getSubscription(subscriptionId);
|
return brokerService.getSubscription(subscriptionId);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class BrokerController{
|
||||||
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
||||||
,produces = MediaType.APPLICATION_JSON_VALUE)
|
,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
||||||
@PathVariable("page") String page,
|
@PathVariable("page") String page,
|
||||||
@PathVariable("size") String size) throws BrokerException{
|
@PathVariable("size") String size) throws BrokerException{
|
||||||
|
|
|
@ -1,96 +1,31 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
|
||||||
import eu.dnetlib.repo.manager.domain.BrokerSummary;
|
|
||||||
import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary;
|
|
||||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.UsageSummary;
|
import eu.dnetlib.repo.manager.service.DashboardService;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import io.swagger.annotations.Api;
|
||||||
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.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/dashboard")
|
@RequestMapping(value = "/dashboard")
|
||||||
@Tag(name="dashboard", description = "Dashboard API")
|
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||||
public class DashboardController {
|
public class DashboardController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DashboardService dashboardService;
|
private DashboardService dashboardService;
|
||||||
|
|
||||||
@Autowired
|
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
|
||||||
private RepositoryService repositoryService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AggregationService aggregationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BrokerService brokerService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PiWikService piWikService;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(
|
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||||
@PathVariable("page") String page,
|
@PathVariable("page") String page,
|
||||||
@PathVariable("size") String size) throws JSONException {
|
@PathVariable("size") String size) throws JSONException {
|
||||||
return dashboardService.getRepositoriesSummaryInfo(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
|
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/collectionMonitorSummary/{repoId}", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
|
||||||
public CollectionMonitorSummary getCollectionMonitorSummary(
|
|
||||||
@PathVariable("repoId") String repoId,
|
|
||||||
@RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException {
|
|
||||||
|
|
||||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId);
|
|
||||||
|
|
||||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
|
||||||
// Set the "aggregationInfo" for the first <number of> requested aggregations, in order to create a "summary".
|
|
||||||
collectionMonitorSummary.setAggregationInfo(aggregationInfoList.subList(0, Math.min(summarySize, aggregationInfoList.size())));
|
|
||||||
|
|
||||||
// Search for the last indexed version and set the "collectionMonitorSummary".
|
|
||||||
for ( AggregationInfo aggregationInfo : aggregationInfoList ) {
|
|
||||||
if ( aggregationInfo.isIndexedVersion() ) {
|
|
||||||
collectionMonitorSummary.setLastIndexedVersion(aggregationInfo);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionMonitorSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/usageSummary/{repoId}", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
|
||||||
public UsageSummary getUsageSummary(
|
|
||||||
@PathVariable("repoId") String repoId
|
|
||||||
) throws RepositoryServiceException {
|
|
||||||
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/brokerSummary/{ds_name}", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
|
||||||
public BrokerSummary getBrokerSummary(
|
|
||||||
@PathVariable("ds_name") String datasourceName) throws BrokerException {
|
|
||||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,21 +2,18 @@ package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
|
||||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.exception.ServerError;
|
import eu.dnetlib.repo.manager.exception.ServerError;
|
||||||
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
@ -26,9 +23,6 @@ import java.net.UnknownHostException;
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
public class GenericControllerAdvice {
|
public class GenericControllerAdvice {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(GenericControllerAdvice.class);
|
|
||||||
|
|
||||||
|
|
||||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||||
@ExceptionHandler(ResourceNotFoundException.class)
|
@ExceptionHandler(ResourceNotFoundException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,57 +2,55 @@ package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
|
||||||
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.json.JSONException;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/monitor")
|
@RequestMapping(value = "/monitor")
|
||||||
@Tag(name="monitor", description="Monitor API")
|
@Api(description = "Monitor API", tags = {"monitor"})
|
||||||
public class MonitorController {
|
public class MonitorController {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MonitorController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorServiceImpl monitorService;
|
private MonitorServiceImpl monitorService;
|
||||||
|
|
||||||
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public JobsOfUser getJobsOfUser(@RequestParam(value = "jobType", required = false)
|
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||||
@Parameter(description = "Equals to filter job type on validation history page") String jobType,
|
@RequestParam(value = "jobType", required = false)
|
||||||
@RequestParam("offset") @Parameter(name = "Page number", required = true) String offset,
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @Parameter(description = "Null value") String limit,
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||||
@RequestParam(value = "dateFrom", required = false) @Parameter(description = "Null value") String dateFrom,
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||||
@RequestParam(value = "dateTo", required = false) @Parameter(description = "Null value") String dateTo,
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||||
@RequestParam("validationStatus") @Parameter(description = "Equals to filter validation jobs", required = false) String validationStatus,
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||||
@RequestParam("includeJobsTotal") @Parameter(description = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs") String validationStatus,
|
||||||
return monitorService.getJobsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws ValidatorServiceException {
|
||||||
|
|
||||||
|
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public int getJobsOfUserPerValidationStatus(@RequestBody String jobType,
|
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
||||||
@RequestBody String validationStatus) throws JSONException {
|
@RequestBody String jobType,
|
||||||
return monitorService.getJobsOfUserPerValidationStatus(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, validationStatus);
|
@RequestBody String validationStatus){
|
||||||
|
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public StoredJob getJobSummary(@RequestParam String jobId,
|
public StoredJob getJobSummary(@RequestParam String jobId,
|
||||||
@RequestParam String groupBy) throws JSONException {
|
@RequestParam String groupBy){
|
||||||
return monitorService.getJobSummary(jobId, groupBy);
|
return monitorService.getJobSummary(jobId, groupBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,12 @@ import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||||
import eu.dnetlib.repo.manager.domain.Paging;
|
import eu.dnetlib.repo.manager.domain.Paging;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
|
||||||
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import org.slf4j.Logger;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -20,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -31,44 +31,36 @@ import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/piwik")
|
@RequestMapping(value = "/piwik")
|
||||||
@Tag(name="piwik", description = "Piwik API")
|
@Api(description = "Piwik API", tags = {"piwik"})
|
||||||
public class PiWikController {
|
public class PiWikController {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PiWikController.class);
|
private static final Logger logger = Logger
|
||||||
|
.getLogger(PiWikController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PiWikServiceImpl piWikService;
|
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)
|
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repositoryId) or (@repositoryService.getRepositoryById(#repositoryId).registeredby==null and hasAuthority('REGISTERED_USER'))")
|
|
||||||
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
||||||
return piWikService.getPiwikSiteForRepo(repositoryId);
|
return piWikService.getPiwikSiteForRepo(repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
@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("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') " +
|
||||||
|
"and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||||
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
||||||
return piWikService.savePiwikInfo(piwikInfo);
|
return piWikService.savePiwikInfo(piwikInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@Parameters({
|
@ApiImplicitParams({
|
||||||
@Parameter(name = "from", description = "number"),
|
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||||
@Parameter(name = "quantity", description = "number"),
|
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||||
@Parameter(name = "order", description = "eu.dnetlib.repo.manager.domain.OrderByType"),
|
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||||
@Parameter(name = "orderField", description = "eu.dnetlib.repo.manager.domain.OrderByField"),
|
@ApiImplicitParam(name = "searchField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||||
@Parameter(name = "searchField", description = "string")
|
@ApiImplicitParam(name = "orderField", dataType = "string", paramType = "query"),
|
||||||
})
|
})
|
||||||
public Paging<PiwikInfo> getPiwikSitesForRepos(
|
public Paging<PiwikInfo> getPiwikSitesForRepos(
|
||||||
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
||||||
|
@ -82,23 +74,22 @@ public class PiWikController {
|
||||||
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField);
|
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField);
|
||||||
results.setFrom(from);
|
results.setFrom(from);
|
||||||
results.setTo(from + returning.size());
|
results.setTo(from + returning.size());
|
||||||
results.setTotal(piWikService.getPiwikSitesTotals(searchField));
|
results.setTotal(piWikService.getPiwikSitesTotals());
|
||||||
results.setResults(returning);
|
results.setResults(returning);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ApiImplicitParams({
|
||||||
@Parameters({
|
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||||
@Parameter(name = "from", description = "number"),
|
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||||
@Parameter(name = "quantity", description = "number"),
|
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||||
@Parameter(name = "order", description = "eu.dnetlib.repo.manager.domain.OrderByType"),
|
@ApiImplicitParam(name = "searchField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||||
@Parameter(name = "searchField", description = "eu.dnetlib.repo.manager.domain.OrderByField"),
|
@ApiImplicitParam(name = "orderField", dataType = "string", paramType = "query"),
|
||||||
@Parameter(name = "orderField", description = "string")
|
|
||||||
})
|
})
|
||||||
@RequestMapping(value = "/getPiwikSitesForRepos/csv" , method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
@RequestMapping(value = "/getPiwikSitesForRepos/csv" , method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public FileSystemResource getPiwikSitesForReposToCsv(
|
public FileSystemResource getPiwikSitesForReposToCsv(
|
||||||
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
||||||
@RequestParam(value = "quantity",required=false,defaultValue = "10000") int quantity,
|
@RequestParam(value = "quantity",required=false,defaultValue = "100") int quantity,
|
||||||
@RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType,
|
@RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType,
|
||||||
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
|
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
|
||||||
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField,
|
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField,
|
||||||
|
@ -107,24 +98,27 @@ public class PiWikController {
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
|
|
||||||
Path p = Files.createTempFile("exportingCsv-", new Date().toString());
|
Path p = Files.createTempFile("exportingCsv-", new Date().toString());
|
||||||
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,0,10000,searchField);
|
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField);
|
||||||
try (PrintWriter writer = new PrintWriter(p.toFile())) {
|
try (PrintWriter writer = new PrintWriter(p.toFile())) {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(" Repository ID , Repository name, Country, Site ID, Authentication token, Creation date, Requestor full name, Requestor email, Validated, Validation date, Comment \n");
|
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){
|
for(PiwikInfo piwikInfo : returning){
|
||||||
sb.append(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId() + ",")
|
sb.append(
|
||||||
.append(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName() + ",")
|
(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId()+ ",")+
|
||||||
.append(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry() + ",")
|
(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName()+ ",")+
|
||||||
.append(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId() + ",")
|
(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry()+ ",")+
|
||||||
.append(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken() + ",")
|
(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId()+ ",") +
|
||||||
.append(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString() + ",")
|
(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken()+ ",")+
|
||||||
.append(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName() + ",")
|
(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString()+ ",") +
|
||||||
.append(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail() + ",")
|
(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName()+ ",") +
|
||||||
.append(piwikInfo.isValidated()).append(",")
|
(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail()+ ",")+
|
||||||
.append(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString() + ",")
|
piwikInfo.isValidated() + "," +
|
||||||
.append(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment() + "\n");
|
(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString()+ ",") +
|
||||||
|
(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment()+ "\n")
|
||||||
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
writer.write(sb.toString());
|
writer.write(sb.toString());
|
||||||
|
|
||||||
|
@ -142,13 +136,14 @@ public class PiWikController {
|
||||||
|
|
||||||
|
|
||||||
String headerKey = "Content-Disposition";
|
String headerKey = "Content-Disposition";
|
||||||
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");//dd/MM/yyyy
|
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String strDate = sdfDate.format(now);
|
String strDate = sdfDate.format(now);
|
||||||
String headerValue = String.format("attachment; filename=\"csv-%s.csv\"",
|
String headerValue = String.format("attachment; filename=\"csv-%s.csv\"",
|
||||||
strDate);
|
strDate);
|
||||||
response.setHeader(headerKey, headerValue);
|
response.setHeader(headerKey, headerValue);
|
||||||
|
|
||||||
|
|
||||||
return new FileSystemResource(p.toFile());
|
return new FileSystemResource(p.toFile());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,29 +151,28 @@ public class PiWikController {
|
||||||
|
|
||||||
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
|
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||||
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
|
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
|
||||||
return piWikService.approvePiwikSite(repositoryId);
|
return piWikService.approvePiwikSite(repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@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(String repositoryid){
|
||||||
public String getOpenaireId(@PathVariable("repositoryId") String repositoryId){
|
return piWikService.getOpenaireId(repositoryid);
|
||||||
return piWikService.getOpenaireId(repositoryId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
|
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||||
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
||||||
return piWikService.markPiwikSiteAsValidated(repositoryId);
|
return piWikService.markPiwikSiteAsValidated(repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
|
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||||
public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
|
public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
|
||||||
@RequestParam("repoWebsite") String repoWebsite,
|
@RequestParam("repoWebsite") String repoWebsite,
|
||||||
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
|
||||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.DiskSpaceMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
|
|
||||||
import io.micrometer.prometheus.PrometheusConfig;
|
|
||||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
|
||||||
import io.prometheus.client.exporter.common.TextFormat;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "/actuator/prometheus", produces = "application/openmetrics-text; version=1.0.0; charset=utf-8")
|
|
||||||
public class PrometheusController {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PrometheusController.class);
|
|
||||||
|
|
||||||
private final PiWikService piWikService;
|
|
||||||
private final RepositoryService repositoryService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public PrometheusController(PiWikService piWikService, RepositoryService repositoryService) {
|
|
||||||
this.piWikService = piWikService;
|
|
||||||
this.repositoryService = repositoryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
|
||||||
public String getPiwikMetrics() {
|
|
||||||
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
|
||||||
registry.gauge("provide_repositories_registered", repositoryService.getTotalRegisteredRepositories());
|
|
||||||
registry.gauge("provide_usagecounts_repositories_registered", piWikService.getTotal());
|
|
||||||
registry.gauge("provide_usagecounts_repositories_validated", piWikService.getValidated(true));
|
|
||||||
|
|
||||||
return registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "metrics", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
||||||
public String getMetrics() {
|
|
||||||
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
|
||||||
new JvmThreadMetrics().bindTo(registry);
|
|
||||||
try (JvmGcMetrics jvmGcMetrics = new JvmGcMetrics() ) {
|
|
||||||
jvmGcMetrics.bindTo(registry);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("", e);
|
|
||||||
}
|
|
||||||
new JvmMemoryMetrics().bindTo(registry);
|
|
||||||
new DiskSpaceMetrics(new File("/")).bindTo(registry);
|
|
||||||
new ProcessorMetrics().bindTo(registry); // metrics related to the CPU stats
|
|
||||||
new UptimeMetrics().bindTo(registry);
|
|
||||||
|
|
||||||
return registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,64 +1,33 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||||
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.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.service.AggregationService;
|
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl;
|
||||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
import eu.dnetlib.repo.manager.shared.*;
|
||||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
import io.swagger.annotations.Api;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
|
||||||
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.json.JSONException;
|
import org.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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PostAuthorize;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.Path;
|
||||||
import java.util.Date;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/repositories")
|
@RequestMapping(value = "/repository")
|
||||||
@Tag(name="repositories", description="Repository API")
|
@Api(description = "Repository API", tags = {"repository"})
|
||||||
public class RepositoryController {
|
public class RepositoryController {
|
||||||
|
|
||||||
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
|
@Autowired
|
||||||
RepositoryController(RepositoryService repositoryService,
|
private RepositoryServiceImpl repositoryService;
|
||||||
AggregationService aggregationService,
|
|
||||||
AuthorizationService authorizationService,
|
|
||||||
PiWikService piWikService) {
|
|
||||||
this.repositoryService = repositoryService;
|
|
||||||
this.aggregationService = aggregationService;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
this.piWikService = piWikService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/countries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Country[] getCountries() {
|
public Country[] getCountries() {
|
||||||
return repositoryService.getCountries();
|
return repositoryService.getCountries();
|
||||||
|
@ -69,40 +38,24 @@ public class RepositoryController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||||
@PathVariable("mode") String mode,
|
@PathVariable("mode") String mode,
|
||||||
@RequestParam(value = "managed", required = false) Boolean managed) {
|
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
||||||
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/snippets/user", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(@RequestParam(name = "page", defaultValue = "0") int page,
|
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
||||||
@RequestParam(name = "size", defaultValue = "1000") int pageSize) throws Exception {
|
@PathVariable("page") String page,
|
||||||
return repositoryService.getRepositoriesSnippetsOfUser(String.valueOf(page), String.valueOf(pageSize));
|
@PathVariable("size") String size) throws JSONException {
|
||||||
}
|
return repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||||
|
|
||||||
@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,
|
@RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}",method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||||
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name="country", required=false) String country,
|
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name="country", required=false) String country,
|
||||||
@RequestParam(name="typology", required=false) String typology,
|
@RequestParam(name="typology", required=false) String typology,
|
||||||
@RequestParam(name="englishName", required=false) String englishName,
|
@RequestParam(name="englishName", required=false) String englishName,
|
||||||
|
@ -110,7 +63,7 @@ public class RepositoryController {
|
||||||
@RequestParam("requestSortBy") String requestSortBy,
|
@RequestParam("requestSortBy") String requestSortBy,
|
||||||
@RequestParam("order") String order,
|
@RequestParam("order") String order,
|
||||||
@PathVariable("page") int page,
|
@PathVariable("page") int page,
|
||||||
@PathVariable("size") int pageSize) {
|
@PathVariable("size") int pageSize) throws Exception {
|
||||||
|
|
||||||
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
||||||
}
|
}
|
||||||
|
@ -118,29 +71,22 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@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 {
|
||||||
public Repository getRepositoryById(@PathVariable("id") String id) throws ResourceNotFoundException {
|
return repositoryService.getRepositoryById(id);
|
||||||
Repository repo = repositoryService.getRepositoryById(id);
|
|
||||||
|
|
||||||
if (repo != null)
|
|
||||||
logger.info("Returning repository {} registered by {}", repo.getId(), repo.getRegisteredby());
|
|
||||||
else
|
|
||||||
logger.info("Requested repository {} not found", id);
|
|
||||||
return repo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<AggregationInfo> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||||
return aggregationService.getRepositoryAggregations(id, 0, 20);
|
return repositoryService.getRepositoryAggregations(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, List<AggregationInfo>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||||
return aggregationService.getRepositoryAggregationsByYear(id);
|
return repositoryService.getRepositoryAggregationsByYear(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
||||||
|
@ -148,30 +94,26 @@ public class RepositoryController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||||
@PathVariable("page") String page,
|
@PathVariable("page") String page,
|
||||||
@PathVariable("size") String size) {
|
@PathVariable("size") String size) throws JSONException {
|
||||||
return repositoryService.getRepositoriesByName(name, page, size);
|
return repositoryService.getRepositoriesByName(name, page, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@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 {
|
||||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) {
|
|
||||||
return repositoryService.getRepositoryInterface(id);
|
return repositoryService.getRepositoryInterface(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
// @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,
|
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||||
@RequestBody Repository repository) {
|
@RequestBody Repository repository) throws Exception {
|
||||||
|
|
||||||
return repositoryService.addRepository(datatype, repository);
|
return repositoryService.addRepository(datatype, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -179,7 +121,6 @@ public class RepositoryController {
|
||||||
return repositoryService.getDnetCountries();
|
return repositoryService.getDnetCountries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -187,7 +128,6 @@ public class RepositoryController {
|
||||||
return repositoryService.getTypologies();
|
return repositoryService.getTypologies();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -198,48 +138,43 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
|
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||||
public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) {
|
|
||||||
return repositoryService.updateRepository(repository, authentication);
|
return repositoryService.updateRepository(repository, authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOfInterface(#id)")
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||||
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
||||||
@RequestParam("registeredBy") String registeredBy){
|
@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,
|
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||||
@RequestParam("repoId") String id,
|
@RequestParam("repoId") String repoId,
|
||||||
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
@RequestParam(value = "comment", required = false) String comment,
|
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
|
||||||
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface, desiredCompatibilityLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
@RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
|
||||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String id,
|
|
||||||
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
|
||||||
@RequestParam(value = "comment", required = false) String comment,
|
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
|
||||||
return repositoryService.updateRepositoryInterface(id, comment, repositoryInterface, desiredCompatibilityLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public List<String> getUrlsOfUserRepos(@PathVariable("page") String page, @PathVariable("size") String size) {
|
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
||||||
return repositoryService.getUrlsOfUserRepos(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
|
@PathVariable("page") String page,
|
||||||
|
@PathVariable("size") String size) throws JSONException {
|
||||||
|
return repositoryService.getUrlsOfUserRepos(userEmail, page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||||
|
return repositoryService.getDatasourceVocabularies(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
|
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
|
||||||
|
@ -257,71 +192,27 @@ public class RepositoryController {
|
||||||
return repositoryService.getDatasourceClasses(mode);
|
return repositoryService.getDatasourceClasses(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getMetricsInfoForRepository/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public MetricsInfo getMetricsInfoForRepository(@PathVariable("id") String id) throws RepositoryServiceException {
|
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
||||||
return repositoryService.getMetricsInfoForRepository(id);
|
return repositoryService.getMetricsInfoForRepository(repoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
|
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) {
|
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||||
return repositoryService.getListLatestUpdate(mode);
|
return repositoryService.getListLatestUpdate(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ResponseBody
|
||||||
/**
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||||
* Get all the admins of the repository
|
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||||
*/
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "{id}/admins")
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
|
||||||
public ResponseEntity<List<User>> getAdminsOfARepo(@PathVariable("id") String id) {
|
|
||||||
return new ResponseEntity<>(authorizationService.getAdminsOfRepo(id), HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Subscribe to repo by email
|
|
||||||
*/
|
|
||||||
@RequestMapping(method = RequestMethod.POST, path = "{id}/admins")
|
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
|
||||||
public Response subscribeByEmail(@PathVariable("id") String id, @RequestBody String email) throws ResourceNotFoundException {
|
|
||||||
authorizationService.addAdmin(id, email);
|
|
||||||
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(javax.ws.rs.core.MediaType.APPLICATION_JSON).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsubscribe from repo by email
|
|
||||||
*/
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, path = "{id}/admins/{email:.+}")
|
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
|
||||||
public ResponseEntity<Void> unsubscribeByEmail(@PathVariable("id") String id, @PathVariable("email") String email) throws ResourceNotFoundException {
|
|
||||||
authorizationService.removeAdmin(id, email);
|
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the Piwik Site of a repository is enabled and validated.
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "{repositoryId}/metrics/valid", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public boolean getMetricsEnabledAndValidated(@PathVariable("repositoryId") String repositoryId) {
|
|
||||||
PiwikInfo info = piWikService.getPiwikSiteForRepo(repositoryId);
|
|
||||||
return info != null && info.isValidated();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns repository Metrics.
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "{repositoryId}/metrics", method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public MetricsInfo getMetricsInfo(@PathVariable("repositoryId") String id) throws RepositoryServiceException {
|
|
||||||
return repositoryService.getMetricsInfoForRepository(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.dnetlib.repo.manager.utils;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -16,17 +16,17 @@ public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
||||||
HttpStatus.Series seriesError = httpResponse.getStatusCode().series();
|
return (httpResponse.getStatusCode().series() == CLIENT_ERROR
|
||||||
return ( (seriesError == CLIENT_ERROR) || (seriesError == SERVER_ERROR) );
|
|| httpResponse.getStatusCode().series() == SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
||||||
|
|
||||||
HttpStatus statusCode = httpResponse.getStatusCode();
|
if (httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) {
|
||||||
if ( statusCode == HttpStatus.NOT_FOUND )
|
|
||||||
throw new IOException();
|
|
||||||
else if (statusCode.series() == SERVER_ERROR)
|
|
||||||
throw new EndPointException();
|
throw new EndPointException();
|
||||||
|
} else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR && httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.service.StatsServiceImpl;
|
import eu.dnetlib.repo.manager.service.StatsServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -13,13 +14,14 @@ import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/stats")
|
@RequestMapping(value = "/stats")
|
||||||
@Tag(name="statistics", description = "Stats API")
|
@Api(description = "Stats API", tags = {"statistics"})
|
||||||
public class StatsController {
|
public class StatsController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StatsServiceImpl statsService;
|
private StatsServiceImpl statsService;
|
||||||
|
|
||||||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map getStatistics(){
|
public Map getStatistics(){
|
||||||
return statsService.getStatistics();
|
return statsService.getStatistics();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.service.sushilite.SushiliteServiceImpl;
|
import eu.dnetlib.repo.manager.service.SushiliteServiceImpl;
|
||||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
@ -10,15 +10,16 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/sushilite")
|
@RequestMapping(value = "/sushilite")
|
||||||
@Tag(name="sushilite", description = "Sushi-Lite API")
|
@Api(description = "Sushi-Lite API", tags = {"sushilite"})
|
||||||
public class SushiliteController {
|
public class SushiliteController {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SushiliteServiceImpl sushiliteService;
|
private SushiliteServiceImpl sushiliteService;
|
||||||
|
|
||||||
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
|
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
|
||||||
@PathVariable("pageSize") String pageSize,
|
@PathVariable("pageSize") String pageSize,
|
||||||
@RequestParam(value = "Report") String Report,
|
@RequestParam(value = "Report") String Report,
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
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;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.service.UserServiceImpl;
|
import eu.dnetlib.repo.manager.service.UserServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
@ -11,14 +11,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/user")
|
@RequestMapping(value = "/user")
|
||||||
@Tag(name="user", description = "User API")
|
@Api(description = "User API", tags = {"user"})
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserServiceImpl userService;
|
private UserServiceImpl userService;
|
||||||
|
|
||||||
@RequestMapping(value = "/login" , method = RequestMethod.GET)
|
@RequestMapping(value = "/login" , method = RequestMethod.GET)
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public ResponseEntity<Object> login() {
|
public ResponseEntity<Object> login() {
|
||||||
return userService.login();
|
return userService.login();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
//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());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,55 +1,50 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
|
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||||
|
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||||
|
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
import java.util.*;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
import io.swagger.annotations.Api;
|
||||||
import eu.dnetlib.repo.manager.service.EmailUtils;
|
import io.swagger.annotations.ApiParam;
|
||||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/validator")
|
@RequestMapping(value = "/validator")
|
||||||
@Tag(name="validator", description = "Validator API")
|
@Api(description = "Validator API", tags = {"validator"})
|
||||||
public class ValidatorController {
|
public class ValidatorController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ValidatorServiceImpl validatorService;
|
private ValidatorServiceImpl validatorService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EmailUtils emailUtils;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
|
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||||
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||||
return validatorService.submitJobForValidation(jobForValidation);
|
return validatorService.submitJobForValidation(jobForValidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/reSubmitJobForValidation/{jobId}",method = RequestMethod.POST,
|
@RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
||||||
return validatorService.reSubmitJobForValidation(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobId);
|
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||||
|
return validatorService.reSubmitJobForValidation(email, jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ -60,13 +55,13 @@ public class ValidatorController {
|
||||||
|
|
||||||
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
public List<String> getSetsOfRepository(@RequestParam(value = "url") String url) {
|
||||||
return validatorService.getSetsOfRepository(url);
|
return validatorService.getSetsOfRepository(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
|
public boolean identifyRepo(@RequestParam(value = "url") String url) {
|
||||||
return validatorService.identifyRepo(url);
|
return validatorService.identifyRepo(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +73,17 @@ public class ValidatorController {
|
||||||
|
|
||||||
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public List<StoredJob> getStoredJobsNew(@RequestParam(value = "jobType", required = false)
|
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||||
@Parameter(description = "Equals to filter job type on validation history page") String jobType,
|
@RequestParam(value = "jobType", required = false)
|
||||||
@RequestParam("offset") @Parameter(description = "Page number", required = true) String offset,
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @Parameter(description = "Null value") String limit,
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||||
@RequestParam(value = "dateFrom", required = false) @Parameter(description = "Null value") String dateFrom,
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||||
@RequestParam(value = "dateTo", required = false) @Parameter(description = "Null value") String dateTo,
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||||
@RequestParam("validationStatus") @Parameter(description = "Equals to filter validation jobs", required = true) String validationStatus
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||||
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
||||||
) throws ValidatorServiceException {
|
) throws ValidatorServiceException {
|
||||||
return validatorService.getStoredJobsNew(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ -102,27 +98,5 @@ public class ValidatorController {
|
||||||
return validatorService.getInterfaceInformation(baseUrl);
|
return validatorService.getInterfaceInformation(baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public List<StoredJob> getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException {
|
|
||||||
return validatorService.getJobsSummary(repoId,size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public void validationCompleted(
|
|
||||||
@RequestParam(value = "repoId") String repoId,
|
|
||||||
@RequestParam(value = "interfaceId") String interfaceId,
|
|
||||||
@RequestParam(value = "jobId") String jobId,
|
|
||||||
@RequestParam(value = "issuerEmail") String issuerEmail,
|
|
||||||
@RequestParam(value = "isUpdate") boolean isUpdate,
|
|
||||||
@RequestParam(value = "isSuccess") boolean isSuccess,
|
|
||||||
@RequestParam(value = "scoreUsage") int scoreUsage,
|
|
||||||
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
|
||||||
|
|
||||||
validatorService.onComplete(repoId, interfaceId, jobId, issuerEmail, isUpdate, isSuccess, scoreUsage, scoreContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,188 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
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,36 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
|
||||||
import eu.dnetlib.repo.manager.domain.broker.SimpleSubscriptionDesc;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class BrokerSummary {
|
|
||||||
private Map<String, List<SimpleSubscriptionDesc>> userSubs;
|
|
||||||
|
|
||||||
private List<BrowseEntry> topicsForDatasource;
|
|
||||||
|
|
||||||
public BrokerSummary(){}
|
|
||||||
|
|
||||||
public BrokerSummary(Map<String, List<SimpleSubscriptionDesc>> userSubs, List<BrowseEntry> topicsForDatasource) {
|
|
||||||
this.userSubs = userSubs;
|
|
||||||
this.topicsForDatasource = topicsForDatasource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, List<SimpleSubscriptionDesc>> getUserSubs() {
|
|
||||||
return userSubs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserSubs(Map<String, List<SimpleSubscriptionDesc>> userSubs) {
|
|
||||||
this.userSubs = userSubs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<BrowseEntry> getTopicsForDatasource() {
|
|
||||||
return topicsForDatasource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTopicsForDatasource(List<BrowseEntry> topicsForDatasource) {
|
|
||||||
this.topicsForDatasource = topicsForDatasource;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CollectionMonitorSummary {
|
|
||||||
private List<AggregationInfo> aggregationInfo;
|
|
||||||
|
|
||||||
private AggregationInfo lastIndexedVersion;
|
|
||||||
|
|
||||||
public CollectionMonitorSummary(){}
|
|
||||||
|
|
||||||
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
|
|
||||||
this.aggregationInfo = aggregationInfo;
|
|
||||||
this.lastIndexedVersion = lastIndexedVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AggregationInfo> getAggregationInfo() {
|
|
||||||
return aggregationInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
|
|
||||||
this.aggregationInfo = aggregationInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AggregationInfo getLastIndexedVersion() {
|
|
||||||
return lastIndexedVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastIndexedVersion(AggregationInfo lastIndexedVersion) {
|
|
||||||
this.lastIndexedVersion = lastIndexedVersion;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,321 +0,0 @@
|
||||||
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,24 +0,0 @@
|
||||||
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,79 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
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 +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Organization implements Serializable {
|
||||||
public class Organization{
|
|
||||||
private String country;
|
private String country;
|
||||||
private String legalname;
|
private String legalname;
|
||||||
private String websiteurl;
|
private String websiteurl;
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
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,18 +43,6 @@ public class Paging<T> {
|
||||||
this.results = new ArrayList<>();
|
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() {
|
public int getTotal() {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
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 +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +1,19 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
public class RepositorySnippet implements IsSerializable {
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class RepositorySnippet {
|
|
||||||
|
|
||||||
// Do not refactor names to keep compatibility with external api.
|
|
||||||
private String id;
|
private String id;
|
||||||
private String officialname;
|
private String officialname;
|
||||||
private String englishname;
|
private String englishname;
|
||||||
private String websiteurl;
|
private String websiteurl;
|
||||||
|
|
||||||
private String registeredby;
|
|
||||||
private Date registrationdate;
|
|
||||||
private String eoscDatasourceType;
|
|
||||||
private String logoUrl;
|
|
||||||
private String description;
|
|
||||||
private Boolean consentTermsOfUse;
|
|
||||||
private Date consentTermsOfUseDate;
|
|
||||||
private Date lastConsentTermsOfUseDate;
|
|
||||||
private Boolean fullTextDownload;
|
|
||||||
private Set<OrganizationDetails> organizations;
|
|
||||||
private String typology;
|
private String typology;
|
||||||
|
private String registeredby;
|
||||||
|
private Organization[] organizations;
|
||||||
|
private String registrationdate;
|
||||||
|
|
||||||
|
public RepositorySnippet() {}
|
||||||
private PiwikInfo piwikInfo;
|
|
||||||
|
|
||||||
public RepositorySnippet() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -80,82 +63,19 @@ public class RepositorySnippet {
|
||||||
this.typology = typology;
|
this.typology = typology;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<OrganizationDetails> getOrganizations() {
|
public Organization[] getOrganizations() {
|
||||||
return organizations;
|
return organizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrganizations(Set<OrganizationDetails> organizations) {
|
public void setOrganizations(Organization[] organizations) {
|
||||||
this.organizations = organizations;
|
this.organizations = organizations;
|
||||||
}
|
}
|
||||||
public Date getRegistrationdate() {
|
|
||||||
|
public String getRegistrationdate() {
|
||||||
return registrationdate;
|
return registrationdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegistrationdate(Date registrationdate) {
|
public void setRegistrationdate(String registrationdate) {
|
||||||
this.registrationdate = registrationdate;
|
this.registrationdate = registrationdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PiwikInfo getPiwikInfo() {
|
|
||||||
return piwikInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPiwikInfo(PiwikInfo piwikInfo) {
|
|
||||||
this.piwikInfo = piwikInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogoUrl() {
|
|
||||||
return logoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogoUrl(String logoUrl) {
|
|
||||||
this.logoUrl = logoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getFullTextDownload() {
|
|
||||||
return fullTextDownload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFullTextDownload(Boolean fullTextDownload) {
|
|
||||||
this.fullTextDownload = fullTextDownload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getConsentTermsOfUse() {
|
|
||||||
return consentTermsOfUse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
|
|
||||||
this.consentTermsOfUse = consentTermsOfUse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getConsentTermsOfUseDate() {
|
|
||||||
return consentTermsOfUseDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) {
|
|
||||||
this.consentTermsOfUseDate = consentTermsOfUseDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastConsentTermsOfUseDate() {
|
|
||||||
return lastConsentTermsOfUseDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastConsentTermsOfUseDate(Date lastConsentTermsOfUseDate) {
|
|
||||||
this.lastConsentTermsOfUseDate = lastConsentTermsOfUseDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEoscDatasourceType() {
|
|
||||||
return eoscDatasourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEoscDatasourceType(String eoscDatasourceType) {
|
|
||||||
this.eoscDatasourceType = eoscDatasourceType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class RepositorySummaryInfo{
|
public class RepositorySummaryInfo implements IsSerializable {
|
||||||
|
|
||||||
String id;
|
String id;
|
||||||
String repositoryName;
|
String repositoryName;
|
||||||
|
|
|
@ -7,7 +7,6 @@ public class RequestFilter{
|
||||||
|
|
||||||
private String registeredby = null;
|
private String registeredby = null;
|
||||||
private String typology = null;
|
private String typology = null;
|
||||||
private String eoscDatasourceType = null;
|
|
||||||
private String country = null;
|
private String country = null;
|
||||||
private String id = null;
|
private String id = null;
|
||||||
private String officialname = null;
|
private String officialname = null;
|
||||||
|
@ -29,14 +28,6 @@ public class RequestFilter{
|
||||||
this.typology = typology;
|
this.typology = typology;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEoscDatasourceType() {
|
|
||||||
return eoscDatasourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEoscDatasourceType(String eoscDatasourceType) {
|
|
||||||
this.eoscDatasourceType = eoscDatasourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRegisteredby() {
|
public String getRegisteredby() {
|
||||||
return registeredby;
|
return registeredby;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
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,53 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by panagiotis on 15/1/2018.
|
|
||||||
*/
|
|
||||||
public class Term {
|
|
||||||
|
|
||||||
private String englishName;
|
|
||||||
private String nativeName;
|
|
||||||
private String encoding;
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
public Term(String englishName, String nativeName, String encoding, String code) {
|
|
||||||
this.englishName = englishName;
|
|
||||||
this.nativeName = nativeName;
|
|
||||||
this.encoding = encoding;
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEnglishName() {
|
|
||||||
return englishName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnglishName(String englishName) {
|
|
||||||
this.englishName = englishName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNativeName() {
|
|
||||||
return nativeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNativeName(String nativeName) {
|
|
||||||
this.nativeName = nativeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEncoding() {
|
|
||||||
return encoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEncoding(String encoding) {
|
|
||||||
this.encoding = encoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
|
||||||
|
|
||||||
public class UsageSummary {
|
|
||||||
private MetricsInfo metricsInfo;
|
|
||||||
|
|
||||||
private PiwikInfo piwikInfo;
|
|
||||||
|
|
||||||
public UsageSummary() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public UsageSummary(MetricsInfo metricsInfo, PiwikInfo piwikInfo) {
|
|
||||||
this.metricsInfo = metricsInfo;
|
|
||||||
this.piwikInfo = piwikInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetricsInfo getMetricsInfo() {
|
|
||||||
return metricsInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMetricsInfo(MetricsInfo metricsInfo) {
|
|
||||||
this.metricsInfo = metricsInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PiwikInfo getPiwikInfo() {
|
|
||||||
return piwikInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPiwikInfo(PiwikInfo piwikInfo) {
|
|
||||||
this.piwikInfo = piwikInfo;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain.broker;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by stefanos on 17/3/2017.
|
|
||||||
*/
|
|
||||||
public enum ConditionOperator {
|
|
||||||
EXACT, MATCH_ANY, MATCH_ALL, RANGE
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain.broker;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by stefanos on 10-Mar-17.
|
|
||||||
*/
|
|
||||||
public enum NotificationFrequency {
|
|
||||||
never, realtime, daily, weekly, monthly
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain.broker;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by stefanos on 10-Mar-17.
|
|
||||||
*/
|
|
||||||
public enum NotificationMode {
|
|
||||||
MOCK, EMAIL
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
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,32 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain.dto;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
@XmlRootElement
|
|
||||||
public class Role {
|
|
||||||
String name;
|
|
||||||
String description;
|
|
||||||
|
|
||||||
public Role() {}
|
|
||||||
|
|
||||||
public Role(String name, String description) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain.dto;
|
|
||||||
|
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
|
||||||
|
|
||||||
public class User {
|
|
||||||
|
|
||||||
private String sub;
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
public User() {}
|
|
||||||
|
|
||||||
public User(String sub, String firstName, String lastName, String email) {
|
|
||||||
this.sub = sub;
|
|
||||||
this.firstName = firstName;
|
|
||||||
this.lastName = lastName;
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static User from(UserInfo userInfo) {
|
|
||||||
User user = new User();
|
|
||||||
user.setSub(user.getSub());
|
|
||||||
user.setFirstName(userInfo.getGivenName());
|
|
||||||
user.setLastName(userInfo.getFamilyName());
|
|
||||||
user.setEmail(userInfo.getEmail());
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSub() {
|
|
||||||
return sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSub(String sub) {
|
|
||||||
this.sub = sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFirstName() {
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstName(String firstName) {
|
|
||||||
this.firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastName() {
|
|
||||||
return lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastName(String lastName) {
|
|
||||||
this.lastName = lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package eu.dnetlib.repo.manager.exception;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
//@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
|
||||||
public class EndPointException extends IOException {
|
public class EndPointException extends IOException {
|
||||||
|
|
||||||
public EndPointException() {
|
public EndPointException() {
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,10 +9,6 @@ public class ResourceNotFoundException extends Exception {
|
||||||
super("Resource Not Found");
|
super("Resource Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceNotFoundException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceNotFoundException(String id, String resourceType) {
|
public ResourceNotFoundException(String id, String resourceType) {
|
||||||
super(resourceType + " with id " + id + " was not found");
|
super(resourceType + " with id " + id + " was not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
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> {
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
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,10 +1,16 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.shared.Term;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -28,8 +34,6 @@ public interface BrokerService {
|
||||||
|
|
||||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
|
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
|
||||||
|
|
||||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException;
|
|
||||||
|
|
||||||
Subscription subscribe(OpenaireSubscription obj) throws BrokerException;
|
Subscription subscribe(OpenaireSubscription obj) throws BrokerException;
|
||||||
|
|
||||||
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
|
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
|
||||||
|
@ -40,5 +44,4 @@ public interface BrokerService {
|
||||||
|
|
||||||
EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException;
|
EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException;
|
||||||
|
|
||||||
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
import eu.dnetlib.repo.manager.shared.Term;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||||
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
import org.springframework.stereotype.Service;
|
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.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
|
@ -24,33 +24,33 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service("brokerService")
|
@Service("brokerService")
|
||||||
public class BrokerServiceImpl implements BrokerService {
|
public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepositoryServiceImpl repoAPI;
|
private RepositoryServiceImpl repoAPI;
|
||||||
@Value("${services.provide.broker.url}:${services.provide.broker.port}/${services.provide.broker.api}${services.provide.broker.openaire}")
|
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}${services.broker.openaire}")
|
||||||
private String openairePath;
|
private String openairePath;
|
||||||
@Value("${services.provide.broker.url}:${services.provide.broker.port}/${services.provide.broker.api}")
|
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}")
|
||||||
private String apiPath;
|
private String apiPath;
|
||||||
@Value("${services.provide.topic_types.url}")
|
@Value("${topic_types.url}")
|
||||||
private String topicsURL;
|
private String topicsURL;
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(BrokerServiceImpl.class);
|
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
|
||||||
|
.getLogger(BrokerServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestTemplate restTemplate ;
|
RestTemplate restTemplate ;
|
||||||
|
|
||||||
private HttpHeaders httpHeaders;
|
private HttpHeaders httpHeaders;
|
||||||
|
|
||||||
private final HashMap<String, Term> topics = new HashMap<>();
|
private HashMap<String,Term> topics = new HashMap<String, Term>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initDnetTopicsMap() {
|
private void initDnetTopicsMap() {
|
||||||
|
@ -65,7 +65,8 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
for (JsonNode term : root.path("terms") )
|
for (JsonNode term : root.path("terms") )
|
||||||
topics.put(term.path("code").textValue(), parseTerm(term));
|
topics.put(term.path("code").textValue(), parseTerm(term));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception on initDnetTopicsMap", e);
|
logger.debug("Exception on initDnetTopicsMap" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,25 +77,24 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) {
|
public DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws JSONException {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
DatasourcesBroker ret = new DatasourcesBroker();
|
DatasourcesBroker ret = new DatasourcesBroker();
|
||||||
try {
|
try {
|
||||||
ret.setDatasourcesOfUser(getDatasourcesOfUserType(repoAPI.getRepositoriesSnippetsOfUser(user, "0", "100")));
|
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||||
//TODO fix bug when values are true
|
if (Boolean.parseBoolean(includeShared)) {
|
||||||
// if (Boolean.parseBoolean(includeShared)) {
|
List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||||
// List<String> sharedDatasourceIds = new ArrayList<String>();
|
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||||
// ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (Boolean.parseBoolean(includeByOthers)) {
|
|
||||||
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
|
||||||
// }
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Exception on getDatasourcesOfUser", e);
|
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
logger.debug("Getting datasources of user in " + (end - start) + "ms");
|
if (Boolean.parseBoolean(includeByOthers)) {
|
||||||
|
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||||
|
}
|
||||||
|
} catch (BrokerException e) {
|
||||||
|
logger.debug("Exception on getDatasourcesOfUser" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,8 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on getTopicsForDatasource" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,15 +129,13 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
final String service = "/events/{page}/{pageSize}";
|
final String service = "/events/{page}/{pageSize}";
|
||||||
|
|
||||||
long pageNum = Long.parseLong(page);
|
|
||||||
advQueryObject.setPage(pageNum);
|
|
||||||
|
|
||||||
Map<String, Long> uriParams = new HashMap<>();
|
Map<String, Long> uriParams = new HashMap<>();
|
||||||
uriParams.put("page", pageNum);
|
uriParams.put("page", Long.parseLong(page));
|
||||||
uriParams.put("pageSize", Long.parseLong(size));
|
uriParams.put("pageSize", Long.parseLong(size));
|
||||||
|
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||||
|
|
||||||
|
advQueryObject.setPage(Long.parseLong(page));
|
||||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||||
ResponseEntity<EventsPage> resp;
|
ResponseEntity<EventsPage> resp;
|
||||||
try {
|
try {
|
||||||
|
@ -144,24 +143,28 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
builder.buildAndExpand(uriParams).encode().toUri(),
|
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
entity,
|
entity,
|
||||||
new ParameterizedTypeReference<EventsPage>() {}
|
new ParameterizedTypeReference<EventsPage>() {
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on advancedShowEvents" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return resp.getBody();
|
return resp.getBody();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<RepositorySnippet> repositories) throws BrokerException {
|
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>();
|
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>();
|
||||||
for (RepositorySnippet repo : repositories) {
|
for (Repository repo : repositories) {
|
||||||
BrowseEntry temp = new BrowseEntry();
|
BrowseEntry temp = new BrowseEntry();
|
||||||
temp.setValue(repo.getOfficialname());
|
temp.setValue(repo.getOfficialName());
|
||||||
temp.setSize(0L);
|
temp.setSize(0L);
|
||||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) {
|
||||||
temp.setSize(temp.getSize() + e.getSize());
|
temp.setSize(temp.getSize() + e.getSize());
|
||||||
}
|
}
|
||||||
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl());
|
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl());
|
||||||
|
@ -170,11 +173,30 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
// sort the collection by the second field of the tuple which is size
|
// sort the collection by the second field of the tuple which is size
|
||||||
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||||
long stop = System.currentTimeMillis();
|
|
||||||
logger.debug("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Repository> getRepositoriesOfUser(String userEmail) throws JSONException {
|
||||||
|
|
||||||
|
int page = 0;
|
||||||
|
int size = 50;
|
||||||
|
List<Repository> rs ;
|
||||||
|
List<Repository> resultSet = new ArrayList<>();
|
||||||
|
|
||||||
|
while (true){
|
||||||
|
rs = repoAPI.getRepositoriesOfUser(userEmail, String.valueOf(page), String.valueOf(size));
|
||||||
|
resultSet.addAll(rs);
|
||||||
|
page+=1;
|
||||||
|
if(rs.size() == 0) break;
|
||||||
|
}
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Repository> getRepositoriesByIds(List<String> sharedDatasourceIds) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventsPage showEvents(String datasourceName,
|
public EventsPage showEvents(String datasourceName,
|
||||||
String topic,
|
String topic,
|
||||||
|
@ -197,7 +219,8 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<EventsPage>() {
|
new ParameterizedTypeReference<EventsPage>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on showEvents" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return resp.getBody();
|
return resp.getBody();
|
||||||
|
@ -209,31 +232,26 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
final String service = "/subscriptions";
|
final String service = "/subscriptions";
|
||||||
|
|
||||||
URI uri = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||||
.queryParam("email", userEmail).build().encode().toUri();
|
.queryParam("email", userEmail);
|
||||||
|
|
||||||
logger.debug("{}", uri);
|
logger.debug(builder.build().encode().toUri());
|
||||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||||
try {
|
try {
|
||||||
resp = restTemplate.exchange(
|
resp = restTemplate.exchange(
|
||||||
uri,
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on getSimpleSubscriptionsOfUser" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return resp.getBody();
|
return resp.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) { //throws BrokerException {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
//Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException {
|
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException {
|
||||||
final String service = "/subscribe";
|
final String service = "/subscribe";
|
||||||
|
@ -256,7 +274,8 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<Subscription>() {
|
new ParameterizedTypeReference<Subscription>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on OpenaireSubscription" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +298,8 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<Void>() {
|
new ParameterizedTypeReference<Void>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on unsubscribe" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||||
|
@ -302,14 +322,15 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<Subscription>() {
|
new ParameterizedTypeReference<Subscription>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on getSubscription" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return resp.getBody();
|
return resp.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Term> getDnetTopics() throws BrokerException {
|
public Map<String, Term> getDnetTopics(){
|
||||||
return topics;
|
return topics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,30 +353,11 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
new ParameterizedTypeReference<EventsPage>() {
|
new ParameterizedTypeReference<EventsPage>() {
|
||||||
});
|
});
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
logger.error(e.getMessage());
|
logger.debug("Exception on getNotificationsBySubscriptionId" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
}
|
}
|
||||||
return resp.getBody();
|
return resp.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Override
|
|
||||||
public Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail)
|
|
||||||
throws BrokerException {
|
|
||||||
|
|
||||||
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);
|
|
||||||
Map<String, List<Subscription>> subs = new HashMap<>();
|
|
||||||
List<Subscription> subscriptions = null;
|
|
||||||
|
|
||||||
for (String s : simpleSubs.keySet()) {
|
|
||||||
List<SimpleSubscriptionDesc> simpleSubscriptionDescs = simpleSubs.get(s);
|
|
||||||
for (SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
|
|
||||||
subscriptions = new ArrayList<>();
|
|
||||||
subscriptions.add(getSubscription(simpleSubscriptionDesc.getId()));
|
|
||||||
}
|
|
||||||
subs.put(s, subscriptions);
|
|
||||||
}
|
|
||||||
return subs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
import eu.dnetlib.domain.data.Repository;
|
||||||
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.RepositorySummaryInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
||||||
import eu.dnetlib.repo.manager.utils.DateUtils;
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||||
import org.slf4j.Logger;
|
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
import javax.xml.ws.ServiceMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("dashboardService")
|
@Service("dashboardService")
|
||||||
public class DashboardServiceImpl implements DashboardService {
|
public class DashboardServiceImpl implements DashboardService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DashboardServiceImpl.class);
|
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AggregationService aggregationService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrokerService brokerService;
|
private BrokerService brokerService;
|
||||||
|
|
||||||
|
@ -38,55 +36,50 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
|
||||||
for (RepositorySnippet repository : repositoriesOfUser)
|
List<Repository> repositoriesOfUser = repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||||
{
|
for(Repository repository: repositoriesOfUser) {
|
||||||
String repoId = repository.getId();
|
|
||||||
String repoOfficialName = repository.getOfficialname();
|
|
||||||
|
|
||||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||||
repositorySummaryInfo.setId(repoId);
|
repositorySummaryInfo.setId(repository.getId());
|
||||||
repositorySummaryInfo.setRepositoryName(repoOfficialName);
|
repositorySummaryInfo.setRepositoryName(repository.getOfficialName());
|
||||||
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
||||||
|
|
||||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it possible that we will find an indexed version there?
|
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId());
|
||||||
boolean isIndexedVersionFound = false;
|
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||||
long start = System.currentTimeMillis();
|
if(aggregationDetails.getIndexedVersion()) {
|
||||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, 20);
|
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||||
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||||
if (aggregationInfo.isIndexedVersion()) {
|
|
||||||
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
|
||||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
|
||||||
isIndexedVersionFound = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
if ( isIndexedVersionFound )
|
|
||||||
logger.debug("Got repo aggregations in " + (end - start) + "ms");
|
|
||||||
else
|
|
||||||
logger.warn("Could not find repo aggregations, after " + (end - start) + "ms!");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MetricsNumbers metricsNumbers = repositoryService.getMetricsInfoForRepository(repoId).getMetricsNumbers();
|
|
||||||
repositorySummaryInfo.setTotalDownloads(metricsNumbers.getTotalDownloads());
|
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
||||||
repositorySummaryInfo.setTotalViews(metricsNumbers.getTotalViews());
|
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||||
|
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||||
|
|
||||||
} catch (RepositoryServiceException e) {
|
} catch (RepositoryServiceException e) {
|
||||||
logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e);
|
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repoOfficialName);
|
|
||||||
|
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialName());
|
||||||
Long totalEvents = 0L;
|
Long totalEvents = 0L;
|
||||||
for(BrowseEntry browseEntry: events)
|
for(BrowseEntry browseEntry: events)
|
||||||
totalEvents += browseEntry.getSize();
|
totalEvents += browseEntry.getSize();
|
||||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||||
|
|
||||||
|
|
||||||
} catch (BrokerException e) {
|
} catch (BrokerException e) {
|
||||||
logger.error("Exception getting broker events for repository: {}, {} ", repoId, repoOfficialName, e);
|
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Something baad happened!", e);
|
logger.error("Something baad happened!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +1,30 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
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 org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface EmailUtils {
|
public interface EmailUtils {
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo);
|
|
||||||
|
|
||||||
@Async
|
void reportException(Exception exception);
|
||||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo);
|
|
||||||
|
|
||||||
@Async
|
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo);
|
|
||||||
|
|
||||||
@Async
|
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo);
|
|
||||||
|
|
||||||
/****USER REGISTRATION REQUEST EMAILS****/
|
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||||
@Async
|
|
||||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
|
||||||
|
|
||||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
@Async
|
|
||||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
||||||
@Async
|
|
||||||
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
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, String desiredCompatibility, Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
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, String desiredCompatibility, Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
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);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
|
|
||||||
|
|
||||||
@Async
|
|
||||||
void sendUponJobCompletion(String repoId,
|
|
||||||
String repoInterfaceId,
|
|
||||||
String compatibility,
|
|
||||||
int scoreUsage,
|
|
||||||
int scoreContent,
|
|
||||||
boolean isSuccess,
|
|
||||||
boolean isUpdate,
|
|
||||||
String issuerEmail,
|
|
||||||
String jobId) throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +1,110 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
import eu.dnetlib.repo.manager.config.CascadingPropertyLoader;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
|
||||||
import eu.dnetlib.utils.MailLibrary;
|
import eu.dnetlib.utils.MailLibrary;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Collection;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.Collections;
|
import java.io.PrintWriter;
|
||||||
import java.util.HashSet;
|
import java.io.StringWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component("emailUtils")
|
@Component("emailUtils")
|
||||||
@Async
|
|
||||||
public class EmailUtilsImpl implements EmailUtils {
|
public class EmailUtilsImpl implements EmailUtils {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(EmailUtilsImpl.class);
|
private static Logger logger = Logger.getLogger(EmailUtilsImpl.class);
|
||||||
|
|
||||||
private final MailLibrary mailLibrary;
|
private List<String> specialRecipients = new ArrayList<>();
|
||||||
private final RepositoryService repositoryService;
|
private boolean override = false, logonly = false;
|
||||||
|
private String overrideEmail = null;
|
||||||
|
|
||||||
@Value("${services.provide.baseUrl}")
|
@Autowired
|
||||||
|
private MailLibrary mailLibrary;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CascadingPropertyLoader pLoader;
|
||||||
|
|
||||||
|
@Value("${services.repo-manager.baseUrl}")
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
@Value("${services.provide.usagestats.adminEmail}")
|
@Value("${services.repo-manager.adminEmail}")
|
||||||
|
private String adminEmail;
|
||||||
|
|
||||||
|
@Value("${services.repomanager.usagestats.adminEmail}")
|
||||||
private String usageStatsAdminEmail;
|
private String usageStatsAdminEmail;
|
||||||
|
|
||||||
@Value("${services.provide.adminEmail}")
|
@Value("${services.provide.adminEmail}")
|
||||||
private String provideAdminEmail;
|
private String provideAdminEmail;
|
||||||
|
|
||||||
@Value("${services.provide.validator.results.url}")
|
|
||||||
private String valBaseUrl;
|
|
||||||
|
|
||||||
@Autowired
|
@PostConstruct
|
||||||
EmailUtilsImpl(MailLibrary mailLibrary, RepositoryService repositoryService) {
|
public void init(){
|
||||||
this.mailLibrary = mailLibrary;
|
logger.info(String.format("url -> %s", this.baseUrl));
|
||||||
this.repositoryService = repositoryService;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reportException(Exception exception) {
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
PrintWriter printWriter = new PrintWriter(writer);
|
||||||
|
exception.printStackTrace(printWriter);
|
||||||
|
|
||||||
|
List<String> recipients = new ArrayList<String>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
recipients.add(this.adminEmail);
|
||||||
|
String message = "An exception has occurred:\n"+writer.toString();
|
||||||
|
String subject = "Automatic Bug Report";
|
||||||
|
this.sendMail(recipients, subject, message, false, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error sending error report", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) {
|
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||||
|
|
||||||
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
||||||
|
|
||||||
String message =
|
String message = "Dear administrator,\n" +
|
||||||
|
"\n" +
|
||||||
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||||
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
|
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"For more information about this request, go here: \n" +
|
"For more information about this request, go here: \n" +
|
||||||
this.baseUrl + "/admin/metrics";
|
this.baseUrl + "/admin/metrics\n" +
|
||||||
message = createAdminMail(message);
|
"\n" +
|
||||||
|
"Best,\n" +
|
||||||
|
"The OpenAIRE team";
|
||||||
|
|
||||||
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
this.sendMail(this.usageStatsAdminEmail, subject, message, false, null);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) {
|
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||||
|
|
||||||
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
||||||
|
|
||||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||||
|
@ -79,7 +112,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
"we have received your request to enable the OpenAIRE usage statistics for your repository\n" +
|
"we have received your request to enable the OpenAIRE usage statistics for your repository\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||||
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
|
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " +
|
"In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " +
|
||||||
|
@ -97,28 +130,45 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
"Best,\n" +
|
"Best,\n" +
|
||||||
"The OpenAIRE team";
|
"The OpenAIRE team";
|
||||||
|
|
||||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) {
|
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||||
|
|
||||||
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||||
|
|
||||||
String message =
|
String message = "Dear administrator,\n" +
|
||||||
|
"\n" +
|
||||||
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
|
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
|
||||||
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||||
"Authentication token - " + piwikInfo.getAuthenticationToken();
|
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||||
message = createAdminMail(message);
|
"\n" +
|
||||||
|
"Best,\n" +
|
||||||
|
"The OpenAIRE team";
|
||||||
|
|
||||||
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
this.sendMail(this.usageStatsAdminEmail, subject, message, false, null);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) {
|
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||||
|
|
||||||
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||||
|
|
||||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||||
|
@ -132,601 +182,172 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
" For more information and questions, you can contact the openaire support team by sending an email to " +
|
" For more information and questions, you can contact the openaire support team by sending an email to " +
|
||||||
"repositoryusagestats@openaire.eu\n" +
|
"repositoryusagestats@openaire.eu\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Best Regards,\n" +
|
"Best,\n" +
|
||||||
"The OpenAIRE team";
|
"The OpenAIRE team";
|
||||||
|
|
||||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) {
|
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||||
String subject = "OpenAIRE content provider registration for " +
|
try {
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
String subject = "OpenAIRE content provider registration request started for " +
|
||||||
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
String message =
|
String message = "Dear administrator" + ",\n" +
|
||||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
"\n" +
|
||||||
|
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
|
||||||
" to the OpenAIRE compliant list of content providers. " +
|
" to the OpenAIRE compliant list of content providers. " +
|
||||||
"\n\n" +
|
"A validation process against the OpenAIRE guidelines compatibility " +
|
||||||
"User Contact: " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() +
|
|
||||||
" (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
|
||||||
"\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
|
||||||
"This message has been generated automatically.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE content provider registration for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" to the OpenAIRE compliant list of content providers. " +
|
|
||||||
"\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
|
||||||
"This message has been generated automatically.\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
|
||||||
}
|
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"We received a request to add the following interface: \n\n" +
|
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
|
||||||
"Selected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) + "\n\n" +
|
|
||||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
|
||||||
|
|
||||||
if (comment != null)
|
|
||||||
message += "\nThe users comment was '" + comment + "'\n";
|
|
||||||
|
|
||||||
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
|
||||||
"has been started. You will be informed in another message once the process is finished." +
|
|
||||||
"\n\n" +
|
|
||||||
"User Contact: " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() +
|
|
||||||
" (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
|
||||||
"\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
|
||||||
"This message has been generated automatically.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
String message =
|
|
||||||
"We received a request to add the following interface: \n\n" +
|
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
|
||||||
"Selected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) + "\n\n" +
|
|
||||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
|
||||||
|
|
||||||
if (comment != null) {
|
|
||||||
message += "\n Your comment was '" + comment + "'\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " +
|
|
||||||
"has been started. You will be informed in another message once the process is finished." +
|
"has been started. You will be informed in another message once the process is finished." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.";
|
"This message has been generated automatically.\n\n" +
|
||||||
message = createUserMail(message, authentication);
|
"Regards,\n" +
|
||||||
|
"the OpenAIRE technical team\n";
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
try {
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
String subject = "OpenAIRE content provider registration request started for " +
|
||||||
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
String message =
|
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"\n" +
|
||||||
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE." +
|
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
|
||||||
|
" to the OpenAIRE compliant list of content providers. " +
|
||||||
|
"A validation process against the OpenAIRE guidelines compatibility " +
|
||||||
|
"has been started. You will be informed in another message once the process is finished." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it's metadata visible on openaire.eu.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
|
||||||
}
|
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE." +
|
|
||||||
"\n\n" +
|
|
||||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it's metadata visible on openaire.eu.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nDesired Selected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nUser Contact: " + issuerEmail + "" +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
String message =
|
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" was not successful and the registration process was interrupted." +
|
|
||||||
"\n\n" +
|
|
||||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
|
||||||
}
|
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on [" + repository.getOfficialname() + "]" +
|
|
||||||
" was not successful and the registration process was interrupted." +
|
|
||||||
"\n\n" +
|
|
||||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nUser Contact: " + issuerEmail + "" +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on [" + repository.getOfficialname() + "] has been successful\n\n" +
|
|
||||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu." + "\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
this.sendMail(issuer, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on [" + repository.getOfficialname() + "] has been successful\n\n" +
|
|
||||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu." + "\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nUser Contact: " + issuerEmail + "" +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on [" + repository.getOfficialname() + "] was not successful." +
|
|
||||||
"\n\n" +
|
|
||||||
"We will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
this.sendMail(issuer, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" was not successful." +
|
|
||||||
"\n\n" +
|
|
||||||
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) +
|
|
||||||
"\n\nUser Contact: " + issuerEmail + "" +
|
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated manually\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
|
|
||||||
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" was not successful." +
|
|
||||||
"\n\n" +
|
|
||||||
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + request.getDesiredCompatibilityLevel() +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated automatically\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createRepoAdminsMail(message);
|
|
||||||
|
|
||||||
this.sendMail(emails, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
|
|
||||||
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
|
|
||||||
" was not successful." +
|
|
||||||
"\n\n" +
|
|
||||||
|
|
||||||
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
|
||||||
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
|
||||||
"\n\nSet: " + repositoryInterface.getAccessSet() +
|
|
||||||
"\n\nSelected Guidelines: " + request.getDesiredCompatibilityLevel() +
|
|
||||||
"\n\n\nPlease do not reply to this email\n" +
|
|
||||||
"This message has been generated automatically\n\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE validator - Test results ";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the validation request you have submitted has finished. You can retrieve the results by following this url: " + valBaseUrl + "" + jobId + " .\n\n" +
|
|
||||||
"Please do not reply to this message.\n" +
|
|
||||||
"This message has been generated automatically.\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createUserMail(message, authentication);
|
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
|
||||||
emailTo.add(issuer);
|
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
|
||||||
}
|
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE validator - Test results ";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"a validation request has finished. You can retrieve the results by following this url: " + valBaseUrl + "" + jobId + " .\n\n" +
|
|
||||||
"\n\nUser Contact: " + issuer + "" +
|
|
||||||
"Please do not reply to this message.\n" +
|
|
||||||
"This message has been generated automatically.\n" +
|
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE validator - job failure";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"the validation job that was automatically submitted for the update/registration of the interface "
|
|
||||||
+ repositoryInterface.getId() + " (" + repositoryInterface.getBaseurl() + ", "
|
|
||||||
+ repositoryInterface.getAccessSet() + ") of the repository " + repository.getId()
|
|
||||||
+ " (" + repository.getOfficialname() + ") failed to complete."
|
|
||||||
+ "This message has been generated automatically.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE content provider update information for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType()
|
|
||||||
+ "[" + repository.getOfficialname() + "].\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
|
||||||
"This message has been generated automatically.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE content provider update information for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.\n\n" +
|
"This message has been generated automatically.\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||||
message = createUserMail(message, authentication);
|
"Regards,\n" +
|
||||||
|
"the OpenAIRE technical team\n";
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
|
public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
try {
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
String subject = "OpenAIRE content provider update request started for " +
|
||||||
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
String message =
|
String message = "Dear administrator" + ",\n" +
|
||||||
"We received a request to update the following interface: \n\n" +
|
"\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
"We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||||
"Selected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) + "\n\n" +
|
|
||||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
|
||||||
|
|
||||||
if (comment != null)
|
|
||||||
message += "\nThe users comment was '" + comment + "'\n";
|
|
||||||
|
|
||||||
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
|
||||||
"User Contact: " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() +
|
|
||||||
" (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
|
||||||
"\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
|
||||||
"This message has been generated automatically.";
|
|
||||||
message = createAdminMail(message);
|
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
|
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
|
||||||
|
|
||||||
String message =
|
|
||||||
"We received a request to update the following interface: \n\n" +
|
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
|
||||||
"Selected Guidelines: " + getSelectedGuidelines(desiredCompatibility, repositoryInterface) + "\n\n" +
|
|
||||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
|
||||||
|
|
||||||
if (comment != null) {
|
|
||||||
message += "\n Your comment was '" + comment + "'\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.\n\n" +
|
"This message has been generated automatically.\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"Regards,\n" +
|
||||||
message = createUserMail(message, authentication);
|
"the OpenAIRE technical team\n";
|
||||||
|
|
||||||
Collection<String> emailTo = new HashSet<>();
|
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||||
if (repository.getRegisteredby() != null) {
|
|
||||||
emailTo.add(repository.getRegisteredby());
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
|
||||||
this.sendMail(emailTo, subject, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) {
|
public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||||
|
try {
|
||||||
|
String subject = "OpenAIRE content provider update request started for " +
|
||||||
|
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||||
|
|
||||||
|
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||||
|
"\n" +
|
||||||
|
"We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
|
||||||
|
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||||
|
"Please do not reply to this message\n" +
|
||||||
|
"This message has been generated automatically.\n\n" +
|
||||||
|
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||||
|
"Regards,\n" +
|
||||||
|
"the OpenAIRE technical team\n";
|
||||||
|
|
||||||
|
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception {
|
||||||
|
try {
|
||||||
String subject = "OpenAIRE validator - Test submission ";
|
String subject = "OpenAIRE validator - Test submission ";
|
||||||
|
|
||||||
String message =
|
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||||
|
"\n" +
|
||||||
"The validation request you have submitted has started.\n" +
|
"The validation request you have submitted has started.\n" +
|
||||||
"Please do not reply to this message.\n" +
|
"Please do not reply to this message.\n" +
|
||||||
"This message has been generated automatically.\n" +
|
"This message has been generated automatically.\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||||
message = createUserMail(message, authentication);
|
"Regards,\n" +
|
||||||
|
"the OpenAIRE technical team\n";
|
||||||
|
|
||||||
this.sendMail(jobForValidation.getUserEmail(), subject, message);
|
this.sendMail(jobForValidation.getUserEmail(), subject, message, false, null);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUponJobCompletion(
|
|
||||||
String repoId,
|
|
||||||
String repoInterfaceId,
|
|
||||||
String compatibility,
|
|
||||||
int scoreUsage,
|
|
||||||
int scoreContent,
|
|
||||||
boolean isSuccess,
|
|
||||||
boolean isUpdate,
|
|
||||||
String issuerEmail,
|
|
||||||
String jobId) throws Exception {
|
|
||||||
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
|
|
||||||
if (repositoryInterfaces.isEmpty())
|
|
||||||
throw new ValidationServiceException("Repository interface with id \"" + repoInterfaceId + "\" not found", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
|
||||||
|
|
||||||
RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter(repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0);
|
|
||||||
Repository repository = repositoryService.getRepositoryById(repoId);
|
|
||||||
|
|
||||||
if (!isUpdate) {
|
|
||||||
if (isSuccess) {
|
|
||||||
if (scoreContent >= 50 && scoreUsage >= 50) {
|
|
||||||
this.sendUserRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
} else {
|
|
||||||
this.sendUserRegistrationResultsFailureEmail(jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
this.sendAdminRegistrationResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isSuccess) {
|
|
||||||
if (scoreContent >= 50 && scoreUsage >= 50) {
|
|
||||||
this.sendUserUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
this.sendAdminUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
} else {
|
|
||||||
this.sendUserUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
this.sendAdminUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendMail(String email, String subject, String message) {
|
|
||||||
this.sendMail(Collections.singletonList(email), subject, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMail(Collection<String> recipients, String subject, String message) {
|
|
||||||
try {
|
|
||||||
logger.debug("Sending e-mail\nRecipients: {}\nSubject: {}\nMessage: {}", recipients, subject, message);
|
|
||||||
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error sending e-mail\nRecipients: " + recipients + "\nSubject: " + subject + "\nMessage: " + message, e);
|
logger.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createAdminMail(String body) {
|
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||||
body = "Dear administrator,\n\n" + body;
|
ArrayList<String> to = new ArrayList<String>();
|
||||||
body += "\n\nBest Regards,\nthe OpenAIRE technical team\n";
|
to.add(email);
|
||||||
return body;
|
this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createUserMail(String body, Authentication authentication) {
|
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||||
body = "Dear " + getUserName(authentication) + ",\n\n" + body;
|
|
||||||
body += "\n\nBest Regards,\nthe OpenAIRE technical team\n";
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String createRepoAdminsMail(String body) {
|
|
||||||
body = "Dear repository admins,\n\n" + body;
|
|
||||||
body += "\n\nBest Regards,\nthe OpenAIRE technical team\n";
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getUserName(Authentication authentication) {
|
|
||||||
String user = "user";
|
|
||||||
if (authentication != null) {
|
|
||||||
try {
|
try {
|
||||||
user = ((OIDCAuthenticationToken) authentication).getUserInfo().getName();
|
if (sendToSpecial) {
|
||||||
} catch (NullPointerException ex) {
|
recipients.addAll(this.specialRecipients);
|
||||||
}
|
|
||||||
}
|
|
||||||
return user; // It may be just "user". TODO - Wouldn't be better if it was null?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSelectedGuidelines(String desiredCompatibility, RepositoryInterface repositoryInterface) {
|
if (repoAdminMails != null)
|
||||||
return desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibilityOverride();
|
recipients.addAll(repoAdminMails);
|
||||||
|
|
||||||
|
if (this.override) {
|
||||||
|
recipients.clear();
|
||||||
|
recipients.add(overrideEmail);
|
||||||
|
}
|
||||||
|
if (!logonly)
|
||||||
|
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
||||||
|
logger.debug("Sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message, e);
|
||||||
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setOverride(boolean override) {
|
||||||
|
this.override = override;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,11 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
public interface MonitorService {
|
public interface MonitorService {
|
||||||
|
|
|
@ -3,31 +3,18 @@ package eu.dnetlib.repo.manager.service;
|
||||||
import eu.dnetlib.api.functionality.ValidatorService;
|
import eu.dnetlib.api.functionality.ValidatorService;
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.Constants;
|
import eu.dnetlib.repo.manager.shared.Constants;
|
||||||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
|
||||||
import gr.uoa.di.driver.util.ServiceLocator;
|
import gr.uoa.di.driver.util.ServiceLocator;
|
||||||
import org.eurocris.openaire.cris.validator.model.Job;
|
import org.apache.log4j.Logger;
|
||||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service("monitorService")
|
@Service("monitorService")
|
||||||
public class MonitorServiceImpl implements MonitorService {
|
public class MonitorServiceImpl implements MonitorService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MonitorServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MapJobDao crisJobs;
|
|
||||||
|
|
||||||
@Resource(name = "validatorServiceLocator")
|
@Resource(name = "validatorServiceLocator")
|
||||||
private ServiceLocator<ValidatorService> validatorServiceLocator;
|
private ServiceLocator<ValidatorService> validatorServiceLocator;
|
||||||
|
|
||||||
|
@ -35,14 +22,8 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
return this.validatorServiceLocator.getService();
|
return this.validatorServiceLocator.getService();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceLocator<ValidatorService> getValidatorServiceLocator() {
|
private static final Logger logger = Logger
|
||||||
return validatorServiceLocator;
|
.getLogger(MonitorServiceImpl.class);
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) {
|
|
||||||
this.validatorServiceLocator = validatorServiceLocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobsOfUser getJobsOfUser(String user,
|
public JobsOfUser getJobsOfUser(String user,
|
||||||
|
@ -52,28 +33,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
String dateFrom,
|
String dateFrom,
|
||||||
String dateTo,
|
String dateTo,
|
||||||
String validationStatus,
|
String validationStatus,
|
||||||
String includeJobsTotal) throws ValidatorServiceException, NumberFormatException {
|
String includeJobsTotal) throws ValidatorServiceException {
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int crisOffset = 0;
|
|
||||||
int limitWithCris = 0;
|
|
||||||
if (offset.equals("0")) {
|
|
||||||
limitWithCris = crisJobs.getJobs(user, validationStatus).size();
|
|
||||||
} else {
|
|
||||||
crisOffset = crisJobs.getJobs(user, validationStatus).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = String.valueOf(Math.max(Integer.parseInt(offset) - crisOffset, 0));
|
|
||||||
limit = String.valueOf(Math.max(Integer.parseInt(limit) - limitWithCris, 0));
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
logger.debug("Getting jobs of user : " + user);
|
||||||
|
logger.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||||
JobsOfUser retJobs = new JobsOfUser();
|
JobsOfUser retJobs = new JobsOfUser();
|
||||||
retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
||||||
Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
|
Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
|
||||||
|
|
||||||
if (Boolean.parseBoolean(includeJobsTotal)) {
|
if (Boolean.parseBoolean(includeJobsTotal)) {
|
||||||
retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null));
|
retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null));
|
||||||
retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL));
|
retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL));
|
||||||
|
@ -81,7 +47,6 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING));
|
retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO fix status with new validator version
|
|
||||||
if(retJobs.getJobs() != null){
|
if(retJobs.getJobs() != null){
|
||||||
for(StoredJob job :retJobs.getJobs()){
|
for(StoredJob job :retJobs.getJobs()){
|
||||||
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
||||||
|
@ -95,50 +60,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
||||||
job.setValidationStatus("failed");
|
job.setValidationStatus("failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if (crisOffset == 0) {
|
|
||||||
List<StoredJob> jobs = new ArrayList<>();
|
|
||||||
|
|
||||||
List<Job> cj = crisJobs.getJobs(user, validationStatus);
|
|
||||||
for (Job job : cj) {
|
|
||||||
StoredJob sj = CrisValidatorUtils.convertJobToStoredJob(job);
|
|
||||||
jobs.add(sj);
|
|
||||||
|
|
||||||
// // filter out entries based on 'validationStatus'
|
|
||||||
// if ("all".equals(validationStatus)) {
|
|
||||||
// jobs.add(sj);
|
|
||||||
// } else {
|
|
||||||
// if (sj.getValidationStatus().equals(validationStatus)) {
|
|
||||||
// jobs.add(sj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// add to CRIS Jan jobs all other jobs
|
|
||||||
if (retJobs.getJobs() != null) {
|
|
||||||
jobs.addAll(retJobs.getJobs());
|
|
||||||
}
|
|
||||||
// set all jobs back to retJobs
|
|
||||||
retJobs.setJobs(jobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix number of jobs
|
|
||||||
if (Boolean.parseBoolean(includeJobsTotal)) {
|
|
||||||
retJobs.setTotalJobs(retJobs.getTotalJobs() + crisJobs.getJobs(user).size());
|
|
||||||
retJobs.setTotalJobsSuccessful(retJobs.getTotalJobsSuccessful() + crisJobs.getJobs(user, Job.Status.SUCCESSFUL.getKey()).size());
|
|
||||||
retJobs.setTotalJobsFailed(retJobs.getTotalJobsFailed() + crisJobs.getJobs(user, Job.Status.FAILED.getKey()).size());
|
|
||||||
retJobs.setTotalJobsOngoing(retJobs.getTotalJobsOngoing() + crisJobs.getJobs(user, Job.Status.ONGOING.getKey()).size());
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
return retJobs;
|
return retJobs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||||
|
@ -148,43 +76,26 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
@Override
|
@Override
|
||||||
public int getJobsOfUserPerValidationStatus(String user,
|
public int getJobsOfUserPerValidationStatus(String user,
|
||||||
String jobType,
|
String jobType,
|
||||||
String validationStatus) throws JSONException {
|
String validationStatus){
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (ValidatorServiceException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoredJob getJobSummary(String jobId, String groupBy) {
|
public StoredJob getJobSummary(String jobId,
|
||||||
|
String groupBy){
|
||||||
logger.debug("Getting job summary with id : " + jobId);
|
logger.debug("Getting job summary with id : " + jobId);
|
||||||
StoredJob job = null;
|
|
||||||
try {
|
try {
|
||||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||||
} catch (Exception e) {
|
} catch (ValidatorServiceException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
return null;
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if (job == null) {
|
|
||||||
// not a good way to do it but Job id field is string
|
|
||||||
List<Job> cJobs = crisJobs.getAll().stream().filter(j -> j.getId().hashCode() == Integer.parseInt(jobId)).collect(Collectors.toList());
|
|
||||||
if (!cJobs.isEmpty()) {
|
|
||||||
job = CrisValidatorUtils.convertJobToStoredJob(cJobs.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
return job;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
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.domain.data.PiwikInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,7 +18,7 @@ public interface PiWikService {
|
||||||
|
|
||||||
List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField);
|
List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField);
|
||||||
|
|
||||||
int getPiwikSitesTotals(String searchField);
|
int getPiwikSitesTotals();
|
||||||
|
|
||||||
ResponseEntity<Object> approvePiwikSite(String repositoryId);
|
ResponseEntity<Object> approvePiwikSite(String repositoryId);
|
||||||
|
|
||||||
|
@ -27,8 +27,4 @@ public interface PiWikService {
|
||||||
ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
|
ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
|
||||||
|
|
||||||
PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException;
|
PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException;
|
||||||
|
|
||||||
Integer getTotal();
|
|
||||||
|
|
||||||
Integer getValidated(boolean validated);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,12 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
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.OrderByField;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.slf4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -33,14 +32,12 @@ import java.util.Map;
|
||||||
@Service("piwikService")
|
@Service("piwikService")
|
||||||
public class PiWikServiceImpl implements PiWikService {
|
public class PiWikServiceImpl implements PiWikService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PiWikServiceImpl.class);
|
@Qualifier("repomanager.dataSource")
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
|
||||||
@Value("${services.provide.analyticsURL}")
|
@Value("${services.repomanager.analyticsURL}")
|
||||||
private String analyticsURL;
|
private String analyticsURL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,20 +48,20 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
@Qualifier("emailUtils")
|
@Qualifier("emailUtils")
|
||||||
private EmailUtils emailUtils;
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
|
private static final Logger logger = Logger
|
||||||
|
.getLogger(PiWikServiceImpl.class);
|
||||||
|
|
||||||
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 GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
|
||||||
|
|
||||||
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 INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
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 = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country 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 GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
||||||
|
|
||||||
private static final String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||||
|
|
||||||
private static final String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
||||||
|
|
||||||
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.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
||||||
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||||
|
|
||||||
|
@ -79,23 +76,18 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||||
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
||||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
if (getPiwikSiteForRepo(piwikInfo.getRepositoryId()) == null) {
|
|
||||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||||
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
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});
|
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;
|
return piwikInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField) {
|
public List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField) {
|
||||||
|
logger.debug("Getting piwik sites for repos! ");
|
||||||
try{
|
try{
|
||||||
String finalizedQuery = GET_PIWIK_SITES + " where ("+
|
String finalizedQuery = GET_PIWIK_SITES + " where ("+
|
||||||
" repositoryid ilike ? " +
|
" repositoryid ilike ? " +
|
||||||
|
@ -125,36 +117,16 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPiwikSitesTotals(String searchField) {
|
public int getPiwikSitesTotals(){
|
||||||
try{
|
try{
|
||||||
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where (" +
|
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL,Integer.class);
|
||||||
" repositoryid ilike ? " +
|
|
||||||
" or siteid ilike ?" +
|
|
||||||
" or requestorname ilike ?" +
|
|
||||||
" or requestoremail ilike ?" +
|
|
||||||
" or comment ilike ?" +
|
|
||||||
" or repositoryname ilike ?" +
|
|
||||||
" or country ilike ?)";
|
|
||||||
|
|
||||||
return new JdbcTemplate(dataSource).query(finalizedQuery, preparedStatement -> {
|
|
||||||
preparedStatement.setString(1, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(2, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(3, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(4, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(5, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(6, "%" + searchField + "%");
|
|
||||||
preparedStatement.setString(7, "%" + searchField + "%");
|
|
||||||
}, rowMapper -> {
|
|
||||||
rowMapper.next();
|
|
||||||
return rowMapper.getInt("totals");
|
|
||||||
});
|
|
||||||
}catch (EmptyResultDataAccessException e){
|
}catch (EmptyResultDataAccessException e){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||||
public ResponseEntity<Object> approvePiwikSite(String repositoryId) {
|
public ResponseEntity<Object> approvePiwikSite(String repositoryId) {
|
||||||
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
|
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
|
||||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||||
|
@ -168,7 +140,7 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||||
public ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException {
|
public ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException {
|
||||||
try {
|
try {
|
||||||
approvePiwikSite(repositoryId);
|
approvePiwikSite(repositoryId);
|
||||||
|
@ -179,23 +151,24 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
|
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
logger.error("Error while approving piwik site: ", e);
|
logger.error("Error while approving piwik site: ", e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (Exception e) {
|
} 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);
|
emailUtils.reportException(e);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||||
public PiwikInfo enableMetricsForRepository(String officialName,
|
public PiwikInfo enableMetricsForRepository(String officialName,
|
||||||
String repoWebsite,
|
String repoWebsite,
|
||||||
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||||
try {
|
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");
|
+ 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;
|
String siteId = null;
|
||||||
if(map.get("value")!=null) {
|
if(map.get("value")!=null) {
|
||||||
siteId = map.get("value").toString();
|
siteId = map.get("value").toString();
|
||||||
|
@ -213,25 +186,18 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
logger.error("Error while creating piwikScript URL", uee);
|
logger.error("Error while creating piwikScript URL", uee);
|
||||||
|
emailUtils.reportException(uee);
|
||||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
logger.error("Error while creating piwik site", ioe);
|
logger.error("Error while creating piwik site", ioe);
|
||||||
|
emailUtils.reportException(ioe);
|
||||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (Exception e) {
|
} 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);
|
emailUtils.reportException(e);
|
||||||
}
|
}
|
||||||
return piwikInfo;
|
return piwikInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getTotal() {
|
|
||||||
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, Integer.class, validated);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,51 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.domain.data.Repository;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
import eu.dnetlib.repo.manager.shared.*;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface RepositoryService {
|
public interface RepositoryService {
|
||||||
|
|
||||||
|
|
||||||
// TODO: move this elsewhere
|
|
||||||
Country[] getCountries() ;
|
Country[] getCountries() ;
|
||||||
|
|
||||||
List<Repository> getRepositories(List<String> ids);
|
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
|
||||||
|
|
||||||
List<Repository> getRepositories(List<String> ids, int page, int size);
|
List<Repository> getRepositoriesOfUser(String userEmail,
|
||||||
|
String page,
|
||||||
|
String size) throws JSONException;
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception;
|
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception;
|
List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException;
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed);
|
Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
|
||||||
|
|
||||||
// TODO: remove?
|
|
||||||
List<Repository> getRepositoriesOfUser(String page, String size);
|
|
||||||
|
|
||||||
// TODO: remove?
|
|
||||||
List<Repository> getRepositoriesOfUser(String userEmail, String page, String size);
|
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size);
|
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size);
|
|
||||||
|
|
||||||
RepositorySnippet getRepositorySnippetById(String id) throws ResourceNotFoundException;
|
|
||||||
|
|
||||||
Repository getRepositoryById(String id) throws ResourceNotFoundException;
|
|
||||||
|
|
||||||
List<Repository> getRepositoriesByName(String name,
|
List<Repository> getRepositoriesByName(String name,
|
||||||
String page,
|
String page,
|
||||||
String size);
|
String size) throws JSONException;
|
||||||
|
|
||||||
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||||
String officialName, String requestSortBy, String order,
|
String officialName, String requestSortBy, String order,
|
||||||
int page, int pageSize);
|
int page, int pageSize) throws Exception;
|
||||||
|
|
||||||
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);
|
void deleteRepositoryInterface(String id, String registeredBy);
|
||||||
|
|
||||||
RepositoryInterface addRepositoryInterface(String datatype,
|
RepositoryInterface addRepositoryInterface(String datatype,
|
||||||
String repoId,
|
String repoId,
|
||||||
String comment,
|
String registeredBy,
|
||||||
RepositoryInterface repositoryInterface,
|
RepositoryInterface iFace) throws JSONException,ResourceNotFoundException;
|
||||||
String desiredCompatibilityLevel) throws Exception;
|
|
||||||
|
|
||||||
List<String> getDnetCountries();
|
List<String> getDnetCountries();
|
||||||
|
|
||||||
|
@ -67,9 +53,13 @@ public interface RepositoryService {
|
||||||
|
|
||||||
List<Timezone> getTimezones();
|
List<Timezone> getTimezones();
|
||||||
|
|
||||||
Repository updateRepository(Repository repository, Authentication authentication);
|
Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
|
||||||
|
|
||||||
List<String> getUrlsOfUserRepos(String userEmail, String page, String size);
|
List<String> getUrlsOfUserRepos(String user_email,
|
||||||
|
String page,
|
||||||
|
String size) throws JSONException;
|
||||||
|
|
||||||
|
List<String> getDatasourceVocabularies(String mode);
|
||||||
|
|
||||||
Map<String, String> getCompatibilityClasses(String mode);
|
Map<String, String> getCompatibilityClasses(String mode);
|
||||||
|
|
||||||
|
@ -79,9 +69,8 @@ public interface RepositoryService {
|
||||||
|
|
||||||
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
|
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
|
||||||
|
|
||||||
Map<String, String> getListLatestUpdate(String mode);
|
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
||||||
|
|
||||||
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface, String desiredCompatibilityLevel) throws ResourceNotFoundException, ValidatorServiceException;
|
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
|
||||||
|
|
||||||
void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance);
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,248 +1,50 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
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.stereotype.Service;
|
||||||
import org.springframework.web.client.RestClientException;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
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.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Service("statsService")
|
@Service("statsService")
|
||||||
public class StatsServiceImpl implements StatsService {
|
public class StatsServiceImpl implements StatsService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StatsServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
@Value("${services.provide.clients.search}")
|
@Value("${search.api.baseAddress}")
|
||||||
private String baseAddress;
|
private String baseAddress;
|
||||||
@Value("${services.provide.clients.usagestats}")
|
@Value("${search.api.usagestats}")
|
||||||
private String usagestatsBaseAddress;
|
private String usagestatsBaseAddress;
|
||||||
@Value("${services.provide.clients.usageEvents}")
|
@Value("${search.api.usageEvents}")
|
||||||
private String usagestatsEvents;
|
private String usagestatsEvents;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getStatistics() {
|
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<>();
|
Map<String,Object> stats = new HashMap<>();
|
||||||
stats.put("aggregators", this.getAggregatorsStats());
|
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
||||||
stats.put("dataRepositories", this.getDataRepositoriesMetadata());
|
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
||||||
stats.put("literature", this.getLiteratureStats());
|
stats.put("literature",literatureHystrixCommand.execute());
|
||||||
stats.put("journal", this.getJournalsStats());
|
stats.put("journal",journalHystrixCommand.execute());
|
||||||
stats.put("publications", this.getPublicationStats());
|
stats.put("publications",publicationHystrixCommand.execute());
|
||||||
stats.put("datasets", this.getDatasetsStats());
|
stats.put("datasets",datasetsHystrixCommand.execute());
|
||||||
stats.put("software", this.getSoftwareStats());
|
stats.put("software",softwareHystrixCommand.execute());
|
||||||
stats.put("lastYearUsagestats", this.getLastYearUsageStats());
|
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
||||||
stats.put("usagestats", this.getUsageStatsTotal());
|
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
||||||
return stats;
|
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,4 +1,4 @@
|
||||||
package eu.dnetlib.repo.manager.service.sushilite;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
|
@ -0,0 +1,116 @@
|
||||||
|
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.Autowired;
|
||||||
|
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.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
|
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.repomanager.usagestats.sushiliteEndpoint}")
|
||||||
|
private String usagestatsSushiliteEndpoint;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
|
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PreAuthorize("hasRole('ROLE_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;
|
||||||
|
try {
|
||||||
|
//communicate with endpoint
|
||||||
|
resp = template.exchange(
|
||||||
|
builder.build().encode().toUri(),
|
||||||
|
HttpMethod.GET,
|
||||||
|
null,
|
||||||
|
new ParameterizedTypeReference<ReportResponseWrapper>() {
|
||||||
|
});
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
logger.debug("Exception on getReportResults" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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,9 +1,7 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
@ -18,7 +16,11 @@ import java.util.stream.Collectors;
|
||||||
@Service("userService")
|
@Service("userService")
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
|
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
|
||||||
|
.getLogger(UserServiceImpl.class);
|
||||||
|
|
||||||
|
@Value("${oidc.issuer}")
|
||||||
|
private String oidc_issuer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Object> login() {
|
public ResponseEntity<Object> login() {
|
||||||
|
@ -26,16 +28,12 @@ public class UserServiceImpl implements UserService {
|
||||||
logger.debug("User authentication : " + authentication);
|
logger.debug("User authentication : " + authentication);
|
||||||
Map<String,Object> body = new HashMap<>();
|
Map<String,Object> body = new HashMap<>();
|
||||||
body.put("sub",authentication.getSub());
|
body.put("sub",authentication.getSub());
|
||||||
|
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
||||||
UserInfo userInfo = authentication.getUserInfo();
|
body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
|
||||||
String userName = userInfo.getName();
|
|
||||||
|
|
||||||
if ( userName == null || userName.isEmpty() )
|
|
||||||
body.put("name", userInfo.getGivenName() + " " + userInfo.getFamilyName());
|
|
||||||
else
|
else
|
||||||
body.put("name", userName);
|
body.put("name",authentication.getUserInfo().getName());
|
||||||
|
|
||||||
body.put("email",userInfo.getEmail());
|
body.put("email",authentication.getUserInfo().getEmail());
|
||||||
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||||
body.put("role",roles);
|
body.put("role",roles);
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,8 @@ import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
@ -40,8 +39,4 @@ public interface ValidatorService {
|
||||||
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
|
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
|
||||||
|
|
||||||
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,30 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
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.RuleSet;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.shared.Constants;
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||||
import gr.uoa.di.driver.util.ServiceLocator;
|
import gr.uoa.di.driver.util.ServiceLocator;
|
||||||
import org.eurocris.openaire.cris.validator.model.Job;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.eurocris.openaire.cris.validator.service.JobExecutor;
|
import org.apache.log4j.Logger;
|
||||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
|
||||||
import org.json.JSONException;
|
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.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Service("validatorService")
|
@Service("validatorService")
|
||||||
|
@ -37,9 +34,6 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorServiceImpl monitorApi;
|
private MonitorServiceImpl monitorApi;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RepositoryService repositoryService;
|
|
||||||
|
|
||||||
@Resource(name = "validatorServiceLocator")
|
@Resource(name = "validatorServiceLocator")
|
||||||
private ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator;
|
private ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator;
|
||||||
|
|
||||||
|
@ -55,28 +49,14 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
this.validatorServiceLocator = validatorServiceLocator;
|
this.validatorServiceLocator = validatorServiceLocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ValidatorServiceImpl.class);
|
private static final Logger logger = Logger
|
||||||
|
.getLogger(ValidatorServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmailUtils emailUtils;
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JobExecutor crisValidatorExecutor;
|
|
||||||
|
|
||||||
@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
|
@PostConstruct
|
||||||
private void loadRules(){
|
private void loadRules(){
|
||||||
logger.debug("PostConstruct method! Load rules!");
|
logger.debug("PostConstruct method! Load rules!");
|
||||||
|
@ -84,15 +64,12 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||||
String key = "";
|
String key = "";
|
||||||
String guidelinesAcronym = ruleSet.getGuidelinesAcronym();
|
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
||||||
if ( OPENAIRE_DATA_REGEX.matcher(guidelinesAcronym).matches() )
|
|
||||||
key = Constants.VALIDATION_MODE_DATA;
|
key = Constants.VALIDATION_MODE_DATA;
|
||||||
else if ( OPENAIRE_OR_DRIVER_REGEX.matcher(guidelinesAcronym).matches() )
|
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
||||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||||
else if ( OPENAIRE_CRIS_REGEX.matcher(guidelinesAcronym).matches() )
|
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
||||||
key = Constants.VALIDATION_MODE_CRIS;
|
key = Constants.VALIDATION_MODE_CRIS;
|
||||||
else if ( FAIR_REGEX.matcher(guidelinesAcronym).matches() )
|
|
||||||
key = Constants.VALIDATION_MODE_FAIR;
|
|
||||||
|
|
||||||
if (rulesetMap.containsKey(key))
|
if (rulesetMap.containsKey(key))
|
||||||
rulesetMap.get(key).add(ruleSet);
|
rulesetMap.get(key).add(ruleSet);
|
||||||
|
@ -103,88 +80,46 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int ruleId = -1000;
|
|
||||||
Rule rule = new Rule();
|
|
||||||
rule.setType("cris");
|
|
||||||
rule.setName("CRIS Rules");
|
|
||||||
rule.setId(ruleId);
|
|
||||||
rule.setMandatory(true);
|
|
||||||
RuleSet crisRuleSet = new RuleSet();
|
|
||||||
crisRuleSet.setContentRulesIds(Collections.singleton(ruleId));
|
|
||||||
crisRuleSet.setContentRules(Collections.singletonList(rule));
|
|
||||||
crisRuleSet.setUsageRulesIds(Collections.singleton(ruleId));
|
|
||||||
crisRuleSet.setUsageRules(Collections.singletonList(rule));
|
|
||||||
crisRuleSet.setId(-1);
|
|
||||||
crisRuleSet.setDescription("Validates using the CRIS Validator implementation");
|
|
||||||
crisRuleSet.setName("CRIS Validation");
|
|
||||||
|
|
||||||
String crisKey = Constants.VALIDATION_MODE_CRIS;
|
|
||||||
if (rulesetMap.containsKey(crisKey))
|
|
||||||
rulesetMap.get(crisKey).add(crisRuleSet);
|
|
||||||
else {
|
|
||||||
List<RuleSet> ruleSets = new ArrayList<RuleSet>();
|
|
||||||
ruleSets.add(crisRuleSet);
|
|
||||||
rulesetMap.put(crisKey, ruleSets);
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (ValidatorServiceException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error("Exception on loadRules" , e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||||
public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException {
|
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);
|
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.getDesiredCompatibilityLevel().equals("openaire-cris_1.1")) {
|
|
||||||
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
|
||||||
} else {
|
|
||||||
this.getValidationService().submitValidationJob(jobForValidation);
|
this.getValidationService().submitValidationJob(jobForValidation);
|
||||||
|
} catch (ValidatorServiceException e) {
|
||||||
|
logger.debug("Exception on submitJobForValidation" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Exception on submitJobForValidation", e);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// this.getValidationService().submitValidationJob(jobForValidation);
|
|
||||||
} catch (Exception e) { // FIXME: replaced exception with log
|
|
||||||
// throw new ValidatorServiceException(e);
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jobForValidation;
|
return jobForValidation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||||
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
||||||
String jobId) throws JSONException, ValidatorServiceException {
|
String jobId) throws ValidatorServiceException {
|
||||||
logger.debug("Resubmit validation job with id : {}", jobId);
|
logger.debug("Resubmit validation job with id : " + jobId);
|
||||||
StoredJob job = monitorApi.getJobSummary(jobId,"all");
|
StoredJob job = monitorApi.getJobSummary(jobId,"all");
|
||||||
Set<Integer> contentRules = new HashSet<Integer>();
|
Set<Integer> contentRules = new HashSet<Integer>();
|
||||||
Set<Integer> usageRules = new HashSet<Integer>();
|
Set<Integer> usageRules = new HashSet<Integer>();
|
||||||
|
|
||||||
RuleSet ruleSet = null;
|
RuleSet ruleSet = null;
|
||||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||||
for (RuleSet rSet : ruleSets) {
|
for (RuleSet rSet : ruleSets)
|
||||||
if (rSet.getName().equalsIgnoreCase("CRIS Validation")) {
|
if (rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) {
|
||||||
crisValidatorExecutor.submit(job.getBaseUrl(), job.getUserEmail());
|
|
||||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
|
||||||
} else if(rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())){
|
|
||||||
ruleSet = rSet;
|
ruleSet = rSet;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if( ruleSet != null) {
|
if( ruleSet != null) {
|
||||||
for (int ruleId : job.getRules()) {
|
for (int ruleId : job.getRules()) {
|
||||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||||
|
@ -203,79 +138,65 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RuleSet> getRuleSets(String mode) {
|
public List<RuleSet> getRuleSets(String mode) {
|
||||||
logger.info("Getting ruleSets for mode: {}", mode);
|
logger.info("Getting rulesets for mode: " + mode);
|
||||||
return rulesetMap.get(mode);
|
return rulesetMap.get(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSetsOfRepository(String url) {
|
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 {
|
try {
|
||||||
sets = OaiTools.getSetsOfRepo(url);
|
return OaiTools.getSetsOfRepo(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception on getSetsOfRepository", e);
|
logger.debug("Exception on getSetsOfRepository" , e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
}
|
}
|
||||||
return sets; // It may be null.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean identifyRepo(String url) {
|
public boolean identifyRepo(String url) {
|
||||||
logger.debug("Identify repository with url : {}", url);
|
logger.debug("Identify repository with url : " + url);
|
||||||
try {
|
try {
|
||||||
return OaiTools.identifyRepository(url);
|
return OaiTools.identifyRepository(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error while identifying repository with url: " + url, e);
|
logger.error("Error while identifying repository with url: " + url, e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RuleSet getRuleSet( String acronym) {
|
public RuleSet getRuleSet( String acronym) {
|
||||||
logger.debug("Getting ruleset with acronym : {}", acronym);
|
logger.debug("Getting ruleset with acronym : " + acronym);
|
||||||
RuleSet ruleSet = null;
|
RuleSet ruleSet = null;
|
||||||
try {
|
try {
|
||||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||||
for ( RuleSet rSet : ruleSets ) {
|
for (RuleSet rSet : ruleSets)
|
||||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
||||||
ruleSet = rSet;
|
ruleSet = rSet;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ruleSet != null )
|
return ruleSet;
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ruleSet; // It may be null.
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error getting ruleset", e);
|
logger.error("Error getting ruleset", e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public List<StoredJob> getStoredJobsNew(String user,
|
public List<StoredJob> getStoredJobsNew(String user,
|
||||||
String jobType,
|
String jobType,
|
||||||
String offset,
|
String offset,
|
||||||
String limit,
|
String limit,
|
||||||
String dateFrom,
|
String dateFrom,
|
||||||
String dateTo,
|
String dateTo,
|
||||||
String validationStatus ) throws ValidatorServiceException {
|
String validationStatus
|
||||||
// return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
) throws ValidatorServiceException {
|
||||||
List<StoredJob> jobs = getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if (jobs == null) {
|
|
||||||
jobs = new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<Job> cj = crisJobs.getJobs(user);
|
|
||||||
for (Job job : cj) {
|
|
||||||
jobs.add(CrisValidatorUtils.convertJobToStoredJob(job));
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
return jobs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -286,7 +207,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Override
|
@Override
|
||||||
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
||||||
try {
|
try {
|
||||||
logger.debug("Getting interface information with url: {}", baseUrl);
|
logger.debug("Getting interface information with url: " + baseUrl);
|
||||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||||
if (interfaceInformation.isIdentified())
|
if (interfaceInformation.isIdentified())
|
||||||
|
@ -295,34 +216,10 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
return interfaceInformation;
|
return interfaceInformation;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error getting interface information with url: " + baseUrl, e);
|
logger.error("Error getting interface information with url: " + baseUrl, e);
|
||||||
|
emailUtils.reportException(e);
|
||||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,300 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.aai.registry;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface AaiRegistryService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1.1 Get CoPersonId List by authenticated user's Email
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Integer> getCoPersonIdsByEmail();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCoPersonIdByIdentifier();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 3.1 Get OpenAIRE cous with a specific name(or substring)
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getCous(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 3.2 Get all OpenAIRE cous
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getCous();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 4.1 Get a couId by name
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCouId(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 4.2 Get a couId by type.id with/without mapping type
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCouId(String type, String id, boolean communityMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 4.3 Get a couId by type.id with mapping type
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCouId(String type, String id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 5. Get User non admin roles
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getRoles(Integer coPersonId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 5.2 Get User non admin active roles
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getRoleId(Integer coPersonId, Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 7. Get User Groups
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getUserGroups(Integer coPersonId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 8. Get User Admin Group of a Cou
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonObject getUserAdminGroup(Integer coPersonId, Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 9. Get Groups of a Cou
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getCouGroups(Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 10. Get Admin Group of a Cou
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonObject getCouAdminGroup(Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 11. Get users of a group
|
|
||||||
*
|
|
||||||
* @param coGroupId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getGroupMembers(Integer coGroupId);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 12. Get Users' email of a Cou
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @param admin
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getUserEmailByCouId(Integer couId, boolean admin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 12.2 Get All Users that have a specific role // TODO: Keep or delete
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getUsersByCouId(Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 13. Get Users' names of a Cou
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @param admin
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getUserNamesByCouId(Integer couId, boolean admin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 14. Get Users' identifiers of a Cou
|
|
||||||
*
|
|
||||||
* @param couId
|
|
||||||
* @param admin
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JsonArray getUserIdByCouId(Integer couId, boolean admin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 15. Assign a member role to a User
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
*/
|
|
||||||
void assignMemberRole(Integer coPersonId, Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 16. Remove a member role from a User
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
void removeMemberRole(Integer coPersonId, Integer couId, Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 17. Create a new role
|
|
||||||
*
|
|
||||||
* @param role
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer createRole(Role role);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 18. Get User's email
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getUserEmail(Integer coPersonId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 19. Get User's names
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getUserNames(Integer coPersonId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 20. Get User's identifier
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getUserId(Integer coPersonId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 21. Assign an admin role to a User
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
*/
|
|
||||||
void assignAdminRole(Integer coPersonId, Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 22. Remove an admin role from a User
|
|
||||||
*
|
|
||||||
* @param coPersonId
|
|
||||||
* @param couId
|
|
||||||
*/
|
|
||||||
void removeAdminRole(Integer coPersonId, Integer couId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 23. Get a cou Names from couIds.
|
|
||||||
*
|
|
||||||
* @param couIds
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Map<Integer, String> getCouNames(List<Integer> couIds);
|
|
||||||
|
|
||||||
// TODO: add description
|
|
||||||
List<User> getUsers(Integer couId);
|
|
||||||
|
|
||||||
enum RoleStatus {
|
|
||||||
ACTIVE("Active"),
|
|
||||||
APPROVED("Approved"),
|
|
||||||
CONFIRMED("Confirmed"),
|
|
||||||
DECLINED("Declined"),
|
|
||||||
DELETED("Deleted"),
|
|
||||||
DENIED("Denied"),
|
|
||||||
DUPLICATE("Duplicate"),
|
|
||||||
EXPIRED("Expired"),
|
|
||||||
GRACE_PERIOD("GracePeriod"),
|
|
||||||
INVITED("Invited"),
|
|
||||||
PENDING("Pending"),
|
|
||||||
PENDING_APPROVAL("PendingApproval"),
|
|
||||||
PENDING_CONFIRMATION("PendingConfirmation"),
|
|
||||||
SUSPENDED("Suspended");
|
|
||||||
|
|
||||||
public final String status;
|
|
||||||
|
|
||||||
RoleStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,460 +0,0 @@
|
||||||
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 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.*;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class RegistryCalls implements AaiRegistryService {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
|
|
||||||
|
|
||||||
public final HttpUtils httpUtils;
|
|
||||||
public final RegistryUtils jsonUtils;
|
|
||||||
private final String coid;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
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) {
|
|
||||||
if (type.equals("organization")) {
|
|
||||||
type = "institution";
|
|
||||||
} else if (type.equals("ri") && communityMap) {
|
|
||||||
type = "community";
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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();
|
|
||||||
return getCoPersonIdsByEmail(email);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Get User info: An error occurred ", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Integer> getCoPersonIdsByEmail(String email) throws RestClientException {
|
|
||||||
List<Integer> coPersonIds = new ArrayList<>();
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
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();
|
|
||||||
for (int i = 0; i < coPeople.size(); i++) {
|
|
||||||
coPersonIds.add(coPeople.get(i).getAsJsonObject().get("Id").getAsInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return coPersonIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCoPersonIdByIdentifier() {
|
|
||||||
try {
|
|
||||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
|
||||||
String sub = authentication.getUserInfo().getSub();
|
|
||||||
return getCoPersonIdByIdentifier(sub);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Get User info: An error occurred ", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCoPersonIdByIdentifier(String sub) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
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) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
if (name != null) {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonArray getCous() {
|
|
||||||
return getCous(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCouId(String name) {
|
|
||||||
JsonArray cous = getCous(name);
|
|
||||||
for (JsonElement cou : cous) {
|
|
||||||
if (cou.getAsJsonObject().get("Name").getAsString().equalsIgnoreCase(name)) {
|
|
||||||
return cou.getAsJsonObject().get("Id").getAsInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCouId(String type, String id, boolean communityMap) {
|
|
||||||
return getCouId(mapType(type, communityMap) + "." + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCouId(String type, String id) {
|
|
||||||
return getCouId(type, id, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
|
||||||
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();
|
|
||||||
if (status != null) {
|
|
||||||
for (JsonElement role : roles) {
|
|
||||||
if (role.getAsJsonObject().get("Status").getAsString().equalsIgnoreCase(status.toString())) {
|
|
||||||
activeRoles.add(role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return activeRoles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getRoleId(Integer coPersonId, Integer couId) {
|
|
||||||
JsonArray roles = getRoles(coPersonId);
|
|
||||||
for (JsonElement role : roles) {
|
|
||||||
JsonObject object = role.getAsJsonObject();
|
|
||||||
if (object.get("CouId").getAsInt() == couId && !object.get("Status").getAsString().equals("Deleted")) {
|
|
||||||
return object.get("Id").getAsInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
JsonArray roles = (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
|
||||||
for (JsonElement role : roles) {
|
|
||||||
JsonObject object = role.getAsJsonObject();
|
|
||||||
if (object.get("CouId") != null && object.get("CouId").getAsInt() == couId) {
|
|
||||||
if (object.get("Name").getAsString().contains("admins")) {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonArray getCouGroups(Integer couId) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("couid", couId.toString());
|
|
||||||
JsonElement response = httpUtils.get("co_groups.json", params);
|
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonObject getCouAdminGroup(Integer couId) {
|
|
||||||
JsonArray groups = getCouGroups(couId);
|
|
||||||
for (JsonElement group : groups) {
|
|
||||||
if (group.getAsJsonObject().get("Name").getAsString().contains("admins")) {
|
|
||||||
return group.getAsJsonObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoGroupMembers").getAsJsonArray() : new JsonArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
params.put("couid", couId.toString());
|
|
||||||
if (admin) {
|
|
||||||
params.put("admin", "true");
|
|
||||||
}
|
|
||||||
JsonElement response = httpUtils.get("email_addresses.json", params);
|
|
||||||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("EmailAddresses").getAsJsonArray() : new JsonArray();
|
|
||||||
JsonArray emails = new JsonArray();
|
|
||||||
infos.forEach(info -> {
|
|
||||||
JsonObject user = new JsonObject();
|
|
||||||
boolean add = true;
|
|
||||||
String email = info.getAsJsonObject().get("Mail").getAsString();
|
|
||||||
for (JsonElement element : emails) {
|
|
||||||
if (element.getAsJsonObject().get("email").getAsString().equals(email)) {
|
|
||||||
add = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (add) {
|
|
||||||
user.addProperty("email", email);
|
|
||||||
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
|
||||||
emails.add(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return emails;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("CoPersonRoles").getAsJsonArray() : new JsonArray();
|
|
||||||
// JsonArray users = new JsonArray();
|
|
||||||
// infos.forEach(info -> {
|
|
||||||
// JsonObject user = new JsonObject();
|
|
||||||
// user.addProperty("email", info.getAsJsonObject().get("Mail").getAsString());
|
|
||||||
// user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
|
||||||
// emails.add(user);
|
|
||||||
// });
|
|
||||||
return infos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<User> getUsers(Integer couId) {
|
|
||||||
List<User> users = new ArrayList<>();
|
|
||||||
JsonArray infos = getUserEmailByCouId(couId, false);
|
|
||||||
|
|
||||||
infos.forEach(info -> {
|
|
||||||
JsonObject jsonInfo = info.getAsJsonObject();
|
|
||||||
|
|
||||||
User user = new User();
|
|
||||||
user.setEmail(jsonInfo.get("email").getAsString());
|
|
||||||
// TODO: should add firstname and lastname and sub of user
|
|
||||||
|
|
||||||
users.add(user);
|
|
||||||
});
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonArray getUserNamesByCouId(Integer couId, boolean admin) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("couid", couId.toString());
|
|
||||||
if (admin) {
|
|
||||||
params.put("admin", "true");
|
|
||||||
}
|
|
||||||
JsonElement response = httpUtils.get("names.json", params);
|
|
||||||
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", 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) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("couid", couId.toString());
|
|
||||||
if (admin) {
|
|
||||||
params.put("admin", "true");
|
|
||||||
}
|
|
||||||
JsonElement response = httpUtils.get("identifiers.json", params);
|
|
||||||
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", jsonInfo.get("Identifier").getAsString());
|
|
||||||
user.addProperty("memberSince", jsonInfo.get("Created").getAsString());
|
|
||||||
emails.add(user);
|
|
||||||
});
|
|
||||||
return emails;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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 + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("copersonid", coPersonId.toString());
|
|
||||||
JsonElement response = httpUtils.get("email_addresses.json", params);
|
|
||||||
JsonObject info = (response != null) ? response.getAsJsonObject().get("EmailAddresses").getAsJsonArray().get(0).getAsJsonObject() : null;
|
|
||||||
return (info != null) ? info.getAsJsonObject().get("Mail").getAsString() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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;
|
|
||||||
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) throws RestClientException {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("copersonid", coPersonId.toString());
|
|
||||||
JsonElement response = httpUtils.get("identifiers.json", params);
|
|
||||||
JsonObject info = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray().get(0).getAsJsonObject() : null;
|
|
||||||
return (info != null) ? info.getAsJsonObject().get("Identifier").getAsString() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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;
|
|
||||||
for (JsonElement admin : admins) {
|
|
||||||
if (admin.getAsJsonObject().get("Person").getAsJsonObject().get("Id").getAsInt() == coPersonId) {
|
|
||||||
id = admin.getAsJsonObject().get("Id").getAsInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (id != null) {
|
|
||||||
httpUtils.delete("co_group_members/" + id + ".json");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<Integer, String> getCouNames(List<Integer> couIds) {
|
|
||||||
Map<Integer, String> idNameMap = new HashMap<>();
|
|
||||||
for (Integer id : couIds) {
|
|
||||||
idNameMap.put(id, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonArray cous = getCous();
|
|
||||||
int count = 0;
|
|
||||||
int total = couIds.size();
|
|
||||||
for (JsonElement cou : cous) {
|
|
||||||
if (count < total) {
|
|
||||||
JsonObject jsonCou = cou.getAsJsonObject();
|
|
||||||
if (idNameMap.containsKey(jsonCou.get("Id").getAsInt())) {
|
|
||||||
idNameMap.put(jsonCou.get("Id").getAsInt(), jsonCou.get("Name").getAsString());
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return idNameMap;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
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.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.StandardCharsets;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class HttpUtils {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.registry.url}")
|
|
||||||
private String registryUrl;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.registry.username}")
|
|
||||||
private String user;
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.registry.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
public JsonElement post(String path, JsonObject body) throws RestClientException {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
HttpHeaders headers = createHeaders(user, password);
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
HttpEntity<String> request = new HttpEntity<>(body.toString(), headers);
|
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(registryUrl + path, HttpMethod.POST, request, String.class);
|
|
||||||
return getResponseEntityAsJsonElement(responseEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement put(String path, JsonObject body) throws RestClientException {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
HttpHeaders headers = createHeaders(user, password);
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
HttpEntity<String> request = new HttpEntity<>(body.toString(), headers);
|
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(registryUrl + path, HttpMethod.PUT, request, String.class);
|
|
||||||
return getResponseEntityAsJsonElement(responseEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement get(String path, Map<String, String> params) throws RestClientException {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
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) 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);
|
|
||||||
return getResponseEntityAsJsonElement(responseEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
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(StandardCharsets.US_ASCII));
|
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
|
||||||
set("Authorization", authHeader);
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
|
||||||
|
|
||||||
if (responseEntity == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
String responseBody = responseEntity.getBody();
|
|
||||||
if (responseBody != null) {
|
|
||||||
logger.trace(responseBody);
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new JsonParser().parse(responseBody);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn("Could not parse response body", e); // Will return null.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.aai.registry.utils;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
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 {
|
|
||||||
|
|
||||||
@Value("1.0")
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
@Value("2")
|
|
||||||
private String coid;
|
|
||||||
|
|
||||||
public JsonObject coPersonRoles(Integer coPersonId, Integer couId, String status) {
|
|
||||||
JsonObject role = new JsonObject();
|
|
||||||
JsonArray coPersonRoles = new JsonArray();
|
|
||||||
JsonObject coPersonRole = new JsonObject();
|
|
||||||
JsonObject person = new JsonObject();
|
|
||||||
person.addProperty("Type", "CO");
|
|
||||||
person.addProperty("Id", coPersonId.toString());
|
|
||||||
coPersonRole.addProperty("Version", version);
|
|
||||||
coPersonRole.add("Person", person);
|
|
||||||
coPersonRole.addProperty("CouId", couId.toString());
|
|
||||||
coPersonRole.addProperty("Affiliation", "member");
|
|
||||||
coPersonRole.addProperty("Title", "");
|
|
||||||
coPersonRole.addProperty("O", "Openaire");
|
|
||||||
coPersonRole.addProperty("Status", status);
|
|
||||||
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);
|
|
||||||
role.add("CoPersonRoles", coPersonRoles);
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonObject createNewCou(Role role) {
|
|
||||||
JsonObject cou = new JsonObject();
|
|
||||||
JsonArray cous = new JsonArray();
|
|
||||||
JsonObject newCou = new JsonObject();
|
|
||||||
newCou.addProperty("Version", version);
|
|
||||||
newCou.addProperty("CoId", coid);
|
|
||||||
newCou.addProperty("Name", role.getName());
|
|
||||||
newCou.addProperty("Description", role.getDescription());
|
|
||||||
cous.add(newCou);
|
|
||||||
cou.addProperty("RequestType", "Cous");
|
|
||||||
cou.addProperty("Version", version);
|
|
||||||
cou.add("Cous", cous);
|
|
||||||
return cou;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonObject coGroupMembers(Integer coGroupId, Integer coPersonId, boolean member) {
|
|
||||||
JsonObject coGroup = new JsonObject();
|
|
||||||
JsonArray coGroupMembers = new JsonArray();
|
|
||||||
JsonObject coGroupMember = new JsonObject();
|
|
||||||
JsonObject person = new JsonObject();
|
|
||||||
person.addProperty("Type", "CO");
|
|
||||||
person.addProperty("Id", coPersonId.toString());
|
|
||||||
coGroupMember.addProperty("Version", version);
|
|
||||||
coGroupMember.add("Person", person);
|
|
||||||
coGroupMember.addProperty("CoGroupId", coGroupId.toString());
|
|
||||||
coGroupMember.addProperty("Member", member);
|
|
||||||
coGroupMember.addProperty("Owner", false);
|
|
||||||
coGroupMember.addProperty("ValidFrom", "");
|
|
||||||
coGroupMember.addProperty("ValidThrough", "");
|
|
||||||
coGroupMembers.add(coGroupMember);
|
|
||||||
coGroup.addProperty("RequestType", "CoGroupMembers");
|
|
||||||
coGroup.addProperty("Version", version);
|
|
||||||
coGroup.add("CoGroupMembers", coGroupMembers);
|
|
||||||
return coGroup;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue