From 1d0d9072842ce74c69b1c347ee32e4620c517bb1 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 24 Mar 2015 22:30:51 -0300 Subject: [PATCH] Improve detection of version in freemind. --- .../wisemapping/importer/VersionNumber.java | 12 +++++++----- .../importer/freemind/FreemindImporter.java | 19 ++++++------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/VersionNumber.java b/wise-webapp/src/main/java/com/wisemapping/importer/VersionNumber.java index 1023b4bb..f1f51a2e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/importer/VersionNumber.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/VersionNumber.java @@ -18,10 +18,12 @@ package com.wisemapping.importer; +import org.jetbrains.annotations.NotNull; + import java.util.*; public class VersionNumber - implements Comparable { + implements Comparable { protected String version_d; @@ -58,13 +60,13 @@ public class VersionNumber } - public int compareTo(final Object otherObject) { + public int compareTo(@NotNull final VersionNumber otherObject) { if (this.equals(otherObject)) { return 0; } final StringTokenizer ownTokenizer = this.getTokenizer(); - final StringTokenizer otherTokenizer = ((VersionNumber) otherObject).getTokenizer(); + final StringTokenizer otherTokenizer = otherObject.getTokenizer(); while (ownTokenizer.hasMoreTokens()) { final int ownNumber; @@ -112,8 +114,8 @@ public class VersionNumber return (version_d != null ? version_d.hashCode() : 0); } - - protected StringTokenizer getTokenizer() { + @NotNull + private StringTokenizer getTokenizer() { return new StringTokenizer(this.getVersion(), "."); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index 52af8997..93a318e3 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -96,8 +96,9 @@ public class FreemindImporter final Map freemindMap = (Map) JAXBUtils.getMapObject(input, "com.wisemapping.jaxb.freemind"); final String version = freemindMap.getVersion(); - if (version != null) { - + if (version == null || version.startsWith("freeplane")) { + throw new ImporterException("You seems to be be trying to import a Freeplane map. FreePlane is not supported format."); + } else { final VersionNumber mapVersion = new VersionNumber(version); if (mapVersion.isGreaterThan(FreemindConstant.SUPPORTED_FREEMIND_VERSION)) { throw new ImporterException("FreeMind version " + mapVersion.getVersion() + " is not supported."); @@ -134,11 +135,7 @@ public class FreemindImporter result.setTitle(mapName); result.setDescription(description); - } catch (JAXBException e) { - throw new ImporterException(e); - } catch (IOException e) { - throw new ImporterException(e); - } catch (TransformerException e) { + } catch (JAXBException | IOException | TransformerException e) { throw new ImporterException(e); } return result; @@ -330,7 +327,7 @@ public class FreemindImporter } } - private int getChildrenCountSameSide(@NotNull List freeChildren, Node freeChild) { + private int getChildrenCountSameSide(@NotNull List freeChildren, Node freeChild) { int result = 0; String childSide = freeChild.getPOSITION(); if (childSide == null) { @@ -500,11 +497,7 @@ public class FreemindImporter } final Boolean folded = Boolean.valueOf(freeNode.getFOLDED()); - if (folded) { - wiseTopic.setShrink(folded); - } - - + wiseTopic.setShrink(folded); }