diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java index dcea803793f2182a1ad48fbb4514294dd2839b37..b48c8fb71e8b940730073dff2cfb9f6153aa2a83 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java @@ -127,8 +127,8 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { DOMParser parser = new DOMParser(); try { parser.parse(params.getSource()); - } catch (IOException e) { - throw new InvalidInputDataExecption("IO Problem with a file: " + params.getSource().getSystemId(), e); + } catch (Exception e) { + throw new InvalidInputDataExecption("Problem with a file: " + params.getSource().getSystemId(), e); } Document doc = parser.getDocument(); try { diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java index 43df7989f4a4f6afa884b26760c8167c2820e9ba..2d31cd35462e43417b2176a5a8c7fe23341bd178 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java @@ -115,9 +115,7 @@ public class ComplexZipConverter { if (zef instanceof ModelZipEntryFile) { ModelZipEntryFile modelEntryFile = (ModelZipEntryFile) zef; InputStream is = zipFile.getInputStream(entry); - ConverterParams cParams = new ConverterParams(); - cParams.inputStream(is); - Model model = converter.createModel(cParams); + Model model = converter.createModel(new ConverterParams().inputStream(is, entry.getName())); model.setName(modelEntryFile.getName()); filenameModelMap.put(entry.getName(), model); nameModelMap.put(FilenameUtils.getBaseName(modelEntryFile.getFilename()).toLowerCase(), model); @@ -180,7 +178,7 @@ public class ComplexZipConverter { return true; } else if (name.isEmpty()) { return true; - } else if (name.startsWith(".DS_Store")) { + } else if (name.startsWith(".DS_Store") || name.endsWith(".DS_Store")) { return true; } else if (name.startsWith("__MACOSX")) { return true; @@ -189,7 +187,7 @@ public class ComplexZipConverter { } /** - * Process a single reaction in mapping file (transfomring reaction into + * Process a single reaction in mapping file (transforming reaction into * connection between submodels). * * @param mapping diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java b/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java index 20400e0c8010baf9e814cc906724f3fb36f8062f..3eb7ff6424d87a561478fe089e042fd577ab1449 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java @@ -11,114 +11,122 @@ import org.apache.xerces.xni.parser.XMLInputSource; * * @author Piotr Gawron */ -public class ConverterParams { - /** - * Input stream for the parser. - */ - private InputStream inputStream; - - /** - * Name of the file used as a data input. (not obligatory) - */ - private String filename; - /** - * Should the map be autoresized after parsing or not. Autoresizing will equal - * right with left margin and top with bottom margin. - */ - private boolean sizeAutoAdjust = true; - - /** - * Should the map be formated as SBGN. - */ - private boolean sbgnFormat = false; - - /** - * Set file as input source. - * - * @param fileName - * path to a file that should be parsed. - * @return object with all set parameters - * @throws FileNotFoundException - */ - public ConverterParams filename(String fileName) throws FileNotFoundException { - inputStream = new FileInputStream(fileName); - this.filename = fileName; - return this; - } - - /** - * - * Set input stream as input source. - * - * @param is - * input stream that should be parsed - * @return object with all set parameters - */ - public ConverterParams inputStream(InputStream is) { - this.inputStream = is; - return this; - } - - /** - * @return the source - * @see #source - */ - public XMLInputSource getSource() { - return new XMLInputSource(null, null, null, this.inputStream, null); - } - - /** - * - * @param value - * the sizeAutoAdjust to set - * @see #sizeAutoAdjust - * @return object with all parameters - */ - public ConverterParams sizeAutoAdjust(boolean value) { - sizeAutoAdjust = value; - return this; - } - - /** - * @return the inputStream - * @see #inputStream - */ - public InputStream getInputStream() { - return this.inputStream; - } - - /** - * @return the sizeAutoAdjust - * @see #sizeAutoAdjust - */ - public boolean isSizeAutoAdjust() { - return sizeAutoAdjust; - } - - /** - * @return the filename - * @see #filename - */ - public String getFilename() { - return filename; - } - - /** - * @return the sbgnFormat - * @see #sbgnFormat - */ - public boolean isSbgnFormat() { - return sbgnFormat; - } - - /** - * @param sbgnFormat the sbgnFormat to set - * @return ConverterParams object with all parameters - * @see #sbgnFormat - */ - public ConverterParams sbgnFormat(boolean sbgnFormat) { - this.sbgnFormat = sbgnFormat; - return this; - } +public class ConverterParams { + /** + * Input stream for the parser. + */ + private InputStream inputStream; + + /** + * Name of the file used as a data input. (not obligatory) + */ + private String filename; + /** + * Should the map be autoresized after parsing or not. Autoresizing will equal + * right with left margin and top with bottom margin. + */ + private boolean sizeAutoAdjust = true; + + /** + * Should the map be formated as SBGN. + */ + private boolean sbgnFormat = false; + + /** + * Set file as input source. + * + * @param fileName + * path to a file that should be parsed. + * @return object with all set parameters + * @throws FileNotFoundException + */ + public ConverterParams filename(String fileName) throws FileNotFoundException { + inputStream = new FileInputStream(fileName); + this.filename = fileName; + return this; + } + + /** + * + * Set input stream as input source. + * + * @param is + * input stream that should be parsed + * @return object with all set parameters + */ + public ConverterParams inputStream(InputStream is) { + return this.inputStream(is, null); + } + + public ConverterParams inputStream(InputStream is, String filename) { + this.inputStream = is; + if (filename != null) { + this.filename = filename; + } + return this; + } + + /** + * @return the source + * @see #source + */ + public XMLInputSource getSource() { + return new XMLInputSource(null, this.filename, null, this.inputStream, null); + } + + /** + * + * @param value + * the sizeAutoAdjust to set + * @see #sizeAutoAdjust + * @return object with all parameters + */ + public ConverterParams sizeAutoAdjust(boolean value) { + sizeAutoAdjust = value; + return this; + } + + /** + * @return the inputStream + * @see #inputStream + */ + public InputStream getInputStream() { + return this.inputStream; + } + + /** + * @return the sizeAutoAdjust + * @see #sizeAutoAdjust + */ + public boolean isSizeAutoAdjust() { + return sizeAutoAdjust; + } + + /** + * @return the filename + * @see #filename + */ + public String getFilename() { + return filename; + } + + /** + * @return the sbgnFormat + * @see #sbgnFormat + */ + public boolean isSbgnFormat() { + return sbgnFormat; + } + + /** + * @param sbgnFormat + * the sbgnFormat to set + * @return ConverterParams object with all parameters + * @see #sbgnFormat + */ + public ConverterParams sbgnFormat(boolean sbgnFormat) { + this.sbgnFormat = sbgnFormat; + return this; + } } diff --git a/converter/src/main/java/lcsb/mapviewer/converter/IConverter.java b/converter/src/main/java/lcsb/mapviewer/converter/IConverter.java index f1e0095ad6ce099c86fbc1ca9f1dc774032a9719..21cb52fd18a194468b10bbfd9c943110299d54fc 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/IConverter.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/IConverter.java @@ -18,11 +18,11 @@ import lcsb.mapviewer.model.map.model.Model; public interface IConverter { /** - * Parse input source and transformes it into a model object. + * Parse input source and transforms it into a model object. * * @param params * input params used for reading data - * @return model obtained from inut source + * @return model obtained from input source * @throws InvalidInputDataExecption * thrown when input parameters are invalid */ diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java index b57e65f20ba639aacf7037da8b2a32e01f239c46..5b2ffadb63d79afbe80ce87dd6fea06cc1c587c4 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java @@ -504,6 +504,10 @@ public class ComplexZipConverterTest { try { ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class); assertTrue(converter.isIgnoredFile("__MACOSX/.desc")); + assertTrue(converter.isIgnoredFile(".DS_Store")); + assertTrue(converter.isIgnoredFile("images/.DS_Store")); + assertTrue(converter.isIgnoredFile("layouts/.DS_Store")); + assertTrue(converter.isIgnoredFile("submaps/.DS_Store")); } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/frontend-js/src/main/js/gui/admin/AddProjectDialog.js b/frontend-js/src/main/js/gui/admin/AddProjectDialog.js index 85621deee6444c15c125e59854c7b6914daebea9..089c8cdb4f963b12c8ca151be05a8ebe9127dbe7 100644 --- a/frontend-js/src/main/js/gui/admin/AddProjectDialog.js +++ b/frontend-js/src/main/js/gui/admin/AddProjectDialog.js @@ -1295,7 +1295,9 @@ AddProjectDialog.prototype.createZipEntry = function (jsZipEntry, zipObject) { var type; var data = {}; var processingPromise = Promise.resolve(); - if (filename.indexOf("submaps") === 0) { + if (this.isIgnoredZipEntry(filename)) { + type = undefined; + } else if (filename.indexOf("submaps") === 0) { type = "MAP"; if (filename.endsWith("mapping.xml")) { data.mapping = true; @@ -1318,8 +1320,6 @@ AddProjectDialog.prototype.createZipEntry = function (jsZipEntry, zipObject) { data.description = ""; } }); - } else if (this.isIgnoredZipEntry(filename)) { - type = undefined; } else if (filename.indexOf("\\") === -1 && filename.indexOf("/") === -1) { type = "MAP"; data.root = true; @@ -1392,7 +1392,7 @@ AddProjectDialog.prototype.isIgnoredZipEntry = function (filename) { // noinspection SpellCheckingInspection if (lowercaseString.indexOf("__macosx") === 0) { return true; - } else if (lowercaseString.indexOf(".ds_store") === 0) { + } else if (lowercaseString.indexOf(".ds_store") === 0 || lowercaseString.endsWith(".ds_store")) { return true; } return false; diff --git a/frontend-js/src/test/js/gui/admin/AddProjectDialog-test.js b/frontend-js/src/test/js/gui/admin/AddProjectDialog-test.js index a83943d8057db13e978ca78523d1d612fd0342cd..65a5fcdffd86b1e16f2602fc7742bcf3f69960c6 100644 --- a/frontend-js/src/test/js/gui/admin/AddProjectDialog-test.js +++ b/frontend-js/src/test/js/gui/admin/AddProjectDialog-test.js @@ -258,6 +258,7 @@ describe('AddProjectDialog', function () { assert.ok(dialog.isIgnoredZipEntry(".DS_Store/.desc")); assert.ok(dialog.isIgnoredZipEntry(".ds_store/.desc")); + assert.ok(dialog.isIgnoredZipEntry("images/.ds_store")); return dialog.destroy(); }); });