From a2a38d9bd220e0507867679ca5873c8238c06be8 Mon Sep 17 00:00:00 2001 From: erickgonzalez Date: Wed, 4 Sep 2024 11:17:40 -0600 Subject: [PATCH] #29259 include in 23.10.24 LTS --- dotCMS/hotfix_tracking.md | 3 ++- .../contentlet/transform/strategy/FileViewStrategy.java | 1 + .../portlets/fileassets/business/FileAssetAPIImpl.java | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index d4b7e15191f9..6a5837d6aa67 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -144,4 +144,5 @@ This maintenance release includes the following code fixes: 137. https://github.com/dotCMS/core/issues/29209 : Wrong url when exporting file asset #29209 138. https://github.com/dotCMS/core/issues/29222 : Telemetry: not getting data after last release of the plugin #29222 139. https://github.com/dotCMS/core/issues/29254 : Add a new main tag for LTSs #29254 -140. https://github.com/dotCMS/core/issues/28857 : dotAsset is Breaking FileViewStrategy #28857 \ No newline at end of file +140. https://github.com/dotCMS/core/issues/28857 : dotAsset is Breaking FileViewStrategy #28857 +141. https://github.com/dotCMS/core/issues/29259 : Page API: Image field content gone when request page with depth #29259 \ No newline at end of file diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/FileViewStrategy.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/FileViewStrategy.java index 69027124d72f..54f3f0707736 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/FileViewStrategy.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/FileViewStrategy.java @@ -114,6 +114,7 @@ public Map transform(final Field field, final Contentlet content //This does always assume we're getting a fileAsset we don't want to miss a dotAsset final Contentlet incoming = fileAsContentOptional.get(); if(incoming.isDotAsset()){ + incoming.setProperty(FileAssetAPI.BINARY_FIELD, Try.of(()->incoming.getBinary("asset")).getOrNull()); fileAsset = convertToFileAsset(incoming, fileAssetAPI); } else { fileAsset = fileAssetAPI.fromContentlet(incoming); diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/fileassets/business/FileAssetAPIImpl.java b/dotCMS/src/main/java/com/dotmarketing/portlets/fileassets/business/FileAssetAPIImpl.java index 0c7164a6fd3a..4d6726c17396 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/fileassets/business/FileAssetAPIImpl.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/fileassets/business/FileAssetAPIImpl.java @@ -268,11 +268,13 @@ public FileAsset fromContentlet(final Contentlet con) throws DotStateException { throw new DotStateException("Content -> FileAsset Copy Failed :" + e.getMessage(), e); } fileAsset.setHost(con.getHost()); + Contentlet originalContentlet = null; if(UtilMethods.isSet(con.getFolder())){ try{ final Identifier ident = APILocator.getIdentifierAPI().find(con); final Host host = APILocator.getHostAPI().find(con.getHost(), APILocator.systemUser() , false); final Folder folder = APILocator.getFolderAPI().findFolderByPath(ident.getParentPath(), host, APILocator.systemUser(), false); + originalContentlet = APILocator.getContentletAPI().find(con.getInode(), APILocator.systemUser(), false); fileAsset.setFolder(folder.getInode()); }catch(Exception e){ try{ @@ -285,7 +287,9 @@ public FileAsset fromContentlet(final Contentlet con) throws DotStateException { } fileAsset.setVariantId(con.getVariantId()); - this.contentletCache.add(fileAsset); + if (null != originalContentlet && !originalContentlet.isDotAsset()){ + this.contentletCache.add(fileAsset); + } return fileAsset; }