diff --git a/services/src/main/java/org/exoplatform/news/storage/jcr/JcrNewsStorage.java b/services/src/main/java/org/exoplatform/news/storage/jcr/JcrNewsStorage.java index 35e8df41cb..26e8d41ee7 100644 --- a/services/src/main/java/org/exoplatform/news/storage/jcr/JcrNewsStorage.java +++ b/services/src/main/java/org/exoplatform/news/storage/jcr/JcrNewsStorage.java @@ -1248,7 +1248,7 @@ private void updateNewsImagesPermissions(News news, SessionProvider sessionProvi if (matcher.find()) { updateNewsImagesPermissions(news, sessionProvider,space, IMAGE_SRC_REGEX); } else { - String existingUploadImagesSrcRegex = "src=\"" + RestUtils.getBaseRestUrl() + "/jcr/?(.+)?\""; + String existingUploadImagesSrcRegex = "src=\"" + CommonsUtils.getCurrentDomain() + "/" + PortalContainer.getCurrentPortalContainerName() + "/" + CommonsUtils.getRestContextName() + "/jcr/?(.+)?\""; updateNewsImagesPermissions(news, sessionProvider,space, existingUploadImagesSrcRegex); } } diff --git a/services/src/test/java/org/exoplatform/news/storage/jcr/JcrNewsStorageTest.java b/services/src/test/java/org/exoplatform/news/storage/jcr/JcrNewsStorageTest.java index d139dd3209..c187677208 100644 --- a/services/src/test/java/org/exoplatform/news/storage/jcr/JcrNewsStorageTest.java +++ b/services/src/test/java/org/exoplatform/news/storage/jcr/JcrNewsStorageTest.java @@ -85,7 +85,6 @@ public class JcrNewsStorageTest { private static final MockedStatic PORTAL_CONTAINER = mockStatic(PortalContainer.class); - private static final MockedStatic REST_UTILS = mockStatic(RestUtils.class); @Mock RepositoryService repositoryService; @@ -163,7 +162,6 @@ public class JcrNewsStorageTest { public static void afterRunBare() throws Exception { // NOSONAR COMMONS_UTILS.close(); PORTAL_CONTAINER.close(); - REST_UTILS.close(); } @Test @@ -1170,8 +1168,12 @@ public void shouldPublishNews() throws Exception { // ExtendedNode existingUploadedNewsImageNode = mock(ExtendedNode.class); String nodePath = "Groups/spaces/test/testimage"; - String baseRestUrl = "https://exoplatform.com/portal/rest"; - REST_UTILS.when(() -> RestUtils.getBaseRestUrl()).thenReturn(baseRestUrl); + String currentDomainName = "https://exoplatform.com"; + String currentPortalContainerName = "portal"; + String restContextName = "rest"; + COMMONS_UTILS.when(() -> CommonsUtils.getRestContextName()).thenReturn(restContextName); + PORTAL_CONTAINER.when(() -> PortalContainer.getCurrentPortalContainerName()).thenReturn(currentPortalContainerName); + COMMONS_UTILS.when(() -> CommonsUtils.getCurrentDomain()).thenReturn(currentDomainName); news.setBody("news body with image src=\"https://exoplatform.com/portal/rest/jcr/repository/collaboration/Groups/spaces/test/testimage\""); when(session.getItem(nullable(String.class))).thenReturn(existingUploadedNewsImageNode); when(jcrNewsStorageSpy.getNodeByPath(nodePath, sessionProvider)).thenReturn(existingUploadedNewsImageNode);