diff --git a/.github/workflows/ga-publication.yml b/.github/workflows/ga-publication.yml
index fb7e7f5a4d..4f266b64bb 100755
--- a/.github/workflows/ga-publication.yml
+++ b/.github/workflows/ga-publication.yml
@@ -46,7 +46,7 @@ jobs:
- name: "Configure GA Repository"
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 17
server-id: maven-central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index e782e3fc85..7642c0021a 100755
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -72,10 +72,10 @@ jobs:
--token "$ENTANDO_BOT_TOKEN" \
;
#~ JDK
- - name: "Set up JDK 11"
+ - name: "Set up JDK 17"
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 17
#~ MAVEN CACHE
- name: "Cache Maven packages"
uses: actions/cache@v2
@@ -119,10 +119,10 @@ jobs:
# ${{ secrets.ENTANDO_OPT_PPL_INSTALL_CMD }}
# ~/ppl-run checkout-branch pr --lcd "$LOCAL_CLONE_DIR"
# #~ JDK
-# - name: "Set up JDK 11"
+# - name: "Set up JDK 17"
# uses: actions/setup-java@v1
# with:
-# java-version: 11
+# java-version: 17
# #~ MAVEN CACHE
# - name: "Cache Maven packages"
# id: maven-cache
diff --git a/.github/workflows/publication.yml b/.github/workflows/publication.yml
index bcbc107a53..2dd993b034 100755
--- a/.github/workflows/publication.yml
+++ b/.github/workflows/publication.yml
@@ -10,17 +10,12 @@ env:
ENTANDO_BOT_TOKEN: ${{ secrets.ENTANDO_BOT_TOKEN }}
PR_CHECKER_PATH: ".github/pr-title-checker-config.json"
- JDK_VERSION: 11
+ JDK_VERSION: 17
BUILD_COMMANDS: mvn clean install;
- DOCKER_EAP_IMAGE_BASE_NAME: entando/entando-de-app-eap
DOCKER_TOMCAT_IMAGE_BASE_NAME: entando/entando-de-app-tomcat
- DOCKER_WILDFLY_IMAGE_BASE_NAME: entando/entando-de-app-wildfly
- DOCKER_EAP-WILDFLY_IMAGE_ARCHITECTURE: linux/amd64
DOCKER_TOMCAT_IMAGE_ARCHITECTURE: linux/amd64,linux/arm64
DOCKER_IMAGE_CONTEXT: .
- DOCKER_EAP_IMAGE_FILE: Dockerfile.eap
DOCKER_TOMCAT_IMAGE_FILE: Dockerfile.tomcat
- DOCKER_WILDFLY_IMAGE_FILE: Dockerfile.wildfly
DOCKER_IMAGE_PUSH: true
jobs:
@@ -58,23 +53,6 @@ jobs:
- name: Build with Maven
run: ${{ env.BUILD_COMMANDS }}
- - name: Docker meta-eap
- id: meta-eap
- uses: docker/metadata-action@v4
- with:
- images: |
- ${{ env.DOCKER_EAP_IMAGE_BASE_NAME }}
- tags: |
- type=schedule
- type=ref,event=branch
- type=ref,event=pr,value={{base_ref}}
- type=ref,event=tag
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- type=semver,pattern={{major}}
- type=sha
- type=raw,event=pr,value={{base_ref}}
-
- name: Docker meta-tomcat
id: meta-tomcat
uses: docker/metadata-action@v4
@@ -92,23 +70,6 @@ jobs:
type=sha
type=raw,event=pr,value={{base_ref}}
- - name: Docker meta-wildfly
- id: meta-wildfly
- uses: docker/metadata-action@v4
- with:
- images: |
- ${{ env.DOCKER_WILDFLY_IMAGE_BASE_NAME }}
- tags: |
- type=schedule
- type=ref,event=branch
- type=ref,event=pr,value={{base_ref}}
- type=ref,event=tag
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- type=semver,pattern={{major}}
- type=sha
- type=raw,event=pr,value={{base_ref}}
-
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
@@ -130,16 +91,6 @@ jobs:
username: ${{ secrets.ENTANDO_RHT_DOCKER_USERNAME }}
password: ${{ secrets.ENTANDO_RHT_DOCKER_PASSWORD }}
- - name: Build and push eap Docker image
- uses: docker/build-push-action@v4
- with:
- context: ${{ env.DOCKER_IMAGE_CONTEXT }}
- file: ${{ env.DOCKER_EAP_IMAGE_FILE }}
- push: ${{ env.DOCKER_IMAGE_PUSH }}
- tags: ${{ steps.meta-eap.outputs.tags }}
- labels: ${{ steps.meta-eap.outputs.labels }}
- platforms: ${{ env.DOCKER_EAP-WILDFLY_IMAGE_ARCHITECTURE }}
-
- name: Build tomcat Docker image for amd64
uses: docker/build-push-action@v4
with:
@@ -168,14 +119,4 @@ jobs:
push: ${{ env.DOCKER_IMAGE_PUSH }}
tags: ${{ steps.meta-tomcat.outputs.tags }}
labels: ${{ steps.meta-tomcat.outputs.labels }}
- platforms: ${{ env.DOCKER_TOMCAT_IMAGE_ARCHITECTURE }}
-
- - name: Build and push wildfly Docker image
- uses: docker/build-push-action@v4
- with:
- context: ${{ env.DOCKER_IMAGE_CONTEXT }}
- file: ${{ env.DOCKER_WILDFLY_IMAGE_FILE }}
- push: ${{ env.DOCKER_IMAGE_PUSH }}
- tags: ${{ steps.meta-wildfly.outputs.tags }}
- labels: ${{ steps.meta-wildfly.outputs.labels }}
- platforms: ${{ env.DOCKER_EAP-WILDFLY_IMAGE_ARCHITECTURE }}
\ No newline at end of file
+ platforms: ${{ env.DOCKER_TOMCAT_IMAGE_ARCHITECTURE }}
\ No newline at end of file
diff --git a/Dockerfile.eap b/Dockerfile.eap
deleted file mode 100644
index df815cde69..0000000000
--- a/Dockerfile.eap
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM registry.hub.docker.com/entando/entando-eap73-clustered-base:7.2.0
-ARG VERSION
-
-### Required OpenShift Labels
-LABEL name="Entando App" \
- maintainer="dev@entando.com" \
- vendor="Entando Inc." \
- version="${VERSION}" \
- release="7.3.0" \
- summary="Entando Application" \
- description="This Entando app engine application provides APIs and composition for Entando applications"
-
-COPY target/generated-resources/licenses /licenses
-COPY target/generated-resources/licenses.xml /
-
-COPY webapp/target/*.war /opt/eap/standalone/deployments/
-
-RUN $ENTANDO_COMMON_PATH/init-derby-from-war.sh
-
-RUN rm -rf /tmp/*.jpg
diff --git a/Dockerfile.tomcat b/Dockerfile.tomcat
index ddd8d6463a..8eb796f981 100644
--- a/Dockerfile.tomcat
+++ b/Dockerfile.tomcat
@@ -1,4 +1,4 @@
-FROM registry.hub.docker.com/entando/entando-tomcat-base:7.3.0
+FROM registry.hub.docker.com/entando/entando-tomcat-base:v7.3.1-ENG-5347-PR-29-BB-release-2F-7.3
ARG VERSION
### Required OpenShift Labels
@@ -6,7 +6,7 @@ LABEL name="Entando App" \
maintainer="dev@entando.com" \
vendor="Entando Inc." \
version="${VERSION}" \
- release="7.3.0" \
+ release="7.3.1" \
summary="Entando Application" \
description="This Entando app engine application provides APIs and composition for Entando applications"
diff --git a/Dockerfile.wildfly b/Dockerfile.wildfly
deleted file mode 100644
index ee27854dce..0000000000
--- a/Dockerfile.wildfly
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM registry.hub.docker.com/entando/entando-wildfly17-base:7.2.0
-
-ARG VERSION
-
-### Required OpenShift Labels
-LABEL name="Entando App" \
- maintainer="dev@entando.com" \
- vendor="Entando Inc." \
- version="${VERSION}" \
- release="7.3.0" \
- summary="Entando Application" \
- description="This Entando app engine application provides APIs and composition for Entando applications"
-
-COPY target/generated-resources/licenses /licenses
-COPY target/generated-resources/licenses.xml /
-
-COPY webapp/target/*.war /wildfly/standalone/deployments/
-
-RUN $ENTANDO_COMMON_PATH/init-derby-from-war.sh
-
-RUN rm -rf /tmp/*.jpg
diff --git a/admin-console/pom.xml b/admin-console/pom.xml
index b8cb5051bf..c420ca7467 100644
--- a/admin-console/pom.xml
+++ b/admin-console/pom.xml
@@ -4,7 +4,7 @@
org.entando
app-engine
- 7.3.0
+ 7.3.1
org.entando.entando
entando-admin-console
@@ -274,21 +274,34 @@
org.apache.httpcomponents
httpclient
+
+ javax.servlet
+ javax.servlet-api
+
+
+ javax.servlet.jsp
+ jsp-api
+
+
org.springframework
spring-test
+ test
org.junit.jupiter
junit-jupiter
+ test
org.junit.jupiter
junit-jupiter-api
+ test
org.mockito
mockito-core
+ test
org.mockito
@@ -298,14 +311,12 @@
org.mockito
mockito-junit-jupiter
+ test
- javax.servlet
- javax.servlet-api
-
-
- javax.servlet.jsp
- jsp-api
+ uk.org.webcompere
+ system-stubs-jupiter
+ test
org.apache.derby
diff --git a/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_en.properties b/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_en.properties
index 852738fb81..3afc35efab 100644
--- a/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_en.properties
+++ b/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_en.properties
@@ -85,6 +85,7 @@ label.template.preview=Template preview
label.key=Key
label.info=Info
+label.warning=Warning
label.description=Name
label.empty.f=Empty
label.empty.m=Empty
diff --git a/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_it.properties b/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_it.properties
index d654d7885f..d50c43a7b4 100644
--- a/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_it.properties
+++ b/admin-console/src/main/java/com/agiletec/apsadmin/global-messages_it.properties
@@ -91,6 +91,7 @@ label.filter=Filtro
label.key=Chiave
label.info=Info
+label.warning=Attenzione
label.description=Descrizione
label.descr=Descrizione
label.empty.f=Vuota
diff --git a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/FileBrowserAction.java b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/FileBrowserAction.java
index 3db3a885f1..f8de312ea9 100644
--- a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/FileBrowserAction.java
+++ b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/FileBrowserAction.java
@@ -28,9 +28,12 @@
import org.apache.commons.lang3.StringUtils;
import org.entando.entando.aps.system.services.storage.BasicFileAttributeView;
+import org.entando.entando.aps.system.services.storage.CdsEnvironmentVariables;
import org.entando.entando.aps.system.services.storage.IStorageManager;
import org.entando.entando.aps.system.services.storage.RootFolderAttributeView;
import org.entando.entando.aps.system.services.storage.StorageManagerUtil;
+import org.entando.entando.aps.system.services.storage.model.DiskInfoDto;
+import org.entando.entando.ent.exception.EntException;
import org.entando.entando.ent.util.EntLogging.EntLogger;
import org.entando.entando.ent.util.EntLogging.EntLogFactory;
@@ -256,6 +259,18 @@ public String createDir() {
}
return SUCCESS;
}
+
+ public DiskInfoDto getDiskInfo() {
+ try {
+ if (!CdsEnvironmentVariables.active()) {
+ return null;
+ }
+ return this.getStorageManager().getDiskInfo();
+ } catch (EntException t) {
+ logger.error("error extracting disk info", t);
+ return null;
+ }
+ }
public String download() {
try {
diff --git a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_en.properties b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_en.properties
index 8efeab9b2f..d28404f448 100644
--- a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_en.properties
+++ b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_en.properties
@@ -22,3 +22,8 @@ filebrowser.label.add-fileinput=Add Another File
filebrowser.label.remove-fileinput=Remove from form
filebrowser.label.button-choose-file=Choose file
filebrowser.label.no-file-selected=No file chosen
+
+label.disk.status=Disk status
+label.disk.used=(Used)
+label.disk.available=(Available)
+label.disk.used.percentage=(Use%)
diff --git a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_it.properties b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_it.properties
index da67ae6082..0ad1b3f44c 100644
--- a/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_it.properties
+++ b/admin-console/src/main/java/org/entando/entando/apsadmin/filebrowser/package_it.properties
@@ -22,3 +22,8 @@ filebrowser.label.add-fileinput=Aggiungi un altro file
filebrowser.label.remove-fileinput=Rimuovi dal form
filebrowser.label.button-choose-file=Seleziona un file
filebrowser.label.no-file-selected=Nessun file selezionato
+
+label.disk.status=Stato disco
+label.disk.used=(Usato)
+label.disk.available=(Totale Disponibile)
+label.disk.used.percentage=(Percentuale utilizzo)
diff --git a/admin-console/src/main/webapp/404.jsp b/admin-console/src/main/webapp/404.jsp
deleted file mode 100644
index 7788f7683e..0000000000
--- a/admin-console/src/main/webapp/404.jsp
+++ /dev/null
@@ -1 +0,0 @@
-<%@ page isErrorPage="true" %>
diff --git a/admin-console/src/main/webapp/META-INF/MANIFEST.MF b/admin-console/src/main/webapp/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e9495128c..0000000000
--- a/admin-console/src/main/webapp/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/admin-console/src/main/webapp/META-INF/context.xml b/admin-console/src/main/webapp/META-INF/context.xml
deleted file mode 100644
index 5bee3dc30f..0000000000
--- a/admin-console/src/main/webapp/META-INF/context.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/admin-console/src/main/webapp/WEB-INF/apsadmin/jsp/filebrowser/filebrowser-list.jsp b/admin-console/src/main/webapp/WEB-INF/apsadmin/jsp/filebrowser/filebrowser-list.jsp
index a3cd2e9b2f..1f47b15f9b 100644
--- a/admin-console/src/main/webapp/WEB-INF/apsadmin/jsp/filebrowser/filebrowser-list.jsp
+++ b/admin-console/src/main/webapp/WEB-INF/apsadmin/jsp/filebrowser/filebrowser-list.jsp
@@ -23,7 +23,24 @@
-
+
+
+
+
+ : /
+ –
+
+ %
+
+
%">
+
% Complete (danger)
+
+
+
+
+
+
+
@@ -42,8 +59,7 @@
">
-
+
diff --git a/admin-console/src/main/webapp/error.jsp b/admin-console/src/main/webapp/error.jsp
index 8bec65d6fd..dfa5b9dfd5 100644
--- a/admin-console/src/main/webapp/error.jsp
+++ b/admin-console/src/main/webapp/error.jsp
@@ -12,14 +12,14 @@
- Entando - Error
+ Error
administration/bootstrap/css/bootstrap.min.css" media="screen" />
-
Entando - Error
+
Error
Go to Home
diff --git a/admin-console/src/main/webapp/index.jsp b/admin-console/src/main/webapp/index.jsp
deleted file mode 100644
index 5e557b0dca..0000000000
--- a/admin-console/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,4 +0,0 @@
-<%@ taglib uri="/aps-core" prefix="wp" %>
-
-
-
\ No newline at end of file
diff --git a/admin-console/src/main/webapp/logout.jsp b/admin-console/src/main/webapp/logout.jsp
index 5e4db796a1..5e557b0dca 100644
--- a/admin-console/src/main/webapp/logout.jsp
+++ b/admin-console/src/main/webapp/logout.jsp
@@ -1,3 +1,4 @@
<%@ taglib uri="/aps-core" prefix="wp" %>
-
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/TestFileBrowserAction.java b/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionIntegrationTest.java
similarity index 99%
rename from admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/TestFileBrowserAction.java
rename to admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionIntegrationTest.java
index c018bf7c33..816ae0758e 100644
--- a/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/TestFileBrowserAction.java
+++ b/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionIntegrationTest.java
@@ -33,9 +33,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-class TestFileBrowserAction extends ApsAdminBaseTestCase {
+class FileBrowserActionIntegrationTest extends ApsAdminBaseTestCase {
- private static final EntLogger logger = EntLogFactory.getSanitizedLogger(TestFileBrowserAction.class);
+ private static final EntLogger logger = EntLogFactory.getSanitizedLogger(FileBrowserActionIntegrationTest.class);
private IStorageManager localStorageManager;
diff --git a/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionTest.java b/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionTest.java
new file mode 100644
index 0000000000..5caba4330f
--- /dev/null
+++ b/admin-console/src/test/java/org/entando/entando/apsadmin/filebrowser/FileBrowserActionTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2024-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+package org.entando.entando.apsadmin.filebrowser;
+
+import org.entando.entando.aps.system.services.storage.IStorageManager;
+import org.entando.entando.aps.system.services.storage.model.DiskInfoDto;
+import org.entando.entando.ent.exception.EntException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
+import uk.org.webcompere.systemstubs.jupiter.SystemStub;
+import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
+
+@ExtendWith({MockitoExtension.class,SystemStubsExtension.class})
+class FileBrowserActionTest {
+
+ @SystemStub
+ private static EnvironmentVariables environmentVariables;
+
+ @Mock
+ private IStorageManager storageManager;
+
+ @InjectMocks
+ private FileBrowserAction fileBrowserAction;
+
+ @Test
+ void shouldReturnNullDiskInfo() throws Exception {
+ environmentVariables.set("CDS_ENABLED", "false");
+ DiskInfoDto dto = fileBrowserAction.getDiskInfo();
+ Assertions.assertNull(dto);
+ Mockito.verifyNoInteractions(this.storageManager);
+ }
+
+ @Test
+ void shouldReturnDiskInfo() throws Exception {
+ environmentVariables.set("CDS_ENABLED", "true");
+ Mockito.when(this.storageManager.getDiskInfo()).thenReturn(Mockito.mock(DiskInfoDto.class));
+ DiskInfoDto dto = fileBrowserAction.getDiskInfo();
+ Assertions.assertNotNull(dto);
+ }
+
+ @Test
+ void shouldReturnNulInvokingGetDiskInfoWithServiceError() throws Exception {
+ environmentVariables.set("CDS_ENABLED", "true");
+ Mockito.when(this.storageManager.getDiskInfo()).thenThrow(new EntException("Error"));
+ DiskInfoDto dto = fileBrowserAction.getDiskInfo();
+ Assertions.assertNull(dto);
+ }
+
+}
diff --git a/cds-plugin/pom.xml b/cds-plugin/pom.xml
index 9932ad875e..3e8185da63 100644
--- a/cds-plugin/pom.xml
+++ b/cds-plugin/pom.xml
@@ -5,7 +5,7 @@
org.entando
app-engine
- 7.3.0
+ 7.3.1
entando-plugin-jpcds
org.entando.entando.plugins
diff --git a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfiguration.java b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfiguration.java
index 331f74992e..e812a28b97 100644
--- a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfiguration.java
+++ b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfiguration.java
@@ -26,7 +26,7 @@
@Component
@CdsActive(true)
public class CdsConfiguration {
-
+
@Value("${resourceRootURL}")
private String baseURL;
@Value("${resourceDiskRootFolder}")
@@ -39,6 +39,10 @@ public class CdsConfiguration {
private boolean enabled;
@Value("${CDS_PUBLIC_URL:https://cds.entando.org}")
private String cdsPublicUrl;
+ @Value("${CDS_PUBLIC_PATH:}")
+ private String cdsPublicPath;
+ @Value("${CDS_INTERNAL_PUBLIC_SECTION:}")
+ private String cdsInternalPublicSection;
@Value("${CDS_PRIVATE_URL:https://cds.entando.org}")
private String cdsPrivateUrl;
@Value("${CDS_PATH:/api/v1}")
@@ -51,6 +55,5 @@ public class CdsConfiguration {
private String kcClientId;
@Value("${KEYCLOAK_CLIENT_SECRET:}")
private String kcClientSecret;
-
-
+
}
diff --git a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCaller.java b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCaller.java
index f017474496..f013272843 100644
--- a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCaller.java
+++ b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCaller.java
@@ -13,6 +13,8 @@
*/
package org.entando.entando.plugins.jpcds.aps.system.storage;
+import org.entando.entando.aps.system.services.storage.model.DiskInfoDto;
+
import static org.entando.entando.aps.system.services.tenants.ITenantManager.PRIMARY_CODE;
import java.io.ByteArrayInputStream;
@@ -64,7 +66,8 @@ public class CdsRemoteCaller {
private Map tenantsToken = new WeakHashMap<>();
@Autowired
- public CdsRemoteCaller(@Qualifier("keycloakRestTemplate")RestTemplate restTemplate,@Qualifier("keycloakRestTemplateWithRedirect")RestTemplate restTemplateWithRedirect,
+ public CdsRemoteCaller(@Qualifier("keycloakRestTemplate")RestTemplate restTemplate,
+ @Qualifier("keycloakRestTemplateWithRedirect")RestTemplate restTemplateWithRedirect,
CdsConfiguration configuration) {
this.restTemplate = restTemplate;
this.restTemplateWithRedirect = restTemplateWithRedirect;
@@ -176,7 +179,6 @@ public Optional getFileAttributeView(URI url, Optiona
logger.debug("Trying to call GET (getFileAttributeView) on url:'{}' and is config tenant empty:'{}'",
url,
config.isEmpty());
-
return this.executeGetCall(url,
Arrays.asList(MediaType.APPLICATION_JSON),
config,
@@ -189,7 +191,6 @@ public Optional getFile(URI url, Optional co
url,
isProtectedResource,
config.isEmpty());
-
Optional bytes;
if (isProtectedResource) {
bytes = executeGetCall(url, null, config, false, new ParameterizedTypeReference(){});
@@ -203,11 +204,15 @@ public Optional getFile(URI url, Optional co
}
throw buildExceptionWithMessage("GET", e.getStatusCode(), url.toString());
}
-
}
return bytes.map(ByteArrayInputStream::new);
}
-
+
+ public Optional getDiskInfo(URI url, Optional config) {
+ logger.debug("Trying to call GET (diskinfo) on url:'{}' and is config tenant empty:'{}'", url, config.isEmpty());
+ return this.executeGetCall(url, null, config, false, new ParameterizedTypeReference(){});
+ }
+
private Optional executeGetCall(URI url, List acceptableMediaTypes, Optional config,
boolean forceTokenRetrieve,
ParameterizedTypeReference responseType) {
@@ -216,7 +221,6 @@ private Optional executeGetCall(URI url, List acceptableMediaT
HttpEntity entity = new HttpEntity<>(headers);
ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, responseType);
return Optional.ofNullable(responseEntity.getBody());
-
} catch (HttpClientErrorException e) {
if (e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
logger.info("File Not found - uri {}", url);
@@ -230,7 +234,7 @@ private Optional executeGetCall(URI url, List acceptableMediaT
}
}
- private EntRuntimeException buildExceptionWithMessage(String method, HttpStatus statusCode, String url){
+ private EntRuntimeException buildExceptionWithMessage(String method, HttpStatus statusCode, String url) {
return new EntRuntimeException(String.format(REST_ERROR_MSG, method, statusCode, url));
}
diff --git a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsStorageManager.java b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsStorageManager.java
index 9cb0c81c2b..a3ed252db3 100644
--- a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsStorageManager.java
+++ b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsStorageManager.java
@@ -13,6 +13,8 @@
*/
package org.entando.entando.plugins.jpcds.aps.system.storage;
+import org.entando.entando.aps.system.services.storage.model.DiskInfoDto;
+import com.agiletec.aps.system.SystemConstants;
import com.agiletec.aps.util.ApsTenantApplicationUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -23,6 +25,8 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
+import lombok.AccessLevel;
+import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -41,17 +45,22 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import org.entando.entando.aps.system.services.storage.CdsActive;
+import org.springframework.web.context.ContextLoader;
+import org.springframework.web.context.WebApplicationContext;
@Slf4j
-@Service("StorageManager")
+@Service(SystemConstants.STORAGE_MANAGER)
@CdsActive(true)
public class CdsStorageManager implements IStorageManager {
private static final String ERROR_VALIDATING_PATH_MSG = "Error validating path";
- private final transient ITenantManager tenantManager;
- private final transient CdsConfiguration configuration;
- private final transient CdsRemoteCaller caller;
-
+
+ @Getter(AccessLevel.PROTECTED)
+ private transient ITenantManager tenantManager;
+ @Getter(AccessLevel.PROTECTED)
+ private transient CdsConfiguration configuration;
+ @Getter(AccessLevel.PROTECTED)
+ private transient CdsRemoteCaller caller;
@Autowired
public CdsStorageManager(CdsRemoteCaller caller, ITenantManager tenantManager, CdsConfiguration configuration) {
@@ -73,21 +82,18 @@ public void saveFile(String subPath, boolean isProtectedResource, InputStream is
private void create(String subPath, boolean isProtectedResource, Optional fileInputStream) {
try {
- Optional config = getTenantConfig();
+ Optional config = this.getTenantConfig();
if(StringUtils.isBlank(subPath)){
throw new EntRuntimeException(ERROR_VALIDATING_PATH_MSG);
}
-
- this.validateAndReturnResourcePath(config, subPath, isProtectedResource);
-
+ this.validateAndReturnResourcePath(config, subPath, false, isProtectedResource);
URI apiUrl = CdsUrlUtils.buildCdsInternalApiUrl(config, configuration, "/upload/");
- CdsCreateResponseDto response = caller.executePostCall(apiUrl,
+ CdsCreateResponseDto response = this.caller.executePostCall(apiUrl,
subPath,
isProtectedResource,
fileInputStream,
config,
false);
-
if (!response.isStatusOk()) {
throw new EntRuntimeException("Invalid status - Response " + response.isStatusOk());
}
@@ -106,22 +112,18 @@ public void deleteDirectory(String subPath, boolean isProtectedResource) throws
@Override
public boolean deleteFile(String subPath, boolean isProtectedResource) {
try {
- Optional config = getTenantConfig();
- if(StringUtils.isBlank(subPath)){
+ Optional config = this.getTenantConfig();
+ if (StringUtils.isBlank(subPath)){
throw new EntRuntimeException(ERROR_VALIDATING_PATH_MSG);
}
-
- this.validateAndReturnResourcePath(config, subPath, isProtectedResource);
-
+ this.validateAndReturnResourcePath(config, subPath, true, isProtectedResource);
URI apiUrl = EntUrlBuilder.builder()
.url(CdsUrlUtils.buildCdsInternalApiUrl(config, configuration))
.path("/delete/")
- .path(CdsUrlUtils.getInternalSection(isProtectedResource))
+ .path(CdsUrlUtils.getSection(isProtectedResource, config, this.configuration, true))
.path(subPath)
.build();
-
- return caller.executeDeleteCall(apiUrl, config, false);
-
+ return this.caller.executeDeleteCall(apiUrl, config, false);
} catch (EntRuntimeException ert) {
throw ert;
} catch (Exception e) {
@@ -134,32 +136,31 @@ public InputStream getStream(String subPath, boolean isProtectedResource) throws
final String ERROR_EXTRACTING_FILE = "Error extracting file";
URI url = null;
try {
- Optional config = getTenantConfig();
- if(StringUtils.isBlank(subPath)){
+ Optional config = this.getTenantConfig();
+ if (StringUtils.isBlank(subPath)) {
throw new EntRuntimeException(ERROR_VALIDATING_PATH_MSG);
}
-
- this.validateAndReturnResourcePath(config, subPath, isProtectedResource);
-
+ if (!this.exists(subPath, isProtectedResource)) {
+ throw new EntResourceNotFoundException(
+ String.format("File \"%s\", protected \"%s\", Not Found", subPath, isProtectedResource));
+ }
+ this.validateAndReturnResourcePath(config, subPath, true, isProtectedResource);
url = (isProtectedResource) ?
CdsUrlUtils.buildCdsInternalApiUrl(config, configuration) :
CdsUrlUtils.buildCdsExternalPublicResourceUrl(config, configuration);
-
url = EntUrlBuilder.builder()
.url(url)
- .path(CdsUrlUtils.getInternalSection(isProtectedResource))
+ .path(CdsUrlUtils.getSection(isProtectedResource, config, this.configuration, true))
.path(subPath).build();
-
Optional is = caller.getFile(url, config, isProtectedResource);
- return is.orElseThrow(IOException::new);
-
- } catch (EntRuntimeException ert) {
+ return is.orElse(new ByteArrayInputStream(new byte[0]));
+ } catch (EntResourceNotFoundException | EntRuntimeException ert) {
throw ert;
} catch (HttpClientErrorException e) {
if (e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
log.info("File Not found - uri {}", url);
return null;
- }
+ }
throw new EntResourceNotFoundException(ERROR_EXTRACTING_FILE, e);
} catch (Exception e) {
throw new EntResourceNotFoundException(ERROR_EXTRACTING_FILE, e);
@@ -167,10 +168,27 @@ public InputStream getStream(String subPath, boolean isProtectedResource) throws
}
@Override
- public String getResourceUrl(String subPath, boolean isProtectedResource) {
+ public DiskInfoDto getDiskInfo() throws EntException {
+ final String ERROR_EXTRACTING_DISK_INFO = "Error extracting disk info: url %s";
+ URI url = null;
try {
Optional config = getTenantConfig();
- return this.validateAndReturnResourcePath(config, subPath, isProtectedResource);
+ url = CdsUrlUtils.buildCdsInternalApiUrl(config, configuration, "utils", "diskinfo");
+ Optional is = caller.getDiskInfo(url, config);
+ return is.orElseThrow(IOException::new);
+ } catch (EntRuntimeException ert) {
+ throw ert;
+ } catch (Exception e) {
+ String errorMessage = String.format(ERROR_EXTRACTING_DISK_INFO, Optional.ofNullable(url).map(URI::toString).orElse("null"));
+ throw new EntResourceNotFoundException(errorMessage, e);
+ }
+ }
+
+ @Override
+ public String getResourceUrl(String subPath, boolean isProtectedResource) {
+ try {
+ Optional config = this.getTenantConfig();
+ return this.validateAndReturnResourcePath(config, subPath, false, isProtectedResource);
} catch (Exception e) {
throw new EntRuntimeException("Error extracting resource url", e);
}
@@ -183,9 +201,33 @@ public boolean exists(String subPath, boolean isProtectedResource) {
return (null != filenames && isSubPathPresent(filenames,subPathParsed.getFileName()));
}
+ @Override
+ public boolean move(String subPathSource, boolean isProtectedResourceSource, String subPathDest, boolean isProtectedResourceDest) throws EntException {
+ if (!this.exists(subPathSource, isProtectedResourceSource)) {
+ log.error(String.format(
+ "Source File does not exists - path '%s' protected '%s'",
+ subPathSource, isProtectedResourceSource));
+ return false;
+ }
+ if (this.exists(subPathDest, isProtectedResourceDest)) {
+ log.error(String.format(
+ "Destination already exists - path '%s' protected '%s'",
+ subPathDest, isProtectedResourceDest));
+ return false;
+ }
+ try {
+ InputStream stream = this.getStream(subPathSource, isProtectedResourceSource);
+ this.saveFile(subPathDest, isProtectedResourceDest, stream);
+ this.deleteFile(subPathSource, isProtectedResourceSource);
+ } catch (Exception e) {
+ throw new EntException("Error moving file", e);
+ }
+ return true;
+ }
+
// when frontend wants to retrieve public or protected folder contents it gets request with an empty subpath
private boolean isSubPathPresent(String[] filenames, String subPath){
- if(StringUtils.isEmpty(subPath)) {
+ if (StringUtils.isEmpty(subPath)) {
return filenames.length > 0;
} else {
return Arrays.asList(filenames).contains(subPath);
@@ -240,15 +282,15 @@ public BasicFileAttributeView[] listFileAttributes(String subPath, boolean isPro
private List listAttributes(String subPath, boolean isProtectedResource, CdsFilter filter) {
Optional config = this.getTenantConfig();
- this.validateAndReturnResourcePath(config, subPath, isProtectedResource);
+ this.validateAndReturnResourcePath(config, subPath, true, isProtectedResource);
URI apiUrl = EntUrlBuilder.builder()
.url(CdsUrlUtils.buildCdsInternalApiUrl(config, configuration).toString())
.path("/list/")
- .path(CdsUrlUtils.getInternalSection(isProtectedResource))
+ .path(CdsUrlUtils.getSection(isProtectedResource, config, this.configuration, true))
.path(subPath)
.build();
-
+
Optional cdsFileList = caller.getFileAttributeView(apiUrl, config);
return remapAndSort(cdsFileList, filter);
@@ -310,22 +352,19 @@ private Optional getTenantConfig() {
}
- private String validateAndReturnResourcePath(Optional config, String resourceRelativePath, boolean privateUrl) {
+ private String validateAndReturnResourcePath(Optional config, String resourceRelativePath, boolean privateCall, boolean privateUrl) {
try {
String baseUrl = EntUrlBuilder.builder()
.url(CdsUrlUtils.fetchBaseUrl(config, configuration, privateUrl))
- .path(CdsUrlUtils.getInternalSection(privateUrl)) // << this is part of base url because we want check path traversal!!
+ .path(CdsUrlUtils.getSection(privateUrl, config, this.configuration, privateCall))
.build().toString();
-
String fullPath = EntUrlBuilder.builder()
.url(baseUrl)
.path(resourceRelativePath)
.build().toString();
-
if (!StorageManagerUtil.doesPathContainsPath(baseUrl, fullPath, true)) {
throw mkPathValidationErr(baseUrl, fullPath);
}
-
return fullPath;
} catch (IOException e) {
throw new EntRuntimeException(ERROR_VALIDATING_PATH_MSG, e);
@@ -355,4 +394,18 @@ public enum CdsFilter {
DIRECTORY,
ALL;
}
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ WebApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext();
+ if (ctx == null) {
+ log.warn("Null WebApplicationContext during deserialization");
+ return;
+ }
+ this.tenantManager = ctx.getBean(ITenantManager.class);
+ this.configuration = ctx.getBean(CdsConfiguration.class);
+ this.caller = ctx.getBean(CdsRemoteCaller.class);
+ }
+
}
diff --git a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsUrlUtils.java b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsUrlUtils.java
index b62d3d5a47..8171c94549 100644
--- a/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsUrlUtils.java
+++ b/cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsUrlUtils.java
@@ -29,28 +29,34 @@ public final class CdsUrlUtils {
private static final String CDS_PUBLIC_URL_TENANT_PARAM = "cdsPublicUrl";
private static final String CDS_PRIVATE_URL_TENANT_PARAM = "cdsPrivateUrl";
+ private static final String CDS_PUBLIC_PATH_TENANT_PARAM = "cdsPublicPath";
+ private static final String CDS_INTERNAL_PUBLIC_SECTION_TENANT_PARAM = "cdsInternalPublicSection";
private static final String CDS_PATH_TENANT_PARAM = "cdsPath";
private static final String URL_SEP = "/";
- private static final String SECTION_PUBLIC = "/public";
- private static final String SECTION_PRIVATE = "/protected";
+ private static final String DEFAULT_SECTION_PUBLIC = "";
+ private static final String DEFAULT_SECTION_PRIVATE = "/protected";
private CdsUrlUtils(){
}
-
- public static String getInternalSection(boolean isProtectedResource) {
- return (isProtectedResource) ? SECTION_PRIVATE : SECTION_PUBLIC;
+
+ public static String getSection(boolean isProtectedResource, Optional config, CdsConfiguration configuration, boolean internalCall) {
+ if (isProtectedResource) {
+ return DEFAULT_SECTION_PRIVATE;
+ }
+ if (internalCall) {
+ return config.map(c -> c.getProperty(CDS_INTERNAL_PUBLIC_SECTION_TENANT_PARAM).orElse(DEFAULT_SECTION_PUBLIC)).orElse(configuration.getCdsInternalPublicSection());
+ } else {
+ return config.map(c -> c.getProperty(CDS_PUBLIC_PATH_TENANT_PARAM).orElse(DEFAULT_SECTION_PUBLIC)).orElse(configuration.getCdsPublicPath());
+ }
}
-
+
public static URI buildCdsExternalPublicResourceUrl(Optional config, CdsConfiguration configuration, String ... paths){
log.debug("Trying to build CDS external public url with is tenant config empty:'{}', CDS primary configuration public url:'{}' and paths:'{}'",
config.isEmpty(),
configuration.getCdsPublicUrl(),
paths);
-
String publicUrl = config.flatMap(c -> c.getProperty(CDS_PUBLIC_URL_TENANT_PARAM)).orElse(configuration.getCdsPublicUrl());
-
return EntUrlBuilder.builder().url(publicUrl).paths(paths).build();
-
}
public static URI buildCdsInternalApiUrl(Optional config, CdsConfiguration configuration, String ... paths){
@@ -59,10 +65,8 @@ public static URI buildCdsInternalApiUrl(Optional config, CdsConfi
configuration.getCdsPrivateUrl(),
configuration.getCdsPath(),
paths);
-
String apiUrl = config.flatMap(c -> c.getProperty(CDS_PRIVATE_URL_TENANT_PARAM)).orElse(configuration.getCdsPrivateUrl());
String basePath = config.flatMap(c -> c.getProperty(CDS_PATH_TENANT_PARAM)).orElse(configuration.getCdsPath());
-
return EntUrlBuilder.builder().url(apiUrl).path(basePath).paths(paths).build();
}
diff --git a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfigurationTest.java b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfigurationTest.java
index 13a9e0f698..5fff824a7f 100644
--- a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfigurationTest.java
+++ b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsConfigurationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
+ * Copyright 2024-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -15,7 +15,6 @@
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Value;
class CdsConfigurationTest {
diff --git a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsCreateRowResponseDtoTest.java b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsCreateRowResponseDtoTest.java
index 7cc7c9c467..f0819dc938 100644
--- a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsCreateRowResponseDtoTest.java
+++ b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsCreateRowResponseDtoTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
+ * Copyright 2024-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -13,7 +13,6 @@
*/
package org.entando.entando.plugins.jpcds.aps.system.storage;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
diff --git a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsFileAttributeViewDtoTest.java b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsFileAttributeViewDtoTest.java
index c87b6212a2..51f636938f 100644
--- a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsFileAttributeViewDtoTest.java
+++ b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsFileAttributeViewDtoTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
+ * Copyright 2024-Present Entando S.r.l. (http://www.entando.com) All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -13,13 +13,11 @@
*/
package org.entando.entando.plugins.jpcds.aps.system.storage;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import lombok.ToString;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
diff --git a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCallerTest.java b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCallerTest.java
index 3e3d392740..440f2069ce 100644
--- a/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCallerTest.java
+++ b/cds-plugin/src/test/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsRemoteCallerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-Present Entando Inc. (http://www.entando.com) All rights reserved.
+ * Copyright 2024-Present Entando Inc. (http://www.entando.com) All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -13,6 +13,8 @@
*/
package org.entando.entando.plugins.jpcds.aps.system.storage;
+import org.entando.entando.aps.system.services.storage.model.DiskInfoDto;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -20,6 +22,7 @@
import static org.mockito.ArgumentMatchers.eq;
import com.agiletec.aps.util.ApsTenantApplicationUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
@@ -31,10 +34,7 @@
import org.apache.commons.io.IOUtils;
import org.entando.entando.aps.system.services.tenants.TenantConfig;
import org.entando.entando.ent.exception.EntRuntimeException;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@@ -51,14 +51,14 @@
@ExtendWith(MockitoExtension.class)
class CdsRemoteCallerTest {
+
@InjectMocks
private CdsRemoteCaller cdsRemoteCaller;
@Mock
private RestTemplate restTemplate;
@Mock
private CdsConfiguration cdsConfiguration;
-
-
+
@Test
void shouldCreateDirectoryForTenant() throws Exception {
Map configMap = Map.of("cdsPublicUrl","http://my-server/tenant1/cms-resources",
@@ -171,8 +171,6 @@ void shouldManageErrorInExecutePostCall() throws Exception {
Assertions.assertEquals(
"Invalid operation 'POST', response status:'502 BAD_GATEWAY' for url:'http://cds-kube-service:8081/mytenant/api/v1/upload/'",
ex.getMessage());
-
-
Mockito.when(restTemplate.exchange(eq(url),eq(HttpMethod.POST),any(), eq(new ParameterizedTypeReference>(){})))
.thenThrow(new HttpClientErrorException(HttpStatus.UNAUTHORIZED));
Mockito.when(restTemplate.exchange(eq(auth.toString()),
@@ -180,7 +178,6 @@ void shouldManageErrorInExecutePostCall() throws Exception {
any(),
eq(new ParameterizedTypeReference