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 0cdf46f5e..f4d1cebb3 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 @@ -20,6 +20,7 @@ public class AuditableAction { public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete"); public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone"); public static final EventId DmpBlueprint_GetXml = new EventId(3005, "DmpBlueprint_GetXml"); + public static final EventId DmpBlueprint_Import = new EventId(3006, "DmpBlueprint_Import"); public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query"); public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup"); @@ -47,5 +48,7 @@ public class AuditableAction { public static final EventId DescriptionTemplate_Delete = new EventId(8003, "DescriptionTemplate_Delete"); public static final EventId DescriptionTemplate_Clone = new EventId(8004, "DescriptionTemplate_Clone"); public static final EventId DescriptionTemplate_PersistNewVersion = new EventId(8005, "DescriptionTemplate_PersistNewVersion"); + public static final EventId DescriptionTemplate_GetXml = new EventId(8006, "DescriptionTemplate_GetXml"); + public static final EventId DescriptionTemplate_Import = new EventId(8007, "DescriptionTemplate_Import"); } 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 d1cd566c9..c2b37d20d 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 @@ -30,6 +30,7 @@ public final class Permission { public static String CloneDescriptionTemplate = "CloneDescriptionTemplate"; public static String CreateNewVersionDescriptionTemplate = "CreateNewVersionDescriptionTemplate"; public static String ImportDescriptionTemplate = "ImportDescriptionTemplate"; + public static String ExportDescriptionTemplate = "ExportDescriptionTemplate"; //DescriptionTemplateType public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java index b32d46666..398d92e9e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java @@ -23,18 +23,18 @@ public class DescriptionTemplateImportExport { @XmlAttribute(name = "language") private String language; @XmlAttribute(name = "type") - private String type; + private UUID type; @XmlElementWrapper(name = "pages") @XmlElement(name = "page") - private List page; + private List pages; - public List getPage() { - return page; + public List getPages() { + return pages; } - public void setPage(List page) { - this.page = page; + public void setPages(List pages) { + this.pages = pages; } @@ -56,60 +56,11 @@ public class DescriptionTemplateImportExport { } - public String getType() { + public UUID getType() { return type; } - public void setType(String type) { + public void setType(UUID type) { this.type = type; } - - public DescriptionTemplatePersist toPersistModel(String label, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){ - DescriptionTemplatePersist newDatasetEntityProfile = new DescriptionTemplatePersist(); - newDatasetEntityProfile.setLabel(label); - newDatasetEntityProfile.setStatus(DescriptionTemplateStatus.Draft); - newDatasetEntityProfile.setDescription(description); - newDatasetEntityProfile.setLanguage(language); - newDatasetEntityProfile.setType(UUID.fromString(type)); - DefinitionPersist definitionPersist = new DefinitionPersist(); - - List pagesDatasetEntity = new LinkedList<>(); - List sectionDatasetEntity = new LinkedList<>(); - for (PageImportExport xmlPage: page) { - pagesDatasetEntity.add(xmlPage.toPersistModel()); - for (int i = 0; i < xmlPage.getSections().size(); i++) { - sectionDatasetEntity.add(xmlPage.toPersistModel(i, fieldDataHelperServiceProvider)); - } - } - definitionPersist.setPages(pagesDatasetEntity); - definitionPersist.setSections(sectionDatasetEntity); - newDatasetEntityProfile.setDefinition(definitionPersist); - - return newDatasetEntityProfile; - } - - public NewVersionDescriptionTemplatePersist toNewVersionPersistModel(UUID id, String label, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){ - NewVersionDescriptionTemplatePersist newDatasetEntityProfile = new NewVersionDescriptionTemplatePersist(); - newDatasetEntityProfile.setId(id); - newDatasetEntityProfile.setLabel(label); - newDatasetEntityProfile.setStatus(DescriptionTemplateStatus.Draft); - newDatasetEntityProfile.setDescription(description); - newDatasetEntityProfile.setLanguage(language); - newDatasetEntityProfile.setType(UUID.fromString(type)); - DefinitionPersist definitionPersist = new DefinitionPersist(); - - List pagesDatasetEntity = new LinkedList<>(); - List sectionDatasetEntity = new LinkedList<>(); - for (PageImportExport xmlPage: page) { - pagesDatasetEntity.add(xmlPage.toPersistModel()); - for (int i = 0; i < xmlPage.getSections().size(); i++) { - sectionDatasetEntity.add(xmlPage.toPersistModel(i, fieldDataHelperServiceProvider)); - } - } - definitionPersist.setPages(pagesDatasetEntity); - definitionPersist.setSections(sectionDatasetEntity); - newDatasetEntityProfile.setDefinition(definitionPersist); - - return newDatasetEntityProfile; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldImportExport.java index 5524f9e82..b3bf3f768 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldImportExport.java @@ -148,27 +148,4 @@ public class FieldImportExport { this.visibilityRules = visibilityRules; } - public FieldPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) { - FieldPersist fieldEntity =new FieldPersist(); - fieldEntity.setId(this.id); - fieldEntity.setOrdinal(this.ordinal); - fieldEntity.setValidations(this.validations); - fieldEntity.setDefaultValue(this.defaultValue); - List rulePersists = new ArrayList<>(); - if(this.visibilityRules!=null) { - for (RuleImportExport xmlRule : this.visibilityRules) { - rulePersists.add(xmlRule.toPersistModel()); - } - } - fieldEntity.setVisibilityRules(rulePersists); - FieldType fieldType = this.fieldType; - - BaseFieldDataEntity data = new FieldDataHelper().toFieldData(null, fieldType, (Element) this.data); - if (data != null) { - FieldDataHelperService fieldDataHelperService = fieldDataHelperServiceProvider.get(fieldType); - fieldEntity.setData(fieldDataHelperService.importExportMapDataToPersist(this.data)); - } - fieldEntity.setSchematics(this.schematics); - return fieldEntity; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java index 444e73822..6168ddd97 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java @@ -113,24 +113,4 @@ public class FieldSetImportExport { this.title = title; } - public FieldSetPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) { - FieldSetPersist fieldSet1Entity = new FieldSetPersist(); - fieldSet1Entity.setId(this.id); - fieldSet1Entity.setOrdinal(this.ordinal); - fieldSet1Entity.setHasCommentField(this.commentField != null ? this.commentField : false); - fieldSet1Entity.setMultiplicity(this.multiplicity != null ? this.multiplicity.toPersistModel() : null); - fieldSet1Entity.setTitle(this.title); - fieldSet1Entity.setDescription(this.description); - fieldSet1Entity.setExtendedDescription(this.extendedDescription); - fieldSet1Entity.setAdditionalInformation(this.additionalInformation); - - List fieldsEntity = new LinkedList<>(); - if (this.fields != null){ - for (FieldImportExport xmlField : this.fields) { - fieldsEntity.add(xmlField.toPersistModel(fieldDataHelperServiceProvider)); - } - } - fieldSet1Entity.setFields(fieldsEntity); - return fieldSet1Entity; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/MultiplicityImportXml.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/MultiplicityImportXml.java index 469f291d2..1ee02b8e4 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/MultiplicityImportXml.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/MultiplicityImportXml.java @@ -48,12 +48,4 @@ public class MultiplicityImportXml { this.tableView = tableView; } - public MultiplicityPersist toPersistModel() { - MultiplicityPersist multiplicityEntity = new MultiplicityPersist(); - multiplicityEntity.setMax(max); - multiplicityEntity.setMin(min); - multiplicityEntity.setPlaceholder(placeholder); - multiplicityEntity.setTableView(tableView); - return multiplicityEntity; - } } \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/PageImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/PageImportExport.java index 3a6507dfb..ff1c5a75f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/PageImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/PageImportExport.java @@ -52,15 +52,4 @@ public class PageImportExport { this.sections = sections; } - public PagePersist toPersistModel(){ - PagePersist pageEntity = new PagePersist(); - pageEntity.setId(this.id); - pageEntity.setOrdinal(this.ordinal); - pageEntity.setTitle(this.title); - return pageEntity; - } - - public SectionPersist toPersistModel(int i, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){ - return sections.get(i).toPersistModel(fieldDataHelperServiceProvider); - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/RuleImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/RuleImportExport.java index 41a8d9ddf..3152ed0ea 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/RuleImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/RuleImportExport.java @@ -27,11 +27,4 @@ public class RuleImportExport { public void setValue(String value) { this.value = value; } - - public RulePersist toPersistModel(){ - RulePersist ruleEntity = new RulePersist(); - ruleEntity.setTarget(target); - ruleEntity.setValue(value); - return ruleEntity; - } } \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/SectionImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/SectionImportExport.java index f159ef662..19defe638 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/SectionImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/SectionImportExport.java @@ -1,11 +1,7 @@ package eu.eudat.commons.types.descriptiontemplate.importexport; -import eu.eudat.model.persist.descriptiontemplatedefinition.FieldSetPersist; -import eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist; -import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider; import jakarta.xml.bind.annotation.*; -import java.util.LinkedList; import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) @@ -29,7 +25,7 @@ public class SectionImportExport { private String title; @XmlElementWrapper(name = "sections") @XmlElement(name = "section") - private List section; + private List sections; @XmlAttribute(name = "multiplicity") private Boolean multiplicity; @@ -97,12 +93,12 @@ public class SectionImportExport { this.title = title; } - public List getSection() { - return section; + public List getSections() { + return sections; } - public void setSection(List section) { - this.section = section; + public void setSections(List sections) { + this.sections = sections; } public Boolean getMultiplicity() { @@ -113,35 +109,4 @@ public class SectionImportExport { this.multiplicity = multiplicity; } - public SectionPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) { - SectionPersist sectionEntity = new SectionPersist(); - List sectionsListEntity = new LinkedList<>(); - - if (this.section != null) { - for (SectionImportExport xmlsection : this.section) { - sectionsListEntity.add(xmlsection.toPersistModel(fieldDataHelperServiceProvider)); - } - } - sectionEntity.setId(this.id); - sectionEntity.setOrdinal(this.ordinal); - sectionEntity.setTitle(this.title); - sectionEntity.setPage(this.page); - sectionEntity.setDescription(this.description); -// List fieldSetsEntity =new LinkedList<>(); -// -// for (FieldSets xmpFieldSets: this.fieldSets) { -// fieldSetsEntity.add(xmpFieldSets.toAdminCompositeModelSection()); -// } - List fieldSetEntity = new LinkedList<>(); - if(this.fieldSets!=null) { - for (FieldSetImportExport xmlFieldSet : this.fieldSets) { - fieldSetEntity.add(xmlFieldSet.toPersistModel(fieldDataHelperServiceProvider)); - } - } - sectionEntity.setFieldSets(fieldSetEntity); - - sectionEntity.setSections(sectionsListEntity); - sectionEntity.setDefaultVisibility(this.defaultVisibility); - return sectionEntity; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateService.java b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateService.java index a468cf84b..1699a75ca 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateService.java @@ -10,6 +10,7 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.fieldset.FieldSet; import jakarta.xml.bind.JAXBException; +import org.springframework.http.ResponseEntity; import org.xml.sax.SAXException; import javax.management.InvalidApplicationException; @@ -25,4 +26,5 @@ public interface DescriptionTemplateService { DescriptionTemplate buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException; DescriptionTemplate createNewVersion(NewVersionDescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException; DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 168fd5a69..f75f94683 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -5,12 +5,14 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.DescriptionTemplateStatus; +import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.UserDescriptionTemplateRole; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.descriptiontemplate.*; import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity; -import eu.eudat.commons.types.descriptiontemplate.importexport.DescriptionTemplateImportExport; +import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper; +import eu.eudat.commons.types.descriptiontemplate.importexport.*; import eu.eudat.convention.ConventionService; import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.UserDescriptionTemplateEntity; @@ -30,9 +32,11 @@ import eu.eudat.model.persist.descriptiontemplatedefinition.*; import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist; import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.UserDescriptionTemplateQuery; +import eu.eudat.service.fielddatahelper.FieldDataHelperService; import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider; import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.SimpleMail; +import eu.eudat.service.responseutils.ResponseUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -55,7 +59,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.core.env.Environment; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import org.w3c.dom.Element; import org.xml.sax.SAXException; import javax.management.InvalidApplicationException; @@ -65,6 +71,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Instant; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -91,6 +98,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic private final ValidationService validationService; private final MailService mailService; private final Environment environment; + private final ResponseUtilsService responseUtilsService; @Autowired public DescriptionTemplateServiceImpl( @@ -101,7 +109,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic ConventionService conventionService, MessageSource messageSource, XmlHandlingService xmlHandlingService, - FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, MailService mailService, Environment environment) { + FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, MailService mailService, Environment environment, ResponseUtilsService responseUtilsService) { this.entityManager = entityManager; this.userScope = userScope; this.authorizationService = authorizationService; @@ -116,6 +124,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic this.validationService = validationService; this.mailService = mailService; this.environment = environment; + this.responseUtilsService = responseUtilsService; } //region Persist @@ -132,6 +141,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic data = this.entityManager.find(DescriptionTemplateEntity.class, model.getId()); if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + if (data.getStatus() == DescriptionTemplateStatus.Finalized) throw new MyForbiddenException("Can not update finalized template"); } else { data = new DescriptionTemplateEntity(); data.setId(UUID.randomUUID()); @@ -485,19 +495,292 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic this.authorizationService.authorizeForce(Permission.ImportDescriptionTemplate); DescriptionTemplateImportExport importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportExport.class, new String(bytes, StandardCharsets.UTF_8)); - if (id != null) { - DescriptionTemplatePersist persist = importXml.toPersistModel(label, this.fieldDataHelperServiceProvider); + if (id == null) { + DescriptionTemplatePersist persist = new DescriptionTemplatePersist(); + persist.setLabel(label); + persist.setStatus(DescriptionTemplateStatus.Draft); + persist.setDescription(importXml.getDescription()); + persist.setLanguage(importXml.getLanguage()); + persist.setType(importXml.getType()); + persist.setDefinition(this.xmlDefinitionToPersist(importXml)); this.validationService.validateForce(persist); return this.persist(persist, fields); } else { - NewVersionDescriptionTemplatePersist persist = importXml.toNewVersionPersistModel(id, label, this.fieldDataHelperServiceProvider); + NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist(); + persist.setId(id); + persist.setLabel(label); + persist.setStatus(DescriptionTemplateStatus.Draft); + persist.setDescription(importXml.getDescription()); + persist.setLanguage(importXml.getLanguage()); + persist.setDefinition(this.xmlDefinitionToPersist(importXml)); + persist.setType(importXml.getType()); + DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id); if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); persist.setHash(this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt())); this.validationService.validateForce(persist); return this.createNewVersion(persist, fields); } - } + } + + public DefinitionPersist xmlDefinitionToPersist(DescriptionTemplateImportExport importExport){ + DefinitionPersist definitionPersist = new DefinitionPersist(); + if(importExport == null) return null; + + List pagesDatasetEntity = new LinkedList<>(); + List sectionDatasetEntity = new LinkedList<>(); + if (!this.conventionService.isListNullOrEmpty(importExport.getPages())) { + for (PageImportExport xmlPage : importExport.getPages()) { + pagesDatasetEntity.add(this.xmlPageToPersist(xmlPage)); + if (!this.conventionService.isListNullOrEmpty(xmlPage.getSections())) { + for (int i = 0; i < xmlPage.getSections().size(); i++) { + sectionDatasetEntity.add(this.xmlSectionToPersist(xmlPage.getSections().get(i))); + } + } + } + } + definitionPersist.setPages(pagesDatasetEntity); + definitionPersist.setSections(sectionDatasetEntity); + + return definitionPersist; + } + + public PagePersist xmlPageToPersist(PageImportExport importExport){ + PagePersist pageEntity = new PagePersist(); + pageEntity.setId(importExport.getId()); + pageEntity.setOrdinal(importExport.getOrdinal()); + pageEntity.setTitle(importExport.getTitle()); + return pageEntity; + } + + public SectionPersist xmlSectionToPersist(SectionImportExport importExport) { + SectionPersist sectionEntity = new SectionPersist(); + List sectionsListEntity = new LinkedList<>(); + + if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) { + for (SectionImportExport xmlSection : importExport.getSections()) { + sectionsListEntity.add(this.xmlSectionToPersist(xmlSection)); + } + } + sectionEntity.setId(importExport.getId()); + sectionEntity.setOrdinal(importExport.getOrdinal()); + sectionEntity.setTitle(importExport.getTitle()); + sectionEntity.setPage(importExport.getPage()); + sectionEntity.setDescription(importExport.getDescription()); + List fieldSetEntity = new LinkedList<>(); + if(!this.conventionService.isListNullOrEmpty(importExport.getFieldSets())) { + for (FieldSetImportExport xmlFieldSet : importExport.getFieldSets()) { + fieldSetEntity.add(this.toFieldSetModel(xmlFieldSet)); + } + } + sectionEntity.setFieldSets(fieldSetEntity); + + sectionEntity.setSections(sectionsListEntity); + sectionEntity.setDefaultVisibility(importExport.getDefaultVisibility()); + return sectionEntity; + } + + + public FieldSetPersist toFieldSetModel(FieldSetImportExport importExport) { + FieldSetPersist fieldSet1Entity = new FieldSetPersist(); + fieldSet1Entity.setId(importExport.getId()); + fieldSet1Entity.setOrdinal(importExport.getOrdinal()); + fieldSet1Entity.setHasCommentField(importExport.getCommentField() != null ? importExport.getCommentField() : false); + fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null); + fieldSet1Entity.setTitle(importExport.getTitle()); + fieldSet1Entity.setDescription(importExport.getDescription()); + fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription()); + fieldSet1Entity.setAdditionalInformation(importExport.getAdditionalInformation()); + + List fieldsEntity = new LinkedList<>(); + if (!this.conventionService.isListNullOrEmpty(importExport.getFields())){ + for (FieldImportExport xmlField : importExport.getFields()) { + fieldsEntity.add(this.xmlFieldToPersist(xmlField)); + } + } + fieldSet1Entity.setFields(fieldsEntity); + return fieldSet1Entity; + } + + + public FieldPersist xmlFieldToPersist(FieldImportExport importExport) { + FieldPersist fieldEntity = new FieldPersist(); + fieldEntity.setId(importExport.getId()); + fieldEntity.setOrdinal(importExport.getOrdinal()); + fieldEntity.setValidations(importExport.getValidations()); + fieldEntity.setDefaultValue(importExport.getDefaultValue()); + List rulePersists = new ArrayList<>(); + if(importExport.getVisibilityRules() !=null) { + for (RuleImportExport xmlRule : importExport.getVisibilityRules()) { + rulePersists.add(this.toRuleModel(xmlRule)); + } + } + fieldEntity.setVisibilityRules(rulePersists); + FieldType fieldType = importExport.getFieldType(); + + if (importExport.getData() != null) { + FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(fieldType); + fieldEntity.setData(fieldDataHelperService.importExportMapDataToPersist(importExport.getData())); + } + fieldEntity.setSchematics(importExport.getSchematics()); + return fieldEntity; + } + + public RulePersist toRuleModel(RuleImportExport importExport){ + RulePersist ruleEntity = new RulePersist(); + ruleEntity.setTarget(importExport.getTarget()); + ruleEntity.setValue(importExport.getValue()); + return ruleEntity; + } + + + public MultiplicityPersist xmlMultiplicityToPersist(MultiplicityImportXml importXml) { + MultiplicityPersist multiplicityEntity = new MultiplicityPersist(); + multiplicityEntity.setMax(importXml.getMax()); + multiplicityEntity.setMin(importXml.getMin()); + multiplicityEntity.setPlaceholder(importXml.getPlaceholder()); + multiplicityEntity.setTableView(importXml.getTableView()); + return multiplicityEntity; + } + + //endregion + + //region Export + + public ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException { + logger.debug(new MapLogEntry("persisting data").And("id", id)); + + this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate); + DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id); + if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition()); + String xml = this.xmlHandlingService.toXml(this.definitionXmlToExport(data, definition)); + return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml"); + } + + public DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity){ + DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport(); + xml.setType(data.getType()); + xml.setLanguage(data.getLanguage()); + xml.setDescription(data.getDescription()); + List pagesDatasetEntity = new LinkedList<>(); + for (PageEntity xmlPage: entity.getPages()) { + pagesDatasetEntity.add(this.pageXmlToExport(xmlPage, entity.getSections())); + } + xml.setPages(pagesDatasetEntity); + + return xml; + } + + public PageImportExport pageXmlToExport(PageEntity entity, List sectionEntities){ + PageImportExport xml = new PageImportExport(); + xml.setId(entity.getId()); + xml.setOrdinal(entity.getOrdinal()); + xml.setTitle(entity.getTitle()); + List sectionsListEntity = new LinkedList<>(); + if (!this.conventionService.isListNullOrEmpty(sectionEntities)) { + for (SectionEntity section : sectionEntities) { + if (section.getPage().equals(entity.getId())) { + sectionsListEntity.add(this.sectionXmlToExport(section)); + } + } + } + xml.setSections(sectionsListEntity); + + return xml; + } + + public SectionImportExport sectionXmlToExport(SectionEntity entity) { + SectionImportExport xml = new SectionImportExport(); + List sectionsListEntity = new LinkedList<>(); + + if (!this.conventionService.isListNullOrEmpty(entity.getSections())) { + for (SectionEntity xmlSection : entity.getSections()) { + sectionsListEntity.add(this.sectionXmlToExport(xmlSection)); + } + } + xml.setSections(sectionsListEntity); + + xml.setId(entity.getId()); + xml.setOrdinal(entity.getOrdinal()); + xml.setTitle(entity.getTitle()); + xml.setPage(entity.getPage()); + xml.setDescription(entity.getDescription()); + List fieldSetEntity = new LinkedList<>(); + if(!this.conventionService.isListNullOrEmpty(entity.getFieldSets())) { + for (FieldSetEntity xmlFieldSet : entity.getFieldSets()) { + fieldSetEntity.add(this.fieldSetXmlToExport(xmlFieldSet)); + } + } + xml.setFieldSets(fieldSetEntity); + + xml.setDefaultVisibility(entity.isDefaultVisibility()); + return xml; + } + + + public FieldSetImportExport fieldSetXmlToExport(FieldSetEntity entity) { + FieldSetImportExport fieldSet1Entity = new FieldSetImportExport(); + fieldSet1Entity.setId(entity.getId()); + fieldSet1Entity.setOrdinal(entity.getOrdinal()); + fieldSet1Entity.setCommentField(entity.getHasCommentField()); + fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null); + fieldSet1Entity.setTitle(entity.getTitle()); + fieldSet1Entity.setDescription(entity.getDescription()); + fieldSet1Entity.setExtendedDescription(entity.getExtendedDescription()); + fieldSet1Entity.setAdditionalInformation(entity.getAdditionalInformation()); + + List fieldsEntity = new LinkedList<>(); + if (entity.getFields() != null){ + for (FieldEntity xmlField : entity.getFields()) { + fieldsEntity.add(this.fieldXmlToExport(xmlField)); + } + } + fieldSet1Entity.setFields(fieldsEntity); + return fieldSet1Entity; + } + + + public FieldImportExport fieldXmlToExport(FieldEntity entity) { + FieldImportExport xml = new FieldImportExport(); + xml.setId(entity.getId()); + xml.setOrdinal(entity.getOrdinal()); + xml.setValidations(entity.getValidations()); + xml.setDefaultValue(entity.getDefaultValue()); + List rulePersists = new ArrayList<>(); + if(!this.conventionService.isListNullOrEmpty(entity.getVisibilityRules())) { + for (RuleEntity xmlRule : entity.getVisibilityRules()) { + rulePersists.add(this.toRuleModel(xmlRule)); + } + } + xml.setVisibilityRules(rulePersists); + + if (entity.getData() != null) { + FieldType fieldType = entity.getData().getFieldType(); + FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(fieldType); + xml.setData(fieldDataHelperService.dataToImportExportXml(entity.getData())); + } + xml.setSchematics(entity.getSchematics()); + return xml; + } + + public RuleImportExport toRuleModel(RuleEntity entity){ + RuleImportExport xml = new RuleImportExport(); + xml.setTarget(entity.getTarget()); + xml.setValue(entity.getValue()); + return xml; + } + + + public MultiplicityImportXml multiplicityXmlToExport(MultiplicityEntity entity) { + MultiplicityImportXml xml = new MultiplicityImportXml(); + xml.setMax(entity.getMax()); + xml.setMin(entity.getMin()); + xml.setPlaceholder(entity.getPlaceholder()); + xml.setTableView(entity.getTableView()); + return xml; + } //endregion } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/AutoCompleteFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/AutoCompleteFieldDataHelperService.java index 3ffe90590..4505b488d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/AutoCompleteFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/AutoCompleteFieldDataHelperService.java @@ -189,4 +189,56 @@ public class AutoCompleteFieldDataHelperService extends BaseFieldDataHelperServi return persist; } + + @Override + protected AutoCompleteDataImportExport dataToImportExportXmlInternal(AutoCompleteDataEntity data, AutoCompleteDataImportExport xml) { + xml.setMultiAutoComplete(data.getMultiAutoComplete()); + if (!this.conventionService.isListNullOrEmpty(data.getAutoCompleteSingleDataList())){ + xml.setAutoCompleteSingleDataList(new ArrayList<>()); + for (AutoCompleteDataEntity.AutoCompleteSingleData autoCompleteSingleData: data.getAutoCompleteSingleDataList()) { + xml.getAutoCompleteSingleDataList().add(this.buildAutoCompleteSingleData(autoCompleteSingleData)); + } + } + return xml; + } + + private @NotNull AutoCompleteSingleData buildAutoCompleteSingleData(AutoCompleteDataEntity.AutoCompleteSingleData data){ + AutoCompleteSingleData xml = new AutoCompleteSingleData(); + if (data == null) return xml; + + xml.setUrl(data.getUrl()); + xml.setAutocompleteType(data.getAutocompleteType()); + xml.setOptionsRoot(data.getOptionsRoot()); + xml.setHasAuth(data.getHasAuth()); + if(data.getAutoCompleteOptions() != null) xml.setAutoCompleteOptions(this.buildOption(data.getAutoCompleteOptions())); + if(data.getAuth() != null) xml.setAuth(this.buildAuthAutoCompleteData(data.getAuth())); + xml.setMethod(data.getMethod()); + + return xml; + } + + private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){ + ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity(); + if (data == null) return xml; + + xml.setLabel(data.getLabel()); + xml.setValue(data.getValue()); + xml.setUri(data.getUri()); + xml.setSource(data.getSource()); + + return xml; + } + + private @NotNull AuthAutoCompleteData buildAuthAutoCompleteData(AutoCompleteDataEntity.AuthAutoCompleteData data){ + AuthAutoCompleteData xml = new AuthAutoCompleteData(); + if (data == null) return xml; + + xml.setBody(data.getBody()); + xml.setUrl(data.getUrl()); + xml.setMethod(data.getMethod()); + xml.setPath(data.getPath()); + xml.setType(data.getType()); + + return xml; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BaseFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BaseFieldDataHelperService.java index 390e70c82..db1afd356 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BaseFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BaseFieldDataHelperService.java @@ -24,6 +24,7 @@ public abstract class BaseFieldDataHelperService buildInternal(FieldSet fieldSet, List datas, EnumSet authorizationFlags); protected abstract D applyPersistInternal(PM persist, D data); protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist); + protected abstract IE dataToImportExportXmlInternal(D data, IE xml); @Override public BaseFieldDataEntity newDataInstance() { return this.newDataInstanceInternal(); @@ -51,6 +52,13 @@ public abstract class BaseFieldDataHelperService data){ + IE xml = this.newImportExportInstanceInternal(); + xml.setLabel(data.getLabel()); + return this.dataToImportExportXmlInternal((D)data, xml); + } @Override public BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist){ BaseFieldDataEntity instance = this.newDataInstance(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BooleanDecisionFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BooleanDecisionFieldDataHelperService.java index da2b2794e..e7c948c60 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BooleanDecisionFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/BooleanDecisionFieldDataHelperService.java @@ -88,4 +88,9 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe return persist; } + @Override + protected BooleanDecisionDataImportExport dataToImportExportXmlInternal(BooleanDecisionDataEntity data, BooleanDecisionDataImportExport xml) { + return xml; + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/CheckBoxFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/CheckBoxFieldDataHelperService.java index 744df6996..7baf19bea 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/CheckBoxFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/CheckBoxFieldDataHelperService.java @@ -91,4 +91,9 @@ public class CheckBoxFieldDataHelperService extends BaseFieldDataHelperService data, EnumSet authorizationFlags); BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist); BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity data); - BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport data); + BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml); + BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity data); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/FreeTextFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/FreeTextFieldDataHelperService.java index 8d4eaac01..aec2eefee 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/FreeTextFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/FreeTextFieldDataHelperService.java @@ -91,4 +91,9 @@ public class FreeTextFieldDataHelperService extends BaseFieldDataHelperService()); + for (RadioBoxDataEntity.Option radioBoxOption: data.getOptions()) { + xml.getOptions().add(this.buildOption(radioBoxOption)); + } + } + return xml; + } + + private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.Option data){ + RadioBoxOption xml = new RadioBoxOption(); + if (data == null) return xml; + + xml.setLabel(data.getLabel()); + xml.setValue(data.getValue()); + + return xml; + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/RegistryFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/RegistryFieldDataHelperService.java index ace57de33..d539c2b5e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/RegistryFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/RegistryFieldDataHelperService.java @@ -92,4 +92,10 @@ public class RegistryFieldDataHelperService extends BaseFieldDataHelperService()); + for (UploadDataEntity.Option option: data.getTypes()) { + xml.getTypes().add(this.buildOption(option)); + } + } + return xml; + } + + private @NotNull UploadDataOption buildOption(UploadDataEntity.Option data){ + UploadDataOption xml = new UploadDataOption(); + if (data == null) return xml; + + xml.setLabel(data.getLabel()); + xml.setValue(data.getValue()); + + return xml; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ValidationFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ValidationFieldDataHelperService.java index 5ab135164..3c58ca698 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ValidationFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ValidationFieldDataHelperService.java @@ -90,4 +90,9 @@ public class ValidationFieldDataHelperService extends BaseFieldDataHelperService protected ValidationDataPersist importExportMapDataToPersistInternal(ValidationDataImportExport data, ValidationDataPersist persist) { return persist; } + + @Override + protected ValidationDataImportExport dataToImportExportXmlInternal(ValidationDataEntity data, ValidationDataImportExport xml) { + return xml; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/WordListFieldDataHelperService.java b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/WordListFieldDataHelperService.java index 3750abb7d..277ffa0ae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/WordListFieldDataHelperService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/WordListFieldDataHelperService.java @@ -131,4 +131,27 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService()); + for (ComboBoxDataEntity.Option option: data.getOptions()) { + xml.getOptions().add(this.buildOption(option)); + } + } + return xml; + } + private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){ + ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity(); + if (data == null) return xml; + + xml.setLabel(data.getLabel()); + xml.setValue(data.getValue()); + xml.setUri(data.getUri()); + xml.setSource(data.getSource()); + + return xml; + } + } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateController.java index 4b6fc3b1b..42e33cd00 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateController.java @@ -30,6 +30,7 @@ import jakarta.xml.bind.JAXBException; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -168,6 +169,20 @@ public class DescriptionTemplateController { return persisted; } + + + @RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml") + public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { + logger.debug(new MapLogEntry("export" + DescriptionTemplate.class.getSimpleName()).And("id", id)); + + ResponseEntity response = this.descriptionTemplateTypeService.exportXml(id); + + this.auditService.track(AuditableAction.DescriptionTemplate_GetXml, Map.ofEntries( + new AbstractMap.SimpleEntry("id", id) + )); + return response; + } + @RequestMapping(method = RequestMethod.POST, value = {"/xml/import/{id}", "/xml/import"}) public DescriptionTemplate importXml(@RequestParam("file") MultipartFile file, @PathVariable(value = "id", required = false) UUID id, FieldSet fieldSet) throws IOException, JAXBException, InvalidApplicationException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { logger.debug(new MapLogEntry("import" + DescriptionTemplate.class.getSimpleName()).And("file", file).And("id", id)); @@ -176,7 +191,7 @@ public class DescriptionTemplateController { DescriptionTemplate model = this.descriptionTemplateTypeService.importXml(file.getBytes(), id, file.getOriginalFilename(), fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries( + this.auditService.track(AuditableAction.DescriptionTemplate_Import, Map.ofEntries( new AbstractMap.SimpleEntry("file", file), new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("fields", fieldSet) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java index 0ca9f3669..18adc93de 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java @@ -160,7 +160,7 @@ public class DmpBlueprintController { @RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml") public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { - logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id)); ResponseEntity response = this.dmpBlueprintService.exportXml(id); @@ -178,7 +178,7 @@ public class DmpBlueprintController { DmpBlueprint model = this.dmpBlueprintService.importXml(file.getBytes(), file.getOriginalFilename(), fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries( + this.auditService.track(AuditableAction.DmpBlueprint_Import, Map.ofEntries( new AbstractMap.SimpleEntry("file", file), new AbstractMap.SimpleEntry("fields", fieldSet) )); diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 0b89d1088..a7707d181 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -155,6 +155,14 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + ExportDescriptionTemplate: + roles: + - Admin + - DatasetProfileManager + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false # Dmp BrowseDmp: roles: