Transform it to a micro-service
This commit is contained in:
parent
591ed6fcd9
commit
a8f4d8a297
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repository-deposit-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>repositorydepositzenodo</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OpenDMP Repository Deposit Zenodo</name>
|
||||
<description>OpenDMP Repository Deposit Zenodo</description>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo/src/branch/master/LICENSE.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>CITE S.A.</name>
|
||||
<email>maven-central@cite.gr</email>
|
||||
<organization>CITE S.A.</organization>
|
||||
<organizationUrl>https://www.cite.gr</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://code-repo.d4science.org</connection>
|
||||
<developerConnection>scm:git:ssh://code-repo.d4science.org</developerConnection>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo</url>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repositorydepositbase</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.eudat.EuDatApplication</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>module-info.class</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.json</pattern>
|
||||
<shadedPattern>zenodorepository.shaded.org.json</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -11,6 +11,7 @@ import eu.eudat.depositinterface.zenodorepository.mapper.DMPToZenodoMapper;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
|
@ -20,6 +21,7 @@ import org.springframework.util.MultiValueMap;
|
|||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
@ -47,14 +49,16 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
|
||||
if(conf != null) {
|
||||
|
||||
if (zenodoToken == null) {
|
||||
if (zenodoToken == null || zenodoToken.isEmpty()) {
|
||||
zenodoToken = conf.getAccessToken();
|
||||
}
|
||||
String finalToken = zenodoToken;
|
||||
|
||||
String zenodoUrl = conf.getRepositoryUrl();
|
||||
|
||||
// First step, post call to Zenodo, to create the entry.
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
WebClient zenodoClient = WebClient.builder().build();
|
||||
//RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -73,7 +77,11 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
|
||||
if (previousDOI == null) {
|
||||
String createUrl = zenodoUrl + "deposit/depositions" + "?access_token=" + zenodoToken;
|
||||
createResponse = restTemplate.postForEntity(createUrl, request, Map.class).getBody();
|
||||
createResponse = zenodoClient.post().uri(createUrl).headers(httpHeaders -> {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
})
|
||||
.bodyValue(deposit).exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})).block(); //restTemplate.postForEntity(createUrl, request, Map.class).getBody();
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
} else {
|
||||
unpublishedUrl = this.getUnpublishedDOI(zenodoUrl, previousDOI, zenodoToken, dmpDepositModel.getVersion());
|
||||
|
@ -82,21 +90,23 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
//First, get the deposit related to the concept DOI
|
||||
String listUrl = zenodoUrl + "deposit/depositions" + "?q=conceptdoi:\"" + previousDOI + "\"&access_token=" + zenodoToken;
|
||||
logger.debug("listUrl = " + listUrl);
|
||||
ResponseEntity<Map[]> listResponses = restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody()[0];
|
||||
ResponseEntity<List<Map>> listResponses = zenodoClient.get().uri(listUrl).retrieve().toEntityList(Map.class).block();//restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody().get(0);
|
||||
logger.debug("createResponse-previousDoi:");
|
||||
logger.debug(objectMapper.writeValueAsString(createResponse));
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
//Second, make the new version (not in the links?)
|
||||
String newVersionUrl = links.get("self") + "/actions/newversion" + "?access_token=" + zenodoToken;
|
||||
logger.debug("new version url: " + newVersionUrl);
|
||||
createResponse = restTemplate.postForObject(newVersionUrl, null, Map.class);
|
||||
createResponse = zenodoClient.post().uri(newVersionUrl)
|
||||
.bodyValue(null).exchangeToMono(mono -> mono.bodyToMono(Map.class)).block();//restTemplate.postForObject(newVersionUrl, null, Map.class);
|
||||
logger.debug("createResponse-newVersion:");
|
||||
logger.debug(objectMapper.writeValueAsString(createResponse));
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
//Third, get the new deposit
|
||||
String latestDraftUrl = links.get("latest_draft") + "?access_token=" + zenodoToken;
|
||||
createResponse = restTemplate.getForObject(latestDraftUrl, Map.class);
|
||||
createResponse = zenodoClient.get().uri(latestDraftUrl)
|
||||
.exchangeToMono(mono -> mono.bodyToMono(Map.class)).block();//restTemplate.getForObject(latestDraftUrl, Map.class);
|
||||
logger.debug("createResponse-latestDraft:");
|
||||
logger.debug(objectMapper.writeValueAsString(createResponse));
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
|
@ -104,23 +114,30 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
try {
|
||||
//Forth, update the new deposit's metadata
|
||||
String updateUrl = links.get("self") + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(updateUrl, request);
|
||||
zenodoClient.put().uri(updateUrl)
|
||||
.headers(httpHeaders -> {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
})
|
||||
.bodyValue(deposit).retrieve().toEntity(Map.class).block();//restTemplate.put(updateUrl, request);
|
||||
//And finally remove pre-existing files from it
|
||||
String fileListUrl = links.get("self") + "/files" + "?access_token=" + zenodoToken;
|
||||
ResponseEntity<Map[]> fileListResponse = restTemplate.getForEntity(fileListUrl, Map[].class);
|
||||
ResponseEntity<List<Map>> fileListResponse = zenodoClient.get().uri(fileListUrl).retrieve().toEntityList(Map.class).block();//restTemplate.getForEntity(fileListUrl, Map[].class);
|
||||
for (Map file : fileListResponse.getBody()) {
|
||||
String fileDeleteUrl = links.get("self") + "/files/" + file.get("id") + "?access_token=" + zenodoToken;
|
||||
restTemplate.delete(fileDeleteUrl);
|
||||
//restTemplate.delete(fileDeleteUrl);
|
||||
zenodoClient.delete().uri(fileDeleteUrl).retrieve().toEntity(Map.class).block();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//In case the last two steps fail delete the latest Deposit it in order to create a new one (only one at a time is allowed)
|
||||
restTemplate.delete(latestDraftUrl);
|
||||
//restTemplate.delete(latestDraftUrl);
|
||||
zenodoClient.delete().uri(latestDraftUrl).retrieve().toEntity(Map.class).block();
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
String listUrl = zenodoUrl + "deposit/depositions" + "?q=conceptdoi:\"" + previousDOI + "\"&access_token=" + zenodoToken;
|
||||
ResponseEntity<Map[]> listResponses = restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody()[0];
|
||||
ResponseEntity<List<Map>> listResponses = zenodoClient.get().uri(listUrl).retrieve().toEntityList(Map.class).block();//restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody().get(0);
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +149,8 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
HttpEntity<FileSystemResource> addFileMapRequest = new HttpEntity<>(fileSystemResource, null);
|
||||
|
||||
String addFileUrl = links.get("bucket") + "/" + pdfEnvelope.getFilename() + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
//restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
zenodoClient.put().uri(addFileUrl).headers(httpHeaders -> httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM)).bodyValue(fileSystemResource).retrieve().toEntity(Map.class).block();
|
||||
|
||||
FileEnvelope rdaJsonEnvelope = dmpDepositModel.getRdaJsonFile();
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
|
@ -158,7 +176,8 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
addFileMapRequest = new HttpEntity<>(fileSystemResource, jsonHeaders);
|
||||
String jsonFileName = jsonFile.getHeaders().get("Content-Disposition").get(0).substring(jsonFile.getHeaders().get("Content-Disposition").get(0).lastIndexOf('=') + 1);
|
||||
addFileUrl = links.get("bucket") + "/" + jsonFileName + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
//restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
zenodoClient.put().uri(addFileUrl).headers(httpHeaders -> httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM)).bodyValue(fileSystemResource).retrieve().toEntity(Map.class).block();
|
||||
Files.deleteIfExists(tempJsonFile.toPath());
|
||||
|
||||
if (dmpDepositModel.getSupportingFilesZip() != null) {
|
||||
|
@ -168,7 +187,8 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
addFileMapRequest = new HttpEntity<>(fileSystemResource, null);
|
||||
|
||||
addFileUrl = links.get("bucket") + "/" + supportinFilesZipName + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
//restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
zenodoClient.put().uri(addFileUrl).bodyValue(fileSystemResource).retrieve().toEntity(Map.class).block();
|
||||
}
|
||||
|
||||
// Third post call to Zenodo to publish the entry and return the DOI.
|
||||
|
@ -191,8 +211,9 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
}
|
||||
|
||||
private String publish(String publishUrl){
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
Map<String, Object> publishResponce = restTemplate.postForObject(publishUrl, "", Map.class);
|
||||
//RestTemplate restTemplate = new RestTemplate();
|
||||
WebClient webClient = WebClient.builder().build();
|
||||
Map<String, Object> publishResponce = webClient.post().uri(publishUrl).bodyValue("").retrieve().bodyToMono(Map.class).block();//restTemplate.postForObject(publishUrl, "", Map.class);
|
||||
return (String) publishResponce.get("conceptdoi");
|
||||
}
|
||||
|
||||
|
@ -210,7 +231,11 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
|
||||
if(conf != null) {
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
//RestTemplate restTemplate = new RestTemplate();
|
||||
WebClient client = WebClient.builder().defaultHeaders(httpHeaders -> {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
}).build();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
|
@ -224,7 +249,7 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
||||
|
||||
try {
|
||||
Map<String, Object> values = restTemplate.postForObject(conf.getRepositoryAccessTokenUrl(), request, Map.class);
|
||||
Map<String, Object> values = client.post().uri(conf.getRepositoryAccessTokenUrl()).bodyValue(map).retrieve().bodyToMono(Map.class).block();//restTemplate.postForObject(conf.getRepositoryAccessTokenUrl(), request, Map.class);
|
||||
//ZenodoResponseToken zenodoResponseToken = new ZenodoResponseToken();
|
||||
Map<String, Object> user = (Map<String, Object>) values.get("user");
|
||||
// zenodoResponseToken.setUserId((String) user.get("id"));
|
||||
|
@ -260,7 +285,8 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
|
||||
private String getUnpublishedDOI(String zenodoUrl, String DOI, String token, Integer version) {
|
||||
try {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
//RestTemplate restTemplate = new RestTemplate();
|
||||
WebClient client = WebClient.builder().build();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -268,8 +294,8 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
|||
LinkedHashMap<String, String> links = null;
|
||||
LinkedHashMap<String, String> metadata = null;
|
||||
String listUrl = zenodoUrl + "deposit/depositions" + "?q=conceptdoi:\"" + DOI + "\"&access_token=" + token;
|
||||
ResponseEntity<Map[]> listResponses = restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody()[0];
|
||||
ResponseEntity<List<Map>> listResponses = client.get().uri(listUrl).retrieve().toEntityList(Map.class).block();//restTemplate.getForEntity(listUrl, Map[].class);
|
||||
createResponse = listResponses.getBody().get(0);
|
||||
metadata = (LinkedHashMap<String, String>) createResponse.get("metadata");
|
||||
links = (LinkedHashMap<String, String>) createResponse.get("links");
|
||||
|
114
pom.xml
114
pom.xml
|
@ -5,114 +5,22 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>2.7.4</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repositorydepositzenodo</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>repository-deposit-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>OpenDMP Repository Deposit Zenodo</name>
|
||||
<description>OpenDMP Repository Deposit Zenodo</description>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo/src/branch/master/LICENSE.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>CITE S.A.</name>
|
||||
<email>maven-central@cite.gr</email>
|
||||
<organization>CITE S.A.</organization>
|
||||
<organizationUrl>https://www.cite.gr</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://code-repo.d4science.org</connection>
|
||||
<developerConnection>scm:git:ssh://code-repo.d4science.org</developerConnection>
|
||||
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-zenodo</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
</properties>
|
||||
|
||||
<properties>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
</properties>
|
||||
<modules>
|
||||
<module>core</module>
|
||||
<module>web</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repositorydepositbase</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.eudat.EuDatApplication</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>module-info.class</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.json</pattern>
|
||||
<shadedPattern>zenodorepository.shaded.org.json</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repository-deposit-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>repository-deposit-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repositorydepositzenodo</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.7.4</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package eu.eudat.deposit;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {
|
||||
"eu.eudat.deposit.*",
|
||||
"eu.eudat.depositinterface.*"
|
||||
})
|
||||
public class DepositApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DepositApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package eu.eudat.deposit.controller;
|
||||
|
||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/deposit")
|
||||
public class DepositController {
|
||||
|
||||
private final RepositoryDeposit repositoryDeposit;
|
||||
|
||||
@Autowired
|
||||
public DepositController(RepositoryDeposit repositoryDeposit) {
|
||||
this.repositoryDeposit = repositoryDeposit;
|
||||
}
|
||||
|
||||
@PostMapping("/{id}")
|
||||
public String deposit(@PathVariable("id") String repositoryId, @RequestBody DMPDepositModel dmpDepositModel, @RequestParam("authToken")String authToken) throws Exception {
|
||||
return repositoryDeposit.deposit(repositoryId, dmpDepositModel, authToken);
|
||||
}
|
||||
|
||||
@GetMapping("/authenticate/{id}")
|
||||
public String authenticate(@PathVariable("id") String repositoryId, @RequestParam("authToken") String authToken) {
|
||||
return repositoryDeposit.authenticate(repositoryId, authToken);
|
||||
}
|
||||
|
||||
@GetMapping("/configuration")
|
||||
public List<RepositoryDepositConfiguration> getConfiguration() {
|
||||
return repositoryDeposit.getConfiguration();
|
||||
}
|
||||
|
||||
@GetMapping("/logo/{id}")
|
||||
public String getLogo(@PathVariable("id") String repositoryId) {
|
||||
return repositoryDeposit.getLogo(repositoryId);
|
||||
}
|
||||
|
||||
}
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Loading…
Reference in New Issue