Compare commits
2 Commits
c4ec41bec1
...
503fe2c3dc
Author | SHA1 | Date |
---|---|---|
Efstratios Giannopoulos | 503fe2c3dc | |
Efstratios Giannopoulos | a4ced2be21 |
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.commons.exceptions;
|
||||||
|
|
||||||
|
public class HugeResultSetException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -6961447213733280563L;
|
||||||
|
|
||||||
|
|
||||||
|
public HugeResultSetException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.services.references;
|
package eu.eudat.service.reference;
|
||||||
|
|
||||||
import gr.cite.tools.cache.CacheOptions;
|
import gr.cite.tools.cache.CacheOptions;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.logic.services.references;
|
package eu.eudat.service.reference;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import gr.cite.tools.cache.CacheService;
|
import gr.cite.tools.cache.CacheService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -15,14 +15,14 @@ public class ReferenceCacheService extends CacheService<ReferenceCacheService.Re
|
||||||
|
|
||||||
public ReferenceCacheValue() {}
|
public ReferenceCacheValue() {}
|
||||||
|
|
||||||
public ReferenceCacheValue(String type, ExternalUrlCriteria externalUrlCriteria) {
|
public ReferenceCacheValue(String type, ExternalReferenceCriteria externalUrlCriteria) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.externalUrlCriteria = externalUrlCriteria;
|
this.externalUrlCriteria = externalUrlCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private ExternalUrlCriteria externalUrlCriteria;
|
private ExternalReferenceCriteria externalUrlCriteria;
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
|
@ -32,11 +32,11 @@ public class ReferenceCacheService extends CacheService<ReferenceCacheService.Re
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalUrlCriteria getExternalUrlCriteria() {
|
public ExternalReferenceCriteria getExternalUrlCriteria() {
|
||||||
return externalUrlCriteria;
|
return externalUrlCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalUrlCriteria(ExternalUrlCriteria externalUrlCriteria) {
|
public void setExternalUrlCriteria(ExternalReferenceCriteria externalUrlCriteria) {
|
||||||
this.externalUrlCriteria = externalUrlCriteria;
|
this.externalUrlCriteria = externalUrlCriteria;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class ReferenceCacheService extends CacheService<ReferenceCacheService.Re
|
||||||
return this.buildKey(value.getType(), value.getExternalUrlCriteria());
|
return this.buildKey(value.getType(), value.getExternalUrlCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buildKey(String externalType, ExternalUrlCriteria externalUrlCriteria) {
|
public String buildKey(String externalType, ExternalReferenceCriteria externalUrlCriteria) {
|
||||||
HashMap<String, String> keyParts = new HashMap<>();
|
HashMap<String, String> keyParts = new HashMap<>();
|
||||||
|
|
||||||
keyParts.put("$type$", externalType.toLowerCase(Locale.ROOT));
|
keyParts.put("$type$", externalType.toLowerCase(Locale.ROOT));
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.service.reference;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.persist.ReferencePersist;
|
||||||
|
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||||
|
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.exception.MyValidationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface ReferenceService {
|
||||||
|
Reference persist(ReferencePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException;
|
||||||
|
|
||||||
|
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||||
|
|
||||||
|
List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException;
|
||||||
|
|
||||||
|
List<Reference> searchReferenceWithDefinition(ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.services.references;
|
package eu.eudat.service.reference;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
@ -11,21 +11,13 @@ import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.reference.FieldEntity;
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
import eu.eudat.commons.types.referencetype.*;
|
import eu.eudat.commons.types.referencetype.*;
|
||||||
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
import eu.eudat.data.ReferenceTypeEntity;
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.proxy.fetching.entities.Results;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.builder.ReferenceBuilder;
|
import eu.eudat.model.builder.ReferenceBuilder;
|
||||||
import eu.eudat.model.builder.referencesearch.ReferenceSearchBuilder;
|
import eu.eudat.model.builder.referencesearch.ReferenceSearchBuilder;
|
||||||
|
@ -37,6 +29,10 @@ import eu.eudat.query.ReferenceQuery;
|
||||||
import eu.eudat.query.ReferenceTypeQuery;
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||||
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.models.ExternalRefernceResult;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
@ -63,6 +59,7 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import reactor.netty.http.client.HttpClient;
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
|
||||||
|
@ -73,12 +70,10 @@ import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@org.springframework.stereotype.Service
|
@Service
|
||||||
public class ReferenceService {
|
public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceServiceImpl.class));
|
||||||
private final ApiContext apiContext;
|
|
||||||
private final UserScope userScope;
|
|
||||||
private final RemoteFetcher remoteFetcher;
|
private final RemoteFetcher remoteFetcher;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
@ -88,13 +83,10 @@ public class ReferenceService {
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private final ReferenceTypeProperties referenceTypeProperties;
|
|
||||||
|
|
||||||
private final WebClient client;
|
private final WebClient client;
|
||||||
|
|
||||||
public ReferenceService(ApiContext apiContext,
|
public ReferenceServiceImpl(RemoteFetcher remoteFetcher,
|
||||||
UserScope userScope,
|
|
||||||
RemoteFetcher remoteFetcher,
|
|
||||||
EntityManager entityManager,
|
EntityManager entityManager,
|
||||||
AuthorizationService authorizationService,
|
AuthorizationService authorizationService,
|
||||||
DeleterFactory deleterFactory,
|
DeleterFactory deleterFactory,
|
||||||
|
@ -102,10 +94,7 @@ public class ReferenceService {
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
MessageSource messageSource,
|
MessageSource messageSource,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
XmlHandlingService xmlHandlingService,
|
XmlHandlingService xmlHandlingService) {
|
||||||
ReferenceTypeProperties referenceTypeProperties) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.userScope = userScope;
|
|
||||||
this.remoteFetcher = remoteFetcher;
|
this.remoteFetcher = remoteFetcher;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
|
@ -115,7 +104,6 @@ public class ReferenceService {
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.referenceTypeProperties = referenceTypeProperties;
|
|
||||||
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||||
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||||
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||||
|
@ -123,6 +111,7 @@ public class ReferenceService {
|
||||||
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Reference persist(ReferencePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException {
|
public Reference persist(ReferencePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException {
|
||||||
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||||
|
|
||||||
|
@ -184,6 +173,7 @@ public class ReferenceService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug("deleting : {}", id);
|
logger.debug("deleting : {}", id);
|
||||||
|
|
||||||
|
@ -192,7 +182,7 @@ public class ReferenceService {
|
||||||
this.deleterFactory.deleter(ReferenceDeleter.class).deleteAndSaveByIds(List.of(id));
|
this.deleterFactory.deleter(ReferenceDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public List<FetcherReference> searchReference(ReferenceType externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
// public List<FetcherReference> searchReference(ReferenceType externalType, String query, String type) throws HugeResultSet, MyNotFoundException, InvalidApplicationException {
|
||||||
// ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
// ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||||
//
|
//
|
||||||
// List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
// List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
||||||
|
@ -205,10 +195,11 @@ public class ReferenceService {
|
||||||
// return list;
|
// return list;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
@Override
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(lookup.getLike());
|
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike());
|
||||||
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(lookup.getType(), externalUrlCriteria, lookup.getKey());
|
List<Map<String, String>> remoteRepos = remoteFetcher.get(lookup.getType(), externalReferenceCriteria, lookup.getKey());
|
||||||
|
|
||||||
List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos);
|
List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos);
|
||||||
List<Reference> models = this.fetchFromDb(lookup);
|
List<Reference> models = this.fetchFromDb(lookup);
|
||||||
|
@ -285,7 +276,8 @@ public class ReferenceService {
|
||||||
// return list;
|
// return list;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<Reference> searchReferenceWithDefinition(ReferenceDefinitionSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
@Override
|
||||||
|
public List<Reference> searchReferenceWithDefinition(ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
|
|
||||||
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(lookup.getReferenceTypeId());
|
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(lookup.getReferenceTypeId());
|
||||||
List<ReferenceTypeEntity> datas = query.collectAs(lookup.getProject());
|
List<ReferenceTypeEntity> datas = query.collectAs(lookup.getProject());
|
||||||
|
@ -366,36 +358,36 @@ public class ReferenceService {
|
||||||
String replacedUrlPath = replaceLookupFields(urlPath, lookup, firstPage, queries);
|
String replacedUrlPath = replaceLookupFields(urlPath, lookup, firstPage, queries);
|
||||||
String replacedUrlBody = replaceLookupFields(requestBody, lookup, firstPage, queries);
|
String replacedUrlBody = replaceLookupFields(requestBody, lookup, firstPage, queries);
|
||||||
|
|
||||||
Results results = getResultsFromUrl(replacedUrlPath, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth);
|
ExternalRefernceResult externalRefernceResult = getResultsFromUrl(replacedUrlPath, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth);
|
||||||
if(results != null) {
|
if(externalRefernceResult != null) {
|
||||||
if (filterType != null && filterType.equals("local") && (lookup.getLike() != null && !lookup.getLike().isEmpty())) {
|
if (filterType != null && filterType.equals("local") && (lookup.getLike() != null && !lookup.getLike().isEmpty())) {
|
||||||
results.setResults(results.getResults().stream()
|
externalRefernceResult.setResults(externalRefernceResult.getResults().stream()
|
||||||
.filter(r -> r.get("name").toLowerCase().contains(lookup.getLike().toLowerCase()))
|
.filter(r -> r.get("name").toLowerCase().contains(lookup.getLike().toLowerCase()))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
if (fetchStrategy == FetchStrategy.FIRST)
|
if (fetchStrategy == FetchStrategy.FIRST)
|
||||||
return results.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
return externalRefernceResult.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
|
|
||||||
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
if (externalRefernceResult.getPagination() != null && externalRefernceResult.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
for (int i = 2; i <= externalRefernceResult.getPagination().get("pages"); i++)
|
||||||
pages.add(i);
|
pages.add(i);
|
||||||
|
|
||||||
//Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
//Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
||||||
Long maxResults = Long.valueOf(1000);
|
Long maxResults = Long.valueOf(1000);
|
||||||
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
|
if ((maxResults > 0) && (externalRefernceResult.getPagination().get("count") > maxResults))
|
||||||
throw new HugeResultSet("The submitted search query " + lookup.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
throw new HugeResultSetException("The submitted search query " + lookup.getLike() + " is about to return " + externalRefernceResult.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||||
|
|
||||||
Optional<Results> optionalResults = pages.parallelStream()
|
Optional<ExternalRefernceResult> optionalResults = pages.parallelStream()
|
||||||
.map(page -> getResultsFromUrl(urlPath + "&page=" + page, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth))
|
.map(page -> getResultsFromUrl(urlPath + "&page=" + page, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce((result1, result2) -> {
|
.reduce((result1, result2) -> {
|
||||||
result1.getResults().addAll(result2.getResults());
|
result1.getResults().addAll(result2.getResults());
|
||||||
return result1;
|
return result1;
|
||||||
});
|
});
|
||||||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
ExternalRefernceResult remainingExternalRefernceResult = optionalResults.orElseGet(ExternalRefernceResult::new);
|
||||||
remainingResults.getResults().addAll(results.getResults());
|
remainingExternalRefernceResult.getResults().addAll(externalRefernceResult.getResults());
|
||||||
|
|
||||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
return remainingExternalRefernceResult.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
|
@ -443,7 +435,7 @@ public class ReferenceService {
|
||||||
return completedPath;
|
return completedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Results getResultsFromUrl(String urlString, ResultsConfigurationEntity resultsEntity, String jsonPaginationPath, String contentType, String requestBody, ReferenceTypeExternalApiHTTPMethodType httpMethod, String auth) {
|
protected ExternalRefernceResult getResultsFromUrl(String urlString, ResultsConfigurationEntity resultsEntity, String jsonPaginationPath, String contentType, String requestBody, ReferenceTypeExternalApiHTTPMethodType httpMethod, String auth) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ResponseEntity<String> response;
|
ResponseEntity<String> response;
|
||||||
|
@ -459,18 +451,18 @@ public class ReferenceService {
|
||||||
}
|
}
|
||||||
}).bodyValue(jsonBody).retrieve().toEntity(String.class).block();
|
}).bodyValue(jsonBody).retrieve().toEntity(String.class).block();
|
||||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||||
Results results = new Results();
|
ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult();
|
||||||
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
results = this.getFromJson(jsonContext, resultsEntity);
|
externalRefernceResult = this.getFromJson(jsonContext, resultsEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (results.getPagination().size() == 0) {
|
if (externalRefernceResult.getPagination().size() == 0) {
|
||||||
results.getPagination().put("pages", 1);
|
externalRefernceResult.getPagination().put("pages", 1);
|
||||||
results.getPagination().put("count", results.getResults().size());
|
externalRefernceResult.getPagination().put("count", externalRefernceResult.getResults().size());
|
||||||
}
|
}
|
||||||
return results;
|
return externalRefernceResult;
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
logger.error(exception.getMessage(), exception);
|
logger.error(exception.getMessage(), exception);
|
||||||
|
@ -480,8 +472,8 @@ public class ReferenceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Results getFromJson(DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
|
public static ExternalRefernceResult getFromJson(DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
|
||||||
return new Results(parseData(jsonContext, resultsEntity),
|
return new ExternalRefernceResult(parseData(jsonContext, resultsEntity),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package eu.eudat.service.reference.external;
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.config.ExternalUrls;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ExternalUrlConfigProvider {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ExternalUrlConfigProvider.class);
|
||||||
|
|
||||||
|
private ExternalUrls externalUrls;
|
||||||
|
private final StorageFileService storageFileService;
|
||||||
|
|
||||||
|
public ExternalUrlConfigProvider(StorageFileService storageFileService) {
|
||||||
|
this.storageFileService = storageFileService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExternalUrls getExternalUrls() {
|
||||||
|
if (externalUrls == null) {
|
||||||
|
byte[] bytes = this.storageFileService.getExternalUrlsFile();
|
||||||
|
try {
|
||||||
|
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
|
||||||
|
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(bytes));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Cannot find resource", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return externalUrls;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.fetching;
|
package eu.eudat.service.reference.external;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
@ -6,12 +6,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.logic.proxy.config.*;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.service.reference.external.config.*;
|
||||||
import eu.eudat.logic.proxy.config.entities.GenericUrls;
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.service.reference.external.models.ExternalRefernceResult;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.fetching.entities.Results;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import jakarta.xml.bind.JAXBContext;
|
import jakarta.xml.bind.JAXBContext;
|
||||||
import jakarta.xml.bind.Unmarshaller;
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -27,6 +29,7 @@ import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import reactor.netty.http.client.HttpClient;
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -38,26 +41,25 @@ import java.util.stream.Collectors;
|
||||||
public class RemoteFetcher {
|
public class RemoteFetcher {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
||||||
|
|
||||||
private ConfigLoader configLoader;
|
|
||||||
private final WebClient client;
|
private final WebClient client;
|
||||||
|
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||||
@Autowired
|
@Autowired
|
||||||
public RemoteFetcher(ConfigLoader configLoader) {
|
public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) {
|
||||||
this.configLoader = configLoader;
|
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||||
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||||
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||||
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||||
}
|
}
|
||||||
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> get(ReferenceType referenceType, ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public List<Map<String, String>> get(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
||||||
FetchStrategy fetchStrategy = null;
|
FetchStrategy fetchStrategy = null;
|
||||||
GenericUrls exGenericUrls = this.getExternalUrls(referenceType);
|
GenericUrls exGenericUrls = this.getExternalUrls(referenceType);
|
||||||
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
: exGenericUrls.getUrls();
|
: exGenericUrls.getUrls();
|
||||||
|
|
||||||
List<Map<String, String>> results = getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
List<Map<String, String>> results = getAll(urlConfigs, fetchStrategy, externalReferenceCriteria);
|
||||||
for (Map<String, String> result: results) {
|
for (Map<String, String> result: results) {
|
||||||
result.put("referenceType", referenceType.name());
|
result.put("referenceType", referenceType.name());
|
||||||
}
|
}
|
||||||
|
@ -66,193 +68,68 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
public GenericUrls getExternalUrls(ReferenceType referenceType) {
|
public GenericUrls getExternalUrls(ReferenceType referenceType) {
|
||||||
switch (referenceType){
|
switch (referenceType){
|
||||||
case Taxonomies: return configLoader.getExternalUrls().getTaxonomies();
|
case Taxonomies: return this.externalUrlConfigProvider.getExternalUrls().getTaxonomies();
|
||||||
case Licenses: return configLoader.getExternalUrls().getLicenses();
|
case Licenses: return this.externalUrlConfigProvider.getExternalUrls().getLicenses();
|
||||||
case Publications: return configLoader.getExternalUrls().getPublications();
|
case Publications: return this.externalUrlConfigProvider.getExternalUrls().getPublications();
|
||||||
case Journals: return configLoader.getExternalUrls().getJournals();
|
case Journals: return this.externalUrlConfigProvider.getExternalUrls().getJournals();
|
||||||
case PubRepositories: return configLoader.getExternalUrls().getPubRepositories();
|
case PubRepositories: return this.externalUrlConfigProvider.getExternalUrls().getPubRepositories();
|
||||||
case DataRepositories: return configLoader.getExternalUrls().getRepositories();
|
case DataRepositories: return this.externalUrlConfigProvider.getExternalUrls().getRepositories();
|
||||||
case Registries: return configLoader.getExternalUrls().getRegistries();
|
case Registries: return this.externalUrlConfigProvider.getExternalUrls().getRegistries();
|
||||||
case Services: return configLoader.getExternalUrls().getServices();
|
case Services: return this.externalUrlConfigProvider.getExternalUrls().getServices();
|
||||||
case Grants: return configLoader.getExternalUrls().getGrants();
|
case Grants: return this.externalUrlConfigProvider.getExternalUrls().getGrants();
|
||||||
case Organizations: return configLoader.getExternalUrls().getOrganisations();
|
case Organizations: return this.externalUrlConfigProvider.getExternalUrls().getOrganisations();
|
||||||
case Datasets: return configLoader.getExternalUrls().getDatasets();
|
case Datasets: return this.externalUrlConfigProvider.getExternalUrls().getDatasets();
|
||||||
case Funder: return configLoader.getExternalUrls().getFunders();
|
case Funder: return this.externalUrlConfigProvider.getExternalUrls().getFunders();
|
||||||
case Project: return configLoader.getExternalUrls().getProjects();
|
case Project: return this.externalUrlConfigProvider.getExternalUrls().getProjects();
|
||||||
case Researcher: return configLoader.getExternalUrls().getResearchers();
|
case Researcher: return this.externalUrlConfigProvider.getExternalUrls().getResearchers();
|
||||||
default: throw new IllegalArgumentException("Type not found" + referenceType);
|
default: throw new IllegalArgumentException("Type not found" + referenceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getRepositories(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getRepositories().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRepositories().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
@Cacheable(value = "pubrepos", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getPubRepositories(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getPubRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getPubRepositories().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getPubRepositories().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
@Cacheable(value = "journals", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getJournals(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getJournals().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getJournals().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getJournals().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
@Cacheable(value = "taxonomies", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getTaxonomies(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getTaxonomies().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getTaxonomies().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getTaxonomies().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
@Cacheable(value = "publications", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getPublications(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getPublications().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getPublications().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getPublications().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "grants", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getGrants(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getGrants().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getGrants().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "projects", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getProjects(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getProjects().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "funders", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getFunders(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getFunders().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getFunders().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "organisations", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getOrganisations(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getOrganisations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getOrganisations().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getOrganisations().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "registries", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getRegistries(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getRegistries().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRegistries().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "services", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getServices(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getServices().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getServices().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "researchers", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getResearchers(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getResearchers().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getResearchers().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getResearchers().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@Cacheable("tags")
|
|
||||||
public List<Map<String, String>> getTags(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getTags().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getTags().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getTags().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Cacheable(value = "externalDatasets", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getDatasets(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getDatasets().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getDatasets().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "licenses", keyGenerator = "externalUrlsKeyGenerator")
|
|
||||||
public List<Map<String, String>> getlicenses(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
|
||||||
List<UrlConfiguration> urlConfigs =
|
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getLicenses().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getLicenses().getUrls();
|
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getLicenses().getFetchMode();
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer findEntries(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public Integer findEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
||||||
List<UrlConfiguration> urlConfigs =
|
List<UrlConfiguration> urlConfigs =
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
key != null && !key.isEmpty() ? this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
: configLoader.getExternalUrls().getValidations().getUrls();
|
: this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls();
|
||||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getValidations().getFetchMode();
|
FetchStrategy fetchStrategy = this.externalUrlConfigProvider.getExternalUrls().getValidations().getFetchMode();
|
||||||
List<Map<String, String>> data = this.getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
List<Map<String, String>> data = this.getAll(urlConfigs, fetchStrategy, externalReferenceCriteria);
|
||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> getExternalGeneric(ExternalUrlCriteria externalUrlCriteria, GenericUrls genericUrls) {
|
public List<Map<String, String>> getExternalGeneric(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) {
|
||||||
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
|
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
|
||||||
FetchStrategy fetchStrategy = genericUrls.getFetchMode();
|
FetchStrategy fetchStrategy = genericUrls.getFetchMode();
|
||||||
return getAll(urlConfigurations, fetchStrategy, externalUrlCriteria);
|
return getAll(urlConfigurations, fetchStrategy, externalReferenceCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, Object>> getExternalGenericWithData(ExternalUrlCriteria externalUrlCriteria, GenericUrls genericUrls) {
|
public List<Map<String, Object>> getExternalGenericWithData(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) {
|
||||||
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
|
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
|
||||||
return getAllWithData(urlConfigurations, externalUrlCriteria);
|
return getAllWithData(urlConfigurations, externalReferenceCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, ExternalUrlCriteria externalUrlCriteria) {
|
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, ExternalReferenceCriteria externalReferenceCriteria) {
|
||||||
|
|
||||||
List<Map<String, String>> results = new LinkedList<>();
|
List<Map<String, String>> results = new LinkedList<>();
|
||||||
|
|
||||||
if (urlConfigs == null || urlConfigs.isEmpty()) {
|
if (urlConfigs == null || urlConfigs.isEmpty()) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
// throw new NoURLFound("No Repository urls found in configuration");
|
// throw new MyNotFoundException("No Repository urls found in configuration");
|
||||||
|
|
||||||
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
||||||
urlConfigs.forEach(urlConfiguration -> {
|
urlConfigs.forEach(urlConfiguration -> {
|
||||||
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
String auth = null;
|
String auth = null;
|
||||||
if (urlConfiguration.getAuth() != null) {
|
if (urlConfiguration.getAuth() != null) {
|
||||||
auth = this.getAuthentication(urlConfiguration.getAuth());
|
auth = this.getAuthentication(urlConfiguration.getAuth());
|
||||||
}
|
}
|
||||||
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalUrlCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalReferenceCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
} else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) {
|
} else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) {
|
||||||
results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalUrlCriteria.getLike()));
|
results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalReferenceCriteria.getLike()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* for (UrlConfiguration urlConfig : urlConfigs) {
|
/* for (UrlConfiguration urlConfig : urlConfigs) {
|
||||||
|
@ -279,7 +156,7 @@ public class RemoteFetcher {
|
||||||
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath());
|
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalUrlCriteria externalUrlCriteria) {
|
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalReferenceCriteria externalReferenceCriteria) {
|
||||||
|
|
||||||
List<Map<String, Object>> results = new LinkedList<>();
|
List<Map<String, Object>> results = new LinkedList<>();
|
||||||
|
|
||||||
|
@ -289,10 +166,10 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
||||||
urlConfigs.forEach(urlConfiguration -> {
|
urlConfigs.forEach(urlConfiguration -> {
|
||||||
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalUrlCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
|
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalReferenceCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -302,9 +179,9 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalUrlCriteria externalUrlCriteria) {
|
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalReferenceCriteria externalReferenceCriteria) {
|
||||||
if (urlConfiguration.getFunderQuery() != null) {
|
if (urlConfiguration.getFunderQuery() != null) {
|
||||||
if (externalUrlCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
if (externalReferenceCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
||||||
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
|
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -313,46 +190,46 @@ public class RemoteFetcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String calculateQuery(ExternalUrlCriteria externalUrlCriteria, List<QueryConfig> queryConfigs) {
|
private String calculateQuery(ExternalReferenceCriteria externalReferenceCriteria, List<QueryConfig> queryConfigs) {
|
||||||
String finalQuery = "";
|
String finalQuery = "";
|
||||||
QueryConfig queryConfig = queryConfigs.stream().filter(queryConfigl -> externalUrlCriteria.getLike().matches(queryConfigl.getCondition()))
|
QueryConfig queryConfig = queryConfigs.stream().filter(queryConfigl -> externalReferenceCriteria.getLike().matches(queryConfigl.getCondition()))
|
||||||
.min((Comparator.comparing(QueryConfig::getOrdinal))).orElse(null);
|
.min((Comparator.comparing(QueryConfig::getOrdinal))).orElse(null);
|
||||||
if (queryConfig != null) {
|
if (queryConfig != null) {
|
||||||
if (queryConfig.getSeparator() != null) {
|
if (queryConfig.getSeparator() != null) {
|
||||||
String[] likes = externalUrlCriteria.getLike().split(queryConfig.getSeparator());
|
String[] likes = externalReferenceCriteria.getLike().split(queryConfig.getSeparator());
|
||||||
finalQuery = queryConfig.getValue();
|
finalQuery = queryConfig.getValue();
|
||||||
for (int i = 0; i < likes.length; i++) {
|
for (int i = 0; i < likes.length; i++) {
|
||||||
finalQuery = finalQuery.replaceAll("\\{like" + (i+1) + "}", likes[i]);
|
finalQuery = finalQuery.replaceAll("\\{like" + (i+1) + "}", likes[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finalQuery = queryConfig.getValue().replaceAll("\\{like}", externalUrlCriteria.getLike());
|
finalQuery = queryConfig.getValue().replaceAll("\\{like}", externalReferenceCriteria.getLike());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return finalQuery;
|
return finalQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String replaceCriteriaOnUrl(String path, ExternalUrlCriteria externalUrlCriteria, String firstPage, List<QueryConfig> queries) {
|
protected String replaceCriteriaOnUrl(String path, ExternalReferenceCriteria externalReferenceCriteria, String firstPage, List<QueryConfig> queries) {
|
||||||
String completedPath = path;
|
String completedPath = path;
|
||||||
if (externalUrlCriteria.getLike() != null) {
|
if (externalReferenceCriteria.getLike() != null) {
|
||||||
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror") || path.contains("fairsharing")) && externalUrlCriteria.getLike().equals("")) {
|
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror") || path.contains("fairsharing")) && externalReferenceCriteria.getLike().equals("")) {
|
||||||
completedPath = completedPath.replaceAll("\\{like}", "*");
|
completedPath = completedPath.replaceAll("\\{like}", "*");
|
||||||
completedPath = completedPath.replaceAll("\\{query}", "*");
|
completedPath = completedPath.replaceAll("\\{query}", "*");
|
||||||
} else {
|
} else {
|
||||||
if (completedPath.contains("{query}")) {
|
if (completedPath.contains("{query}")) {
|
||||||
completedPath = completedPath.replaceAll("\\{query}", this.calculateQuery(externalUrlCriteria, queries));
|
completedPath = completedPath.replaceAll("\\{query}", this.calculateQuery(externalReferenceCriteria, queries));
|
||||||
} else {
|
} else {
|
||||||
completedPath = completedPath.replaceAll("\\{like}", externalUrlCriteria.getLike());
|
completedPath = completedPath.replaceAll("\\{like}", externalReferenceCriteria.getLike());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
completedPath = completedPath.replace("{like}", "");
|
completedPath = completedPath.replace("{like}", "");
|
||||||
}
|
}
|
||||||
if (externalUrlCriteria.getFunderId() != null) {
|
if (externalReferenceCriteria.getFunderId() != null) {
|
||||||
String funderPrefix = externalUrlCriteria.getFunderId().split(":")[0];
|
String funderPrefix = externalReferenceCriteria.getFunderId().split(":")[0];
|
||||||
String funderId = externalUrlCriteria.getFunderId().replace(funderPrefix + ":", "");
|
String funderId = externalReferenceCriteria.getFunderId().replace(funderPrefix + ":", "");
|
||||||
if (funderId.toCharArray()[0] == ':') {
|
if (funderId.toCharArray()[0] == ':') {
|
||||||
funderId = externalUrlCriteria.getFunderId();
|
funderId = externalReferenceCriteria.getFunderId();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
try { funderId = URLEncoder.encode(funderId, "UTF-8"); } catch
|
try { funderId = URLEncoder.encode(funderId, "UTF-8"); } catch
|
||||||
|
@ -364,8 +241,8 @@ public class RemoteFetcher {
|
||||||
logger.warn("FunderId is null.");
|
logger.warn("FunderId is null.");
|
||||||
completedPath = completedPath.replace("{funderId}", " ");
|
completedPath = completedPath.replace("{funderId}", " ");
|
||||||
}
|
}
|
||||||
if (externalUrlCriteria.getPage() != null) {
|
if (externalReferenceCriteria.getPage() != null) {
|
||||||
completedPath = completedPath.replace("{page}", externalUrlCriteria.getPage());
|
completedPath = completedPath.replace("{page}", externalReferenceCriteria.getPage());
|
||||||
} else {
|
} else {
|
||||||
if (firstPage != null) {
|
if (firstPage != null) {
|
||||||
completedPath = completedPath.replace("{page}", firstPage);
|
completedPath = completedPath.replace("{page}", firstPage);
|
||||||
|
@ -373,69 +250,69 @@ public class RemoteFetcher {
|
||||||
completedPath = completedPath.replace("{page}", "1");
|
completedPath = completedPath.replace("{page}", "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (externalUrlCriteria.getPageSize() != null) {
|
if (externalReferenceCriteria.getPageSize() != null) {
|
||||||
completedPath = completedPath.replace("{pageSize}", externalUrlCriteria.getPageSize());
|
completedPath = completedPath.replace("{pageSize}", externalReferenceCriteria.getPageSize());
|
||||||
} else {
|
} else {
|
||||||
completedPath = completedPath.replace("{pageSize}", "60");
|
completedPath = completedPath.replace("{pageSize}", "60");
|
||||||
}
|
}
|
||||||
if (externalUrlCriteria.getHost() != null) {
|
if (externalReferenceCriteria.getHost() != null) {
|
||||||
completedPath = completedPath.replace("{host}", externalUrlCriteria.getHost());
|
completedPath = completedPath.replace("{host}", externalReferenceCriteria.getHost());
|
||||||
} else {
|
} else {
|
||||||
completedPath = completedPath.replace("{host}", "");
|
completedPath = completedPath.replace("{host}", "");
|
||||||
}
|
}
|
||||||
if (externalUrlCriteria.getPath() != null) {
|
if (externalReferenceCriteria.getPath() != null) {
|
||||||
completedPath = completedPath.replace("{path}", externalUrlCriteria.getPath());
|
completedPath = completedPath.replace("{path}", externalReferenceCriteria.getPath());
|
||||||
} else {
|
} else {
|
||||||
completedPath = completedPath.replace("{path}", "");
|
completedPath = completedPath.replace("{path}", "");
|
||||||
}
|
}
|
||||||
return completedPath;
|
return completedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries, String auth) throws Exception {
|
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalReferenceCriteria externalReferenceCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries, String auth) throws Exception {
|
||||||
Set<Integer> pages = new HashSet<>();
|
Set<Integer> pages = new HashSet<>();
|
||||||
|
|
||||||
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
String replacedPath = replaceCriteriaOnUrl(path, externalReferenceCriteria, firstPage, queries);
|
||||||
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
String replacedBody = replaceCriteriaOnUrl(requestBody, externalReferenceCriteria, firstPage, queries);
|
||||||
|
|
||||||
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth);
|
ExternalRefernceResult externalRefernceResult = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth);
|
||||||
if(results != null) {
|
if(externalRefernceResult != null) {
|
||||||
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
if (filterType != null && filterType.equals("local") && (externalReferenceCriteria.getLike() != null && !externalReferenceCriteria.getLike().isEmpty())) {
|
||||||
results.setResults(results.getResults().stream()
|
externalRefernceResult.setResults(externalRefernceResult.getResults().stream()
|
||||||
.filter(r -> r.get("name").toLowerCase().contains(externalUrlCriteria.getLike().toLowerCase()))
|
.filter(r -> r.get("name").toLowerCase().contains(externalReferenceCriteria.getLike().toLowerCase()))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
if (fetchStrategy == FetchStrategy.FIRST)
|
if (fetchStrategy == FetchStrategy.FIRST)
|
||||||
return results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
return externalRefernceResult.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
|
|
||||||
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
if (externalRefernceResult.getPagination() != null && externalRefernceResult.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
for (int i = 2; i <= externalRefernceResult.getPagination().get("pages"); i++)
|
||||||
pages.add(i);
|
pages.add(i);
|
||||||
|
|
||||||
Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
Long maxResults = this.externalUrlConfigProvider.getExternalUrls().getMaxresults();
|
||||||
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
|
if ((maxResults > 0) && (externalRefernceResult.getPagination().get("count") > maxResults))
|
||||||
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
throw new HugeResultSetException("The submitted search query " + externalReferenceCriteria.getLike() + " is about to return " + externalRefernceResult.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||||
|
|
||||||
Optional<Results> optionalResults = pages.parallelStream()
|
Optional<ExternalRefernceResult> optionalResults = pages.parallelStream()
|
||||||
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth))
|
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce((result1, result2) -> {
|
.reduce((result1, result2) -> {
|
||||||
result1.getResults().addAll(result2.getResults());
|
result1.getResults().addAll(result2.getResults());
|
||||||
return result1;
|
return result1;
|
||||||
});
|
});
|
||||||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
ExternalRefernceResult remainingExternalRefernceResult = optionalResults.orElseGet(ExternalRefernceResult::new);
|
||||||
remainingResults.getResults().addAll(results.getResults());
|
remainingExternalRefernceResult.getResults().addAll(externalRefernceResult.getResults());
|
||||||
|
|
||||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
return remainingExternalRefernceResult.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> getAllResultsFromUrlWithData(String path, final DataUrlConfiguration jsonDataPath, ExternalUrlCriteria externalUrlCriteria, String contentType, String firstPage, String requestBody, String requestType, List<QueryConfig> queries) {
|
private List<Map<String, Object>> getAllResultsFromUrlWithData(String path, final DataUrlConfiguration jsonDataPath, ExternalReferenceCriteria externalReferenceCriteria, String contentType, String firstPage, String requestBody, String requestType, List<QueryConfig> queries) {
|
||||||
|
|
||||||
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
String replacedPath = replaceCriteriaOnUrl(path, externalReferenceCriteria, firstPage, queries);
|
||||||
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
String replacedBody = replaceCriteriaOnUrl(requestBody, externalReferenceCriteria, firstPage, queries);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
@ -465,7 +342,7 @@ public class RemoteFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType, String auth) {
|
protected ExternalRefernceResult getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType, String auth) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
|
//RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
|
||||||
|
@ -501,18 +378,18 @@ public class RemoteFetcher {
|
||||||
//response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
//response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
||||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||||
//do here all the parsing
|
//do here all the parsing
|
||||||
Results results = new Results();
|
ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult();
|
||||||
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
|
|
||||||
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType, auth);
|
externalRefernceResult = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType, auth);
|
||||||
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
externalRefernceResult = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
||||||
} else {
|
} else {
|
||||||
results = RemoteFetcherUtils.getFromJson(jsonContext, jsonDataPath);
|
externalRefernceResult = RemoteFetcherUtils.getFromJson(jsonContext, jsonDataPath);
|
||||||
}
|
}
|
||||||
results.setResults(results.getResults().stream().map(e -> e.entrySet().stream().collect(Collectors.toMap(x -> this.transformKey(jsonDataPath,x.getKey()), Map.Entry::getValue)))
|
externalRefernceResult.setResults(externalRefernceResult.getResults().stream().map(e -> e.entrySet().stream().collect(Collectors.toMap(x -> this.transformKey(jsonDataPath,x.getKey()), Map.Entry::getValue)))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
else if (response.getHeaders().get("Content-Type").get(0).contains("xml")) {
|
else if (response.getHeaders().get("Content-Type").get(0).contains("xml")) {
|
||||||
|
@ -566,14 +443,14 @@ public class RemoteFetcher {
|
||||||
values.add(map);
|
values.add(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results = new Results(values, new HashMap<>(1, 1));
|
externalRefernceResult = new ExternalRefernceResult(values, new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.getPagination().size() == 0) {
|
if (externalRefernceResult.getPagination().isEmpty()) {
|
||||||
results.getPagination().put("pages", 1);
|
externalRefernceResult.getPagination().put("pages", 1);
|
||||||
results.getPagination().put("count", results.getResults().size());
|
externalRefernceResult.getPagination().put("count", externalRefernceResult.getResults().size());
|
||||||
}
|
}
|
||||||
return results;
|
return externalRefernceResult;
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
logger.error(exception.getMessage(), exception);
|
logger.error(exception.getMessage(), exception);
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.logic.proxy.fetching;
|
package eu.eudat.service.reference.external;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import eu.eudat.logic.proxy.config.DataUrlConfiguration;
|
import eu.eudat.service.reference.external.config.DataUrlConfiguration;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.fetching.entities.Results;
|
import eu.eudat.service.reference.external.models.ExternalRefernceResult;
|
||||||
import net.minidev.json.JSONArray;
|
import net.minidev.json.JSONArray;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -18,35 +18,35 @@ public class RemoteFetcherUtils {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(RemoteFetcherUtils.class);
|
private final static Logger logger = LoggerFactory.getLogger(RemoteFetcherUtils.class);
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
private static final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
public static Results getFromJson(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
public static ExternalRefernceResult getFromJson(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
||||||
return new Results(parseData(jsonContext, jsonDataPath),
|
return new ExternalRefernceResult(parseData(jsonContext, jsonDataPath),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Results getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType, String auth) {
|
public static ExternalRefernceResult getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType, String auth) {
|
||||||
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult(parseData(jsonContext, jsonDataPath),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
|
|
||||||
List<Map<String, String>> multiResults = results.getResults().stream().map(result -> {
|
List<Map<String, String>> multiResults = externalRefernceResult.getResults().stream().map(result -> {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria();
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
|
||||||
externalUrlCriteria.setPath(result.get("path"));
|
externalReferenceCriteria.setPath(result.get("path"));
|
||||||
externalUrlCriteria.setHost(result.get("host"));
|
externalReferenceCriteria.setHost(result.get("host"));
|
||||||
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalUrlCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalReferenceCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
||||||
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth);
|
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth);
|
||||||
}).filter(Objects::nonNull).map(results1 -> results1.getResults().get(0)).collect(Collectors.toList());
|
}).filter(Objects::nonNull).map(externalRefernceResult1 -> externalRefernceResult1.getResults().get(0)).collect(Collectors.toList());
|
||||||
return new Results(multiResults, new HashMap<>(1, 1));
|
return new ExternalRefernceResult(multiResults, new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Results getFromJsonWithFirstAndLastName(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
public static ExternalRefernceResult getFromJsonWithFirstAndLastName(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
||||||
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult(parseData(jsonContext, jsonDataPath),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
results.getResults().stream().forEach(entry -> {
|
externalRefernceResult.getResults().stream().forEach(entry -> {
|
||||||
String name = entry.get(jsonDataPath.getFieldsUrlConfiguration().getFirstName().replace("'", "")) + " " + entry.get(jsonDataPath.getFieldsUrlConfiguration().getLastName().replace("'", ""));
|
String name = entry.get(jsonDataPath.getFieldsUrlConfiguration().getFirstName().replace("'", "")) + " " + entry.get(jsonDataPath.getFieldsUrlConfiguration().getLastName().replace("'", ""));
|
||||||
entry.put("name", name);
|
entry.put("name", name);
|
||||||
entry.remove(jsonDataPath.getFieldsUrlConfiguration().getFirstName().replace("'", ""));
|
entry.remove(jsonDataPath.getFieldsUrlConfiguration().getFirstName().replace("'", ""));
|
||||||
entry.remove(jsonDataPath.getFieldsUrlConfiguration().getLastName().replace("'", ""));
|
entry.remove(jsonDataPath.getFieldsUrlConfiguration().getLastName().replace("'", ""));
|
||||||
});
|
});
|
||||||
return results;
|
return externalRefernceResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Map<String, String>> parseData (DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
private static List<Map<String, String>> parseData (DocumentContext jsonContext, DataUrlConfiguration jsonDataPath) {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.entities.*;
|
import eu.eudat.service.reference.external.config.prefilling.PrefillingConfigMapAdapter;
|
||||||
import eu.eudat.logic.proxy.config.prefilling.PrefillingConfigMapAdapter;
|
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.config.entities.*;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.config;
|
||||||
|
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,12 +1,13 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GeneralUrls extends GenericUrls{
|
public class GeneralUrls extends GenericUrls {
|
||||||
|
|
||||||
List<UrlConfiguration> urls;
|
List<UrlConfiguration> urls;
|
||||||
FetchStrategy fetchMode;
|
FetchStrategy fetchMode;
|
|
@ -0,0 +1,12 @@
|
||||||
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class GenericUrls {
|
||||||
|
|
||||||
|
public abstract List<UrlConfiguration> getUrls();
|
||||||
|
public abstract FetchStrategy getFetchMode();
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.config.entities.PrefillingSearch;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PrefillingSearch extends GenericUrls{
|
public class PrefillingSearch extends GenericUrls {
|
||||||
private UrlConfiguration urlConfig;
|
private UrlConfiguration urlConfig;
|
||||||
|
|
||||||
public UrlConfiguration getUrlConfig() {
|
public UrlConfiguration getUrlConfig() {
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,13 +1,14 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RepositoryUrls extends GenericUrls{
|
public class RepositoryUrls extends GenericUrls {
|
||||||
|
|
||||||
List<UrlConfiguration> urls;
|
List<UrlConfiguration> urls;
|
||||||
FetchStrategy fetchMode;
|
FetchStrategy fetchMode;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,13 +1,14 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TaxonomiesUrls extends GenericUrls{
|
public class TaxonomiesUrls extends GenericUrls {
|
||||||
|
|
||||||
List<UrlConfiguration> urls;
|
List<UrlConfiguration> urls;
|
||||||
FetchStrategy fetchMode;
|
FetchStrategy fetchMode;
|
|
@ -1,14 +1,15 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
package eu.eudat.service.reference.external.config.entities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
public class ValidationUrls extends GenericUrls{
|
public class ValidationUrls extends GenericUrls {
|
||||||
|
|
||||||
List<UrlConfiguration> urls;
|
List<UrlConfiguration> urls;
|
||||||
FetchStrategy fetchMode;
|
FetchStrategy fetchMode;
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.logic.proxy.config.prefilling;
|
package eu.eudat.service.reference.external.config.prefilling;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingConfig;
|
import eu.eudat.service.reference.external.config.entities.PrefillingConfig;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import jakarta.xml.bind.JAXBContext;
|
import jakarta.xml.bind.JAXBContext;
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
package eu.eudat.service.reference.external.criteria;
|
||||||
|
|
||||||
public class ExternalUrlCriteria {
|
public class ExternalReferenceCriteria {
|
||||||
private String like;
|
private String like;
|
||||||
private String page;
|
private String page;
|
||||||
private String pageSize;
|
private String pageSize;
|
||||||
|
@ -52,11 +52,11 @@ public class ExternalUrlCriteria {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalUrlCriteria(String like) {
|
public ExternalReferenceCriteria(String like) {
|
||||||
this.like = like;
|
this.like = like;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalUrlCriteria() {
|
public ExternalReferenceCriteria() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -0,0 +1,8 @@
|
||||||
|
package eu.eudat.service.reference.external.criteria;
|
||||||
|
|
||||||
|
public enum FetchStrategy {
|
||||||
|
|
||||||
|
FIRST,
|
||||||
|
ALL
|
||||||
|
|
||||||
|
}
|
|
@ -1,20 +1,20 @@
|
||||||
package eu.eudat.logic.proxy.fetching.entities;
|
package eu.eudat.service.reference.external.models;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Results {
|
public class ExternalRefernceResult {
|
||||||
List<Map<String, String>> results;
|
List<Map<String, String>> results;
|
||||||
Map<String, Integer> pagination;
|
Map<String, Integer> pagination;
|
||||||
|
|
||||||
public Results() {
|
public ExternalRefernceResult() {
|
||||||
this.results = new ArrayList<>();
|
this.results = new ArrayList<>();
|
||||||
this.pagination = new HashMap<>();
|
this.pagination = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Results(List<Map<String, String>> results, Map<String, Integer> pagination) {
|
public ExternalRefernceResult(List<Map<String, String>> results, Map<String, Integer> pagination) {
|
||||||
this.results = results;
|
this.results = results;
|
||||||
this.pagination = pagination;
|
this.pagination = pagination;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.configurations.dynamicfunder.entities;
|
package eu.eudat.configurations.dynamicfunder.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.configurations.dynamicgrant.entities;
|
package eu.eudat.configurations.dynamicgrant.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.configurations.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import eu.eudat.logic.managers.CommonsManager;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.service.reference.external.ExternalUrlConfigProvider;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -23,16 +25,18 @@ import java.util.List;
|
||||||
public class CommonController {
|
public class CommonController {
|
||||||
|
|
||||||
private ConfigLoader configLoader;
|
private ConfigLoader configLoader;
|
||||||
|
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CommonController(ConfigLoader configLoader) {
|
public CommonController(ConfigLoader configLoader, ExternalUrlConfigProvider externalUrlConfigProvider) {
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
|
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/externalSourcesConfiguration"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/externalSourcesConfiguration"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<ExternalSourcesConfiguration>> getExternalSourcesConfiguration() {
|
ResponseEntity<ResponseItem<ExternalSourcesConfiguration>> getExternalSourcesConfiguration() {
|
||||||
ExternalSourcesConfiguration configuration = CommonsManager.getExternalSourcesConfiguration(configLoader);
|
ExternalSourcesConfiguration configuration = CommonsManager.getExternalSourcesConfiguration(configLoader, externalUrlConfigProvider);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalSourcesConfiguration>().status(ApiMessageCode.NO_MESSAGE).payload(configuration));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalSourcesConfiguration>().status(ApiMessageCode.NO_MESSAGE).payload(configuration));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.old.DataRepository;
|
import eu.eudat.data.old.DataRepository;
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
import eu.eudat.logic.managers.DataRepositoryManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -39,7 +39,7 @@ public class DataRepositories extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getDataRepositories(query, type);
|
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getDataRepositories(query, type);
|
||||||
|
|
|
@ -4,14 +4,14 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
import eu.eudat.data.old.ExternalDataset;
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||||
import eu.eudat.logic.managers.ExternalDatasetManager;
|
import eu.eudat.logic.managers.ExternalDatasetManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -51,7 +51,7 @@ public class ExternalDatasets extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query, type);
|
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query, type);
|
||||||
|
@ -60,7 +60,7 @@ public class ExternalDatasets extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseItem<ExternalDatasetListingModel> getWithExternal(@PathVariable UUID id) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
ResponseItem<ExternalDatasetListingModel> getWithExternal(@PathVariable UUID id) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
ExternalDatasetListingModel externalDatasetModel = externalDatasetManager.getSingle(id);
|
ExternalDatasetListingModel externalDatasetModel = externalDatasetManager.getSingle(id);
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
||||||
import eu.eudat.logic.managers.FunderManager;
|
import eu.eudat.logic.managers.FunderManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.funder.Funder;
|
import eu.eudat.models.data.funder.Funder;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -32,7 +32,7 @@ public class Funders extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<Funder> dataTable = this.funderManager.getCriteriaWithExternal(funderCriteria);
|
List<Funder> dataTable = this.funderManager.getCriteriaWithExternal(funderCriteria);
|
||||||
|
|
|
@ -4,14 +4,14 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
||||||
import eu.eudat.logic.managers.GrantManager;
|
import eu.eudat.logic.managers.GrantManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.grant.GrantListingModel;
|
import eu.eudat.models.data.grant.GrantListingModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -80,7 +80,7 @@ public class Grants extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> getWithExternal(@RequestBody GrantCriteriaRequest grantCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> getWithExternal(@RequestBody GrantCriteriaRequest grantCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteriaWithExternal(grantCriteria);
|
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteriaWithExternal(grantCriteria);
|
||||||
|
@ -89,7 +89,7 @@ public class Grants extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"get"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"get"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> get(@RequestBody GrantCriteriaRequest grantCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> get(@RequestBody GrantCriteriaRequest grantCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AnonymousRole);
|
this.authorizationService.authorizeForce(Permission.AnonymousRole);
|
||||||
|
|
||||||
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteria(grantCriteria);
|
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteria(grantCriteria);
|
||||||
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
import eu.eudat.logic.managers.DataRepositoryManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -37,7 +37,7 @@ public class JournalsController extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getJournals(query, type);
|
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getJournals(query, type);
|
||||||
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.LicenseManager;
|
import eu.eudat.logic.managers.LicenseManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
import eu.eudat.models.data.license.LicenseModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -36,7 +36,7 @@ public class Licenses extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<LicenseModel>>> listExternalLicenses(
|
ResponseEntity<ResponseItem<List<LicenseModel>>> listExternalLicenses(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<LicenseModel> licenseModels = this.licenseManager.getLicenses(query, type);
|
List<LicenseModel> licenseModels = this.licenseManager.getLicenses(query, type);
|
||||||
|
|
|
@ -3,14 +3,14 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
||||||
import eu.eudat.logic.managers.OrganisationsManager;
|
import eu.eudat.logic.managers.OrganisationsManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
import eu.eudat.models.data.dmp.Organisation;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -41,7 +41,7 @@ public class Organisations extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<Organisation>>> listExternalOrganisations(
|
ResponseEntity<ResponseItem<List<Organisation>>> listExternalOrganisations(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
List<Organisation> organisations = organisationsManager.getCriteriaWithExternal(query, type);
|
List<Organisation> organisations = organisationsManager.getCriteriaWithExternal(query, type);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||||
import eu.eudat.logic.managers.ProjectManager;
|
import eu.eudat.logic.managers.ProjectManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -34,7 +34,7 @@ public class Projects extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria);
|
List<Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria);
|
||||||
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
import eu.eudat.logic.managers.DataRepositoryManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -37,7 +37,7 @@ public class PubRepositoriesController extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getPubRepositories(query, type);
|
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getPubRepositories(query, type);
|
||||||
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.PublicationManager;
|
import eu.eudat.logic.managers.PublicationManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.publication.PublicationModel;
|
import eu.eudat.models.data.publication.PublicationModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -36,7 +36,7 @@ public class PublicationsController extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<PublicationModel>>> listExternalPublications(
|
ResponseEntity<ResponseItem<List<PublicationModel>>> listExternalPublications(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<PublicationModel> publicationModels = this.publicationManager.getPublications(query, type);
|
List<PublicationModel> publicationModels = this.publicationManager.getPublications(query, type);
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.old.Registry;
|
import eu.eudat.data.old.Registry;
|
||||||
import eu.eudat.logic.managers.RegistryManager;
|
import eu.eudat.logic.managers.RegistryManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.registries.RegistryModel;
|
import eu.eudat.models.data.registries.RegistryModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -38,7 +38,7 @@ public class Registries extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<RegistryModel>>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
|
ResponseEntity<ResponseItem<List<RegistryModel>>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
|
||||||
, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
, @RequestParam(value = "type", required = false) String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<RegistryModel> registryModels = this.registryManager.getRegistries(query, type);
|
List<RegistryModel> registryModels = this.registryManager.getRegistries(query, type);
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
||||||
import eu.eudat.logic.managers.ResearcherManager;
|
import eu.eudat.logic.managers.ResearcherManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.dmp.Researcher;
|
import eu.eudat.models.data.dmp.Researcher;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -37,7 +37,7 @@ public class Researchers extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Researcher> dataTable = this.researcherManager.getCriteriaWithExternal(researcherCriteriaRequest);
|
List<eu.eudat.models.data.dmp.Researcher> dataTable = this.researcherManager.getCriteriaWithExternal(researcherCriteriaRequest);
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.old.Service;
|
import eu.eudat.data.old.Service;
|
||||||
import eu.eudat.logic.managers.ServiceManager;
|
import eu.eudat.logic.managers.ServiceManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.services.ServiceModel;
|
import eu.eudat.models.data.services.ServiceModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -39,7 +39,7 @@ public class Services extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<ServiceModel>>> listExternalServices(
|
ResponseEntity<ResponseItem<List<ServiceModel>>> listExternalServices(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
List<ServiceModel> serviceModels = this.serviceManager.getServices(query, type);
|
List<ServiceModel> serviceModels = this.serviceManager.getServices(query, type);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ServiceModel>>().payload(serviceModels).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ServiceModel>>().payload(serviceModels).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.TaxonomyManager;
|
import eu.eudat.logic.managers.TaxonomyManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -36,7 +36,7 @@ public class TaxonomiesController extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<TaxonomyModel>>> listExternalPublications(
|
ResponseEntity<ResponseItem<List<TaxonomyModel>>> listExternalPublications(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<TaxonomyModel> taxonomyModels = this.taxonomyManager.getTaxonomies(query, type);
|
List<TaxonomyModel> taxonomyModels = this.taxonomyManager.getTaxonomies(query, type);
|
||||||
|
|
|
@ -2,12 +2,12 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.logic.managers.ValidationManager;
|
import eu.eudat.logic.managers.ValidationManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -32,7 +32,7 @@ public class Validation extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Boolean>> validate(
|
ResponseEntity<ResponseItem<Boolean>> validate(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
Boolean isValid = this.validationManager.validateIdentifier(query, type);
|
Boolean isValid = this.validationManager.validateIdentifier(query, type);
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
//package eu.eudat.controllers.controllerhandler;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
//import eu.eudat.types.ApiMessageCode;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//import org.springframework.http.HttpStatus;
|
|
||||||
//import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
||||||
//import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
//
|
|
||||||
//import jakarta.annotation.Priority;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * Created by ikalyvas on 6/12/2018.
|
|
||||||
// */
|
|
||||||
//@ControllerAdvice
|
|
||||||
//@Priority(5)
|
|
||||||
//public class ControllerErrorHandler {
|
|
||||||
// private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
|
|
||||||
//
|
|
||||||
// @ExceptionHandler(Exception.class)
|
|
||||||
// @ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
||||||
// @ResponseBody
|
|
||||||
// public ResponseItem<Exception> processValidationError( Exception ex) throws Exception {
|
|
||||||
// logger.error(ex.getMessage(), ex);
|
|
||||||
// return new ResponseItem<Exception>().message(ex.getMessage()).status(ApiMessageCode.DEFAULT_ERROR_MESSAGE);
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,34 +0,0 @@
|
||||||
//package eu.eudat.controllers.controllerhandler;
|
|
||||||
//
|
|
||||||
//import eu.eudat.exceptions.security.UnauthorisedException;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.http.HttpStatus;
|
|
||||||
//import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
||||||
//import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
//
|
|
||||||
//import jakarta.annotation.Priority;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * Created by ikalyvas on 6/12/2018.
|
|
||||||
// */
|
|
||||||
//@ControllerAdvice
|
|
||||||
//@Priority(4)
|
|
||||||
//public class ControllerUnauthorisedHandler {
|
|
||||||
// private static final Logger logger = LoggerFactory.getLogger(ControllerUnauthorisedHandler.class);
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// public ControllerUnauthorisedHandler() {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @ExceptionHandler(UnauthorisedException.class)
|
|
||||||
// @ResponseStatus(HttpStatus.UNAUTHORIZED)
|
|
||||||
// @ResponseBody
|
|
||||||
// public void processValidationError(UnauthorisedException ex) {
|
|
||||||
// logger.error(ex.getMessage(), ex);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,19 +0,0 @@
|
||||||
//package eu.eudat.controllers.controllerhandler;
|
|
||||||
//
|
|
||||||
//import eu.eudat.exceptions.security.NullEmailException;
|
|
||||||
//import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
//import eu.eudat.types.ApiMessageCode;
|
|
||||||
//import org.springframework.core.annotation.Order;
|
|
||||||
//import org.springframework.http.ResponseEntity;
|
|
||||||
//import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
||||||
//import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
//
|
|
||||||
//@ControllerAdvice
|
|
||||||
//@Order(2)
|
|
||||||
//public class ControllerUserNullEmailHandler {
|
|
||||||
//
|
|
||||||
// @ExceptionHandler(NullEmailException.class)
|
|
||||||
// public ResponseEntity nullEmailException(Exception ex) throws Exception {
|
|
||||||
// return ResponseEntity.status(ApiMessageCode.NULL_EMAIL.getValue()).body("");
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,66 +0,0 @@
|
||||||
//package eu.eudat.controllers.controllerhandler;
|
|
||||||
//
|
|
||||||
//import eu.eudat.models.data.errormodels.ValidationErrorContext;
|
|
||||||
//import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
//import eu.eudat.types.ApiMessageCode;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.MessageSource;
|
|
||||||
//import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
//import org.springframework.core.annotation.Order;
|
|
||||||
//import org.springframework.http.HttpStatus;
|
|
||||||
//import org.springframework.validation.BindingResult;
|
|
||||||
//import org.springframework.validation.FieldError;
|
|
||||||
//import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
||||||
//import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
||||||
//import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
//import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Locale;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//@ControllerAdvice
|
|
||||||
//@Order(3)
|
|
||||||
//public class ControllerValidatorErrorHandler {
|
|
||||||
//
|
|
||||||
// private MessageSource messageSource;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// public ControllerValidatorErrorHandler(MessageSource messageSource) {
|
|
||||||
// this.messageSource = messageSource;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @ExceptionHandler(MethodArgumentNotValidException.class)
|
|
||||||
// @ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
||||||
// @ResponseBody
|
|
||||||
// public ResponseItem<ValidationErrorContext> processValidationError(MethodArgumentNotValidException ex) {
|
|
||||||
// BindingResult result = ex.getBindingResult();
|
|
||||||
// List<FieldError> fieldErrors = result.getFieldErrors();
|
|
||||||
//
|
|
||||||
// return processFieldErrors(fieldErrors);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private ResponseItem<ValidationErrorContext> processFieldErrors(List<FieldError> fieldErrors) {
|
|
||||||
// ValidationErrorContext dto = new ValidationErrorContext();
|
|
||||||
//
|
|
||||||
// for (FieldError fieldError : fieldErrors) {
|
|
||||||
// String localizedErrorMessage = resolveLocalizedErrorMessage(fieldError);
|
|
||||||
// dto.addFieldError(fieldError.getField(), localizedErrorMessage);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return new ResponseItem<ValidationErrorContext>().status(ApiMessageCode.VALIDATION_MESSAGE).payload(dto);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private String resolveLocalizedErrorMessage(FieldError fieldError) {
|
|
||||||
// Locale currentLocale = LocaleContextHolder.getLocale();
|
|
||||||
// String localizedErrorMessage = messageSource.getMessage(fieldError, currentLocale);
|
|
||||||
//
|
|
||||||
// if (localizedErrorMessage.equals(fieldError.getDefaultMessage())) {
|
|
||||||
// String[] fieldErrorCodes = fieldError.getCodes();
|
|
||||||
// localizedErrorMessage = fieldErrorCodes[0];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return localizedErrorMessage;
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -2,13 +2,13 @@ package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.controllers.BaseController;
|
import eu.eudat.controllers.BaseController;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.ExternalValidationService;
|
import eu.eudat.logic.services.ExternalValidationService;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -32,7 +32,7 @@ public class ExternalValidationController extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Boolean>> validate(
|
ResponseEntity<ResponseItem<Boolean>> validate(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound {
|
) throws HugeResultSetException, MyNotFoundException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
Boolean isValid = this.externalValidationService.validateIdentifier(query, type);
|
Boolean isValid = this.externalValidationService.validateIdentifier(query, type);
|
||||||
|
|
|
@ -7,10 +7,9 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.controllers.BaseController;
|
import eu.eudat.controllers.BaseController;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.references.ReferenceService;
|
import eu.eudat.service.reference.ReferenceService;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.builder.ReferenceBuilder;
|
import eu.eudat.model.builder.ReferenceBuilder;
|
||||||
import eu.eudat.model.censorship.ReferenceCensor;
|
import eu.eudat.model.censorship.ReferenceCensor;
|
||||||
|
@ -107,7 +106,7 @@ public class ReferenceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("search")
|
@PostMapping("search")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
||||||
|
|
||||||
|
@ -119,7 +118,7 @@ public class ReferenceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("search-with-db-definition")
|
@PostMapping("search-with-db-definition")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
|
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
|
||||||
|
@ -166,7 +165,7 @@ public class ReferenceController extends BaseController {
|
||||||
// public @ResponseBody ResponseEntity<ResponseItem<List<FetcherReference>>> searchReference(@PathVariable(value = "externalType") int externalType,
|
// public @ResponseBody ResponseEntity<ResponseItem<List<FetcherReference>>> searchReference(@PathVariable(value = "externalType") int externalType,
|
||||||
// @RequestParam(value = "query", required = false) String query,
|
// @RequestParam(value = "query", required = false) String query,
|
||||||
// @RequestParam(value = "type", required = false) String type
|
// @RequestParam(value = "type", required = false) String type
|
||||||
// ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
// ) throws HugeResultSet, MyNotFoundException, InvalidApplicationException {
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
||||||
//
|
//
|
||||||
|
|
|
@ -2,23 +2,32 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
|
import eu.eudat.service.reference.external.ExternalUrlConfigProvider;
|
||||||
|
import eu.eudat.service.reference.external.config.ExternalUrls;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 5/17/2018.
|
* Created by ikalyvas on 5/17/2018.
|
||||||
*/
|
*/
|
||||||
public class CommonsManager {
|
public class CommonsManager {
|
||||||
|
|
||||||
|
|
||||||
public static ExternalSourcesConfiguration getExternalSourcesConfiguration(ConfigLoader configLoader){
|
public static ExternalSourcesConfiguration getExternalSourcesConfiguration(ConfigLoader configLoader, ExternalUrlConfigProvider externalUrlConfigProvider){
|
||||||
ExternalSourcesConfiguration externalSourcesConfiguration = new ExternalSourcesConfiguration();
|
ExternalSourcesConfiguration externalSourcesConfiguration = new ExternalSourcesConfiguration();
|
||||||
externalSourcesConfiguration.setDataRepositories(configLoader.getExternalUrls().getRepositories().getUrls().stream()
|
externalSourcesConfiguration.setDataRepositories(externalUrlConfigProvider.getExternalUrls().getRepositories().getUrls().stream()
|
||||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||||
externalSourcesConfiguration.setExternalDatasets(configLoader.getExternalUrls().getDatasets().getUrls().stream()
|
externalSourcesConfiguration.setExternalDatasets(externalUrlConfigProvider.getExternalUrls().getDatasets().getUrls().stream()
|
||||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||||
externalSourcesConfiguration.setRegistries(configLoader.getExternalUrls().getRegistries().getUrls().stream()
|
externalSourcesConfiguration.setRegistries(externalUrlConfigProvider.getExternalUrls().getRegistries().getUrls().stream()
|
||||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||||
externalSourcesConfiguration.setServices(configLoader.getExternalUrls().getServices().getUrls().stream()
|
externalSourcesConfiguration.setServices(externalUrlConfigProvider.getExternalUrls().getServices().getUrls().stream()
|
||||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||||
/*externalSourcesConfiguration.setTags(configLoader.getExternalUrls().getTags().getUrls().stream()
|
/*externalSourcesConfiguration.setTags(configLoader.getExternalUrls().getTags().getUrls().stream()
|
||||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));*/
|
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));*/
|
||||||
|
|
|
@ -2,14 +2,15 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
import eu.eudat.data.old.DataRepository;
|
import eu.eudat.data.old.DataRepository;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ public class DataRepositoryManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
return apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DataRepositoryModel> getDataRepositories(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<DataRepositoryModel> getDataRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getRepositories(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
@ -58,9 +59,9 @@ public class DataRepositoryManager {
|
||||||
|
|
||||||
return dataRepositoryModels;
|
return dataRepositoryModels;
|
||||||
}
|
}
|
||||||
public List<DataRepositoryModel> getPubRepositories(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<DataRepositoryModel> getPubRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getPubRepositories(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.PubRepositories, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
@ -77,9 +78,9 @@ public class DataRepositoryManager {
|
||||||
|
|
||||||
return dataRepositoryModels;
|
return dataRepositoryModels;
|
||||||
}
|
}
|
||||||
public List<DataRepositoryModel> getJournals(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<DataRepositoryModel> getJournals(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getJournals(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Journals, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
|
|
@ -4,14 +4,18 @@ import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.logic.proxy.config.*;
|
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
|
import eu.eudat.service.reference.external.config.entities.GeneralUrls;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.service.descriptiontemplate.Semantic;
|
import eu.eudat.service.reference.external.config.AuthenticationConfiguration;
|
||||||
|
import eu.eudat.service.reference.external.config.DataFieldsUrlConfiguration;
|
||||||
|
import eu.eudat.service.reference.external.config.DataUrlConfiguration;
|
||||||
|
import eu.eudat.service.reference.external.config.UrlConfiguration;
|
||||||
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -37,7 +41,6 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -134,7 +137,7 @@ public class DatasetProfileManager {
|
||||||
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
||||||
*/
|
*/
|
||||||
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
||||||
ExternalUrlCriteria urlCriteria = new ExternalUrlCriteria();
|
ExternalReferenceCriteria urlCriteria = new ExternalReferenceCriteria();
|
||||||
GeneralUrls genericUrls = new GeneralUrls();
|
GeneralUrls genericUrls = new GeneralUrls();
|
||||||
int ordinal = 1;
|
int ordinal = 1;
|
||||||
List<Map<String, String>> rawResults = new ArrayList<>();
|
List<Map<String, String>> rawResults = new ArrayList<>();
|
||||||
|
|
|
@ -2,21 +2,22 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
import eu.eudat.data.old.ExternalDataset;
|
||||||
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -49,15 +50,15 @@ public class ExternalDatasetManager {
|
||||||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExternalDatasetListingModel> getWithExternal(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<ExternalDatasetListingModel> getWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
// Fetch the local saved external Datasets that belong to the user.
|
// Fetch the local saved external Datasets that belong to the user.
|
||||||
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
||||||
|
|
||||||
// Fetch external Datasets from external sources.
|
// Fetch external Datasets from external sources.
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getDatasets(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Datasets, externalReferenceCriteria, type);
|
||||||
|
|
||||||
// Parse items from external sources to listing models.
|
// Parse items from external sources to listing models.
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
@ -72,7 +73,7 @@ public class ExternalDatasetManager {
|
||||||
return externalDatasets;
|
return externalDatasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalDatasetListingModel getSingle(UUID id) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException, InvalidApplicationException {
|
public ExternalDatasetListingModel getSingle(UUID id) throws HugeResultSetException, MyNotFoundException, InstantiationException, IllegalAccessException, InvalidApplicationException {
|
||||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().find(id);
|
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().find(id);
|
||||||
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetListingModel();
|
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetListingModel();
|
||||||
externalDatasetModel.fromDataModel(externalDataset);
|
externalDatasetModel.fromDataModel(externalDataset);
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
||||||
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
import eu.eudat.logic.utilities.helpers.ListHelper;
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
import eu.eudat.models.data.external.FundersExternalSourcesModel;
|
import eu.eudat.models.data.external.FundersExternalSourcesModel;
|
||||||
import eu.eudat.models.data.funder.Funder;
|
import eu.eudat.models.data.funder.Funder;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
@ -37,15 +38,15 @@ public class FunderManager {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Funder> getCriteriaWithExternal(FunderCriteriaRequest funderCriteria) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<Funder> getCriteriaWithExternal(FunderCriteriaRequest funderCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
UserEntity userInfo = new UserEntity();
|
UserEntity userInfo = new UserEntity();
|
||||||
userInfo.setId(this.userScope.getUserId());
|
userInfo.setId(this.userScope.getUserId());
|
||||||
funderCriteria.getCriteria().setReference("dmp:");
|
funderCriteria.getCriteria().setReference("dmp:");
|
||||||
QueryableList<eu.eudat.data.old.Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria.getCriteria());
|
QueryableList<eu.eudat.data.old.Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria.getCriteria());
|
||||||
QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
|
QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
|
||||||
List<Funder> funders = authItems.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item));
|
List<Funder> funders = authItems.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item));
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(funderCriteria.getCriteria().getLike());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(funderCriteria.getCriteria().getLike());
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getFunders(externalUrlCriteria);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Funder, externalReferenceCriteria, null);
|
||||||
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
|
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
|
||||||
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
||||||
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
import eu.eudat.data.dao.entities.GrantDao;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
import eu.eudat.logic.utilities.helpers.ListHelper;
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
|
@ -14,11 +15,11 @@ import eu.eudat.models.data.grant.Grant;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
||||||
import eu.eudat.models.data.grant.GrantListingModel;
|
import eu.eudat.models.data.grant.GrantListingModel;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
@ -105,7 +106,7 @@ public class GrantManager {
|
||||||
return grant;
|
return grant;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public List<eu.eudat.models.data.grant.Grant> getCriteriaWithExternal(GrantCriteriaRequest grantCriteria) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<eu.eudat.models.data.grant.Grant> getCriteriaWithExternal(GrantCriteriaRequest grantCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
UserEntity userInfo = new UserEntity();
|
UserEntity userInfo = new UserEntity();
|
||||||
userInfo.setId(this.userScope.getUserId());
|
userInfo.setId(this.userScope.getUserId());
|
||||||
/*if (grantCriteria.getCriteria().getFunderReference() != null && !grantCriteria.getCriteria().getFunderReference().trim().isEmpty()) {
|
/*if (grantCriteria.getCriteria().getFunderReference() != null && !grantCriteria.getCriteria().getFunderReference().trim().isEmpty()) {
|
||||||
|
@ -116,9 +117,9 @@ public class GrantManager {
|
||||||
grantCriteria.getCriteria().setFunderId(funder.getId().toString());
|
grantCriteria.getCriteria().setFunderId(funder.getId().toString());
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(grantCriteria.getCriteria().getLike());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(grantCriteria.getCriteria().getLike());
|
||||||
if (grantCriteria.getCriteria().getFunderReference() != null) {
|
if (grantCriteria.getCriteria().getFunderReference() != null) {
|
||||||
externalUrlCriteria.setFunderId(grantCriteria.getCriteria().getFunderReference());
|
externalReferenceCriteria.setFunderId(grantCriteria.getCriteria().getFunderReference());
|
||||||
grantCriteria.getCriteria().setFunderReference(null);
|
grantCriteria.getCriteria().setFunderReference(null);
|
||||||
}
|
}
|
||||||
grantCriteria.getCriteria().setReference("dmp:");
|
grantCriteria.getCriteria().setReference("dmp:");
|
||||||
|
@ -126,7 +127,7 @@ public class GrantManager {
|
||||||
QueryableList<eu.eudat.data.old.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo);
|
QueryableList<eu.eudat.data.old.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo);
|
||||||
List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item));
|
List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item));
|
||||||
|
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getGrants(externalUrlCriteria);
|
List<Map<String, String>> remoteRepos = remoteFetcher.get(ReferenceType.Grants, externalReferenceCriteria, null);
|
||||||
|
|
||||||
GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos);
|
GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
for (ExternalSourcesItemModel externalListingItem : grantsExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : grantsExternalSourcesModel) {
|
||||||
|
@ -145,7 +146,7 @@ public class GrantManager {
|
||||||
return grants;
|
return grants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<eu.eudat.models.data.grant.Grant> getCriteria(GrantCriteriaRequest grantCriteria) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<eu.eudat.models.data.grant.Grant> getCriteria(GrantCriteriaRequest grantCriteria) throws IllegalAccessException, InstantiationException, HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||||
QueryableList<eu.eudat.data.old.Grant> items = grantRepository.getWithCriteria(grantCriteria.getCriteria());
|
QueryableList<eu.eudat.data.old.Grant> items = grantRepository.getWithCriteria(grantCriteria.getCriteria());
|
||||||
if (grantCriteria.getLength() != null) items.take(grantCriteria.getLength());
|
if (grantCriteria.getLength() != null) items.take(grantCriteria.getLength());
|
||||||
|
|
|
@ -2,12 +2,13 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
import eu.eudat.models.data.license.LicenseModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -28,9 +29,9 @@ public class LicenseManager {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSet, NoURLFound {
|
public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getlicenses(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Licenses, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
||||||
import eu.eudat.logic.builders.model.models.OrganisationBuilder;
|
import eu.eudat.logic.builders.model.models.OrganisationBuilder;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
import eu.eudat.models.data.dmp.Organisation;
|
||||||
|
@ -15,6 +15,7 @@ import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -80,8 +81,8 @@ public class OrganisationsManager {
|
||||||
|
|
||||||
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(organisationsTableRequest.getCriteria().getLabelLike());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(organisationsTableRequest.getCriteria().getLabelLike());
|
||||||
List<Map<String, String>> remoteRepos = apiContext.getOperationsContext().getRemoteFetcher().getOrganisations(externalUrlCriteria, null);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, null);
|
||||||
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
||||||
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
|
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
|
||||||
|
@ -95,9 +96,9 @@ public class OrganisationsManager {
|
||||||
return org;
|
return org;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSet, NoURLFound {
|
public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = apiContext.getOperationsContext().getRemoteFetcher().getOrganisations(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, type);
|
||||||
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
List<Organisation> organisations = new LinkedList<>();
|
List<Organisation> organisations = new LinkedList<>();
|
||||||
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
||||||
|
|
|
@ -4,52 +4,62 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.logic.mapper.prefilling.PrefillingMapper;
|
import eu.eudat.logic.mapper.prefilling.PrefillingMapper;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.ExternalUrlConfigProvider;
|
||||||
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
|
import eu.eudat.service.reference.external.config.ExternalUrls;
|
||||||
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingConfig;
|
import eu.eudat.service.reference.external.config.entities.PrefillingConfig;
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingGet;
|
import eu.eudat.service.reference.external.config.entities.PrefillingGet;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.prefilling.Prefilling;
|
import eu.eudat.models.data.prefilling.Prefilling;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PrefillingManager {
|
public class PrefillingManager {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PrefillingManager.class);
|
||||||
|
|
||||||
private final ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private final ConfigLoader configLoader;
|
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
private final LicenseManager licenseManager;
|
private final LicenseManager licenseManager;
|
||||||
private final PrefillingMapper prefillingMapper;
|
private final PrefillingMapper prefillingMapper;
|
||||||
|
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper) {
|
public PrefillingManager(ApiContext apiContext, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper, ExternalUrlConfigProvider externalUrlConfigProvider) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.configLoader = configLoader;
|
|
||||||
this.prefillingMapper = prefillingMapper;
|
this.prefillingMapper = prefillingMapper;
|
||||||
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||||
|
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.licenseManager = licenseManager;
|
this.licenseManager = licenseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Prefilling> getPrefillings(String like) {
|
public List<Prefilling> getPrefillings(String like) {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria();
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
|
||||||
externalUrlCriteria.setLike(like);
|
externalReferenceCriteria.setLike(like);
|
||||||
List<Prefilling> prefillings = new ArrayList<>();
|
List<Prefilling> prefillings = new ArrayList<>();
|
||||||
List<Map<String, String>> map;
|
List<Map<String, String>> map;
|
||||||
Map<String, PrefillingConfig> prefillingConfigs = configLoader.getExternalUrls().getPrefillings();
|
Map<String, PrefillingConfig> prefillingConfigs = this.externalUrlConfigProvider.getExternalUrls().getPrefillings();
|
||||||
for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {
|
for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {
|
||||||
map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
|
map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
|
||||||
prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList()));
|
prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList()));
|
||||||
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
|
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
|
||||||
List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
|
List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
|
||||||
for (int i = 0; i < mapData.size(); i++) {
|
for (int i = 0; i < mapData.size(); i++) {
|
||||||
prefillings.get(i).setData(mapData.get(i));
|
prefillings.get(i).setData(mapData.get(i));
|
||||||
}
|
}
|
||||||
|
@ -60,7 +70,7 @@ public class PrefillingManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getPrefilledDataset(String prefillId, String configId, UUID profileId) throws Exception {
|
public DatasetWizardModel getPrefilledDataset(String prefillId, String configId, UUID profileId) throws Exception {
|
||||||
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(configId);
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
|
@ -68,7 +78,7 @@ public class PrefillingManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
||||||
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(configId);
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager, licenseManager);
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager, licenseManager);
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
import eu.eudat.logic.utilities.helpers.ListHelper;
|
||||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||||
import eu.eudat.logic.builders.model.models.ProjectBuilder;
|
import eu.eudat.logic.builders.model.models.ProjectBuilder;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
@ -37,15 +38,15 @@ public class ProjectManager {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
UserEntity userInfo = new UserEntity();
|
UserEntity userInfo = new UserEntity();
|
||||||
userInfo.setId(this.userScope.getUserId());
|
userInfo.setId(this.userScope.getUserId());
|
||||||
projectCriteria.getCriteria().setReference("dmp:");
|
projectCriteria.getCriteria().setReference("dmp:");
|
||||||
QueryableList<eu.eudat.data.old.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
|
QueryableList<eu.eudat.data.old.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
|
||||||
QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
||||||
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(projectCriteria.getCriteria().getLike());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(projectCriteria.getCriteria().getLike());
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(externalUrlCriteria);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, null);
|
||||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
||||||
eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)
|
eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)
|
||||||
|
|
|
@ -2,12 +2,13 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.publication.PublicationModel;
|
import eu.eudat.models.data.publication.PublicationModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -25,9 +26,9 @@ public class PublicationManager {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PublicationModel> getPublications(String query, String type) throws HugeResultSet, NoURLFound {
|
public List<PublicationModel> getPublications(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getPublications(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Publications, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
|
|
@ -2,14 +2,15 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
||||||
import eu.eudat.data.old.Registry;
|
import eu.eudat.data.old.Registry;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.registries.RegistryModel;
|
import eu.eudat.models.data.registries.RegistryModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -40,9 +41,9 @@ public class RegistryManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
|
return apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegistryModel> getRegistries(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<RegistryModel> getRegistries(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getRegistries(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Registries, externalReferenceCriteria, type);
|
||||||
|
|
||||||
RegistryCriteria criteria = new RegistryCriteria();
|
RegistryCriteria criteria = new RegistryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.logic.builders.model.models.ResearcherBuilder;
|
import eu.eudat.logic.builders.model.models.ResearcherBuilder;
|
||||||
import eu.eudat.data.old.Researcher;
|
import eu.eudat.data.old.Researcher;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
import eu.eudat.models.data.external.ResearchersExternalSourcesModel;
|
import eu.eudat.models.data.external.ResearchersExternalSourcesModel;
|
||||||
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.query.UserQuery;
|
import eu.eudat.query.UserQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ public class ResearcherManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
|
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<eu.eudat.models.data.dmp.Researcher> getCriteriaWithExternal(ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<eu.eudat.models.data.dmp.Researcher> getCriteriaWithExternal(ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
|
|
||||||
QueryableList<Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
|
QueryableList<Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
|
||||||
items.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), this.userScope.getUserId()));
|
items.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), this.userScope.getUserId()));
|
||||||
|
@ -63,8 +64,8 @@ public class ResearcherManager {
|
||||||
else
|
else
|
||||||
item.setTag(keyToSourceMap.get(item.getKey()));
|
item.setTag(keyToSourceMap.get(item.getKey()));
|
||||||
}
|
}
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(researcherCriteriaRequest.getCriteria().getName());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(researcherCriteriaRequest.getCriteria().getName());
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getResearchers(externalUrlCriteria,null);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Researcher, externalReferenceCriteria, null);
|
||||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||||
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
|
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
|
||||||
eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)
|
eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)
|
||||||
|
|
|
@ -3,15 +3,16 @@ package eu.eudat.logic.managers;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
||||||
import eu.eudat.data.old.Service;
|
import eu.eudat.data.old.Service;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.services.ServiceModel;
|
import eu.eudat.models.data.services.ServiceModel;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -43,12 +44,12 @@ public class ServiceManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
return apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ServiceModel> getServices(String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
public List<ServiceModel> getServices(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getServices(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Services, externalReferenceCriteria, type);
|
||||||
|
|
||||||
ServiceCriteria criteria = new ServiceCriteria();
|
ServiceCriteria criteria = new ServiceCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
criteria.setCreationUserId(userScope.getUserId());
|
criteria.setCreationUserId(userScope.getUserId());
|
||||||
|
|
|
@ -2,12 +2,13 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -26,9 +27,9 @@ public class TaxonomyManager {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaxonomyModel> getTaxonomies(String query, String type) throws HugeResultSet, NoURLFound {
|
public List<TaxonomyModel> getTaxonomies(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getTaxonomies(externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Taxonomies, externalReferenceCriteria, type);
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ValidationManager {
|
public class ValidationManager {
|
||||||
|
@ -22,9 +22,9 @@ public class ValidationManager {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean validateIdentifier(String identifier, String type) throws NoURLFound, HugeResultSet {
|
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(identifier);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
|
||||||
Integer count = this.remoteFetcher.findEntries(externalUrlCriteria, type);
|
Integer count = this.remoteFetcher.findEntries(externalReferenceCriteria, type);
|
||||||
return this.userScope.isSet() && count > 0;
|
return this.userScope.isSet() && count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,11 @@ import eu.eudat.data.TagEntity;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.managers.LicenseManager;
|
import eu.eudat.logic.managers.LicenseManager;
|
||||||
import eu.eudat.logic.proxy.config.entities.DefaultPrefillingMapping;
|
import eu.eudat.service.reference.external.config.entities.DefaultPrefillingMapping;
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingFixedMapping;
|
import eu.eudat.service.reference.external.config.entities.PrefillingFixedMapping;
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingGet;
|
import eu.eudat.service.reference.external.config.entities.PrefillingGet;
|
||||||
import eu.eudat.logic.proxy.config.entities.PrefillingMapping;
|
import eu.eudat.service.reference.external.config.entities.PrefillingMapping;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
import eu.eudat.logic.utilities.json.JsonSearcher;
|
import eu.eudat.logic.utilities.json.JsonSearcher;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||||
|
@ -23,6 +22,7 @@ import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
import eu.eudat.models.data.license.LicenseModel;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -209,7 +209,7 @@ public class PrefillingMapper {
|
||||||
properties.put(id, mapper.writeValueAsString(licenses.get(0)));
|
properties.put(id, mapper.writeValueAsString(licenses.get(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NoURLFound | HugeResultSet e){
|
catch (MyNotFoundException | HugeResultSetException e){
|
||||||
properties.put(id, parsedValue);
|
properties.put(id, parsedValue);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package eu.eudat.logic.proxy.config;
|
|
||||||
|
|
||||||
public enum FetchStrategy {
|
|
||||||
|
|
||||||
FIRST,
|
|
||||||
ALL
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +1,14 @@
|
||||||
package eu.eudat.logic.proxy.config.configloaders;
|
package eu.eudat.logic.proxy.config.configloaders;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrls;
|
|
||||||
import eu.eudat.service.descriptiontemplate.Semantic;
|
import eu.eudat.service.descriptiontemplate.Semantic;
|
||||||
import eu.eudat.models.data.pid.PidLinks;
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
|
import eu.eudat.service.reference.external.config.ExternalUrls;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ConfigLoader {
|
public interface ConfigLoader {
|
||||||
ExternalUrls getExternalUrls();
|
|
||||||
XWPFDocument getDocument();
|
XWPFDocument getDocument();
|
||||||
XWPFDocument getDatasetDocument();
|
XWPFDocument getDatasetDocument();
|
||||||
PidLinks getPidLinks();
|
PidLinks getPidLinks();
|
||||||
|
|
|
@ -2,8 +2,8 @@ package eu.eudat.logic.proxy.config.configloaders;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrls;
|
|
||||||
import eu.eudat.models.data.pid.PidLinks;
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
|
import eu.eudat.service.reference.external.config.ExternalUrls;
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -25,17 +25,14 @@ import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service("configLoader")
|
@Service("configLoader")
|
||||||
//@Profile("devel")
|
|
||||||
public class DefaultConfigLoader implements ConfigLoader {
|
public class DefaultConfigLoader implements ConfigLoader {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DefaultConfigLoader.class);
|
private static final Logger logger = LoggerFactory.getLogger(DefaultConfigLoader.class);
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
private static final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
private ExternalUrls externalUrls;
|
|
||||||
private XWPFDocument document;
|
private XWPFDocument document;
|
||||||
private XWPFDocument datasetDocument;
|
private XWPFDocument datasetDocument;
|
||||||
private PidLinks pidLinks;
|
private PidLinks pidLinks;
|
||||||
|
@ -45,17 +42,6 @@ public class DefaultConfigLoader implements ConfigLoader {
|
||||||
private StorageFileService storageFileService;
|
private StorageFileService storageFileService;
|
||||||
|
|
||||||
|
|
||||||
private void setExternalUrls() {
|
|
||||||
byte[] bytes = this.storageFileService.getExternalUrlsFile();
|
|
||||||
try {
|
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
|
|
||||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
|
||||||
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(bytes));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error("Cannot find resource", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDocument() {
|
private void setDocument() {
|
||||||
byte[] bytes = this.storageFileService.getH2020TemplateFile();
|
byte[] bytes = this.storageFileService.getH2020TemplateFile();
|
||||||
try {
|
try {
|
||||||
|
@ -115,16 +101,6 @@ public class DefaultConfigLoader implements ConfigLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ExternalUrls getExternalUrls() {
|
|
||||||
if (externalUrls == null) {
|
|
||||||
externalUrls = new ExternalUrls();
|
|
||||||
this.setExternalUrls();
|
|
||||||
}
|
|
||||||
return externalUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public XWPFDocument getDocument() {
|
public XWPFDocument getDocument() {
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package eu.eudat.logic.proxy.config.entities;
|
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
|
||||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class GenericUrls {
|
|
||||||
|
|
||||||
public abstract List<UrlConfiguration> getUrls();
|
|
||||||
public abstract FetchStrategy getFetchMode();
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package eu.eudat.logic.proxy.config.exceptions;
|
|
||||||
|
|
||||||
public class HugeResultSet extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6961447213733280563L;
|
|
||||||
|
|
||||||
|
|
||||||
public HugeResultSet(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package eu.eudat.logic.proxy.config.exceptions;
|
|
||||||
|
|
||||||
public class NoURLFound extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6961447213733280563L;
|
|
||||||
|
|
||||||
|
|
||||||
public NoURLFound(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.logic.services;
|
package eu.eudat.logic.services;
|
||||||
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ public class ExternalValidationService {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean validateIdentifier(String identifier, String type) throws NoURLFound, HugeResultSet {
|
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(identifier);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
|
||||||
Integer count = this.remoteFetcher.findEntries(externalUrlCriteria, type);
|
Integer count = this.remoteFetcher.findEntries(externalReferenceCriteria, type);
|
||||||
return userScope.isSet() && count > 0;
|
return userScope.isSet() && count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.services.operations;
|
package eu.eudat.logic.services.operations;
|
||||||
|
|
||||||
import eu.eudat.logic.builders.BuilderFactory;
|
import eu.eudat.logic.builders.BuilderFactory;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.logic.services.operations;
|
package eu.eudat.logic.services.operations;
|
||||||
|
|
||||||
import eu.eudat.logic.builders.BuilderFactory;
|
import eu.eudat.logic.builders.BuilderFactory;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import eu.eudat.service.reference.external.RemoteFetcher;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
Loading…
Reference in New Issue