Skip to content

Commit

Permalink
#24093 Ignoring File Asset metadata legacy field, migrating that fiel…
Browse files Browse the repository at this point in the history
…d could cause issues and the value either way is always ignored, metadata is calculated directly from the asset.
  • Loading branch information
jgambarios committed Apr 13, 2023
1 parent b275da2 commit cfa302b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ private static Contentlet transform(final Map<String, Object> map) {

try {
if(!hasJsonFields) {
contentlet.setProperty(Contentlet.TITTLE_KEY, map.get(Contentlet.TITTLE_KEY));
populateFields(contentlet, map);
}
refreshStoryBlockReferences(contentlet);
Expand Down Expand Up @@ -246,11 +245,15 @@ private static void populateWysiwyg(final Map<String, Object> map, Contentlet co
*/
private static void populateFields(final Contentlet contentlet, final Map<String, Object> originalMap)
throws DotDataException, DotSecurityException {

final Map<String, Object> fieldsMap = new HashMap<>();
final String inode = (String) originalMap.get(INODE);
final String identifier = (String) originalMap.get(IDENTIFIER);
final String contentTypeId = (String) originalMap.get(STRUCTURE_INODE);

// Populate the title
contentlet.setProperty(Contentlet.TITTLE_KEY, originalMap.get(Contentlet.TITTLE_KEY));

final ContentType contentType = APILocator.getContentTypeAPI(APILocator.systemUser())
.find(contentTypeId);
final List<Field> fields = new LegacyFieldTransformer(contentType.fields())
Expand All @@ -277,6 +280,11 @@ private static void populateFields(final Contentlet contentlet, final Map<String
&& FileAssetAPI.FILE_NAME_FIELD
.equals(field.getVelocityVarName())) {
value = APILocator.getIdentifierAPI().find(identifier).getAssetName();
} else if (UtilMethods.isSet(identifier)
&& contentType instanceof FileAssetContentType
&& FileAssetAPI.META_DATA_FIELD.equals(field.getVelocityVarName())) {
// We can ignore this metadata field, metadata will be generated directly from the asset
value = Collections.emptyMap();
} else {
if (LegacyFieldTypes.BINARY.legacyValue()
.equals(field.getFieldType())) {
Expand Down

0 comments on commit cfa302b

Please sign in to comment.