Skip to content

Commit

Permalink
better logging in case creation of substructure failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hig committed Oct 19, 2022
1 parent 9788e58 commit 15bacfa
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,17 @@ private Person createPerson(String cellContent, MappingField mappingField) throw
* @throws MetadataTypeNotAllowedException
* @throws TypeNotAllowedAsChildException
*/
private void addMetadata(DocStruct ds, MappingField mappingField, String cellContent)
throws MetadataTypeNotAllowedException, TypeNotAllowedAsChildException {
private void addMetadata(DocStruct ds, MappingField mappingField, String cellContent) throws MetadataTypeNotAllowedException {
switch (mappingField.getType()) {
case "personWithGnd":
if (StringUtils.isBlank(mappingField.getMets())) {
if (StringUtils.isBlank(mappingField.getEad())) {
plugin.updateLogAndProcess(process.getId(), "No Mets provided. Please update the Mapping " + importSet.getMapping(), 3);
}

return;
}
if (StringUtils.isBlank(cellContent)) {
plugin.updateLogAndProcess(process.getId(), "No content to create Person was provided in Column " + mappingField.getColumn(), 3);
return;
}
String gnd = cellContent.substring(cellContent.lastIndexOf(mappingField.getSeparator()) + 1).trim();
Expand Down Expand Up @@ -288,7 +290,12 @@ private void addMetadata(DocStruct ds, MappingField mappingField, String cellCon
}
Metadata md = new Metadata(prefs.getMetadataTypeByName(mappingField.getMets()));
md.setValue(cellContent);
ds.addMetadata(md);
try {
ds.addMetadata(md);
} catch (DocStructHasNoTypeException ex) {
plugin.updateLogAndProcess(process.getId(),
"DocStruct has no type! This may happen if you specified an invalid type (i.e. Chapter) for sub elements", 3);
}
break;
case "FileName":
//do nothhing
Expand Down

0 comments on commit 15bacfa

Please sign in to comment.