Skip to content

Commit

Permalink
#28706 use the dotasset variable when getting metadata for a dotasset (
Browse files Browse the repository at this point in the history
…#28803)

Use the dotAsset variable when retrieving metadata for a dotAsset image.
Postman test included.
  • Loading branch information
dsilvam authored Jun 7, 2024
1 parent 75e0d68 commit 7b54550
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;

import static com.dotcms.contenttype.model.type.DotAssetContentType.ASSET_FIELD_VAR;

public class TitleImageFieldDataFetcher implements DataFetcher<Map<String, Object>> {

private static final String FILE_ASSET = FileAssetAPI.BINARY_FIELD;
Expand Down Expand Up @@ -54,7 +56,8 @@ public Map<String, Object> get(final DataFetchingEnvironment environment) throws
final Contentlet imageContentlet = imageContentletOptional.get();

if (imageContentlet.getTitleImage().isPresent()) {
final Metadata imageFile = imageContentletOptional.get().getBinaryMetadata(FILE_ASSET);
final String fileVariable = imageContentlet.isDotAsset() ? ASSET_FIELD_VAR : FILE_ASSET;
final Metadata imageFile = imageContentletOptional.get().getBinaryMetadata(fileVariable);

titleImageMap = BinaryToMapTransformer.transform(imageFile, imageContentlet, imageContentlet.getTitleImage().get());
}
Expand Down
Loading

0 comments on commit 7b54550

Please sign in to comment.