Skip to content

Commit

Permalink
#2734 return handling of one-off cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Mar 27, 2020
1 parent c468519 commit 75b21e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,24 @@ public String getOriginalFileName() {
DataTable dataTable = getDataTable();
if (dataTable != null) {
return dataTable.getOriginalFileName() != null ? dataTable.getOriginalFileName()
: getFileMetadata().getLabel().replaceAll(".tab$", FileUtil.generateOriginalExtension(getOriginalFileFormat()));
: getDerivedOriginalFileName();
}
}
return null;
}


private String getDerivedOriginalFileName() {
FileMetadata fm = getFileMetadata();
String filename = fm.getLabel();
String originalExtension = FileUtil.generateOriginalExtension(getOriginalFileFormat());
String extensionToRemove = StringUtil.substringIncludingLast(filename, ".");
if (StringUtil.nonEmpty(extensionToRemove)) {
return filename.replaceAll(extensionToRemove + "$", originalExtension);
} else{
return filename + originalExtension ;
}
}

@Override
public boolean isAncestorOf( DvObject other ) {
Expand Down

0 comments on commit 75b21e3

Please sign in to comment.