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

This commit is contained in:
Nikolaos Laskaris 2017-11-21 12:56:26 +02:00
commit 2390cf2760
13 changed files with 433 additions and 5 deletions

View File

@ -0,0 +1,88 @@
package proxy.config;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import proxy.config.entities.OrganisationUrls;
import proxy.config.entities.RegistryUrls;
import proxy.config.entities.RepositoryUrls;
import proxy.config.entities.ResearcherUrls;
import proxy.config.entities.ServiceUrls;
@XmlRootElement
public class ExternalUrls implements Serializable {
private static final long serialVersionUID = -5076364662014107275L;
RegistryUrls registries;
RepositoryUrls repositories;
ServiceUrls services;
ResearcherUrls researchers;
OrganisationUrls organisations;
public RegistryUrls getRegistries() {
return registries;
}
@XmlElement(name = "registries")
public void setRegistries(RegistryUrls registries) {
this.registries = registries;
}
public RepositoryUrls getRepositories() {
return repositories;
}
@XmlElement(name = "repositories")
public void setRepositories(RepositoryUrls repositories) {
this.repositories = repositories;
}
public ServiceUrls getServices() {
return services;
}
@XmlElement(name = "services")
public void setServices(ServiceUrls services) {
this.services = services;
}
public ResearcherUrls getResearchers() {
return researchers;
}
@XmlElement(name = "researchers")
public void setResearchers(ResearcherUrls researchers) {
this.researchers = researchers;
}
public OrganisationUrls getOrganisations() {
return organisations;
}
@XmlElement(name = "organisations")
public void setOrganisations(OrganisationUrls organisations) {
this.organisations = organisations;
}
}

View File

@ -0,0 +1,8 @@
package proxy.config;
public enum FetchStrategy {
FIRST,
ALL
}

View File

@ -0,0 +1,49 @@
package proxy.config;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Loader {
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");
// }
public Loader(String fileUrl) {
System.out.println("LOADING 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));
}
catch(Exception ex) {
//log the error and shutdown the system (that's a critical error)
ex.printStackTrace();
System.exit(0);
}
finally {
try {
if(is !=null) is.close();
} catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: "+fileUrl);
}
}
}
}

View File

@ -0,0 +1,34 @@
package proxy.config;
import java.net.URL;
import javax.xml.bind.annotation.XmlElement;
public class UrlConfig {
private URL url;
private Integer ordinal;
public URL getUrl() {
return url;
}
@XmlElement(name = "url")
public void setUrl(URL url) {
this.url = url;
}
public Integer getOrdinal() {
return ordinal;
}
@XmlElement(name = "ordinal")
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
}

View File

@ -0,0 +1,32 @@
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 OrganisationUrls {
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,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 RegistryUrls {
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,32 @@
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 RepositoryUrls {
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,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 ResearcherUrls {
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,34 @@
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 ServiceUrls {
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

@ -140,15 +140,15 @@ public class Projects {
@RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> createProject(@RequestBody Project project) {
Project createdProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(createdProject));
}
@RequestMapping(method = RequestMethod.POST, value = { "/project/update" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> updateProject(@RequestBody Project project) {
Project createdProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
Project updatedProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(updatedProject));
}

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

@ -42,7 +42,13 @@
<bean id="tokenAuthenticationFilter" class="security.TokenAuthenticationFilter" />
<bean id="customAuthenticationProvider" class="security.CustomAuthenticationProvider" />
<bean id="externalUrlLoader" class="proxy.config.Loader">
<constructor-arg type="java.lang.String" value = "classpath:ExternalUrls.xml"/>
</bean>
<bean id="emf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="DMPBackendPersistence" />
<property name="jpaProperties">

View File

@ -86,7 +86,6 @@
<router-outlet></router-outlet>
<!--this should be invisible -->
<app-main-sign-in [ngClass]="'invisible'"></app-main-sign-in>
</div>