Compare commits
1 Commits
master
...
piwikSiteI
Author | SHA1 | Date |
---|---|---|
Ioannis Diplas | 9e1de969bf |
|
@ -1,4 +0,0 @@
|
|||
# Ignore directories
|
||||
.idea
|
||||
target
|
||||
|
12
Dockerfile
12
Dockerfile
|
@ -1,12 +0,0 @@
|
|||
#FROM tomcat:7.0.90-jre8
|
||||
FROM tomcat:8.5.71-jre8-openjdk-bullseye
|
||||
MAINTAINER "pkanakakis@di.uoa.gr"
|
||||
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
|
||||
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
|
||||
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
|
||||
COPY validator.env /usr/local/tomcat/lib/dnet-override.properties
|
||||
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
|
||||
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
|
||||
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
|
||||
CMD ["catalina.sh", "run"]
|
||||
|
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
|
|
@ -0,0 +1,55 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
|
||||
* override the previous. It also supports property expansion like:
|
||||
*
|
||||
* <code>
|
||||
* something = 1
|
||||
* somethingelse = 2
|
||||
* test = ${something}/${somethingelse}
|
||||
* </code>
|
||||
*
|
||||
* <p>
|
||||
* And if you override something to XX, then test will become XX/2
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author marko
|
||||
*
|
||||
*/
|
||||
public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
|
||||
|
||||
private Properties properties;
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.properties = mergeProperties();
|
||||
|
||||
// Convert the merged properties, if necessary.
|
||||
convertProperties(this.properties);
|
||||
|
||||
logger.debug("Properties: " + properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processProperties(final ConfigurableListableBeanFactory beanFactoryToProcess, final Properties props) throws BeansException {
|
||||
super.processProperties(beanFactoryToProcess, props);
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(final Properties properties) {
|
||||
super.setProperties(properties);
|
||||
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||
import org.springframework.session.web.http.CookieSerializer;
|
||||
import org.springframework.session.web.http.DefaultCookieSerializer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Configuration
|
||||
@EnableRedisHttpSession
|
||||
@EnableAspectJAutoProxy
|
||||
@EnableCircuitBreaker
|
||||
@PropertySource(value = {"classpath:application.properties"} )
|
||||
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
|
||||
public class Config {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Config.class);
|
||||
|
||||
@Value("${redis.host:194.177.192.121}")
|
||||
private String host;
|
||||
|
||||
@Value("${redis.port:6379}")
|
||||
private String port;
|
||||
|
||||
@Value("${redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
|
||||
@PostConstruct
|
||||
private void init(){
|
||||
LOGGER.info(host);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JedisConnectionFactory connectionFactory() {
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
||||
jedisConnectionFactory.setHostName(host);
|
||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
||||
if(password != null) jedisConnectionFactory.setPassword(password);
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CookieSerializer cookieSerializer() {
|
||||
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
||||
serializer.setCookieName("openAIRESession");
|
||||
serializer.setCookiePath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
serializer.setDomainName(".openaire.eu");
|
||||
// serializer.setDomainName(".athenarc.gr");
|
||||
LOGGER.info("Serializer : " + serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.set("Content-Type", "application/json");
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import com.google.gson.*;
|
||||
|
||||
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||
|
||||
private String frontEndURI;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
||||
|
||||
public void init(){
|
||||
LOGGER.debug("Front end uri : " + frontEndURI);
|
||||
}
|
||||
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
|
||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||
JsonObject userInfo = new JsonObject();
|
||||
|
||||
if (authOIDC.getUserInfo().getSub() == null)
|
||||
userInfo.addProperty("sub", "");
|
||||
else
|
||||
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
|
||||
|
||||
|
||||
if(authOIDC.getUserInfo().getName() != null)
|
||||
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
|
||||
|
||||
if (authOIDC.getUserInfo().getGivenName() == null)
|
||||
userInfo.addProperty("firstname", "");
|
||||
else
|
||||
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
||||
|
||||
if (authOIDC.getUserInfo().getFamilyName() == null)
|
||||
userInfo.addProperty("lastname", "");
|
||||
else
|
||||
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
||||
|
||||
userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
|
||||
if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
|
||||
userInfo.addProperty("role", "");
|
||||
else
|
||||
userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
|
||||
.getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||
|
||||
|
||||
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
|
||||
openAIREUser.setMaxAge(14400);
|
||||
openAIREUser.setPath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
openAIREUser .setDomain(".openaire.eu");
|
||||
// openAIREUser.setDomain(".athenarc.gr");
|
||||
response.addCookie(openAIREUser);
|
||||
|
||||
|
||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||
accessToken.setMaxAge(14400);
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
accessToken.setDomain(".openaire.eu");
|
||||
accessToken.setPath("/");
|
||||
|
||||
// accessToken.setDomain(".athenarc.gr");
|
||||
response.addCookie(accessToken);
|
||||
response.sendRedirect(frontEndURI);
|
||||
}
|
||||
|
||||
public String getFrontEndURI() {
|
||||
return frontEndURI;
|
||||
}
|
||||
|
||||
public void setFrontEndURI(String frontEndURI) {
|
||||
this.frontEndURI = frontEndURI;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
final private static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||
|
||||
private Map<String,SimpleGrantedAuthority> userRolesMap;
|
||||
|
||||
OpenAireProviderAuthoritiesMapper(Map<String,String> userRoles) {
|
||||
userRolesMap = new HashMap<>();
|
||||
userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
|
||||
Set<GrantedAuthority> out = new HashSet<>();
|
||||
out.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
|
||||
if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
|
||||
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
|
||||
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
|
||||
if (authority != null) {
|
||||
logger.debug("Role mapped " + role);
|
||||
out.add(authority);
|
||||
}
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.util.Properties;
|
||||
|
||||
public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
||||
private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
|
||||
|
||||
|
||||
public RepoManagerContextLoaderListener() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RepoManagerContextLoaderListener(WebApplicationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebApplicationContext createWebApplicationContext(
|
||||
ServletContext servletContext)
|
||||
throws BeansException {
|
||||
logger.debug("Creating web application context");
|
||||
Properties props = this.loadProperties();
|
||||
String repoMode = props.getProperty("services.validator.mode.repo");
|
||||
String userMode = props.getProperty("services.validator.mode.user");
|
||||
Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
|
||||
|
||||
logger.info("User mode: " + userMode);
|
||||
logger.info("Repo mode: " + repoMode);
|
||||
logger.info("Standalone mode: " + standaloneMode);
|
||||
// logger.info("Dnet workflow enabled: " + repoMode);
|
||||
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
|
||||
|
||||
ctx.setServletContext(servletContext);
|
||||
|
||||
String userApiContext = null;
|
||||
if (userMode.equalsIgnoreCase("local"))
|
||||
userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
|
||||
else if (userMode.equalsIgnoreCase("ldap"))
|
||||
userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
|
||||
|
||||
String[] springContextCore = new String[] {
|
||||
"classpath:META-INF/cxf/cxf.xml",
|
||||
"classpath:META-INF/cxf/cxf-extension-soap.xml",
|
||||
"classpath:META-INF/cxf/cxf-extension-jaxws.xml",
|
||||
"classpath:META-INF/cxf/cxf-servlet.xml",
|
||||
"classpath*:/cxf.xml",
|
||||
"classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
|
||||
"classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
|
||||
"classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-struts.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-emailer.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/config/springContext-validator.xml",
|
||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/commons/dao/springContext-*.xml",
|
||||
"classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
|
||||
"classpath*:/" + userApiContext
|
||||
};
|
||||
|
||||
|
||||
String[] springContextForStandalone = new String[] {
|
||||
};
|
||||
|
||||
String[] springContextForIS = new String[] {
|
||||
"classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
|
||||
"classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
|
||||
};
|
||||
|
||||
if (standaloneMode) {
|
||||
logger.debug("Loading contexts for standalone mode");
|
||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
|
||||
} else {
|
||||
logger.debug("Loading contexts for dnet");
|
||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
|
||||
}
|
||||
|
||||
ctx.refresh();
|
||||
|
||||
logger.debug("done");
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
private Properties loadProperties() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
|
||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
|
||||
});
|
||||
|
||||
CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
|
||||
Properties props = pLoader.getProperties();
|
||||
|
||||
ctx.destroy();
|
||||
ctx.close();
|
||||
return props;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.json.JSONException;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,29 +19,31 @@ import java.util.Map;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/broker")
|
||||
@Tag(name="broker", description="Broker API")
|
||||
@Api(description = "Broker API", tags = {"broker"})
|
||||
public class BrokerController{
|
||||
|
||||
@Autowired
|
||||
private BrokerServiceImpl brokerService;
|
||||
BrokerServiceImpl brokerService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public DatasourcesBroker getDatasourcesOfUser(
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
|
||||
@ApiParam(value = "User email", required = true) String user,
|
||||
@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")
|
||||
@Parameter(description = "Include datasources of other (default = false)", required = true) String includeByOthers) throws JSONException {
|
||||
return brokerService.getDatasourcesOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), includeShared, includeByOthers);
|
||||
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
|
||||
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
|
||||
List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
|
||||
return brokerService.getTopicsForDatasource(datasourceName);
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ public class BrokerController{
|
|||
method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public EventsPage advancedShowEvents(@PathVariable("page") String page,
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
EventsPage advancedShowEvents(@PathVariable("page") String page,
|
||||
@PathVariable("size") String size,
|
||||
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
|
||||
return brokerService.advancedShowEvents(page, size, advQueryObject);
|
||||
|
@ -62,29 +62,29 @@ public class BrokerController{
|
|||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
||||
@RequestParam("topic") String topic,
|
||||
@RequestParam("page") String page,
|
||||
@RequestParam("size") String size) throws BrokerException, JSONException{
|
||||
return brokerService.showEvents(datasourceName, topic, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getSimpleSubscriptionsOfUser" ,
|
||||
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser() throws BrokerException{
|
||||
return brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
|
||||
return brokerService.getSimpleSubscriptionsOfUser(userEmail);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER') ")
|
||||
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
||||
@PreAuthorize("hasRole('ROLE_USER') ")
|
||||
Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
||||
return brokerService.subscribe(obj);
|
||||
}
|
||||
|
||||
|
@ -92,16 +92,16 @@ public class BrokerController{
|
|||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
return brokerService.unsubscribe(subscriptionId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
return brokerService.getSubscription(subscriptionId);
|
||||
}
|
||||
|
||||
|
@ -109,18 +109,26 @@ public class BrokerController{
|
|||
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, Term> getDnetTopics() throws BrokerException{
|
||||
Map<String, Term> getDnetTopics() throws BrokerException{
|
||||
return brokerService.getDnetTopics();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
||||
,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws BrokerException{
|
||||
return brokerService.getNotificationsBySubscriptionId(subscriptionId, page, size);
|
||||
}
|
||||
|
||||
/*@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
|
||||
,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody*/
|
||||
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException{
|
||||
return brokerService.getSubscriptionsOfUser(userEmail);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||
import eu.dnetlib.repo.manager.service.DashboardService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/dashboard")
|
||||
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||
public class DashboardController {
|
||||
|
||||
@Autowired
|
||||
DashboardService dashboardService;
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ServerError;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class GenericControllerAdvice {
|
||||
|
||||
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
@ResponseBody
|
||||
ServerError securityException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseBody
|
||||
ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(UnknownHostException.class)
|
||||
@ResponseBody
|
||||
ServerError unknownHostException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class})
|
||||
@ResponseBody
|
||||
ServerError internalException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
||||
@ExceptionHandler(EndPointException.class)
|
||||
@ResponseBody
|
||||
ServerError endPointException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/monitor")
|
||||
@Api(description = "Monitor API", tags = {"monitor"})
|
||||
public class MonitorController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorController.class);
|
||||
|
||||
@Autowired
|
||||
MonitorServiceImpl monitorService;
|
||||
|
||||
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam(value = "jobType", required = false)
|
||||
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus,
|
||||
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
|
||||
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
||||
@RequestBody String jobType,
|
||||
@RequestBody String validationStatus) throws JSONException {
|
||||
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public StoredJob getJobSummary(@RequestParam String jobId,
|
||||
@RequestParam String groupBy) throws JSONException {
|
||||
return monitorService.getJobSummary(jobId, groupBy);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
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 = "/piwik")
|
||||
@Api(description = "Piwik API", tags = {"piwik"})
|
||||
public class PiWikController {
|
||||
|
||||
@Autowired
|
||||
PiWikServiceImpl piWikService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
||||
return piWikService.getPiwikSiteForRepo(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') " +
|
||||
"and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
||||
return piWikService.savePiwikInfo(piwikInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<PiwikInfo> getPiwikSitesForRepos(){
|
||||
return piWikService.getPiwikSitesForRepos();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
|
||||
return piWikService.approvePiwikSite(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
String getOpenaireId(String repositoryid){
|
||||
return piWikService.getOpenaireId(repositoryid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
||||
return piWikService.markPiwikSiteAsValidated(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
|
||||
@RequestParam("repoWebsite") String repoWebsite,
|
||||
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
return piWikService.enableMetricsForRepository(officialName, repoWebsite, piwikInfo);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/repository")
|
||||
@Api(description = "Repository API", tags = {"repository"})
|
||||
public class RepositoryController {
|
||||
|
||||
@Autowired
|
||||
RepositoryServiceImpl repositoryService;
|
||||
|
||||
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Country[] getCountries() {
|
||||
return repositoryService.getCountries();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesByCountry/{country}/{mode}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||
@PathVariable("mode") String mode,
|
||||
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
||||
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name="country", required=false) String country,
|
||||
@RequestParam(name="typology", required=false) String typology,
|
||||
@RequestParam(name="englishName", required=false) String englishName,
|
||||
@RequestParam(name="officialName", required=false) String officialName,
|
||||
@RequestParam("requestSortBy") String requestSortBy,
|
||||
@RequestParam("order") String order,
|
||||
@PathVariable("page") int page,
|
||||
@PathVariable("size") int pageSize) throws Exception {
|
||||
|
||||
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
||||
return repositoryService.getRepositoryById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryAggregations(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryAggregationsByYear(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getRepositoriesByName(name, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryInterface(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
// @PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||
@RequestBody Repository repository) throws Exception {
|
||||
|
||||
return repositoryService.addRepository(datatype, repository);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
List<String> getDnetCountries(){
|
||||
return repositoryService.getDnetCountries();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
List<String> getTypologies(){
|
||||
return repositoryService.getTypologies();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
List<Timezone> getTimezones(){
|
||||
return repositoryService.getTimezones();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||
return repositoryService.updateRepository(repository, authentication);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
||||
@RequestParam("registeredBy") String registeredBy){
|
||||
repositoryService.deleteRepositoryInterface(id, registeredBy);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
||||
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getUrlsOfUserRepos(userEmail, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getDatasourceVocabularies(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
|
||||
|
||||
return repositoryService.getCompatibilityClasses(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getDatasourceClasses(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
||||
return repositoryService.getMetricsInfoForRepository(repoId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||
return repositoryService.getListLatestUpdate(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.utils;
|
||||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -16,17 +16,19 @@ public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
|||
|
||||
@Override
|
||||
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
||||
HttpStatus.Series seriesError = httpResponse.getStatusCode().series();
|
||||
return ( (seriesError == CLIENT_ERROR) || (seriesError == SERVER_ERROR) );
|
||||
return (httpResponse.getStatusCode().series() == CLIENT_ERROR
|
||||
|| httpResponse.getStatusCode().series() == SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
||||
|
||||
HttpStatus statusCode = httpResponse.getStatusCode();
|
||||
if ( statusCode == HttpStatus.NOT_FOUND )
|
||||
throw new IOException();
|
||||
else if (statusCode.series() == SERVER_ERROR)
|
||||
if (httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) {
|
||||
throw new EndPointException();
|
||||
} else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) {
|
||||
if (httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
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.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -13,15 +14,16 @@ import java.util.Map;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/stats")
|
||||
@Tag(name="statistics", description = "Stats API")
|
||||
@Api(description = "Stats API", tags = {"statistics"})
|
||||
public class StatsController {
|
||||
|
||||
@Autowired
|
||||
private StatsServiceImpl statsService;
|
||||
StatsServiceImpl statsService;
|
||||
|
||||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map getStatistics(){
|
||||
public Map getStatistics() throws JSONException {
|
||||
return statsService.getStatistics();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
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 io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -10,15 +10,16 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/sushilite")
|
||||
@Tag(name="sushilite", description = "Sushi-Lite API")
|
||||
@Api(description = "Sushi-Lite API", tags = {"sushilite"})
|
||||
public class SushiliteController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SushiliteServiceImpl sushiliteService;
|
||||
SushiliteServiceImpl sushiliteService;
|
||||
|
||||
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
|
||||
@PathVariable("pageSize") String pageSize,
|
||||
@RequestParam(value = "Report") String Report,
|
|
@ -1,7 +1,7 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
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.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -11,14 +11,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
@Tag(name="user", description = "User API")
|
||||
@Api(description = "User API", tags = {"user"})
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
UserServiceImpl userService;
|
||||
|
||||
@RequestMapping(value = "/login" , method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ResponseEntity<Object> login() {
|
||||
return userService.login();
|
||||
}
|
|
@ -1,55 +1,50 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.service.EmailUtils;
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.json.JSONException;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/validator")
|
||||
@Tag(name="validator", description = "Validator API")
|
||||
@Api(description = "Validator API", tags = {"validator"})
|
||||
public class ValidatorController {
|
||||
|
||||
@Autowired
|
||||
private ValidatorServiceImpl validatorService;
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
ValidatorServiceImpl validatorService;
|
||||
|
||||
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@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 {
|
||||
return validatorService.submitJobForValidation(jobForValidation);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/reSubmitJobForValidation/{jobId}",method = RequestMethod.POST,
|
||||
@RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||
return validatorService.reSubmitJobForValidation(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), jobId);
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
||||
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||
return validatorService.reSubmitJobForValidation(email, jobId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
@ -78,16 +73,17 @@ public class ValidatorController {
|
|||
|
||||
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(@RequestParam(value = "jobType", required = false)
|
||||
@Parameter(description = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @Parameter(description = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @Parameter(description = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @Parameter(description = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @Parameter(description = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @Parameter(description = "Equals to filter validation jobs", required = true) String validationStatus
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam(value = "jobType", required = false)
|
||||
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
||||
) 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)
|
||||
|
@ -98,31 +94,9 @@ public class ValidatorController {
|
|||
|
||||
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
|
||||
return validatorService.getInterfaceInformation(baseUrl);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<StoredJob> getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException {
|
||||
return validatorService.getJobsSummary(repoId,size);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public void validationCompleted(
|
||||
@RequestParam(value = "repoId") String repoId,
|
||||
@RequestParam(value = "interfaceId") String interfaceId,
|
||||
@RequestParam(value = "jobId") String jobId,
|
||||
@RequestParam(value = "issuerEmail") String issuerEmail,
|
||||
@RequestParam(value = "isUpdate") boolean isUpdate,
|
||||
@RequestParam(value = "isSuccess") boolean isSuccess,
|
||||
@RequestParam(value = "scoreUsage") int scoreUsage,
|
||||
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
||||
|
||||
validatorService.onComplete(repoId, interfaceId, jobId, issuerEmail, isUpdate, isSuccess, scoreUsage, scoreContent);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class Organization{
|
||||
public class Organization implements Serializable {
|
||||
private String country;
|
||||
private String legalname;
|
||||
private String websiteurl;
|
|
@ -0,0 +1,81 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class RepositorySnippet implements IsSerializable {
|
||||
|
||||
private String id;
|
||||
private String officialname;
|
||||
private String englishname;
|
||||
private String websiteurl;
|
||||
private String typology;
|
||||
private String registeredby;
|
||||
private Organization[] organizations;
|
||||
private String registrationdate;
|
||||
|
||||
public RepositorySnippet() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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 getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
||||
|
||||
public void setRegisteredby(String registeredby) {
|
||||
this.registeredby = registeredby;
|
||||
}
|
||||
|
||||
public String getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
public void setTypology(String typology) {
|
||||
this.typology = typology;
|
||||
}
|
||||
|
||||
public Organization[] getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
||||
public void setOrganizations(Organization[] organizations) {
|
||||
this.organizations = organizations;
|
||||
}
|
||||
|
||||
public String getRegistrationdate() {
|
||||
return registrationdate;
|
||||
}
|
||||
|
||||
public void setRegistrationdate(String registrationdate) {
|
||||
this.registrationdate = registrationdate;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class RepositorySummaryInfo{
|
||||
public class RepositorySummaryInfo implements IsSerializable {
|
||||
|
||||
String id;
|
||||
String repositoryName;
|
|
@ -7,7 +7,6 @@ public class RequestFilter{
|
|||
|
||||
private String registeredby = null;
|
||||
private String typology = null;
|
||||
private String eoscDatasourceType = null;
|
||||
private String country = null;
|
||||
private String id = null;
|
||||
private String officialname = null;
|
||||
|
@ -29,14 +28,6 @@ public class RequestFilter{
|
|||
this.typology = typology;
|
||||
}
|
||||
|
||||
public String getEoscDatasourceType() {
|
||||
return eoscDatasourceType;
|
||||
}
|
||||
|
||||
public void setEoscDatasourceType(String eoscDatasourceType) {
|
||||
this.eoscDatasourceType = eoscDatasourceType;
|
||||
}
|
||||
|
||||
public String getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
|
@ -9,10 +9,6 @@ public class ResourceNotFoundException extends Exception {
|
|||
super("Resource Not Found");
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String id, String resourceType) {
|
||||
super(resourceType + " with id " + id + " was not found");
|
||||
}
|
|
@ -1,10 +1,16 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
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.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.MediaType;
|
||||
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.util.List;
|
||||
|
@ -28,8 +34,6 @@ public interface BrokerService {
|
|||
|
||||
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;
|
||||
|
||||
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
|
|
@ -2,20 +2,20 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
|
@ -24,33 +24,33 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service("brokerService")
|
||||
public class BrokerServiceImpl implements BrokerService {
|
||||
|
||||
@Autowired
|
||||
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;
|
||||
@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;
|
||||
@Value("${services.provide.topic_types.url}")
|
||||
@Value("${topic_types.url}")
|
||||
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
|
||||
RestTemplate restTemplate;
|
||||
RestTemplate restTemplate ;
|
||||
|
||||
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
|
||||
private void initDnetTopicsMap() {
|
||||
|
@ -58,43 +58,46 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.set("Content-Type", "application/json");
|
||||
|
||||
logger.debug("Init dnet topics!");
|
||||
try (InputStream is = new URL(topicsURL).openStream()) {
|
||||
LOGGER.debug("Init dnet topics!");
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new URL(topicsURL).openStream();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(is);
|
||||
for (JsonNode term : root.path("terms"))
|
||||
for (JsonNode term : root.path("terms") )
|
||||
topics.put(term.path("code").textValue(), parseTerm(term));
|
||||
} catch (IOException e) {
|
||||
logger.error("Exception on initDnetTopicsMap", e);
|
||||
LOGGER.debug("Exception on initDnetTopicsMap" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Term parseTerm(JsonNode term) {
|
||||
return new Term(term.path("englishName").textValue(), term.path("nativeName").textValue(),
|
||||
term.path("encoding").textValue(), term.path("code").textValue());
|
||||
return new Term(term.path("englishName").textValue(),term.path("nativeName").textValue(),
|
||||
term.path("encoding").textValue(),term.path("code").textValue());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) {
|
||||
long start = System.currentTimeMillis();
|
||||
public DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws JSONException {
|
||||
|
||||
DatasourcesBroker ret = new DatasourcesBroker();
|
||||
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)) {
|
||||
// List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||
// ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||
// }
|
||||
if (Boolean.parseBoolean(includeShared)) {
|
||||
List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||
}
|
||||
|
||||
// if (Boolean.parseBoolean(includeByOthers)) {
|
||||
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception on getDatasourcesOfUser", e);
|
||||
if (Boolean.parseBoolean(includeByOthers)) {
|
||||
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
}
|
||||
} catch (BrokerException e) {
|
||||
LOGGER.debug("Exception on getDatasourcesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
logger.debug("Getting datasources of user in " + (end - start) + "ms");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -114,7 +117,8 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on getTopicsForDatasource" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
|
@ -124,19 +128,18 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
@Override
|
||||
public EventsPage advancedShowEvents(String page,
|
||||
String size,
|
||||
AdvQueryObject advQueryObject) throws BrokerException {
|
||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException {
|
||||
|
||||
final String service = "/events/{page}/{pageSize}";
|
||||
|
||||
long pageNum = Long.parseLong(page);
|
||||
advQueryObject.setPage(pageNum);
|
||||
|
||||
Map<String, Long> uriParams = new HashMap<>();
|
||||
uriParams.put("page", pageNum);
|
||||
uriParams.put("page", Long.parseLong(page));
|
||||
uriParams.put("pageSize", Long.parseLong(size));
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
advQueryObject.setPage(Long.parseLong(page));
|
||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
|
@ -144,24 +147,28 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
new ParameterizedTypeReference<EventsPage>() {}
|
||||
new ParameterizedTypeReference<EventsPage>() {
|
||||
}
|
||||
);
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on advancedShowEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<RepositorySnippet> repositories) throws BrokerException {
|
||||
long start = System.currentTimeMillis();
|
||||
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException {
|
||||
|
||||
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>();
|
||||
for (RepositorySnippet repo : repositories) {
|
||||
for (Repository repo : repositories) {
|
||||
BrowseEntry temp = new BrowseEntry();
|
||||
temp.setValue(repo.getOfficialname());
|
||||
temp.setSize(0L);
|
||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
||||
temp.setValue(repo.getOfficialName());
|
||||
temp.setSize(new Long(0));
|
||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) {
|
||||
temp.setSize(temp.getSize() + e.getSize());
|
||||
}
|
||||
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl());
|
||||
|
@ -169,17 +176,41 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
|
||||
// sort the collection by the second field of the tuple which is size
|
||||
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||
long stop = System.currentTimeMillis();
|
||||
logger.debug("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
||||
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() {
|
||||
@Override
|
||||
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) {
|
||||
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue());
|
||||
}
|
||||
});
|
||||
|
||||
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 null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventsPage showEvents(String datasourceName,
|
||||
String topic,
|
||||
String page,
|
||||
String size) throws BrokerException {
|
||||
String size) throws BrokerException, JSONException {
|
||||
|
||||
final String service = "/events";
|
||||
|
||||
|
@ -197,7 +228,8 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on showEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -209,31 +241,26 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
|
||||
final String service = "/subscriptions";
|
||||
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail).build().encode().toUri();
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail);
|
||||
|
||||
logger.debug("{}", uri);
|
||||
LOGGER.debug(builder.build().encode().toUri());
|
||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
uri,
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
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
|
||||
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException {
|
||||
final String service = "/subscribe";
|
||||
|
@ -256,7 +283,8 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on OpenaireSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
|
@ -279,14 +307,15 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on unsubscribe" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return new ResponseEntity<>("OK", HttpStatus.OK);
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription getSubscription(String subscriptionId) throws BrokerException {
|
||||
public Subscription getSubscription( String subscriptionId) throws BrokerException {
|
||||
final String service = "/subscriptions/" + subscriptionId;
|
||||
|
||||
//build the uri params
|
||||
|
@ -302,7 +331,8 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on getSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -321,7 +351,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(openairePath + "/notifications/")
|
||||
.path("/{id}/{page}/{size}/")
|
||||
.build().expand(subscriptionId, page, size).encode();
|
||||
.build().expand(subscriptionId,page, size).encode();
|
||||
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
|
@ -332,7 +362,8 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
logger.error(e.getMessage());
|
||||
LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
@ -343,16 +374,16 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
throws BrokerException {
|
||||
|
||||
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);
|
||||
Map<String, List<Subscription>> subs = new HashMap<>();
|
||||
Map<String,List<Subscription>> subs = new HashMap<>();
|
||||
List<Subscription> subscriptions = null;
|
||||
|
||||
for (String s : simpleSubs.keySet()) {
|
||||
for(String s:simpleSubs.keySet()){
|
||||
List<SimpleSubscriptionDesc> simpleSubscriptionDescs = simpleSubs.get(s);
|
||||
for (SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
|
||||
for(SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
|
||||
subscriptions = new ArrayList<>();
|
||||
subscriptions.add(getSubscription(simpleSubscriptionDesc.getId()));
|
||||
}
|
||||
subs.put(s, subscriptions);
|
||||
subs.put(s,subscriptions);
|
||||
}
|
||||
return subs;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import javax.xml.ws.ServiceMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service("dashboardService")
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private BrokerService brokerService;
|
||||
|
||||
@Override
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
|
||||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
List<Repository> repositoriesOfUser = repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||
for(Repository repository: repositoriesOfUser) {
|
||||
|
||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||
repositorySummaryInfo.setId(repository.getId());
|
||||
repositorySummaryInfo.setRepositoryName(repository.getOfficialName());
|
||||
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
||||
|
||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId());
|
||||
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||
if(aggregationDetails.getIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
||||
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||
|
||||
} catch (RepositoryServiceException e) {
|
||||
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialName());
|
||||
Long totalEvents = 0L;
|
||||
for(BrowseEntry browseEntry: events)
|
||||
totalEvents += browseEntry.getSize();
|
||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||
|
||||
|
||||
} catch (BrokerException e) {
|
||||
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
||||
}
|
||||
|
||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Something baad happened!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return repositorySummaryInfoList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public interface EmailUtils {
|
||||
|
||||
|
||||
void reportException(Exception exception);
|
||||
|
||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
||||
}
|
|
@ -0,0 +1,387 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.config.CascadingPropertyLoader;
|
||||
import eu.dnetlib.utils.MailLibrary;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component("emailUtils")
|
||||
public class EmailUtilsImpl implements EmailUtils {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
|
||||
|
||||
private List<String> specialRecipients = new ArrayList<String>();
|
||||
private boolean override = false, logonly = false;
|
||||
private String overrideEmail = null, from = null;
|
||||
|
||||
@Autowired
|
||||
private MailLibrary mailLibrary;
|
||||
|
||||
@Autowired
|
||||
private CascadingPropertyLoader pLoader;
|
||||
|
||||
@Value("${services.repo-manager.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${services.repo-manager.adminEmail}")
|
||||
private String adminEmail;
|
||||
|
||||
@Value("${services.repomanager.usagestats.adminEmail}")
|
||||
private String usageStatsAdminEmail;
|
||||
|
||||
@Value("${services.provide.adminEmail}")
|
||||
private String provideAdminEmail;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
System.out.println("url -> " + this.baseUrl);
|
||||
}
|
||||
|
||||
|
||||
@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
|
||||
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
||||
|
||||
String message = "Dear administrator,\n" +
|
||||
"\n" +
|
||||
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"For more information about this request, go here: \n" +
|
||||
this.baseUrl + "/admin/metrics\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
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
|
||||
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
||||
|
||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||
"\n" +
|
||||
"we have received your request to enable the OpenAIRE usage statistics for your repository\n" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " +
|
||||
"OpenAIRE's usage statistics service tracking code is maintained on Github as a patch for various versions of DSpace " +
|
||||
"(https://github.com/openaire/OpenAIRE-Piwik-DSpace) and as an Eprints plugin for version 3 " +
|
||||
"(https://github.com/openaire/EPrints-OAPiwik). In case the platform is different from DSpace or EPrints please contact " +
|
||||
"the OpenAIRE team in repositoryusagestats@openaire.eu in order to find a solution.\n" +
|
||||
"\n" +
|
||||
"For more information about your request and configuration details, go here: \n" +
|
||||
this.baseUrl + "/getImpact/instructions/" + piwikInfo.getRepositoryId() + "\n" +
|
||||
"\n" +
|
||||
"Once you have finished configuring your repository or if you have any questions, please notify the OpenAIRE team by sending \n" +
|
||||
"an email to repositoryusagestats@openaire.eu\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
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
|
||||
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||
|
||||
String message = "Dear administrator,\n" +
|
||||
"\n" +
|
||||
"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" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
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
|
||||
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||
|
||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||
"\n" +
|
||||
"The installation and configuration of OpenAIRE's tracking code for your repository \"" + piwikInfo.getRepositoryName() +
|
||||
"\" has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
||||
"\n" +
|
||||
"You can preview the statistics in your repository's dashboard: \n" +
|
||||
this.baseUrl + "/getImpact/" + piwikInfo.getRepositoryId() + "\n" +
|
||||
"\n" +
|
||||
" For more information and questions, you can contact the openaire support team by sending an email to " +
|
||||
"repositoryusagestats@openaire.eu\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
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
|
||||
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"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" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
"\n" +
|
||||
"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" +
|
||||
"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 sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\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" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
"\n" +
|
||||
"The validation request you have submitted has started.\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'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(jobForValidation.getUserEmail(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||
ArrayList<String> to = new ArrayList<String>();
|
||||
to.add(email);
|
||||
this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
|
||||
}
|
||||
|
||||
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||
|
||||
try {
|
||||
if (sendToSpecial) {
|
||||
recipients.addAll(this.specialRecipients);
|
||||
}
|
||||
|
||||
if (repoAdminMails != null)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private String getEmailProperty(String key) {
|
||||
return pLoader.getProperties().getProperty(key);
|
||||
}
|
||||
|
||||
public void setSpecialRecipients(String specialRecipients) {
|
||||
String[] recps = specialRecipients.split(",");
|
||||
|
||||
for (String recp : recps) {
|
||||
recp = recp.trim();
|
||||
|
||||
this.specialRecipients.add(recp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
public void setOverrideEmail(String overrideEmail) {
|
||||
this.overrideEmail = overrideEmail;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public boolean isLogonly() {
|
||||
return logonly;
|
||||
}
|
||||
|
||||
public void setLogonly(boolean logonly) {
|
||||
this.logonly = logonly;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,8 +2,11 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
public interface MonitorService {
|
|
@ -0,0 +1,111 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.shared.Constants;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service("monitorService")
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Resource(name = "validatorServiceLocator")
|
||||
private ServiceLocator<ValidatorService> validatorServiceLocator;
|
||||
|
||||
private ValidatorService getValidationService() {
|
||||
return this.validatorServiceLocator.getService();
|
||||
}
|
||||
|
||||
public ServiceLocator<ValidatorService> getValidatorServiceLocator() {
|
||||
return validatorServiceLocator;
|
||||
}
|
||||
|
||||
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) {
|
||||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public JobsOfUser getJobsOfUser(String user,
|
||||
String jobType,
|
||||
String offset,
|
||||
String limit,
|
||||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus,
|
||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
|
||||
LOGGER.debug("Getting jobs of user : " + user);
|
||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||
JobsOfUser retJobs = new JobsOfUser();
|
||||
retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
||||
Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
|
||||
if (Boolean.parseBoolean(includeJobsTotal)) {
|
||||
retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null));
|
||||
retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL));
|
||||
retJobs.setTotalJobsFailed(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_FAILED));
|
||||
retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING));
|
||||
}
|
||||
|
||||
//TODO fix status with new validator version
|
||||
if(retJobs.getJobs() != null){
|
||||
for(StoredJob job :retJobs.getJobs()){
|
||||
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
||||
job.setValidationStatus("ongoing");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && job.getContentJobScore() > 50 && job.getUsageJobScore() > 50)
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() > 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() > 50)) {
|
||||
job.setValidationStatus("successful");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && (job.getContentJobScore() <= 50 || job.getUsageJobScore() <= 50))
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() <= 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return retJobs;
|
||||
|
||||
}
|
||||
|
||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJobsOfUserPerValidationStatus(String user,
|
||||
String jobType,
|
||||
String validationStatus) throws JSONException {
|
||||
LOGGER.debug("Getting job with validation status : " + validationStatus);
|
||||
try {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException {
|
||||
LOGGER.debug("Getting job summary with id : " + jobId);
|
||||
try {
|
||||
return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,7 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,9 +14,7 @@ public interface PiWikService {
|
|||
|
||||
PiwikInfo savePiwikInfo(PiwikInfo piwikInfo);
|
||||
|
||||
List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField);
|
||||
|
||||
int getPiwikSitesTotals(String searchField);
|
||||
List<PiwikInfo> getPiwikSitesForRepos();
|
||||
|
||||
ResponseEntity<Object> approvePiwikSite(String repositoryId);
|
||||
|
||||
|
@ -27,8 +23,4 @@ public interface PiWikService {
|
|||
ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
|
||||
|
||||
PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException;
|
||||
|
||||
Integer getTotal();
|
||||
|
||||
Integer getValidated(boolean validated);
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("piwikService")
|
||||
public class PiWikServiceImpl implements PiWikService {
|
||||
|
||||
@Qualifier("repomanager.dataSource")
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@Value("${services.repomanager.analyticsURL}")
|
||||
private String analyticsURL;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("emailUtils")
|
||||
EmailUtils emailUtils;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PiWikServiceImpl.class);
|
||||
|
||||
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
|
||||
|
||||
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site order by repositoryname";
|
||||
|
||||
private final static 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"),
|
||||
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
||||
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||
|
||||
|
||||
@Override
|
||||
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
||||
try{
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITE, new String[]{repositoryId}, new int[]{Types.VARCHAR}, piwikRowMapper);
|
||||
}catch (EmptyResultDataAccessException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
||||
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PiwikInfo> getPiwikSitesForRepos() {
|
||||
LOGGER.debug("Getting piwik sites for repos! ");
|
||||
try{
|
||||
return new JdbcTemplate(dataSource).query(GET_PIWIK_SITES, piwikRowMapper);
|
||||
}catch (EmptyResultDataAccessException e){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
|
||||
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOpenaireId(@PathVariable("repositoryId") String repositoryId) {
|
||||
if (repositoryId != null && repositoryId.contains("::"))
|
||||
return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
||||
try {
|
||||
approvePiwikSite(repositoryId);
|
||||
|
||||
PiwikInfo piwikInfo = getPiwikSiteForRepo(repositoryId);
|
||||
emailUtils.sendAdministratorMetricsEnabled(piwikInfo);
|
||||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOGGER.error("Error while approving piwik site: ", e);
|
||||
emailUtils.reportException(e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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,
|
||||
@RequestParam("repoWebsite") String repoWebsite,
|
||||
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
try {
|
||||
String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
||||
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
||||
Map map = new ObjectMapper().readValue(new URL(URL), Map.class);
|
||||
String siteId = null;
|
||||
if(map.get("value")!=null) {
|
||||
siteId = map.get("value").toString();
|
||||
}
|
||||
piwikInfo.setSiteId(siteId);
|
||||
|
||||
savePiwikInfo(piwikInfo);
|
||||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
LOGGER.error("Error while creating piwikScript URL", uee);
|
||||
emailUtils.reportException(uee);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Error while creating piwik site", ioe);
|
||||
emailUtils.reportException(ioe);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface RepositoryService {
|
||||
|
||||
|
||||
Country[] getCountries() ;
|
||||
|
||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
|
||||
|
||||
List<Repository> getRepositoriesOfUser(String userEmail,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
|
||||
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
||||
|
||||
List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException;
|
||||
|
||||
Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
|
||||
|
||||
List<Repository> getRepositoriesByName(String name,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
|
||||
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order,
|
||||
int page, int pageSize) throws Exception;
|
||||
|
||||
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
|
||||
|
||||
Repository addRepository(String datatype, Repository repository) throws Exception;
|
||||
|
||||
void deleteRepositoryInterface(String id, String registeredBy);
|
||||
|
||||
RepositoryInterface addRepositoryInterface(String datatype,
|
||||
String repoId,
|
||||
String registeredBy,
|
||||
RepositoryInterface iFace) throws JSONException,ResourceNotFoundException;
|
||||
|
||||
List<String> getDnetCountries();
|
||||
|
||||
List<String> getTypologies();
|
||||
|
||||
List<Timezone> getTimezones();
|
||||
|
||||
Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
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> getDatasourceClasses(String mode);
|
||||
|
||||
String getCountryName(String countryCode);
|
||||
|
||||
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
|
||||
|
||||
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
||||
|
||||
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,924 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.RequestFilter;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import eu.dnetlib.repo.manager.utils.Converter;
|
||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
||||
import gr.uoa.di.driver.xml.repository.INTERFACE;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
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 org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("repositoryService")
|
||||
public class RepositoryServiceImpl implements RepositoryService {
|
||||
|
||||
@Value("${api.baseAddress}")
|
||||
private String baseAddress;
|
||||
|
||||
@Value("${services.repo-manager.adminEmail}")
|
||||
private String adminEmail;
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"};
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class);
|
||||
|
||||
@Value("${services.repomanager.usageStatisticsDiagramsBaseURL}")
|
||||
private String usageStatisticsDiagramsBaseURL;
|
||||
|
||||
@Value("${services.repomanager.usageStatisticsNumbersBaseURL}")
|
||||
private String usageStatisticsNumbersBaseURL;
|
||||
|
||||
@Autowired
|
||||
private VocabularyLoader vocabularyLoader;
|
||||
|
||||
@Autowired
|
||||
private PiWikService piWikService;
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
ValidatorService validatorService;
|
||||
|
||||
|
||||
private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<String, Vocabulary>();
|
||||
|
||||
private Map<String, String> countriesMap = new HashMap<>();
|
||||
private Map<String, String> inverseCountriesMap = new HashMap<>();
|
||||
|
||||
private static Map<String,List<String>> dataSourceClass = new HashMap<String,List<String>>(){{
|
||||
put("opendoar",new ArrayList<String>(){{ add("pubsrepository::institutional");
|
||||
add("pubsrepository::thematic");
|
||||
add("pubsrepository::unknown");
|
||||
add("pubsrepository::mock");
|
||||
}});
|
||||
put("re3data",new ArrayList<String>(){{ add("datarepository::unknown");
|
||||
}});
|
||||
put("journal",new ArrayList<String>(){{ add("pubsrepository::journal");
|
||||
}});
|
||||
put("aggregator",new ArrayList<String>(){{ add("aggregator::pubsrepository::institutional");
|
||||
add("aggregator::pubsrepository::journals");
|
||||
add("aggregator::datarepository");
|
||||
add("aggregator::pubsrepository::unknown");
|
||||
}});
|
||||
}};
|
||||
|
||||
private static Map<String,String> invertedDataSourceClass = new HashMap<String,String>(){{
|
||||
put("pubsrepository::institutional","opendoar");
|
||||
put("pubsrepository::thematic","opendoar");
|
||||
put("pubsrepository::unknown","opendoar");
|
||||
put("pubsrepository::mock","opendoar");
|
||||
|
||||
put("datarepository::unknown","re3data");
|
||||
|
||||
put("pubsrepository::journal","journal");
|
||||
|
||||
put("aggregator::pubsrepository::institutional","aggregator");
|
||||
put("aggregator::pubsrepository::journals","aggregator");
|
||||
put("aggregator::datarepository","aggregator");
|
||||
put("aggregator::pubsrepository::unknown","aggregator");
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
LOGGER.debug("Initialization method of repository api!");
|
||||
LOGGER.debug("Updated version!");
|
||||
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
||||
for (String vocName : vocabularyNames) {
|
||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||
}
|
||||
|
||||
Country[] countries = getCountries();
|
||||
for (Country c : countries) {
|
||||
countriesMap.put(c.getName(), c.getCode());
|
||||
inverseCountriesMap.put(c.getCode(), c.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Country[] getCountries() {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/countries")
|
||||
.build().encode();
|
||||
return restTemplate.getForObject(uriComponents.toUri(), Country[].class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||
@PathVariable("mode") String mode,
|
||||
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
||||
|
||||
LOGGER.debug("Getting repositories by country!");
|
||||
int page = 0;
|
||||
int size = 100;
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String filterKey = "UNKNOWN";
|
||||
if (mode.equalsIgnoreCase("opendoar"))
|
||||
filterKey = "openaire____::opendoar";
|
||||
else if (mode.equalsIgnoreCase("re3data"))
|
||||
filterKey = "openaire____::re3data";
|
||||
|
||||
|
||||
LOGGER.debug("Country code equals : " + country);
|
||||
LOGGER.debug("Filter mode equals : " + filterKey);
|
||||
|
||||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setCollectedfrom(filterKey);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
while (jsonArray.length() > 0 ) {
|
||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||
page += 1;
|
||||
uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size));
|
||||
rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
}
|
||||
return resultSet;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByCountry" , e);
|
||||
// emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
||||
|
||||
LOGGER.debug("Searching registered repositories");
|
||||
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
UriComponents uriComponents = searchRegisteredDatasource(requestSortBy, order, Integer.toString(page), Integer.toString(pageSize));
|
||||
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setTypology(typology);
|
||||
requestFilter.setOfficialname(officialName);
|
||||
requestFilter.setEnglishname(englishName);
|
||||
|
||||
try {
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray), mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||
|
||||
return resultSet;
|
||||
}catch (Exception e){
|
||||
LOGGER.error("Error searching registered datasources" , e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Repository updateRepositoryInfo(Repository r) throws JSONException {
|
||||
|
||||
/*
|
||||
* from datasource class
|
||||
* we get the datasource type form the inverted map
|
||||
* */
|
||||
r.setDatasourceType(getRepositoryType(r.getDatasourceClass()));
|
||||
r.setInterfaces(this.getRepositoryInterface(r.getId()));
|
||||
r.setPiwikInfo(piWikService.getPiwikSiteForRepo(r.getId()));
|
||||
r.setCountryName(getCountryName(r.getCountryCode()));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
private Collection<Repository> getRepositoriesByMode(String mode, List<Repository> rs) {
|
||||
|
||||
List<Repository> reps = new ArrayList<>();
|
||||
for (Repository r : rs) {
|
||||
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
|
||||
reps.add(r);
|
||||
|
||||
}
|
||||
return reps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories of user : " + userEmail );
|
||||
UriComponents uriComponents = searchDatasource(page,size);
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
for (Repository r : repos)
|
||||
this.updateRepositoryInfo(r);
|
||||
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with id : " + id );
|
||||
Repository repo = null;
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
||||
if(jsonArray.length() == 0)
|
||||
throw new ResourceNotFoundException();
|
||||
|
||||
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
|
||||
return updateRepositoryInfo(repo);
|
||||
}catch (JSONException e){
|
||||
LOGGER.debug("Exception on getRepositoryById" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving aggregations for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
|
||||
try {
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONObject repository = new JSONObject(rs);
|
||||
|
||||
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
||||
return aggregationHistory;
|
||||
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
.limit(20)
|
||||
.collect(Collectors.toList());
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||
LOGGER.debug("Retreiving aggregations (by year) for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
Map<String, List<AggregationDetails>> aggregationByYear = new HashMap<>();
|
||||
try {
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONObject repository = new JSONObject(rs);
|
||||
|
||||
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
||||
return aggregationByYear;
|
||||
|
||||
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
return aggregationHistory.size() == 0? aggregationByYear:createYearMap(aggregationHistory);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String,List<AggregationDetails>> createYearMap(List<AggregationDetails> aggregationHistory) {
|
||||
Map<String, List<AggregationDetails>> aggregationByYear;
|
||||
aggregationHistory = aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return aggregationHistory.stream()
|
||||
.collect(Collectors.groupingBy(AggregationDetails::getYear));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with official name : " + name );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setOfficialname(name);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
for (Repository r : repos)
|
||||
updateRepositoryInfo(r);
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByName" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
|
||||
try{
|
||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
|
||||
}catch (Exception e ){
|
||||
LOGGER.debug("Exception on getRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||
@RequestBody Repository repository) throws Exception {
|
||||
|
||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
repository.setActivationId(UUID.randomUUID().toString());
|
||||
repository.setCollectedFrom("infrastruct_::openaire");
|
||||
|
||||
if (datatype.equals("journal")) {
|
||||
repository.setId("openaire____::issn" + repository.getIssn());
|
||||
repository.setNamespacePrefix("issn" + repository.getIssn());
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}else if (datatype.equals("aggregator")) {
|
||||
repository.setId("openaire____::" + com.unboundid.util.Base64.encode(repository.getOfficialName()));
|
||||
repository.setNamespacePrefix(DigestUtils.md5Hex(repository.getOfficialName()).substring(0,12));
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}else {
|
||||
this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
/* update method acting as add -> send email with registration topic/body*/
|
||||
private Repository latentUpdate(Repository repository, Authentication authentication) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
LOGGER.debug("JSON to add(update) -> " + json_repository);
|
||||
|
||||
//
|
||||
// // TODO delete these 3 lines
|
||||
// HttpHeaders temp = new HttpHeaders();
|
||||
// temp.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
|
||||
LOGGER.debug("JSON to update -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity
|
||||
, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
|
||||
emailUtils.sendAdminUpdateRepositoryEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInterface(String datatype,RepositoryInterface iFace) {
|
||||
//TODO call update base url
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateBaseUrl(repo.getId(), iFace.getId(), iFace.getBaseUrl());
|
||||
if (!iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set not empty: " + iFace.getAccessSet());
|
||||
//TODO call update method for access params
|
||||
// ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "set", iFace.getAccessSet(), false);
|
||||
} else {
|
||||
//TODO call deleteAccessParamOrExtraField
|
||||
//((DatasourceManagerService) this.dmService.getService()).deleteAccessParamOrExtraField(repo.getId(), iFace.getId(), "set");
|
||||
}
|
||||
//TODO update content description
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateContentDescription(repo.getId(), iFace.getId(), "metadata");
|
||||
if (datatype.equals("re3data")) {
|
||||
//TODO call update access params
|
||||
// ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_datacite", false);
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
} else {
|
||||
//TODO call update access params
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_dc", false);
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void storeRepository(Repository repository, Authentication authentication) throws Exception {
|
||||
|
||||
Date utilDate = new Date();
|
||||
Timestamp date = new Timestamp(utilDate.getTime());
|
||||
repository.setDateOfCollection(date);
|
||||
repository.setAggregator("OPENAIRE");
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/add/")
|
||||
.build()
|
||||
.encode();
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if(responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else {
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
||||
@RequestParam("registeredBy") String registeredBy){
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
LOGGER.debug(uriComponents.toUri());
|
||||
restTemplate.delete(uriComponents.toUri());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
||||
try {
|
||||
Repository e = this.getRepositoryById(repoId);
|
||||
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
||||
String json_interface = Converter.repositoryInterfaceObjectToJson(e,repositoryInterface);
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity <String> (json_interface,httpHeaders);
|
||||
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
|
||||
return repositoryInterface;
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
|
||||
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
|
||||
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
|
||||
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
|
||||
return repositoryInterface;
|
||||
}
|
||||
|
||||
private void submitInterfaceValidation(Repository repo, String repoType, String userEmail, RepositoryInterface iFace) throws ValidatorServiceException {
|
||||
JobForValidation job = new JobForValidation();
|
||||
|
||||
job.setActivationId(UUID.randomUUID().toString());
|
||||
job.setAdminEmails(Collections.singletonList(this.adminEmail));
|
||||
job.setBaseUrl(iFace.getBaseUrl());
|
||||
job.setDatasourceId(repo.getId());
|
||||
job.setDesiredCompatibilityLevel(iFace.getDesiredCompatibilityLevel());
|
||||
job.setInterfaceId(iFace.getId());
|
||||
// job.setInterfaceIdOld(null);
|
||||
job.setOfficialName(repo.getOfficialName());
|
||||
job.setRepoType(repoType);
|
||||
job.setUserEmail(userEmail);
|
||||
job.setValidationSet(iFace.getAccessSet());
|
||||
job.setRecords(-1);
|
||||
job.setRegistration(true);
|
||||
job.setUpdateExisting(false);
|
||||
|
||||
this.validatorService.submitJobForValidation(job);
|
||||
}
|
||||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
iFace.setCompliance("UNKNOWN");
|
||||
|
||||
if (datatype.equals("re3data"))
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
else
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
|
||||
|
||||
if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty())
|
||||
iFace.setTypology(repo.getDatasourceClass());
|
||||
else if (datatype.equalsIgnoreCase("journal"))
|
||||
iFace.setTypology("pubsrepository::journal");
|
||||
else if (datatype.equalsIgnoreCase("aggregator"))
|
||||
iFace.setTypology("aggregator::pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("opendoar"))
|
||||
iFace.setTypology("pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("re3data"))
|
||||
iFace.setTypology("datarepository::unknown");
|
||||
|
||||
iFace.setRemovable(true);
|
||||
iFace.setAccessProtocol("oai");
|
||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
}
|
||||
return iFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDnetCountries() {
|
||||
LOGGER.debug("Getting dnet-countries!");
|
||||
return Converter.readFile("countries.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypologies() {
|
||||
return Converter.readFile("typologies.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Timezone> getTimezones() {
|
||||
List<String> timezones = Converter.readFile("timezones.txt");
|
||||
return Converter.toTimezones(timezones);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/api/baseurl/")
|
||||
.path("/{page}/{size}")
|
||||
.build().expand(page,size).encode();
|
||||
|
||||
try{
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||
|
||||
List<String> resultSet = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
if (mode.equalsIgnoreCase("aggregator")) {
|
||||
if (entry.getKey().contains("aggregator"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("journal")) {
|
||||
if (entry.getKey().contains("journal"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("opendoar")) {
|
||||
if (entry.getKey().contains("pubsrepository"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
if (entry.getKey().contains("datarepository"))
|
||||
resultSet.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private Vocabulary getVocabulary(String vocName) {
|
||||
|
||||
if (!vocabularyMap.containsKey(vocName)) {
|
||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||
}
|
||||
return vocabularyMap.get(vocName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
|
||||
|
||||
LOGGER.debug("Getting compatibility classes for mode: " + mode);
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||
boolean foundData = false;
|
||||
for (Map.Entry<String, String> entry : compatibilityClasses.entrySet()) {
|
||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||
return compatibilityClasses;
|
||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||
if (entry.getKey().matches("^openaire[1-9].0_data$")) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
}
|
||||
} else {
|
||||
if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED
|
||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA) && !foundData)
|
||||
retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)");
|
||||
|
||||
return retMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
|
||||
|
||||
LOGGER.debug("Getting datasource classes for mode: " + mode);
|
||||
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
if (mode.equalsIgnoreCase("aggregator")) {
|
||||
if (entry.getKey().contains("aggregator"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("journal")) {
|
||||
if (entry.getKey().contains("journal"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("opendoar")) {
|
||||
if (entry.getKey().contains("pubsrepository"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
if (entry.getKey().contains("datarepository"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return filterResults(retMap,mode);
|
||||
|
||||
}
|
||||
|
||||
private Map<String,String> filterResults(Map<String, String> map,String mode) {
|
||||
|
||||
HashMap<String,String> filteredMap = new HashMap<>();
|
||||
for(String key:map.keySet())
|
||||
if(dataSourceClass.get(mode).contains(key))
|
||||
filteredMap.put(key,map.get(key));
|
||||
|
||||
return filteredMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryName(String countryCode) {
|
||||
return inverseCountriesMap.get(countryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = new MetricsInfo();
|
||||
metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL);
|
||||
metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId)));
|
||||
return metricsInfo;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while getting metrics info for repository: ", e);
|
||||
emailUtils.reportException(e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||
if(mode.equals("opendoar"))
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(0).getLastCollectionDate());
|
||||
else
|
||||
/*
|
||||
* first api of re3data has null value on collection date
|
||||
* */
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(1).getLastCollectionDate());
|
||||
}
|
||||
|
||||
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/oaiset")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("oaiSet",validationSet)
|
||||
.build().encode();
|
||||
restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, null, ResponseEntity.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateBaseUrl(String repositoryId, String repositoryInterfaceId, String baseUrl) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/baseurl")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("baseUrl",baseUrl)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private void updateCompliance(String repositoryId, String repositoryInterfaceId,String compliance) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/compliance")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("compliance",compliance)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private MetricsNumbers getMetricsNumbers(String openAIREID) throws BrokerException {
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usageStatisticsNumbersBaseURL + openAIREID + "/clicks");
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<MetricsNumbers> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<MetricsNumbers>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getMetricsNumbers" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
private String getOpenAIREId(String repoId) {
|
||||
|
||||
if (repoId != null && repoId.contains("::")) {
|
||||
return repoId.split("::")[0] + "::" + DigestUtils.md5Hex(repoId.split("::")[1]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private UriComponents searchDatasource(String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/search/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy","officialname")
|
||||
.queryParam("order","ASCENDING")
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private UriComponents searchSnipperDatasource(String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy","officialname")
|
||||
.queryParam("order","ASCENDING")
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private UriComponents searchRegisteredDatasource(String requestSortBy, String order, String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/searchregistered/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy",requestSortBy)
|
||||
.queryParam("order",order)
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private String getRepositoryType(String typology){
|
||||
return invertedDataSourceClass.get(typology);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface StatsService {
|
||||
|
||||
Map getStatistics() ;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("statsService")
|
||||
public class StatsServiceImpl implements StatsService {
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@Value("${search.api.baseAddress}")
|
||||
private String baseAddress;
|
||||
@Value("${search.api.usagestats}")
|
||||
private String usagestatsBaseAddress;
|
||||
@Value("${search.api.usageEvents}")
|
||||
private String usagestatsEvents;
|
||||
|
||||
@Override
|
||||
public Map getStatistics() {
|
||||
|
||||
UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate);
|
||||
DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate);
|
||||
AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate);
|
||||
LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate);
|
||||
JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate);
|
||||
PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate);
|
||||
DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate);
|
||||
SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate);
|
||||
LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate);
|
||||
|
||||
Map<String,Object> stats = new HashMap<>();
|
||||
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
||||
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
||||
stats.put("literature",literatureHystrixCommand.execute());
|
||||
stats.put("journal",journalHystrixCommand.execute());
|
||||
stats.put("publications",publicationHystrixCommand.execute());
|
||||
stats.put("datasets",datasetsHystrixCommand.execute());
|
||||
stats.put("software",softwareHystrixCommand.execute());
|
||||
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
||||
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
||||
return stats;
|
||||
}
|
||||
}
|
|
@ -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 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(@PathVariable("page") String page,
|
||||
@PathVariable("pageSize") String pageSize,
|
||||
@RequestParam(value = "Report") String Report,
|
||||
@RequestParam(value = "Release",defaultValue="4") 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") String RepositoryIdentifier,
|
||||
@RequestParam(value = "ItemIdentifier",required=false,defaultValue="") String ItemIdentifier,
|
||||
@RequestParam(value = "ItemDataType",required=false,defaultValue="") String ItemDataType,
|
||||
@RequestParam(value = "Granularity") String Granularity,
|
||||
@RequestParam(value = "Pretty",required=false,defaultValue="") 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;
|
||||
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
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.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
@ -18,24 +16,24 @@ import java.util.stream.Collectors;
|
|||
@Service("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
|
||||
public ResponseEntity<Object> login() {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
logger.debug("User authentication : " + authentication);
|
||||
LOGGER.debug("User authentication : " + authentication);
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
body.put("sub",authentication.getSub());
|
||||
|
||||
UserInfo userInfo = authentication.getUserInfo();
|
||||
String userName = userInfo.getName();
|
||||
|
||||
if ( userName == null || userName.isEmpty() )
|
||||
body.put("name", userInfo.getGivenName() + " " + userInfo.getFamilyName());
|
||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
||||
body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
|
||||
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());
|
||||
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.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
@ -40,8 +39,4 @@ public interface ValidatorService {
|
|||
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.shared.Constants;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
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.security.core.context.SecurityContextHolder;
|
||||
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.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@Service("validatorService")
|
||||
public class ValidatorServiceImpl implements ValidatorService {
|
||||
|
||||
@Autowired
|
||||
private MonitorServiceImpl monitorApi;
|
||||
|
||||
@Resource(name = "validatorServiceLocator")
|
||||
private ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator;
|
||||
|
||||
private eu.dnetlib.api.functionality.ValidatorService getValidationService() {
|
||||
return this.validatorServiceLocator.getService();
|
||||
}
|
||||
|
||||
public ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> getValidatorServiceLocator() {
|
||||
return validatorServiceLocator;
|
||||
}
|
||||
|
||||
public void setValidatorServiceLocator(ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator) {
|
||||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(ValidatorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@PostConstruct
|
||||
private void loadRules(){
|
||||
LOGGER.debug("PostConstruct method! Load rules!");
|
||||
try {
|
||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||
String key = "";
|
||||
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
||||
key = Constants.VALIDATION_MODE_DATA;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
||||
key = Constants.VALIDATION_MODE_CRIS;
|
||||
|
||||
if (rulesetMap.containsKey(key))
|
||||
rulesetMap.get(key).add(ruleSet);
|
||||
else {
|
||||
List<RuleSet> ruleSets = new ArrayList<RuleSet>();
|
||||
ruleSets.add(ruleSet);
|
||||
rulesetMap.put(key, ruleSets);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
|
||||
try {
|
||||
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(),jobForValidation);
|
||||
this.getValidationService().submitValidationJob(jobForValidation);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.debug("Exception on submitJobForValidation" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jobForValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
||||
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||
LOGGER.debug("Resubmit validation job with id : " + jobId);
|
||||
StoredJob job = monitorApi.getJobSummary(jobId,"all");
|
||||
Set<Integer> contentRules = new HashSet<Integer>();
|
||||
Set<Integer> usageRules = new HashSet<Integer>();
|
||||
|
||||
RuleSet ruleSet = null;
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ruleId : job.getRules()) {
|
||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||
contentRules.add(ruleId);
|
||||
else if (ruleSet.getUsageRulesIds().contains(ruleId))
|
||||
usageRules.add(ruleId);
|
||||
}
|
||||
if (!contentRules.isEmpty())
|
||||
job.setSelectedContentRules(contentRules);
|
||||
if (!usageRules.isEmpty())
|
||||
job.setSelectedUsageRules(usageRules);
|
||||
this.submitJobForValidation(job);
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets(@PathVariable("mode") String mode) {
|
||||
LOGGER.info("Getting rulesets for mode: " + mode);
|
||||
return rulesetMap.get(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
||||
LOGGER.debug("Getting sets of repository with url : " + url);
|
||||
try {
|
||||
return OaiTools.getSetsOfRepo(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on getSetsOfRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
|
||||
LOGGER.debug("Identify repository with url : " + url);
|
||||
try {
|
||||
return OaiTools.identifyRepository(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while identifying repository with url: " + url, e);
|
||||
emailUtils.reportException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleSet getRuleSet(@PathVariable("acronym") String acronym) {
|
||||
LOGGER.debug("Getting ruleset with acronym : " + acronym);
|
||||
RuleSet ruleSet = null;
|
||||
try {
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ruleSet;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting ruleset", e);
|
||||
emailUtils.reportException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam(value = "jobType", required = false)
|
||||
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
||||
) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
|
||||
try {
|
||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||
if (interfaceInformation.isIdentified())
|
||||
interfaceInformation.setSets(this.getSetsOfRepository(baseUrl));
|
||||
|
||||
return interfaceInformation;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting interface information with url: " + baseUrl, e);
|
||||
emailUtils.reportException(e);
|
||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 JournalHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public JournalHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress+"/resources"+
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" datasourcetypename exact Journal";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LastYearUsageStatsHystrixCommand extends HystrixCommand<Map> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
String usagestatsBaseAddress;
|
||||
|
||||
public LastYearUsageStatsHystrixCommand(String usagestatsBaseAddress,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.usagestatsBaseAddress = usagestatsBaseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map run() throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
||||
|
||||
List yearly_stats = (List) ((Map)rs.getBody()).get("yearly_stats");
|
||||
Map lastYear = (Map) yearly_stats.get(yearly_stats.size()-1);
|
||||
Integer downloads = (Integer) lastYear.get("downloads");
|
||||
Integer views = (Integer) lastYear.get("views");
|
||||
Integer year = (Integer) lastYear.get("year");
|
||||
|
||||
Map<String,Object> usagestats = new HashMap<>();
|
||||
usagestats.put("number",String.valueOf(downloads+views));
|
||||
usagestats.put("year",year);
|
||||
|
||||
return usagestats;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LiteratureHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public LiteratureHystrixCommand(String baseAddress , RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress+"/resources"+
|
||||
"?query= " +
|
||||
" oaftype exact datasource and " +
|
||||
" ( datasourcetypename exact Institutional Repository " +
|
||||
" or datasourcetypename exact Publication Repository )";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PublicationHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
RestTemplate restTemplate;
|
||||
private String baseAddress;
|
||||
|
||||
public PublicationHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() throws Exception {
|
||||
String url = baseAddress + "/publications/count";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) (rs.getBody());
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 SoftwareHystrixCommand extends HystrixCommand<String> {
|
||||
|
||||
String baseAddress;
|
||||
RestTemplate restTemplate;
|
||||
|
||||
public SoftwareHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.baseAddress = baseAddress;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String run() {
|
||||
String url = baseAddress + "/software/count";
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(url)
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 0)
|
||||
.queryParam("format", "json")
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||
Map metadata = (Map) (rs.getBody());
|
||||
return String.valueOf(metadata.get("total"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallback() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UsageStatsTotalHystrixCommand extends HystrixCommand<Integer> {
|
||||
|
||||
RestTemplate restTemplate ;
|
||||
String usagestatsEvents;
|
||||
|
||||
public UsageStatsTotalHystrixCommand(String usagestatsEvents,RestTemplate restTemplate) {
|
||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
||||
this.usagestatsEvents = usagestatsEvents;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer run() {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsEvents)
|
||||
.build().encode();
|
||||
|
||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
||||
Map metadata = (Map) ((Map)rs.getBody()).get("totals");
|
||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
// JSONObject resultSet = new JSONObject(rs);
|
||||
// JSONObject totals = resultSet.getJSONObject("totals");
|
||||
return (Integer) metadata.get("events");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getFallback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class AggregationDetails implements IsSerializable{
|
||||
|
||||
|
||||
private String aggregationStage;
|
||||
private Date date;
|
||||
private int numberOfRecords;
|
||||
private String collectionMode;
|
||||
private Boolean indexedVersion;
|
||||
|
||||
public AggregationDetails() {
|
||||
}
|
||||
|
||||
public String getAggregationStage() {
|
||||
return aggregationStage;
|
||||
}
|
||||
|
||||
public String getCollectionMode() {
|
||||
return collectionMode;
|
||||
}
|
||||
|
||||
public void setCollectionMode(String collectionMode) {
|
||||
this.collectionMode = collectionMode;
|
||||
}
|
||||
|
||||
public void setAggregationStage(String aggregationStage) {
|
||||
this.aggregationStage = aggregationStage;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public int getNumberOfRecords() {
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
||||
public void setNumberOfRecords(int numberOfRecords) {
|
||||
this.numberOfRecords = numberOfRecords;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(getDate());
|
||||
return String.valueOf(calendar.get(Calendar.YEAR));
|
||||
}
|
||||
|
||||
public Boolean getIndexedVersion() {
|
||||
return indexedVersion;
|
||||
}
|
||||
|
||||
public void setIndexedVersion(Boolean indexedVersion) {
|
||||
this.indexedVersion = indexedVersion;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Aggregations implements IsSerializable{
|
||||
|
||||
private List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
private AggregationDetails lastCollection;
|
||||
private AggregationDetails lastTransformation;
|
||||
|
||||
public Aggregations() {
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationHistory() {
|
||||
return aggregationHistory;
|
||||
}
|
||||
|
||||
public void setAggregationHistory(List<AggregationDetails> aggregationHistory) {
|
||||
this.aggregationHistory = aggregationHistory;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastCollection() {
|
||||
return lastCollection;
|
||||
}
|
||||
|
||||
public void setLastCollection(AggregationDetails lastCollection) {
|
||||
this.lastCollection = lastCollection;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastTransformation() {
|
||||
return lastTransformation;
|
||||
}
|
||||
|
||||
public void setLastTransformation(AggregationDetails lastTransformation) {
|
||||
this.lastTransformation = lastTransformation;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
|
||||
/**
|
|
@ -1,12 +1,12 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 23/12/15.
|
||||
*/
|
||||
|
||||
public class Constants{
|
||||
public class Constants implements IsSerializable {
|
||||
|
||||
public static final String MODE_LOCAL = "local";
|
||||
public static final String MODE_DNET = "dnet";
|
||||
|
@ -32,7 +32,6 @@ public class Constants{
|
|||
public static final String VALIDATION_MODE_LITERATURE = "literature";
|
||||
public static final String VALIDATION_MODE_DATA = "data";
|
||||
public static final String VALIDATION_MODE_CRIS = "cris";
|
||||
public static final String VALIDATION_MODE_FAIR = "fair";
|
||||
|
||||
public static final String VALIDATION_JOB_TYPE_COMPATIBILITY_TEST = "Compatibility Test";
|
||||
public static final String VALIDATION_JOB_TYPE_REGISTRATION_REQUEST = "Registration Request";
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
public class Country {
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/17/15.
|
||||
*/
|
||||
public class DatasourceRegistrationState extends WizardState implements IsSerializable {
|
||||
|
||||
private String mode;
|
||||
private String selectedRepositoryId;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
public DatasourceRegistrationState() {
|
||||
}
|
||||
|
||||
public DatasourceRegistrationState(String mode, String selectedRepositoryId, Repository repository) {
|
||||
this.mode = mode;
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getSelectedRepositoryId() {
|
||||
return selectedRepositoryId;
|
||||
}
|
||||
|
||||
public void setSelectedRepositoryId(String selectedRepositoryId) {
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 21/12/15.
|
||||
*/
|
||||
public class DatasourceVocabularies implements IsSerializable {
|
||||
|
||||
Map<String, String> countries;
|
||||
List<Timezone> timezones;
|
||||
Map<String, String> datasourceClasses;
|
||||
List<String> typologies;
|
||||
Map<String, String> compatibilityLevels;
|
||||
|
||||
public DatasourceVocabularies() {
|
||||
}
|
||||
|
||||
public Map<String, String> getCountries() {
|
||||
return countries;
|
||||
}
|
||||
|
||||
public void setCountries(Map<String, String> countries) {
|
||||
this.countries = countries;
|
||||
}
|
||||
|
||||
public List<Timezone> getTimezones() {
|
||||
return timezones;
|
||||
}
|
||||
|
||||
public void setTimezones(List<Timezone> timezones) {
|
||||
this.timezones = timezones;
|
||||
}
|
||||
|
||||
public Map<String, String> getDatasourceClasses() {
|
||||
return datasourceClasses;
|
||||
}
|
||||
|
||||
public void setDatasourceClasses(Map<String, String> datasourceClasses) {
|
||||
this.datasourceClasses = datasourceClasses;
|
||||
}
|
||||
|
||||
public List<String> getTypologies() {
|
||||
return typologies;
|
||||
}
|
||||
|
||||
public void setTypologies(List<String> typologies) {
|
||||
this.typologies = typologies;
|
||||
}
|
||||
|
||||
public Map<String, String> getCompatibilityLevels() {
|
||||
return compatibilityLevels;
|
||||
}
|
||||
|
||||
public void setCompatibilityLevels(Map<String, String> compatibilityLevels) {
|
||||
this.compatibilityLevels = compatibilityLevels;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -6,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by nikonas on 14/1/16.
|
||||
*/
|
||||
public class DatasourcesCollection{
|
||||
public class DatasourcesCollection implements IsSerializable{
|
||||
|
||||
private List<Repository> datasourcesOfUser;
|
||||
private List<Repository> sharedDatasources;
|
|
@ -1,12 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/1/16.
|
||||
*/
|
||||
public class InterfaceInformation{
|
||||
public class InterfaceInformation implements IsSerializable {
|
||||
|
||||
private boolean identified;
|
||||
private List<String> sets;
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by nikonas on 29/3/16.
|
||||
*/
|
||||
public class JobsOfUser {
|
||||
public class JobsOfUser implements IsSerializable {
|
||||
|
||||
private int totalJobs;
|
||||
private int totalJobsSuccessful;
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 11/6/17.
|
||||
*/
|
||||
public class MetricsInfo {
|
||||
public class MetricsInfo implements IsSerializable {
|
||||
|
||||
private MetricsNumbers metricsNumbers;
|
||||
private String diagramsBaseURL;
|
|
@ -1,13 +1,14 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefania on 11/7/17.
|
||||
*/
|
||||
public class MetricsNumbers{
|
||||
public class MetricsNumbers implements IsSerializable {
|
||||
|
||||
private List<String> downloads;
|
||||
private List<String> views;
|
|
@ -1,11 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class RepositoryServiceException extends Exception {
|
||||
public class RepositoryServiceException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode{
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
REPOSITORY_ALREADY_EXISTS,
|
||||
SQL_ERROR,
|
||||
NOT_ACTIVATED,
|
|
@ -1,16 +1,16 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by panagiotis on 15/1/2018.
|
||||
*/
|
||||
public class Term {
|
||||
public class Term implements IsSerializable {
|
||||
|
||||
private String englishName;
|
||||
private String nativeName;
|
||||
private String encoding;
|
||||
private String code;
|
||||
public String englishName;
|
||||
public String nativeName;
|
||||
public String encoding;
|
||||
public String code;
|
||||
|
||||
public Term(String englishName, String nativeName, String encoding, String code) {
|
||||
this.englishName = englishName;
|
|
@ -0,0 +1,17 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class Timezone implements IsSerializable {
|
||||
public String name;
|
||||
public double offset;
|
||||
|
||||
public Timezone(){
|
||||
}
|
||||
|
||||
public Timezone(String name, double offset) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 3/8/16.
|
||||
*/
|
||||
public class Triple<K, V, L> extends Tuple<K, V> {
|
||||
public class Triple<K, V, L> extends Tuple<K, V> implements IsSerializable {
|
||||
|
||||
private L third;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/18/15.
|
||||
*/
|
||||
public class Tuple<K, V> {
|
||||
public class Tuple<K, V> implements IsSerializable {
|
||||
|
||||
private K first;
|
||||
private V second;
|
|
@ -1,13 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class UserAccessException extends Exception {
|
||||
public class UserAccessException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode {
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
USER_ALREADY_EXISTS,
|
||||
SQL_ERROR,
|
||||
INVALID_USERNAME,
|
|
@ -1,11 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class ValidationServiceException extends Exception{
|
||||
public class ValidationServiceException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode{
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
NO_ADMIN_EMAILS,
|
||||
NOT_VALID_BASEURL,
|
||||
GENERAL_ERROR, NOT_VALID_SET
|
|
@ -0,0 +1,16 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class ValidationState extends WizardState implements IsSerializable {
|
||||
|
||||
private JobForValidation jobForValidation = new JobForValidation();
|
||||
|
||||
public JobForValidation getJobForValidation() {
|
||||
return jobForValidation;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 3/8/16.
|
||||
*/
|
||||
public class Vocabulary {
|
||||
public class Vocabulary implements IsSerializable {
|
||||
|
||||
private String id;
|
||||
private String name;
|
|
@ -0,0 +1,9 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class WizardState implements IsSerializable {
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvQueryObject {
|
||||
public class AdvQueryObject implements IsSerializable {
|
||||
|
||||
private String datasource = "";
|
||||
private String topic = "";
|
|
@ -1,12 +1,14 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 26/10/2016.
|
||||
*/
|
||||
public class BrowseEntry implements Comparable<BrowseEntry>{
|
||||
public class BrowseEntry implements Comparable<BrowseEntry>, IsSerializable{
|
||||
|
||||
private String value;
|
||||
private Long size;
|
||||
public String value;
|
||||
public Long size;
|
||||
|
||||
public BrowseEntry() {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public enum ConditionOperator implements IsSerializable {
|
||||
EXACT, MATCH_ANY, MATCH_ALL, RANGE
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public class ConditionParams {
|
||||
public class ConditionParams implements IsSerializable {
|
||||
|
||||
private String value;
|
||||
private String otherValue;
|
|
@ -0,0 +1,58 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Dataset implements IsSerializable {
|
||||
|
||||
private List<String> titles;
|
||||
|
||||
private List<String> collectedFrom;
|
||||
|
||||
private List<Pid> pids;
|
||||
|
||||
private List<Instance> instances;
|
||||
|
||||
public Dataset() {
|
||||
}
|
||||
|
||||
public Dataset(final List<String> titles, final List<String> collectedFrom, final List<Pid> pids, final List<Instance> instances) {
|
||||
this.titles = titles;
|
||||
this.collectedFrom = collectedFrom;
|
||||
this.pids = pids;
|
||||
this.instances = instances;
|
||||
}
|
||||
|
||||
public List<String> getTitles() {
|
||||
return titles;
|
||||
}
|
||||
|
||||
public void setTitles(List<String> titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
public List<String> getCollectedFrom() {
|
||||
return collectedFrom;
|
||||
}
|
||||
|
||||
public void setCollectedFrom(List<String> collectedFrom) {
|
||||
this.collectedFrom = collectedFrom;
|
||||
}
|
||||
|
||||
public List<Pid> getPids() {
|
||||
return pids;
|
||||
}
|
||||
|
||||
public void setPids(List<Pid> pids) {
|
||||
this.pids = pids;
|
||||
}
|
||||
|
||||
public List<Instance> getInstances() {
|
||||
return instances;
|
||||
}
|
||||
|
||||
public void setInstances(List<Instance> instances) {
|
||||
this.instances = instances;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 31/10/2016.
|
||||
*/
|
||||
public class DatasourcesBroker {
|
||||
public class DatasourcesBroker implements IsSerializable {
|
||||
|
||||
private List<Tuple<BrowseEntry, String>> datasourcesOfUser;
|
||||
private List<Tuple<BrowseEntry, String>> sharedDatasources;
|
|
@ -1,26 +1,27 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 26/10/2016.
|
||||
*/
|
||||
public class EventsPage{
|
||||
public class EventsPage implements IsSerializable{
|
||||
|
||||
private String datasource;
|
||||
private String topic;
|
||||
private long currPage;
|
||||
private long totalPages;
|
||||
private long total;
|
||||
private List<OaBrokerEventPayload> values;
|
||||
private List<OpenAireEventPayload> values;
|
||||
|
||||
public EventsPage() {
|
||||
|
||||
}
|
||||
public EventsPage(final String datasource, final String topic, final long currPage, final long totalPages, final long total,
|
||||
final List<OaBrokerEventPayload> values) {
|
||||
final List<OpenAireEventPayload> values) {
|
||||
this.datasource = datasource;
|
||||
this.topic = topic;
|
||||
this.currPage = currPage;
|
||||
|
@ -69,11 +70,11 @@ public class EventsPage{
|
|||
this.total = total;
|
||||
}
|
||||
|
||||
public List<OaBrokerEventPayload> getValues() {
|
||||
public List<OpenAireEventPayload> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<OaBrokerEventPayload> values) {
|
||||
public void setValues(List<OpenAireEventPayload> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class ExternalReference implements IsSerializable {
|
||||
|
||||
private String url;
|
||||
|
||||
private String sitename;
|
||||
|
||||
private String type;
|
||||
|
||||
private String refidentifier;
|
||||
|
||||
public ExternalReference() {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getSitename() {
|
||||
return sitename;
|
||||
}
|
||||
|
||||
public void setSitename(String sitename) {
|
||||
this.sitename = sitename;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRefidentifier() {
|
||||
return refidentifier;
|
||||
}
|
||||
|
||||
public void setRefidentifier(String refidentifier) {
|
||||
this.refidentifier = refidentifier;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Instance implements IsSerializable {
|
||||
|
||||
private String url;
|
||||
|
||||
private String license;
|
||||
|
||||
private String hostedby;
|
||||
|
||||
private String instancetype;
|
||||
|
||||
public Instance() {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public String getHostedby() {
|
||||
return hostedby;
|
||||
}
|
||||
|
||||
public void setHostedby(String hostedby) {
|
||||
this.hostedby = hostedby;
|
||||
}
|
||||
|
||||
public String getInstancetype() {
|
||||
return instancetype;
|
||||
}
|
||||
|
||||
public void setInstancetype(String instancetype) {
|
||||
this.instancetype = instancetype;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Journal implements IsSerializable {
|
||||
|
||||
private String name;
|
||||
|
||||
private String issn;
|
||||
|
||||
private String eissn;
|
||||
|
||||
private String lissn;
|
||||
|
||||
public Journal() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public class MapConditions {
|
||||
public class MapConditions implements IsSerializable {
|
||||
|
||||
private String field;
|
||||
private MapValueType fieldType;
|
|
@ -1,9 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public enum MapValueType {
|
||||
public enum MapValueType implements IsSerializable {
|
||||
STRING, INTEGER, FLOAT, DATE, BOOLEAN, LIST_STRING, LIST_INTEGER, LIST_FLOAT, LIST_DATE, LIST_BOOLEAN;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
public enum NotificationFrequency implements IsSerializable {
|
||||
never, realtime, daily, weekly, monthly
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
public enum NotificationMode implements IsSerializable {
|
||||
MOCK, EMAIL
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 11/07/16.
|
||||
*/
|
||||
public class OpenAireEventPayload implements IsSerializable {
|
||||
|
||||
private Publication publication;
|
||||
|
||||
private Publication highlight;
|
||||
|
||||
private Provenance provenance;
|
||||
|
||||
private float trust;
|
||||
|
||||
public OpenAireEventPayload() {
|
||||
}
|
||||
|
||||
public Publication getPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
public void setPublication(Publication publication) {
|
||||
this.publication = publication;
|
||||
}
|
||||
|
||||
public Publication getHighlight() {
|
||||
return highlight;
|
||||
}
|
||||
|
||||
public void setHighlight(Publication highlight) {
|
||||
this.highlight = highlight;
|
||||
}
|
||||
|
||||
public Provenance getProvenance() {
|
||||
return provenance;
|
||||
}
|
||||
|
||||
public void setProvenance(Provenance provenance) {
|
||||
this.provenance = provenance;
|
||||
}
|
||||
|
||||
public float getTrust() {
|
||||
return trust;
|
||||
}
|
||||
|
||||
public void setTrust(float trust) {
|
||||
this.trust = trust;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
|
||||
public class OpenaireSubscription {
|
||||
public class OpenaireSubscription implements IsSerializable {
|
||||
|
||||
private String subscriber;
|
||||
private NotificationFrequency frequency;
|
|
@ -0,0 +1,32 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Pid implements IsSerializable {
|
||||
|
||||
private String value;
|
||||
|
||||
private String type;
|
||||
|
||||
public Pid() {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class Project implements IsSerializable {
|
||||
|
||||
private String code;
|
||||
private String acronym;
|
||||
private String title;
|
||||
private String funder;
|
||||
private String fundingProgram;
|
||||
private String jurisdiction;
|
||||
|
||||
public Project() {
|
||||
}
|
||||
|
||||
public Project(final String code, final String acronym, final String title, final String funder, final String fundingProgram, final String jurisdiction) {
|
||||
this.code = code;
|
||||
this.acronym = acronym;
|
||||
this.title = title;
|
||||
this.funder = funder;
|
||||
this.fundingProgram = fundingProgram;
|
||||
this.jurisdiction = jurisdiction;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAcronym() {
|
||||
return acronym;
|
||||
}
|
||||
|
||||
public void setAcronym(String acronym) {
|
||||
this.acronym = acronym;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getFunder() {
|
||||
return funder;
|
||||
}
|
||||
|
||||
public void setFunder(String funder) {
|
||||
this.funder = funder;
|
||||
}
|
||||
|
||||
public String getFundingProgram() {
|
||||
return fundingProgram;
|
||||
}
|
||||
|
||||
public void setFundingProgram(String fundingProgram) {
|
||||
this.fundingProgram = fundingProgram;
|
||||
}
|
||||
|
||||
public String getJurisdiction() {
|
||||
return jurisdiction;
|
||||
}
|
||||
|
||||
public void setJurisdiction(String jurisdiction) {
|
||||
this.jurisdiction = jurisdiction;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 26/07/16.
|
||||
*/
|
||||
public class Provenance implements IsSerializable {
|
||||
|
||||
private String repositoryName;
|
||||
|
||||
private String url;
|
||||
|
||||
private String id;
|
||||
|
||||
public Provenance() {
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Publication implements IsSerializable {
|
||||
|
||||
private String originalId;
|
||||
|
||||
private List<String> titles = new ArrayList<>();
|
||||
|
||||
private List<String> abstracts = new ArrayList<>();
|
||||
|
||||
private String language;
|
||||
|
||||
private List<String> subjects = new ArrayList<>();
|
||||
|
||||
private List<String> creators = new ArrayList<>();
|
||||
|
||||
private String publicationdate;
|
||||
|
||||
private String publisher;
|
||||
|
||||
private String embargoenddate;
|
||||
|
||||
private List<String> contributor = new ArrayList<>();
|
||||
|
||||
private Journal journal;
|
||||
|
||||
private List<String> collectedFrom = new ArrayList<>();
|
||||
|
||||
private List<Pid> pids = new ArrayList<>();
|
||||
|
||||
private List<Instance> instances = new ArrayList<>();
|
||||
|
||||
private List<ExternalReference> externalReferences = new ArrayList<>();
|
||||
|
||||
private List<Project> projects = new ArrayList<>();
|
||||
|
||||
private List<Dataset> datasets = new ArrayList<>();
|
||||
|
||||
public Publication() {
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public List<String> getTitles() {
|
||||
return titles;
|
||||
}
|
||||
|
||||
public void setTitles(List<String> titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
public List<String> getAbstracts() {
|
||||
return abstracts;
|
||||
}
|
||||
|
||||
public void setAbstracts(List<String> abstracts) {
|
||||
this.abstracts = abstracts;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public List<String> getSubjects() {
|
||||
return subjects;
|
||||
}
|
||||
|
||||
public void setSubjects(List<String> subjects) {
|
||||
this.subjects = subjects;
|
||||
}
|
||||
|
||||
public List<String> getCreators() {
|
||||
return creators;
|
||||
}
|
||||
|
||||
public void setCreators(List<String> creators) {
|
||||
this.creators = creators;
|
||||
}
|
||||
|
||||
public String getPublicationdate() {
|
||||
return publicationdate;
|
||||
}
|
||||
|
||||
public void setPublicationdate(String publicationdate) {
|
||||
this.publicationdate = publicationdate;
|
||||
}
|
||||
|
||||
public String getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(String publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public String getEmbargoenddate() {
|
||||
return embargoenddate;
|
||||
}
|
||||
|
||||
public void setEmbargoenddate(String embargoenddate) {
|
||||
this.embargoenddate = embargoenddate;
|
||||
}
|
||||
|
||||
public List<String> getContributor() {
|
||||
return contributor;
|
||||
}
|
||||
|
||||
public void setContributor(List<String> contributor) {
|
||||
this.contributor = contributor;
|
||||
}
|
||||
|
||||
public Journal getJournal() {
|
||||
return journal;
|
||||
}
|
||||
|
||||
public void setJournal(Journal journal) {
|
||||
this.journal = journal;
|
||||
}
|
||||
|
||||
public List<String> getCollectedFrom() {
|
||||
return collectedFrom;
|
||||
}
|
||||
|
||||
public void setCollectedFrom(List<String> collectedFrom) {
|
||||
this.collectedFrom = collectedFrom;
|
||||
}
|
||||
|
||||
public List<Pid> getPids() {
|
||||
return pids;
|
||||
}
|
||||
|
||||
public void setPids(List<Pid> pids) {
|
||||
this.pids = pids;
|
||||
}
|
||||
|
||||
public List<Instance> getInstances() {
|
||||
return instances;
|
||||
}
|
||||
|
||||
public void setInstances(List<Instance> instances) {
|
||||
this.instances = instances;
|
||||
}
|
||||
|
||||
public List<ExternalReference> getExternalReferences() {
|
||||
return externalReferences;
|
||||
}
|
||||
|
||||
public void setExternalReferences(List<ExternalReference> externalReferences) {
|
||||
this.externalReferences = externalReferences;
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public List<Dataset> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void setDatasets(List<Dataset> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.domain.broker;
|
||||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 26/10/2016.
|
||||
*/
|
||||
public class Range{
|
||||
public class Range implements IsSerializable {
|
||||
|
||||
private String min;
|
||||
private String max;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue