From 79b009e29ebe2304dd24f108c4b19f8cccd6ddc0 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 6 Jun 2012 00:48:46 -0300 Subject: [PATCH] Add wisemapping support for import. --- .../wisemapping/controller/MindmapCooker.java | 63 ---------- .../controller/MindmapEditorController.java | 70 ------------ .../controller/PublicViewController.java | 42 ------- .../wisemapping/dao/MindmapManagerImpl.java | 38 +++--- .../java/com/wisemapping/model/MindMap.java | 9 +- .../wisemapping/rest/MindmapController.java | 47 ++++---- .../wisemapping/rest/model/RestMindmap.java | 8 +- .../java/com/wisemapping/security/Utils.java | 5 + .../security/aop/BaseSecurityAdvice.java | 2 - .../security/aop/UpdateSecurityAdvise.java | 23 ++-- .../wisemapping/service/MindmapService.java | 4 +- .../service/MindmapServiceImpl.java | 12 +- .../com/wisemapping/view/MindMapBean.java | 5 + .../WEB-INF/classes/messages.properties | 6 +- .../WEB-INF/classes/messages_es.properties | 3 +- .../WEB-INF/classes/messages_fr.properties | 2 - .../main/webapp/WEB-INF/defs/definitions.xml | 4 +- .../webapp/WEB-INF/wisemapping-servlet.xml | 15 --- wise-webapp/src/main/webapp/js/mymaps.js | 56 ++++----- wise-webapp/src/main/webapp/jsp/login.jsp | 14 ++- .../src/main/webapp/jsp/mindmapImport.jsp | 108 +++++++++++------- .../src/main/webapp/jsp/mindmapList.jsp | 15 +++ wise-webapp/src/main/webapp/jsp/template.jsp | 2 +- 23 files changed, 214 insertions(+), 339 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/MindmapCooker.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/MindmapEditorController.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/PublicViewController.java diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapCooker.java b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapCooker.java deleted file mode 100644 index 94f4e701..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapCooker.java +++ /dev/null @@ -1,63 +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 org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.wisemapping.model.MindMap; - -/** - * Usage: http://localhost:8080/wisemapping/c/cooker?action=edit&mapId=12 - */ -public class MindmapCooker extends BaseMultiActionController { - - public static final String MINDMAP_ID_PARAMETER = "mapId"; - public static final String MAP_XML_PARAM = "mapXml"; - - public ModelAndView edit(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - - final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER); - final int mapId = Integer.parseInt(mindmapId); - final MindMap mindmap = getMindmapService().getMindmapById(mapId); - - // Mark as try mode... - final ModelAndView view = new ModelAndView("mindmapCooker", "mindmap", mindmap); - return view; - } - - public ModelAndView save(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - - final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER); - final int mapId = Integer.parseInt(mindmapId); - final MindMap mindmap = getMindmapService().getMindmapById(mapId); - - String xml = httpServletRequest.getParameter("xml"); - mindmap.setXmlStr(xml); - - getMindmapService().updateMindmap(mindmap, false); - - // Mark as try mode... - final ModelAndView view = new ModelAndView("mindmapCooker", "mindmap", mindmap); - return view; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapEditorController.java b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapEditorController.java deleted file mode 100644 index bf98ca22..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapEditorController.java +++ /dev/null @@ -1,70 +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.filter.UserAgent; -import com.wisemapping.model.MindMap; -import com.wisemapping.security.Utils; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; -import org.springframework.web.servlet.view.RedirectView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class MindmapEditorController extends BaseMultiActionController { - - public static final String MINDMAP_ID_PARAMETER = "mapId"; - public static final String MAP_XML_PARAM = "mapXml"; - - public ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - return new ModelAndView(new RedirectView("maps/")); - } - - public ModelAndView open(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - - ModelAndView view; - - final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER); - final int mapId = Integer.parseInt(mindmapId); - - UserAgent userAgent = UserAgent.create(httpServletRequest); - if(userAgent.needsGCF()){ - view = new ModelAndView("gcfPluginNeeded"); - view.addObject(MINDMAP_ID_PARAMETER, mindmapId); - } - else{ - - final MindMap mindmap = getMindmapService().getMindmapById(mapId); - - // Mark as try mode... - view = new ModelAndView("mindmapEditor", "mindmap", mindmap); - view.addObject("editorTryMode", false); - final boolean showHelp = isWelcomeMap(mindmap); - view.addObject("showHelp", showHelp); - view.addObject("user", Utils.getUser()); - } - return view; - } - - private boolean isWelcomeMap(MindMap map) { - return map.getTitle().startsWith("Welcome "); - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/PublicViewController.java b/wise-webapp/src/main/java/com/wisemapping/controller/PublicViewController.java deleted file mode 100644 index be535277..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/PublicViewController.java +++ /dev/null @@ -1,42 +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 org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.wisemapping.model.MindMap; - -public class PublicViewController extends BaseMultiActionController { - - protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) - throws Exception - { - - final MindMap mindmap = super.getMindmapFromRequest(httpServletRequest); - - final ModelAndView view = new ModelAndView("mindmapPublicView"); - view.addObject("mindmap", mindmap); - view.addObject("viewTitle","'"+mindmap.getTitle()+"' Map View"); - return view; - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 246f26c0..9df4d0a6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -19,6 +19,7 @@ package com.wisemapping.dao; import com.wisemapping.model.*; +import org.jetbrains.annotations.NotNull; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.SimpleExpression; @@ -35,10 +36,10 @@ public class MindmapManagerImpl public Collaborator getCollaboratorBy(final String email) { final Collaborator collaborator; - final List colaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email); - if (colaborators != null && !colaborators.isEmpty()) { - assert colaborators.size() == 1 : "More than one user with the same username!"; - collaborator = (Collaborator) colaborators.get(0); + final List collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email); + if (collaborators != null && !collaborators.isEmpty()) { + assert collaborators.size() == 1 : "More than one user with the same username!"; + collaborator = collaborators.get(0); } else { collaborator = null; } @@ -46,24 +47,22 @@ public class MindmapManagerImpl } public List search(MindMapCriteria criteria) { - return search(criteria,-1); + return search(criteria, -1); } - public List getHistoryFrom(int mindmapId) - { + public List getHistoryFrom(int mindmapId) { final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class); - hibernateCriteria.add(Restrictions.eq("mindmapId",mindmapId)); - hibernateCriteria.addOrder( Order.desc("creationTime")); + hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId)); + hibernateCriteria.addOrder(Order.desc("creationTime")); // Mientras no haya paginacion solo los 10 primeros // This line throws errors in some environments, so getting all history and taking firsts 10 records // hibernateCriteria.setMaxResults(10); List list = hibernateCriteria.list(); - return list.subList(0,(10 search(MindMapCriteria criteria, int maxResult) { @@ -161,9 +160,8 @@ public class MindmapManagerImpl return result; } - public void addView(int mapId) - { - + public void addView(int mapId) { + } public void addMindmap(User user, MindMap mindMap) { @@ -175,11 +173,10 @@ public class MindmapManagerImpl getSession().save(mindMap); } - public void updateMindmap(MindMap mindMap, boolean saveHistory) { + public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) { assert mindMap != null : "Save Mindmap: Mindmap is required!"; getHibernateTemplate().saveOrUpdate(mindMap); - if (saveHistory) - { + if (saveHistory) { saveHistory(mindMap); } } @@ -188,8 +185,7 @@ public class MindmapManagerImpl getHibernateTemplate().delete(mindMap); } - public void saveHistory(MindMap mindMap) - { + public void saveHistory(MindMap mindMap) { final MindMapHistory history = new MindMapHistory(); history.setXml(mindMap.getXml()); 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 a149f176..23a1735a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -211,7 +211,10 @@ public class MindMap { this.creationTime = creationTime; } - public void setOwner(User owner) { + public void setOwner(@NotNull User owner) { + if (owner == null) { + throw new IllegalArgumentException("Owner can not be null"); + } this.owner = owner; } @@ -241,6 +244,10 @@ public class MindMap { } public void setStarred(@NotNull Collaborator collaborator, boolean value) { + if(collaborator==null){ + throw new IllegalStateException("Collaborator can not be null"); + } + CollaboratorProperties collaboratorProperties = this.findUserProperty(collaborator); if (collaboratorProperties == null) { collaboratorProperties = new CollaboratorProperties(collaborator, this); 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 9027dcd7..57579f49 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -174,12 +174,6 @@ public class MindmapController extends BaseController { saveMindmap(minor, mindMap, user); } - private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException { - final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), ""); - result.rejectValue(fieldName, "error.not-specified", null, message); - return new ValidationException(result); - } - @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) @@ -261,16 +255,17 @@ public class MindmapController extends BaseController { } } - private void saveMindmap(boolean minor, @NotNull final MindMap mindMap, @NotNull final User user) throws WiseMappingException { - final Calendar now = Calendar.getInstance(); - mindMap.setLastModificationTime(now); - mindMap.setLastModifierUser(user.getUsername()); - mindmapService.updateMindmap(mindMap, minor); - } - - @RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"}) + @RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json", "application/wisemapping+xml"}) @ResponseStatus(value = HttpStatus.CREATED) - public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response) throws IOException, WiseMappingException { + public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException { + + // Overwrite title and description if they where specified by parameter. + if (title != null && !title.isEmpty()) { + restMindmap.setTitle(title); + } + if (description != null && !description.isEmpty()) { + restMindmap.setDescription(description); + } // Validate ... final BindingResult result = new BeanPropertyBindingResult(restMindmap, ""); @@ -279,19 +274,16 @@ public class MindmapController extends BaseController { throw new ValidationException(result); } - // Some basic validations ... - final User user = Utils.getUser(); - // If the user has not specified the xml content, add one ... final MindMap delegated = restMindmap.getDelegated(); String xml = restMindmap.getXml(); if (xml == null || xml.isEmpty()) { xml = MindMap.getDefaultMindmapXml(restMindmap.getTitle()); } - delegated.setOwner(user); delegated.setXmlStr(xml); // Add new mindmap ... + final User user = Utils.getUser(); mindmapService.addMindmap(delegated, user); // Return the new created map ... @@ -306,11 +298,11 @@ public class MindmapController extends BaseController { // Convert map ... final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND); final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml); - final MindMap mindMap = importer.importMap(title, description, stream); + final MindMap mindMap = importer.importMap(title, "", stream); // Save new map ... final User user = Utils.getUser(); - createMap(new RestMindmap(mindMap, user), response); + createMap(new RestMindmap(mindMap, user), response, title, description); } @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"}) @@ -340,4 +332,17 @@ public class MindmapController extends BaseController { response.setHeader("Location", "/service/maps/" + clonedMap.getId()); response.setHeader("ResourceId", Integer.toString(clonedMap.getId())); } + + private void saveMindmap(boolean minor, @NotNull final MindMap mindMap, @NotNull final User user) throws WiseMappingException { + final Calendar now = Calendar.getInstance(); + mindMap.setLastModificationTime(now); + mindMap.setLastModifierUser(user.getUsername()); + mindmapService.updateMindmap(mindMap, minor); + } + + private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException { + final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), ""); + result.rejectValue(fieldName, "error.not-specified", null, message); + return new ValidationException(result); + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java index 7ae6850c..dfb66647 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java @@ -4,6 +4,7 @@ package com.wisemapping.rest.model; import com.wisemapping.model.Collaborator; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; +import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,7 +39,7 @@ public class RestMindmap { } public RestMindmap() { - this(new MindMap(), null); + this(new MindMap(), Utils.getUser()); } @@ -56,7 +57,6 @@ public class RestMindmap { return result; } - public String getDescription() { return mindmap.getDescription(); } @@ -161,7 +161,9 @@ public class RestMindmap { } public void setStarred(boolean value) { - mindmap.setStarred(collaborator, value); + if (collaborator != null) { + mindmap.setStarred(collaborator, value); + } } @JsonIgnore diff --git a/wise-webapp/src/main/java/com/wisemapping/security/Utils.java b/wise-webapp/src/main/java/com/wisemapping/security/Utils.java index 141b884d..e71c6c67 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/Utils.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/Utils.java @@ -41,6 +41,7 @@ final public class Utils { return result; } + @NotNull public static User getUser() { User result = null; final Authentication auth = SecurityContextHolder.getContext().getAuthentication(); @@ -51,6 +52,10 @@ final public class Utils { result = ((UserDetails)principal).getUser(); } } + + if(result==null){ + throw new IllegalStateException("User could not be retrieved"); + } return result; } } 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 1bf0652d..63902ccb 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 @@ -31,9 +31,7 @@ public abstract class BaseSecurityAdvice { 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) { diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java index 0c67dcac..dd627030 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java @@ -24,11 +24,11 @@ import com.wisemapping.model.MindMap; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; +import org.jetbrains.annotations.NotNull; public class UpdateSecurityAdvise - extends BaseSecurityAdvice - implements MethodInterceptor -{ + extends BaseSecurityAdvice + implements MethodInterceptor { private UserRole grantedRole = UserRole.COLLABORATOR; @@ -37,13 +37,18 @@ public class UpdateSecurityAdvise return methodInvocation.proceed(); } - protected boolean isAllowed(User user, MindMap map) - { - return getMindmapService().isAllowedToView(user,map,grantedRole); + protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) { + boolean result; + if (map.getOwner() == null) { + // This means that the map is new and is an add operation. + result = true; + } else { + result = getMindmapService().isAllowedToView(user, map, grantedRole); + } + return result; } - 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/MindmapService.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java index 6209bcbf..68ac46a0 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -41,7 +41,7 @@ public interface MindmapService { public void addMindmap(MindMap map, User user) throws WiseMappingException; - public void addCollaborators(MindMap mindmap, String[] colaboratorEmails, UserRole role, ColaborationEmail email) + public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email) throws InvalidColaboratorException; public void addTags(MindMap mindmap, String tags); @@ -60,7 +60,7 @@ public interface MindmapService { public boolean isAllowedToView(User user, int mapId, UserRole allowedRole); - public boolean isAllowedToColaborate(User user, int mapId, UserRole grantedRole); + public boolean isAllowedToCollaborate(User user, int mapId, UserRole grantedRole); public boolean isAllowedToCollaborate(User user, MindMap map, UserRole 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 6b93ba3c..7949075d 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -36,7 +36,7 @@ public class MindmapServiceImpl private UserService userService; private Mailer mailer; - public boolean isAllowedToColaborate(User user, int mapId, UserRole grantedRole) { + public boolean isAllowedToCollaborate(@NotNull User user, int mapId, @NotNull UserRole grantedRole) { final MindMap map = mindmapManager.getMindmapById(mapId); return isAllowedToCollaborate(user, map, grantedRole); } @@ -46,7 +46,7 @@ public class MindmapServiceImpl return isAllowedToView(user, map, grantedRole); } - public boolean isAllowedToView(User user, MindMap map, UserRole grantedRole) { + public boolean isAllowedToView(@NotNull User user, @NotNull MindMap map, @NotNull UserRole grantedRole) { boolean result = false; if (map != null) { if (map.isPublic()) { @@ -162,16 +162,16 @@ public class MindmapServiceImpl final MindmapUser mindmapUser = new MindmapUser(UserRole.OWNER.ordinal(), dbUser, map); map.getMindmapUsers().add(mindmapUser); - mindmapManager.addMindmap(user, map); + mindmapManager.addMindmap(dbUser, map); } - public void addCollaborators(MindMap mindmap, String[] colaboratorEmails, UserRole role, ColaborationEmail email) + public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email) throws InvalidColaboratorException { - if (colaboratorEmails != null && colaboratorEmails.length > 0) { + if (collaboratorEmails != null && collaboratorEmails.length > 0) { final Collaborator owner = mindmap.getOwner(); final Set mindmapUsers = mindmap.getMindmapUsers(); - for (String colaboratorEmail : colaboratorEmails) { + for (String colaboratorEmail : collaboratorEmails) { if (owner.getEmail().equals(colaboratorEmail)) { throw new InvalidColaboratorException("The user " + owner.getEmail() + " is the owner"); } diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index ad48fa61..e119dd5e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -22,6 +22,7 @@ import com.wisemapping.model.MindMap; import com.wisemapping.model.MindmapUser; import com.wisemapping.model.UserRole; import com.wisemapping.model.User; +import com.wisemapping.security.Utils; import java.text.DateFormat; import java.util.*; @@ -57,6 +58,10 @@ public class MindMapBean { return mindMap.getId(); } + public boolean isStarred() { + return mindMap.isStarred(Utils.getUser()); + } + public List getViewers() { return viewers; } 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 8c895f3b..f3ca1965 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties @@ -231,11 +231,9 @@ UNEXPECTED_ERROR_SERVER_ERROR=We're sorry, an error has occurred and we can't pr NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore. NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted. 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 0.9 version 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 maps and WiseMapping maps to your list of maps. Select the file you want to import. PRINT=Print -FREE_MIND_FILE=FreeMind File +MIND_FILE=File IMPORT_MAP_ERROR=FreeMind file could not be imported. {0} MAP_TITLE_ALREADY_EXISTS=A map already exists with this name. EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post! 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 8fb4bad3..a6804bad 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 @@ -215,9 +215,8 @@ NO_ENOUGH_PERMISSIONS_DETAILS=No tiene suficiente permisos de acceso para ver es SHARING=Colaboración IMPORT_MINDMAP=Importar mapa IMPORT_MINDMAP_DETAILS=Tiene mapas creados con FreeMind?. Ningun problema, los puede importar!. -IMPORT_MINDMAP_INFO=Ahora puedes importar mapas de FreeMind a WiseMapping. Por favor, seleccione el mapa FreeMind que desea importar.
Los campos marcados con un asterisco * son requeridos. PRINT=Imprimir -FREE_MIND_FILE=Archivo FreeMind +FREE_MIND_FILE=Archivo de mapa mentaa IMPORT_MAP_ERROR=El archivo importado no parece ser un archivo FreeMind válido MAP_TITLE_ALREADY_EXISTS=Nombre de mapa ya existente. EMBEDDED_VIEWER=Incluya un visor de mapa en su sitio web, blog o post. 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 64052082..804a3017 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 @@ -230,9 +230,7 @@ NO_ENOUGH_PERMISSIONS_DETAILS = Vous ne pouvez pas acc\u00e9der \u00e0 cette car SHARING = Partager IMPORT_MINDMAP = Importer une carte IMPORT_MINDMAP_DETAILS = Vous avez d\u00e9j\u00e0 cr\u00e9\u00e9 des cartes sur FreeMind ou FreePlane? Pas de probl\u00e9me, importez-les! -IMPORT_MINDMAP_INFO=Vous pouvez importer les cartes FreeMind dans WiseMapping. Choisissez la carte que vous souhaiez importer.
Les champs avec une ast\u00e9risque sont requis. PRINT = Imprimer -FREE_MIND_FILE = Fichier FreeMind IMPORT_MAP_ERROR = Le fichier import\u00e9 ne semble pas \u00eatre un fichier FreeMind valide. MAP_TITLE_ALREADY_EXISTS = Le titre de la carte existe d\u00e9j\u00e0. EMBEDDED_VIEWER = Int\u00e9grer un visualiseur de carte dans votre propre site internet, blog ou billet. diff --git a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml index 142f203f..535ee2ae 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml @@ -164,9 +164,7 @@ - - - + 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 db4290e0..ebd572b5 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -27,12 +27,6 @@ - - - - - - @@ -131,11 +125,6 @@ - - - - - @@ -145,9 +134,6 @@ - - publicView - userController sharingController @@ -155,7 +141,6 @@ forgotPasswordController activationController changePasswordController - cookerController settingsController editProfileController historyController diff --git a/wise-webapp/src/main/webapp/js/mymaps.js b/wise-webapp/src/main/webapp/js/mymaps.js index fe3055fc..f1b759e4 100644 --- a/wise-webapp/src/main/webapp/js/mymaps.js +++ b/wise-webapp/src/main/webapp/js/mymaps.js @@ -161,6 +161,8 @@ jQuery.fn.dialogForm = function(options) { dialogElem.modal('hide'); $('#messagesPanel div').text(errorThrown).parent().show(); } + var acceptBtn = $('#' + containerId + ' .btn-accept'); + acceptBtn.button('reset'); } }); @@ -348,10 +350,6 @@ $(function() { }); }); - $("#importBtn").click(function() { - window.location = 'c/maps/import'; - }); - $("#duplicateBtn").click(function() { // Map to be cloned ... var tableElem = $('#mindmapListTable'); @@ -433,40 +431,36 @@ $(function() { }); $("#infoBtn").click(function() { - var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); - if (mapIds.length > 0) { - $('#info-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/details", function() { - $('#info-dialog-modal').modal(); - }); - - } + showEmbeddedDialog("c/maps/{mapId}/details", 'info-dialog-modal'); }); $("#publishBtn").click(function() { - var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); - if (mapIds.length > 0) { - $('#publish-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/publish", - function() { - $('#publish-dialog-modal .btn-accept').click(function() { - submitDialogForm(); - }); - $('#publish-dialog-modal').modal(); - }); - } + showEmbeddedDialog("c/maps/{mapId}/publish", "publish-dialog-modal"); }); $("#exportBtn").click(function() { - var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); - if (mapIds.length > 0) { - $('#export-dialog-modal .modal-body').load("c/maps/" + mapIds[0] + "/export", - function() { - $('#export-dialog-modal .btn-accept').click(function() { - submitDialogForm(); - }); - $('#export-dialog-modal').modal(); + showEmbeddedDialog("c/maps/{mapId}/export", 'export-dialog-modal'); + }); + + $("#importBtn").click(function() { + showEmbeddedDialog("c/maps/import", 'import-dialog-modal', true); + }); + + + var showEmbeddedDialog = function(urlTemplate, dialogElemId, ignore) { + var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); + if (mapIds.length > 0 || ignore) { + var mapId = mapIds[0]; + $('#' + dialogElemId + ' .modal-body').load(urlTemplate.replace("{mapId}", mapId), + function() { + $('#' + dialogElemId + ' .btn-accept').click(function() { + submitDialogForm(); }); - } - }); + $('#' + dialogElemId).modal(); + }); + } + }; + $("#actionButtons .shareMap").click(function() { }); diff --git a/wise-webapp/src/main/webapp/jsp/login.jsp b/wise-webapp/src/main/webapp/jsp/login.jsp index 19abcbbc..2af164bc 100644 --- a/wise-webapp/src/main/webapp/jsp/login.jsp +++ b/wise-webapp/src/main/webapp/jsp/login.jsp @@ -2,6 +2,15 @@ <%@ include file="/jsp/init.jsp" %> + + +

What is New:

@@ -38,8 +47,9 @@
- " - data-toggle="button">    + +    
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp index 3829b49a..6338df61 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp @@ -1,68 +1,98 @@ <%@ include file="/jsp/init.jsp" %> -
-

- -

+
-

+
-
+
+ +

+ +
- - +
+ + +
+
+ + +
+
- - + + +
- - Freemind (0.9) - WiseMapping - - -
- - " class="btn btn-primary"/> - " class="btn">
\ No newline at end of file diff --git a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp index 8be8b985..4d81a3c1 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp @@ -40,6 +40,7 @@
+

@@ -264,6 +265,20 @@
+ +
diff --git a/wise-webapp/src/main/webapp/jsp/template.jsp b/wise-webapp/src/main/webapp/jsp/template.jsp index 61f16f64..31eec2d7 100644 --- a/wise-webapp/src/main/webapp/jsp/template.jsp +++ b/wise-webapp/src/main/webapp/jsp/template.jsp @@ -28,7 +28,7 @@ - +