Skip to content

Commit

Permalink
fix : enable to display published news images selected from existing …
Browse files Browse the repository at this point in the history
…upload for non members - EXO-65111 (#875)
  • Loading branch information
sofyenne committed Jul 7, 2023
1 parent 94d07a5 commit db5534b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class JcrNewsStorageTest {

private static final MockedStatic<PortalContainer> PORTAL_CONTAINER = mockStatic(PortalContainer.class);

private static final MockedStatic<RestUtils> REST_UTILS = mockStatic(RestUtils.class);

@Mock
RepositoryService repositoryService;
Expand Down Expand Up @@ -163,7 +162,6 @@ public class JcrNewsStorageTest {
public static void afterRunBare() throws Exception { // NOSONAR
COMMONS_UTILS.close();
PORTAL_CONTAINER.close();
REST_UTILS.close();
}

@Test
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit db5534b

Please sign in to comment.