svn merge -r62311:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/uoa-repository-manager-service/branches/new-datasource-model .
This commit is contained in:
parent
2a8294a958
commit
c7b7d37ae3
50
pom.xml
50
pom.xml
|
@ -137,21 +137,21 @@
|
|||
<!-- <artifactId>log4j</artifactId>-->
|
||||
<!-- <version>${log4j.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-domain</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
<exclusions>
|
||||
<exclusion> <!-- declare the exclusion here -->
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>eu.dnetlib</groupId>-->
|
||||
<!-- <artifactId>uoa-domain</artifactId>-->
|
||||
<!-- <version>[2.0.0-SNAPSHOT, 3.0.0)</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion> <!– declare the exclusion here –>-->
|
||||
<!-- <groupId>cglib</groupId>-->
|
||||
<!-- <artifactId>cglib</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>log4j</groupId>-->
|
||||
<!-- <artifactId>log4j</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
||||
|
@ -291,7 +291,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
|
@ -305,13 +305,13 @@
|
|||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
<!--<version>3.7.0</version>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<version>${jedis.version}</version>
|
||||
<!--<version>3.7.0</version>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
@ -327,8 +327,8 @@
|
|||
<groupId>com.netflix.hystrix</groupId>
|
||||
<artifactId>hystrix-core</artifactId>
|
||||
<version>1.5.18</version>
|
||||
</dependency>
|
||||
<!--
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.netflix.rxjava</groupId>
|
||||
<artifactId>rxjava-core</artifactId>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -24,4 +23,4 @@ public class AsyncConfiguration implements AsyncConfigurer {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,21 @@ import gr.uoa.di.driver.util.StaticServiceLocator;
|
|||
import gr.uoa.di.driver.xml.VocabularyXmlConverter;
|
||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {"org.eurocris.openaire.cris.validator.service"})
|
||||
public class Config {
|
||||
|
||||
@Value("${services.provide.iSLookUpService.url}")
|
||||
private String lookupURL;
|
||||
|
||||
@Value("${services.provide.validatorService.url}")
|
||||
@Value("${services.provide.validatorService.url}")
|
||||
private String validatorUrl;
|
||||
|
||||
@Bean(name="vocabularyLoader")
|
||||
@Bean(name = "vocabularyLoader")
|
||||
public VocabularyLoader createVocabularyLoader() throws Exception {
|
||||
ISVocabularyLoader loader = new ISVocabularyLoader();
|
||||
|
||||
|
@ -78,4 +81,4 @@ public class Config {
|
|||
|
||||
return locator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import org.apache.log4j.Logger;
|
|||
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@ComponentScan
|
||||
@Component
|
||||
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ package eu.dnetlib.repo.manager.config;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
|
@ -15,9 +16,6 @@ import javax.annotation.PostConstruct;
|
|||
|
||||
@Configuration
|
||||
@EnableRedisHttpSession
|
||||
@ComponentScan(basePackages = {
|
||||
"org.eurocris.openaire.cris.validator.service",
|
||||
"eu.dnetlib.repo.manager.*"})
|
||||
public class RedisConfiguration {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(RedisConfiguration.class);
|
||||
|
@ -35,18 +33,18 @@ public class RedisConfiguration {
|
|||
private String domain;
|
||||
|
||||
@PostConstruct
|
||||
private void init(){
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
private void init() {
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JedisConnectionFactory connectionFactory() {
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
||||
jedisConnectionFactory.setHostName(host);
|
||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
||||
jedisConnectionFactory.setUsePool(true);
|
||||
if(password != null) jedisConnectionFactory.setPassword(password);
|
||||
if (password != null) jedisConnectionFactory.setPassword(password);
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.repo.manager.controllers.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
|
@ -23,17 +21,7 @@ import java.util.ArrayList;
|
|||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableWebMvc
|
||||
@ComponentScan(basePackageClasses = {
|
||||
RepositoryController.class,
|
||||
MonitorController.class,
|
||||
ValidatorController.class,
|
||||
PiWikController.class,
|
||||
BrokerController.class,
|
||||
StatsController.class,
|
||||
UserController.class,
|
||||
SushiliteController.class
|
||||
},basePackages = "eu.dnetlib.repo.manager.*")
|
||||
public class SwaggerConfig {
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket productApi() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.service.BrokerService;
|
||||
import eu.dnetlib.repo.manager.service.DashboardService;
|
||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||
|
@ -18,7 +20,7 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/dashboard")
|
||||
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||
public class DashboardController {
|
||||
|
||||
@Autowired
|
||||
|
@ -33,17 +35,17 @@ public class DashboardController {
|
|||
@Autowired
|
||||
private PiWikService piWikService;
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{page}/{size}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return dashboardService.getRepositoriesSummaryInfo(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/collectionMonitorSummary/{repoId}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
|
@ -51,25 +53,25 @@ public class DashboardController {
|
|||
@PathVariable("repoId") String repoId,
|
||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
||||
|
||||
List<AggregationDetails> aggregationDetails = repositoryService.getRepositoryAggregations(repoId,0,size);
|
||||
List<AggregationDetails> aggregationDetails = repositoryService.getRepositoryAggregations(repoId, 0, size);
|
||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||
collectionMonitorSummary.setAggregationDetails(aggregationDetails);
|
||||
size=0;
|
||||
size = 0;
|
||||
do {
|
||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId,size,size+50);
|
||||
for(AggregationDetails aggregationDetail : aggregationDetails){
|
||||
if(aggregationDetail.getIndexedVersion()){
|
||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
||||
for (AggregationDetails aggregationDetail : aggregationDetails) {
|
||||
if (aggregationDetail.getIndexedVersion()) {
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
size+=30;
|
||||
}while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion()==null);
|
||||
size += 30;
|
||||
} while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||
|
||||
return collectionMonitorSummary;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/usageSummary/{repoId}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
|
@ -79,16 +81,14 @@ public class DashboardController {
|
|||
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/brokerSummary/{ds_name}" , method = RequestMethod.GET,
|
||||
@RequestMapping(value = "/brokerSummary/{ds_name}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public BrokerSummary getBrokerSummary(
|
||||
@PathVariable("ds_name") String datasourceName) throws BrokerException {
|
||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser( ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.dnetlib.repo.manager.controllers;
|
|||
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ServerError;
|
||||
|
@ -33,35 +33,35 @@ public class GenericControllerAdvice {
|
|||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
@ResponseBody
|
||||
public ServerError securityException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseBody
|
||||
public ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(UnknownHostException.class)
|
||||
@ResponseBody
|
||||
public ServerError unknownHostException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class})
|
||||
@ExceptionHandler({JSONException.class, BrokerException.class, ValidatorServiceException.class})
|
||||
@ResponseBody
|
||||
public ServerError internalException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
||||
@ExceptionHandler(EndPointException.class)
|
||||
@ResponseBody
|
||||
public ServerError endPointException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
return new ServerError(req.getRequestURL().toString(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.dnetlib.domain.data.PiwikInfo;
|
|||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.Paging;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.domain.dto.RepositoryTerms;
|
||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||
|
@ -65,8 +66,9 @@ public class RepositoryController {
|
|||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser() throws Exception {
|
||||
return repositoryService.getRepositoriesSnippetsOfUser("0", "100"); // FIXME
|
||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(@RequestParam(name = "page", defaultValue = "0") int page,
|
||||
@RequestParam(name = "size", defaultValue = "1000") int pageSize) throws Exception {
|
||||
return repositoryService.getRepositoriesSnippetsOfUser(String.valueOf(page), String.valueOf(pageSize));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/terms", method = RequestMethod.POST,
|
||||
|
@ -110,7 +112,7 @@ public class RepositoryController {
|
|||
Repository repo = repositoryService.getRepositoryById(id);
|
||||
|
||||
if (repo != null)
|
||||
logger.info("Returning repository " + repo.getId() + " registered by " + repo.getRegisteredBy());
|
||||
logger.info("Returning repository " + repo.getId() + " registered by " + repo.getRegisteredby());
|
||||
else
|
||||
logger.info("Requested repository " + id + " not found");
|
||||
return repo;
|
||||
|
@ -158,6 +160,7 @@ public class RepositoryController {
|
|||
return repositoryService.addRepository(datatype, repository);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
@ -165,6 +168,7 @@ public class RepositoryController {
|
|||
return repositoryService.getDnetCountries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
@ -172,6 +176,7 @@ public class RepositoryController {
|
|||
return repositoryService.getTypologies();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
@ -225,13 +230,6 @@ public class RepositoryController {
|
|||
return repositoryService.getUrlsOfUserRepos(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDatasourceVocabularies/{mode}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getDatasourceVocabularies(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getCompatibilityClasses/{mode}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.EmailUtils;
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Aggregations{
|
||||
|
||||
private List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
private AggregationDetails lastCollection;
|
||||
private AggregationDetails lastTransformation;
|
||||
|
||||
public Aggregations() {
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationHistory() {
|
||||
return aggregationHistory;
|
||||
}
|
||||
|
||||
public void setAggregationHistory(List<AggregationDetails> aggregationHistory) {
|
||||
this.aggregationHistory = aggregationHistory;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastCollection() {
|
||||
return lastCollection;
|
||||
}
|
||||
|
||||
public void setLastCollection(AggregationDetails lastCollection) {
|
||||
this.lastCollection = lastCollection;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastTransformation() {
|
||||
return lastTransformation;
|
||||
}
|
||||
|
||||
public void setLastTransformation(AggregationDetails lastTransformation) {
|
||||
this.lastTransformation = lastTransformation;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
public class ApiDetails {
|
||||
protected String id = null;
|
||||
protected String protocol = null;
|
||||
protected String datasource = null;
|
||||
protected String contentdescription = null;
|
||||
protected String eoscDatasourceType = null;
|
||||
protected String compatibility;
|
||||
protected String compatibilityOverride;
|
||||
protected Integer lastCollectionTotal;
|
||||
protected Date lastCollectionDate;
|
||||
protected Integer lastAggregationTotal;
|
||||
protected Date lastAggregationDate;
|
||||
protected Integer lastDownloadTotal;
|
||||
protected Date lastDownloadDate;
|
||||
protected String baseurl;
|
||||
protected Boolean removable = false;
|
||||
protected Set<ApiParamDetails> apiParams;
|
||||
protected String metadataIdentifierPath = "";
|
||||
@Deprecated
|
||||
protected String typology = null;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public String getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public String getContentdescription() {
|
||||
return contentdescription;
|
||||
}
|
||||
|
||||
public String getCompatibility() {
|
||||
return compatibility;
|
||||
}
|
||||
|
||||
public Integer getLastCollectionTotal() {
|
||||
return lastCollectionTotal;
|
||||
}
|
||||
|
||||
public Date getLastCollectionDate() {
|
||||
return lastCollectionDate;
|
||||
}
|
||||
|
||||
public Integer getLastAggregationTotal() {
|
||||
return lastAggregationTotal;
|
||||
}
|
||||
|
||||
public Date getLastAggregationDate() {
|
||||
return lastAggregationDate;
|
||||
}
|
||||
|
||||
public Integer getLastDownloadTotal() {
|
||||
return lastDownloadTotal;
|
||||
}
|
||||
|
||||
public Date getLastDownloadDate() {
|
||||
return lastDownloadDate;
|
||||
}
|
||||
|
||||
public String getBaseurl() {
|
||||
return baseurl;
|
||||
}
|
||||
|
||||
public ApiDetails setId(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setProtocol(final String protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setDatasource(final String datasource) {
|
||||
this.datasource = datasource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setContentdescription(final String contentdescription) {
|
||||
this.contentdescription = contentdescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setCompatibility(final String compatibility) {
|
||||
this.compatibility = compatibility;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastCollectionTotal(final Integer lastCollectionTotal) {
|
||||
this.lastCollectionTotal = lastCollectionTotal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastCollectionDate(final Date lastCollectionDate) {
|
||||
this.lastCollectionDate = lastCollectionDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastAggregationTotal(final Integer lastAggregationTotal) {
|
||||
this.lastAggregationTotal = lastAggregationTotal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastAggregationDate(final Date lastAggregationDate) {
|
||||
this.lastAggregationDate = lastAggregationDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastDownloadTotal(final Integer lastDownloadTotal) {
|
||||
this.lastDownloadTotal = lastDownloadTotal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setLastDownloadDate(final Date lastDownloadDate) {
|
||||
this.lastDownloadDate = lastDownloadDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiDetails setBaseurl(final String baseurl) {
|
||||
this.baseurl = baseurl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<ApiParamDetails> getApiParams() {
|
||||
return apiParams;
|
||||
}
|
||||
|
||||
public void setApiParams(final Set<ApiParamDetails> apiParams) {
|
||||
this.apiParams = apiParams;
|
||||
}
|
||||
|
||||
public String getCompatibilityOverride() {
|
||||
return compatibilityOverride;
|
||||
}
|
||||
|
||||
public ApiDetails setCompatibilityOverride(final String compatibilityOverride) {
|
||||
this.compatibilityOverride = compatibilityOverride;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getRemovable() {
|
||||
return removable;
|
||||
}
|
||||
|
||||
public ApiDetails setRemovable(final Boolean removable) {
|
||||
this.removable = removable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMetadataIdentifierPath() {
|
||||
return metadataIdentifierPath;
|
||||
}
|
||||
|
||||
public ApiDetails setMetadataIdentifierPath(final String metadataIdentifierPath) {
|
||||
this.metadataIdentifierPath = metadataIdentifierPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEoscDatasourceType() {
|
||||
return eoscDatasourceType;
|
||||
}
|
||||
|
||||
public ApiDetails setEoscDatasourceType(final String eoscDatasourceType) {
|
||||
this.eoscDatasourceType = eoscDatasourceType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
public ApiDetails setTypology(final String typology) {
|
||||
this.typology = typology;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ApiDetailsResponse extends Response {
|
||||
|
||||
private List<ApiDetails> api;
|
||||
|
||||
|
||||
public List<ApiDetails> getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
public ApiDetailsResponse setApi(final List<ApiDetails> api) {
|
||||
this.api = api;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public class ApiParamDetails {
|
||||
|
||||
protected String param;
|
||||
protected String value;
|
||||
|
||||
|
||||
public String getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setParam(final String param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
public class DatasourceDetails {
|
||||
|
||||
protected String id;
|
||||
@Transient
|
||||
protected String openaireId;
|
||||
protected String officialname;
|
||||
protected String englishname;
|
||||
protected String websiteurl;
|
||||
protected String logourl;
|
||||
protected String contactemail;
|
||||
protected Double latitude = 0.0;
|
||||
protected Double longitude = 0.0;
|
||||
protected Double timezone = 0.0;
|
||||
protected String namespaceprefix;
|
||||
protected String languages;
|
||||
protected Date dateofvalidation;
|
||||
protected String eoscDatasourceType;
|
||||
protected Date dateofcollection;
|
||||
protected String platform;
|
||||
protected String activationId;
|
||||
protected String description;
|
||||
protected String issn;
|
||||
protected String eissn;
|
||||
protected String lissn;
|
||||
protected String registeredby;
|
||||
protected String subjects;
|
||||
protected String aggregator = "OPENAIRE";
|
||||
protected String collectedfrom;
|
||||
protected Boolean managed;
|
||||
protected Boolean consentTermsOfUse;
|
||||
protected Boolean fullTextDownload;
|
||||
protected Date consentTermsOfUseDate;
|
||||
protected Date lastConsentTermsOfUseDate;
|
||||
protected Set<OrganizationDetails> organizations;
|
||||
protected Set<IdentitiesDetails> identities;
|
||||
protected String status;
|
||||
protected String typology;
|
||||
protected Date registrationdate;
|
||||
|
||||
public DatasourceDetails() {
|
||||
// no arg constructor
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOpenaireId() {
|
||||
return openaireId;
|
||||
}
|
||||
|
||||
public void setOpenaireId(String openaireId) {
|
||||
this.openaireId = openaireId;
|
||||
}
|
||||
|
||||
public String getOfficialname() {
|
||||
return officialname;
|
||||
}
|
||||
|
||||
public void setOfficialname(String officialname) {
|
||||
this.officialname = officialname;
|
||||
}
|
||||
|
||||
public String getEnglishname() {
|
||||
return englishname;
|
||||
}
|
||||
|
||||
public void setEnglishname(String englishname) {
|
||||
this.englishname = englishname;
|
||||
}
|
||||
|
||||
public String getWebsiteurl() {
|
||||
return websiteurl;
|
||||
}
|
||||
|
||||
public void setWebsiteurl(String websiteurl) {
|
||||
this.websiteurl = websiteurl;
|
||||
}
|
||||
|
||||
public String getLogourl() {
|
||||
return logourl;
|
||||
}
|
||||
|
||||
public void setLogourl(String logourl) {
|
||||
this.logourl = logourl;
|
||||
}
|
||||
|
||||
public String getContactemail() {
|
||||
return contactemail;
|
||||
}
|
||||
|
||||
public void setContactemail(String contactemail) {
|
||||
this.contactemail = contactemail;
|
||||
}
|
||||
|
||||
public Double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(Double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public Double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(Double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getNamespaceprefix() {
|
||||
return namespaceprefix;
|
||||
}
|
||||
|
||||
public void setNamespaceprefix(String namespaceprefix) {
|
||||
this.namespaceprefix = namespaceprefix;
|
||||
}
|
||||
|
||||
public String getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
public void setLanguages(String languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
public Date getDateofvalidation() {
|
||||
return dateofvalidation;
|
||||
}
|
||||
|
||||
public void setDateofvalidation(Date dateofvalidation) {
|
||||
this.dateofvalidation = dateofvalidation;
|
||||
}
|
||||
|
||||
public String getEoscDatasourceType() {
|
||||
return eoscDatasourceType;
|
||||
}
|
||||
|
||||
public void setEoscDatasourceType(String eoscDatasourceType) {
|
||||
this.eoscDatasourceType = eoscDatasourceType;
|
||||
}
|
||||
|
||||
public Date getDateofcollection() {
|
||||
return dateofcollection;
|
||||
}
|
||||
|
||||
public void setDateofcollection(Date dateofcollection) {
|
||||
this.dateofcollection = dateofcollection;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getActivationId() {
|
||||
return activationId;
|
||||
}
|
||||
|
||||
public void setActivationId(String activationId) {
|
||||
this.activationId = activationId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getIssn() {
|
||||
return issn;
|
||||
}
|
||||
|
||||
public void setIssn(String issn) {
|
||||
this.issn = issn;
|
||||
}
|
||||
|
||||
public String getEissn() {
|
||||
return eissn;
|
||||
}
|
||||
|
||||
public void setEissn(String eissn) {
|
||||
this.eissn = eissn;
|
||||
}
|
||||
|
||||
public String getLissn() {
|
||||
return lissn;
|
||||
}
|
||||
|
||||
public void setLissn(String lissn) {
|
||||
this.lissn = lissn;
|
||||
}
|
||||
|
||||
public String getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
||||
|
||||
public void setRegisteredby(String registeredby) {
|
||||
this.registeredby = registeredby;
|
||||
}
|
||||
|
||||
public String getSubjects() {
|
||||
return subjects;
|
||||
}
|
||||
|
||||
public void setSubjects(String subjects) {
|
||||
this.subjects = subjects;
|
||||
}
|
||||
|
||||
public String getAggregator() {
|
||||
return aggregator;
|
||||
}
|
||||
|
||||
public void setAggregator(String aggregator) {
|
||||
this.aggregator = aggregator;
|
||||
}
|
||||
|
||||
public String getCollectedfrom() {
|
||||
return collectedfrom;
|
||||
}
|
||||
|
||||
public void setCollectedfrom(String collectedfrom) {
|
||||
this.collectedfrom = collectedfrom;
|
||||
}
|
||||
|
||||
public Boolean getManaged() {
|
||||
return managed;
|
||||
}
|
||||
|
||||
public void setManaged(Boolean managed) {
|
||||
this.managed = managed;
|
||||
}
|
||||
|
||||
public Boolean getConsentTermsOfUse() {
|
||||
return consentTermsOfUse;
|
||||
}
|
||||
|
||||
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
|
||||
this.consentTermsOfUse = consentTermsOfUse;
|
||||
}
|
||||
|
||||
public Boolean getFullTextDownload() {
|
||||
return fullTextDownload;
|
||||
}
|
||||
|
||||
public void setFullTextDownload(Boolean fullTextDownload) {
|
||||
this.fullTextDownload = fullTextDownload;
|
||||
}
|
||||
|
||||
public Date getConsentTermsOfUseDate() {
|
||||
return consentTermsOfUseDate;
|
||||
}
|
||||
|
||||
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) {
|
||||
this.consentTermsOfUseDate = consentTermsOfUseDate;
|
||||
}
|
||||
|
||||
public Date getLastConsentTermsOfUseDate() {
|
||||
return lastConsentTermsOfUseDate;
|
||||
}
|
||||
|
||||
public void setLastConsentTermsOfUseDate(Date lastConsentTermsOfUseDate) {
|
||||
this.lastConsentTermsOfUseDate = lastConsentTermsOfUseDate;
|
||||
}
|
||||
|
||||
public Set<OrganizationDetails> getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
||||
public void setOrganizations(Set<OrganizationDetails> organizations) {
|
||||
this.organizations = organizations;
|
||||
}
|
||||
|
||||
public Set<IdentitiesDetails> getIdentities() {
|
||||
return identities;
|
||||
}
|
||||
|
||||
public void setIdentities(Set<IdentitiesDetails> identities) {
|
||||
this.identities = identities;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
public void setTypology(String typology) {
|
||||
this.typology = typology;
|
||||
}
|
||||
|
||||
public Date getRegistrationdate() {
|
||||
return registrationdate;
|
||||
}
|
||||
|
||||
public void setRegistrationdate(Date registrationdate) {
|
||||
this.registrationdate = registrationdate;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/17/15.
|
||||
*/
|
||||
public class DatasourceRegistrationState extends WizardState {
|
||||
|
||||
private String mode;
|
||||
private String selectedRepositoryId;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
public DatasourceRegistrationState() {
|
||||
}
|
||||
|
||||
public DatasourceRegistrationState(String mode, String selectedRepositoryId, Repository repository) {
|
||||
this.mode = mode;
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getSelectedRepositoryId() {
|
||||
return selectedRepositoryId;
|
||||
}
|
||||
|
||||
public void setSelectedRepositoryId(String selectedRepositoryId) {
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DatasourceResponse extends Response {
|
||||
|
||||
private List<DatasourceDetails> datasourceInfo = Lists.newArrayList();
|
||||
|
||||
public DatasourceResponse addDatasourceInfo(final DatasourceDetails datasourceInfo) {
|
||||
getDatasourceInfo().add(datasourceInfo);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<DatasourceDetails> getDatasourceInfo() {
|
||||
return datasourceInfo;
|
||||
}
|
||||
|
||||
public DatasourceResponse setDatasourceInfo(final List<DatasourceDetails> datasourceInfo) {
|
||||
this.datasourceInfo = datasourceInfo;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 21/12/15.
|
||||
*/
|
||||
public class DatasourceVocabularies{
|
||||
|
||||
private Map<String, String> countries;
|
||||
private List<Timezone> timezones;
|
||||
private Map<String, String> datasourceClasses;
|
||||
private List<String> typologies;
|
||||
private Map<String, String> compatibilityLevels;
|
||||
|
||||
public DatasourceVocabularies() {
|
||||
}
|
||||
|
||||
public Map<String, String> getCountries() {
|
||||
return countries;
|
||||
}
|
||||
|
||||
public void setCountries(Map<String, String> countries) {
|
||||
this.countries = countries;
|
||||
}
|
||||
|
||||
public List<Timezone> getTimezones() {
|
||||
return timezones;
|
||||
}
|
||||
|
||||
public void setTimezones(List<Timezone> timezones) {
|
||||
this.timezones = timezones;
|
||||
}
|
||||
|
||||
public Map<String, String> getDatasourceClasses() {
|
||||
return datasourceClasses;
|
||||
}
|
||||
|
||||
public void setDatasourceClasses(Map<String, String> datasourceClasses) {
|
||||
this.datasourceClasses = datasourceClasses;
|
||||
}
|
||||
|
||||
public List<String> getTypologies() {
|
||||
return typologies;
|
||||
}
|
||||
|
||||
public void setTypologies(List<String> typologies) {
|
||||
this.typologies = typologies;
|
||||
}
|
||||
|
||||
public Map<String, String> getCompatibilityLevels() {
|
||||
return compatibilityLevels;
|
||||
}
|
||||
|
||||
public void setCompatibilityLevels(Map<String, String> compatibilityLevels) {
|
||||
this.compatibilityLevels = compatibilityLevels;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Header {
|
||||
|
||||
private long total;
|
||||
private int page;
|
||||
private int size;
|
||||
private long time;
|
||||
private int statusCode;
|
||||
private List<String> errors = Lists.newArrayList();
|
||||
|
||||
private Queue<Throwable> exceptions = Lists.newLinkedList();
|
||||
public static Header newInsance() {
|
||||
return new Header();
|
||||
}
|
||||
public Header() {
|
||||
}
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
public Header setTime(final long time) {
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
public Header setStatusCode(final int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
public Header setPage(final int page) {
|
||||
this.page = page;
|
||||
return this;
|
||||
}
|
||||
public Header setSize(final int size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
public Header setTotal(final long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
public Queue<Throwable> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
public Header setExceptions(final Queue<Throwable> exceptions) {
|
||||
this.exceptions = exceptions;
|
||||
return this;
|
||||
}
|
||||
public List<String> getErrors() {
|
||||
return getExceptions().stream()
|
||||
.map(Throwable::getMessage)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
public Header setErrors(final List<String> errors) {
|
||||
this.errors = errors;
|
||||
return this;
|
||||
}
|
||||
public String toJson() {
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public class IdentitiesDetails {
|
||||
private String pid;
|
||||
private String issuertype;
|
||||
|
||||
public IdentitiesDetails() {
|
||||
// no arg constructor
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public String getIssuertype() {
|
||||
return issuertype;
|
||||
}
|
||||
|
||||
public IdentitiesDetails setPid(final String pid) {
|
||||
this.pid = pid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IdentitiesDetails setIssuertype(final String issuertype) {
|
||||
this.issuertype = issuertype;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public class OrganizationDetails {
|
||||
|
||||
private String legalshortname;
|
||||
private String legalname;
|
||||
private String websiteurl;
|
||||
private String logourl;
|
||||
private String country;
|
||||
|
||||
public OrganizationDetails() {
|
||||
// no arg constructor
|
||||
}
|
||||
|
||||
public String getLegalshortname() {
|
||||
return legalshortname;
|
||||
}
|
||||
|
||||
public void setLegalshortname(String legalshortname) {
|
||||
this.legalshortname = legalshortname;
|
||||
}
|
||||
|
||||
public String getLegalname() {
|
||||
return legalname;
|
||||
}
|
||||
|
||||
public void setLegalname(String legalname) {
|
||||
this.legalname = legalname;
|
||||
}
|
||||
|
||||
public String getWebsiteurl() {
|
||||
return websiteurl;
|
||||
}
|
||||
|
||||
public void setWebsiteurl(String websiteurl) {
|
||||
this.websiteurl = websiteurl;
|
||||
}
|
||||
|
||||
public String getLogourl() {
|
||||
return logourl;
|
||||
}
|
||||
|
||||
public void setLogourl(String logourl) {
|
||||
this.logourl = logourl;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.DataCollectionType;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The domain object for the Repository resource data structure
|
||||
*
|
||||
*/
|
||||
public class Repository extends DatasourceDetails {
|
||||
private static final long serialVersionUID = -7241644234046760972L;
|
||||
|
||||
private List<RepositoryInterface> interfaces = new ArrayList<>();
|
||||
|
||||
private static List<DataCollectionType> dataCollectionTypes = new ArrayList<>();
|
||||
|
||||
private PiwikInfo piwikInfo;
|
||||
|
||||
public Repository() {
|
||||
}
|
||||
|
||||
public List<RepositoryInterface> getInterfaces() {
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
public void setInterfaces(List<RepositoryInterface> interfaces) {
|
||||
this.interfaces = interfaces;
|
||||
}
|
||||
|
||||
public Double getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(Double timezone) throws IllegalArgumentException {
|
||||
if (timezone < -12 || timezone > 12 || (timezone % 0.5) != 0) {
|
||||
String t = String.valueOf(timezone);
|
||||
throw new IllegalArgumentException(
|
||||
"timezone must be in the range [-12.0, 12.0] and must me divided by 0.5. Value given is "
|
||||
+ t);
|
||||
}
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public List<DataCollectionType> getDataCollectionTypes() {
|
||||
return dataCollectionTypes;
|
||||
}
|
||||
|
||||
public void setDataCollectionTypes(
|
||||
List<DataCollectionType> dataCollectionTypes) {
|
||||
this.dataCollectionTypes = dataCollectionTypes;
|
||||
}
|
||||
|
||||
public PiwikInfo getPiwikInfo() {
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
public void setPiwikInfo(PiwikInfo piwikInfo) {
|
||||
this.piwikInfo = piwikInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return officialname.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Repository))
|
||||
return false;
|
||||
else
|
||||
return this.equals((Repository) o);
|
||||
}
|
||||
|
||||
public boolean equals(Repository r) {
|
||||
// TODO: fill with required fields...
|
||||
|
||||
if (this.getEnglishname() != null && r.getEnglishname() == null) {
|
||||
return false;
|
||||
} else if (this.getEnglishname() == null
|
||||
&& r.getEnglishname() != null) {
|
||||
return false;
|
||||
} else if (this.getEnglishname() != null
|
||||
&& r.getEnglishname() != null) {
|
||||
return this.getEnglishname().equals(r.getEnglishname());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RepositoryInterface extends ApiDetails {
|
||||
|
||||
private static final long serialVersionUID = 8013272950607614479L;
|
||||
|
||||
public void updateApiParam(String param, String value) {
|
||||
for (ApiParamDetails entry : apiParams) {
|
||||
if (entry.getParam().equals(param)) {
|
||||
entry.setValue(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ApiParamDetails newSet = new ApiParamDetails();
|
||||
newSet.setParam(param);
|
||||
newSet.setValue(value);
|
||||
this.apiParams.add(newSet);
|
||||
}
|
||||
|
||||
public void setAccessSet(String accessSet) {
|
||||
if (accessSet != null) {
|
||||
updateApiParam("set", accessSet);
|
||||
}
|
||||
}
|
||||
|
||||
public String getAccessSet() {
|
||||
Map<String, String> map;
|
||||
if (apiParams != null) {
|
||||
map = apiParams.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(k -> k.getParam() == null && k.getValue() == null)
|
||||
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
|
||||
return map.get("set");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessFormat(String accessFormat) {
|
||||
updateApiParam("format", accessFormat);
|
||||
}
|
||||
|
||||
public String getAccessFormat() {
|
||||
Map<String, String> map;
|
||||
if (apiParams != null) {
|
||||
map = apiParams.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(k -> k.getParam() == null && k.getValue() == null)
|
||||
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
|
||||
return map.get("format");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ package eu.dnetlib.repo.manager.domain;
|
|||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
public class RepositorySnippet {
|
||||
|
||||
|
@ -12,18 +13,18 @@ public class RepositorySnippet {
|
|||
private String officialname;
|
||||
private String englishname;
|
||||
private String websiteurl;
|
||||
private String typology;
|
||||
|
||||
private String registeredby;
|
||||
private Organization[] organizations;
|
||||
private String registrationdate;
|
||||
private Date registrationdate;
|
||||
private String eoscDatasourceType;
|
||||
private String logoUrl;
|
||||
private String description;
|
||||
private String fullTextDownload;
|
||||
private String consentTermsOfUse;
|
||||
private Boolean consentTermsOfUse;
|
||||
private Date consentTermsOfUseDate;
|
||||
|
||||
private Date lastConsentTermsOfUseDate;
|
||||
private String eoscDatasourceType;
|
||||
private Boolean fullTextDownload;
|
||||
private Set<OrganizationDetails> organizations;
|
||||
private String typology;
|
||||
|
||||
|
||||
private PiwikInfo piwikInfo;
|
||||
|
@ -79,19 +80,18 @@ public class RepositorySnippet {
|
|||
this.typology = typology;
|
||||
}
|
||||
|
||||
public Organization[] getOrganizations() {
|
||||
public Set<OrganizationDetails> getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
||||
public void setOrganizations(Organization[] organizations) {
|
||||
public void setOrganizations(Set<OrganizationDetails> organizations) {
|
||||
this.organizations = organizations;
|
||||
}
|
||||
|
||||
public String getRegistrationdate() {
|
||||
public Date getRegistrationdate() {
|
||||
return registrationdate;
|
||||
}
|
||||
|
||||
public void setRegistrationdate(String registrationdate) {
|
||||
public void setRegistrationdate(Date registrationdate) {
|
||||
this.registrationdate = registrationdate;
|
||||
}
|
||||
|
||||
|
@ -119,19 +119,19 @@ public class RepositorySnippet {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFullTextDownload() {
|
||||
public Boolean getFullTextDownload() {
|
||||
return fullTextDownload;
|
||||
}
|
||||
|
||||
public void setFullTextDownload(String fullTextDownload) {
|
||||
public void setFullTextDownload(Boolean fullTextDownload) {
|
||||
this.fullTextDownload = fullTextDownload;
|
||||
}
|
||||
|
||||
public String getConsentTermsOfUse() {
|
||||
public Boolean getConsentTermsOfUse() {
|
||||
return consentTermsOfUse;
|
||||
}
|
||||
|
||||
public void setConsentTermsOfUse(String consentTermsOfUse) {
|
||||
public void setConsentTermsOfUse(Boolean consentTermsOfUse) {
|
||||
this.consentTermsOfUse = consentTermsOfUse;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ public class RequestFilter{
|
|||
|
||||
private String registeredby = null;
|
||||
private String typology = null;
|
||||
private String eoscDatasourceType = null;
|
||||
private String country = null;
|
||||
private String id = null;
|
||||
private String officialname = null;
|
||||
|
@ -28,6 +29,14 @@ public class RequestFilter{
|
|||
this.typology = typology;
|
||||
}
|
||||
|
||||
public String getEoscDatasourceType() {
|
||||
return eoscDatasourceType;
|
||||
}
|
||||
|
||||
public void setEoscDatasourceType(String eoscDatasourceType) {
|
||||
this.eoscDatasourceType = eoscDatasourceType;
|
||||
}
|
||||
|
||||
public String getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public class Response {
|
||||
|
||||
private Header header;
|
||||
|
||||
public Response() {
|
||||
this.header = new Header();
|
||||
}
|
||||
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public Response setHeader(final Header header) {
|
||||
this.header = header;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class ValidationState extends WizardState {
|
||||
|
||||
private JobForValidation jobForValidation = new JobForValidation();
|
||||
|
||||
public JobForValidation getJobForValidation() {
|
||||
return jobForValidation;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class WizardState {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
|
||||
/**
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import org.json.JSONException;
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.repo.manager.domain.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||
|
|
|
@ -2,6 +2,8 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.utils.MailLibrary;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
|
@ -169,11 +169,11 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "]" +
|
||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
||||
" to the OpenAIRE compliant list of content providers. " +
|
||||
"\n\n" +
|
||||
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
||||
|
@ -195,12 +195,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
|
||||
"\n" +
|
||||
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "]" +
|
||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
||||
" to the OpenAIRE compliant list of content providers. " +
|
||||
"\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
|
@ -209,10 +209,10 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -221,15 +221,15 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to add the following interface: \n\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||
"to " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n";
|
||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||
|
||||
if (comment != null)
|
||||
message += "\nThe users comment was '" + comment + "'\n";
|
||||
|
@ -256,15 +256,15 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
|
||||
"\n" +
|
||||
"We received a request to add the following interface: \n\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||
"to " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n";
|
||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||
|
||||
if (comment != null) {
|
||||
message += "\n Your comment was '" + comment + "'\n";
|
||||
|
@ -278,10 +278,10 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -290,20 +290,20 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"\n\n" +
|
||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
|
@ -311,10 +311,10 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -323,19 +323,19 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear admin ,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"\n\n" +
|
||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
|
@ -347,7 +347,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(this.provideAdminEmail, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -356,19 +356,19 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was not successful and the registration process was interrupted."+
|
||||
"\n\n" +
|
||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
|
@ -376,10 +376,10 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -388,19 +388,19 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was not successful and the registration process was interrupted."+
|
||||
"\n\n" +
|
||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
|
@ -412,7 +412,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(this.provideAdminEmail, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -421,18 +421,18 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on [" + repository.getOfficialName()+"] has been successful\n\n" +
|
||||
"the compatibility test on [" + repository.getOfficialname()+"] has been successful\n\n" +
|
||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
|
@ -452,17 +452,17 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on [" + repository.getOfficialName()+"] has been successful\n\n" +
|
||||
"the compatibility test on [" + repository.getOfficialname()+"] has been successful\n\n" +
|
||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
|
@ -483,20 +483,20 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was not successful."+
|
||||
"\n\n" +
|
||||
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
|
@ -507,7 +507,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(issuer, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -516,19 +516,19 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialName() + "]" +
|
||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||
" was not successful."+
|
||||
"\n\n" +
|
||||
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialname() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
|
@ -540,7 +540,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(this.provideAdminEmail, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseUrl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialName()+") failed to complete." +
|
||||
"the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseurl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialname()+") failed to complete." +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
@ -615,11 +615,11 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update information for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to update the basic information for " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n\n" +
|
||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"Regards,\n" +
|
||||
|
@ -637,22 +637,22 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update information for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"We received a request to update the basic information for " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n\n" +
|
||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\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);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -661,15 +661,15 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to update the following interface: \n\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||
"for " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n";
|
||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||
|
||||
if (comment != null)
|
||||
message += "\nThe users comment was '" + comment + "'\n";
|
||||
|
@ -694,16 +694,16 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE interface update request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getOfficialName() + "]";
|
||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"We received a request to update the following interface: \n\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
|
||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
|
||||
"for " + repository.getDatasourceType() + "[" + repository.getOfficialName() + "].\n";
|
||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||
|
||||
if (comment != null) {
|
||||
message += "\n Your comment was '" + comment + "'\n";
|
||||
|
@ -716,10 +716,10 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message);
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package eu.dnetlib.repo.manager.service;
|
|||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -2,10 +2,10 @@ package eu.dnetlib.repo.manager.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
@ -82,8 +83,6 @@ public interface RepositoryService {
|
|||
String page,
|
||||
String size);
|
||||
|
||||
List<String> getDatasourceVocabularies(String mode);
|
||||
|
||||
Map<String, String> getCompatibilityClasses(String mode);
|
||||
|
||||
Map<String, String> getDatasourceClasses(String mode);
|
||||
|
|
|
@ -5,12 +5,14 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||
|
@ -72,16 +74,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
@Value("${services.provide.usageStatisticsNumbersBaseURL}")
|
||||
private String usageStatisticsNumbersBaseURL;
|
||||
|
||||
private final Converter converter;
|
||||
|
||||
private static final Map<String, List<String>> dataSourceClass = new HashMap<>();
|
||||
private static final Map<String, String> invertedDataSourceClass = new HashMap<>();
|
||||
|
||||
|
||||
private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"};
|
||||
private final String[] vocabularyNames = {"dnet:countries", "dnet:eosc_datasource_types", "dnet:compatibilityLevel"};
|
||||
private final Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<>();
|
||||
private final Map<String, String> countriesMap = new HashMap<>();
|
||||
private final Map<String, String> inverseCountriesMap = new HashMap<>();
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
@Autowired
|
||||
|
@ -91,6 +93,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
AuthoritiesUpdater authoritiesUpdater,
|
||||
VocabularyLoader vocabularyLoader,
|
||||
RestTemplate restTemplate,
|
||||
Converter converter,
|
||||
@Lazy EmailUtils emailUtils,
|
||||
@Lazy ValidatorService validatorService,
|
||||
@Lazy PiWikService piWikService) {
|
||||
|
@ -100,6 +103,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
this.authoritiesUpdater = authoritiesUpdater;
|
||||
this.vocabularyLoader = vocabularyLoader;
|
||||
this.piWikService = piWikService;
|
||||
this.converter = converter;
|
||||
this.emailUtils = emailUtils;
|
||||
this.validatorService = validatorService;
|
||||
this.restTemplate = restTemplate;
|
||||
|
@ -115,8 +119,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
dataSourceClass.putIfAbsent("aggregator", new ArrayList<>());
|
||||
dataSourceClass.get("aggregator").add(key);
|
||||
} else if (key.contains("crissystem")) {
|
||||
dataSourceClass.putIfAbsent("cris", new ArrayList<>());
|
||||
dataSourceClass.get("cris").add(key);
|
||||
dataSourceClass.putIfAbsent("dris", new ArrayList<>());
|
||||
dataSourceClass.get("dris").add(key);
|
||||
} else if (key.contains("pubsrepository::journal")) { // do not change order -->
|
||||
dataSourceClass.putIfAbsent("journal", Collections.singletonList("pubsrepository::journal"));
|
||||
} else if (key.contains("pubsrepository")) { // do not change order <--
|
||||
|
@ -175,9 +179,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
for (String repoId : ids) {
|
||||
requestFilter.setId(repoId);
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
List<Repository> rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, List.class);
|
||||
|
||||
repos.addAll(Converter.jsonToRepositoryList(new JSONObject(rs)));
|
||||
// repos.addAll(converter.toRepositoryList(new JSONObject(rs)));
|
||||
}
|
||||
|
||||
for (Repository r : repos)
|
||||
|
@ -239,12 +243,10 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String filterKey = "UNKNOWN";
|
||||
if (mode.equalsIgnoreCase("opendoar"))
|
||||
filterKey = "openaire____::opendoar";
|
||||
else if (mode.equalsIgnoreCase("re3data"))
|
||||
filterKey = "openaire____::re3data";
|
||||
if (mode.equalsIgnoreCase("repository"))
|
||||
filterKey = "Repository";
|
||||
else if (mode.equalsIgnoreCase("cris"))
|
||||
filterKey = "eurocrisdris::dris";
|
||||
filterKey = "CRIS system";
|
||||
|
||||
|
||||
LOGGER.debug("Country code equals : " + country);
|
||||
|
@ -253,7 +255,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setCollectedfrom(filterKey);
|
||||
requestFilter.setEoscDatasourceType(filterKey);
|
||||
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
@ -309,15 +311,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -338,21 +333,33 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
@Override
|
||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size) throws Exception {
|
||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
|
||||
return getRepositoriesSnippets(new ArrayList<>(repoIds));
|
||||
return getRepositoriesSnippetsOfUser(null, page, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception {
|
||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail));
|
||||
return getRepositoriesSnippets(new ArrayList<>(repoIds));
|
||||
int from = Integer.parseInt(page) * Integer.parseInt(size);
|
||||
int to = from + Integer.parseInt(size);
|
||||
List<String> repoIds = new ArrayList<>();
|
||||
if (userEmail != null && !"".equals(userEmail)) {
|
||||
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail)));
|
||||
} else {
|
||||
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles()));
|
||||
}
|
||||
|
||||
if (repoIds.size() < from) {
|
||||
return Collections.emptyList();
|
||||
} else if (repoIds.size() < to) {
|
||||
to = repoIds.size();
|
||||
}
|
||||
return getRepositoriesSnippets(repoIds.subList(from, to)); // FIXME: returns less results if some repos are not found
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException {
|
||||
|
||||
LOGGER.debug("Retrieving repositories with id : " + id);
|
||||
RepositorySnippet repo = null;
|
||||
RepositorySnippet repo;
|
||||
UriComponents uriComponents = searchSnipperDatasource("0", "100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
@ -363,7 +370,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
if (jsonArray.length() == 0)
|
||||
throw new ResourceNotFoundException();
|
||||
|
||||
repo = Converter.jsonToRepositorySnippetObject(jsonArray.getJSONObject(0));
|
||||
repo = converter.toRepositorySnippet(jsonArray.getJSONObject(0));
|
||||
return repo;
|
||||
}
|
||||
|
||||
|
@ -371,19 +378,25 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
public Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException {
|
||||
|
||||
LOGGER.debug("Retrieving repositories with id : " + id);
|
||||
Repository repo = null;
|
||||
Repository repo;
|
||||
UriComponents uriComponents = searchDatasource("0", "100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
// String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
// JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
||||
if (jsonArray.length() == 0)
|
||||
DatasourceResponse response;
|
||||
response = (DatasourceResponse) restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||
List<DatasourceDetails> datasources = response.getDatasourceInfo();
|
||||
if (datasources.size() == 0)
|
||||
throw new ResourceNotFoundException();
|
||||
|
||||
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
|
||||
return updateRepositoryInfo(repo);
|
||||
// repo = converter.toRepository(jsonArray.getJSONObject(0));
|
||||
// return updateRepositoryInfo(repo);
|
||||
|
||||
return updateRepositoryInfo(converter.toRepository(datasources.get(0)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -396,12 +409,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
JSONArray aggregationInfo = new JSONObject(rs).getJSONArray("aggregationInfo");
|
||||
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>(Converter.getAggregationHistoryFromJson(aggregationInfo));
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>(converter.toAggregationHistory(aggregationInfo));
|
||||
|
||||
return aggregationHistory;
|
||||
// return aggregationHistory.size() == 0 ? aggregationHistory : aggregationHistory.stream()
|
||||
// .sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
// .collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -444,7 +454,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
requestFilter.setOfficialname(name);
|
||||
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
List<Repository> repos = converter.toRepositoryList(new JSONObject(rs));
|
||||
for (Repository r : repos)
|
||||
updateRepositoryInfo(r);
|
||||
return repos;
|
||||
|
@ -459,8 +469,10 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
|
||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
|
||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
ApiDetailsResponse rs = restTemplate.getForObject(uriComponents.toUri(), ApiDetailsResponse.class);
|
||||
|
||||
return converter.toRepositoryInterfaceList(rs.getApi());
|
||||
|
||||
}
|
||||
|
||||
|
@ -469,26 +481,37 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
repository.setActivationId(UUID.randomUUID().toString());
|
||||
repository.setCollectedFrom("infrastruct_::openaire");
|
||||
repository.setCollectedfrom("infrastruct_::openaire");
|
||||
|
||||
// Date now = new Date();
|
||||
// repository.setRegistrationdate(now);
|
||||
// repository.setConsentTermsOfUseDate(now);
|
||||
// repository.setLastConsentTermsOfUseDate(now);
|
||||
|
||||
if (datatype.equals("journal")) {
|
||||
repository.setEoscDatasourceType("Journal archive");
|
||||
repository.setId("openaire____::issn" + repository.getIssn());
|
||||
repository.setNamespacePrefix("issn" + repository.getIssn());
|
||||
repository.setNamespaceprefix("issn" + repository.getIssn());
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
} else if (datatype.equals("aggregator")) {
|
||||
repository.setId("openaire____::" + DigestUtils.md5Hex(repository.getOfficialName()));
|
||||
repository.setNamespacePrefix(DigestUtils.md5Hex(repository.getOfficialName()).substring(0, 12));
|
||||
repository.setEoscDatasourceType("Aggregator");
|
||||
repository.setId("openaire____::" + DigestUtils.md5Hex(repository.getOfficialname()));
|
||||
repository.setNamespaceprefix(DigestUtils.md5Hex(repository.getOfficialname()).substring(0, 12));
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
} else {
|
||||
if (repository.getTypology().contains("crissystem")) {
|
||||
repository.setEoscDatasourceType("CRIS system");
|
||||
} else {
|
||||
repository.setEoscDatasourceType("Repository");
|
||||
}
|
||||
this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
// TODO: move the following code elsewhere (creation and assignment of role to user) ??
|
||||
// Create new role
|
||||
String newRoleName = roleMappingService.getRoleIdByRepoId(repository.getId());
|
||||
Role newRole = new Role(newRoleName, repository.getOfficialName());
|
||||
Role newRole = new Role(newRoleName, repository.getOfficialname());
|
||||
Integer couId = null;
|
||||
try {
|
||||
couId = registryCalls.createRole(newRole);
|
||||
|
@ -529,10 +552,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
.build()
|
||||
.encode();
|
||||
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
LOGGER.debug("JSON to add(update) -> " + json_repository);
|
||||
// FIXME: problematic
|
||||
// String json_repository = converter.toJson(repository);
|
||||
// LOGGER.debug("JSON to add(update) -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<>(json_repository, httpHeaders);
|
||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders); // TODO: check if it works (Repository contains extra fields)
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
|
@ -555,11 +579,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
.build()
|
||||
.encode();
|
||||
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
// FIXME: problematic
|
||||
// String json_repository = converter.toJson(repository);
|
||||
// LOGGER.debug("JSON to update -> " + json_repository);
|
||||
|
||||
LOGGER.debug("JSON to update -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity
|
||||
, ResponseEntity.class);
|
||||
|
||||
|
@ -580,16 +604,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
Date utilDate = new Date();
|
||||
Timestamp date = new Timestamp(utilDate.getTime());
|
||||
repository.setDateOfCollection(date);
|
||||
repository.setDateofcollection(date);
|
||||
repository.setAggregator("OPENAIRE");
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
// 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);
|
||||
// String json_repository = converter.toJson(repository);
|
||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
|
@ -622,14 +646,14 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
||||
Repository e = this.getRepositoryById(repoId);
|
||||
repositoryInterface = createRepositoryInterface(e, repositoryInterface, datatype);
|
||||
String json_interface = Converter.repositoryInterfaceObjectToJson(e, repositoryInterface);
|
||||
// String json_interface = converter.toJson(e, repositoryInterface);
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<>(json_interface, httpHeaders);
|
||||
HttpEntity<RepositoryInterface> httpEntity = new HttpEntity<>(repositoryInterface, httpHeaders);
|
||||
|
||||
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
|
||||
|
||||
|
@ -650,8 +674,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
String registeredBy,
|
||||
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
||||
|
||||
this.updateBaseUrl(repoId, repositoryInterface.getId(), repositoryInterface.getBaseUrl());
|
||||
this.updateCompliance(repoId, repositoryInterface.getId(), repositoryInterface.getCompliance());
|
||||
this.updateBaseUrl(repoId, repositoryInterface.getId(), repositoryInterface.getBaseurl());
|
||||
this.updateCompliance(repoId, repositoryInterface.getId(), repositoryInterface.getCompatibility());
|
||||
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
||||
|
||||
Repository repository = this.getRepositoryById(repoId);
|
||||
|
@ -676,12 +700,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
job.setActivationId(UUID.randomUUID().toString());
|
||||
job.setAdminEmails(Collections.singletonList(this.adminEmail));
|
||||
job.setBaseUrl(iFace.getBaseUrl());
|
||||
job.setBaseUrl(iFace.getBaseurl());
|
||||
job.setDatasourceId(repo.getId());
|
||||
job.setDesiredCompatibilityLevel(iFace.getDesiredCompatibilityLevel());
|
||||
job.setDesiredCompatibilityLevel(iFace.getCompatibilityOverride());
|
||||
job.setInterfaceId(iFace.getId());
|
||||
job.setOfficialName(repo.getOfficialName());
|
||||
job.setRepoType(repo.getDatasourceType());
|
||||
job.setOfficialName(repo.getOfficialname());
|
||||
job.setRepoType(repo.getEoscDatasourceType());
|
||||
job.setUserEmail(userEmail);
|
||||
job.setValidationSet((iFace.getAccessSet().isEmpty() ? "none" : iFace.getAccessSet()));
|
||||
job.setRecords(-1);
|
||||
|
@ -693,8 +717,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
iFace.setCompliance("UNKNOWN");
|
||||
iFace.setDatasource(repo.getId());
|
||||
iFace.setContentdescription("metadata");
|
||||
iFace.setCompatibility("UNKNOWN");
|
||||
|
||||
if (datatype.equals("re3data"))
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
|
@ -702,8 +727,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
iFace.setAccessFormat("oai_dc");
|
||||
|
||||
|
||||
if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty())
|
||||
iFace.setTypology(repo.getDatasourceClass());
|
||||
// FIXME: this will probably not work
|
||||
if (repo.getEoscDatasourceType() != null && !repo.getEoscDatasourceType().isEmpty())
|
||||
iFace.setTypology(repo.getEoscDatasourceType());
|
||||
else if (datatype.equalsIgnoreCase("journal"))
|
||||
iFace.setTypology("pubsrepository::journal");
|
||||
else if (datatype.equalsIgnoreCase("aggregator"))
|
||||
|
@ -714,12 +740,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
iFace.setTypology("datarepository::unknown");
|
||||
|
||||
iFace.setRemovable(true);
|
||||
iFace.setAccessProtocol("oai");
|
||||
iFace.setProtocol("oai");
|
||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
// iFace.removeAccessSet();
|
||||
iFace.setAccessSet("none");
|
||||
}
|
||||
return iFace;
|
||||
|
@ -728,18 +754,18 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
@Override
|
||||
public List<String> getDnetCountries() {
|
||||
LOGGER.debug("Getting dnet-countries!");
|
||||
return Converter.readFile("countries.txt");
|
||||
return converter.readFile("countries.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypologies() {
|
||||
return Converter.readFile("typologies.txt");
|
||||
return converter.readFile("typologies.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Timezone> getTimezones() {
|
||||
List<String> timezones = Converter.readFile("timezones.txt");
|
||||
return Converter.toTimezones(timezones);
|
||||
List<String> timezones = converter.readFile("timezones.txt");
|
||||
return converter.toTimezones(timezones);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -756,33 +782,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(), requestFilter, String[].class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDatasourceVocabularies(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());
|
||||
} else if (mode.equalsIgnoreCase("cris")) {
|
||||
if (entry.getKey().contains("crissystem"))
|
||||
resultSet.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private Vocabulary getVocabulary(String vocName) {
|
||||
|
||||
if (!vocabularyMap.containsKey(vocName)) {
|
||||
|
@ -834,6 +833,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
// TODO: refactor (remove?)
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
if (mode.equalsIgnoreCase("aggregator")) {
|
||||
if (entry.getKey().contains("aggregator"))
|
||||
|
@ -847,10 +847,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
if (entry.getKey().contains("datarepository"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("cris")) {
|
||||
} else if (mode.equalsIgnoreCase("dris")) {
|
||||
if (entry.getKey().contains("crissystem"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (mode.equalsIgnoreCase("fairsharing")) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
if (mode.equals("fairsharing")) {
|
||||
return retMap;
|
||||
}
|
||||
return filterResults(retMap, mode);
|
||||
|
||||
|
@ -859,11 +865,14 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
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));
|
||||
if (map != null && mode != null) {
|
||||
for (String key : map.keySet())
|
||||
if (dataSourceClass.get(mode).contains(key))
|
||||
filteredMap.put(key, map.get(key));
|
||||
|
||||
return filteredMap;
|
||||
return filteredMap;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -888,15 +897,22 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
@Override
|
||||
public Map<String, String> getListLatestUpdate(String mode) throws JSONException {
|
||||
if (mode.equals("opendoar"))
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate());
|
||||
Map<String, String> dates = new HashMap<>();
|
||||
if (mode.equals("repository")) {
|
||||
dates.put("opendoar", converter.toString(getRepositoryInterface("openaire____::opendoar").get(0).getLastCollectionDate()));
|
||||
dates.put("re3data", converter.toString(getRepositoryInterface("openaire____::re3data").get(1).getLastCollectionDate()));
|
||||
dates.put("fairsharing", converter.toString(getRepositoryInterface("openaire____::fairsharing").get(0).getLastCollectionDate()));
|
||||
return dates;
|
||||
}
|
||||
else if (mode.equals("cris"))
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate());
|
||||
return Collections.singletonMap("lastCollectionDate", converter.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
||||
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
||||
return Collections.singletonMap("lastCollectionDate", converter.toString(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());
|
||||
return Collections.singletonMap("lastCollectionDate", converter.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||
}
|
||||
|
||||
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.*;
|
||||
import eu.dnetlib.repo.manager.domain.Constants;
|
||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
|
@ -293,7 +293,11 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
@Override
|
||||
public List<StoredJob> getJobsSummary(String repoId, int limit) throws JSONException, ValidatorServiceException {
|
||||
return getValidationService().getJobSummary(repositoryService.getRepositoryInterface(repoId).stream().map(RepositoryInterface::getBaseUrl).collect(Collectors.toList()),limit);
|
||||
return getValidationService().getJobSummary(
|
||||
repositoryService.getRepositoryInterface(repoId)
|
||||
.stream()
|
||||
.map(RepositoryInterface::getBaseurl)
|
||||
.collect(Collectors.toList()), limit);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,7 @@ package eu.dnetlib.repo.manager.utils;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.Timezone;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONArray;
|
||||
|
@ -27,367 +23,67 @@ public class Converter {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(Converter.class);
|
||||
|
||||
public static Repository jsonToRepositoryObject(JSONObject repositoryObject) throws JSONException {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
Repository repository = new Repository();
|
||||
public Converter() {
|
||||
objectMapper = new ObjectMapper();
|
||||
}
|
||||
public Repository toRepository(Object repositoryObject) {
|
||||
|
||||
// JSONObject datasource = repositoryObject.getJSONObject("datasource");
|
||||
JSONObject datasource = repositoryObject;
|
||||
|
||||
//if( datasource.equals(null))
|
||||
// return null;
|
||||
|
||||
repository.setId(datasource.get("id").toString());
|
||||
repository.setOfficialName(datasource.get("officialname").toString());
|
||||
|
||||
repository.setEnglishName(datasource.get("englishname").toString());
|
||||
if (repository.getEnglishName().equals("null"))
|
||||
repository.setEnglishName("");
|
||||
|
||||
repository.setWebsiteUrl(datasource.get("websiteurl").toString());
|
||||
if (repository.getWebsiteUrl().equals("null"))
|
||||
repository.setWebsiteUrl("");
|
||||
|
||||
repository.setLogoUrl(datasource.get("logourl").toString());
|
||||
if (repository.getLogoUrl().equals("null"))
|
||||
repository.setLogoUrl("");
|
||||
|
||||
repository.setContactEmail(datasource.get("contactemail").toString());
|
||||
if (repository.getContactEmail().equals("null"))
|
||||
repository.setContactEmail("");
|
||||
|
||||
|
||||
repository.setLatitude(toDouble(datasource.get("latitude").toString()));
|
||||
repository.setLongitude(toDouble(datasource.get("longitude").toString()));
|
||||
Double timezone = toDouble(datasource.get("timezone").toString());
|
||||
repository.setTimezone(timezone != null ? timezone : 0.0);
|
||||
repository.setNamespacePrefix(datasource.get("namespaceprefix").toString());
|
||||
repository.setOdLanguages(datasource.get("languages").toString());
|
||||
repository.setDateOfValidation(convertStringToDate(datasource.get("dateofvalidation").toString()));
|
||||
|
||||
/* typology -> platform
|
||||
* datasource class -> typology */
|
||||
repository.setTypology(datasource.get("platform").toString());
|
||||
if (repository.getTypology().equals("null"))
|
||||
repository.setTypology("");
|
||||
|
||||
// // TODO: enable in future release
|
||||
// /* 07-04-2022 | "typology" -> "eoscDatasourceType" */
|
||||
// try { // FIXME: remove attemp to get typology if eoscDatasourceType fails
|
||||
// repository.setDatasourceClass(datasource.get("eoscDatasourceType").toString());
|
||||
// } catch (JSONException e) {
|
||||
// repository.setDatasourceClass(datasource.get("typology").toString());
|
||||
// }
|
||||
repository.setDatasourceClass(datasource.get("typology").toString());
|
||||
// <--
|
||||
|
||||
repository.setDateOfCollection(convertStringToDate(datasource.get("dateofcollection").toString()));
|
||||
repository.setActivationId(datasource.get("activationId").toString());
|
||||
|
||||
repository.setDescription(datasource.get("description").toString());
|
||||
if (repository.getDescription().equals("null"))
|
||||
repository.setDescription("");
|
||||
|
||||
repository.setIssn(datasource.get("issn").toString());
|
||||
repository.setLissn(datasource.get("lissn").toString());
|
||||
if (repository.getLissn().equals("null"))
|
||||
repository.setLissn("");
|
||||
repository.setEissn(datasource.get("eissn").toString());
|
||||
if (repository.getEissn().equals("null"))
|
||||
repository.setEissn("");
|
||||
repository.setRegisteredBy(datasource.get("registeredby").toString());
|
||||
|
||||
/* managed field */
|
||||
repository.setRegistered(Boolean.parseBoolean(datasource.get("managed").toString()));
|
||||
|
||||
//subjects
|
||||
|
||||
repository.setAggregator(datasource.get("aggregator").toString());
|
||||
repository.setCollectedFrom(datasource.get("collectedfrom").toString());
|
||||
|
||||
//TODO change organization to list
|
||||
JSONArray organizations = ((JSONArray) datasource.get("organizations"));
|
||||
if (organizations.length() != 0) {
|
||||
repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString());
|
||||
String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString();
|
||||
repository.setCountryCode(countryCode);
|
||||
}
|
||||
|
||||
repository.setConsentTermsOfUse(convertStringToBoolean(datasource.get("consentTermsOfUse").toString()));
|
||||
repository.setConsentTermsOfUseDate(null);
|
||||
repository.setLastConsentTermsOfUseDate(null);
|
||||
try {
|
||||
repository.setConsentTermsOfUseDate(convertStringToDate(datasource.get("consentTermsOfUseDate").toString()));
|
||||
repository.setLastConsentTermsOfUseDate(convertStringToDate(datasource.get("lastConsentTermsOfUseDate").toString()));
|
||||
} catch (JSONException e) {
|
||||
LOGGER.info("Error setting consentTermsOfUseDate date and lastConsentTermsOfUseDate", e);
|
||||
}
|
||||
repository.setFullTextDownload(convertStringToBoolean(datasource.get("fullTextDownload").toString()));
|
||||
|
||||
/* identities field */
|
||||
Repository repository = objectMapper.convertValue(repositoryObject, Repository.class);
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static Boolean convertStringToBoolean(String value) {
|
||||
return value.equals("null") ? null : Boolean.valueOf(value);
|
||||
public RepositorySnippet toRepositorySnippet(JSONObject repositorySnippetObject) {
|
||||
|
||||
RepositorySnippet snippet = objectMapper.convertValue(repositorySnippetObject, RepositorySnippet.class);
|
||||
|
||||
return snippet;
|
||||
}
|
||||
|
||||
public static Date convertStringToDate(String date) {
|
||||
|
||||
if (Objects.equals(date, "null"))
|
||||
return null;
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
return formatter.parse(date);
|
||||
} catch (ParseException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertDateToString(Date date) {
|
||||
|
||||
if (Objects.equals(date, null))
|
||||
return null;
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
public static Double toDouble(String number) {
|
||||
if (Objects.equals(number, "null"))
|
||||
return 0.0;
|
||||
else
|
||||
return Double.valueOf(number);
|
||||
}
|
||||
|
||||
public static List<RepositorySnippet> jsonToRepositorySnippetList(JSONObject json) throws JSONException {
|
||||
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
JSONArray rs = json.getJSONArray("datasourceInfo");
|
||||
for (int i = 0; i < rs.length(); i++)
|
||||
resultSet.add(jsonToRepositorySnippetObject(rs.getJSONObject(i)));
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
public static RepositorySnippet jsonToRepositorySnippetObject(JSONObject repositorySnippetObject) throws JSONException {
|
||||
|
||||
|
||||
RepositorySnippet repositorySnippet = new RepositorySnippet();
|
||||
|
||||
// JSONObject datasource = repositorySnippetObject.getJSONObject("datasource");
|
||||
|
||||
|
||||
repositorySnippet.setId(repositorySnippetObject.get("id").toString());
|
||||
repositorySnippet.setOfficialname(repositorySnippetObject.get("officialname").toString());
|
||||
|
||||
repositorySnippet.setEnglishname(repositorySnippetObject.get("englishname").toString());
|
||||
if (repositorySnippet.getEnglishname().equals("null"))
|
||||
repositorySnippet.setEnglishname("");
|
||||
|
||||
repositorySnippet.setWebsiteurl(repositorySnippetObject.get("websiteurl").toString());
|
||||
if (repositorySnippet.getWebsiteurl().equals("null"))
|
||||
repositorySnippet.setWebsiteurl("");
|
||||
|
||||
repositorySnippet.setRegisteredby(repositorySnippetObject.get("registeredby").toString());
|
||||
if (repositorySnippet.getRegisteredby().equals("null"))
|
||||
repositorySnippet.setRegisteredby("");
|
||||
|
||||
repositorySnippet.setConsentTermsOfUse(repositorySnippetObject.get("consenttermsofuse").toString());
|
||||
repositorySnippet.setFullTextDownload(repositorySnippetObject.get("fulltextdownload").toString());
|
||||
repositorySnippet.setConsentTermsOfUseDate(convertStringToDate(repositorySnippetObject.get("consenttermsofusedate").toString()));
|
||||
|
||||
return repositorySnippet;
|
||||
|
||||
}
|
||||
|
||||
public static List<Repository> jsonToRepositoryList(JSONObject json) throws JSONException {
|
||||
public List<Repository> toRepositoryList(JSONObject json) throws JSONException {
|
||||
|
||||
List<Repository> resultSet = new ArrayList<>();
|
||||
JSONArray rs = json.getJSONArray("datasourceInfo");
|
||||
for (int i = 0; i < rs.length(); i++)
|
||||
resultSet.add(jsonToRepositoryObject(rs.getJSONObject(i)));
|
||||
resultSet.add(toRepository(rs.getJSONObject(i)));
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
public static List<RepositoryInterface> jsonToRepositoryInterfaceList(JSONObject json) throws JSONException {
|
||||
public List<RepositoryInterface> toRepositoryInterfaceList(JSONObject json) throws JSONException {
|
||||
|
||||
List<RepositoryInterface> resultSet = new ArrayList<>();
|
||||
JSONArray rs = json.getJSONArray("api");
|
||||
for (int i = 0; i < rs.length(); i++)
|
||||
resultSet.add(jsonToRepositoryInterfaceObject(rs.getJSONObject(i)));
|
||||
resultSet.add(toRepositoryInterface(rs.getJSONObject(i)));
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
public static RepositoryInterface jsonToRepositoryInterfaceObject(JSONObject repositoryInterfaceObject) throws JSONException {
|
||||
public List<RepositoryInterface> toRepositoryInterfaceList(List<ApiDetails> apiDetailsList) throws JSONException {
|
||||
|
||||
RepositoryInterface repositoryInterface = new RepositoryInterface();
|
||||
List<RepositoryInterface> resultSet = new ArrayList<>();
|
||||
|
||||
repositoryInterface.setId(repositoryInterfaceObject.get("id").toString());
|
||||
repositoryInterface.setAccessProtocol(repositoryInterfaceObject.get("protocol").toString());
|
||||
repositoryInterface.setContentDescription(repositoryInterfaceObject.get("contentdescription").toString());
|
||||
|
||||
// /* 07-04-2022 | "typology" -> "eoscDatasourceType" */
|
||||
// // TODO: enable in future release
|
||||
// try { // FIXME: remove attemp to get typology if eoscDatasourceType fails
|
||||
// repositoryInterface.setTypology(repositoryInterfaceObject.get("eoscDatasourceType").toString());
|
||||
// } catch (JSONException e) {
|
||||
// repositoryInterface.setTypology(repositoryInterfaceObject.get("typology").toString());
|
||||
// }
|
||||
repositoryInterface.setTypology(repositoryInterfaceObject.get("typology").toString());
|
||||
// <--
|
||||
|
||||
repositoryInterface.setCompliance(repositoryInterfaceObject.get("compatibility").toString());
|
||||
repositoryInterface.setLastCollectionDate(repositoryInterfaceObject.get("lastCollectionDate").toString());
|
||||
|
||||
repositoryInterface.setBaseUrl(repositoryInterfaceObject.get("baseurl").toString());
|
||||
repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
|
||||
|
||||
|
||||
// repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
|
||||
repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
|
||||
//repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
|
||||
|
||||
|
||||
Map<String, String> accessParams = new HashMap<>();
|
||||
Map<String, String> extraFields = new HashMap<>();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JSONArray apiparams = repositoryInterfaceObject.getJSONArray("apiParams");
|
||||
|
||||
for (int i = 0; i < apiparams.length(); i++)
|
||||
accessParams.put(apiparams.getJSONObject(i).getString("param"), apiparams.getJSONObject(i).getString("value"));
|
||||
|
||||
repositoryInterface.setAccessParams(accessParams);
|
||||
|
||||
return repositoryInterface;
|
||||
for (ApiDetails entry : apiDetailsList)
|
||||
resultSet.add(toRepositoryInterface(entry));
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
public static String repositoryObjectToJson(Repository repository) throws JSONException, JsonProcessingException {
|
||||
public RepositoryInterface toRepositoryInterface(Object repositoryInterfaceObject) {
|
||||
|
||||
HashMap<String, Object> repositoryMap = new HashMap<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
RepositoryInterface repoInterface = objectMapper.convertValue(repositoryInterfaceObject, RepositoryInterface.class);
|
||||
|
||||
repositoryMap.put("id", repository.getId());
|
||||
repositoryMap.put("openaireId", getOpenaireId(repository.getId()));
|
||||
repositoryMap.put("officialname", repository.getOfficialName());
|
||||
repositoryMap.put("englishname", repository.getEnglishName());
|
||||
repositoryMap.put("websiteurl", repository.getWebsiteUrl());
|
||||
repositoryMap.put("logourl", repository.getLogoUrl());
|
||||
repositoryMap.put("contactemail", repository.getContactEmail());
|
||||
repositoryMap.put("longitude", repository.getLongitude().toString());
|
||||
repositoryMap.put("latitude", repository.getLatitude().toString());
|
||||
repositoryMap.put("timezone", repository.getTimezone());
|
||||
|
||||
repositoryMap.put("namespaceprefix", repository.getNamespacePrefix() != null ? repository.getNamespacePrefix() : "");
|
||||
repositoryMap.put("languages", repository.getOdLanguages() != null ? repository.getOdLanguages() : "");
|
||||
|
||||
repositoryMap.put("dateofcollection", repository.getDateOfCollection() != null ? convertDateToString(repository.getDateOfCollection()) : "");
|
||||
|
||||
/*
|
||||
* typology -> platform
|
||||
* datasource class -> typology
|
||||
* */
|
||||
// repositoryMap.put("eoscDatasourceType", repository.getDatasourceClass()); // TODO: enable in future release
|
||||
repositoryMap.put("typology", repository.getDatasourceClass());
|
||||
repositoryMap.put("platform", repository.getTypology());
|
||||
|
||||
repositoryMap.put("dateofvalidation", repository.getDateOfCollection() != null ? convertDateToString(repository.getDateOfCollection()) : "");
|
||||
repositoryMap.put("activationId", repository.getActivationId() != null ? repository.getActivationId() : "");
|
||||
|
||||
repositoryMap.put("description", repository.getDescription());
|
||||
|
||||
repositoryMap.put("eissn", repository.getEissn() != null ? repository.getEissn() : "");
|
||||
repositoryMap.put("issn", repository.getIssn() != null ? repository.getIssn() : "");
|
||||
repositoryMap.put("lissn", repository.getLissn() != null ? repository.getLissn() : "");
|
||||
|
||||
repositoryMap.put("registeredby", repository.getRegisteredBy());
|
||||
|
||||
repositoryMap.put("aggregator", repository.getAggregator() != null ? repository.getAggregator() : "");
|
||||
repositoryMap.put("collectedfrom", repository.getCollectedFrom() != null ? repository.getCollectedFrom() : "");
|
||||
|
||||
repositoryMap.put("managed", repository.isRegistered());
|
||||
|
||||
Map<String, String> organization = new HashMap<>();
|
||||
organization.put("legalname", repository.getOrganization());
|
||||
organization.put("country", repository.getCountryCode());
|
||||
organization.put("legalshortname", "");
|
||||
organization.put("websiteurl", "");
|
||||
organization.put("logourl", "");
|
||||
|
||||
List organizations = new ArrayList();
|
||||
organizations.add(organization);
|
||||
repositoryMap.put("organizations", organizations);
|
||||
|
||||
//TODO check identitites
|
||||
//Map<String,String> identity = new HashMap<>();
|
||||
|
||||
if (repository.getPiwikInfo() != null) {
|
||||
Map<String, Object> identity = new HashMap<>();
|
||||
HashSet<Map<String, Object>> identities = new HashSet<>();
|
||||
|
||||
identity.put("issuertype", "piwik");
|
||||
identity.put("pid", "piwik:" + repository.getPiwikInfo().getSiteId());
|
||||
|
||||
identities.add(identity);
|
||||
|
||||
repositoryMap.put("identities", identities);
|
||||
}
|
||||
|
||||
repositoryMap.put("subjects", "");
|
||||
repositoryMap.put("consentTermsOfUse", repository.getConsentTermsOfUse());
|
||||
repositoryMap.put("fullTextDownload", repository.getFullTextDownload());
|
||||
repositoryMap.put("consentTermsOfUseDate", convertDateToString(repository.getConsentTermsOfUseDate()));
|
||||
repositoryMap.put("lastConsentTermsOfUseDate", convertDateToString(repository.getLastConsentTermsOfUseDate()));
|
||||
|
||||
return mapper.writeValueAsString(repositoryMap);
|
||||
return repoInterface;
|
||||
}
|
||||
|
||||
public static String repositoryInterfaceObjectToJson(Repository repository, RepositoryInterface repositoryInterface) throws JSONException {
|
||||
public String toJson(Repository repository) throws JsonProcessingException {
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
jsonObject.put("id", repositoryInterface.getId());
|
||||
jsonObject.put("protocol", repositoryInterface.getAccessProtocol());
|
||||
jsonObject.put("datasource", repository.getId());
|
||||
jsonObject.put("contentdescription", repositoryInterface.getContentDescription());
|
||||
jsonObject.put("typology", repositoryInterface.getTypology());
|
||||
jsonObject.put("compatibility", repositoryInterface.getDesiredCompatibilityLevel());
|
||||
jsonObject.put("compatibilityOverride", repositoryInterface.getDesiredCompatibilityLevel());
|
||||
|
||||
jsonObject.put("lastCollectionTotal", "");
|
||||
|
||||
jsonObject.put("lastCollectionDate", repositoryInterface.getLastCollectionDate());
|
||||
jsonObject.put("lastAggregationTotal", "");
|
||||
jsonObject.put("lastAggregationDate", "");
|
||||
jsonObject.put("lastDownloadTotal", "");
|
||||
jsonObject.put("lastDownloadDate", "");
|
||||
|
||||
jsonObject.put("baseurl", repositoryInterface.getBaseUrl());
|
||||
jsonObject.put("removable", repositoryInterface.isRemovable());
|
||||
|
||||
|
||||
JSONArray apiparams = new JSONArray();
|
||||
for (String param : repositoryInterface.getAccessParams().keySet()) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("param", param);
|
||||
jo.put("value", repositoryInterface.getAccessParams().get(param));
|
||||
apiparams.put(jo);
|
||||
}
|
||||
jsonObject.put("apiParams", apiparams);
|
||||
|
||||
|
||||
// jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
|
||||
|
||||
|
||||
return jsonObject.toString();
|
||||
return objectMapper.writeValueAsString(repository);
|
||||
}
|
||||
|
||||
public static ArrayList<String> readFile(String filename) {
|
||||
public List<String> readFile(String filename) {
|
||||
String line;
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
//InputStream in = Converter.class.getResourceAsStream("resources/eu/dnetlib/repo/manager/service/utils/"+filename);
|
||||
InputStream in = Converter.class.getClass().getResourceAsStream("/eu/**/" + filename);
|
||||
|
@ -403,32 +99,16 @@ public class Converter {
|
|||
return list;
|
||||
}
|
||||
|
||||
public static List<AggregationDetails> getAggregationHistoryFromJson(JSONArray aggregationInfo) throws JSONException {
|
||||
public List<AggregationDetails> toAggregationHistory(JSONArray aggregationInfo) throws JSONException {
|
||||
List<AggregationDetails> aggregationDetailsList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < aggregationInfo.length(); i++)
|
||||
aggregationDetailsList.add(jsonToAggregationDetails(aggregationInfo.getJSONObject(i)));
|
||||
aggregationDetailsList.add(toAggregationDetails(aggregationInfo.getJSONObject(i)));
|
||||
|
||||
return aggregationDetailsList;
|
||||
}
|
||||
|
||||
private static AggregationDetails jsonToAggregationDetails(JSONObject aggregationObject) throws JSONException {
|
||||
|
||||
AggregationDetails aggregationDetails = new AggregationDetails();
|
||||
|
||||
if (aggregationObject.has("collectionMode"))
|
||||
aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString());
|
||||
if (aggregationObject.has("indexedVersion"))
|
||||
aggregationDetails.setIndexedVersion(Boolean.parseBoolean(aggregationObject.get("indexedVersion").toString()));
|
||||
|
||||
aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString());
|
||||
aggregationDetails.setDate(convertStringToDate(aggregationObject.get("date").toString()));
|
||||
aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString()));
|
||||
|
||||
return aggregationDetails;
|
||||
}
|
||||
|
||||
public static List<Timezone> toTimezones(List<String> timezones) {
|
||||
public List<Timezone> toTimezones(List<String> timezones) {
|
||||
|
||||
List<Timezone> tmz = new ArrayList<>();
|
||||
for (String t : timezones) {
|
||||
|
@ -438,10 +118,60 @@ public class Converter {
|
|||
return tmz;
|
||||
}
|
||||
|
||||
private static String getOpenaireId(String repositoryId) {
|
||||
private String getOpenaireId(String repositoryId) {
|
||||
if (repositoryId != null && repositoryId.contains("::"))
|
||||
return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Boolean convertStringToBoolean(String value) {
|
||||
return value.equals("null") ? null : Boolean.valueOf(value);
|
||||
}
|
||||
|
||||
private Date toDate(String date) {
|
||||
|
||||
if (Objects.equals(date, "null"))
|
||||
return null;
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
return formatter.parse(date);
|
||||
} catch (ParseException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString(Date date) {
|
||||
|
||||
if (Objects.equals(date, null))
|
||||
return null;
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
private Double toDouble(String number) {
|
||||
if (Objects.equals(number, "null"))
|
||||
return 0.0;
|
||||
else
|
||||
return Double.valueOf(number);
|
||||
}
|
||||
|
||||
private AggregationDetails toAggregationDetails(JSONObject aggregationObject) throws JSONException {
|
||||
|
||||
AggregationDetails aggregationDetails = new AggregationDetails();
|
||||
|
||||
if (aggregationObject.has("collectionMode"))
|
||||
aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString());
|
||||
if (aggregationObject.has("indexedVersion"))
|
||||
aggregationDetails.setIndexedVersion(Boolean.parseBoolean(aggregationObject.get("indexedVersion").toString()));
|
||||
|
||||
aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString());
|
||||
aggregationDetails.setDate(toDate(aggregationObject.get("date").toString()));
|
||||
aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString()));
|
||||
|
||||
return aggregationDetails;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue