Remove Image export support. It will be moved to the front end.

This commit is contained in:
Paulo Gustavo Veiga
2021-12-31 09:13:07 -08:00
parent ac7fd7e706
commit 71fefdd8c6
62 changed files with 4 additions and 30690 deletions

View File

@@ -42,55 +42,7 @@ public class TransformerController extends BaseController {
private static final String PARAM_WISE_MAP_XML = "mapXml";
private static final String PARAM_FILENAME = "filename";
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/pdf"}, consumes = {"image/svg+xml"})
@ResponseBody
public ModelAndView transformPdf(@RequestBody @Nullable final String content) {
final Map<String, Object> values = new HashMap<String, Object>();
if (content == null || content.length() == 0) {
throw new IllegalArgumentException("Body can not be null.");
}
values.put("content", content);
return new ModelAndView("transformViewPdf", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/svg+xml"}, consumes = {"image/svg+xml"})
@ResponseBody
public ModelAndView transformSvg(@RequestBody @Nullable final String content) {
final Map<String, Object> values = new HashMap<String, Object>();
if (content == null || content.length() == 0) {
throw new IllegalArgumentException("Body can not be null.");
}
values.put("content", content);
return new ModelAndView("transformViewSvg", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/png"}, consumes = {"image/svg+xml"})
@ResponseBody
public ModelAndView transformPng(@RequestBody @Nullable final String content) {
final Map<String, Object> values = new HashMap<String, Object>();
if (content == null || content.length() == 0) {
throw new IllegalArgumentException("Body can not be null.");
}
values.put("content", content);
values.put("imageSize", ExportProperties.ImageProperties.Size.LARGE);
return new ModelAndView("transformViewPng", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"image/jpeg"}, consumes = {"image/svg+xml"})
@ResponseBody
public ModelAndView transformJpeg(@RequestBody @Nullable final String content) throws IOException {
final Map<String, Object> values = new HashMap<String, Object>();
if (content == null || content.length() == 0) {
throw new IllegalArgumentException("Body can not be null.");
}
values.put("content", content);
values.put("imageSize", ExportProperties.ImageProperties.Size.LARGE);
return new ModelAndView("transformViewJpeg", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"application/xml"})
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"application/xml"})
@ResponseBody
public ModelAndView transformFreemind(@RequestBody @Nullable final String content) throws IOException {
final Map<String, Object> values = new HashMap<String, Object>();
@@ -100,40 +52,4 @@ public class TransformerController extends BaseController {
values.put("content", content);
return new ModelAndView("transformViewFreemind", values);
}
@RequestMapping(method = RequestMethod.POST, value = "/transform", consumes = {"application/x-www-form-urlencoded"})
public ModelAndView transform(@NotNull HttpServletRequest request) throws IOException {
final String svg = request.getParameter(PARAM_SVG_XML);
final String mapXml = request.getParameter(PARAM_WISE_MAP_XML);
final String filename = request.getParameter(PARAM_FILENAME);
// Obtains transformation type based on the last part of the URL ...
final String requestURI = request.getRequestURI();
final String format = requestURI.substring(requestURI.lastIndexOf(".") + 1);
final ExportFormat exportFormat = ExportFormat.valueOf(format.toUpperCase());
ModelAndView result;
switch (exportFormat) {
case PNG:
result = this.transformPng(svg);
break;
case JPG:
result = this.transformJpeg(svg);
break;
case PDF:
result = this.transformPdf(svg);
break;
case SVG:
result = this.transformSvg(svg);
break;
default:
throw new IllegalArgumentException("Unsupported export format");
}
if (filename != null) {
result.getModelMap().put("filename", filename);
}
return result;
}
}

View File

@@ -63,10 +63,6 @@ public class TransformView extends AbstractView {
// Build format properties ...
final ExportProperties properties = ExportProperties.create(exportFormat);
if (properties instanceof ExportProperties.ImageProperties) {
final ExportProperties.ImageProperties imageProperties = (ExportProperties.ImageProperties) properties;
imageProperties.setSize(ExportProperties.ImageProperties.Size.LARGE);
}
if (version != null) {
properties.setVersion(version);
}
@@ -93,7 +89,7 @@ public class TransformView extends AbstractView {
final Object mindmap = viewMap.get("mindmap");
final StreamResult result = new StreamResult(outputStream);
jaxbMarshaller.marshal(mindmap, result);
} else if (exportFormat == ExportFormat.MICROSOFT_EXCEL || exportFormat == ExportFormat.TEXT || exportFormat == ExportFormat.OPEN_OFFICE_WRITER || exportFormat == ExportFormat.MINDJET) {
} else if (exportFormat == ExportFormat.MICROSOFT_EXCEL || exportFormat == ExportFormat.TEXT || exportFormat == ExportFormat.MINDJET) {
response.setContentType(String.format("%s; charset=%s", contentType, DEFAULT_ENCODING));
factory.export(properties, content, outputStream, null);