From d7759fe4bd8dd088ea950cbe6c01b2eff5a69f67 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 15 May 2024 16:40:49 +0300 Subject: [PATCH] add maxInMemorySizeInBytes --- .../types/deposit/DepositSourceEntity.java | 25 +++++++++++++------ .../FileTransformerSourceEntity.java | 21 +++++++++++----- .../service/deposit/DepositServiceImpl.java | 7 ++++-- .../FileTransformerServiceImpl.java | 5 +++- .../main/resources/config/deposit-devel.yml | 4 ++- .../config/file-transformer-devel.yml | 6 +++-- 6 files changed, 48 insertions(+), 20 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/deposit/DepositSourceEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/deposit/DepositSourceEntity.java index 0aef2fe0e..d67741bc9 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/deposit/DepositSourceEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/deposit/DepositSourceEntity.java @@ -10,9 +10,10 @@ public class DepositSourceEntity { private String scope; private String pdfTransformerId; private String rdaTransformerId; + private int maxInMemorySizeInBytes; public String getRepositoryId() { - return repositoryId; + return this.repositoryId; } public void setRepositoryId(String repositoryId) { @@ -20,7 +21,7 @@ public class DepositSourceEntity { } public String getUrl() { - return url; + return this.url; } public void setUrl(String url) { @@ -28,7 +29,7 @@ public class DepositSourceEntity { } public String getIssuerUrl() { - return issuerUrl; + return this.issuerUrl; } public void setIssuerUrl(String issuerUrl) { @@ -36,7 +37,7 @@ public class DepositSourceEntity { } public String getClientId() { - return clientId; + return this.clientId; } public void setClientId(String clientId) { @@ -44,7 +45,7 @@ public class DepositSourceEntity { } public String getClientSecret() { - return clientSecret; + return this.clientSecret; } public void setClientSecret(String clientSecret) { @@ -52,7 +53,7 @@ public class DepositSourceEntity { } public String getScope() { - return scope; + return this.scope; } public void setScope(String scope) { @@ -60,7 +61,7 @@ public class DepositSourceEntity { } public String getPdfTransformerId() { - return pdfTransformerId; + return this.pdfTransformerId; } public void setPdfTransformerId(String pdfTransformerId) { @@ -68,10 +69,18 @@ public class DepositSourceEntity { } public String getRdaTransformerId() { - return rdaTransformerId; + return this.rdaTransformerId; } public void setRdaTransformerId(String rdaTransformerId) { this.rdaTransformerId = rdaTransformerId; } + + public int getMaxInMemorySizeInBytes() { + return this.maxInMemorySizeInBytes; + } + + public void setMaxInMemorySizeInBytes(int maxInMemorySizeInBytes) { + this.maxInMemorySizeInBytes = maxInMemorySizeInBytes; + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/filetransformer/FileTransformerSourceEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/filetransformer/FileTransformerSourceEntity.java index fa34a4f7d..c60a4a2be 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/filetransformer/FileTransformerSourceEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/filetransformer/FileTransformerSourceEntity.java @@ -8,9 +8,10 @@ public class FileTransformerSourceEntity { private String clientId; private String clientSecret; private String scope; + private int maxInMemorySizeInBytes; public String getUrl() { - return url; + return this.url; } public void setUrl(String url) { @@ -18,7 +19,7 @@ public class FileTransformerSourceEntity { } public String getTransformerId() { - return transformerId; + return this.transformerId; } public void setTransformerId(String transformerId) { @@ -26,7 +27,7 @@ public class FileTransformerSourceEntity { } public String getIssuerUrl() { - return issuerUrl; + return this.issuerUrl; } public void setIssuerUrl(String issuerUrl) { @@ -34,7 +35,7 @@ public class FileTransformerSourceEntity { } public String getClientId() { - return clientId; + return this.clientId; } public void setClientId(String clientId) { @@ -42,7 +43,7 @@ public class FileTransformerSourceEntity { } public String getClientSecret() { - return clientSecret; + return this.clientSecret; } public void setClientSecret(String clientSecret) { @@ -50,10 +51,18 @@ public class FileTransformerSourceEntity { } public String getScope() { - return scope; + return this.scope; } public void setScope(String scope) { this.scope = scope; } + + public int getMaxInMemorySizeInBytes() { + return this.maxInMemorySizeInBytes; + } + + public void setMaxInMemorySizeInBytes(int maxInMemorySizeInBytes) { + this.maxInMemorySizeInBytes = maxInMemorySizeInBytes; + } } \ No newline at end of file diff --git a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java index dc9b170c3..6a34f06a9 100644 --- a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java @@ -158,8 +158,11 @@ public class DepositServiceImpl implements DepositService { exchangeFilterFunctions.add(apiKeyExchangeFilterFunction); exchangeFilterFunctions.add(logRequest()); exchangeFilterFunctions.add(logResponse()); - }).build(); - DepositClientImpl repository = new DepositClientImpl(webClient); + }).codecs(codecs -> codecs + .defaultCodecs() + .maxInMemorySize(source.getMaxInMemorySizeInBytes()) + ).build(); + DepositClientImpl repository = new DepositClientImpl(webClient); this.clients.put(repositoryIdByTenant, repository); return repository; } diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java index 875439623..29553f216 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java @@ -109,7 +109,10 @@ public class FileTransformerServiceImpl implements FileTransformerService { exchangeFilterFunctions.add(tokenExchangeFilterFunction); exchangeFilterFunctions.add(logRequest()); exchangeFilterFunctions.add(logResponse()); - }).build()); + }).codecs(codecs -> codecs + .defaultCodecs() + .maxInMemorySize(source.getMaxInMemorySizeInBytes()) + ).build()); this.clients.put(repositoryIdByTenant, repository); return repository; } diff --git a/backend/web/src/main/resources/config/deposit-devel.yml b/backend/web/src/main/resources/config/deposit-devel.yml index 79d67a7d0..6eb01fe91 100644 --- a/backend/web/src/main/resources/config/deposit-devel.yml +++ b/backend/web/src/main/resources/config/deposit-devel.yml @@ -8,6 +8,7 @@ deposit: client-id: ${IDP_APIKEY_CLIENT_ID} client-secret: ${IDP_APIKEY_CLIENT_SECRET} scope: ${IDP_APIKEY_SCOPE} + maxInMemorySizeInBytes: 6554000 - url: http://dev04.local.cite.gr:55330/zenodo1 repositoryId: Zenodo1 pdfTransformerId: docx-file-transformer @@ -15,4 +16,5 @@ deposit: issuer-url: ${IDP_ISSUER_URI_TOKEN} client-id: ${IDP_APIKEY_CLIENT_ID} client-secret: ${IDP_APIKEY_CLIENT_SECRET} - scope: ${IDP_APIKEY_SCOPE} \ No newline at end of file + scope: ${IDP_APIKEY_SCOPE} + maxInMemorySizeInBytes: 6554000 \ No newline at end of file diff --git a/backend/web/src/main/resources/config/file-transformer-devel.yml b/backend/web/src/main/resources/config/file-transformer-devel.yml index 91120d01d..c7111db5b 100644 --- a/backend/web/src/main/resources/config/file-transformer-devel.yml +++ b/backend/web/src/main/resources/config/file-transformer-devel.yml @@ -1,14 +1,16 @@ file-transformer: sources: - - url: http://dev04.local.cite.gr:55330/file/docx + - url: http://localhost:8084 transformerId: docx-file-transformer issuer-url: ${IDP_ISSUER_URI_TOKEN} client-id: ${IDP_APIKEY_CLIENT_ID} client-secret: ${IDP_APIKEY_CLIENT_SECRET} scope: ${IDP_APIKEY_SCOPE} + maxInMemorySizeInBytes: 6554000 - url: http://dev04.local.cite.gr:55330/file/rdajson transformerId: rda-file-transformer issuer-url: ${IDP_ISSUER_URI_TOKEN} client-id: ${IDP_APIKEY_CLIENT_ID} client-secret: ${IDP_APIKEY_CLIENT_SECRET} - scope: ${IDP_APIKEY_SCOPE} \ No newline at end of file + scope: ${IDP_APIKEY_SCOPE} + maxInMemorySizeInBytes: 6554000 \ No newline at end of file