Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of OME-TIFF multi-file filesets with partial metadata blocks #2314

Merged
merged 2 commits into from
Apr 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions components/formats-bsd/src/loci/formats/in/OMETiffReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ public boolean isThisType(String name, boolean open) {
}
metaFile = new Location(name).getAbsolutePath();
boolean valid = super.isThisType(name, open);
if (metadataFile != null) {
// this is a binary-only file
// overwrite XML with what is in the companion OME-XML file
String dir = new File(metaFile).getParent();
Location path = new Location(dir, metadataFile);
LOGGER.debug("Checking metadata file {}", path);
if (!path.exists()) return false;
metadataFile = path.getAbsolutePath();

try {
String xml = readMetadataFile();
service.createOMEXMLMetadata(xml);
} catch (ServiceException se) {
LOGGER.debug("OME-XML parsing failed", se);
return false;
} catch (IOException e) {
return false;
} catch (NullPointerException e) {
return false;
}
}
if (valid && !isGroupFiles()) {
try {
return isSingleFile(metaFile);
Expand Down Expand Up @@ -215,11 +236,10 @@ else if (description instanceof String) {
meta = service.createOMEXMLMetadata(comment);

try {
String metadataFile = meta.getBinaryOnlyMetadataFile();
metadataFile = meta.getBinaryOnlyMetadataFile();
// check the suffix to make sure that the MetadataFile is not
// referencing the current OME-TIFF
if (metadataFile != null && !checkSuffix(metadataFile, "ome.tiff") &&
!checkSuffix(metadataFile, "ome.tif"))
if (metadataFile != null)
{
return true;
}
Expand Down