[CST-7756] If no crosswalk is defined for the Item's entity type, default generic Item one is applied

This commit is contained in:
corrado lombardi
2023-02-07 18:52:35 +01:00
parent 31bd28e80c
commit 6190e337ac

View File

@@ -16,8 +16,8 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.content.Item; import org.dspace.content.Item;
@@ -74,9 +74,10 @@ public class ContentGenerator implements SubscriptionGenerator<IndexableObject>
for (IndexableObject indexableObject : indexableObjects) { for (IndexableObject indexableObject : indexableObjects) {
out.write("\n".getBytes(UTF_8)); out.write("\n".getBytes(UTF_8));
Item item = (Item) indexableObject.getIndexedObject(); Item item = (Item) indexableObject.getIndexedObject();
String entityType = StringUtils.defaultIfBlank(itemService.getEntityTypeLabel(item), String entityType = itemService.getEntityTypeLabel(item);
"Item"); Optional.ofNullable(entityType2Disseminator.get(entityType))
entityType2Disseminator.get(entityType).disseminate(context, item, out); .orElseGet(() -> entityType2Disseminator.get("Item"))
.disseminate(context, item, out);
} }
return out.toString(); return out.toString();
} else { } else {