diff --git a/core/pom.xml b/core/pom.xml
index 32c2bdd..07a8016 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -45,7 +45,7 @@
gr.cite.opendmp
repositorydepositbase
- 1.0.0-SNAPSHOT
+ 2.0.0
@@ -58,6 +58,11 @@
json
20160810
+
+ gr.cite
+ cache
+ 2.1.0
+
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/funder/FunderProperties.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/funder/FunderProperties.java
index 448b172..2a1bc77 100644
--- a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/funder/FunderProperties.java
+++ b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/funder/FunderProperties.java
@@ -8,26 +8,19 @@ import java.util.List;
@ConfigurationProperties(prefix = "funder")
public class FunderProperties {
- private final List available;
+ private List available;
- @ConstructorBinding
- public FunderProperties(List available) {
- this.available = available;
- }
-
- public List getAvailable() {
+ public List getAvailable() {
return available;
}
- public static class DOIFunder {
- private final String funder;
- private final String doi;
+ public void setAvailable(List available) {
+ this.available = available;
+ }
- @ConstructorBinding
- public DOIFunder(String funder, String doi) {
- this.funder = funder;
- this.doi = doi;
- }
+ public static class DoiFunder {
+ private String funder;
+ private String doi;
public String getFunder() {
return funder;
@@ -36,5 +29,13 @@ public class FunderProperties {
public String getDoi() {
return doi;
}
+
+ public void setFunder(String funder) {
+ this.funder = funder;
+ }
+
+ public void setDoi(String doi) {
+ this.doi = doi;
+ }
}
}
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/identifier/IdentifierProperties.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/identifier/IdentifierProperties.java
index dcd7676..f0026d9 100644
--- a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/identifier/IdentifierProperties.java
+++ b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/identifier/IdentifierProperties.java
@@ -7,14 +7,13 @@ import java.util.List;
@ConfigurationProperties(prefix = "identifiers")
public class IdentifierProperties {
- private final List related;
-
- @ConstructorBinding
- public IdentifierProperties(List related) {
- this.related = related;
- }
+ private List related;
public List getRelated() {
return related;
}
+
+ public void setRelated(List related) {
+ this.related = related;
+ }
}
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/pid/PidProperties.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/pid/PidProperties.java
index f65043b..abee71c 100644
--- a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/pid/PidProperties.java
+++ b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/pid/PidProperties.java
@@ -8,14 +8,8 @@ import java.util.List;
@ConfigurationProperties(prefix = "pid")
public class PidProperties {
- private final List acceptedTypes;
- private final PidFieldNames fields;
-
- @ConstructorBinding
- public PidProperties(List acceptedTypes, PidFieldNames fields) {
- this.acceptedTypes = acceptedTypes;
- this.fields = fields;
- }
+ private List acceptedTypes;
+ private PidFieldNames fields;
public List getAcceptedTypes() {
return acceptedTypes;
@@ -25,22 +19,32 @@ public class PidProperties {
return fields;
}
- public static class PidFieldNames {
- private final String pidName;
- private final String pidTypeName;
+ public void setAcceptedTypes(List acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
- @ConstructorBinding
- public PidFieldNames(String pidName, String pidTypeName) {
- this.pidName = pidName;
- this.pidTypeName = pidTypeName;
- }
+ public void setFields(PidFieldNames fields) {
+ this.fields = fields;
+ }
+
+ public static class PidFieldNames {
+ private String pidName;
+ private String pidTypeName;
public String getPidName() {
return pidName;
}
+ public void setPidName(String pidName) {
+ this.pidName = pidName;
+ }
+
public String getPidTypeName() {
return pidTypeName;
}
+
+ public void setPidTypeName(String pidTypeName) {
+ this.pidTypeName = pidTypeName;
+ }
}
}
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/zenodo/ZenodoProperties.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/zenodo/ZenodoProperties.java
index cc4cc35..d9bfc3c 100644
--- a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/zenodo/ZenodoProperties.java
+++ b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/configuration/zenodo/ZenodoProperties.java
@@ -1,149 +1,57 @@
package eu.eudat.depositinterface.zenodorepository.configuration.zenodo;
-import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
+import eu.eudat.depositinterface.repository.DepositConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.ConstructorBinding;
-
-import java.util.List;
-import java.util.Map;
@ConfigurationProperties(prefix = "zenodo")
public class ZenodoProperties {
+ private String logo;
- private final String tempStorage;
+ private String community;
- private final List configuration;
+ private String domain;
- @ConstructorBinding
- public ZenodoProperties(Map storage, List configuration) {
- this.tempStorage = storage.get("temp");
- this.configuration = configuration;
+ private String affiliation;
+
+ private DepositConfiguration depositConfiguration;
+
+ public void setLogo(String logo) {
+ this.logo = logo;
}
- public String getTempStorage() {
- return tempStorage;
+ public String getLogo() {
+ return logo;
}
- public List getConfiguration() {
- return configuration;
+ public String getCommunity() {
+ return community;
}
- public static class ZenodoConfig extends RepositoryDepositConfiguration {
- private final int depositType;
- private final String repositoryId;
- private final String accessToken;
- private final String repositoryUrl;
- private final String repositoryAuthorizationUrl;
- private final String repositoryRecordUrl;
- private final String repositoryAccessTokenUrl;
- private final String repositoryClientId;
- private final String repositoryClientSecret;
- private final String redirectUri;
- private final boolean hasLogo;
- private final String logo;
- private final String doiFunder;
- private final String community;
- private final String affiliation;
- private final String domain;
+ public void setCommunity(String community) {
+ this.community = community;
+ }
- @ConstructorBinding
- public ZenodoConfig(int depositType, String repositoryId, String accessToken, String repositoryUrl, String repositoryAuthorizationUrl, String repositoryRecordUrl, String repositoryAccessTokenUrl, String repositoryClientId, String repositoryClientSecret, String redirectUri, boolean hasLogo, String logo, String doiFunder, String community, String affiliation, String domain) {
- this.depositType = depositType;
- this.repositoryId = repositoryId;
- this.accessToken = accessToken;
- this.repositoryUrl = repositoryUrl;
- this.repositoryAuthorizationUrl = repositoryAuthorizationUrl;
- this.repositoryRecordUrl = repositoryRecordUrl;
- this.repositoryAccessTokenUrl = repositoryAccessTokenUrl;
- this.repositoryClientId = repositoryClientId;
- this.repositoryClientSecret = repositoryClientSecret;
- this.redirectUri = redirectUri;
- this.hasLogo = hasLogo;
- this.logo = logo;
- this.doiFunder = doiFunder;
- this.community = community;
- this.affiliation = affiliation;
- this.domain = domain;
- }
+ public String getDomain() {
+ return domain;
+ }
- public int getDepositType() {
- return depositType;
- }
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
- public String getRepositoryId() {
- return repositoryId;
- }
+ public String getAffiliation() {
+ return affiliation;
+ }
- public String getAccessToken() {
- return accessToken;
- }
+ public void setAffiliation(String affiliation) {
+ this.affiliation = affiliation;
+ }
- public String getRepositoryUrl() {
- return repositoryUrl;
- }
+ public DepositConfiguration getDepositConfiguration() {
+ return depositConfiguration;
+ }
- public String getRepositoryAuthorizationUrl() {
- return repositoryAuthorizationUrl;
- }
-
- public String getRepositoryRecordUrl() {
- return repositoryRecordUrl;
- }
-
- public String getRepositoryAccessTokenUrl() {
- return repositoryAccessTokenUrl;
- }
-
- public String getRepositoryClientId() {
- return repositoryClientId;
- }
-
- public String getRepositoryClientSecret() {
- return repositoryClientSecret;
- }
-
- public String getRedirectUri() {
- return redirectUri;
- }
-
- public boolean isHasLogo() {
- return hasLogo;
- }
-
- public String getLogo() {
- return logo;
- }
-
- public String getDoiFunder() {
- return doiFunder;
- }
-
- public String getCommunity() {
- return community;
- }
-
- public String getAffiliation() {
- return affiliation;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public RepositoryDepositConfiguration toRepoConfig() {
- RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
- config.setDepositType(this.depositType);
- config.setRepositoryId(this.repositoryId);
- config.setAccessToken(this.accessToken);
- config.setRepositoryUrl(this.repositoryUrl);
- config.setRepositoryAuthorizationUrl(this.repositoryAuthorizationUrl);
- config.setRepositoryRecordUrl(this.repositoryRecordUrl);
- config.setRepositoryAccessTokenUrl(this.repositoryAccessTokenUrl);
- config.setRepositoryClientId(this.repositoryClientId);
- config.setRepositoryClientSecret(this.repositoryClientSecret);
- config.setRedirectUri(this.redirectUri);
- config.setHasLogo(this.hasLogo);
- return config;
- }
+ public void setDepositConfiguration(DepositConfiguration depositConfiguration) {
+ this.depositConfiguration = depositConfiguration;
}
}
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/enums/ZenodoAccessRight.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/enums/ZenodoAccessRight.java
new file mode 100644
index 0000000..fe58d5d
--- /dev/null
+++ b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/enums/ZenodoAccessRight.java
@@ -0,0 +1,36 @@
+package eu.eudat.depositinterface.zenodorepository.enums;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import eu.eudat.depositinterface.enums.EnumUtils;
+import eu.eudat.depositinterface.enums.EnumValueProvider;
+import eu.eudat.depositinterface.enums.FieldType;
+
+import java.util.Map;
+
+public enum ZenodoAccessRight implements EnumValueProvider {
+ RESTRICTED(Names.Restricted), EMBARGOED(Names.Embargoed), OPEN(Names.Open);
+
+ private final String value;
+
+ public static class Names {
+ public static final String Restricted = "restricted";
+ public static final String Embargoed = "embargoed";
+ public static final String Open = "open";
+ }
+
+ ZenodoAccessRight(String value) {
+ this.value = value;
+ }
+
+ @Override
+ @JsonValue
+ public String getValue() {
+ return value;
+ }
+
+ private static final Map map = EnumUtils.getEnumValueMap(ZenodoAccessRight.class);
+
+ public static ZenodoAccessRight of(String i) {
+ return map.get(i);
+ }
+}
diff --git a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/interfaces/ZenodoDeposit.java b/core/src/main/java/eu/eudat/depositinterface/zenodorepository/interfaces/ZenodoDeposit.java
deleted file mode 100644
index 16e0b0c..0000000
--- a/core/src/main/java/eu/eudat/depositinterface/zenodorepository/interfaces/ZenodoDeposit.java
+++ /dev/null
@@ -1,284 +0,0 @@
-package eu.eudat.depositinterface.zenodorepository.interfaces;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import eu.eudat.depositinterface.models.DMPDepositModel;
-import eu.eudat.depositinterface.models.FileEnvelope;
-import eu.eudat.depositinterface.repository.RepositoryDeposit;
-import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
-import eu.eudat.depositinterface.zenodorepository.configuration.zenodo.ZenodoProperties;
-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.io.ByteArrayResource;
-import org.springframework.http.*;
-import org.springframework.stereotype.Component;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.util.ResourceUtils;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.HttpServerErrorException;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.client.WebClient;
-
-import java.io.*;
-import java.nio.file.Files;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Component
-public class ZenodoDeposit implements RepositoryDeposit {
- private static final Logger logger = LoggerFactory.getLogger(ZenodoDeposit.class);
- private static final ObjectMapper objectMapper = new ObjectMapper();
-
- private final ZenodoProperties zenodoProperties;
- private final DMPToZenodoMapper mapper;
-
- @Autowired
- public ZenodoDeposit(ZenodoProperties zenodoProperties, DMPToZenodoMapper mapper){
- this.zenodoProperties = zenodoProperties;
- this.mapper = mapper;
- }
-
- @Override
- public String deposit(String repositoryId, DMPDepositModel dmpDepositModel, String zenodoToken) throws Exception {
-
- RepositoryDepositConfiguration conf = this.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
-
- if(conf != null) {
-
- if (zenodoToken == null || zenodoToken.isEmpty()) {
- zenodoToken = conf.getAccessToken();
- }
-
- String zenodoUrl = conf.getRepositoryUrl();
-
- // First step, post call to Zenodo, to create the entry.
- WebClient zenodoClient = WebClient.builder().build();
- HttpHeaders headers = new HttpHeaders();
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- headers.setContentType(MediaType.APPLICATION_JSON);
-
- ZenodoProperties.ZenodoConfig zenodoConfig = this.zenodoProperties.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
- eu.eudat.depositinterface.zenodorepository.models.ZenodoDeposit deposit = mapper.fromDMP(dmpDepositModel, zenodoConfig);
-
- Map createResponse;
- LinkedHashMap links;
- String previousDOI = dmpDepositModel.getPreviousDOI();
- String unpublishedUrl = null;
- String publishUrl;
- try {
-
- if (previousDOI == null) {
- String createUrl = zenodoUrl + "deposit/depositions" + "?access_token=" + zenodoToken;
- 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