Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot

This commit is contained in:
Nikolaos Laskaris 2017-11-22 12:24:48 +02:00
commit b48a4b6264
23 changed files with 687 additions and 43 deletions

View File

@ -79,6 +79,12 @@
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- MY SPRING -->
@ -225,7 +231,11 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
<!-- Json Web Tokens -->

View File

@ -0,0 +1,43 @@
package cache;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.cache.guava.GuavaCache;
import com.google.common.cache.CacheBuilder;
@Component
@EnableCaching
public class ResponsesCache {
public static long HOW_MANY = 30;
public static TimeUnit TIME_UNIT = TimeUnit.MINUTES;
@Bean
public CacheManager cacheManager() {
System.out.print("Loading ResponsesCache...");
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
List<GuavaCache> caches = new ArrayList<GuavaCache>();
caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("projects", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("organisations", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("registries", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
simpleCacheManager.setCaches(caches);
System.out.println("OK");
return simpleCacheManager;
}
}

View File

@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module.Feature;
@ -40,6 +41,11 @@ public class SerializerProvider {
;
}
public static CollectionType constructTypeFor(Class<? extends Collection> collectionClass, Class<?> elementClass) {
return objectMapper.getTypeFactory().constructCollectionType(collectionClass, elementClass);
}
public static ObjectMapper getJsonSerializer() {
if(objectMapper==null)
initialize();
@ -67,9 +73,11 @@ public class SerializerProvider {
return getJsonSerializer().readValue(jsonObject, type);
}
public static <T> T fromJson(String jsonObject, TypeReference type) throws Exception {
return getJsonSerializer().readValue(jsonObject, type);
public static <T> T fromJson(String jsonObject, TypeReference typeRef) throws Exception {
return getJsonSerializer().readValue(jsonObject, typeRef);
}
}

View File

@ -9,26 +9,25 @@ import javax.xml.bind.Unmarshaller;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Loader {
public class ConfigLoader {
private ExternalUrls externalUrls;
// public static void main(String [] args) {
// Loader l = new Loader("file:///home/nikolas/git/OpenAIRE-EUDAT-DMP/dmp-backend/src/main/resources/ExternalUrls.xml");
// ConfigLoader l = new ConfigLoader("file:///home/nikolas/git/OpenAIRE-EUDAT-DMP/dmp-backend/src/main/resources/ExternalUrls.xml");
// }
public Loader(String fileUrl) {
System.out.println("LOADING FILE: "+fileUrl);
public ConfigLoader(String fileUrl) {
System.out.println("Loaded also config file: "+fileUrl);
InputStream is = null;
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL(fileUrl).openStream();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
System.out.println(new ObjectMapper().writeValueAsString(externalUrls));
// System.out.println(new ObjectMapper().writeValueAsString(externalUrls));
}
catch(Exception ex) {
//log the error and shutdown the system (that's a critical error)
@ -43,6 +42,11 @@ public class Loader {
}
}
}
public ExternalUrls getExternalUrls() {
return externalUrls;
}

View File

@ -7,6 +7,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import proxy.config.entities.OrganisationUrls;
import proxy.config.entities.ProjectUrls;
import proxy.config.entities.RegistryUrls;
import proxy.config.entities.RepositoryUrls;
import proxy.config.entities.ResearcherUrls;
@ -19,6 +20,9 @@ public class ExternalUrls implements Serializable {
private static final long serialVersionUID = -5076364662014107275L;
Long maxresults;
ProjectUrls projects;
RegistryUrls registries;
RepositoryUrls repositories;
ServiceUrls services;
@ -75,6 +79,26 @@ public class ExternalUrls implements Serializable {
public void setOrganisations(OrganisationUrls organisations) {
this.organisations = organisations;
}
public ProjectUrls getProjects() {
return projects;
}
@XmlElement(name = "projects")
public void setProjects(ProjectUrls projects) {
this.projects = projects;
}
public Long getMaxresults() {
return maxresults;
}
@XmlElement(name = "maxresults")
public void setMaxresults(Long maxresults) {
this.maxresults = maxresults;
}

View File

@ -1,23 +1,25 @@
package proxy.config;
import java.net.URL;
import javax.xml.bind.annotation.XmlElement;
//private static String DATAPATH = "$['data'][*]['attributes']['pid','name','uri','description']";
//private static String PAGINATIONPATH = "$['meta']['pagination']['page','pages','count']";
public class UrlConfig {
private URL url;
private Integer ordinal;
private String url;
private String dataPath;
private String paginationPath;
public URL getUrl() {
public String getUrl() {
return url;
}
@XmlElement(name = "url")
public void setUrl(URL url) {
public void setUrl(String url) {
this.url = url;
}
public Integer getOrdinal() {
@ -27,6 +29,22 @@ public class UrlConfig {
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public String getDataPath() {
return dataPath;
}
@XmlElement(name = "datapath")
public void setDataPath(String dataPath) {
this.dataPath = dataPath;
}
public String getPaginationPath() {
return paginationPath;
}
@XmlElement(name = "paginationpath")
public void setPaginationPath(String paginationPath) {
this.paginationPath = paginationPath;
}

View File

@ -0,0 +1,33 @@
package proxy.config.entities;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import proxy.config.FetchStrategy;
import proxy.config.UrlConfig;
public class ProjectUrls {
List<UrlConfig> urls;
FetchStrategy fetchMode;
public List<UrlConfig> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfig> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -0,0 +1,13 @@
package proxy.config.exceptions;
public class HugeResultSet extends Exception {
private static final long serialVersionUID = -6961447213733280563L;
public HugeResultSet(String message) {
super(message);
}
}

View File

@ -0,0 +1,13 @@
package proxy.config.exceptions;
public class NoURLFound extends Exception {
private static final long serialVersionUID = -6961447213733280563L;
public NoURLFound(String message) {
super(message);
}
}

View File

@ -0,0 +1,205 @@
package proxy.fetching;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.google.common.collect.ContiguousSet;
import com.google.common.collect.DiscreteDomain;
import com.google.common.collect.Range;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import proxy.config.ConfigLoader;
import proxy.config.UrlConfig;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
@Service
public class RemoteFetcher {
@Autowired private ConfigLoader configLoader;
// private static int MAX_RESULTS = 30;
// public static void main(String [] args) throws Exception {
//
// String path = "https://eestore.paas2.uninett.no/api/datarepo";
// String query = "her";
//
// RemoteFetcher remoteFetcher = new RemoteFetcher();
// List<Map<String, String>> repos = remoteFetcher.getAllResultsFromUrl(path, query);
//
//// List<Map<String, String>> repos = remoteFetcher.getRepositories(query);
// System.out.println(repos.size());
//
// }
@Cacheable("repositories")
public List<Map<String, String>> getRepositories(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getRepositories().getUrls();
return getAll(urlConfigs, query);
}
@Cacheable("projects")
public List<Map<String, String>> getProjects(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getProjects().getUrls();
return getAll(urlConfigs, query);
}
@Cacheable("organisations")
public List<Map<String, String>> getOrganisations(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getOrganisations().getUrls();
return getAll(urlConfigs, query);
}
@Cacheable("registries")
public List<Map<String, String>> getRegistries(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getRegistries().getUrls();
return getAll(urlConfigs, query);
}
@Cacheable("services")
public List<Map<String, String>> getServices(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getServices().getUrls();
return getAll(urlConfigs, query);
}
@Cacheable("researchers")
public List<Map<String, String>> getResearchers(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getResearchers().getUrls();
return getAll(urlConfigs, query);
}
private List<Map<String, String>> getAll(List<UrlConfig> urlConfigs, String query) throws NoURLFound, HugeResultSet{
if(urlConfigs == null || urlConfigs.isEmpty())
throw new NoURLFound("No Repository urls found in configuration");
Collections.sort(urlConfigs, (config1, config2) -> config1.getOrdinal().compareTo(config2.getOrdinal()));
//for the time being, we only get the first one. in the near future we can add more than one (parallel stream)
//urlConfigs.parallelStream().map(mapper).reduce() etc etc
return getAllResultsFromUrl(urlConfigs.get(0).getUrl(), urlConfigs.get(0).getDataPath(), urlConfigs.get(0).getPaginationPath(), query);
}
private List<Map<String, String>> getAllResultsFromUrl(String path, final String jsonDataPath, final String jsonPaginationPath, String query) throws HugeResultSet {
Set<Integer> pages = new HashSet<Integer>();
final String searchQuery = (query!=null) && !query.isEmpty() ? "&search="+query : "";
//first call
Results results = getResultsFromUrl(path + "?page=1" + searchQuery, jsonDataPath, jsonPaginationPath);
if(results.getPagination()!= null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
for(int i = 2; i <= results.getPagination().get("pages") ; i++)
pages.add(i);
Long maxResults = configLoader.getExternalUrls().getMaxresults();
if( (maxResults > 0) && (results.getPagination().get("count") > maxResults) )
throw new HugeResultSet("The submitted search query "+query+" is about to return "+results.getPagination().get("count") +" results... Please submit a more detailed search query");
//remaining calls (if pages array has elements)
Optional<Results> optionalResults = pages.parallelStream()
.map(page -> getResultsFromUrl(path + "?page="+page + searchQuery, jsonDataPath, jsonPaginationPath))
.reduce((result1, result2) -> {
result1.getResults().addAll(result2.getResults());
return result1;
});
Results remainingResults = optionalResults.isPresent() ? optionalResults.get() : new Results();
remainingResults.getResults().addAll(results.getResults());
return remainingResults.getResults();
}
private Results getResultsFromUrl(String urlString, String jsonDataPath, String jsonPaginationPath) {
try {
URL url = new URL(urlString);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Accept", "application/vnd.api+json; charset=utf-8");
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) { // success
//do here all the parsing
DocumentContext jsonContext = JsonPath.parse(con.getInputStream());
Results results = new Results(jsonContext.read(jsonDataPath), jsonContext.read(jsonPaginationPath));
return results;
}
}
catch(MalformedURLException e1) {} //maybe print smth...
catch(IOException e2) {} //maybe print smth...
finally {}
return null;
}
class Results {
List<Map<String, String>> results;
Map<String, Integer> pagination;
public Results() {
this.results = new ArrayList<Map<String,String>>();
this.pagination = new HashMap<String,Integer>();
}
public Results(List<Map<String, String>> results, Map<String, Integer> pagination) {
this.results = results;
this.pagination = pagination;
}
public List<Map<String, String>> getResults() {
return results;
}
public void setResults(List<Map<String, String>> results) {
this.results = results;
}
public Map<String, Integer> getPagination() {
return pagination;
}
public void setPagination(Map<String, Integer> pagination) {
this.pagination = pagination;
}
}
}

View File

@ -1,6 +1,8 @@
package rest.entities;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@ -36,6 +38,7 @@ import dao.entities.ProjectDao;
import dao.entities.RegistryDao;
import dao.entities.ResearcherDao;
import dao.entities.ServiceDao;
import dao.entities.UserInfoDao;
import entities.DMP;
import entities.DMPProfile;
import entities.DataRepository;
@ -49,6 +52,9 @@ import entities.Researcher;
import entities.Service;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -69,6 +75,27 @@ public class DataRepositories {
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/datarepos" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalDataRepositories(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getRepositories(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE DATAREPOSITORy(IES)
@RequestMapping(method = RequestMethod.GET, value = { "/datarepos" })

View File

@ -1,6 +1,7 @@
package rest.entities;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@ -49,6 +50,9 @@ import entities.Researcher;
import entities.Service;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -70,6 +74,23 @@ public class Organisations {
@Autowired private ServiceDao serviceDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/organisations" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getOrganisations(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE ORGANISATIONS(S)

View File

@ -61,6 +61,9 @@ import entities.UserInfo;
import entities.responses.IDLabelPair;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -82,6 +85,23 @@ public class Projects {
@Autowired private ServiceDao serviceDao;
@Autowired private UserInfoDao userInfoDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalProjects(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getProjects(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE PROJECT(S)

View File

@ -1,6 +1,7 @@
package rest.entities;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@ -49,6 +50,9 @@ import entities.Service;
import entities.responses.IDLabelPair;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -69,6 +73,23 @@ public class Registries {
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/registries" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getRegistries(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE REGISTRY(IES)

View File

@ -1,6 +1,7 @@
package rest.entities;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@ -49,6 +50,9 @@ import entities.Researcher;
import entities.Service;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -69,6 +73,23 @@ public class Researchers {
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/researchers" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getResearchers(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE RESEARCHER(S)

View File

@ -2,6 +2,7 @@ package rest.entities;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@ -50,6 +51,9 @@ import entities.Researcher;
import entities.Service;
import helpers.SerializerProvider;
import helpers.Transformers;
import proxy.config.exceptions.HugeResultSet;
import proxy.config.exceptions.NoURLFound;
import proxy.fetching.RemoteFetcher;
import responses.RestResponse;
@ -70,6 +74,22 @@ public class Services {
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
@Autowired private RemoteFetcher remoteFetcher;
@RequestMapping(method = RequestMethod.GET, value = { "/external/services" }, produces="application/json")
public @ResponseBody ResponseEntity<Object> listExternalServices(@RequestParam(value="query", required=false) String query ){
try {
List<Map<String,String>> remoteRepos = remoteFetcher.getServices(query);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(remoteRepos));
}
catch(NoURLFound ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
catch(HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"reason\":\""+ex.getMessage()+"\"}"); //the ex.getMessage has the appropriate text description
}
}
// MANAGE SERVICE(S)

View File

@ -2,31 +2,53 @@
<externalUrls>
<maxresults>1000</maxresults> <!-- if you want it disabled, please enter a negative number -->
<registries>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</registries>
<repositories>
<urls>
<urlConfig>
<url>https://eestore.paas2.uninett.no/api/datarepo/</url>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/metadataschemarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</registries>
<projects>
<urls>
<urlConfig>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</projects>
<repositories>
<urls>
<urlConfig>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/datarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</repositories>
@ -34,9 +56,12 @@
<services>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/servicerepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
@ -47,9 +72,12 @@
<researchers>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/personrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
@ -61,9 +89,12 @@
<organisations>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/organizationrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>

View File

@ -1,16 +1,21 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:property-placeholder location="classpath*:**/dmp.properties" />
<!-- <cache:annotation-driven /> -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
@ -44,9 +49,12 @@
<bean id="customAuthenticationProvider" class="security.CustomAuthenticationProvider" />
<bean id="externalUrlLoader" class="proxy.config.Loader">
<bean id="externalUrlLoader" class="proxy.config.ConfigLoader">
<constructor-arg type="java.lang.String" value = "classpath:ExternalUrls.xml"/>
</bean>
<bean class="proxy.fetching.RemoteFetcher" />
<bean id="emf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">

View File

@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:property-placeholder location="classpath*:**/dmp.properties" />
@ -16,6 +19,8 @@
<mvc:annotation-driven />
<context:component-scan base-package="login" />
<!-- <cache:annotation-driven /> -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000000" />

View File

@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:property-placeholder location="classpath*:**/dmp.properties" />
@ -16,6 +19,7 @@
<mvc:annotation-driven />
<context:component-scan base-package="proxy" />
<!-- <cache:annotation-driven /> -->
<bean id="proxy" class="proxy.Proxy">
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>

View File

@ -1,22 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:property-placeholder location="classpath*:**/dmp.properties" />
<mvc:resources mapping="resources/**" location="/resources/" />
<mvc:annotation-driven />
<context:component-scan base-package="rest" />
<context:component-scan base-package="rest" />
<context:component-scan base-package="cache" />
<context:component-scan base-package="proxy.fetching" />
<cache:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<externalUrls>
<registries>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</registries>
<repositories>
<urls>
<urlConfig>
<url>https://eestore.paas2.uninett.no/api/datarepo/</url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</repositories>
<services>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</services>
<researchers>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</researchers>
<organisations>
<urls>
<urlConfig>
<url></url>
<ordinal>1</ordinal>
</urlConfig>
</urls>
<fetchMode>ALL</fetchMode>
</organisations>
</externalUrls>

View File

@ -35,6 +35,12 @@
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
</bean>
<bean id="externalUrlLoader" class="proxy.config.ConfigLoader">
<constructor-arg type="java.lang.String" value = "classpath:ExternalUrlsTEST.xml"/>
</bean>
<bean id="springApplicationContext" class="dao.SpringJpaDaoFactory" />
<bean id="databaseColumnType" class="typedefinition.PostgreSQLDatabaseColumnType" />
@ -112,6 +118,7 @@
<context:component-scan base-package="dao" />
<context:component-scan base-package="core" />
<context:component-scan base-package="rest" />
<context:component-scan base-package="proxy.fetching" />
<!-- <context:component-scan base-package="controller" /> -->