diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/ImportController.java b/wise-webapp/src/main/java/com/wisemapping/controller/ImportController.java deleted file mode 100644 index d97ff5ff..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/ImportController.java +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.controller; - -import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.importer.ImporterException; -import com.wisemapping.model.MindMap; -import com.wisemapping.model.User; -import com.wisemapping.security.Utils; -import com.wisemapping.service.MindmapService; -import com.wisemapping.service.UserService; -import com.wisemapping.view.ImportMapBean; -import org.springframework.validation.BindException; -import org.springframework.web.bind.ServletRequestDataBinder; -import org.springframework.web.multipart.support.StringMultipartFileEditor; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class ImportController - extends BaseSimpleFormController { - - //~ Methods .............................................................................................. - protected Object formBackingObject(HttpServletRequest httpServletRequest) throws Exception { - return new ImportMapBean(); - } - - public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) - throws ServletException, WiseMappingException, ImporterException { - final ImportMapBean bean = (ImportMapBean) command; - - User user = Utils.getUser(); - final UserService userService = this.getUserService(); - - user = userService.getUserBy(user.getId()); - final MindMap mindMap = bean.getImportedMap(); - mindMap.setOwner(user); - - final MindmapService mindmapService = this.getMindmapService(); - mindmapService.addMindmap(mindMap, user); - - final StringBuilder redirectionTo = new StringBuilder("redirect:" + mindMap.getId() + "/edit"); - return new ModelAndView(redirectionTo.toString()); - } - - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) - throws ServletException { - // to actually be able to convert Multipart instance to a String - // we have to register a custom editor - binder.registerCustomEditor(String.class, new StringMultipartFileEditor()); - // now Spring knows how to handle multipart object and convert them - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index db8a3d56..84c552be 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -32,6 +32,11 @@ public class MindmapController { return new ModelAndView("mindmapExport", "mindmap", modelObject); } + @RequestMapping(value = "maps/import") + public ModelAndView showImportPAge() throws IOException { + return new ModelAndView("mindmapImport"); + } + @RequestMapping(value = "maps/{id}/exportf") public ModelAndView showExportPageFull(@PathVariable int id) throws IOException { final MindMapBean modelObject = findMindmapBean(id); @@ -76,7 +81,6 @@ public class MindmapController { return new ModelAndView("mindmapPublishFull", "mindmap", mindmap); } - @RequestMapping(value = "maps/{id}/edit") public ModelAndView editMap(@PathVariable int id, @NotNull HttpServletRequest request) { ModelAndView view; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 8e7439b9..cfe068c9 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -21,6 +21,10 @@ package com.wisemapping.rest; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.exporter.ExportFormat; +import com.wisemapping.importer.ImportFormat; +import com.wisemapping.importer.Importer; +import com.wisemapping.importer.ImporterException; +import com.wisemapping.importer.ImporterFactory; import com.wisemapping.model.MindMap; import com.wisemapping.model.MindmapUser; import com.wisemapping.model.User; @@ -29,6 +33,7 @@ import com.wisemapping.rest.model.RestMindmapInfo; import com.wisemapping.rest.model.RestMindmapList; import com.wisemapping.security.Utils; import com.wisemapping.service.MindmapService; +import com.wisemapping.service.UserService; import com.wisemapping.validator.MapInfoValidator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,6 +47,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.*; @@ -85,8 +91,7 @@ public class MindmapController extends BaseController { return new ModelAndView("transformViewFreemind", values); } - - @RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"application/json", "text/html", "application/xml"}) + @RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json", "text/html", "application/xml"}) public ModelAndView retrieveList(@RequestParam(required = false) String q) throws IOException { final User user = com.wisemapping.security.Utils.getUser(); @@ -129,7 +134,6 @@ public class MindmapController extends BaseController { saveMindmap(minor, mindMap, user); } - /** * The intention of this method is the update of several properties at once ... */ @@ -299,6 +303,20 @@ public class MindmapController extends BaseController { response.setHeader("ResourceId", Integer.toString(delegated.getId())); } + @RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/freemind"}) + @ResponseStatus(value = HttpStatus.CREATED) + public void createMapFromFreemind(@RequestBody byte[] freemindXml, @RequestParam(required = true) String title, @RequestParam(required = false) String description, @NotNull HttpServletResponse response) throws IOException, WiseMappingException, ImporterException { + + // Convert map ... + final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND); + final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml); + final MindMap mindMap = importer.importMap(title, description, stream); + + // Save new map ... + final User user = Utils.getUser(); + createMap(new RestMindmap(mindMap, user), response); + } + @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"}) @ResponseStatus(value = HttpStatus.CREATED) public void createDuplicate(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws IOException, WiseMappingException { diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java deleted file mode 100644 index 22cabc9e..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/validator/ImportMapValidator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.validator; - -import com.wisemapping.controller.Messages; -import com.wisemapping.importer.ImportFormat; -import com.wisemapping.importer.Importer; -import com.wisemapping.importer.ImporterException; -import com.wisemapping.importer.ImporterFactory; -import com.wisemapping.model.MindMap; -import com.wisemapping.view.ImportMapBean; -import org.jetbrains.annotations.NotNull; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; - -import java.io.ByteArrayInputStream; - -public class ImportMapValidator extends MapInfoValidator { - - public boolean supports(final Class clazz) { - return clazz.equals(ImportMapBean.class); - } - - public void validate(Object obj, @NotNull Errors errors) { - final ImportMapBean bean = (ImportMapBean) obj; - - this.validateMapInfo(errors, bean.getTitle(), bean.getDescription()); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mapFile", Messages.FIELD_REQUIRED); - try { - final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND); - final ByteArrayInputStream stream = new ByteArrayInputStream(bean.getMapFile().getBytes()); - final MindMap map = importer.importMap(bean.getTitle(), bean.getDescription(), stream); - - bean.setImportedMap(map); - - } catch (ImporterException e) { - 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/java/com/wisemapping/view/ImportMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/ImportMapBean.java deleted file mode 100644 index dc06c424..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/view/ImportMapBean.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.view; - -import com.wisemapping.model.MindMap; - -public class ImportMapBean extends MindMapInfoBean{ - - - private String mapFile; - private MindMap importedMap; - - - public MindMap getImportedMap() { - return importedMap; - } - - public void setMapFile(String mapFile) { - this.mapFile = mapFile; - } - - public String getMapFile() { - return mapFile; - } - - public void setImportedMap(MindMap map) { - this.importedMap = map; - } -} 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 cd5a4c65..a59d70d4 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties @@ -1,6 +1,6 @@ -NEW_MINDMAP=Create a new map NAME=Name DESCRIPTION=Description +FILE_FORMAT=File Format OK=Ok WISEMAPPING=WiseMapping ADD=Add @@ -245,7 +245,6 @@ FREEMIND_EXPORT_IMPORT_MESSAGE=You can now easily import and export mind maps fr EDITOR_TOOLBAR_IMPROVED=Usability Improvement: The editor toolbar has been redesign EDITOR_TOOLBAR_IMPROVED_MESSAGE= The toolbar has been redesign to improve its usability. COLLABORATE=Collaborate -IMPORT-EXPORT_ISSUES_FIXED=Usability Improvement: Import-Export issues have been solved. GO_TO= Go to my Wisemaps NEWS_AND_ARTICLES=News & Articles diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties index 63cfc9c2..52209f65 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties @@ -1,4 +1,3 @@ -NEW_MINDMAP=Crear un nuevo mapa NAME=Nombre DESCRIPTION=Descripción OK=Ok diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties index 6f8d6507..ddc45c7b 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_fr.properties @@ -1,4 +1,3 @@ -NEW_MINDMAP = Cr\u00e9er une nouvelle carte mentale NAME = Nom DESCRIPTION = Description OK = Ok @@ -246,13 +245,6 @@ COLLABORATE = Contribuer PRINT_FEATURE_IMPLEMENTED = Imprimer la carte maintenant. PRINT_FEATURE_IMPLEMENTED_MESSAGE = Vous pouvez maintenant imprimer vos cartes \u00e0 partir de l\'\u00e9diteur et de la liste de cartes! EMBEDDED_MAP_SIZE=* Note -USABILITY_EDITING_IMPROVED= Usability Improvement = -USABILITY_EDITING_IMPROVED_ESC= Usability Improvement = -USABILITY_EDITING_IMPROVED_TEXT=Now you have 3 different ways of editing a node text.