add maxInMemorySizeInBytes

This commit is contained in:
Efstratios Giannopoulos 2024-05-15 16:32:55 +03:00
parent 169f0a71ff
commit af0a6655c6
4 changed files with 24 additions and 12 deletions

View File

@ -29,7 +29,10 @@ public class PdfServiceImpl implements PdfService {
WebClient webClient = WebClient.builder().filters(exchangeFilterFunctions -> {
exchangeFilterFunctions.add(logRequest());
exchangeFilterFunctions.add(logResponse());
}).baseUrl(pdfServiceProperties.getUrl()).build();
}).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");
@ -47,7 +50,7 @@ public class PdfServiceImpl implements PdfService {
private static ExchangeFilterFunction logRequest() {
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
logger.debug(new MapLogEntry("Request").And("method", clientRequest.method()).And("url", clientRequest.url()));
logger.debug(new MapLogEntry("Request").And("method", clientRequest.method().toString()).And("url", clientRequest.url()));
return Mono.just(clientRequest);
});
}
@ -57,7 +60,7 @@ public class PdfServiceImpl implements PdfService {
if (response.statusCode().isError()) {
return response.mutate().build().bodyToMono(String.class)
.flatMap(body -> {
logger.error(new MapLogEntry("Response").And("method", response.request().getMethod()).And("url", response.request().getURI()).And("status", response.statusCode()).And("body", 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);
});
}

View File

@ -5,14 +5,22 @@ 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;
}
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;
}
}

View File

@ -971,8 +971,8 @@ public class WordBuilderImpl implements WordBuilder {
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) { // search all text segments having text to find
System.out.println(foundTextSegment.getBeginRun()+":"+foundTextSegment.getBeginText()+":"+foundTextSegment.getBeginChar());
System.out.println(foundTextSegment.getEndRun()+":"+foundTextSegment.getEndText()+":"+foundTextSegment.getEndChar());
logger.debug(foundTextSegment.getBeginRun()+":"+foundTextSegment.getBeginText()+":"+foundTextSegment.getBeginChar());
logger.debug(foundTextSegment.getEndRun()+":"+foundTextSegment.getEndText()+":"+foundTextSegment.getEndChar());
// maybe there is text before textToFind in begin run
XWPFRun beginRun = paragraph.getRuns().get(foundTextSegment.getBeginRun());

View File

@ -1,3 +1,4 @@
pdf:
converter:
url: ${PDF_CONVERTER_URL}
url: ${PDF_CONVERTER_URL}
maxInMemorySizeInBytes: 6554000