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

Fixed AnIML converter reading unrelated files and crashing #215

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class ChromatogramMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class MassSpectrumMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class ChromatogramReader extends AbstractChromatogramMSDReader {
@Override
public IChromatogramMSD read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorChromatogram chromatogram = null;
try {
AnIMLType animl = XmlReader.getAnIML(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class MassSpectrumReader extends AbstractMassSpectraReader implements IMa
@Override
public IMassSpectra read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorStandaloneMassSpectrum massSpectrum = null;
//
try {
Expand Down