From 776e216e501fea98bbdd3f844c2f71f7f2f55afb Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 15 Apr 2011 23:22:58 -0300 Subject: [PATCH] - Improve error handling on export - Validate FreeMind 0.9 or gretter during import - Improve login message. --- .gitignore | 2 +- .../wisemapping/controller/ExportController.java | 10 ++++++++-- .../controller/RenameMindmapController.java | 2 +- .../importer/freemind/FreemindImporter.java | 2 +- .../wisemapping/validator/ImportMapValidator.java | 3 ++- .../webapp/WEB-INF/classes/messages.properties | 4 ++-- wise-webapp/src/main/webapp/images/info.png | Bin 0 -> 778 bytes wise-webapp/src/main/webapp/jsp/login.jsp | 10 ++++++---- 8 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 wise-webapp/src/main/webapp/images/info.png diff --git a/.gitignore b/.gitignore index 478a868d..386c3dc3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ wisemapping.ipr wisemapping.iws wisemapping.iml -wise-webapp/wisemapping.log +wise-webapp/wisemapping.log.* */.DS_Store .DS_Store diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java b/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java index 5896e93b..469233c4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java @@ -41,6 +41,7 @@ import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.XMLStreamException; import javax.xml.transform.TransformerException; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -97,8 +98,13 @@ public class ExportController extends BaseMultiActionController { } } + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + // Change image link URL. setBaseBaseImgUrl(format, properties); + ExporterFactory.export(properties, mindMap, bos, mapSvg); + + // If the export goes ok, write the map to the stream ... // Set format content type... final String contentType = format.getContentType(); @@ -110,7 +116,7 @@ public class ExportController extends BaseMultiActionController { // Write content ... final ServletOutputStream outputStream = response.getOutputStream(); - ExporterFactory.export(properties, mindMap, outputStream, mapSvg); + outputStream.write(bos.toByteArray()); } catch (Throwable e) { @@ -125,7 +131,7 @@ public class ExportController extends BaseMultiActionController { return null; } - private void setBaseBaseImgUrl(ExportFormat format, @NotNull ExportProperties properties) { + private void setBaseBaseImgUrl(@NotNull ExportFormat format, @NotNull ExportProperties properties) { final String baseUrl; if (format == ExportFormat.SVG) { diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/RenameMindmapController.java b/wise-webapp/src/main/java/com/wisemapping/controller/RenameMindmapController.java index bbc2bdc6..e8832aef 100755 --- a/wise-webapp/src/main/java/com/wisemapping/controller/RenameMindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/RenameMindmapController.java @@ -40,7 +40,7 @@ public class RenameMindmapController final MindMap mindMap = getMindmapFromRequest(httpServletRequest); User user = Utils.getUser(); if (!mindMap.getOwner().equals(user)) { - throw new IllegalStateException("No enought right to execute this operation"); + throw new IllegalStateException("No enough right to execute this operation"); } 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 59d81bcb..9aabf96f 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 @@ -106,7 +106,7 @@ public class FreemindImporter if (version != null) { final VersionNumber mapVersion = new VersionNumber(version); if (SUPPORTED_FREEMIND_VERSION.isGreaterThan(mapVersion)) { - throw new ImporterException("FreeMind map has been created with '" + mapVersion.getVersion() + "'. Supported FreeMind version is '" + SUPPORTED_FREEMIND_VERSION.getVersion() + "' or greater."); + throw new ImporterException("FreeMind version " + mapVersion.getVersion() + " is not supported."); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java index 7125a233..aa532f2a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java @@ -50,7 +50,8 @@ public class ImportMapValidator extends MapInfoValidator { bean.setImportedMap(map); } catch (ImporterException e) { - errors.rejectValue("mapFile",Messages.IMPORT_MAP_ERROR); + Object[] errorArgs = new Object[]{e.getMessage()}; + errors.rejectValue("mapFile", Messages.IMPORT_MAP_ERROR,errorArgs,"FreeMind could not be imported."); } } } diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties index c73fafbd..81eab56c 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties @@ -240,10 +240,10 @@ NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this ma SHARING=Sharing IMPORT_MINDMAP=Import map IMPORT_MINDMAP_DETAILS=Do you already have maps created with FreeMind?.No problem, Import them!. -IMPORT_MINDMAP_INFO=You can import FreeMind maps to WiseMapping. Please, select the FreeMind map that want to import.
Fields marked with an asterisk * are required. +IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 version maps to WiseMapping. Please, select the FreeMind map that want to import.
Fields marked with an asterisk * are required. PRINT=Print FREE_MIND_FILE=FreeMind File -IMPORT_MAP_ERROR=Imported file seems not to be a valid FreeMind file. +IMPORT_MAP_ERROR=FreeMind file could not be imported. {0} MAP_TITLE_ALREADY_EXISTS=Map name already exists. EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post! EMBEDDED_VIEWER_MESSAGE=Once you make your map public, you will be able to embed a mind map viewer in your own web site, blog or post just as we did it here!
Try it!!, you can drag nodes, pan the map, and zoom in and out. diff --git a/wise-webapp/src/main/webapp/images/info.png b/wise-webapp/src/main/webapp/images/info.png new file mode 100644 index 0000000000000000000000000000000000000000..12cd1aef900803abba99b26920337ec01ad5c267 GIT binary patch literal 778 zcmV+l1NHogP)BVme|mWaqy4$_pJm?y9KM{-*hp?1+Ey3e-CEDooTa!B;e(Q>TSF?bj>5At13y1p zriN3w3x~5SfZj{@J4M{kp{?=M_Lh2bV+5LH)Q)5W!-ePA$RgE1@5f1cyHki0Y}JyVEYZF(LD$xXlt$7A5CgE@ zpV-&l%vf;=5kZ2-2gi@Y6J&=cuwt>!vJ^#(&n|LcZyUzi6Duj$$hJ1s*HD-#;k-w@ zpdrwAuoDG_N2bvb07G$Zk*?Hc)JLtW4yqOnic_$zO7NZ#l>Fm){;fE?b$IbOaX2fe z0la4g0Dfw2xk7Wi7NapVD8YMPCZu?A1QCK*67dgsvRKBLFtrM>?$%&_lD1882mzdO zWPdw5KWw6IT`m1b_8=lS5jt8D3=RDa=&jWzR-)S@56WMslZ~mKu1)-wpXB>rNBQ>N zU#K`#1B&v|_AQK;7I~B}OdGiUT9LX>f0xm6<;LeP!=vFjPsUQF*wCJ*dO)4YBypgdiuF!=i@6Zyi7F|q#K zz?tlSZULa@t1D?$e;f@b36&N!V2mjOHw|*
- - -

You are using an HSQL database. You shouldn't use this environment for production!

-

What is New:

  • Links Between Nodes
  • @@ -102,3 +98,9 @@
+ + + + +
Note: Although HSQLDB is bundled with WiseMapping by default during the installation, we do not recommend this database for production use. Please consider using MySQL 5.5 instead. You can find more information how to configure MySQL here.
+