export xml changes
This commit is contained in:
parent
85b2258e19
commit
418188546a
|
@ -5,4 +5,5 @@ import java.util.EnumSet;
|
||||||
public enum AuthorizationFlags {
|
public enum AuthorizationFlags {
|
||||||
None, Permission, DmpAssociated, Public, Owner;
|
None, Permission, DmpAssociated, Public, Owner;
|
||||||
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermission = EnumSet.of(DmpAssociated, Permission, Owner);
|
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermission = EnumSet.of(DmpAssociated, Permission, Owner);
|
||||||
|
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermissionOrPublic = EnumSet.of(DmpAssociated, Permission, Owner, Public);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public interface DescriptionService {
|
||||||
StorageFileEntity getFieldFile(UUID descriptionId, UUID storageFileId);
|
StorageFileEntity getFieldFile(UUID descriptionId, UUID storageFileId);
|
||||||
void updateDescriptionTemplate(UpdateDescriptionTemplatePersist model) throws InvalidApplicationException, IOException, JAXBException;
|
void updateDescriptionTemplate(UpdateDescriptionTemplatePersist model) throws InvalidApplicationException, IOException, JAXBException;
|
||||||
|
|
||||||
DescriptionImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
DescriptionImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1119,13 +1119,12 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
//region Export
|
//region Export
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
public DescriptionImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDescription);
|
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescription);
|
||||||
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, id);
|
DescriptionEntity data = this.queryFactory.query(DescriptionQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
PropertyDefinitionEntity definition = this.jsonHandlingService.fromJson(PropertyDefinitionEntity.class, data.getProperties());
|
PropertyDefinitionEntity definition = this.jsonHandlingService.fromJson(PropertyDefinitionEntity.class, data.getProperties());
|
||||||
return this.toExport(data, definition);
|
return this.toExport(data, definition);
|
||||||
|
@ -1136,11 +1135,10 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDescription);
|
this.authorizationService.authorizeForce(Permission.ExportDescription);
|
||||||
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, id);
|
DescriptionEntity data = this.queryFactory.query(DescriptionQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId()));
|
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId(), false));
|
||||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,20 +1149,20 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
xml.setLabel(data.getLabel());
|
xml.setLabel(data.getLabel());
|
||||||
xml.setFinalizedAt(data.getFinalizedAt());
|
xml.setFinalizedAt(data.getFinalizedAt());
|
||||||
|
|
||||||
DescriptionTemplateEntity blueprintEntity = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
DescriptionTemplateEntity blueprintEntity = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (blueprintEntity != null) {
|
if (blueprintEntity != null) {
|
||||||
xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(blueprintEntity.getId()));
|
xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(blueprintEntity.getId(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertiesEntity != null) {
|
if (propertiesEntity != null) {
|
||||||
xml.setProperties(this.descriptionPropertyDefinitionToExport(propertiesEntity));
|
xml.setProperties(this.descriptionPropertyDefinitionToExport(propertiesEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DescriptionReferenceEntity> dmpReferences = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<DescriptionReferenceEntity> dmpReferences = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpReferences)) {
|
if (!this.conventionService.isListNullOrEmpty(dmpReferences)) {
|
||||||
List<ReferenceEntity> references = this.queryFactory.query(ReferenceQuery.class).ids(dmpReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<ReferenceEntity> references = this.queryFactory.query(ReferenceQuery.class).ids(dmpReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, ReferenceEntity> referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x));
|
Map<UUID, ReferenceEntity> referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x));
|
||||||
List<ReferenceTypeEntity> referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<ReferenceTypeEntity> referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x));
|
Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x));
|
||||||
List<DescriptionReferenceImportExport> dmpReferenceImportExports = new LinkedList<>();
|
List<DescriptionReferenceImportExport> dmpReferenceImportExports = new LinkedList<>();
|
||||||
for (DescriptionReferenceEntity descriptionTemplateEntity : dmpReferences) {
|
for (DescriptionReferenceEntity descriptionTemplateEntity : dmpReferences) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public interface DescriptionTemplateService {
|
||||||
DescriptionTemplate createNewVersion(NewVersionDescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
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;
|
DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
DescriptionTemplateImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
||||||
|
|
||||||
|
|
|
@ -898,13 +898,12 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
//region Export
|
//region Export
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionTemplateImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
public DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
||||||
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
||||||
return this.definitionXmlToExport(data, definition);
|
return this.definitionXmlToExport(data, definition);
|
||||||
|
@ -916,12 +915,10 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
||||||
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.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.exportXmlEntity(id, false));
|
||||||
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(id));
|
|
||||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public interface DmpService {
|
||||||
|
|
||||||
void dmpInvitationAccept(String token) throws InvalidApplicationException, IOException;
|
void dmpInvitationAccept(String token) throws InvalidApplicationException, IOException;
|
||||||
|
|
||||||
DmpImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
DmpImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1345,13 +1345,12 @@ public class DmpServiceImpl implements DmpService {
|
||||||
//region Export
|
//region Export
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DmpImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
public DmpImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDmp);
|
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDmp);
|
||||||
DmpEntity data = this.entityManager.find(DmpEntity.class, id);
|
DmpEntity data = this.queryFactory.query(DmpQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
DmpPropertiesEntity definition = this.jsonHandlingService.fromJson(DmpPropertiesEntity.class, data.getProperties());
|
DmpPropertiesEntity definition = this.jsonHandlingService.fromJson(DmpPropertiesEntity.class, data.getProperties());
|
||||||
return this.definitionXmlToExport(data, definition);
|
return this.definitionXmlToExport(data, definition);
|
||||||
|
@ -1362,11 +1361,10 @@ public class DmpServiceImpl implements DmpService {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDmp);
|
this.authorizationService.authorizeForce(Permission.ExportDmp);
|
||||||
DmpEntity data = this.entityManager.find(DmpEntity.class, id);
|
DmpEntity data = this.queryFactory.query(DmpQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId()));
|
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId(), false));
|
||||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1382,7 +1380,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) {
|
if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) {
|
||||||
List<DmpContactImportExport> dmpContactImportExports = new LinkedList<>();
|
List<DmpContactImportExport> dmpContactImportExports = new LinkedList<>();
|
||||||
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(propertiesEntity.getContacts().stream().map(DmpContactEntity::getUserId).filter(Objects::nonNull).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(propertiesEntity.getContacts().stream().map(DmpContactEntity::getUserId).filter(Objects::nonNull).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
||||||
for (DmpContactEntity contactEntity : propertiesEntity.getContacts()) {
|
for (DmpContactEntity contactEntity : propertiesEntity.getContacts()) {
|
||||||
dmpContactImportExports.add(this.dmpContactToExport(contactEntity, usersMap));
|
dmpContactImportExports.add(this.dmpContactToExport(contactEntity, usersMap));
|
||||||
|
@ -1390,9 +1388,9 @@ public class DmpServiceImpl implements DmpService {
|
||||||
xml.setContacts(dmpContactImportExports);
|
xml.setContacts(dmpContactImportExports);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActives(IsActive.Active).collect();
|
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActives(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpUsers)) {
|
if (!this.conventionService.isListNullOrEmpty(dmpUsers)) {
|
||||||
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(dmpUsers.stream().map(DmpUserEntity::getUserId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(dmpUsers.stream().map(DmpUserEntity::getUserId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
||||||
List<DmpUserImportExport> dmpUserImportExports = new LinkedList<>();
|
List<DmpUserImportExport> dmpUserImportExports = new LinkedList<>();
|
||||||
for (DmpUserEntity dmpUserEntity : dmpUsers) {
|
for (DmpUserEntity dmpUserEntity : dmpUsers) {
|
||||||
|
@ -1400,12 +1398,12 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
xml.setUsers(dmpUserImportExports);
|
xml.setUsers(dmpUserImportExports);
|
||||||
}
|
}
|
||||||
DmpBlueprintEntity blueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).ids(data.getBlueprintId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
DmpBlueprintEntity blueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).ids(data.getBlueprintId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (blueprintEntity != null) {
|
if (blueprintEntity != null) {
|
||||||
xml.setBlueprint(this.dmpBlueprintService.getExportXmlEntity(blueprintEntity.getId()));
|
xml.setBlueprint(this.dmpBlueprintService.getExportXmlEntity(blueprintEntity.getId(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(data.getId()).isActive(IsActive.Active).collect();
|
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).dmpIds(data.getId()).isActive(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)) {
|
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)) {
|
||||||
List<DmpDescriptionTemplateImportExport> dmpDescriptionTemplateImportExports = new LinkedList<>();
|
List<DmpDescriptionTemplateImportExport> dmpDescriptionTemplateImportExports = new LinkedList<>();
|
||||||
for (DmpDescriptionTemplateEntity descriptionTemplateEntity : dmpDescriptionTemplateEntities) {
|
for (DmpDescriptionTemplateEntity descriptionTemplateEntity : dmpDescriptionTemplateEntities) {
|
||||||
|
@ -1422,9 +1420,9 @@ public class DmpServiceImpl implements DmpService {
|
||||||
xml.setBlueprintValues(dmpDescriptionTemplateImportExports);
|
xml.setBlueprintValues(dmpDescriptionTemplateImportExports);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActives(IsActive.Active).collect();
|
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActives(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpReferences)) {
|
if (!this.conventionService.isListNullOrEmpty(dmpReferences)) {
|
||||||
List<ReferenceEntity> references = this.queryFactory.query(ReferenceQuery.class).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<ReferenceEntity> references = this.queryFactory.query(ReferenceQuery.class).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, ReferenceEntity> referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x));
|
Map<UUID, ReferenceEntity> referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x));
|
||||||
List<ReferenceTypeEntity> referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<ReferenceTypeEntity> referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x));
|
Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x));
|
||||||
|
@ -1434,11 +1432,11 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
xml.setReferences(dmpReferenceImportExports);
|
xml.setReferences(dmpReferenceImportExports);
|
||||||
}
|
}
|
||||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(data.getId()).isActive(IsActive.Active).collect();
|
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).dmpIds(data.getId()).isActive(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(descriptions)) {
|
if (!this.conventionService.isListNullOrEmpty(descriptions)) {
|
||||||
List<DescriptionImportExport> descriptionImportExports = new LinkedList<>();
|
List<DescriptionImportExport> descriptionImportExports = new LinkedList<>();
|
||||||
for (DescriptionEntity description : descriptions) {
|
for (DescriptionEntity description : descriptions) {
|
||||||
descriptionImportExports.add(this.descriptionService.exportXmlEntity(description.getId()));
|
descriptionImportExports.add(this.descriptionService.exportXmlEntity(description.getId(), true));
|
||||||
}
|
}
|
||||||
xml.setDescriptions(descriptionImportExports);
|
xml.setDescriptions(descriptionImportExports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public interface DmpBlueprintService {
|
||||||
|
|
||||||
DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fieldSet) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fieldSet) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
||||||
|
|
||||||
BlueprintImportExport getExportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
||||||
DmpBlueprint importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
DmpBlueprint importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.opencdmp.commons.types.dmpblueprint.*;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.importexport.*;
|
import org.opencdmp.commons.types.dmpblueprint.importexport.*;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.DmpBlueprintEntity;
|
import org.opencdmp.data.DmpBlueprintEntity;
|
||||||
|
import org.opencdmp.data.DmpEntity;
|
||||||
import org.opencdmp.data.TenantEntityManager;
|
import org.opencdmp.data.TenantEntityManager;
|
||||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
import org.opencdmp.model.DmpBlueprint;
|
import org.opencdmp.model.DmpBlueprint;
|
||||||
|
@ -22,6 +23,7 @@ import org.opencdmp.model.persist.DmpBlueprintPersist;
|
||||||
import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist;
|
import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist;
|
||||||
import org.opencdmp.model.persist.dmpblueprintdefinition.*;
|
import org.opencdmp.model.persist.dmpblueprintdefinition.*;
|
||||||
import org.opencdmp.query.DmpBlueprintQuery;
|
import org.opencdmp.query.DmpBlueprintQuery;
|
||||||
|
import org.opencdmp.query.DmpQuery;
|
||||||
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
@ -445,13 +447,12 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlueprintImportExport getExportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
public BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDmpBlueprint);
|
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDmpBlueprint);
|
||||||
DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id);
|
DmpBlueprintEntity data = this.queryFactory.query(DmpBlueprintQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
return this.definitionXmlToExport(data);
|
return this.definitionXmlToExport(data);
|
||||||
}
|
}
|
||||||
|
@ -460,11 +461,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException {
|
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("export xml").And("id", id));
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id);
|
DmpBlueprintEntity data = this.queryFactory.query(DmpBlueprintQuery.class).ids(id).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
||||||
if (data == null)
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
String xml = this.xmlHandlingService.toXml(this.getExportXmlEntity(id));
|
String xml = this.xmlHandlingService.toXml(this.getExportXmlEntity(id, false));
|
||||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,17 +222,10 @@ permissions:
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
ExportDescription:
|
ExportDescription:
|
||||||
roles:
|
roles: []
|
||||||
- TenantAdmin
|
|
||||||
dmp:
|
|
||||||
roles:
|
|
||||||
- Owner
|
|
||||||
- User
|
|
||||||
- DescriptionContributor
|
|
||||||
- Reviewer
|
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: true
|
||||||
# Tag
|
# Tag
|
||||||
BrowseTag:
|
BrowseTag:
|
||||||
roles:
|
roles:
|
||||||
|
@ -390,6 +383,7 @@ permissions:
|
||||||
ExportDescriptionTemplate:
|
ExportDescriptionTemplate:
|
||||||
roles:
|
roles:
|
||||||
- TenantAdmin
|
- TenantAdmin
|
||||||
|
- Admin
|
||||||
- TenantDescriptionTemplateEditor
|
- TenantDescriptionTemplateEditor
|
||||||
claims: [ ]
|
claims: [ ]
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
|
@ -454,15 +448,11 @@ permissions:
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
ExportDmp:
|
ExportDmp:
|
||||||
roles:
|
roles: [ ]
|
||||||
- TenantAdmin
|
|
||||||
dmp:
|
|
||||||
roles:
|
|
||||||
- Owner
|
|
||||||
claims: [ ]
|
claims: [ ]
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: true
|
||||||
CreateNewVersionDmp:
|
CreateNewVersionDmp:
|
||||||
roles:
|
roles:
|
||||||
- TenantAdmin
|
- TenantAdmin
|
||||||
|
@ -544,6 +534,7 @@ permissions:
|
||||||
ExportDmpBlueprint:
|
ExportDmpBlueprint:
|
||||||
roles:
|
roles:
|
||||||
- TenantAdmin
|
- TenantAdmin
|
||||||
|
- Admin
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
Loading…
Reference in New Issue