Skip to content

Commit

Permalink
#22867 cherry pick done
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Nov 28, 2022
1 parent 43630f8 commit fc1224e
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 155 deletions.
2 changes: 1 addition & 1 deletion core-web/libs/dotcms-webcomponents/src/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function encodeChars(value: string): string {
* @param string value
* @returns string
*/
export function decodeChars(value: string): string {
export function decodeChars(value: string): string {
let decodedValue = value
.replace(/"/gi, '"')
.replace(/\/gi, '\\')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.dotcms.contenttype.business;

import com.dotcms.IntegrationTestBase;
Expand All @@ -11,6 +12,7 @@
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.liferay.util.StringPool;
import io.vavr.Tuple2;
import io.vavr.control.Try;
import org.junit.Assert;
import org.junit.BeforeClass;
Expand All @@ -29,7 +31,7 @@ public class StoryBlockAPITest extends IntegrationTestBase {

private static final String JSON =

"{\n" +
"{\n" +
" \"type\":\"doc\",\n" +
" \"content\":[\n" +
" {\n" +
Expand Down Expand Up @@ -114,7 +116,7 @@ public void test_refresh_references() throws DotDataException, DotSecurityExcept
Assert.assertNotNull(newStoryBlockMap);
final List contentList = (List) newStoryBlockMap.get("content");
final Optional<Object> firstContentletMap = contentList.stream()
.filter(content -> "dotContent".equals(Map.class.cast(content).get("type"))).findFirst();
.filter(content -> "dotContent".equals(Map.class.cast(content).get("type"))).findFirst();

Assert.assertTrue(firstContentletMap.isPresent());
final Map contentletMap = (Map) Map.class.cast(Map.class.cast(firstContentletMap.get()).get(StoryBlockAPI.ATTRS_KEY)).get(StoryBlockAPI.DATA_KEY);
Expand Down Expand Up @@ -174,6 +176,7 @@ public void test_get_dependencies() throws DotDataException, DotSecurityExceptio
.readValue(Try.of(() -> newStoryBlockJson3.toString())
.getOrElse(StringPool.BLANK), LinkedHashMap.class);


Assert.assertNotNull(newStoryBlockMap);
final List<String> contentletIdList = APILocator.getStoryBlockAPI().getDependencies(newStoryBlockJson3);
Assert.assertNotNull(contentletIdList);
Expand All @@ -182,4 +185,4 @@ public void test_get_dependencies() throws DotDataException, DotSecurityExceptio
Assert.assertTrue(contentletIdList.contains(richTextContentlet2.getIdentifier()));
Assert.assertTrue(contentletIdList.contains(richTextContentlet3.getIdentifier()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.dotcms.content.elasticsearch.ESQueryCache;
import com.dotcms.content.elasticsearch.util.RestHighLevelClientProvider;
import com.dotcms.contenttype.business.StoryBlockReferenceResult;
import com.dotcms.contenttype.model.field.DataTypes;
import com.dotcms.contenttype.model.type.BaseContentType;
import com.dotcms.enterprise.license.LicenseManager;
import com.dotcms.exception.ExceptionUtil;
Expand Down Expand Up @@ -73,6 +74,7 @@
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import com.liferay.portal.model.User;
import io.vavr.Tuple2;
import io.vavr.control.Try;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -890,6 +892,7 @@ private Contentlet processCachedContentlet(final Contentlet cachedContentlet) {
if (storyBlockRefreshedResult.isRefreshed()) {
Logger.debug(this, () -> String.format("Refreshed Story Block dependencies for Contentlet '%s'",
cachedContentlet.getIdentifier()));

final Contentlet refreshedContentlet = (Contentlet) storyBlockRefreshedResult.getValue();
contentletCache.add(refreshedContentlet.getInode(), refreshedContentlet);
return refreshedContentlet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public interface StoryBlockAPI {
* @param contentlet The Contentlet containing the Story Block field(s).
*
* @return The {@link StoryBlockReferenceResult} object containing the final result of the refreshing process.
* Encapsulates the allowed types for contentlets on the story block
*/

StoryBlockReferenceResult refreshReferences(final Contentlet contentlet);

/**
Expand Down

0 comments on commit fc1224e

Please sign in to comment.