Skip to content

Commit

Permalink
Issue 29259 (#29656)
Browse files Browse the repository at this point in the history
The issue was being generated because of the addition of an image as
dotAsset, if it was a File Asset, then everything was working ok.

- To solve the removal of the image a check was added to see if it is a
dotAsset, then avoid to cache the data.
- To solve the missing data in the related content, "fileAsset" was
added into the dotAsset properties with the data that "asset" property
had, this workaround is to make the mapping of the fields like a File
Asset.
  • Loading branch information
gortiz-dotcms authored Aug 22, 2024
1 parent 0b665e2 commit 78dafd3
Show file tree
Hide file tree
Showing 3 changed files with 7,347 additions and 6,817 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public Map<String, Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit 78dafd3

Please sign in to comment.