diff --git a/service/src/main/java/gov/nasa/pds/api/registry/model/Pds4ProductFactory.java b/service/src/main/java/gov/nasa/pds/api/registry/model/Pds4ProductFactory.java index 402a7dff..4f97c059 100644 --- a/service/src/main/java/gov/nasa/pds/api/registry/model/Pds4ProductFactory.java +++ b/service/src/main/java/gov/nasa/pds/api/registry/model/Pds4ProductFactory.java @@ -13,7 +13,7 @@ /** * Creates Pds4Product object from opensearch key-value field map. - * + * * @author karpenko */ public class Pds4ProductFactory { @@ -46,7 +46,7 @@ public class Pds4ProductFactory { /** * Create Pds4Product object from opensearch key-value field map. - * + * * @param lidvid product LIDVID * @param fieldMap key-value field map * @return new Pds4Product object @@ -137,11 +137,15 @@ private static Pds4MetadataOpsLabelFileInfo createLabelFile(Map @SuppressWarnings("rawtypes") private static List createDataFiles(Map fieldMap) { - List items = new ArrayList(); ArrayList vals = (ArrayList) fieldMap.get(FLD_DATA_FILE_NAME); - Pds4MetadataOpsDataFile item = new Pds4MetadataOpsDataFile(); + if (vals == null) { + return new ArrayList(); + } + + List items = new ArrayList(); for (int i = 0; i < ((List) vals).size(); i++) { + Pds4MetadataOpsDataFile item = new Pds4MetadataOpsDataFile(); item.setOpsColonFileName((String) ((List) fieldMap.get(FLD_DATA_FILE_CREATION)).get(i)); item.setOpsColonCreationDate((String) ((List) fieldMap.get(FLD_DATA_FILE_CREATION)).get(i)); item.opsColonFileRef((String) ((List) fieldMap.get(FLD_DATA_FILE_REF)).get(i)); @@ -149,8 +153,8 @@ private static List createDataFiles(Map item.setOpsColonMd5Checksum((String) ((List) fieldMap.get(FLD_DATA_FILE_MD5)).get(i)); item.setOpsColonMimeType((String) ((List) fieldMap.get(FLD_DATA_FILE_MIME_TYPE)).get(i)); items.add(item); - item = new Pds4MetadataOpsDataFile(); } + return items; }