|
46 | 46 | * |
47 | 47 | */ |
48 | 48 | public class IngestFolderCreate extends DefaultImporter { |
49 | | - private static enum IngestStatsItems implements StatsItemEnum { |
| 49 | + static enum IngestStatsItems implements StatsItemEnum { |
50 | 50 | LineNo(StatsItem.makeStringStatsItem("Line No").setExport(false).setWidth(60)), |
51 | 51 | Folder(StatsItem.makeStringStatsItem("Folder")), |
52 | 52 | Status(StatsItem.makeEnumStatsItem(status.class, "Status").setWidth(60)), |
@@ -104,9 +104,9 @@ class column { |
104 | 104 |
|
105 | 105 | } |
106 | 106 |
|
107 | | - private static enum FileStats {NA, NOT_FOUND, ERROR, ALREADY_EXISTS, MOVED_TO_INGEST, COPIED_TO_INGEST;} |
108 | | - private static enum MetaStats {NA, ERROR, CREATED, OVERWRITTEN;} |
109 | | - private static enum InputMetaStats {NA, MISSING, FORMAT_ERROR, DUPLICATE, OK;} |
| 107 | + static enum FileStats {NA, NOT_FOUND, ERROR, ALREADY_EXISTS, MOVED_TO_INGEST, COPIED_TO_INGEST;} |
| 108 | + static enum MetaStats {NA, ERROR, CREATED, OVERWRITTEN;} |
| 109 | + static enum InputMetaStats {NA, MISSING, FORMAT_ERROR, DUPLICATE, OK;} |
110 | 110 | class CreateException extends Exception { |
111 | 111 | private static final long serialVersionUID = 5042987495219000857L; |
112 | 112 |
|
@@ -166,7 +166,7 @@ public String getDescription() { |
166 | 166 | "\t3) Thumbnail file name - optional, file must exist if present\n"+ |
167 | 167 | "\t4) License file name - optional, file must exist if present\n"+ |
168 | 168 | "\tAddition columns should have a dublin core field name in their header. Columns without a 'dc.' header will be ignored\n" + |
169 | | - "A title (dc.title) and a properly formatted creation date (dc.date.created) must be present somewhere in the set of additional columns."; |
| 169 | + validateRowDescription(); |
170 | 170 | } |
171 | 171 | public String getShortName() { |
172 | 172 | return "Ingest Folder"; |
@@ -373,6 +373,16 @@ public ActionResult importFile(File selectedFile) throws IOException { |
373 | 373 | return new ActionResult(selectedFile, selectedFile.getName(), this.toString(), getDetails(), types, true, timer.getDuration()); |
374 | 374 | } |
375 | 375 |
|
| 376 | + public String validateRowDescription() { |
| 377 | + return "A title (dc.title) must be present ."; |
| 378 | + } |
| 379 | + public void validateRow(Vector<String> cols,Stats stats) throws CreateException { |
| 380 | + if (!hasColumnValue(cols, "dc.title")) { |
| 381 | + stats.setVal(IngestStatsItems.InputMetadata, InputMetaStats.MISSING); |
| 382 | + throw new CreateException("Item must have element [dc.title]"); |
| 383 | + } |
| 384 | + } |
| 385 | + |
376 | 386 | public void importRow(File selectedFile, Vector<String> cols,Stats stats, String globalThumb, String globalLicense) { |
377 | 387 | StringBuffer buf = new StringBuffer(); |
378 | 388 | try { |
@@ -433,23 +443,7 @@ public void importRow(File selectedFile, Vector<String> cols,Stats stats, String |
433 | 443 | } |
434 | 444 | } |
435 | 445 |
|
436 | | - if (!hasColumnValue(cols, "dc.title")) { |
437 | | - stats.setVal(IngestStatsItems.InputMetadata, InputMetaStats.MISSING); |
438 | | - throw new CreateException("Item must have element [dc.title]"); |
439 | | - } else if (!hasColumnValue(cols, "dc.date.created")) { |
440 | | - stats.setVal(IngestStatsItems.InputMetadata, InputMetaStats.MISSING); |
441 | | - throw new CreateException("Item must have element [dc.date.created]"); |
442 | | - } else { |
443 | | - for(column col: colHeaderDefs) { |
444 | | - if (col.valid && col.element.equals("date")) { |
445 | | - String val = getColumnValue(cols, col.name, ""); |
446 | | - if (!testDate(val)) { |
447 | | - stats.setVal(IngestStatsItems.InputMetadata, InputMetaStats.FORMAT_ERROR); |
448 | | - throw new CreateException(col.name +" [" + val + "] must start with either YYYY-MM-DD, YYYY-MM, YYYY or 'No Date'."); |
449 | | - } |
450 | | - } |
451 | | - } |
452 | | - } |
| 446 | + validateRow(cols, stats); |
453 | 447 | stats.setVal(IngestStatsItems.InputMetadata, InputMetaStats.OK); |
454 | 448 |
|
455 | 449 | testFile(stats, IngestStatsItems.ItemFileStats, selectedFile, folder, file); |
|
0 commit comments