- Improve error handling on export
- Validate FreeMind 0.9 or gretter during import - Improve login message.
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user