Compare commits
34 Commits
|
@ -1,2 +1,3 @@
|
|||
.idea/
|
||||
target/
|
||||
logs/
|
||||
|
|
|
@ -5,9 +5,9 @@ ARG MAVEN_ACCOUNT_USR
|
|||
ARG MAVEN_ACCOUNT_PSW
|
||||
ARG REVISION
|
||||
ARG PROFILE
|
||||
ARG DEV_PROFILE_URL
|
||||
ENV server_username=$MAVEN_ACCOUNT_USR
|
||||
ENV server_password=$MAVEN_ACCOUNT_PSW
|
||||
ARG CITE_MAVEN_REPO_URL
|
||||
|
||||
COPY pom.xml /build/
|
||||
COPY core /build/core/
|
||||
|
@ -19,9 +19,9 @@ RUN rm -f /build/web/src/main/resources/config/*-dev.yml
|
|||
|
||||
WORKDIR /build/
|
||||
|
||||
RUN mvn -Drevision=${REVISION} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} dependency:go-offline
|
||||
# Build project
|
||||
RUN mvn -Drevision=${REVISION} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} clean package
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} clean
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} install
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} package
|
||||
|
||||
######################################## Run Stage ########################################
|
||||
FROM eclipse-temurin:21
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
####################################### Build stage #######################################
|
||||
FROM maven:3.9-eclipse-temurin-21-alpine
|
||||
|
||||
ARG MAVEN_ACCOUNT_USR
|
||||
ARG MAVEN_ACCOUNT_PSW
|
||||
ARG REVISION
|
||||
ARG PROFILE
|
||||
ARG ORACLE_URL
|
||||
ARG ORACLE_TOKEN
|
||||
ENV server_username=$MAVEN_ACCOUNT_USR
|
||||
ENV server_password=$MAVEN_ACCOUNT_PSW
|
||||
ARG CITE_MAVEN_REPO_URL
|
||||
|
||||
COPY pom.xml /build/
|
||||
COPY core /build/core/
|
||||
COPY web /build/web/
|
||||
COPY settings.xml /root/.m2/settings.xml
|
||||
RUN rm -f /build/web/src/main/resources/config/*-dev.yml
|
||||
RUN rm -f /build/web/src/main/resources/logging/*.xml
|
||||
|
||||
COPY oracle.local.cite.gr.crt $JAVA_HOME/conf/security
|
||||
RUN cd "$JAVA_HOME"/conf/security && keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias oraclecert -file oracle.local.cite.gr.crt
|
||||
|
||||
WORKDIR /build/
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} clean
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} install
|
||||
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} package
|
||||
RUN mvn sonar:sonar -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} -Dsonar.projectKey=OpenDMP:file-transformer-docx -Dsonar.login=${ORACLE_TOKEN} -Dsonar.host.url=${ORACLE_URL} -Dsonar.projectName='OpenDMP file-transformer-docx'
|
17
core/pom.xml
17
core/pom.xml
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-document-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
@ -21,11 +21,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>file-transformer-base</artifactId>
|
||||
<version>0.0.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -55,6 +50,16 @@
|
|||
<artifactId>jsoup</artifactId>
|
||||
<version>1.17.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
<artifactId>logging</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
<artifactId>exceptions</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package eu.eudat.file.transformer.service.pdf;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class PdfServiceImpl implements PdfService {
|
||||
|
||||
private final PdfServiceProperties pdfServiceProperties;
|
||||
|
||||
public PdfServiceImpl(PdfServiceProperties pdfServiceProperties) {
|
||||
this.pdfServiceProperties = pdfServiceProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] convertToPDF(byte[] file) {
|
||||
WebClient webClient = WebClient.builder().baseUrl(pdfServiceProperties.getUrl()).build();
|
||||
MultipartBodyBuilder builder = new MultipartBodyBuilder();
|
||||
builder.part("files", new ByteArrayResource(file)).filename(UUID.randomUUID() + ".docx");
|
||||
|
||||
return webClient.post().uri("forms/libreoffice/convert")
|
||||
.headers(httpHeaders -> {
|
||||
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
httpHeaders.add("Content-disposition", "attachment; filename=" + UUID.randomUUID() + ".pdf");
|
||||
httpHeaders.add("Content-type", "application/pdf");
|
||||
})
|
||||
.body(BodyInserters.fromMultipartData(builder.build()))
|
||||
.retrieve().bodyToMono(byte[].class).block();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package eu.eudat.file.transformer.service.pdf;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||
|
||||
@ConfigurationProperties(prefix = "pdf.converter")
|
||||
public class PdfServiceProperties {
|
||||
private final String url;
|
||||
|
||||
@ConstructorBinding
|
||||
public PdfServiceProperties(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
|||
package org.opencdmp.filetransformer.docx.audit;
|
||||
|
||||
|
||||
import gr.cite.tools.logging.EventId;
|
||||
|
||||
public class AuditableAction {
|
||||
|
||||
public static final EventId FileTransformer_ExportDmp = new EventId(1000, "FileTransformer_ExportDmp");
|
||||
public static final EventId FileTransformer_ExportDescription = new EventId(1001, "FileTransformer_ExportDescription");
|
||||
public static final EventId FileTransformer_ImportFileToDmp = new EventId(1002, "FileTransformer_ImportFileToDmp");
|
||||
public static final EventId FileTransformer_ImportFileToDescription = new EventId(1003, "FileTransformer_ImportFileToDescription");
|
||||
public static final EventId FileTransformer_GetSupportedFormats = new EventId(1004, "FileTransformer_GetSupportedFormats");
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.model;
|
||||
package org.opencdmp.filetransformer.docx.model;
|
||||
|
||||
public class PidLink {
|
||||
private String pid;
|
|
@ -1,9 +1,9 @@
|
|||
package eu.eudat.file.transformer.model.enums;
|
||||
package org.opencdmp.filetransformer.docx.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import eu.eudat.commonmodels.enums.EnumUtils;
|
||||
import eu.eudat.commonmodels.enums.EnumValueProvider;
|
||||
import org.opencdmp.commonmodels.enums.EnumUtils;
|
||||
import org.opencdmp.commonmodels.enums.EnumValueProvider;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package eu.eudat.file.transformer.model.enums;
|
||||
package org.opencdmp.filetransformer.docx.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import eu.eudat.commonmodels.enums.EnumUtils;
|
||||
import eu.eudat.commonmodels.enums.EnumValueProvider;
|
||||
import org.opencdmp.commonmodels.enums.EnumUtils;
|
||||
import org.opencdmp.commonmodels.enums.EnumValueProvider;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public enum ParagraphStyle implements EnumValueProvider<Integer> {
|
|||
|
||||
private final Integer value;
|
||||
|
||||
private ParagraphStyle(Integer value) {
|
||||
ParagraphStyle(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.model.interfaces;
|
||||
package org.opencdmp.filetransformer.docx.model.interfaces;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/27/2018.
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.pdf;
|
||||
package org.opencdmp.filetransformer.docx.service.pdf;
|
||||
|
||||
public interface PdfService {
|
||||
byte[] convertToPDF(byte[] file);
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.pdf;
|
||||
package org.opencdmp.filetransformer.docx.service.pdf;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -0,0 +1,71 @@
|
|||
package org.opencdmp.filetransformer.docx.service.pdf;
|
||||
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class PdfServiceImpl implements PdfService {
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PdfServiceImpl.class));
|
||||
|
||||
private final PdfServiceProperties pdfServiceProperties;
|
||||
|
||||
public PdfServiceImpl(PdfServiceProperties pdfServiceProperties) {
|
||||
this.pdfServiceProperties = pdfServiceProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] convertToPDF(byte[] file) {
|
||||
WebClient webClient = WebClient.builder().filters(exchangeFilterFunctions -> {
|
||||
exchangeFilterFunctions.add(logRequest());
|
||||
exchangeFilterFunctions.add(logResponse());
|
||||
}).baseUrl(pdfServiceProperties.getUrl()) .codecs(codecs -> codecs
|
||||
.defaultCodecs()
|
||||
.maxInMemorySize(this.pdfServiceProperties.getMaxInMemorySizeInBytes())
|
||||
).build();
|
||||
MultipartBodyBuilder builder = new MultipartBodyBuilder();
|
||||
builder.part("files", new ByteArrayResource(file)).filename(UUID.randomUUID() + ".docx");
|
||||
|
||||
return webClient.post().uri("forms/libreoffice/convert")
|
||||
.headers(httpHeaders -> {
|
||||
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
httpHeaders.add("Content-disposition", "attachment; filename=" + UUID.randomUUID() + ".pdf");
|
||||
httpHeaders.add("Content-type", "application/pdf");
|
||||
})
|
||||
.body(BodyInserters.fromMultipartData(builder.build()))
|
||||
.retrieve().bodyToMono(byte[].class).block();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static ExchangeFilterFunction logRequest() {
|
||||
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
|
||||
logger.debug(new MapLogEntry("Request").And("method", clientRequest.method().toString()).And("url", clientRequest.url()));
|
||||
return Mono.just(clientRequest);
|
||||
});
|
||||
}
|
||||
|
||||
private static ExchangeFilterFunction logResponse() {
|
||||
return ExchangeFilterFunction.ofResponseProcessor(response -> {
|
||||
if (response.statusCode().isError()) {
|
||||
return response.mutate().build().bodyToMono(String.class)
|
||||
.flatMap(body -> {
|
||||
logger.error(new MapLogEntry("Response").And("method", response.request().getMethod().toString()).And("url", response.request().getURI()).And("status", response.statusCode()).And("body", body));
|
||||
return Mono.just(response);
|
||||
});
|
||||
}
|
||||
return Mono.just(response);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.opencdmp.filetransformer.docx.service.pdf;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||
|
||||
@ConfigurationProperties(prefix = "pdf.converter")
|
||||
public class PdfServiceProperties {
|
||||
private String url;
|
||||
private int maxInMemorySizeInBytes;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public int getMaxInMemorySizeInBytes() {
|
||||
return maxInMemorySizeInBytes;
|
||||
}
|
||||
|
||||
public void setMaxInMemorySizeInBytes(int maxInMemorySizeInBytes) {
|
||||
this.maxInMemorySizeInBytes = maxInMemorySizeInBytes;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.file.transformer.service.pid;
|
||||
package org.opencdmp.filetransformer.docx.service.pid;
|
||||
|
||||
import eu.eudat.file.transformer.model.PidLink;
|
||||
import org.opencdmp.filetransformer.docx.model.PidLink;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package eu.eudat.file.transformer.service.pid;
|
||||
package org.opencdmp.filetransformer.docx.service.pid;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.file.transformer.service.wordfiletransformer.WordFileTransformerServiceProperties;
|
||||
import eu.eudat.file.transformer.model.PidLink;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.WordFileTransformerServiceProperties;
|
||||
import org.opencdmp.filetransformer.docx.model.PidLink;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -13,7 +14,7 @@ import java.util.List;
|
|||
|
||||
@Component
|
||||
public class PidServiceImpl implements PidService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PidServiceImpl.class);
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PidServiceImpl.class));
|
||||
private final WordFileTransformerServiceProperties properties;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private List<PidLink> pidLinks = null;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.storage;
|
||||
package org.opencdmp.filetransformer.docx.service.storage;
|
||||
|
||||
public interface FileStorageService {
|
||||
String storeFile(byte[] data);
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.storage;
|
||||
package org.opencdmp.filetransformer.docx.service.storage;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.file.transformer.service.storage;
|
||||
package org.opencdmp.filetransformer.docx.service.storage;
|
||||
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.WordFileTransformerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,7 +18,7 @@ import java.util.UUID;
|
|||
|
||||
@Service
|
||||
public class FileStorageServiceImpl implements FileStorageService {
|
||||
private final static Logger logger = LoggerFactory.getLogger(FileStorageServiceImpl.class);
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(WordFileTransformerService.class));
|
||||
|
||||
private final FileStorageServiceProperties properties;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.storage;
|
||||
package org.opencdmp.filetransformer.docx.service.storage;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
|
@ -1,62 +1,77 @@
|
|||
package eu.eudat.file.transformer.service.wordfiletransformer;
|
||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer;
|
||||
|
||||
import eu.eudat.commonmodels.enums.DescriptionStatus;
|
||||
import eu.eudat.commonmodels.enums.DmpAccessType;
|
||||
import eu.eudat.commonmodels.enums.DmpStatus;
|
||||
import eu.eudat.commonmodels.models.dmp.DmpBlueprintValueModel;
|
||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||
import eu.eudat.commonmodels.models.dmpblueprint.*;
|
||||
import eu.eudat.commonmodels.models.dmpreference.DmpReferenceModel;
|
||||
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
||||
import eu.eudat.file.transformer.interfaces.FileTransformerClient;
|
||||
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
|
||||
import eu.eudat.file.transformer.model.enums.FileFormats;
|
||||
import eu.eudat.file.transformer.models.misc.FileFormat;
|
||||
import eu.eudat.file.transformer.service.pdf.PdfService;
|
||||
import eu.eudat.file.transformer.model.enums.ParagraphStyle;
|
||||
import eu.eudat.file.transformer.service.storage.FileStorageService;
|
||||
import eu.eudat.file.transformer.service.wordfiletransformer.word.WordBuilder;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.commonmodels.enums.*;
|
||||
import org.opencdmp.commonmodels.models.UserContactInfoModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||
import org.opencdmp.commonmodels.models.dmpblueprint.*;
|
||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
||||
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
||||
import org.opencdmp.filetransformerbase.enums.FileTransformerEntityType;
|
||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
||||
import org.opencdmp.filetransformer.docx.model.enums.FileFormats;
|
||||
import org.opencdmp.filetransformerbase.models.misc.FileFormat;
|
||||
import org.opencdmp.filetransformer.docx.service.pdf.PdfService;
|
||||
import org.opencdmp.filetransformer.docx.model.enums.ParagraphStyle;
|
||||
import org.opencdmp.filetransformer.docx.service.storage.FileStorageService;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility.VisibilityServiceImpl;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.word.WordBuilder;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.context.annotation.RequestScope;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@RequestScope
|
||||
public class WordFileTransformerService implements FileTransformerClient {
|
||||
private final static Logger logger = LoggerFactory.getLogger(WordFileTransformerService.class);
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(WordFileTransformerService.class));
|
||||
|
||||
private final static List<FileFormat> FILE_FORMATS = List.of(
|
||||
new FileFormat(FileFormats.PDF.getValue(), true, "fa-file-pdf-o"),
|
||||
new FileFormat(FileFormats.DOCX.getValue(), true, "fa-file-word-o"));
|
||||
|
||||
private final static List<FileTransformerEntityType> FILE_TRANSFORMER_ENTITY_TYPES = List.of(
|
||||
FileTransformerEntityType.Dmp, FileTransformerEntityType.Description);
|
||||
|
||||
private final WordFileTransformerServiceProperties wordFileTransformerServiceProperties;
|
||||
private final PdfService pdfService;
|
||||
private final WordBuilder wordBuilder;
|
||||
private final FileStorageService storageService;
|
||||
private final MessageSource messageSource;
|
||||
@Autowired
|
||||
public WordFileTransformerService(
|
||||
WordFileTransformerServiceProperties wordFileTransformerServiceProperties,
|
||||
PdfService pdfService, WordBuilder wordBuilder, FileStorageService storageService) {
|
||||
PdfService pdfService, WordBuilder wordBuilder, FileStorageService storageService, MessageSource messageSource) {
|
||||
this.wordFileTransformerServiceProperties = wordFileTransformerServiceProperties;
|
||||
this.pdfService = pdfService;
|
||||
this.wordBuilder = wordBuilder;
|
||||
this.storageService = storageService;
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +84,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
bytes = this.pdfService.convertToPDF(bytes);
|
||||
yield this.getDmpFileName(dmp, ".pdf");
|
||||
}
|
||||
default -> throw new InvalidApplicationException("Invalid type " + fileFormat);
|
||||
default -> throw new MyApplicationException("Invalid type " + fileFormat);
|
||||
};
|
||||
|
||||
FileEnvelopeModel wordFile = new FileEnvelopeModel();
|
||||
|
@ -93,7 +108,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
bytes = this.pdfService.convertToPDF(bytes);
|
||||
yield this.getDescriptionFileName(descriptionModel, ".pdf");
|
||||
}
|
||||
default -> throw new InvalidApplicationException("Invalid type " + fileFormat);
|
||||
default -> throw new MyApplicationException("Invalid type " + fileFormat);
|
||||
};
|
||||
|
||||
FileEnvelopeModel wordFile = new FileEnvelopeModel();
|
||||
|
@ -110,12 +125,12 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
|
||||
@Override
|
||||
public DmpModel importDmp(FileEnvelopeModel envelope) {
|
||||
throw new UnsupportedOperationException("import not supported");
|
||||
throw new MyApplicationException("import not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionModel importDescription(FileEnvelopeModel envelope) {
|
||||
throw new UnsupportedOperationException("import not supported");
|
||||
throw new MyApplicationException("import not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,6 +139,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
configuration.setFileTransformerId(this.wordFileTransformerServiceProperties.getTransformerId());
|
||||
configuration.setExportVariants(FILE_FORMATS);
|
||||
configuration.setImportVariants(null);
|
||||
configuration.setExportEntityTypes(FILE_TRANSFORMER_ENTITY_TYPES);
|
||||
configuration.setUseSharedStorage(this.wordFileTransformerServiceProperties.isUseSharedStorage());
|
||||
return configuration;
|
||||
}
|
||||
|
@ -142,11 +158,11 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
|
||||
|
||||
private byte[] buildDmpWordDocument(DmpModel dmpEntity) throws IOException, InvalidApplicationException {
|
||||
if (dmpEntity == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
||||
DmpBlueprintModel dmpBlueprintModel = dmpEntity.getDmpBlueprint();
|
||||
if (dmpBlueprintModel == null) throw new IllegalArgumentException("DmpBlueprint required");
|
||||
if (dmpBlueprintModel.getDefinition() == null) throw new IllegalArgumentException("DmpBlueprint Definition required");
|
||||
if (dmpBlueprintModel.getDefinition().getSections() == null) throw new IllegalArgumentException("DmpBlueprint Section required");
|
||||
if (dmpBlueprintModel == null) throw new MyApplicationException("DmpBlueprint required");
|
||||
if (dmpBlueprintModel.getDefinition() == null) throw new MyApplicationException("DmpBlueprint Definition required");
|
||||
if (dmpBlueprintModel.getDefinition().getSections() == null) throw new MyApplicationException("DmpBlueprint Section required");
|
||||
|
||||
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordDmpTemplate())));
|
||||
|
||||
|
@ -187,24 +203,8 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
private void buildDmpSection(DmpModel dmpEntity, SectionModel sectionModel, XWPFDocument document) throws InvalidApplicationException {
|
||||
this.wordBuilder.addParagraphContent("Section " + sectionModel.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
||||
XWPFParagraph sectionInfoParagraph = document.createParagraph();
|
||||
sectionInfoParagraph.setSpacingBetween(1.0);
|
||||
XWPFRun runSectionTitle = sectionInfoParagraph.createRun();
|
||||
runSectionTitle.setText("Title: ");
|
||||
runSectionTitle.setColor("000000");
|
||||
XWPFRun runSectionTitleText = sectionInfoParagraph.createRun();
|
||||
runSectionTitleText.setText(sectionModel.getLabel());
|
||||
runSectionTitleText.setColor("116a78");
|
||||
XWPFParagraph sectionDescriptionParagraph = document.createParagraph();
|
||||
XWPFRun runSectionDescription = sectionDescriptionParagraph.createRun();
|
||||
runSectionDescription.setText("Description: ");
|
||||
runSectionDescription.setColor("000000");
|
||||
XWPFRun runSectionDescriptionText = sectionDescriptionParagraph.createRun();
|
||||
runSectionDescriptionText.setText(sectionModel.getDescription());
|
||||
runSectionDescriptionText.setColor("116a78");
|
||||
this.wordBuilder.addParagraphContent(sectionModel.getOrdinal() + ". " + sectionModel.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
||||
|
||||
this.wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||
if (sectionModel.getFields() != null) {
|
||||
sectionModel.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
|
||||
for (FieldModel fieldModel : sectionModel.getFields()) {
|
||||
|
@ -215,7 +215,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
final boolean isFinalized = dmpEntity.getStatus() != null && dmpEntity.getStatus().equals(DmpStatus.Finalized);
|
||||
final boolean isPublic = dmpEntity.getPublicAfter() != null && dmpEntity.getPublicAfter().isAfter(Instant.now());
|
||||
|
||||
List<DescriptionModel> descriptions = dmpEntity.getDescriptions().stream()
|
||||
List<DescriptionModel> descriptions = dmpEntity.getDescriptions() == null ? new ArrayList<>() : dmpEntity.getDescriptions().stream()
|
||||
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
||||
.filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized)
|
||||
.filter(item -> item.getSectionId().equals(sectionModel.getId()))
|
||||
|
@ -227,20 +227,19 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
private void buildSectionDescriptions(XWPFDocument document, List<DescriptionModel> descriptions) {
|
||||
if (document == null) throw new IllegalArgumentException("Document required");
|
||||
if (descriptions == null) throw new IllegalArgumentException("Descriptions required");
|
||||
if (document == null) throw new MyApplicationException("Document required");
|
||||
if (descriptions == null) throw new MyApplicationException("Descriptions required");
|
||||
|
||||
List<DescriptionTemplateModel> descriptionTemplateModels = descriptions.stream().map(DescriptionModel::getDescriptionTemplate).toList();
|
||||
if (descriptionTemplateModels.isEmpty()) return;
|
||||
|
||||
this.wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||
this.wordBuilder.addParagraphContent("Description Templates", document, ParagraphStyle.HEADER4, BigInteger.ZERO, 0);
|
||||
for (DescriptionTemplateModel descriptionTemplateModelEntity : descriptionTemplateModels) {
|
||||
XWPFParagraph templateParagraph = document.createParagraph();
|
||||
XWPFRun runTemplateLabel = templateParagraph.createRun();
|
||||
runTemplateLabel.setText("• " + descriptionTemplateModelEntity.getLabel());
|
||||
runTemplateLabel.setColor("116a78");
|
||||
}
|
||||
wordBuilder.addParagraphContent("Descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||
// for (DescriptionTemplateModel descriptionTemplateModelEntity : descriptionTemplateModels) {
|
||||
// XWPFParagraph templateParagraph = document.createParagraph();
|
||||
// XWPFRun runTemplateLabel = templateParagraph.createRun();
|
||||
// runTemplateLabel.setText("• " + descriptionTemplateModelEntity.getLabel());
|
||||
// runTemplateLabel.setColor("116a78");
|
||||
// }
|
||||
|
||||
for (DescriptionModel descriptionModel : descriptions){
|
||||
buildSectionDescription(document, descriptionModel);
|
||||
|
@ -248,8 +247,8 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
private void buildSectionDescription(XWPFDocument document, DescriptionModel descriptionModel) {
|
||||
if (document == null) throw new IllegalArgumentException("Document required");
|
||||
if (descriptionModel == null) throw new IllegalArgumentException("DescriptionModel required");
|
||||
if (document == null) throw new MyApplicationException("Document required");
|
||||
if (descriptionModel == null) throw new MyApplicationException("DescriptionModel required");
|
||||
|
||||
DescriptionTemplateModel descriptionTemplateModelFileModel = descriptionModel.getDescriptionTemplate();
|
||||
|
||||
|
@ -258,43 +257,35 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
datasetDescriptionParagraph.setStyle("Heading4");
|
||||
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
||||
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
||||
datasetDescriptionRun.setText("Dataset Description");
|
||||
datasetDescriptionRun.setText(descriptionModel.getLabel());
|
||||
datasetDescriptionRun.setFontSize(15);
|
||||
|
||||
XWPFParagraph descriptionParagraph = document.createParagraph();
|
||||
wordBuilder.addParagraphContent(descriptionModel.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||
|
||||
// Custom style for the Dataset title.
|
||||
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
||||
datasetLabelParagraph.setSpacingBetween(1.0);
|
||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||
runDatasetTitle1.setText("Title: ");
|
||||
runDatasetTitle1.setColor("000000");
|
||||
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
||||
runDatasetTitle.setText(descriptionModel.getLabel());
|
||||
runDatasetTitle.setColor("116a78");
|
||||
|
||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
||||
runDatasetTemplate1.setText("Template: ");
|
||||
runDatasetTemplate1.setColor("000000");
|
||||
|
||||
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
||||
runDatasetTemplate.setText(descriptionTemplateModelFileModel != null ? descriptionTemplateModelFileModel.getLabel() : "");
|
||||
runDatasetTemplate.setColor("116a78");
|
||||
|
||||
|
||||
XWPFParagraph datasetDescParagraph = document.createParagraph();
|
||||
XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
|
||||
runDatasetDescription1.setText("Description: ");
|
||||
runDatasetDescription1.setText("Type: ");
|
||||
runDatasetDescription1.setColor("000000");
|
||||
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
||||
runDatasetDescription.setText(descriptionTemplateModelFileModel != null ? descriptionTemplateModelFileModel.getLabel() : "");
|
||||
runDatasetDescription.setText(descriptionTemplateModelFileModel != null && descriptionTemplateModelFileModel.getType() != null ? descriptionTemplateModelFileModel.getType().getName() : "");
|
||||
runDatasetDescription.setColor("116a78");
|
||||
|
||||
document.createParagraph();
|
||||
|
||||
|
||||
try {
|
||||
this.wordBuilder.build(document, descriptionModel.getDescriptionTemplate(), descriptionModel.getProperties());
|
||||
} catch (IOException e) {
|
||||
this.wordBuilder.build(document, descriptionModel.getDescriptionTemplate(), descriptionModel.getProperties(), new VisibilityServiceImpl(descriptionModel.getVisibilityStates()));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
// Page break at the end of the Dataset.
|
||||
|
@ -304,99 +295,95 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
|
||||
|
||||
private void buildDmpSectionField(DmpModel dmpEntity, XWPFDocument document, FieldModel fieldModel) throws InvalidApplicationException {
|
||||
if (fieldModel == null) throw new IllegalArgumentException("Field required");
|
||||
if (fieldModel.getCategory() == null) throw new IllegalArgumentException("Field is required" + fieldModel.getId() + " " + fieldModel.getLabel());
|
||||
if (fieldModel == null) throw new MyApplicationException("Field required");
|
||||
if (fieldModel.getCategory() == null) throw new MyApplicationException("Field is required" + fieldModel.getId() + " " + fieldModel.getLabel());
|
||||
switch (fieldModel.getCategory()){
|
||||
case System -> {
|
||||
buildDmpSectionSystemField(dmpEntity, document, (SystemFieldModel) fieldModel);
|
||||
}
|
||||
case Extra -> buildDmpSectionExtraField(dmpEntity, document, (ExtraFieldModel) fieldModel);
|
||||
case ReferenceType -> {
|
||||
buildDmpSectionFieldTitleDescription(document, fieldModel);
|
||||
buildDmpSectionReferenceTypeField(dmpEntity, document, (ReferenceTypeFieldModel) fieldModel);
|
||||
}
|
||||
default -> throw new InvalidApplicationException("Invalid type " + fieldModel.getCategory());
|
||||
default -> throw new MyApplicationException("Invalid type " + fieldModel.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
private void buildDmpSectionReferenceTypeField(DmpModel dmpEntity, XWPFDocument document, ReferenceTypeFieldModel referenceField) {
|
||||
if (referenceField == null) throw new IllegalArgumentException("ReferenceField required");
|
||||
if (dmpEntity == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (document == null) throw new IllegalArgumentException("Document required");
|
||||
if (referenceField.getReferenceType() == null) throw new IllegalArgumentException("ReferenceField type required");
|
||||
if (referenceField == null) throw new MyApplicationException("ReferenceField required");
|
||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
||||
if (document == null) throw new MyApplicationException("Document required");
|
||||
if (referenceField.getReferenceType() == null) throw new MyApplicationException("ReferenceField type required");
|
||||
if (referenceField.getReferenceType().getCode() == null && !referenceField.getReferenceType().getCode().isBlank()) throw new IllegalArgumentException("ReferenceField type code required");
|
||||
|
||||
XWPFParagraph systemFieldInput = document.createParagraph();
|
||||
systemFieldInput.setSpacingBetween(1.0);
|
||||
XWPFRun runInput = systemFieldInput.createRun();
|
||||
runInput.setText("Input: ");
|
||||
runInput.setColor("000000");
|
||||
|
||||
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
||||
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
|
||||
runSyStemFieldTitle.setText(this.getReferenceFieldLabel(referenceField) + ": ");
|
||||
runSyStemFieldTitle.setColor("000000");
|
||||
|
||||
List<ReferenceModel> referenceModels = this.getReferenceModelOfTypeCode(dmpEntity, referenceField.getReferenceType().getCode(), referenceField.getId());
|
||||
for (ReferenceModel reference : referenceModels) {
|
||||
XWPFRun runResearcher = systemFieldInput.createRun();
|
||||
runResearcher.setText("• " + reference.getLabel());
|
||||
XWPFRun runResearcher = systemFieldParagraph.createRun();
|
||||
if (this.wordFileTransformerServiceProperties.getResearcherReferenceCode().equalsIgnoreCase(referenceField.getReferenceType().getCode()) ||
|
||||
this.wordFileTransformerServiceProperties.getOrganizationReferenceCode().equalsIgnoreCase(referenceField.getReferenceType().getCode())
|
||||
) runResearcher.addBreak();
|
||||
if (this.wordFileTransformerServiceProperties.getLicenceReferenceCode().equalsIgnoreCase(referenceField.getReferenceType().getCode())) runResearcher.setText(reference.getReference());
|
||||
else runResearcher.setText(reference.getLabel());
|
||||
runResearcher.setColor("116a78");
|
||||
}
|
||||
|
||||
document.createParagraph();
|
||||
}
|
||||
|
||||
private void buildDmpSectionFieldTitleDescription(XWPFDocument document, FieldModel fieldModel){
|
||||
if (fieldModel == null) throw new IllegalArgumentException("FieldModel required");
|
||||
if (document == null) throw new IllegalArgumentException("Document required");
|
||||
|
||||
private String getReferenceFieldLabel(ReferenceTypeFieldModel referenceTypeField) {
|
||||
if (referenceTypeField == null) return "";
|
||||
if (referenceTypeField.getLabel() != null && !referenceTypeField.getLabel().isBlank()) return referenceTypeField.getLabel();
|
||||
|
||||
return referenceTypeField.getReferenceType().getName();
|
||||
}
|
||||
|
||||
private void buildDmpSectionSystemField(DmpModel dmpEntity, XWPFDocument document, SystemFieldModel systemField) {
|
||||
if (systemField == null) throw new MyApplicationException("SystemField required");
|
||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
||||
if (document == null) throw new MyApplicationException("Document required");
|
||||
|
||||
if (DmpBlueprintSystemFieldType.Language.equals(systemField.getSystemFieldType()) || DmpBlueprintSystemFieldType.User.equals(systemField.getSystemFieldType())) return;
|
||||
|
||||
|
||||
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
||||
systemFieldParagraph.setSpacingBetween(1.0);
|
||||
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
|
||||
runSyStemFieldTitle.setText("Title: ");
|
||||
runSyStemFieldTitle.setText(this.getSystemFieldLabel(systemField) + ": ");
|
||||
runSyStemFieldTitle.setColor("000000");
|
||||
XWPFRun runSystemFieldTitleText = systemFieldParagraph.createRun();
|
||||
runSystemFieldTitleText.setText(fieldModel.getLabel());
|
||||
runSystemFieldTitleText.setColor("116a78");
|
||||
if (fieldModel.getDescription() != null && !fieldModel.getDescription().isEmpty()) {
|
||||
XWPFParagraph systemFieldDescription = document.createParagraph();
|
||||
systemFieldDescription.setSpacingBetween(1.0);
|
||||
XWPFRun runSyStemFieldDescription = systemFieldDescription.createRun();
|
||||
runSyStemFieldDescription.setText("Description: ");
|
||||
runSyStemFieldDescription.setColor("000000");
|
||||
XWPFRun runSystemFieldDescriptionText = systemFieldDescription.createRun();
|
||||
runSystemFieldDescriptionText.setText(fieldModel.getDescription());
|
||||
runSystemFieldDescriptionText.setColor("116a78");
|
||||
}
|
||||
}
|
||||
|
||||
private void buildDmpSectionSystemField(DmpModel dmpEntity, XWPFDocument document, SystemFieldModel systemField) throws InvalidApplicationException {
|
||||
if (systemField == null) throw new IllegalArgumentException("SystemField required");
|
||||
if (dmpEntity == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (document == null) throw new IllegalArgumentException("Document required");
|
||||
|
||||
XWPFParagraph systemFieldInput = document.createParagraph();
|
||||
systemFieldInput.setSpacingBetween(1.0);
|
||||
XWPFRun runInput = systemFieldInput.createRun();
|
||||
runInput.setText("Input: ");
|
||||
runInput.setColor("000000");
|
||||
switch (systemField.getSystemFieldType()) {
|
||||
case Title:
|
||||
XWPFRun runTitle = systemFieldInput.createRun();
|
||||
XWPFRun runTitle = systemFieldParagraph.createRun();
|
||||
runTitle.setText(dmpEntity.getLabel());
|
||||
runTitle.setColor("116a78");
|
||||
break;
|
||||
case Description:
|
||||
XWPFRun runDescription = systemFieldInput.createRun();
|
||||
runDescription.setText(dmpEntity.getDescription());
|
||||
runDescription.setColor("116a78");
|
||||
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||
break;
|
||||
case AccessRights:
|
||||
if (dmpEntity.getAccessType() != null) {
|
||||
XWPFRun runAccessRights = systemFieldInput.createRun();
|
||||
XWPFRun runAccessRights = systemFieldParagraph.createRun();
|
||||
runAccessRights.setText(dmpEntity.getAccessType().equals(DmpAccessType.Public) ? "Public" : "Restricted"); //TODO
|
||||
//runAccessRights.setText(dmpProperties.get("visible").toString());
|
||||
runAccessRights.setColor("116a78");
|
||||
}
|
||||
break;
|
||||
case Contact:
|
||||
if (dmpEntity.getCreator() != null) {
|
||||
XWPFRun runContact = systemFieldInput.createRun();
|
||||
runContact.setText(dmpEntity.getCreator().getName());
|
||||
List<String> contacts = new ArrayList<>();
|
||||
|
||||
if (dmpEntity.getProperties() != null && dmpEntity.getProperties().getContacts() != null && !dmpEntity.getProperties().getContacts().isEmpty()) {
|
||||
for (DmpContactModel contactModel : dmpEntity.getProperties().getContacts()){
|
||||
String contact;
|
||||
contact = (contactModel.getLastName() == null ? "" : contactModel.getLastName()) + " " + (contactModel.getFirstName() == null ? "" : contactModel.getFirstName());
|
||||
if (contactModel.getEmail() != null && !contactModel.getEmail().isEmpty()) contact = contact + " (" + contactModel.getEmail() +")";
|
||||
contacts.add(contact.trim());
|
||||
}
|
||||
}
|
||||
|
||||
if (!contacts.isEmpty()) {
|
||||
XWPFRun runContact = systemFieldParagraph.createRun();
|
||||
runContact.setText(String.join(", ", contacts));
|
||||
runContact.setColor("116a78");
|
||||
}
|
||||
break;
|
||||
|
@ -404,50 +391,85 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
case Language:
|
||||
break;
|
||||
default:
|
||||
throw new InvalidApplicationException("Invalid type " + systemField.getSystemFieldType());
|
||||
throw new MyApplicationException("Invalid type " + systemField.getSystemFieldType());
|
||||
}
|
||||
document.createParagraph();
|
||||
}
|
||||
|
||||
private String getSystemFieldLabel(SystemFieldModel systemField) {
|
||||
if (systemField == null) return "";
|
||||
if (systemField.getLabel() != null && !systemField.getLabel().isBlank()) return systemField.getLabel();
|
||||
|
||||
return switch (systemField.getSystemFieldType()) {
|
||||
case Title -> this.messageSource.getMessage("SystemField_Title_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
case Description -> this.messageSource.getMessage("SystemField_Description_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
case AccessRights -> this.messageSource.getMessage("SystemField_AccessRights_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
case Contact -> this.messageSource.getMessage("SystemField_Contact_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
case User -> this.messageSource.getMessage("SystemField_User_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
case Language -> this.messageSource.getMessage("SystemField_Language_Label", new Object[]{}, LocaleContextHolder.getLocale());
|
||||
default -> throw new MyApplicationException("Invalid type " + systemField.getSystemFieldType());
|
||||
};
|
||||
}
|
||||
|
||||
private void buildDmpSectionExtraField(DmpModel dmpEntity, XWPFDocument document, ExtraFieldModel extraFieldModel) {
|
||||
if (extraFieldModel == null) throw new IllegalArgumentException("ExtraFieldModel required");
|
||||
if (extraFieldModel == null) throw new MyApplicationException("ExtraFieldModel required");
|
||||
XWPFParagraph extraFieldParagraph = document.createParagraph();
|
||||
extraFieldParagraph.setSpacingBetween(1.0);
|
||||
XWPFRun runExtraFieldLabel = extraFieldParagraph.createRun();
|
||||
runExtraFieldLabel.setText(extraFieldModel.getLabel());
|
||||
runExtraFieldLabel.setColor("116a78");
|
||||
if (extraFieldModel.getDescription() != null && !extraFieldModel.getDescription().isEmpty()) {
|
||||
XWPFRun runExtraFieldDescription = extraFieldParagraph.createRun();
|
||||
runExtraFieldDescription.setText(extraFieldModel.getDescription());
|
||||
runExtraFieldDescription.setColor("116a78");
|
||||
}
|
||||
runExtraFieldLabel.setText(extraFieldModel.getLabel() + ": ");
|
||||
runExtraFieldLabel.setColor("000000");
|
||||
|
||||
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
|
||||
DmpBlueprintValueModel dmpBlueprintValueModel = dmpEntity.getProperties() != null && dmpEntity.getProperties().getDmpBlueprintValues() != null ? dmpEntity.getProperties().getDmpBlueprintValues().stream().filter(x -> extraFieldModel.getId().equals(x.getFieldId())).findFirst().orElse(null) : null;
|
||||
if (dmpBlueprintValueModel != null && dmpBlueprintValueModel.getValue() != null) {
|
||||
runExtraFieldInput.setText(dmpBlueprintValueModel.getValue());
|
||||
if (dmpBlueprintValueModel != null) {
|
||||
switch (extraFieldModel.getDataType()) {
|
||||
case RichTex:
|
||||
if(dmpBlueprintValueModel.getValue() != null && !dmpBlueprintValueModel.getValue().isBlank()) wordBuilder.addParagraphContent(dmpBlueprintValueModel.getValue(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||
break;
|
||||
case Number:
|
||||
if(dmpBlueprintValueModel.getNumberValue() != null) {
|
||||
runExtraFieldInput.setText(DecimalFormat.getNumberInstance().format(dmpBlueprintValueModel.getNumberValue()));
|
||||
runExtraFieldInput.setColor("116a78");
|
||||
}
|
||||
break;
|
||||
case Date:
|
||||
if(dmpBlueprintValueModel.getDateValue() != null){
|
||||
runExtraFieldInput.setText(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(dmpBlueprintValueModel.getDateValue()));
|
||||
runExtraFieldInput.setColor("116a78");
|
||||
}
|
||||
break;
|
||||
case Text:
|
||||
if(dmpBlueprintValueModel.getValue() != null && !dmpBlueprintValueModel.getValue().isBlank()) {
|
||||
runExtraFieldInput.setText(dmpBlueprintValueModel.getValue());
|
||||
runExtraFieldInput.setColor("116a78");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new MyApplicationException("Invalid type " + extraFieldModel.getDataType());
|
||||
}
|
||||
}
|
||||
runExtraFieldInput.setColor("116a78");
|
||||
}
|
||||
|
||||
private String getDmpFileName(DmpModel dmpModel, String extension){
|
||||
if (dmpModel == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (dmpModel == null) throw new MyApplicationException("DmpEntity required");
|
||||
|
||||
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(dmpModel, this.wordFileTransformerServiceProperties.getGrantReferenceCode(), null);
|
||||
String fileName;
|
||||
String fileName = null;
|
||||
if (dmpModel.getLabel() != null){
|
||||
return dmpModel.getLabel() + extension;
|
||||
}
|
||||
if (!grants.isEmpty() && grants.getFirst().getLabel() != null) {
|
||||
fileName = "DMP_" + grants.getFirst().getLabel();
|
||||
fileName += "_" + dmpModel.getVersion();
|
||||
|
||||
}
|
||||
else {
|
||||
fileName = "DMP_" + dmpModel.getLabel();
|
||||
}
|
||||
fileName += "_" + dmpModel.getVersion();
|
||||
|
||||
return fileName + extension;
|
||||
}
|
||||
|
||||
private byte[] buildDescriptionWordDocument(DescriptionModel descriptionModel) throws IOException {
|
||||
if (descriptionModel == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (descriptionModel == null) throw new MyApplicationException("DmpEntity required");
|
||||
DmpModel dmpEntity = descriptionModel.getDmp();
|
||||
if (dmpEntity == null) throw new IllegalArgumentException("Dmp is invalid");
|
||||
if (dmpEntity == null) throw new MyApplicationException("Dmp is invalid");
|
||||
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordDescriptionTemplate())));
|
||||
|
||||
this.wordBuilder.fillFirstPage(dmpEntity, descriptionModel, document, true);
|
||||
|
@ -461,7 +483,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
argos_img_par = document.getParagraphArray(powered_pos + 1);
|
||||
}
|
||||
|
||||
this.wordBuilder.build(document, descriptionModel.getDescriptionTemplate(), descriptionModel.getProperties());
|
||||
this.wordBuilder.build(document, descriptionModel.getDescriptionTemplate(), descriptionModel.getProperties(), new VisibilityServiceImpl(descriptionModel.getVisibilityStates()));
|
||||
|
||||
if(powered_pos != -1) {
|
||||
document.getLastParagraph().setPageBreak(false);
|
||||
|
@ -484,7 +506,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
private String getDescriptionFileName(DescriptionModel descriptionModel, String extension){
|
||||
if (descriptionModel == null) throw new IllegalArgumentException("DmpEntity required");
|
||||
if (descriptionModel == null) throw new MyApplicationException("DmpEntity required");
|
||||
String fileName = descriptionModel.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||
|
||||
return fileName + extension;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.wordfiletransformer;
|
||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.wordfiletransformer;
|
||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FieldKey {
|
||||
private final String fieldId;
|
||||
private final Integer ordinal;
|
||||
private final int hashCode;
|
||||
|
||||
|
||||
public FieldKey(String fieldId, Integer ordinal) {
|
||||
this.fieldId = fieldId;
|
||||
this.ordinal = ordinal;
|
||||
hashCode = Objects.hash(this.fieldId, this.ordinal);
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public String getFieldId() {
|
||||
return fieldId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
FieldKey that = (FieldKey) o;
|
||||
return Objects.equals(ordinal, that.getOrdinal()) && Objects.equals(fieldId, that.getFieldId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface VisibilityService {
|
||||
boolean isVisible(String id, Integer ordinal);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility;
|
||||
|
||||
import org.opencdmp.commonmodels.models.description.VisibilityStateModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VisibilityServiceImpl implements VisibilityService {
|
||||
private final Map<FieldKey, Boolean> visibility;
|
||||
|
||||
public VisibilityServiceImpl(List<VisibilityStateModel> visibilityStates) {
|
||||
this.visibility = new HashMap<>();
|
||||
for (VisibilityStateModel visibilityState : visibilityStates) this.visibility.put(new FieldKey(visibilityState.getFieldId(), visibilityState.getOrdinal()), visibilityState.getVisible());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(String id, Integer ordinal) {
|
||||
FieldKey fieldKey = new FieldKey(id, ordinal);
|
||||
return this.visibility.getOrDefault(fieldKey, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.service.wordfiletransformer.word;
|
||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer.word;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
|
@ -21,7 +21,7 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
private final float indentation;
|
||||
private Boolean isIdentationUsed;
|
||||
private XWPFNumbering numbering;
|
||||
private Queue<BigInteger> abstractNumId;
|
||||
private final Queue<BigInteger> abstractNumId;
|
||||
private BigInteger numberingLevel;
|
||||
private XmlCursor cursor;
|
||||
|
||||
|
@ -75,6 +75,7 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
|
||||
private void parseProperties(Node node) {
|
||||
properties.entrySet().forEach(stringBooleanEntry -> {
|
||||
this.run.setFontSize(11);
|
||||
switch (stringBooleanEntry.getKey()) {
|
||||
case "i" :
|
||||
case "em":
|
||||
|
@ -121,6 +122,9 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
if (stringBooleanEntry.getValue()) {
|
||||
if (node.hasAttr("align")) {
|
||||
String alignment = node.attr("align");
|
||||
if(alignment.toUpperCase(Locale.ROOT).equals("JUSTIFY")) {
|
||||
alignment = "both";
|
||||
}
|
||||
this.paragraph.setAlignment(ParagraphAlignment.valueOf(alignment.toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
|
@ -213,6 +217,28 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
this.run.addBreak();
|
||||
}
|
||||
break;
|
||||
case "h1":
|
||||
System.out.println(this.run.getFontSize());
|
||||
this.run.setFontSize(24);
|
||||
break;
|
||||
case "h2":
|
||||
this.run.setFontSize(20);
|
||||
break;
|
||||
case "h3":
|
||||
this.run.setFontSize(16);
|
||||
break;
|
||||
case "h4":
|
||||
this.run.setFontSize(14);
|
||||
this.run.setBold(stringBooleanEntry.getValue());
|
||||
break;
|
||||
case "h5":
|
||||
this.run.setFontSize(14);
|
||||
break;
|
||||
case "h6":
|
||||
this.run.setFontSize(11);
|
||||
this.run.setBold(stringBooleanEntry.getValue());
|
||||
this.run.setCapitalized(stringBooleanEntry.getValue());
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.file.transformer.service.wordfiletransformer.word;
|
||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer.word;
|
||||
|
||||
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||
import eu.eudat.commonmodels.models.description.PropertyDefinitionModel;
|
||||
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||
import eu.eudat.file.transformer.model.enums.ParagraphStyle;
|
||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
||||
import org.opencdmp.filetransformer.docx.model.enums.ParagraphStyle;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility.VisibilityService;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
|
||||
public interface WordBuilder {
|
||||
void build(XWPFDocument document, DescriptionTemplateModel descriptionTemplate, PropertyDefinitionModel propertyDefinitionModel) throws IOException;
|
||||
void build(XWPFDocument document, DescriptionTemplateModel descriptionTemplate, PropertyDefinitionModel propertyDefinitionModel, VisibilityService visibilityService) throws IOException;
|
||||
|
||||
XWPFParagraph addParagraphContent(Object content, XWPFDocument mainDocumentPart, ParagraphStyle style, BigInteger numId, int indent);
|
||||
|
File diff suppressed because it is too large
Load Diff
52
pom.xml
52
pom.xml
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<version>3.2.4</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-document-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
@ -18,19 +18,31 @@
|
|||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<log4j2.version>2.15.0</log4j2.version>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-base</artifactId>
|
||||
<version>0.0.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.26.0</version>
|
||||
<version>1.26.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
<artifactId>logging</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -38,5 +50,37 @@
|
|||
<module>core</module>
|
||||
<module>web</module>
|
||||
</modules>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dev</id>
|
||||
<name>Dev Profile</name>
|
||||
<url>${devProfileUrl}</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>dev</id>
|
||||
<name>Dev Profile</name>
|
||||
<url>${devProfileUrlDeposit}</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>cite-dev</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>cite-maven</id>
|
||||
<name>CITE Maven Repository</name>
|
||||
<url>https://crepo.cite.gr/repository/cite-maven/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
32
settings.xml
32
settings.xml
|
@ -1,29 +1,33 @@
|
|||
<settings>
|
||||
<pluginGroups>
|
||||
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
|
||||
</pluginGroups>
|
||||
<servers>
|
||||
<server>
|
||||
<id>ossrh</id>
|
||||
<username>${server_username}</username>
|
||||
<password>${server_password}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>dev</id>
|
||||
<id>cite-repo</id>
|
||||
<username>${server_username}</username>
|
||||
<password>${server_password}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<id>release</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dev</id>
|
||||
<name>Dev Profile</name>
|
||||
<url>${devProfileUrl}</url>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
<layout>default</layout>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>cite-repo</id>
|
||||
<name>CITE Maven Repo</name>
|
||||
<url>${citeMavenRepoUrl}</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>
|
||||
</settings>
|
||||
|
|
13
web/pom.xml
13
web/pom.xml
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-document-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-document</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
<artifactId>oidc-authn</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
|
@ -44,7 +44,12 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
<artifactId>exceptions</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package eu.eudat.file.transformer.controller;
|
||||
|
||||
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||
import eu.eudat.file.transformer.interfaces.FileTransformerClient;
|
||||
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/file-transformer")
|
||||
public class FileTransformerController implements eu.eudat.file.transformer.interfaces.FileTransformerController {
|
||||
|
||||
private final FileTransformerClient fileTransformerExecutor;
|
||||
|
||||
@Autowired
|
||||
public FileTransformerController(FileTransformerClient fileTransformerExecutor) {
|
||||
this.fileTransformerExecutor = fileTransformerExecutor;
|
||||
}
|
||||
|
||||
public FileEnvelopeModel exportDmp(@RequestBody DmpModel dmpDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
||||
return fileTransformerExecutor.exportDmp(dmpDepositModel, format);
|
||||
}
|
||||
|
||||
public FileEnvelopeModel exportDescription(@RequestBody DescriptionModel descriptionModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
||||
return fileTransformerExecutor.exportDescription(descriptionModel, format);
|
||||
}
|
||||
|
||||
public DmpModel importFileToDmp(@RequestBody FileEnvelopeModel fileEnvelope) {
|
||||
return fileTransformerExecutor.importDmp(fileEnvelope);
|
||||
}
|
||||
|
||||
public DescriptionModel importFileToDescription(@RequestBody FileEnvelopeModel fileEnvelope) {
|
||||
return fileTransformerExecutor.importDescription(fileEnvelope);
|
||||
}
|
||||
|
||||
public FileTransformerConfiguration getSupportedFormats() {
|
||||
return fileTransformerExecutor.getConfiguration();
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.file.transformer;
|
||||
package org.opencdmp.filetransformer.docx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {
|
||||
"eu.eudat.file.transformer",
|
||||
"org.opencdmp.filetransformerbase",
|
||||
"org.opencdmp.filetransformer.docx.*",
|
||||
"gr.cite.tools",
|
||||
"gr.cite.commons"
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.file.transformer.config;
|
||||
package org.opencdmp.filetransformer.docx.web.config;
|
||||
|
||||
import gr.cite.commons.web.oidc.configuration.WebSecurityProperties;
|
||||
import gr.cite.commons.web.oidc.configuration.filter.ApiKeyFilter;
|
|
@ -0,0 +1,91 @@
|
|||
package org.opencdmp.filetransformer.docx.web.controller;
|
||||
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
||||
import org.opencdmp.filetransformer.docx.audit.AuditableAction;
|
||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.WordFileTransformerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/file-transformer")
|
||||
public class FileTransformerController implements org.opencdmp.filetransformerbase.interfaces.FileTransformerController {
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerController.class));
|
||||
|
||||
private final FileTransformerClient fileTransformerExecutor;
|
||||
|
||||
private final AuditService auditService;
|
||||
|
||||
@Autowired
|
||||
public FileTransformerController(FileTransformerClient fileTransformerExecutor, AuditService auditService) {
|
||||
this.fileTransformerExecutor = fileTransformerExecutor;
|
||||
this.auditService = auditService;
|
||||
}
|
||||
|
||||
public FileEnvelopeModel exportDmp(@RequestBody DmpModel dmpDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
||||
logger.debug(new MapLogEntry("exportDmp " + DmpModel.class.getSimpleName()).And("dmpDepositModel", dmpDepositModel).And("format", format));
|
||||
|
||||
FileEnvelopeModel model = fileTransformerExecutor.exportDmp(dmpDepositModel, format);
|
||||
|
||||
this.auditService.track(AuditableAction.FileTransformer_ExportDmp, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("dmpDepositModel", dmpDepositModel),
|
||||
new AbstractMap.SimpleEntry<String, Object>("format", format)
|
||||
));
|
||||
return model;
|
||||
}
|
||||
|
||||
public FileEnvelopeModel exportDescription(@RequestBody DescriptionModel descriptionModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
||||
logger.debug(new MapLogEntry("exportDescription " + DescriptionModel.class.getSimpleName()).And("descriptionModel", descriptionModel).And("format", format));
|
||||
|
||||
FileEnvelopeModel model = fileTransformerExecutor.exportDescription(descriptionModel, format);
|
||||
|
||||
this.auditService.track(AuditableAction.FileTransformer_ExportDescription, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("descriptionModel", descriptionModel),
|
||||
new AbstractMap.SimpleEntry<String, Object>("format", format)
|
||||
));
|
||||
return model;
|
||||
}
|
||||
|
||||
public DmpModel importFileToDmp(@RequestBody FileEnvelopeModel fileEnvelope) {
|
||||
|
||||
logger.debug(new MapLogEntry("importFileToDmp " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope));
|
||||
|
||||
DmpModel model = fileTransformerExecutor.importDmp(fileEnvelope);
|
||||
|
||||
this.auditService.track(AuditableAction.FileTransformer_ImportFileToDmp, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("fileEnvelope", fileEnvelope)
|
||||
));
|
||||
return model;
|
||||
}
|
||||
|
||||
public DescriptionModel importFileToDescription(@RequestBody FileEnvelopeModel fileEnvelope) {
|
||||
logger.debug(new MapLogEntry("importFileToDescription " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope));
|
||||
|
||||
DescriptionModel model = fileTransformerExecutor.importDescription(fileEnvelope);
|
||||
|
||||
this.auditService.track(AuditableAction.FileTransformer_ImportFileToDescription, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("importFileToDescription ", fileEnvelope)
|
||||
));
|
||||
return model;
|
||||
}
|
||||
|
||||
public FileTransformerConfiguration getSupportedFormats() {
|
||||
logger.debug(new MapLogEntry("getSupportedFormats"));
|
||||
|
||||
FileTransformerConfiguration model = fileTransformerExecutor.getConfiguration();
|
||||
|
||||
this.auditService.track(AuditableAction.FileTransformer_GetSupportedFormats);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
package org.opencdmp.filetransformer.docx.web.controller.controllerhandler;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import gr.cite.tools.exception.*;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestControllerAdvice
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(GlobalExceptionHandler.class));
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public GlobalExceptionHandler() {
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.registerModule(new JavaTimeModule());
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<?> handleUnexpectedErrors(Exception exception, WebRequest request) throws Exception {
|
||||
HandledException handled = this.handleException(exception, request);
|
||||
this.log(handled.getLevel(), exception, MessageFormat.format("returning code {0} and payload {1}", handled.getStatusCode(), handled.getMessage()));
|
||||
return new ResponseEntity<>(handled.getMessage(), handled.getStatusCode());
|
||||
}
|
||||
|
||||
public String toJsonSafe(Object item) {
|
||||
if (item == null) return null;
|
||||
try {
|
||||
return this.objectMapper.writeValueAsString(item);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void log(System.Logger.Level level, Exception e, String message) {
|
||||
if (level != null) {
|
||||
switch (level) {
|
||||
case TRACE:
|
||||
logger.trace(message, e);
|
||||
break;
|
||||
case DEBUG:
|
||||
logger.debug(message, e);
|
||||
break;
|
||||
case INFO:
|
||||
logger.info(message, e);
|
||||
break;
|
||||
case WARNING:
|
||||
logger.warn(message, e);
|
||||
break;
|
||||
case ERROR:
|
||||
logger.error(message, e);
|
||||
break;
|
||||
default:
|
||||
logger.error(e);
|
||||
}
|
||||
} else {
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HandledException handleException(Exception exception, WebRequest request) throws Exception {
|
||||
HttpStatus statusCode;
|
||||
Map<String, Object> result;
|
||||
System.Logger.Level logLevel;
|
||||
|
||||
switch (exception){
|
||||
case MyNotFoundException myNotFoundException -> {
|
||||
logLevel = System.Logger.Level.DEBUG;
|
||||
statusCode = HttpStatus.NOT_FOUND;
|
||||
int code = myNotFoundException.getCode();
|
||||
if (code > 0) {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("code", code),
|
||||
Map.entry("error", myNotFoundException.getMessage())
|
||||
);
|
||||
}
|
||||
else {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", myNotFoundException.getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
case MyUnauthorizedException myUnauthorizedException -> {
|
||||
logLevel = System.Logger.Level.DEBUG;
|
||||
statusCode = HttpStatus.UNAUTHORIZED;
|
||||
int code = myUnauthorizedException.getCode();
|
||||
if (code > 0) {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("code", code),
|
||||
Map.entry("error", myUnauthorizedException.getMessage())
|
||||
);
|
||||
}
|
||||
else {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", myUnauthorizedException.getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
case MyForbiddenException myForbiddenException -> {
|
||||
logLevel = System.Logger.Level.DEBUG;
|
||||
statusCode = HttpStatus.FORBIDDEN;
|
||||
int code = myForbiddenException.getCode();
|
||||
if (code > 0) {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("code", code),
|
||||
Map.entry("error", myForbiddenException.getMessage())
|
||||
);
|
||||
}
|
||||
else {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", myForbiddenException.getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
case MyValidationException myValidationException -> {
|
||||
logLevel = System.Logger.Level.DEBUG;
|
||||
statusCode = HttpStatus.BAD_REQUEST;
|
||||
int code = myValidationException.getCode();
|
||||
|
||||
result = new HashMap<>();
|
||||
if (code > 0) result.put("code", code);
|
||||
if (myValidationException.getMessage() != null) result.put("error", myValidationException.getMessage());
|
||||
if (myValidationException.getErrors() != null) result.put("message", myValidationException.getErrors());
|
||||
}
|
||||
case MyApplicationException myApplicationException -> {
|
||||
logLevel = System.Logger.Level.ERROR;
|
||||
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
int code = myApplicationException.getCode();
|
||||
if (code > 0) {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("code", code),
|
||||
Map.entry("error", myApplicationException.getMessage())
|
||||
);
|
||||
}
|
||||
else {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", myApplicationException.getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
logLevel = System.Logger.Level.ERROR;
|
||||
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", "System error")
|
||||
);
|
||||
}
|
||||
}
|
||||
String serialization = this.toJsonSafe(result);
|
||||
return new HandledException(statusCode, serialization, logLevel);
|
||||
}
|
||||
|
||||
public static class HandledException{
|
||||
public HttpStatus statusCode;
|
||||
public String message;
|
||||
public System.Logger.Level level;
|
||||
|
||||
public HandledException(HttpStatus statusCode, String message, System.Logger.Level level) {
|
||||
this.statusCode = statusCode;
|
||||
this.message = message;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public HttpStatus getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(HttpStatus statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public System.Logger.Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(System.Logger.Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ spring:
|
|||
optional:classpath:config/storage.yml[.yml], optional:classpath:config/storage-${spring.profiles.active}.yml[.yml], optional:file:../config/storage-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/security.yml[.yml], optional:classpath:config/security-${spring.profiles.active}.yml[.yml], optional:file:../config/security-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/cache.yml[.yml], optional:classpath:config/cache-${spring.profiles.active}.yml[.yml], optional:file:../config/cache-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/logging.yml[.yml], optional:classpath:config/logging-${spring.profiles.active}.yml[.yml], optional:file:../config/logging-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/word-file-transformer.yml[.yml], optional:classpath:config/word-file-transformer-${spring.profiles.active}.yml[.yml], optional:file:../config/word-file-transformer-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/pdf.yml[.yml], optional:classpath:config/pdf-${spring.profiles.active}.yml[.yml], optional:file:../config/pdf-${spring.profiles.active}.yml[.yml]
|
||||
optional:classpath:config/pdf.yml[.yml], optional:classpath:config/pdf-${spring.profiles.active}.yml[.yml], optional:file:../config/pdf-${spring.profiles.active}.yml[.yml],
|
||||
optional:classpath:config/idpclaims.yml[.yml], optional:classpath:config/idpclaims-${spring.profiles.active}.yml[.yml], optional:file:../config/idpclaims-${spring.profiles.active}.yml[.yml]
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
idpclient:
|
||||
claims:
|
||||
mapping:
|
||||
Subject:
|
||||
- type: sub
|
||||
Name:
|
||||
- type: name
|
||||
Client:
|
||||
- type: client_id
|
||||
AuthenticationMethod:
|
||||
- type: amr
|
||||
NotBefore:
|
||||
- type: nbf
|
||||
AuthenticatedAt:
|
||||
- type: auth_time
|
||||
ExpiresAt:
|
||||
- type: exp
|
||||
Email:
|
||||
- type: email
|
||||
Roles:
|
||||
- type: resource_access
|
||||
path: dmp_zenodo_bridge.roles
|
||||
Scope:
|
||||
- type: scope
|
||||
AccessToken:
|
||||
- type: x-access-token
|
||||
visibility: SENSITIVE
|
||||
IssuedAt:
|
||||
- type: iat
|
||||
Issuer:
|
||||
- type: iss
|
||||
Audience:
|
||||
- type: aud
|
||||
TokenType:
|
||||
- type: typ
|
||||
AuthorizedParty:
|
||||
- type: azp
|
||||
Authorities:
|
||||
- type: authorities
|
||||
ExternalProviderName:
|
||||
- type: identity_provider
|
|
@ -0,0 +1,36 @@
|
|||
logging:
|
||||
config: classpath:logging/logback-${spring.profiles.active}.xml
|
||||
context:
|
||||
request:
|
||||
requestIdKey: req.id
|
||||
requestRemoteHostKey: req.remoteHost
|
||||
requestUriKey: req.requestURI
|
||||
requestQueryStringKey: req.queryString
|
||||
requestUrlKey : req.requestURL
|
||||
requestMethodKey: req.method
|
||||
requestUserAgentKey: req.userAgent
|
||||
requestForwardedForKey: req.xForwardedFor
|
||||
requestSchemeKey: req.scheme
|
||||
requestRemoteAddressKey: req.remoteAddr
|
||||
requestRemotePortKey: req.remotePort
|
||||
requestRemoteUserKey: req.remoteUser
|
||||
principal:
|
||||
subjectKey: usr.subject
|
||||
nameKey: usr.name
|
||||
clientKey: usr.client
|
||||
audit:
|
||||
enable: true
|
||||
requestRemoteHostKey: req.remoteHost
|
||||
requestUriKey: req.requestURI
|
||||
requestQueryStringKey: req.queryString
|
||||
requestUrlKey : req.requestURL
|
||||
requestMethodKey: req.method
|
||||
requestUserAgentKey: req.userAgent
|
||||
requestForwardedForKey: req.xForwardedFor
|
||||
requestSchemeKey: req.scheme
|
||||
requestRemoteAddressKey: req.remoteAddr
|
||||
requestRemotePortKey: req.remotePort
|
||||
requestRemoteUserKey: req.remoteUser
|
||||
principalSubjectKey: usr.subject
|
||||
principalNameKey: usr.name
|
||||
principalClientKey: usr.client
|
|
@ -0,0 +1,35 @@
|
|||
logging:
|
||||
context:
|
||||
request:
|
||||
requestIdKey: req.id
|
||||
requestRemoteHostKey: req.remoteHost
|
||||
requestUriKey: req.requestURI
|
||||
requestQueryStringKey: req.queryString
|
||||
requestUrlKey : req.requestURL
|
||||
requestMethodKey: req.method
|
||||
requestUserAgentKey: req.userAgent
|
||||
requestForwardedForKey: req.xForwardedFor
|
||||
requestSchemeKey: req.scheme
|
||||
requestRemoteAddressKey: req.remoteAddr
|
||||
requestRemotePortKey: req.remotePort
|
||||
requestRemoteUserKey: req.remoteUser
|
||||
principal:
|
||||
subjectKey: usr.subject
|
||||
nameKey: usr.name
|
||||
clientKey: usr.client
|
||||
audit:
|
||||
enable: true
|
||||
requestRemoteHostKey: req.remoteHost
|
||||
requestUriKey: req.requestURI
|
||||
requestQueryStringKey: req.queryString
|
||||
requestUrlKey : req.requestURL
|
||||
requestMethodKey: req.method
|
||||
requestUserAgentKey: req.userAgent
|
||||
requestForwardedForKey: req.xForwardedFor
|
||||
requestSchemeKey: req.scheme
|
||||
requestRemoteAddressKey: req.remoteAddr
|
||||
requestRemotePortKey: req.remotePort
|
||||
requestRemoteUserKey: req.remoteUser
|
||||
principalSubjectKey: usr.subject
|
||||
principalNameKey: usr.name
|
||||
principalClientKey: usr.client
|
|
@ -1,3 +1,4 @@
|
|||
pdf:
|
||||
converter:
|
||||
url: ${PDF_CONVERTER_URL}
|
||||
url: ${PDF_CONVERTER_URL}
|
||||
maxInMemorySizeInBytes: 6554000
|
|
@ -9,5 +9,6 @@ web:
|
|||
resource:
|
||||
token-type: JWT #| opaque
|
||||
jwt:
|
||||
claims: [ role, x-role ]
|
||||
issuer-uri: ${IDP_ISSUER_URI}
|
||||
validIssuer: ${IDP_ISSUER_URI}
|
|
@ -2,4 +2,4 @@ word-file-transformer:
|
|||
word-dmp-template: classpath:documents/h2020.docx
|
||||
pid-template: classpath:pidLinks.json
|
||||
word-description-template: classpath:documents/h2020_dataset.docx
|
||||
useSharedStorage: true
|
||||
useSharedStorage: false
|
||||
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,62 @@
|
|||
<configuration debug="true">
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%date{ISO8601} [%thread] %-5level %logger{36} [%X{req.id}] - %message%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="TROUBLESHOOTING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>logs/logging.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>logs/logging.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%date{ISO8601} [%thread] %-5level %logger{36} [%X{req.id}] - %message%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="AUDITING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>logs/auditing.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>logs/auditing.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%date{ISO8601} - %X{req.id} - %message%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="org.springframework.web" level="INFO" additivity="false">
|
||||
<appender-ref ref="TROUBLESHOOTING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<logger name="org.hibernate" level="INFO" additivity="false">
|
||||
<appender-ref ref="TROUBLESHOOTING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<logger name="gr.cite" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="TROUBLESHOOTING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<logger name="org.opencdmp" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="TROUBLESHOOTING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<logger name="audit" level="INFO" additivity="false">
|
||||
<appender-ref ref="AUDITING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="TROUBLESHOOTING"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,25 @@
|
|||
validation.empty=Value cannot be empty
|
||||
validation.hashempty=Hash must be set
|
||||
validation.lowerthanmin=Value must be larger than {value}
|
||||
validation.largerthanmax=Value must be less than {value}
|
||||
validation.invalidid=Not valid id
|
||||
General_ItemNotFound=Item {0} of type {1} not found
|
||||
Validation_Required={0} is required
|
||||
Validation_OverPosting=Too much info
|
||||
Validation_MaxLength={0} too long
|
||||
Validation_UnexpectedValue=Unexpected value in field {0}
|
||||
Validation_Unique= {0} must be unique
|
||||
Validation.LowerThanMin= value must be equal or larger than {0}
|
||||
Validation.LessThenEqual= value {0} must be equal or less than {1}
|
||||
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
||||
Validation.MissingFields= missing fields: {0}
|
||||
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
||||
Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors
|
||||
Validation_UrlRequired={0} is not valid url
|
||||
|
||||
SystemField_Title_Label=Title
|
||||
SystemField_Description_Label=Description
|
||||
SystemField_AccessRights_Label=Access
|
||||
SystemField_Contact_Label=Contact
|
||||
SystemField_User_Label=User
|
||||
SystemField_Language_Label=Language
|
|
@ -0,0 +1,18 @@
|
|||
validation.empty=Value cannot be empty
|
||||
validation.hashempty=Hash must be set
|
||||
validation.lowerthanmin=Value must be larger than {value}
|
||||
validation.largerthanmax=Value must be less than {value}
|
||||
validation.invalidid=Not valid id
|
||||
General_ItemNotFound=Item {0} of type {1} not found
|
||||
Validation_Required={0} is required
|
||||
Validation_OverPosting=Too much info
|
||||
Validation_MaxLength={0} too long
|
||||
Validation_UnexpectedValue=Unexpected value in field {0}
|
||||
Validation_Unique= {0} must be unique
|
||||
Validation.LowerThanMin= value must be equal or larger than {0}
|
||||
Validation.LessThenEqual= value {0} must be equal or less than {1}
|
||||
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
||||
Validation.MissingFields= missing fields: {0}
|
||||
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
||||
Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors
|
||||
Validation_UrlRequired={0} is not valid url
|
Loading…
Reference in New Issue