diff --git a/dmp-backend/core/pom.xml b/dmp-backend/core/pom.xml
index 883457036..6c607edd2 100644
--- a/dmp-backend/core/pom.xml
+++ b/dmp-backend/core/pom.xml
@@ -37,7 +37,7 @@
gr.cite.opendmp
repositorydepositbase
- 1.0.4
+ 2.0.0
gr.cite
diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
index 684724804..73928b6da 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
@@ -104,4 +104,8 @@ public class AuditableAction {
public static final EventId Lock_Persist = new EventId(17002, "Lock_Persist");
public static final EventId Lock_Delete = new EventId(17003, "Lock_Delete");
+ public static final EventId Deposit_GetAvailableRepositories = new EventId(18000, "Deposit_GetAvailableRepositories");
+ public static final EventId Deposit_GetAccessToken = new EventId(18001, "Deposit_GetAccessToken");
+ public static final EventId Deposit_Deposit = new EventId(18002, "Deposit_Deposit");
+ public static final EventId Deposit_GetLogo = new EventId(18003, "Deposit_GetLogo");
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
index 85558dca5..6ecc0b23b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
@@ -26,6 +26,9 @@ public final class Permission {
//Elastic
public static String ManageElastic = "ManageElastic";
+ //Deposit
+ public static String BrowseDeposit = "BrowseDeposit";
+ public static String EditDeposit = "BrowseDeposit";
//Language
diff --git a/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java b/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java
deleted file mode 100644
index 904bf2e3d..000000000
--- a/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package eu.eudat.cache.deposit;
-
-
-import eu.eudat.configurations.deposit.DepositCacheOptions;
-import eu.eudat.model.doi.RepositoryConfigs;
-import gr.cite.tools.cache.CacheService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RepositoryDepositConfigurationCache extends CacheService {
- @Autowired
- public RepositoryDepositConfigurationCache(DepositCacheOptions options) {
- super(options);
- }
-
- @Override
- protected Class valueClass() {
- return RepositoryConfigs.class;
- }
-}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java
index aeed04fa7..4ebcded6c 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java
@@ -8,58 +8,71 @@ import java.util.List;
@ConfigurationProperties(prefix = "deposit")
public class DepositProperties {
- private final List sources;
-
- @ConstructorBinding
- public DepositProperties(List sources) {
- this.sources = sources;
- }
+ private List sources;
public List getSources() {
return sources;
}
+ public void setSources(List sources) {
+ this.sources = sources;
+ }
+
public static class DepositSource {
- private final String url;
- private final List codes;
- private final String issuerUrl;
- private final String clientId;
- private final String clientSecret;
- private final String scope;
+ private String repositoryId;
+ private String url;
+ private String issuerUrl;
+ private String clientId;
+ private String clientSecret;
+ private String scope;
- @ConstructorBinding
- public DepositSource(String url, List codes, String issuerUrl, String clientId, String clientSecret, String scope) {
- this.url = url;
- this.codes = codes;
- this.issuerUrl = issuerUrl;
- this.clientId = clientId;
- this.clientSecret = clientSecret;
- this.scope = scope;
+ public String getRepositoryId() {
+ return repositoryId;
+ }
+
+ public void setRepositoryId(String repositoryId) {
+ this.repositoryId = repositoryId;
}
public String getUrl() {
return url;
}
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
public String getIssuerUrl() {
return issuerUrl;
}
+ public void setIssuerUrl(String issuerUrl) {
+ this.issuerUrl = issuerUrl;
+ }
+
public String getClientId() {
return clientId;
}
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
public String getClientSecret() {
return clientSecret;
}
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
public String getScope() {
return scope;
}
- public List getCodes() {
- return codes;
+ public void setScope(String scope) {
+ this.scope = scope;
}
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/BaseDepositBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/BaseDepositBuilder.java
new file mode 100644
index 000000000..a45c1c847
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/BaseDepositBuilder.java
@@ -0,0 +1,78 @@
+package eu.eudat.model.builder.deposit;
+
+import eu.eudat.convention.ConventionService;
+import gr.cite.tools.data.builder.Builder;
+import gr.cite.tools.data.query.QueryBase;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.LoggerService;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public abstract class BaseDepositBuilder implements Builder {
+ protected final LoggerService logger;
+ protected final ConventionService conventionService;
+
+ public BaseDepositBuilder(
+ ConventionService conventionService,
+ LoggerService logger
+ ) {
+ this.conventionService = conventionService;
+ this.logger = logger;
+ }
+
+ public M build(D data) throws MyApplicationException {
+ if (data == null) {
+ //this.logger.Debug(new MapLogEntry("requested build for null item requesting fields").And("fields", directives));
+// return default(M);
+ M model = null;
+ return null; //TODO
+ }
+ List> models = this.buildInternal(List.of(data));
+ return models.stream().map(DepositBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
+ }
+
+ public List build(List data) throws MyApplicationException{
+ List> models = this.buildInternal(data);
+ return models == null ? null : models.stream().map(DepositBuilderItemResponse::getModel).collect(Collectors.toList());
+ }
+
+ protected abstract List> buildInternal(List data) throws MyApplicationException;
+
+ public Map asForeignKey(QueryBase query, Function keySelector) throws MyApplicationException {
+ this.logger.trace("Building references from query");
+ List data = query.collect();
+ this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
+ return this.asForeignKey(data, keySelector);
+ }
+
+ public Map asForeignKey(List data, Function keySelector) throws MyApplicationException {
+ this.logger.trace("building references");
+ List> models = this.buildInternal(data);
+ this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
+ return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), DepositBuilderItemResponse::getModel));
+ }
+ public Map> asMasterKey(QueryBase query,Function keySelector) throws MyApplicationException {
+ this.logger.trace("Building details from query");
+ List data = query.collect();
+ this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
+ return this.asMasterKey(data, keySelector);
+ }
+
+ public Map> asMasterKey(List data, Function keySelector) throws MyApplicationException {
+ this.logger.trace("building details");
+ List> models = this.buildInternal(data);
+ this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
+ Map> map = new HashMap<>();
+ if (models == null) return map;
+ for (DepositBuilderItemResponse model : models) {
+ K key = keySelector.apply(model.getData());
+ if (!map.containsKey(key)) map.put(key, new ArrayList());
+ map.get(key).add(model.getModel());
+ }
+ return map;
+ }
+}
+
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositBuilderItemResponse.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositBuilderItemResponse.java
new file mode 100644
index 000000000..d2a45511e
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositBuilderItemResponse.java
@@ -0,0 +1,19 @@
+package eu.eudat.model.builder.deposit;
+
+public class DepositBuilderItemResponse{
+ private final M model;
+ private final D data;
+
+ public DepositBuilderItemResponse(M model, D data) {
+ this.model = model;
+ this.data = data;
+ }
+
+ public D getData() {
+ return data;
+ }
+
+ public M getModel() {
+ return model;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositConfigurationBuilder.java
new file mode 100644
index 000000000..b6014685a
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DepositConfigurationBuilder.java
@@ -0,0 +1,67 @@
+package eu.eudat.model.builder.deposit;
+
+import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.convention.ConventionService;
+import eu.eudat.data.TagEntity;
+import eu.eudat.model.Tag;
+import eu.eudat.model.User;
+import eu.eudat.model.builder.BaseBuilder;
+import eu.eudat.model.builder.UserBuilder;
+import eu.eudat.model.deposit.DepositConfiguration;
+import eu.eudat.query.UserQuery;
+import gr.cite.tools.data.builder.BuilderFactory;
+import gr.cite.tools.data.query.QueryFactory;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.BaseFieldSet;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class DepositConfigurationBuilder extends BaseBuilder {
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+
+ @Autowired
+ public DepositConfigurationBuilder(
+ ConventionService conventionService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(DepositConfigurationBuilder.class)));
+ }
+
+ public DepositConfigurationBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List data) throws MyApplicationException {
+ this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ this.logger.trace(new DataLogEntry("requested fields", fields));
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
+
+ List models = new ArrayList<>();
+ for (eu.eudat.depositinterface.repository.DepositConfiguration d : data) {
+ DepositConfiguration m = new DepositConfiguration();
+ if (fields.hasField(this.asIndexer(DepositConfiguration._depositType))) m.setDepositType(d.getDepositType());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._redirectUri))) m.setRedirectUri(d.getRedirectUri());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryId))) m.setRepositoryId(d.getRepositoryId());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryAuthorizationUrl))) m.setRepositoryAuthorizationUrl(d.getRepositoryAuthorizationUrl());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryRecordUrl))) m.setRepositoryRecordUrl(d.getRepositoryRecordUrl());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryClientId))) m.setRepositoryClientId(d.getRepositoryClientId());
+ if (fields.hasField(this.asIndexer(DepositConfiguration._hasLogo))) m.setHasLogo(d.isHasLogo());
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionDepositBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionDepositBuilder.java
new file mode 100644
index 000000000..110d54af2
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionDepositBuilder.java
@@ -0,0 +1,100 @@
+package eu.eudat.model.builder.deposit;
+
+import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.commons.JsonHandlingService;
+import eu.eudat.commons.XmlHandlingService;
+import eu.eudat.commons.enums.IsActive;
+import eu.eudat.commons.types.description.PropertyDefinitionEntity;
+import eu.eudat.convention.ConventionService;
+import eu.eudat.data.DescriptionEntity;
+import eu.eudat.data.DescriptionTemplateEntity;
+import eu.eudat.depositinterface.models.DescriptionDepositModel;
+import eu.eudat.model.*;
+import eu.eudat.model.builder.*;
+import eu.eudat.model.builder.descriptionpropertiesdefinition.PropertyDefinitionBuilder;
+import eu.eudat.query.*;
+import gr.cite.tools.data.builder.BuilderFactory;
+import gr.cite.tools.data.query.QueryFactory;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.BaseFieldSet;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class DescriptionDepositBuilder extends BaseDepositBuilder {
+
+ private final QueryFactory queryFactory;
+
+ private final BuilderFactory builderFactory;
+ private final JsonHandlingService jsonHandlingService;
+
+ private final XmlHandlingService xmlHandlingService;
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+
+ @Autowired
+ public DescriptionDepositBuilder(
+ ConventionService conventionService,
+ QueryFactory queryFactory,
+ BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionDepositBuilder.class)));
+ this.queryFactory = queryFactory;
+ this.builderFactory = builderFactory;
+ this.jsonHandlingService = jsonHandlingService;
+ this.xmlHandlingService = xmlHandlingService;
+ }
+
+ public DescriptionDepositBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ protected List> buildInternal(List data) throws MyApplicationException {
+ this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty()) return new ArrayList<>();
+
+ Map definitionMap = this.collectDescriptionTemplates(data);
+
+ List> models = new ArrayList<>();
+ for (DescriptionEntity d : data) {
+ DescriptionDepositModel m = new DescriptionDepositModel();
+ m.setLabel(d.getLabel());
+ m.setDescription(d.getDescription());
+ if (d.getProperties() != null){
+ PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
+ if (definitionMap != null && definitionMap.containsKey(d.getDescriptionTemplateId()) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setFields(this.builderFactory.builder(DescriptionFieldDepositBuilder.class).authorize(this.authorize).setDefinition(definitionMap.get(d.getDescriptionTemplateId())).build(propertyDefinition.getFields()));
+ }
+ models.add(new DepositBuilderItemResponse<>(m, d));
+ }
+
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+
+ return models;
+ }
+
+ private Map collectDescriptionTemplates(List data) throws MyApplicationException {
+ if (data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
+
+ List descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
+ MapitemMap = new HashMap<>();
+
+ for (DescriptionTemplateEntity descriptionTemplateEntity : descriptionTemplateEntities){
+ eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
+ itemMap.put(descriptionTemplateEntity.getId(), definition);
+ }
+ return itemMap;
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionFieldDepositBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionFieldDepositBuilder.java
new file mode 100644
index 000000000..b044d0a4c
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/deposit/DescriptionFieldDepositBuilder.java
@@ -0,0 +1,121 @@
+package eu.eudat.model.builder.deposit;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.commons.types.description.FieldEntity;
+import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
+import eu.eudat.convention.ConventionService;
+import eu.eudat.depositinterface.enums.FieldType;
+import eu.eudat.depositinterface.models.DescriptionFieldDepositModel;
+import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.logging.LoggerService;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Optional;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class DescriptionFieldDepositBuilder extends BaseDepositBuilder {
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition;
+ private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
+ @Autowired
+ public DescriptionFieldDepositBuilder(
+ ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
+ ) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldDepositBuilder.class)));
+ this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
+ }
+
+ public DescriptionFieldDepositBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ public DescriptionFieldDepositBuilder setDefinition(DefinitionEntity definition) {
+ this.definition = definition;
+ return this;
+ }
+
+ @Override
+ protected List> buildInternal(List data) throws MyApplicationException {
+ this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty()) return new ArrayList<>();
+
+ List> models = new ArrayList<>();
+ ObjectMapper objectMapper = new ObjectMapper();
+ for (FieldEntity d : data) {
+ DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
+ if (definition != null){
+ List fieldEntities = definition.getFieldById(d.getKey());
+ if (!this.conventionService.isListNullOrEmpty(fieldEntities)){
+ eu.eudat.commons.types.descriptiontemplate.FieldEntity field = fieldEntities.getFirst();
+ m.setSchematics(field.getSchematics());
+ if (field.getData() != null) {
+ boolean isMultiValue = fieldDataHelperServiceProvider.get(field.getData().getFieldType()).isMultiValue(field.getData());
+ if (!isMultiValue) m.setValues(List.of(d.getValue()));
+ else {
+ try {
+ //TODO: Find better Solution
+ List