From f52f01a6b1de288edc888ca0f9ebb6f5bf505dff Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 2 Apr 2012 14:11:28 -0300 Subject: [PATCH] Change symblink to moootols Add editor issue. --- core-js/pom.xml | 2 - core-js/src/main/javascript/footer.js | 91 ----------- .../javascript/libraries/moodialog/Overlay.js | 2 +- mindplot/src/main/javascript/widget/Menu.js | 2 +- wise-editor/src/main/webapp/c/map/export.htm | 117 ++++++++++++++ wise-editor/src/main/webapp/js/editor.js | 28 ++-- .../controller/BaseMultiActionController.java | 11 -- .../controller/ExportController.java | 117 -------------- .../controller/MindmapController.java | 144 ----------------- .../dwr/JavaScriptErrorLoggerService.java | 72 --------- .../java/com/wisemapping/model/MindMap.java | 2 +- .../main/java/com/wisemapping/model/User.java | 1 + .../ncontroller/MindmapController.java | 148 ++++++++++++++++++ .../ncontroller/NMindmapController.java | 31 ---- .../security/aop/BaseSecurityAdvice.java | 32 ++-- .../security/aop/ViewBaseSecurityAdvise.java | 18 +-- .../service/MindmapServiceImpl.java | 9 +- wise-webapp/src/main/webapp/WEB-INF/web.xml | 1 + .../main/webapp/WEB-INF/wisemapping-aop.xml | 1 - .../webapp/WEB-INF/wisemapping-nservlet.xml | 91 +++++++++++ .../webapp/WEB-INF/wisemapping-servlet.xml | 79 ---------- .../src/main/webapp/js/mootools-core.js | 2 +- .../src/main/webapp/js/mootools-more.js | 2 +- .../src/main/webapp/jsp/mindmapEditor.jsp | 7 +- 24 files changed, 411 insertions(+), 599 deletions(-) delete mode 100644 core-js/src/main/javascript/footer.js create mode 100644 wise-editor/src/main/webapp/c/map/export.htm delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/MindmapController.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/dwr/JavaScriptErrorLoggerService.java create mode 100644 wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/ncontroller/NMindmapController.java create mode 100644 wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml diff --git a/core-js/pom.xml b/core-js/pom.xml index 5625e078..6297519a 100644 --- a/core-js/pom.xml +++ b/core-js/pom.xml @@ -64,8 +64,6 @@ ${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.Fx.js - ${basedir}/target/tmp/footer-min.js - diff --git a/core-js/src/main/javascript/footer.js b/core-js/src/main/javascript/footer.js deleted file mode 100644 index 0e54191f..00000000 --- a/core-js/src/main/javascript/footer.js +++ /dev/null @@ -1,91 +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. - */ - -//// Init default logger level ... -//var wLogger = new Log4js.getLogger("WiseMapping"); -//wLogger.setLevel(Log4js.Level.ALL); -////wLogger.addAppender(new Log4js.BrowserConsoleAppender()); -// -//// Is logger service available ? -//if ($defined(window.LoggerService)) -//{ -// Log4js.WiseServerAppender = function() -// { -// this.layout = new Log4js.SimpleLayout(); -// }; -// -// Log4js.WiseServerAppender.prototype = Log4js.extend(new Log4js.Appender(), { -// /** -// * @see Log4js.Appender#doAppend -// */ -// doAppend: function(loggingEvent) { -// try { -// var message = this.layout.format(loggingEvent); -// var level = this.levelCode(loggingEvent); -// -// window.LoggerService.logError(level, message); -// -// } catch (e) { -// alert(e); -// } -// }, -// -// /** -// * toString -// */ -// toString: function() { -// return "Log4js.WiseServerAppender"; -// }, -// -// levelCode: function(loggingEvent) -// { -// var retval; -// switch (loggingEvent.level) { -// case Log4js.Level.FATAL: -// retval = 3; -// break; -// case Log4js.Level.ERROR: -// retval = 3; -// break; -// case Log4js.Level.WARN: -// retval = 2; -// break; -// default: -// retval = 1; -// break; -// } -// -// return retval; -// } -// }); -// -// wLogger.addAppender(new Log4js.WiseServerAppender()); -// -//} -// - -//// Handle error events ... -//window.onerror = function(sMsg, sUrl, sLine) -//{ -// window.hasUnexpectedErrors = true; -// var msg = sMsg + ' (' + sUrl + ', line ' + sLine + ')'; -// wLogger.fatal(msg); -// -// $(window).fireEvent("error",null,0); -// return false; -//}; \ No newline at end of file diff --git a/mindplot/src/main/javascript/libraries/moodialog/Overlay.js b/mindplot/src/main/javascript/libraries/moodialog/Overlay.js index 81a64570..ce101867 100644 --- a/mindplot/src/main/javascript/libraries/moodialog/Overlay.js +++ b/mindplot/src/main/javascript/libraries/moodialog/Overlay.js @@ -22,7 +22,7 @@ var Overlay = new Class({ options: { id: 'overlay', - color: '#000', + color: '#000000', duration: 500, opacity: 0.8, zIndex: 5000/*, diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js index 97429bd0..80bff79f 100644 --- a/mindplot/src/main/javascript/widget/Menu.js +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -191,7 +191,7 @@ mindplot.widget.Menu = new Class({ this._registerTooltip('fontColor', "Text color"); - this._addButton('export', false, false, "Export", function() { + this._addButton('export', false, false, function() { var reqDialog = new MooDialog.Request('c/export.htm?mapId=' + mapId, null, {'class': 'exportModalDialog', closeButton:true, diff --git a/wise-editor/src/main/webapp/c/map/export.htm b/wise-editor/src/main/webapp/c/map/export.htm new file mode 100644 index 00000000..c0017ee0 --- /dev/null +++ b/wise-editor/src/main/webapp/c/map/export.htm @@ -0,0 +1,117 @@ +
+

Export

+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + Scalable Vector Graphics (SVG) + +

+ Scalable Vector Graphics (SVG) is an XML markup language for describing two-dimensional + vector graphics. This format will enable you to print your maps without quality lost at any + resolution. +

+
+ + Portable Document Format (PDF) + +

+ Get your map as Portable Document Format(PDF) to share use in your presentations. +

+
+ + Freemind (version 0.9.0) + +

+ FreeMind is a nice desktop mind mapping application that has the great benefit of being + free. +

+
+ + Image File + + +

+ Get a graphic representation of your map including all colors and shapes to reuse in + documents or for archiving +

+
+ + +
+
+
+ +
+ \ No newline at end of file diff --git a/wise-editor/src/main/webapp/js/editor.js b/wise-editor/src/main/webapp/js/editor.js index 4f8743b3..dc6d7c48 100644 --- a/wise-editor/src/main/webapp/js/editor.js +++ b/wise-editor/src/main/webapp/js/editor.js @@ -26,13 +26,15 @@ function buildDesigner(options) { // Register load events ... designer = new mindplot.Designer(options, container); designer.addEvent('loadSuccess', function() { - window.waitDialog.close(); - window.waitDialog.destroy(); + window.waitDialog.close.delay(1000,window.waitDialog); + window.waitDialog = null; }); window.onerror = function(e) { - window.waitDialog.close(); - window.waitDialog.destroy(); + if (window.waitDialog) { + window.waitDialog.close.delay(1000,window.waitDialog); + window.waitDialog = null; + } errorDialog.show(); console.log(e); }; @@ -117,12 +119,12 @@ editor.WaitDialog = new Class({ duration: 100, transition: Fx.Transitions.Bounce.easeOut }); - this.overlay = new Overlay(this.options.inject, { - duration: this.options.duration - }); }, onBeforeOpen: function() { + this.overlay = new Overlay(this.options.inject, { + duration: this.options.duration + }); this.overlay.open(); this.fx.start({ 'margin-top': [-200, -100], @@ -142,7 +144,6 @@ editor.WaitDialog = new Class({ }).chain(function() { this.fireEvent('hide'); this.wrapper.setStyle('display', 'none'); - this.overlay.destroy(); }.bind(this)); }} @@ -163,6 +164,11 @@ editor.WaitDialog = new Class({ show : function() { this.open(); + }, + + destroy: function() { + this.parent(); + this.overlay.destroy(); } }); @@ -211,7 +217,6 @@ editor.FatalErrorDialog = new Class({ }).chain(function() { this.wrapper.setStyle('display', 'none'); this.fireEvent('hide'); - this.overlay.destroy(); }.bind(this)); }} @@ -219,6 +224,11 @@ editor.FatalErrorDialog = new Class({ this.setContent(panel); }, + destroy: function() { + this.parent(); + this.overlay.destroy(); + }, + _buildPanel : function () { var result = new Element('div'); result.setStyles({ diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java b/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java index 4ffd35d2..9002815e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java @@ -38,17 +38,6 @@ public abstract class BaseMultiActionController private MindmapService mindmapService; private UserService userService; - protected List getMindmapUsersFromRequest(HttpServletRequest request) { - List result = new ArrayList(); - final String mindmapIds = request.getParameter("mindmapIds"); - - final String ids[] = mindmapIds.split(","); - for (String id : ids) - if (mindmapIds.length()!=0){ - result.add(getMindmapUser(Integer.parseInt(id), request)); - } - return result; - } protected List getMindmapsFromRequest(HttpServletRequest request) { List result = new ArrayList(); diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java b/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java deleted file mode 100644 index 7d76c4fe..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/ExportController.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.wisemapping.controller; - - -import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.model.User; -import com.wisemapping.rest.BaseController; -import com.wisemapping.rest.model.RestUser; -import com.wisemapping.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -@Controller -public class ExportController extends BaseController { - @Autowired - private UserService userService; - - @RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "text/html", "application/xml"}) - @ResponseBody - public ModelAndView getUserById(@PathVariable long id) throws IOException { - final User userBy = userService.getUserBy(id); - if (userBy == null) { - throw new IllegalArgumentException("User could not be found"); - } - return new ModelAndView("userView", "user", new RestUser(userBy)); - } - - @RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/json", "text/html", "application/xml"}) - @ResponseBody - public ModelAndView getUserByEmail(@PathVariable String email) throws IOException { - final User user = userService.getUserBy(email); - if (user == null) { - throw new IllegalArgumentException("User '" + email + "' could not be found"); - } - return new ModelAndView("userView", "user", new RestUser(user)); - } - - @RequestMapping(method = RequestMethod.GET, value = "admin/users/username/{username}", produces = {"application/json", "text/html", "application/xml"}) - @ResponseBody - public ModelAndView getUserByUsername(@PathVariable String username) throws IOException { - final User user = userService.getUserByUsername(username); - if (user == null) { - throw new IllegalArgumentException("User '" + username + "' could not be found"); - } - return new ModelAndView("userView", "user", new RestUser(user)); - } - - @RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"}) - @ResponseStatus(value = HttpStatus.CREATED) - public void createUser(@RequestBody RestUser user, HttpServletResponse response) throws IOException, WiseMappingException { - if (user == null) { - throw new IllegalArgumentException("User could not be found"); - } - - // User already exists ? - final String email = user.getEmail(); - if (userService.getUserBy(email) != null) { - throw new IllegalArgumentException("User already exists with this email."); - } - - final String username = user.getUsername(); - if (username == null || username.isEmpty()) { - throw new IllegalArgumentException("username can not be null"); - } - - if (userService.getUserByUsername(username) != null) { - throw new IllegalArgumentException("User already exists with this username."); - } - - // Run some other validations ... - final User delegated = user.getDelegated(); - final String lastname = delegated.getLastname(); - if (lastname == null || lastname.isEmpty()) { - throw new IllegalArgumentException("lastname can not be null"); - } - - final String firstName = delegated.getFirstname(); - if (firstName == null || firstName.isEmpty()) { - throw new IllegalArgumentException("firstname can not be null"); - } - - // Finally create the user ... - userService.createUser(delegated, false); - response.setHeader("Location", "/service/admin/users/" + user.getId()); - } - - @RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"}) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void changePassword(@RequestBody String password, @PathVariable long id) throws IOException, WiseMappingException { - if (password == null) { - throw new IllegalArgumentException("Password can not be null"); - } - - final User user = userService.getUserBy(id); - if (user == null) { - throw new IllegalArgumentException("User '" + id + "' could not be found"); - } - user.setPassword(password); - userService.changePassword(user); - } - - @RequestMapping(method = RequestMethod.DELETE) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void getUserByEmail(@PathVariable long id) throws IOException, WiseMappingException { - final User user = userService.getUserBy(id); - if (user == null) { - throw new IllegalArgumentException("User '" + id + "' could not be found"); - } - userService.deleteUser(user); - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapController.java deleted file mode 100644 index 2100726c..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapController.java +++ /dev/null @@ -1,144 +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.model.MindMap; -import com.wisemapping.model.MindmapUser; -import com.wisemapping.model.User; -import com.wisemapping.security.Utils; -import com.wisemapping.view.MindMapBean; -import com.wisemapping.filter.UserAgent; -import com.wisemapping.exceptions.WiseMappingException; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.util.List; - -public class MindmapController extends BaseMultiActionController { - protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - return list(httpServletRequest, httpServletResponse); - } - - public ModelAndView list(HttpServletRequest request, HttpServletResponse response) { - logger.info("Mindmap Controller: myMindmap action"); - final HttpSession session = request.getSession(false); - - // Try to loaded from the request ... - UserAgent userAgent = null; - if (session != null) { - userAgent = (UserAgent) session.getAttribute(USER_AGENT); - } - - // I could not loaded. I will create a new one... - if (userAgent == null) { - userAgent = UserAgent.create(request); - if (session != null) { - session.setAttribute(USER_AGENT, userAgent); - } - } - - // It's a supported browser ?. - final UserAgent.OS os = userAgent.getOs(); - - final User user = Utils.getUser(request); - final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", getMindMapBeanList(user)); - view.addObject("isMAC", os == UserAgent.OS.MAC); - view.addObject("user", user); - return view; - } - - public ModelAndView edit(HttpServletRequest request, HttpServletResponse response) { - logger.info("Mindmap Controller: EDIT action"); - final MindMap mindmap = getMindmapFromRequest(request); - return new ModelAndView("mindmapEditor", "wisemapsList", new MindMapBean(mindmap)); - } - - public ModelAndView collaborator(HttpServletRequest request, HttpServletResponse response) { - logger.info("Mindmap Controller: COLLABORATE action"); - final MindMap mindmap = getMindmapFromRequest(request); - return new ModelAndView("mindmapCollaborator", "mindmap", new MindMapBean(mindmap)); - } - - public ModelAndView viewer(HttpServletRequest request, HttpServletResponse response) { - logger.info("Mindmap Controller: VIEWER action"); - final MindMap mindmap = getMindmapFromRequest(request); - return new ModelAndView("mindmapViewer", "wisemapsList", new MindMapBean(mindmap)); - } - - public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException { - logger.info("Mindmap Controller: DELETE action"); - final User user = Utils.getUser(request); - - final MindMap mindmap = getMindmapFromRequest(request); - getMindmapService().removeCollaboratorFromMindmap(mindmap, user.getId()); - - return list(request, response); - } - - public ModelAndView deleteAll(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException { - logger.info("Mindmap Controller: DELETE ALL action"); - - final List mindmaps = getMindmapUsersFromRequest(request); - final User user = Utils.getUser(request); - for (MindmapUser mindmap : mindmaps) - getMindmapService().removeMindmap(mindmap.getMindMap(), user); - return list(request, response); - } - - public ModelAndView detail(HttpServletRequest request, HttpServletResponse response) { - logger.info("Mindmap Controller: DETAIL action"); - final MindMap mindMap = getMindmapFromRequest(request); - final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindMap)); - view.addObject("user", Utils.getUser()); - return view; - } - - public ModelAndView changeStatus(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException { - final MindMap mindmap = getMindmapFromRequest(request); - boolean isPublic = !mindmap.isPublic(); - mindmap.setPublic(isPublic); - getMindmapService().updateMindmap(mindmap, false); - return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap)); - } - - public ModelAndView editMindmap(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException { - final MindMap mindmap = getMindmapFromRequest(request); - final ModelAndView view = new ModelAndView("editMindmap", "mindmap", new MindMapBean(mindmap)); - view.addObject("user", Utils.getUser()); - return view; - } - - public ModelAndView updateMindmap(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException { - final MindMap mindmap = getMindmapFromRequest(request); - - final String title = request.getParameter("title"); - final String description = request.getParameter("description"); - - mindmap.setTitle(title); - mindmap.setDescription(description); - - getMindmapService().updateMindmap(mindmap, false); - return list(request, response); - } - - private static final String USER_AGENT = "wisemapping.userAgent"; -} diff --git a/wise-webapp/src/main/java/com/wisemapping/dwr/JavaScriptErrorLoggerService.java b/wise-webapp/src/main/java/com/wisemapping/dwr/JavaScriptErrorLoggerService.java deleted file mode 100644 index 2d8895cd..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/dwr/JavaScriptErrorLoggerService.java +++ /dev/null @@ -1,72 +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.dwr; - -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class JavaScriptErrorLoggerService -{ - final Log logger = LogFactory.getLog(JavaScriptErrorLoggerService.class); - private static final int ERROR_MESSAGE = 3; - private static final int FATAL_MESSAGE = 4; - private static final String USER_AGENT = "User-Agent"; - - JavaScriptErrorLoggerService() { - LogFactory.getLog(JavaScriptErrorLoggerService.class); - } - //~ Methods .............................................................................................. - - public void logError(final int severity, final String logMsg) - throws IOException { - -// final User user = getUser(); - - -// final String userAgent = request.getHeader(USER_AGENT); -// synchronized (logger) { -// // Log user info ... -// if (user != null) { -// log(severity, "UserId:" + user.getId() + ", UserEmail:" + user.getEmail()); -// } else { -// log(severity, "Anonymous user"); -// } -// -// // Log browser details ... -// log(severity, "Browser:" + userAgent); -// -// // Log error message ... -// log(severity, logMsg); -// } - } - - void log(final int severity, final String msg) { - // Log error message ... - if (severity == ERROR_MESSAGE && logger.isErrorEnabled()) { - logger.error(msg); - } else if (severity == FATAL_MESSAGE && logger.isFatalEnabled()) { - logger.fatal(msg); - } else if (logger.isInfoEnabled()) { - logger.info(msg); - } - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java index bce9e27e..3212eb19 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -222,7 +222,7 @@ public class MindMap { public static String getDefaultMindmapXml(@NotNull final String title) { final StringBuilder result = new StringBuilder(); - result.append(""); + result.append(""); result.append(""); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index 7bebde47..eafd4ec0 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -131,4 +131,5 @@ public class User public void setUsername(String username) { this.username = username; } + } diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java new file mode 100644 index 00000000..cefa7e2b --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -0,0 +1,148 @@ +package com.wisemapping.ncontroller; + + +import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.filter.UserAgent; +import com.wisemapping.model.MindMap; +import com.wisemapping.model.MindmapUser; +import com.wisemapping.model.User; +import com.wisemapping.security.Utils; +import com.wisemapping.service.MindmapService; +import com.wisemapping.view.MindMapBean; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@Controller +@RequestMapping("/c/") +public class MindmapController { + @Autowired + private MindmapService mindmapService; + + @RequestMapping(value = "export") + public ModelAndView export(@RequestParam(required = true) long mapId) throws IOException { + final MindMapBean modelObject = findMindmapBean(mapId); + return new ModelAndView("mindmapExport", "mindmap", modelObject); + } + + @RequestMapping(value = "edit") + public ModelAndView edit(@RequestParam(required = true) long mapId) { + final MindMapBean modelObject = findMindmapBean(mapId); + return new ModelAndView("mindmapEditor", "wisemapsList", modelObject); + } + + @RequestMapping(value = "collaborator") + public ModelAndView collaborator(@RequestParam(required = true) long mapId) { + final MindMapBean modelObject = findMindmapBean(mapId); + return new ModelAndView("mindmapCollaborator", "mindmap", modelObject); + } + + @RequestMapping(value = "viewer") + public ModelAndView viewer(@RequestParam(required = true) long mapId) { + final MindMapBean modelObject = findMindmapBean(mapId); + return new ModelAndView("mindmapViewer", "wisemapsList", modelObject); + } + + @RequestMapping(value = "detail") + public ModelAndView detail(@RequestParam(required = true) long mapId) { + final MindMapBean modelObject = findMindmapBean(mapId); + final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", modelObject); + view.addObject("user", Utils.getUser()); + return view; + } + + @RequestMapping(value = "changeStatus") + public ModelAndView changeStatus(@RequestParam(required = true) long mapId) throws WiseMappingException { + final MindMap mindmap = findMindmap(mapId); + boolean isPublic = !mindmap.isPublic(); + mindmap.setPublic(isPublic); + mindmapService.updateMindmap(mindmap, false); + return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap)); + } + + @RequestMapping(value = "editMindmap") + public ModelAndView editMindmap(@RequestParam(required = true) long mapId) throws WiseMappingException { + final MindMapBean mindmap = findMindmapBean(mapId); + final ModelAndView view = new ModelAndView("editMindmap", "mindmap", mindmap); + view.addObject("user", Utils.getUser()); + return view; + } + + @RequestMapping(value = "mymaps") + public ModelAndView list(@NotNull HttpServletRequest request) { + final HttpSession session = request.getSession(false); + + // Try to loaded from the request ... + UserAgent userAgent = null; + if (session != null) { + userAgent = (UserAgent) session.getAttribute(USER_AGENT); + } + + // I could not loaded. I will create a new one... + if (userAgent == null) { + userAgent = UserAgent.create(request); + if (session != null) { + session.setAttribute(USER_AGENT, userAgent); + } + } + + // It's a supported browser ?. + final UserAgent.OS os = userAgent.getOs(); + + final User user = Utils.getUser(); + final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", findMindMapBeanList(user)); + view.addObject("isMAC", os == UserAgent.OS.MAC); + view.addObject("user", user); + return view; + } + + @RequestMapping(value = "delete") + public ModelAndView delete(@RequestParam(required = true) long mapId, @NotNull HttpServletRequest request) throws WiseMappingException { + final User user = Utils.getUser(); + final MindMap mindmap = findMindmap(mapId); + mindmapService.removeCollaboratorFromMindmap(mindmap, user.getId()); + return list(request); + } + + @RequestMapping(value = "updateMindmap") + public ModelAndView updateMindmap(@RequestParam(required = true) long mapId, @RequestParam(required = true) String title, @RequestParam(required = true) String description, @NotNull HttpServletRequest request) throws WiseMappingException { + final MindMap mindmap = findMindmap(mapId); + mindmap.setTitle(title); + mindmap.setDescription(description); + + mindmapService.updateMindmap(mindmap, false); + return list(request); + } + + private MindMap findMindmap(long mapId) { + final MindMap mindmap = mindmapService.getMindmapById((int) mapId); + if (mindmap == null) { + throw new IllegalArgumentException("Mindmap could not be found"); + } + return mindmap; + } + + private List findMindMapBeanList(@NotNull User user) { + final List userMindmaps = mindmapService.getMindmapUserByUser(user); + + final List mindMapBeans = new ArrayList(userMindmaps.size()); + for (MindmapUser mindmap : userMindmaps) { + mindMapBeans.add(new MindMapBean(mindmap.getMindMap())); + } + return mindMapBeans; + } + + private MindMapBean findMindmapBean(long mapId) { + return new MindMapBean(findMindmap(mapId)); + } + + private static final String USER_AGENT = "wisemapping.userAgent"; +} diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/NMindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/NMindmapController.java deleted file mode 100644 index b01c865a..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/NMindmapController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.wisemapping.ncontroller; - - -import com.wisemapping.model.User; -import com.wisemapping.rest.model.RestUser; -import com.wisemapping.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -import java.io.IOException; - -@Controller -public class NMindmapController { - @Autowired - private UserService userService; - - @RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "text/html", "application/xml"}) - @ResponseBody - public ModelAndView getUserById(@PathVariable long id) throws IOException { - final User userBy = userService.getUserBy(id); - if (userBy == null) { - throw new IllegalArgumentException("User could not be found"); - } - return new ModelAndView("userView", "user", new RestUser(userBy)); - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java index 6b4536b8..f779f678 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java @@ -29,43 +29,35 @@ import org.aopalliance.intercept.MethodInvocation; public abstract class BaseSecurityAdvice { private MindmapService mindmapService = null; - public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException,AccessDeniedSecurityException - { + public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException { final User user = Utils.getUser(); final Object argument = methodInvocation.getArguments()[0]; boolean isAllowed; - if (argument instanceof MindMap) - { - isAllowed = isAllowed(user,(MindMap) argument); - } - else if (argument instanceof Integer) - { - isAllowed = isAllowed(user, ((Integer)argument)); - } - else - { - throw new UnexpectedArgumentException("Argument " +argument); + if (argument instanceof MindMap) { + isAllowed = isAllowed(user, (MindMap) argument); + } else if (argument instanceof Integer) { + isAllowed = isAllowed(user, ((Integer) argument)); + } else { + throw new UnexpectedArgumentException("Argument " + argument); } - if (!isAllowed) - { - throw new AccessDeniedSecurityException("User not allowed to invoke:" + methodInvocation); + if (!isAllowed) { + throw new AccessDeniedSecurityException("User '" + user.getEmail() + "' not allowed to invoke:" + methodInvocation); } } protected abstract boolean isAllowed(User user, MindMap map); + protected abstract boolean isAllowed(User user, int mapId); - protected MindmapService getMindmapService() - { + protected MindmapService getMindmapService() { return mindmapService; } - public void setMindmapService(MindmapService service) - { + public void setMindmapService(MindmapService service) { this.mindmapService = service; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java index 802a41f8..becf50b0 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java @@ -23,25 +23,23 @@ import org.aopalliance.intercept.MethodInvocation; import com.wisemapping.model.UserRole; import com.wisemapping.model.User; import com.wisemapping.model.MindMap; +import org.jetbrains.annotations.NotNull; public class ViewBaseSecurityAdvise extends BaseSecurityAdvice - implements MethodInterceptor -{ + implements MethodInterceptor { private UserRole grantedRole = UserRole.VIEWER; - public Object invoke(MethodInvocation methodInvocation) throws Throwable { + public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable { checkRole(methodInvocation); return methodInvocation.proceed(); } - protected boolean isAllowed(User user, MindMap map) - { - return getMindmapService().isAllowedToView(user,map,grantedRole); + protected boolean isAllowed(User user, MindMap map) { + return getMindmapService().isAllowedToView(user, map, grantedRole); } - protected boolean isAllowed(User user, int mapId) - { - return getMindmapService().isAllowedToView(user,mapId,grantedRole); - } + protected boolean isAllowed(User user, int mapId) { + return getMindmapService().isAllowedToView(user, mapId, grantedRole); + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index d6e1a367..e73eab93 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -47,16 +47,15 @@ public class MindmapServiceImpl } public boolean isAllowedToView(User user, MindMap map, UserRole grantedRole) { - boolean isAllowed = false; + boolean result = false; if (map != null) { - if (map.isPublic()) { - isAllowed = true; + result = true; } else if (user != null) { - isAllowed = isAllowedToCollaborate(user, map, grantedRole); + result = isAllowedToCollaborate(user, map, grantedRole); } } - return isAllowed; + return result; } public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, UserRole grantedRole) { diff --git a/wise-webapp/src/main/webapp/WEB-INF/web.xml b/wise-webapp/src/main/webapp/WEB-INF/web.xml index d62b5db1..a778bb6f 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/web.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/web.xml @@ -90,6 +90,7 @@ contextConfigLocation + /WEB-INF/wisemapping-nservlet.xml /WEB-INF/wisemapping-servlet.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-aop.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-aop.xml index 270a65cf..4e5ab45e 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-aop.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-aop.xml @@ -26,7 +26,6 @@ update* add* remove* - remove* diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml new file mode 100644 index 00000000..64ab8a1d --- /dev/null +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + browserNotSupported + + securityError + emailNotExistsError + + + + + + + + + + + + /WEB-INF/defs/definitions.xml + + + + + + + + + + + + + + + + + + + + + + / + /index.jsp + /c/home.htm + /c/login.htm + /c/userRegistration.htm + /c/captcha.htm + /c/publicView.htm + /service/* + /c/search.htm + /c/keyboard.htm + /c/renameMap.htm + /c/embeddedView.htm + /c/forgotPassword.htm + + + + + + + + messages + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 7d14529a..a11f4af7 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -2,43 +2,6 @@ - - - - - - - - / - /index.jsp - /c/home.htm - /c/login.htm - /c/userRegistration.htm - /c/captcha.htm - /c/publicView.htm - /service/* - /c/search.htm - /c/keyboard.htm - /c/renameMap.htm - /c/embeddedView.htm - /c/forgotPassword.htm - - - - - - - - - - browserNotSupported - - securityError - emailNotExistsError - - - @@ -50,19 +13,6 @@ - - - - - - - - - - messages - - - - <spring:message code="SITE.TITLE"/> - ${mindmap.title}