fix supportive materials to use config

This commit is contained in:
Efstratios Giannopoulos 2024-02-19 17:28:46 +02:00
parent fd30b89f93
commit a44fe43cf3
23 changed files with 160 additions and 371 deletions

View File

@ -7,7 +7,7 @@ import java.io.File;
*/ */
public class FileEnvelope { public class FileEnvelope {
private String filename; private String filename;
private File file; private byte[] file;
public String getFilename() { public String getFilename() {
return filename; return filename;
@ -17,11 +17,11 @@ public class FileEnvelope {
this.filename = filename; this.filename = filename;
} }
public File getFile() { public byte[] getFile() {
return file; return file;
} }
public void setFile(File file) { public void setFile(byte[] file) {
this.file = file; this.file = file;
} }
} }

View File

@ -730,7 +730,7 @@ public class DescriptionServiceImpl implements DescriptionService {
FileEnvelope fileEnvelope = this.fileTransformerService.exportDescription(id, exportType); FileEnvelope fileEnvelope = this.fileTransformerService.exportDescription(id, exportType);
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename()); headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath()); byte[] data = fileEnvelope.getFile();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<>(data, headers, HttpStatus.OK); return new ResponseEntity<>(data, headers, HttpStatus.OK);
} }

View File

@ -506,7 +506,7 @@ public class DmpServiceImpl implements DmpService {
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(id, exportType); FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(id, exportType);
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename()); headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath()); byte[] data = fileEnvelope.getFile();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<>(data, headers, HttpStatus.OK); return new ResponseEntity<>(data, headers, HttpStatus.OK);
} }

View File

@ -27,7 +27,6 @@ import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
@ -50,13 +49,12 @@ public class LanguageServiceImpl implements LanguageService {
private final ConventionService conventionService; private final ConventionService conventionService;
private final MessageSource messageSource; private final MessageSource messageSource;
private final ErrorThesaurusProperties errors; private final ErrorThesaurusProperties errors;
private final Environment environment;
private final StorageFileService storageFileService; private final StorageFileService storageFileService;
public LanguageServiceImpl( public LanguageServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors, Environment environment, StorageFileService storageFileService){ ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors, StorageFileService storageFileService){
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -64,7 +62,6 @@ public class LanguageServiceImpl implements LanguageService {
this.conventionService = conventionService; this.conventionService = conventionService;
this.messageSource = messageSource; this.messageSource = messageSource;
this.errors = errors; this.errors = errors;
this.environment = environment;
this.storageFileService = storageFileService; this.storageFileService = storageFileService;
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.service.storage; package eu.eudat.service.storage;
import eu.eudat.commons.enums.StorageType; import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.model.StorageFile; import eu.eudat.model.StorageFile;
import eu.eudat.model.persist.StorageFilePersist; import eu.eudat.model.persist.StorageFilePersist;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -40,6 +41,8 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
byte[] getH2020DescriptionTemplateFile(); byte[] getH2020DescriptionTemplateFile();
byte[] getSupportiveMaterial(SupportiveMaterialFieldType type, String language);
byte[] getUserGuide(String language); byte[] getUserGuide(String language);
void setUserGuide(String language, byte[] payload); void setUserGuide(String language, byte[] payload);

View File

@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.StorageFilePermission; import eu.eudat.commons.enums.StorageFilePermission;
import eu.eudat.commons.enums.StorageType; import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.StorageFileEntity; import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.Description; import eu.eudat.model.Description;
@ -375,11 +376,35 @@ public class StorageFileServiceImpl implements StorageFileService {
return null; return null;
} }
} }
//endregion //endregion
//region materials //region materials
@Override
public byte[] getSupportiveMaterial(SupportiveMaterialFieldType type, String language) {
switch (type){
case Faq -> {
return this.getFaq(language);
}
case About -> {
return this.getAbout(language);
}
case Glossary -> {
return this.getGlossary(language);
}
case TermsOfService -> {
return this.getTermsOfService(language);
}
case UserGuide -> {
return this.getUserGuide(language);
}
default -> throw new InternalError("unknown type: " + type);
}
}
@Override @Override
public byte[] getUserGuide(String language) { public byte[] getUserGuide(String language) {
return this.getLocalized(this.config.getMaterialFiles().getUserGuide(), this.config.getMaterialFiles().getUserGuideNamePattern(), language); return this.getLocalized(this.config.getMaterialFiles().getUserGuide(), this.config.getMaterialFiles().getUserGuideNamePattern(), language);

View File

@ -1,6 +1,7 @@
package eu.eudat.service.supportivematerial; package eu.eudat.service.supportivematerial;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import gr.cite.tools.cache.CacheService; import gr.cite.tools.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,23 +17,17 @@ public class SupportiveMaterialCacheService extends CacheService<SupportiveMater
public SupportiveMaterialCacheValue() {} public SupportiveMaterialCacheValue() {}
public SupportiveMaterialCacheValue(String name, byte[] content) { public SupportiveMaterialCacheValue(String language, SupportiveMaterialFieldType type, byte[] content) {
this.name = name; this.language = language;
this.type = type;
this.content = content; this.content = content;
} }
private String name; private String language;
private SupportiveMaterialFieldType type;
private byte[] content; private byte[] content;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte[] getContent() { public byte[] getContent() {
return content; return content;
} }
@ -40,6 +35,22 @@ public class SupportiveMaterialCacheService extends CacheService<SupportiveMater
public void setContent(byte[] content) { public void setContent(byte[] content) {
this.content = content; this.content = content;
} }
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public SupportiveMaterialFieldType getType() {
return type;
}
public void setType(SupportiveMaterialFieldType type) {
this.type = type;
}
} }
@Autowired @Autowired
@ -52,14 +63,14 @@ public class SupportiveMaterialCacheService extends CacheService<SupportiveMater
public String keyOf(SupportiveMaterialCacheValue value) { public String keyOf(SupportiveMaterialCacheValue value) {
return this.buildKey(value.getName()); return this.buildKey(value.getLanguage(), value.getType());
} }
public String buildKey(String name) { public String buildKey(String language, SupportiveMaterialFieldType type) {
HashMap<String, String> keyParts = new HashMap<>(); HashMap<String, String> keyParts = new HashMap<>();
keyParts.put("$material$", name.toLowerCase(Locale.ROOT)); keyParts.put("$lang$", language.toLowerCase(Locale.ROOT));
//keyParts.put("$material_content$", new String(content, StandardCharsets.UTF_8).toLowerCase(Locale.ROOT)); keyParts.put("$type$", type.name().toLowerCase(Locale.ROOT));
return this.generateKey(keyParts); return this.generateKey(keyParts);
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.service.supportivematerial; package eu.eudat.service.supportivematerial;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.model.SupportiveMaterial; import eu.eudat.model.SupportiveMaterial;
import eu.eudat.model.persist.SupportiveMaterialPersist; import eu.eudat.model.persist.SupportiveMaterialPersist;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
@ -19,7 +20,7 @@ import org.springframework.http.ResponseEntity;
public interface SupportiveMaterialService { public interface SupportiveMaterialService {
ResponseEntity<byte[]> getResponseEntity(String lang, Stream<Path> paths) throws IOException; byte[] loadFromFile(String language, SupportiveMaterialFieldType type) throws IOException;
SupportiveMaterial persist(SupportiveMaterialPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException; SupportiveMaterial persist(SupportiveMaterialPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException;

View File

@ -3,6 +3,7 @@ package eu.eudat.service.supportivematerial;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.model.SupportiveMaterial; import eu.eudat.model.SupportiveMaterial;
@ -11,6 +12,7 @@ import eu.eudat.model.deleter.SupportiveMaterialDeleter;
import eu.eudat.model.persist.SupportiveMaterialPersist; import eu.eudat.model.persist.SupportiveMaterialPersist;
import eu.eudat.query.SupportiveMaterialQuery; import eu.eudat.query.SupportiveMaterialQuery;
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl; import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
import eu.eudat.service.storage.StorageFileService;
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;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
@ -57,11 +59,12 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
private final MessageSource messageSource; private final MessageSource messageSource;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final SupportiveMaterialCacheService supportiveMaterialCacheService; private final SupportiveMaterialCacheService supportiveMaterialCacheService;
private final StorageFileService storageFileService;
public SupportiveMaterialServiceImpl( public SupportiveMaterialServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory,
SupportiveMaterialCacheService supportiveMaterialCacheService SupportiveMaterialCacheService supportiveMaterialCacheService, StorageFileService storageFileService
) { ) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
@ -71,50 +74,23 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
this.messageSource = messageSource; this.messageSource = messageSource;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.supportiveMaterialCacheService = supportiveMaterialCacheService; this.supportiveMaterialCacheService = supportiveMaterialCacheService;
this.storageFileService = storageFileService;
} }
public ResponseEntity<byte[]> getResponseEntity(String lang, Stream<Path> paths) throws IOException { public byte[] loadFromFile(String language, SupportiveMaterialFieldType type) {
List<String> result = paths.filter(Files::isRegularFile) SupportiveMaterialCacheService.SupportiveMaterialCacheValue supportiveMaterialCacheItem = this.supportiveMaterialCacheService.lookup(this.supportiveMaterialCacheService.buildKey(language, type));
.map(Path::toString).collect(Collectors.toList());
String fileName = result.stream().filter(about -> about.contains("_" + lang)).findFirst().orElse(null);
if (fileName == null) {
fileName = result.stream().filter(about -> about.contains("_en")).findFirst().get();
}
SupportiveMaterialCacheService.SupportiveMaterialCacheValue supportiveMaterialCacheItem = this.supportiveMaterialCacheService.lookup(this.supportiveMaterialCacheService.buildKey(fileName));
if(supportiveMaterialCacheItem == null){ if(supportiveMaterialCacheItem == null){
InputStream is = new FileInputStream(fileName); byte[] content = this.storageFileService.getSupportiveMaterial(type, language);
if (content == null) throw new MyNotFoundException("Material not found");
// Path path = Paths.get(fileName); supportiveMaterialCacheItem = new SupportiveMaterialCacheService.SupportiveMaterialCacheValue(language, type, content);
byte[] content = new byte[is.available()];
is.read(content);
is.close();
supportiveMaterialCacheItem = new SupportiveMaterialCacheService.SupportiveMaterialCacheValue(fileName, content);
this.supportiveMaterialCacheService.put(supportiveMaterialCacheItem); this.supportiveMaterialCacheService.put(supportiveMaterialCacheItem);
} }
HttpHeaders responseHeaders = new HttpHeaders(); return supportiveMaterialCacheItem.getContent();
responseHeaders.setContentLength(supportiveMaterialCacheItem.getContent().length);
responseHeaders.setContentType(MediaType.TEXT_HTML);
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName);
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
return new ResponseEntity<>(supportiveMaterialCacheItem.getContent(), responseHeaders, HttpStatus.OK);
} }
// public void persist(SupportiveMaterialPersist model) throws IOException {
// this.supportiveMaterialCacheService.evict(model.getName());
// OutputStream os = new FileOutputStream(model.getName());
// os.write(model.getHtml().getBytes());
// os.close();
// }
public SupportiveMaterial persist(SupportiveMaterialPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{ public SupportiveMaterial persist(SupportiveMaterialPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields)); logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));

View File

@ -32,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction; import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
@ -55,7 +54,6 @@ public class FileTransformerService {
private final FileTransformerConfigurationCache fileTransformerConfigurationCache; private final FileTransformerConfigurationCache fileTransformerConfigurationCache;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final ConventionService conventionService; private final ConventionService conventionService;
private final Environment environment;
private final WebClient.Builder webClientBuilder; private final WebClient.Builder webClientBuilder;
private final EntityDoiService doiService; private final EntityDoiService doiService;
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
@ -66,13 +64,12 @@ public class FileTransformerService {
@Autowired @Autowired
public FileTransformerService(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, Environment environment, DmpQuery dmpQuery, EntityDoiQuery doiQuery, EntityDoiService doiService, ApplicationContext applicationContext, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, BuilderFactory builderFactory, StorageFileService storageFileService) { public FileTransformerService(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, DmpQuery dmpQuery, EntityDoiQuery doiQuery, EntityDoiService doiService, ApplicationContext applicationContext, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, BuilderFactory builderFactory, StorageFileService storageFileService) {
this.transformerProperties = transformerProperties; this.transformerProperties = transformerProperties;
this.tokenExchangeCacheService = tokenExchangeCacheService; this.tokenExchangeCacheService = tokenExchangeCacheService;
this.fileTransformerConfigurationCache = fileTransformerConfigurationCache; this.fileTransformerConfigurationCache = fileTransformerConfigurationCache;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.conventionService = conventionService; this.conventionService = conventionService;
this.environment = environment;
this.webClientBuilder = builder; this.webClientBuilder = builder;
this.doiService = doiService; this.doiService = doiService;
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
@ -142,11 +139,7 @@ public class FileTransformerService {
FileEnvelope fileEnvelope = repository.exportDmp(dmpFileTransformerModel); FileEnvelope fileEnvelope = repository.exportDmp(dmpFileTransformerModel);
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope(); eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
byte[] data = storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer); byte[] data = storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
File temp = new File(environment.getProperty("path.path") + UUID.randomUUID()); result.setFile(data);
try (FileOutputStream fos = new FileOutputStream(temp)) {
fos.write(data);
}
result.setFile(temp);
result.setFilename(fileEnvelope.getFilename()); result.setFilename(fileEnvelope.getFilename());
return result; return result;
} }
@ -164,11 +157,7 @@ public class FileTransformerService {
FileEnvelope fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format); FileEnvelope fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope(); eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
byte[] data = this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer); byte[] data = this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
File temp = new File(environment.getProperty("path.path") + UUID.randomUUID()); result.setFile(data);
try (FileOutputStream fos = new FileOutputStream(temp)) {
fos.write(data);
}
result.setFile(temp);
result.setFilename(fileEnvelope.getFilename()); result.setFilename(fileEnvelope.getFilename());
return result; return result;
} }

View File

@ -57,7 +57,7 @@ public class FileTransformerController {
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(requestModel.getId(), requestModel.getFormat()); FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(requestModel.getId(), requestModel.getFormat());
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename()); headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath()); byte[] data = fileEnvelope.getFile();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<>(data, headers, HttpStatus.OK); return new ResponseEntity<>(data, headers, HttpStatus.OK);
} }
@ -69,7 +69,7 @@ public class FileTransformerController {
FileEnvelope fileEnvelope = this.fileTransformerService.exportDescription(requestModel.getId(), requestModel.getFormat()); FileEnvelope fileEnvelope = this.fileTransformerService.exportDescription(requestModel.getId(), requestModel.getFormat());
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename()); headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath()); byte[] data = fileEnvelope.getFile();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<>(data, headers, HttpStatus.OK); return new ResponseEntity<>(data, headers, HttpStatus.OK);
} }

View File

@ -1,8 +1,12 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.tdunning.math.stats.Sort;
import eu.eudat.audit.AuditableAction; import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.service.storage.StorageFileService;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.validation.ValidationFilterAnnotation; import gr.cite.tools.validation.ValidationFilterAnnotation;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.model.SupportiveMaterial; import eu.eudat.model.SupportiveMaterial;
@ -30,8 +34,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.env.Environment; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -39,11 +44,7 @@ import javax.management.InvalidApplicationException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*; import java.util.*;
import java.util.stream.Stream;
@RestController @RestController
@RequestMapping(path = {"/api/supportive-material"}) @RequestMapping(path = {"/api/supportive-material"})
@ -51,7 +52,6 @@ public class SupportiveMaterialController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class));
private Environment environment;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@ -65,20 +65,16 @@ public class SupportiveMaterialController {
private final SupportiveMaterialService supportiveMaterialService; private final SupportiveMaterialService supportiveMaterialService;
private final AuthorizationService authorizationService;
@Autowired @Autowired
public SupportiveMaterialController(Environment environment, SupportiveMaterialService supportiveMaterialService, BuilderFactory builderFactory, public SupportiveMaterialController(SupportiveMaterialService supportiveMaterialService, BuilderFactory builderFactory,
AuditService auditService, CensorFactory censorFactory, QueryFactory queryFactory, MessageSource messageSource, AuditService auditService, CensorFactory censorFactory, QueryFactory queryFactory, MessageSource messageSource) {
AuthorizationService authorizationService) {
this.environment = environment;
this.supportiveMaterialService = supportiveMaterialService; this.supportiveMaterialService = supportiveMaterialService;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.auditService = auditService; this.auditService = auditService;
this.censorFactory = censorFactory; this.censorFactory = censorFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.messageSource = messageSource; this.messageSource = messageSource;
this.authorizationService = authorizationService;
} }
@PostMapping("query") @PostMapping("query")
@ -94,7 +90,7 @@ public class SupportiveMaterialController {
this.auditService.track(AuditableAction.SupportiveMaterial_Query, "lookup", lookup); this.auditService.track(AuditableAction.SupportiveMaterial_Query, "lookup", lookup);
return new QueryResult(models, count); return new QueryResult<SupportiveMaterial>(models, count);
} }
@GetMapping("{id}") @GetMapping("{id}")
@ -116,21 +112,41 @@ public class SupportiveMaterialController {
return model; return model;
} }
@PostMapping("public") @GetMapping("get-payload/{type}/{language}")
public ResponseEntity<byte[]> queryPublic(@RequestBody SupportiveMaterialLookup lookup) throws IOException { public ResponseEntity<byte[]> getPayload(@PathVariable("type") Short type, @PathVariable("type") String language) throws IOException {
logger.debug("querying {}", SupportiveMaterial.class.getSimpleName()); logger.debug("querying {}", SupportiveMaterial.class.getSimpleName());
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(lookup.getProject(), null);
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic); SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).types(SupportiveMaterialFieldType.of(type)).languageCodes(language).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
List<SupportiveMaterialEntity> data = query.collectAs(lookup.getProject()); List<SupportiveMaterialEntity> data = query.collectAs(new BaseFieldSet().ensure(SupportiveMaterial._id).ensure(SupportiveMaterial._payload));
if (data.size() == 1) { byte[] content;
return new ResponseEntity<>(data.get(0).getPayload().getBytes(), HttpStatus.OK); if (data.size() == 1) content = data.getFirst().getPayload().getBytes();
} else content = this.supportiveMaterialService.loadFromFile(language, SupportiveMaterialFieldType.of(type));
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty(lookup.getTypes().stream().toList().get(0).name().toLowerCase() + ".path"))))) { HttpHeaders responseHeaders = new HttpHeaders();
return this.supportiveMaterialService.getResponseEntity(lookup.getLanguageCodes().get(0), paths); responseHeaders.setContentLength(content.length);
} responseHeaders.setContentType(MediaType.TEXT_HTML);
responseHeaders.set("Content-Disposition", "attachment;filename=" + SupportiveMaterialFieldType.of(type).name().toLowerCase(Locale.ROOT) + "_" + language + "html");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
@GetMapping("public/get-payload/{type}/{language}")
public ResponseEntity<byte[]> getPayloadPublic(@PathVariable("type") Short type, @PathVariable("type") String language) throws IOException {
logger.debug("querying {}", SupportiveMaterial.class.getSimpleName());
byte[] content = this.supportiveMaterialService.loadFromFile(language, SupportiveMaterialFieldType.of(type));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(content.length);
responseHeaders.setContentType(MediaType.TEXT_HTML);
responseHeaders.set("Content-Disposition", "attachment;filename=" + SupportiveMaterialFieldType.of(type).name().toLowerCase(Locale.ROOT) + "_" + language + "html");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
} }
@PostMapping("persist") @PostMapping("persist")

View File

@ -1,133 +0,0 @@
dmp.domain = http://localhost:8080
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=jdbc:postgresql://dmp-db:5432/dmptool
database.username=dmptool
database.password=CHANGEME
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = opendmp-elastic
elasticsearch.port = 9200
elasticsearch.username=elastic
elasticsearch.password=
elasticsearch.index=dmps
elasticsearch.usingssl=false
elasticsearch.certPath=
elasticsearch.certKey=
elasticsearch.innerHitsSize=100
####################ELK OVERRIDES CONFIGURATIONS##########
#http-logger.server-address = http://logstash:31311
####################PDF OVERRIDES CONFIGURATIONS##########
pdf.converter.url=http://opendmp-pdf:3000/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=externalUrls/ExternalUrls.xml
configuration.h2020template=documents/h2020.docx
configuration.h2020datasettemplate=documents/h2020_dataset.docx
configuration.configurable_login_providers=configurableLoginProviders.json
configuration.pid_links=pidLinks.json
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
email.invite=classpath:templates/email/email.html
email.confirmation=classpath:templates/email/emailConfirmation.html
email.merge=classpath:templates/email/emailMergeConfirmation.html
email.unlink=classpath:templates/email/emailUnlinkConfirmation.html
email.dataset.template=classpath:templates/email/emailAdmin.html
####################INVITATION MAIL CONFIGURATIONS##############
####################GENERIC MAIL CONFIGURATIONS#################
mail.subject=Invitation to DMP Plan {dmpname}
mail.from=opendmp-dev@cite.gr
####################DATASET TEMPLATE MAIL CONFIGURATIONS#################
admin.mail.subject=You have been invited to the Dataset Template {templateName}
####################SPRING MAIL CONFIGURATIONS#################
spring.mail.default-encoding=UTF-8
spring.mail.host=
spring.mail.username=
spring.mail.password=
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=true
#############FACEBOOK LOGIN CONFIGURATIONS#########
facebook.login.clientId=
facebook.login.clientSecret=
facebook.login.namespace=
#############GOOGLE LOGIN CONFIGURATIONS#########
google.login.clientId=
#############LINKEDIN LOGIN CONFIGURATIONS#########
linkedin.login.clientId=
linkedin.login.clientSecret=
linkedin.login.redirect_uri=http://localhost:8080/login/linkedin
linkedin.login.user_info_url=https://api.linkedin.com/v2/me
linkedin.login.user_email=https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
linkedin.login.access_token_url=https://www.linkedin.com/uas/oauth2/accessToken
#############TWITTER LOGIN CONFIGURATIONS#########
twitter.login.clientId=
twitter.login.clientSecret=
twitter.login.redirect_uri=http://localhost:8080/login/twitter
#############B2 ACCESS CONFIGURATIONS#########
b2access.externallogin.user_info_url=https://b2access-integration.fz-juelich.de:443/oauth2/userinfo
b2access.externallogin.access_token_url=https://b2access-integration.fz-juelich.de:443/oauth2/token
b2access.externallogin.redirect_uri=http://localhost:8080/api/oauth/authorized/b2access
b2access.externallogin.clientid=
b2access.externallogin.clientSecret=
#############ORCID CONFIGURATIONS#########
orcid.login.client_id=
orcid.login.client_secret=
orcid.login.access_token_url=https://orcid.org/oauth/token
orcid.login.redirect_uri=http://localhost:8080/login/external/orcid
#############OPENAIRE CONFIGURATIONS#########
openaire.login.client_id=
openaire.login.client_secret=
openaire.login.access_token_url=https://aai.openaire.eu/oidc/token
openaire.login.redirect_uri=http://localhost:8080/login/openaire
openaire.login.user_info_url=https://aai.openaire.eu/oidc/userinfo
#############CONFIRMATION EMAIL CONFIGURATIONS#########
conf_email.expiration_time_seconds=14400
conf_email.subject=OpenDMP email confirmation
#############ZENODO CONFIGURATIONS#########
zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token
zenodo.login.client_id=
zenodo.login.client_secret=
zenodo.login.redirect_uri=http://localhost:8080/login/external/zenodo
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
logging.config=classpath:logging/logback-${spring.profiles.active}.xml
language.path=i18n/
##########################MISC##########################################
#############USER GUIDE#########
userguide.path=user-guide/
#############NOTIFICATION#########
notification.rateInterval=30000
notification.maxRetries=10
notification.modified.subject=[OpenDMP] The {name} has been modified
notification.publish.subject=[OpenDMP] The {name} has been published
notification.finalised.subject=[OpenDMP] The {name} has been finalised
notification.modifiedFinalised.subject=[OpenDMP] The {name} has been modified and finalised
#############TEMP#########
temp.temp=tmp/
file.storage=storage/
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
#############PROMETHEUS#########
endpoints.prometheus.sensitive: false

View File

@ -1,102 +0,0 @@
dmp.domain = https://opendmp.eu
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=jdbc:postgresql://dmp-db:5432/dmptool
database.username=dmptool
database.password=CHANGEME
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = tags-elastic-search
elasticsearch.port = 9200
elasticsearch.username=elastic
elasticsearch.password=
elasticsearch.index=dmps
elasticsearch.innerHitsSize=100
####################PDF OVERRIDES CONFIGURATIONS##########
pdf.converter.url=http://docsbox-web/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=externalUrls/ExternalUrls.xml
configuration.h2020template=documents/h2020.docx
configuration.h2020datasettemplate=documents/h2020_dataset.docx
configuration.configurable_login_providers=ConfigurableLoginProviders.json
configuration.doi_funder=DOI_Funder.json
configuration.pid_links=pidLinks.json
####################SPRING MAIL CONFIGURATIONS#################
spring.mail.default-encoding=UTF-8
spring.mail.host=
spring.mail.username=
spring.mail.password=
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=true
#############FACEBOOK LOGIN CONFIGURATIONS#########
facebook.login.clientId=
facebook.login.clientSecret=
facebook.login.namespace=opendmp
#############GOOGLE LOGIN CONFIGURATIONS#########
google.login.clientId=
#############LINKEDIN LOGIN CONFIGURATIONS#########
linkedin.login.clientId=
linkedin.login.clientSecret=
linkedin.login.redirect_uri=https://opendmp.eu/login/linkedin
linkedin.login.user_info_url=https://api.linkedin.com/v2/me
linkedin.login.user_email=https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
linkedin.login.access_token_url=https://www.linkedin.com/uas/oauth2/accessToken
#############TWITTER LOGIN CONFIGURATIONS#########
twitter.login.clientId=
twitter.login.clientSecret=
twitter.login.redirect_uri=https://opendmp.eu/login/twitter
#############B2 ACCESS CONFIGURATIONS#########
b2access.externallogin.user_info_url=https://b2access-integration.fz-juelich.de:443/oauth2/userinfo
b2access.externallogin.access_token_url=https://b2access-integration.fz-juelich.de:443/oauth2/token
b2access.externallogin.redirect_uri=https://opendmp.eu/api/oauth/authorized/b2access
b2access.externallogin.clientid=
b2access.externallogin.clientSecret=
#############ORCID CONFIGURATIONS#########
orcid.login.client_id=
orcid.login.client_secret=
orcid.login.access_token_url=https://orcid.org/oauth/token
orcid.login.redirect_uri=https://opendmp.eu/login/external/orcid
#############OPENAIRE CONFIGURATIONS#########
openaire.login.client_id=
openaire.login.client_secret=
openaire.login.access_token_url=
openaire.login.redirect_uri=
openaire.login.user_info_url=
#############SPRING DATASOURCE CONFIGURATIONS#########
spring.datasource.maxIdle: 10
spring.datasource.max-active: 70
spring.datasource.max-wait: 10000
spring.datasource.validationQuery: select 1
spring.datasource.removeAbandoned: true
spring.datasource.removeAbandonedTimeout: 1
spring.datasource.logAbandoned: true
spring.datasource.testOnBorrow: true
spring.datasource.testOnConnect: false
spring.datasource.testWhileIdle: false
#############CONFIRMATION EMAIL CONFIGURATIONS#########
conf_email.expiration_time_seconds=14400
conf_email.subject=OpenDMP email confirmation
#############ZENODO CONFIGURATIONS#########
zenodo.url=https://zenodo.org/api/
zenodo.access_token=
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
language.path=i18n/

View File

@ -64,7 +64,7 @@ cache:
keyPattern: user_by_subject_$subject$:v0 keyPattern: user_by_subject_$subject$:v0
supportiveMaterial: supportiveMaterial:
name: supportiveMaterial name: supportiveMaterial
keyPattern: supportive_material_$material$:v0 keyPattern: supportive_material_$type$_$lang$:v0
Reference: Reference:
name: Reference name: Reference
keyPattern: reference_$type$_$criteria$:v0 keyPattern: reference_$type$_$criteria$:v0

View File

@ -2,7 +2,7 @@ web:
security: security:
enabled: true enabled: true
authorized-endpoints: [ api ] authorized-endpoints: [ api ]
allowed-endpoints: [ api/public, api/description/public, api/language/public, api/contact-support/public, api/dashboard/public ] allowed-endpoints: [ api/public, api/description/public, /api/supportive-material/public, api/language/public, api/contact-support/public, api/dashboard/public ]
idp: idp:
api-key: api-key:
enabled: false enabled: false

View File

@ -10,20 +10,43 @@ import { catchError } from "rxjs/operators";
import { nameof } from "ts-simple-nameof"; import { nameof } from "ts-simple-nameof";
import { ConfigurationService } from "../configuration/configuration.service"; import { ConfigurationService } from "../configuration/configuration.service";
import { BaseHttpV2Service } from "../http/base-http-v2.service"; import { BaseHttpV2Service } from "../http/base-http-v2.service";
import { SupportiveMaterialFieldType } from "@app/core/common/enum/supportive-material-field-type";
import { BaseHttpParams } from "@common/http/base-http-params";
import { InterceptorType } from "@common/http/interceptors/interceptor-type";
import { AuthService } from "../auth/auth.service";
@Injectable() @Injectable()
export class SupportiveMaterialService { export class SupportiveMaterialService {
constructor( constructor(
private http: BaseHttpV2Service, private http: BaseHttpV2Service,
private configurationService: ConfigurationService private configurationService: ConfigurationService,
private authService: AuthService
) { ) {
} }
private get apiBase(): string { return `${this.configurationService.server}supportive-material`; } private get apiBase(): string { return `${this.configurationService.server}supportive-material`; }
queryPublic(q: SupportiveMaterialLookup): Observable<HttpResponse<Blob>> { getPayload(type: SupportiveMaterialFieldType, language: string): Observable<HttpResponse<Blob>> {
return this.http.post<HttpResponse<Blob>>(`${this.apiBase}/public`, q, { responseType: 'blob', observe: 'response' }); if (this.authService.isLoggedIn() && this.authService.currentAccountIsAuthenticated() ) {
return this.getPayloadLogin(type, language);
} else {
return this.getPayloadPublic(type, language);
}
}
getPayloadLogin(type: SupportiveMaterialFieldType, language: string): Observable<HttpResponse<Blob>> {
const url = `${this.apiBase}/get-payload/${type}/${language}`;
return this.http.get<HttpResponse<Blob>>(url, { responseType: 'blob', observe: 'response' });
}
getPayloadPublic(type: SupportiveMaterialFieldType, language: string): Observable<HttpResponse<Blob>> {
const url = `${this.apiBase}/public/get-payload/${type}/${language}`;
const params = new BaseHttpParams();
params.interceptorContext = {
excludedInterceptors: [InterceptorType.AuthToken]
};
return this.http.get(url, { params: params, responseType: 'blob', observe: 'response' });
} }
query(q: SupportiveMaterialLookup): Observable<QueryResult<SupportiveMaterial>> { query(q: SupportiveMaterialLookup): Observable<QueryResult<SupportiveMaterial>> {

View File

@ -25,7 +25,7 @@ export class AboutComponent extends BaseComponent implements OnInit {
private languageService: LanguageService, private languageService: LanguageService,
private matomoService: MatomoService, private matomoService: MatomoService,
private translate: TranslateService, private translate: TranslateService,
private router: Router private router: Router,
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
@ -33,11 +33,8 @@ export class AboutComponent extends BaseComponent implements OnInit {
this.translate.onLangChange.subscribe((event: LangChangeEvent) => { this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/about'])); this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/about']));
}); });
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.About];
this.supportiveMaterialService.queryPublic(lookup) this.supportiveMaterialService.getPayload(SupportiveMaterialFieldType.About, this.languageService.getCurrentLanguage())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' }); const blob = new Blob([response.body], { type: 'text/html' });

View File

@ -28,11 +28,8 @@ export class FaqContentComponent extends BaseComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.matomoService.trackPageView('FAQ'); this.matomoService.trackPageView('FAQ');
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.Faq];
this.supportiveMaterialService.queryPublic(lookup) this.supportiveMaterialService.getPayload(SupportiveMaterialFieldType.Faq, this.languageService.getCurrentLanguage())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' }); const blob = new Blob([response.body], { type: 'text/html' });

View File

@ -36,11 +36,7 @@ export class GlossaryContentComponent extends BaseComponent implements OnInit {
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/glossary'])); this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/glossary']));
}); });
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup(); this.supportiveMaterialService.getPayload(SupportiveMaterialFieldType.Glossary, this.languageService.getCurrentLanguage())
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.Glossary];
this.supportiveMaterialService.queryPublic(lookup)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' }); const blob = new Blob([response.body], { type: 'text/html' });

View File

@ -33,11 +33,8 @@ export class TermsComponent extends BaseComponent implements OnInit {
this.translate.onLangChange.subscribe((event: LangChangeEvent) => { this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/terms-and-conditions'])); this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/terms-and-conditions']));
}); });
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.TermsOfService];
this.supportiveMaterialService.queryPublic(lookup) this.supportiveMaterialService.getPayload(SupportiveMaterialFieldType.TermsOfService, this.languageService.getCurrentLanguage())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' }); const blob = new Blob([response.body], { type: 'text/html' });

View File

@ -51,11 +51,7 @@ export class UserGuideContentComponent extends BaseComponent implements OnInit {
this.translate.onLangChange.subscribe((event: LangChangeEvent) => { this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/user-guide'])); this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/user-guide']));
}); });
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup(); this.supportiveMaterialService.getPayload(SupportiveMaterialFieldType.UserGuide, this.languageService.getCurrentLanguage())
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.UserGuide];
this.supportiveMaterialService.queryPublic(lookup)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' }); const blob = new Blob([response.body], { type: 'text/html' });