From 5f441c2c2052aab941bbdc3e185cd30b19d934d9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 15 Aug 2012 21:28:51 -0300 Subject: [PATCH] - IE window.open does not support base href tag. Fixed. --- .../com/wisemapping/dao/MindmapManager.java | 134 ++--- .../wisemapping/dao/MindmapManagerImpl.java | 436 +++++++------- .../com/wisemapping/exporter/Exporter.java | 56 +- .../exporter/FreemindExporter.java | 4 +- .../com/wisemapping/importer/Importer.java | 57 +- .../importer/freemind/FreemindImporter.java | 6 +- .../wisemapping/mail/NotificationService.java | 7 +- .../com/wisemapping/model/Collaboration.java | 206 +++---- .../java/com/wisemapping/model/MindMap.java | 551 +++++++++--------- .../ncontroller/ExtensionsController.java | 4 +- .../ncontroller/MindmapController.java | 15 +- .../wisemapping/rest/AccountController.java | 4 +- .../wisemapping/rest/MindmapController.java | 48 +- .../com/wisemapping/rest/MindmapFilter.java | 14 +- .../rest/model/RestCollaborationList.java | 2 - .../wisemapping/rest/model/RestMindmap.java | 8 +- .../rest/model/RestMindmapHistory.java | 6 - .../rest/model/RestMindmapInfo.java | 10 +- .../rest/model/RestMindmapList.java | 8 +- .../rest/view/ImportTransformationView.java | 4 +- .../security/aop/BaseSecurityAdvice.java | 133 +++-- .../security/aop/UpdateSecurityAdvise.java | 106 ++-- .../security/aop/ViewBaseSecurityAdvise.java | 90 +-- .../wisemapping/service/MindmapService.java | 23 +- .../service/MindmapServiceImpl.java | 26 +- .../wisemapping/service/UserServiceImpl.java | 11 +- .../validator/MapInfoValidator.java | 190 +++--- .../com/wisemapping/view/MindMapBean.java | 324 +++++----- .../com/wisemapping/view/MindMapInfoBean.java | 8 +- .../wisemapping/model/Collaboration.hbm.xml | 66 +-- .../com/wisemapping/model/MindMap.hbm.xml | 58 +- .../main/webapp/WEB-INF/wisemapping-dao.xml | 2 +- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 +- .../main/webapp/jsp/mindmapEditorToolbar.jsf | 2 +- .../src/main/webapp/jsp/mindmapEmbed.jsp | 2 +- .../src/main/webapp/jsp/mindmapPrint.jsp | 2 +- .../wisemapping/test/freemind/ExportTest.java | 8 +- .../test/freemind/ImportExportTest.java | 4 +- 38 files changed, 1310 insertions(+), 1327 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index 9b284c9c..edb4435e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -1,67 +1,67 @@ -/* -* 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.dao; - -import com.wisemapping.model.*; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public interface MindmapManager { - - Collaborator findCollaborator(@NotNull String email); - - Collaborator findCollaborator(long id); - - List findCollaboration(final long collaboratorId); - - List findCollaboration(final CollaborationRole userRole); - - Collaboration findCollaboration(final int mindmapId, final User user); - - List getAllMindmaps(); - - MindMap getMindmapById(int mindmapId); - - MindMap getMindmapByTitle(final String name, final User user); - - void addCollaborator(Collaborator collaborator); - - void addMindmap(User user, MindMap mindMap); - - void saveMindmap(MindMap mindMap); - - void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory); - - void removeCollaborator(@NotNull Collaborator collaborator); - - void removeMindmap(MindMap mindap); - - void removeCollaboration(Collaboration collaboration); - - public List search(MindMapCriteria criteria); - - public List search(MindMapCriteria criteria, int maxResult); - - public List getHistoryFrom(int mindmapId); - - public MindMapHistory getHistory(int historyId); - - void updateCollaboration(@NotNull Collaboration collaboration); -} +/* +* 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.dao; + +import com.wisemapping.model.*; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public interface MindmapManager { + + Collaborator findCollaborator(@NotNull String email); + + Collaborator findCollaborator(long id); + + List findCollaboration(final long collaboratorId); + + List findCollaboration(final CollaborationRole userRole); + + Collaboration findCollaboration(final int mindmapId, final User user); + + List getAllMindmaps(); + + Mindmap getMindmapById(int mindmapId); + + Mindmap getMindmapByTitle(final String name, final User user); + + void addCollaborator(Collaborator collaborator); + + void addMindmap(User user, Mindmap mindMap); + + void saveMindmap(Mindmap mindMap); + + void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory); + + void removeCollaborator(@NotNull Collaborator collaborator); + + void removeMindmap(Mindmap mindap); + + void removeCollaboration(Collaboration collaboration); + + public List search(MindMapCriteria criteria); + + public List search(MindMapCriteria criteria, int maxResult); + + public List getHistoryFrom(int mindmapId); + + public MindMapHistory getHistory(int historyId); + + void updateCollaboration(@NotNull Collaboration collaboration); +} 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 8d87fbf7..c29e2df3 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -1,218 +1,218 @@ -/* -* 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.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; -import org.hibernate.criterion.Junction; -import org.hibernate.criterion.Order; -import org.hibernate.Criteria; - -import java.util.List; -import java.util.Calendar; - -public class MindmapManagerImpl - extends HibernateDaoSupport - implements MindmapManager { - - @Override - public Collaborator findCollaborator(@NotNull final String email) { - final Collaborator collaborator; - 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 email!"; - collaborator = collaborators.get(0); - } else { - collaborator = null; - } - return collaborator; - } - - @Override - public List search(MindMapCriteria criteria) { - return search(criteria, -1); - } - - @Override - public List getHistoryFrom(int mindmapId) { - final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class); - 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 < list.size() ? 10 : list.size())); - } - - @Override - public MindMapHistory getHistory(int historyId) { - return getHibernateTemplate().get(MindMapHistory.class, historyId); - } - - @Override - public void updateCollaboration(@NotNull Collaboration collaboration) { - getHibernateTemplate().save(collaboration); - } - - @Override - public List search(MindMapCriteria criteria, int maxResult) { - final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class); - //always search public maps - hibernateCriteria.add(Restrictions.like("public", Boolean.TRUE)); - - if (criteria != null) { - final Junction junction; - if (criteria.isOrCriteria()) { - junction = Restrictions.disjunction(); - } else { - junction = Restrictions.conjunction(); - } - - if (criteria.getTitle() != null && criteria.getTitle().length() > 0) { - final SimpleExpression titleRestriction = Restrictions.like("title", "%" + criteria.getTitle() + "%"); - junction.add(titleRestriction); - } - - if (criteria.getDescription() != null && criteria.getDescription().length() > 0) { - final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%"); - junction.add(descriptionRestriction); - } - if (criteria.getTags().size() > 0) { - for (String tag : criteria.getTags()) { - final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%"); - junction.add(tagRestriction); - } - } - - hibernateCriteria.add(junction); - } -// if (maxResult>0) -// { -// hibernateCriteria.setMaxResults(maxResult); -// } - return hibernateCriteria.list(); - } - - @Override - public Collaborator findCollaborator(long id) { - return getHibernateTemplate().get(Collaborator.class, id); - } - - @Override - public List findCollaboration(final long collaboratorId) { - return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where colaborator_id=?", collaboratorId); - } - - @Override - public List findCollaboration(final CollaborationRole collaborationRole) { - return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where roleId=?", collaborationRole.ordinal()); - } - - @Override - public Collaboration findCollaboration(final int mindmapId, final User user) { - final Collaboration result; - - final List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()}); - if (mindMaps != null && !mindMaps.isEmpty()) { - result = mindMaps.get(0); - } else { - result = null; - } - - return result; - } - - @Override - public void addCollaborator(@NotNull Collaborator collaborator) { - assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!"; - getHibernateTemplate().save(collaborator); - } - - @Override - public void removeCollaboration(Collaboration collaboration) { - getHibernateTemplate().delete(collaboration); - } - - @Override - public void removeCollaborator(@NotNull Collaborator collaborator) { - getHibernateTemplate().delete(collaborator); - } - - @Override - public List getAllMindmaps() { - return getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping"); - } - - @Override - public MindMap getMindmapById(int mindmapId) { - return getHibernateTemplate().get(MindMap.class, mindmapId); - } - - @Override - public MindMap getMindmapByTitle(final String title, final User user) { - final MindMap result; - List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user}); - if (mindMaps != null && !mindMaps.isEmpty()) { - result = mindMaps.get(0); - } else { - result = null; - } - return result; - } - - @Override - public void addMindmap(User user, MindMap mindMap) { - saveMindmap(mindMap); - } - - @Override - public void saveMindmap(MindMap mindMap) { - assert mindMap != null : "Save Mindmap: Mindmap is required!"; - getSession().save(mindMap); - } - - @Override - public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) { - assert mindMap != null : "Save Mindmap: Mindmap is required!"; - getHibernateTemplate().saveOrUpdate(mindMap); - if (saveHistory) { - saveHistory(mindMap); - } - } - - @Override - public void removeMindmap(@NotNull final MindMap mindMap) { - getHibernateTemplate().delete(mindMap); - } - - private void saveHistory(@NotNull final MindMap mindMap) { - final MindMapHistory history = new MindMapHistory(); - - history.setXml(mindMap.getXml()); - history.setCreationTime(Calendar.getInstance()); - history.setEditor(mindMap.getLastEditor()); - history.setMindmapId(mindMap.getId()); - getHibernateTemplate().saveOrUpdate(history); - } -} - +/* +* 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.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; +import org.hibernate.criterion.Junction; +import org.hibernate.criterion.Order; +import org.hibernate.Criteria; + +import java.util.List; +import java.util.Calendar; + +public class MindmapManagerImpl + extends HibernateDaoSupport + implements MindmapManager { + + @Override + public Collaborator findCollaborator(@NotNull final String email) { + final Collaborator collaborator; + 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 email!"; + collaborator = collaborators.get(0); + } else { + collaborator = null; + } + return collaborator; + } + + @Override + public List search(MindMapCriteria criteria) { + return search(criteria, -1); + } + + @Override + public List getHistoryFrom(int mindmapId) { + final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class); + 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 < list.size() ? 10 : list.size())); + } + + @Override + public MindMapHistory getHistory(int historyId) { + return getHibernateTemplate().get(MindMapHistory.class, historyId); + } + + @Override + public void updateCollaboration(@NotNull Collaboration collaboration) { + getHibernateTemplate().save(collaboration); + } + + @Override + public List search(MindMapCriteria criteria, int maxResult) { + final Criteria hibernateCriteria = getSession().createCriteria(Mindmap.class); + //always search public maps + hibernateCriteria.add(Restrictions.like("public", Boolean.TRUE)); + + if (criteria != null) { + final Junction junction; + if (criteria.isOrCriteria()) { + junction = Restrictions.disjunction(); + } else { + junction = Restrictions.conjunction(); + } + + if (criteria.getTitle() != null && criteria.getTitle().length() > 0) { + final SimpleExpression titleRestriction = Restrictions.like("title", "%" + criteria.getTitle() + "%"); + junction.add(titleRestriction); + } + + if (criteria.getDescription() != null && criteria.getDescription().length() > 0) { + final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%"); + junction.add(descriptionRestriction); + } + if (criteria.getTags().size() > 0) { + for (String tag : criteria.getTags()) { + final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%"); + junction.add(tagRestriction); + } + } + + hibernateCriteria.add(junction); + } +// if (maxResult>0) +// { +// hibernateCriteria.setMaxResults(maxResult); +// } + return hibernateCriteria.list(); + } + + @Override + public Collaborator findCollaborator(long id) { + return getHibernateTemplate().get(Collaborator.class, id); + } + + @Override + public List findCollaboration(final long collaboratorId) { + return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where colaborator_id=?", collaboratorId); + } + + @Override + public List findCollaboration(final CollaborationRole collaborationRole) { + return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where roleId=?", collaborationRole.ordinal()); + } + + @Override + public Collaboration findCollaboration(final int mindmapId, final User user) { + final Collaboration result; + + final List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()}); + if (mindMaps != null && !mindMaps.isEmpty()) { + result = mindMaps.get(0); + } else { + result = null; + } + + return result; + } + + @Override + public void addCollaborator(@NotNull Collaborator collaborator) { + assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!"; + getHibernateTemplate().save(collaborator); + } + + @Override + public void removeCollaboration(Collaboration collaboration) { + getHibernateTemplate().delete(collaboration); + } + + @Override + public void removeCollaborator(@NotNull Collaborator collaborator) { + getHibernateTemplate().delete(collaborator); + } + + @Override + public List getAllMindmaps() { + return getHibernateTemplate().find("from com.wisemapping.model.Mindmap wisemapping"); + } + + @Override + public Mindmap getMindmapById(int mindmapId) { + return getHibernateTemplate().get(Mindmap.class, mindmapId); + } + + @Override + public Mindmap getMindmapByTitle(final String title, final User user) { + final Mindmap result; + List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Mindmap wisemapping where title=? and creator=?", new Object[]{title, user}); + if (mindMaps != null && !mindMaps.isEmpty()) { + result = mindMaps.get(0); + } else { + result = null; + } + return result; + } + + @Override + public void addMindmap(User user, Mindmap mindMap) { + saveMindmap(mindMap); + } + + @Override + public void saveMindmap(Mindmap mindMap) { + assert mindMap != null : "Save Mindmap: Mindmap is required!"; + getSession().save(mindMap); + } + + @Override + public void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory) { + assert mindMap != null : "Save Mindmap: Mindmap is required!"; + getHibernateTemplate().saveOrUpdate(mindMap); + if (saveHistory) { + saveHistory(mindMap); + } + } + + @Override + public void removeMindmap(@NotNull final Mindmap mindMap) { + getHibernateTemplate().delete(mindMap); + } + + private void saveHistory(@NotNull final Mindmap mindMap) { + final MindMapHistory history = new MindMapHistory(); + + history.setXml(mindMap.getXml()); + history.setCreationTime(Calendar.getInstance()); + history.setEditor(mindMap.getLastEditor()); + history.setMindmapId(mindMap.getId()); + getHibernateTemplate().saveOrUpdate(history); + } +} + diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/Exporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/Exporter.java index 272a6a77..0e8c66ac 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/Exporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/Exporter.java @@ -1,28 +1,28 @@ -/* -* 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.exporter; - -import com.wisemapping.model.MindMap; - -import java.io.OutputStream; - -public interface Exporter { - public void export(byte[] xml, OutputStream outputStream) throws ExportException; - public void export(MindMap map, OutputStream outputStream) throws ExportException; -} +/* +* 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.exporter; + +import com.wisemapping.model.Mindmap; + +import java.io.OutputStream; + +public interface Exporter { + public void export(byte[] xml, OutputStream outputStream) throws ExportException; + public void export(Mindmap map, OutputStream outputStream) throws ExportException; +} diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java index 96e0d3d3..9cca5102 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java @@ -20,7 +20,7 @@ package com.wisemapping.exporter; import com.wisemapping.importer.freemind.FreemindIconConverter; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.ShapeStyle; import com.wisemapping.util.JAXBUtils; import com.wisemapping.jaxb.freemind.*; @@ -48,7 +48,7 @@ public class FreemindExporter private Map nodesMap = null; - public void export(MindMap map, OutputStream outputStream) throws ExportException { + public void export(Mindmap map, OutputStream outputStream) throws ExportException { export(map.getXml(), outputStream); } diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java b/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java index f54ecaff..85156237 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java @@ -1,29 +1,28 @@ -/* -* 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.importer; - -import com.wisemapping.model.MindMap; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.io.InputStream; - -public interface Importer { - public MindMap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException; -} +/* +* 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.importer; + +import com.wisemapping.model.Mindmap; +import org.jetbrains.annotations.NotNull; + +import java.io.InputStream; + +public interface Importer { + public Mindmap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException; +} diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index fb6a8dbb..e030ec2a 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -22,7 +22,7 @@ import com.sun.org.apache.xerces.internal.dom.TextImpl; import com.wisemapping.importer.Importer; import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.VersionNumber; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.ShapeStyle; import com.wisemapping.util.JAXBUtils; import com.wisemapping.jaxb.freemind.*; @@ -94,9 +94,9 @@ public class FreemindImporter } - public MindMap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException { + public Mindmap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException { - final MindMap result = new MindMap(); + final Mindmap result = new Mindmap(); nodesMap = new HashMap(); relationships = new ArrayList(); mindmapObjectFactory = new com.wisemapping.jaxb.wisemap.ObjectFactory(); diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java index 1f057a84..e0c64819 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java @@ -19,14 +19,13 @@ package com.wisemapping.mail; import com.wisemapping.model.Collaboration; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; -import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.HashMap; @@ -43,7 +42,7 @@ final public class NotificationService { } - public void newCollaboration(@NotNull Collaboration collaboration, @NotNull MindMap mindmap, @NotNull User user, @Nullable String message) { + public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull User user, @Nullable String message) { try { // Sent collaboration email ... @@ -151,7 +150,7 @@ final public class NotificationService { // } } - public void reportMindmapEditorError(@NotNull MindMap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) { + public void reportMindmapEditorError(@NotNull Mindmap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) { try { final Map model = new HashMap(); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 9240d3cb..2a657e87 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -1,103 +1,103 @@ -/* -* 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.model; - -import org.jetbrains.annotations.NotNull; - -public class Collaboration { - - private long id; - private CollaborationRole role; - private MindMap mindMap; - private Collaborator collaborator; - private CollaborationProperties collaborationProperties; - - public Collaboration() { - } - - public Collaboration(@NotNull CollaborationRole role, @NotNull Collaborator collaborator, @NotNull MindMap mindmap) { - this.role = role; - this.mindMap = mindmap; - this.collaborator = collaborator; - - // Guarantee referential integrity - mindmap.addCollaboration(this); - collaborator.addCollaboration(this); - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public int getRoleId() { - return role.ordinal(); - } - - public void setRoleId(int roleId) { - this.role = CollaborationRole.values()[roleId]; - } - - public CollaborationRole getRole() { - return role; - } - - public void setRole(@NotNull CollaborationRole role) { - this.role = role; - } - - public MindMap getMindMap() { - return mindMap; - } - - public void setMindMap(MindMap mindMap) { - this.mindMap = mindMap; - } - - @NotNull - public Collaborator getCollaborator() { - return collaborator; - } - - public void setCollaborator(@NotNull Collaborator collaborator) { - this.collaborator = collaborator; - } - - @NotNull - public CollaborationProperties getCollaborationProperties() { - CollaborationProperties result = collaborationProperties; - if (result == null) { - collaborationProperties = new CollaborationProperties(); - result = collaborationProperties; - } - return result; - } - - public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { - this.collaborationProperties = collaborationProperties; - } - - public boolean hasPermissions(@NotNull CollaborationRole role) { - return this.getRole().ordinal() <= role.ordinal(); - - } -} +/* +* 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.model; + +import org.jetbrains.annotations.NotNull; + +public class Collaboration { + + private long id; + private CollaborationRole role; + private Mindmap mindMap; + private Collaborator collaborator; + private CollaborationProperties collaborationProperties; + + public Collaboration() { + } + + public Collaboration(@NotNull CollaborationRole role, @NotNull Collaborator collaborator, @NotNull Mindmap mindmap) { + this.role = role; + this.mindMap = mindmap; + this.collaborator = collaborator; + + // Guarantee referential integrity + mindmap.addCollaboration(this); + collaborator.addCollaboration(this); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public int getRoleId() { + return role.ordinal(); + } + + public void setRoleId(int roleId) { + this.role = CollaborationRole.values()[roleId]; + } + + public CollaborationRole getRole() { + return role; + } + + public void setRole(@NotNull CollaborationRole role) { + this.role = role; + } + + public Mindmap getMindMap() { + return mindMap; + } + + public void setMindMap(Mindmap mindMap) { + this.mindMap = mindMap; + } + + @NotNull + public Collaborator getCollaborator() { + return collaborator; + } + + public void setCollaborator(@NotNull Collaborator collaborator) { + this.collaborator = collaborator; + } + + @NotNull + public CollaborationProperties getCollaborationProperties() { + CollaborationProperties result = collaborationProperties; + if (result == null) { + collaborationProperties = new CollaborationProperties(); + result = collaborationProperties; + } + return result; + } + + public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { + this.collaborationProperties = collaborationProperties; + } + + public boolean hasPermissions(@NotNull CollaborationRole role) { + return this.getRole().ordinal() <= role.ordinal(); + + } +} 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 dc4bdde2..e2eb0dad 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -1,276 +1,275 @@ -/* -* 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.model; - -import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.util.ZipUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -public class MindMap { - private static final String UTF_8 = "UTF-8"; - - //~ Instance fields ...................................................................................... - private int id; - private Calendar creationTime; - private String description; - - private boolean isPublic; - private Calendar lastModificationTime; - private User lastEditor; - - private Set collaborations = new HashSet(); - - private User creator; - private String tags; - private String title; - private byte[] xml; - - //~ Constructors ......................................................................................... - - public MindMap() { - } - - //~ Methods .............................................................................................. - - public void setXml(byte[] xml) { - this.xml = xml; - } - - public void setXmlStr(@NotNull String xml) - throws IOException { - this.xml = xml.getBytes(UTF_8); - } - - public byte[] getXml() { - return xml; - } - - public String getXmlStr() throws UnsupportedEncodingException { - String result = null; - if (this.xml != null) { - result = new String(this.xml, UTF_8); - } - return result; - } - - public byte[] getZippedXml() - throws IOException { - byte[] result = this.xml; - if (result != null) { - result = ZipUtils.stringToZip(new String(result, UTF_8)); - } - return result; - } - - public void setZippedXml(byte[] xml) - throws IOException { - this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8); - } - - public Set getCollaborations() { - return collaborations; - } - - public void setCollaborations(Set collaborations) { - this.collaborations = collaborations; - } - - public void addCollaboration(@NotNull Collaboration collaboration) { - collaborations.add(collaboration); - } - - public void removedCollaboration(@NotNull Collaboration collaboration) { - collaborations.add(collaboration); - } - - @Nullable - public Collaboration findCollaboration(@NotNull Collaborator collaborator) { - return this.findCollaboration(collaborator.getEmail()); - } - - @Nullable - public Collaboration findCollaboration(@NotNull String email) { - Collaboration result = null; - for (Collaboration collaboration : collaborations) { - if (collaboration.getCollaborator().getEmail().equals(email)) { - result = collaboration; - break; - } - } - return result; - } - - public boolean isPublic() { - return isPublic; - } - - public void setPublic(boolean isPublic) { - this.isPublic = isPublic; - } - - public Calendar getLastModificationTime() { - return lastModificationTime; - } - - public Date getLastModificationDate() { - return new Date(); - } - - public void setLastModificationTime(Calendar lastModificationTime) { - this.lastModificationTime = lastModificationTime; - } - - @Nullable - public User getLastEditor() { - return lastEditor; - } - - public void setLastEditor(@Nullable User lastEditor) { - this.lastEditor = lastEditor; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getXmlAsJsLiteral() - throws IOException { - String xml = this.getXmlStr(); - if (xml != null) { - xml = xml.replace("'", "\\'"); - xml = xml.replaceAll("\\r|\\n", ""); - xml = xml.trim(); - } - return xml; - } - - - public void setTags(String tags) { - this.tags = tags; - } - - public String getTags() { - return tags; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Calendar getCreationTime() { - return creationTime; - } - - public void setCreationTime(Calendar creationTime) { - this.creationTime = creationTime; - } - - public void setCreator(@NotNull User creator) { - if (creator == null) { - throw new IllegalArgumentException("Owner can not be null"); - } - this.creator = creator; - } - - public User getCreator() { - return creator; - } - - private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { - final Collaboration collaboration = this.findCollaboration(collaborator); - return collaboration != null ? collaboration.getCollaborationProperties() : null; - } - - public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException { - final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator); - collaborationProperties.setStarred(value); - } - - @NotNull - public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException { - if (collaborator == null) { - throw new IllegalStateException("Collaborator can not be null"); - } - - final Collaboration collaboration = this.findCollaboration(collaborator); - if (collaboration == null) { - throw new WiseMappingException("User is not collaborator"); - } - return collaboration.getCollaborationProperties(); - } - - public boolean isStarred(@NotNull Collaborator collaborator) { - final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator); - return collaboratorProperty != null && collaboratorProperty.getStarred(); - } - - public static String getDefaultMindmapXml(@NotNull final String title) { - - final StringBuilder result = new StringBuilder(); - result.append(""); - result.append(""); - return result.toString(); - } - - public MindMap shallowClone() { - final MindMap result = new MindMap(); - result.setDescription(this.getDescription()); - result.setTitle(this.getTitle()); - result.setXml(this.getXml()); - result.setTags(this.getTags()); - - return result; - } - - public boolean hasPermissions(@NotNull Collaborator collaborator, @NotNull CollaborationRole role) { - final Collaboration collaboration = this.findCollaboration(collaborator); - boolean result = false; - if (collaboration != null) { - result = collaboration.hasPermissions(role); - } - return result; - - } -} +/* +* 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.model; + +import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.util.ZipUtils; +import org.apache.commons.lang.StringEscapeUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +public class Mindmap { + private static final String UTF_8 = "UTF-8"; + + //~ Instance fields ...................................................................................... + private int id; + private Calendar creationTime; + private String description; + + private boolean isPublic; + private Calendar lastModificationTime; + private User lastEditor; + + private Set collaborations = new HashSet(); + + private User creator; + private String tags; + private String title; + private byte[] xml; + + //~ Constructors ......................................................................................... + + public Mindmap() { + } + + //~ Methods .............................................................................................. + + public void setXml(byte[] xml) { + this.xml = xml; + } + + public void setXmlStr(@NotNull String xml) + throws IOException { + this.xml = xml.getBytes(UTF_8); + } + + public byte[] getXml() { + return xml; + } + + public String getXmlStr() throws UnsupportedEncodingException { + String result = null; + if (this.xml != null) { + result = new String(this.xml, UTF_8); + } + return result; + } + + public byte[] getZippedXml() + throws IOException { + byte[] result = this.xml; + if (result != null) { + result = ZipUtils.stringToZip(new String(result, UTF_8)); + } + return result; + } + + public void setZippedXml(byte[] xml) + throws IOException { + this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8); + } + + public Set getCollaborations() { + return collaborations; + } + + public void setCollaborations(Set collaborations) { + this.collaborations = collaborations; + } + + public void addCollaboration(@NotNull Collaboration collaboration) { + collaborations.add(collaboration); + } + + public void removedCollaboration(@NotNull Collaboration collaboration) { + collaborations.add(collaboration); + } + + @Nullable + public Collaboration findCollaboration(@NotNull Collaborator collaborator) { + return this.findCollaboration(collaborator.getEmail()); + } + + @Nullable + public Collaboration findCollaboration(@NotNull String email) { + Collaboration result = null; + for (Collaboration collaboration : collaborations) { + if (collaboration.getCollaborator().getEmail().equals(email)) { + result = collaboration; + break; + } + } + return result; + } + + public boolean isPublic() { + return isPublic; + } + + public void setPublic(boolean isPublic) { + this.isPublic = isPublic; + } + + public Calendar getLastModificationTime() { + return lastModificationTime; + } + + public Date getLastModificationDate() { + return new Date(); + } + + public void setLastModificationTime(Calendar lastModificationTime) { + this.lastModificationTime = lastModificationTime; + } + + @Nullable + public User getLastEditor() { + return lastEditor; + } + + public void setLastEditor(@Nullable User lastEditor) { + this.lastEditor = lastEditor; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getXmlAsJsLiteral() + throws IOException { + String xml = this.getXmlStr(); + if (xml != null) { + xml = StringEscapeUtils.escapeJavaScript(xml); + } + return xml; + } + + + public void setTags(String tags) { + this.tags = tags; + } + + public String getTags() { + return tags; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Calendar getCreationTime() { + return creationTime; + } + + public void setCreationTime(Calendar creationTime) { + this.creationTime = creationTime; + } + + public void setCreator(@NotNull User creator) { + if (creator == null) { + throw new IllegalArgumentException("Owner can not be null"); + } + this.creator = creator; + } + + public User getCreator() { + return creator; + } + + private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { + final Collaboration collaboration = this.findCollaboration(collaborator); + return collaboration != null ? collaboration.getCollaborationProperties() : null; + } + + public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException { + final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator); + collaborationProperties.setStarred(value); + } + + @NotNull + public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException { + if (collaborator == null) { + throw new IllegalStateException("Collaborator can not be null"); + } + + final Collaboration collaboration = this.findCollaboration(collaborator); + if (collaboration == null) { + throw new WiseMappingException("User is not collaborator"); + } + return collaboration.getCollaborationProperties(); + } + + public boolean isStarred(@NotNull Collaborator collaborator) { + final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator); + return collaboratorProperty != null && collaboratorProperty.getStarred(); + } + + public static String getDefaultMindmapXml(@NotNull final String title) { + + final StringBuilder result = new StringBuilder(); + result.append(""); + result.append(""); + return result.toString(); + } + + public Mindmap shallowClone() { + final Mindmap result = new Mindmap(); + result.setDescription(this.getDescription()); + result.setTitle(this.getTitle()); + result.setXml(this.getXml()); + result.setTags(this.getTags()); + + return result; + } + + public boolean hasPermissions(@NotNull Collaborator collaborator, @NotNull CollaborationRole role) { + final Collaboration collaboration = this.findCollaboration(collaborator); + boolean result = false; + if (collaboration != null) { + result = collaboration.hasPermissions(role); + } + return result; + + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java index 5da41d6e..96b6e67b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java @@ -18,7 +18,7 @@ package com.wisemapping.ncontroller; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.service.MindmapService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -37,7 +37,7 @@ public class ExtensionsController { @RequestMapping(value = "try") public ModelAndView tryEditor() throws IOException { - final MindMap mindmap = mindmapService.findMindmapById(TRY_EXAMPLE_MINDMAP_ID); + final Mindmap mindmap = mindmapService.findMindmapById(TRY_EXAMPLE_MINDMAP_ID); ModelAndView view = new ModelAndView("mindmapEditor", "mindmap", mindmap); final String xmlMap = mindmap.getXmlAsJsLiteral(); 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 b94f31e4..7124b986 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -21,9 +21,8 @@ package com.wisemapping.ncontroller; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.CollaborationRole; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.MindMapHistory; -import com.wisemapping.model.User; import com.wisemapping.security.Utils; import com.wisemapping.service.MindmapService; import com.wisemapping.view.MindMapBean; @@ -77,7 +76,7 @@ public class MindmapController { @RequestMapping(value = "maps/{id}/export") public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException { - final MindMap mindmap = findMindmap(id); + final Mindmap mindmap = findMindmap(id); model.addAttribute("mindmap", mindmap); return "mindmapExport"; } @@ -90,7 +89,7 @@ public class MindmapController { @RequestMapping(value = "maps/{id}/share") public String showSharePage(@PathVariable int id, @NotNull Model model) { - final MindMap mindmap = findMindmap(id); + final Mindmap mindmap = findMindmap(id); model.addAttribute("mindmap", mindmap); return "mindmapShare"; } @@ -103,7 +102,7 @@ public class MindmapController { @RequestMapping(value = "maps/{id}/publish") public String showPublishPage(@PathVariable int id, @NotNull Model model) { - final MindMap mindmap = findMindmap(id); + final Mindmap mindmap = findMindmap(id); model.addAttribute("mindmap", mindmap); model.addAttribute("baseUrl", siteBaseUrl); return "mindmapPublish"; @@ -137,7 +136,7 @@ public class MindmapController { @RequestMapping(value = "maps/{id}/edit", method = RequestMethod.GET) public String showMindmapEditorPage(@PathVariable int id, @NotNull Model model) { final MindMapBean mindmapBean = findMindmapBean(id); - final MindMap mindmap = mindmapBean.getDelegated(); + final Mindmap mindmap = mindmapBean.getDelegated(); String result; if (mindmap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR)) { @@ -202,8 +201,8 @@ public class MindmapController { return "redirect:maps/" + mapId + "/embed?zoom=" + zoom; } - private MindMap findMindmap(long mapId) { - final MindMap mindmap = mindmapService.findMindmapById((int) mapId); + private Mindmap findMindmap(long mapId) { + final Mindmap mindmap = mindmapService.findMindmapById((int) mapId); if (mindmap == null) { throw new IllegalArgumentException("Mindmap could not be found"); } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java index 1784f3e4..f74d4ef5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java @@ -19,7 +19,7 @@ package com.wisemapping.rest; import com.wisemapping.mail.NotificationService; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import com.wisemapping.rest.model.RestLogItem; import com.wisemapping.security.Utils; @@ -96,7 +96,7 @@ public class AccountController extends BaseController { @RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void changePassword(@RequestBody RestLogItem item) { - final MindMap mindmap = mindmapService.findMindmapById(item.getMapId()); + final Mindmap mindmap = mindmapService.findMindmapById(item.getMapId()); final User user = Utils.getUser(); notificationService.reportMindmapEditorError(mindmap, user, item.getUserAgent(), item.getJsErrorMsg() + "\n" + item.getJsStack()); } 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 3348b5de..f3b948ae 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -57,7 +57,7 @@ public class MindmapController extends BaseController { @ResponseBody public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException { final User user = Utils.getUser(); - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final RestMindmap map = new RestMindmap(mindMap, user); return new ModelAndView("mapView", "map", map); @@ -66,7 +66,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/wisemapping+xml"}, params = {"download=wxml"}) @ResponseBody public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final Map values = new HashMap(); final User user = Utils.getUser(); @@ -78,7 +78,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"}) @ResponseBody public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final Map values = new HashMap(); values.put("content", mindMap.getXmlStr()); values.put("filename", mindMap.getTitle()); @@ -92,9 +92,9 @@ public class MindmapController extends BaseController { final MindmapFilter filter = MindmapFilter.parse(q); final List collaborations = mindmapService.findCollaborations(user); - final List mindmaps = new ArrayList(); + final List mindmaps = new ArrayList(); for (Collaboration collaboration : collaborations) { - final MindMap mindmap = collaboration.getMindMap(); + final Mindmap mindmap = collaboration.getMindMap(); if (filter.accept(mindmap, user)) { mindmaps.add(mindmap); } @@ -118,7 +118,7 @@ public class MindmapController extends BaseController { @RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException { - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); if (LATEST_HISTORY_REVISION.equals(hid)) { @@ -138,7 +138,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException { - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); // Validate arguments ... @@ -169,7 +169,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void update(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException { - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); final String xml = restMindmap.getXml(); @@ -213,7 +213,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); // Is there a map with the same name ? @@ -223,7 +223,7 @@ public class MindmapController extends BaseController { } // Update map ... - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); mindmap.setTitle(title); saveMindmap(true, mindMap, user); } @@ -231,7 +231,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "text/html", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); // Only owner can change collaborators... final User user = Utils.getUser(); @@ -271,7 +271,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"}) public ModelAndView retrieveList(@PathVariable int id) { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final Set collaborations = mindMap.getCollaborations(); final List collabs = new ArrayList(); @@ -290,11 +290,11 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); // Update map ... - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); mindmap.setDescription(description); saveMindmap(true, mindMap, user); } @@ -303,7 +303,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final Mindmap mindMap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) { @@ -320,7 +320,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); // Update map status ... @@ -337,7 +337,7 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateMap(@PathVariable int id) throws IOException, WiseMappingException { final User user = Utils.getUser(); - final MindMap mindmap = mindmapService.findMindmapById(id); + final Mindmap mindmap = mindmapService.findMindmapById(id); mindmapService.removeMindmap(mindmap, user); } @@ -347,7 +347,7 @@ public class MindmapController extends BaseController { final User user = Utils.getUser(); final String[] mapsIds = ids.split(","); for (final String mapId : mapsIds) { - final MindMap mindmap = mindmapService.findMindmapById(Integer.parseInt(mapId)); + final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mapId)); mindmapService.removeMindmap(mindmap, user); } } @@ -372,10 +372,10 @@ public class MindmapController extends BaseController { } // If the user has not specified the xml content, add one ... - final MindMap delegated = restMindmap.getDelegated(); + final Mindmap delegated = restMindmap.getDelegated(); String xml = restMindmap.getXml(); if (xml == null || xml.isEmpty()) { - xml = MindMap.getDefaultMindmapXml(restMindmap.getTitle()); + xml = Mindmap.getDefaultMindmapXml(restMindmap.getTitle()); } delegated.setXmlStr(xml); @@ -393,7 +393,7 @@ public class MindmapController extends BaseController { public void createMapFromFreemind(@RequestBody byte[] freemindXml, @RequestParam(required = true) String title, @RequestParam(required = false) String description, @NotNull HttpServletResponse response) throws IOException, WiseMappingException { // Convert map ... - final MindMap mindMap; + final Mindmap mindMap; try { final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND); final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml); @@ -421,8 +421,8 @@ public class MindmapController extends BaseController { final User user = Utils.getUser(); // Create a shallowCopy of the map ... - final MindMap mindMap = mindmapService.findMindmapById(id); - final MindMap clonedMap = mindMap.shallowClone(); + final Mindmap mindMap = mindmapService.findMindmapById(id); + final Mindmap clonedMap = mindMap.shallowClone(); clonedMap.setTitle(restMindmap.getTitle()); clonedMap.setDescription(restMindmap.getDescription()); @@ -434,7 +434,7 @@ public class MindmapController extends BaseController { response.setHeader("ResourceId", Integer.toString(clonedMap.getId())); } - private void saveMindmap(boolean minor, @NotNull final MindMap mindMap, @NotNull final User user) throws WiseMappingException { + private void saveMindmap(boolean minor, @NotNull final Mindmap mindMap, @NotNull final User user) throws WiseMappingException { final Calendar now = Calendar.getInstance(); mindMap.setLastModificationTime(now); mindMap.setLastEditor(user); diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java index a41bd7df..c9e4a87e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java @@ -20,7 +20,7 @@ package com.wisemapping.rest; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,32 +28,32 @@ import org.jetbrains.annotations.Nullable; public enum MindmapFilter { ALL("all") { @Override - public boolean accept(@NotNull MindMap mindmap, @NotNull User user) { + public boolean accept(@NotNull Mindmap mindmap, @NotNull User user) { return true; } }, MY_MAPS("my_maps") { @Override - boolean accept(@NotNull MindMap mindmap, @NotNull User user) { + boolean accept(@NotNull Mindmap mindmap, @NotNull User user) { return mindmap.getCreator().equals(user); } }, STARRED("starred") { @Override - boolean accept(@NotNull MindMap mindmap, @NotNull User user) { + boolean accept(@NotNull Mindmap mindmap, @NotNull User user) { return mindmap.isStarred(user); } }, SHARED_WITH_ME("shared_with_me") { @Override - boolean accept(@NotNull MindMap mindmap, @NotNull User user) { + boolean accept(@NotNull Mindmap mindmap, @NotNull User user) { return !MY_MAPS.accept(mindmap, user); } }, PUBLIC("public") { @Override - boolean accept(@NotNull MindMap mindmap, @NotNull User user) { + boolean accept(@NotNull Mindmap mindmap, @NotNull User user) { return mindmap.isPublic(); } }; @@ -76,6 +76,6 @@ public enum MindmapFilter { return result; } - abstract boolean accept(@NotNull MindMap mindmap, @NotNull User user); + abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user); } \ No newline at end of file diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java index b307a188..5c0614eb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java @@ -1,8 +1,6 @@ package com.wisemapping.rest.model; -import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; import org.codehaus.jackson.annotate.JsonAutoDetect; import org.jetbrains.annotations.NotNull; 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 8a9b3799..1e35368a 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 @@ -27,7 +27,7 @@ public class RestMindmap { @JsonIgnore private Collaborator collaborator; @JsonIgnore - private MindMap mindmap; + private Mindmap mindmap; @JsonIgnore static private SimpleDateFormat sdf; private String properties; @@ -38,11 +38,11 @@ public class RestMindmap { } public RestMindmap() throws WiseMappingException { - this(new MindMap(), null); + this(new Mindmap(), null); } - public RestMindmap(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) throws WiseMappingException { + public RestMindmap(@NotNull Mindmap mindmap, @Nullable Collaborator collaborator) throws WiseMappingException { this.mindmap = mindmap; this.collaborator = collaborator; if (collaborator != null) { @@ -172,7 +172,7 @@ public class RestMindmap { } @JsonIgnore - public MindMap getDelegated() { + public Mindmap getDelegated() { return this.mindmap; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java index 29db2f15..b2083164 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java @@ -1,16 +1,10 @@ package com.wisemapping.rest.model; -import com.wisemapping.model.Collaboration; -import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; import com.wisemapping.model.MindMapHistory; -import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.JsonAutoDetect; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java index 88633266..4cb14b80 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java @@ -3,7 +3,7 @@ package com.wisemapping.rest.model; import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.*; @@ -30,7 +30,7 @@ import java.util.TimeZone; public class RestMindmapInfo { @JsonIgnore - private MindMap mindmap; + private Mindmap mindmap; private Collaborator collaborator; @JsonIgnore static private SimpleDateFormat sdf; @@ -41,11 +41,11 @@ public class RestMindmapInfo { } public RestMindmapInfo() { - this(new MindMap(), null); + this(new Mindmap(), null); } - public RestMindmapInfo(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) { + public RestMindmapInfo(@NotNull Mindmap mindmap, @Nullable Collaborator collaborator) { this.mindmap = mindmap; this.collaborator = collaborator; } @@ -135,7 +135,7 @@ public class RestMindmapInfo { } @JsonIgnore - public MindMap getDelegated() { + public Mindmap getDelegated() { return this.mindmap; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java index 438f4f2e..4a2001ff 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java @@ -2,7 +2,7 @@ package com.wisemapping.rest.model; import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import org.codehaus.jackson.annotate.JsonAutoDetect; import org.jetbrains.annotations.NotNull; @@ -26,12 +26,12 @@ public class RestMindmapList { private List mindmapsInfo; public RestMindmapList() { - this(Collections.emptyList(), null); + this(Collections.emptyList(), null); } - public RestMindmapList(@NotNull List mindmaps, @NotNull Collaborator collaborator) { + public RestMindmapList(@NotNull List mindmaps, @NotNull Collaborator collaborator) { this.mindmapsInfo = new ArrayList(); - for (MindMap mindMap : mindmaps) { + for (Mindmap mindMap : mindmaps) { this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator)); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/view/ImportTransformationView.java b/wise-webapp/src/main/java/com/wisemapping/rest/view/ImportTransformationView.java index ce3eb955..8bc58bdd 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/view/ImportTransformationView.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/view/ImportTransformationView.java @@ -22,7 +22,7 @@ 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.Mindmap; import org.jetbrains.annotations.NotNull; import org.springframework.web.servlet.view.AbstractView; @@ -51,7 +51,7 @@ public class ImportTransformationView extends AbstractView { // Convert to map ... final InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8")); - final MindMap mindMap = importer.importMap("filename", "filename", is); + final Mindmap mindMap = importer.importMap("filename", "filename", is); // Set file name... final String fileName = (filename != null ? filename : "map") + "." + "xwise"; 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 7330b8ec..4f4bea73 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 @@ -1,67 +1,66 @@ -/* -* 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.security.aop; - -import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; -import com.wisemapping.model.User; -import com.wisemapping.exceptions.AccessDeniedSecurityException; -import com.wisemapping.exceptions.UnexpectedArgumentException; -import com.wisemapping.security.Utils; -import com.wisemapping.service.MindmapService; -import org.aopalliance.intercept.MethodInvocation; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public abstract class BaseSecurityAdvice { - private MindmapService mindmapService = null; - - 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 if (argument instanceof Collaborator) { - // Read operation find on the user are allowed ... - isAllowed = user.equals(argument); - } else { - throw new UnexpectedArgumentException("Argument " + argument); - } - - if (!isAllowed) { - throw new AccessDeniedSecurityException("User '" + (user != null ? user.getEmail() : "none") + "' not allowed to invoke:" + methodInvocation); - } - } - - protected abstract boolean isAllowed(@Nullable User user, MindMap map); - - protected abstract boolean isAllowed(@Nullable User user, int mapId); - - protected MindmapService getMindmapService() { - return mindmapService; - } - - public void setMindmapService(MindmapService service) { - this.mindmapService = service; - } -} +/* +* 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.security.aop; + +import com.wisemapping.model.Collaborator; +import com.wisemapping.model.Mindmap; +import com.wisemapping.model.User; +import com.wisemapping.exceptions.AccessDeniedSecurityException; +import com.wisemapping.exceptions.UnexpectedArgumentException; +import com.wisemapping.security.Utils; +import com.wisemapping.service.MindmapService; +import org.aopalliance.intercept.MethodInvocation; +import org.jetbrains.annotations.Nullable; + +public abstract class BaseSecurityAdvice { + private MindmapService mindmapService = null; + + 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 if (argument instanceof Collaborator) { + // Read operation find on the user are allowed ... + isAllowed = user.equals(argument); + } else { + throw new UnexpectedArgumentException("Argument " + argument); + } + + if (!isAllowed) { + throw new AccessDeniedSecurityException("User '" + (user != null ? user.getEmail() : "none") + "' not allowed to invoke:" + methodInvocation); + } + } + + protected abstract boolean isAllowed(@Nullable User user, Mindmap map); + + protected abstract boolean isAllowed(@Nullable User user, int mapId); + + protected MindmapService getMindmapService() { + return mindmapService; + } + + public void setMindmapService(MindmapService service) { + this.mindmapService = service; + } +} 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 116f58aa..95c0b16a 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 @@ -1,53 +1,53 @@ -/* -* 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.security.aop; - -import com.wisemapping.model.CollaborationRole; -import com.wisemapping.model.User; -import com.wisemapping.model.MindMap; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class UpdateSecurityAdvise - extends BaseSecurityAdvice - implements MethodInterceptor { - - public Object invoke(MethodInvocation methodInvocation) throws Throwable { - checkRole(methodInvocation); - return methodInvocation.proceed(); - } - - protected boolean isAllowed(@Nullable User user, @NotNull MindMap map) { - boolean result; - if (map.getCreator() == null) { - // This means that the map is new and is an add operation. - result = true; - } else { - result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR); - } - return result; - } - - protected boolean isAllowed(@Nullable User user, int mapId) { - return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR); - } -} +/* +* 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.security.aop; + +import com.wisemapping.model.CollaborationRole; +import com.wisemapping.model.Mindmap; +import com.wisemapping.model.User; + +import org.aopalliance.intercept.MethodInterceptor; +import org.aopalliance.intercept.MethodInvocation; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class UpdateSecurityAdvise + extends BaseSecurityAdvice + implements MethodInterceptor { + + public Object invoke(MethodInvocation methodInvocation) throws Throwable { + checkRole(methodInvocation); + return methodInvocation.proceed(); + } + + protected boolean isAllowed(@Nullable User user, @NotNull Mindmap map) { + boolean result; + if (map.getCreator() == null) { + // This means that the map is new and is an add operation. + result = true; + } else { + result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR); + } + return result; + } + + protected boolean isAllowed(@Nullable User user, int mapId) { + return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR); + } +} 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 5c8f5fcb..832e3195 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 @@ -1,45 +1,45 @@ -/* -* 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.security.aop; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import com.wisemapping.model.CollaborationRole; -import com.wisemapping.model.User; -import com.wisemapping.model.MindMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class ViewBaseSecurityAdvise - extends BaseSecurityAdvice - implements MethodInterceptor { - - public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable { - checkRole(methodInvocation); - return methodInvocation.proceed(); - } - - protected boolean isAllowed(@Nullable User user, MindMap map) { - return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER); - } - - protected boolean isAllowed(@Nullable User user, int mapId) { - return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER); - } -} +/* +* 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.security.aop; + +import com.wisemapping.model.Mindmap; +import org.aopalliance.intercept.MethodInterceptor; +import org.aopalliance.intercept.MethodInvocation; +import com.wisemapping.model.CollaborationRole; +import com.wisemapping.model.User; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ViewBaseSecurityAdvise + extends BaseSecurityAdvice + implements MethodInterceptor { + + public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable { + checkRole(methodInvocation); + return methodInvocation.proceed(); + } + + protected boolean isAllowed(@Nullable User user, Mindmap map) { + return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER); + } + + protected boolean isAllowed(@Nullable User user, int mapId) { + return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER); + } +} 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 c30602af..ddf93648 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -24,40 +24,39 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; -import java.io.IOException; public interface MindmapService { static final String TAG_SEPARATOR = " "; - MindMap findMindmapById(int mindmapId); + Mindmap findMindmapById(int mindmapId); - MindMap getMindmapByTitle(String title, User user); + Mindmap getMindmapByTitle(String title, User user); List findCollaborations(@NotNull User user); - void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException; + void updateMindmap(Mindmap mindMap, boolean saveHistory) throws WiseMappingException; - void addMindmap(MindMap map, User user) throws WiseMappingException; + void addMindmap(Mindmap map, User user) throws WiseMappingException; - void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) + void addCollaboration(@NotNull Mindmap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) throws CollaborationException; - void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException; + void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException; - void addTags(@NotNull MindMap mindmap, String tags); + void addTags(@NotNull Mindmap mindmap, String tags); - void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException; + void removeMindmap(@NotNull final Mindmap mindmap, @NotNull final User user) throws WiseMappingException; - List search(MindMapCriteria criteria); + List search(MindMapCriteria criteria); List findMindmapHistory(int mindmapId); - boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole); + boolean hasPermissions(@Nullable User user, Mindmap map, CollaborationRole allowedRole); boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); - void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException; + void revertChange(@NotNull Mindmap map, int historyId) throws WiseMappingException; MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException; 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 53cb769a..1179ccc7 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -46,12 +46,12 @@ public class MindmapServiceImpl @Override public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) { - final MindMap map = mindmapManager.getMindmapById(mapId); + final Mindmap map = mindmapManager.getMindmapById(mapId); return hasPermissions(user, map, grantedRole); } @Override - public boolean hasPermissions(@Nullable User user, @Nullable MindMap map, @NotNull CollaborationRole role) { + public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) { boolean result = false; if (map != null) { if (map.isPublic() && role == CollaborationRole.VIEWER) { @@ -68,12 +68,12 @@ public class MindmapServiceImpl } @Override - public MindMap getMindmapByTitle(String title, User user) { + public Mindmap getMindmapByTitle(String title, User user) { return mindmapManager.getMindmapByTitle(title, user); } @Override - public MindMap findMindmapById(int mindmapId) { + public Mindmap findMindmapById(int mindmapId) { return mindmapManager.getMindmapById(mindmapId); } @@ -83,7 +83,7 @@ public class MindmapServiceImpl } @Override - public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) throws WiseMappingException { + public void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory) throws WiseMappingException { if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) { throw new WiseMappingException("The tile can not be empty"); } @@ -91,14 +91,14 @@ public class MindmapServiceImpl } @Override - public List search(MindMapCriteria criteria) { + public List search(MindMapCriteria criteria) { return mindmapManager.search(criteria); } @Override - public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException { + public void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException { // remove collaborator association - final MindMap mindMap = collaboration.getMindMap(); + final Mindmap mindMap = collaboration.getMindMap(); final Set collaborations = mindMap.getCollaborations(); if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) { @@ -111,7 +111,7 @@ public class MindmapServiceImpl } @Override - public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException { + public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException { if (mindmap.getCreator().equals(user)) { mindmapManager.removeMindmap(mindmap); } else { @@ -123,7 +123,7 @@ public class MindmapServiceImpl } @Override - public void addMindmap(@NotNull MindMap map, @NotNull User user) throws WiseMappingException { + public void addMindmap(@NotNull Mindmap map, @NotNull User user) throws WiseMappingException { final String title = map.getTitle(); @@ -151,7 +151,7 @@ public class MindmapServiceImpl } @Override - public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) + public void addCollaboration(@NotNull Mindmap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) throws CollaborationException { // Validate @@ -197,7 +197,7 @@ public class MindmapServiceImpl } @Override - public void addTags(@NotNull MindMap mindmap, String tags) { + public void addTags(@NotNull Mindmap mindmap, String tags) { mindmap.setTags(tags); mindmapManager.updateMindmap(mindmap, false); if (tags != null && tags.length() > 0) { @@ -226,7 +226,7 @@ public class MindmapServiceImpl } @Override - public void revertChange(@NotNull MindMap mindmap, int historyId) + public void revertChange(@NotNull Mindmap mindmap, int historyId) throws WiseMappingException { final MindMapHistory history = mindmapManager.getHistory(historyId); mindmap.setXml(history.getXml()); diff --git a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java index 7251061b..4578aeeb 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java @@ -23,9 +23,8 @@ import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.mail.NotificationService; import com.wisemapping.model.AccessAuditory; import com.wisemapping.model.Collaborator; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; -import org.apache.commons.io.IOUtils; import org.apache.velocity.app.VelocityEngine; import org.jetbrains.annotations.NotNull; import org.springframework.context.MessageSource; @@ -33,8 +32,6 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.ui.velocity.VelocityEngineUtils; import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.util.*; public class UserServiceImpl @@ -130,7 +127,7 @@ public class UserServiceImpl } //create welcome map - final MindMap mindMap = buildWelcomeMindmap(user.getFirstname()); + final Mindmap mindMap = buildWelcomeMindmap(user.getFirstname()); mindmapService.addMindmap(mindMap, user); @@ -145,13 +142,13 @@ public class UserServiceImpl return user; } - public MindMap buildWelcomeMindmap(@NotNull String firstName) { + public Mindmap buildWelcomeMindmap(@NotNull String firstName) { //To change body of created methods use File | Settings | File Templates. Locale locale = LocaleContextHolder.getLocale(); // @TODO: Remove this once is translated locale = Locale.ENGLISH; - MindMap result = new MindMap(); + Mindmap result = new Mindmap(); final Map model = new HashMap(); model.put("messages", messageSource); model.put("noArgs", new Object[]{}); diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java index faef8e42..06d79430 100755 --- a/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java @@ -1,96 +1,96 @@ -/* -* 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.model.MindMap; -import com.wisemapping.model.User; -import com.wisemapping.model.Constants; -import com.wisemapping.service.MindmapService; -import com.wisemapping.view.MindMapInfoBean; -import org.jetbrains.annotations.NotNull; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; -import org.springframework.validation.Validator; - -public class MapInfoValidator implements Validator { - - - private MindmapService mindmapService; - - public boolean supports(final Class clazz) { - return clazz.equals(MindMapInfoBean.class); - } - - public MapInfoValidator() { - - } - - public MapInfoValidator(@NotNull MindmapService service) { - this.mindmapService = service; - } - - public void validate(Object obj, @NotNull Errors errors) { - final MindMap map = (MindMap) obj; - - - if (map == null) { - errors.rejectValue("map", "error.not-specified", null, "Value required."); - } else { - - final String title = map.getTitle(); - final String desc = map.getDescription(); - validateMapInfo(errors, title, desc); - } - - } - - protected void validateMapInfo(Errors errors, String title, String desc) { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED); - - - if (title != null && title.length() > 0) { - if (title.length() > Constants.MAX_MAP_NAME_LENGTH) { - errors.rejectValue("title", "field.max.length", - new Object[]{Constants.MAX_MAP_NAME_LENGTH}, - "The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters."); - } else { - // Map already exists ? - final MindmapService service = this.getMindmapService(); - final User user = com.wisemapping.security.Utils.getUser(); - final MindMap mindMap = service.getMindmapByTitle(title, user); - if (mindMap != null) { - errors.rejectValue("title", Messages.MAP_TITLE_ALREADY_EXISTS); - } - } - } - ValidatorUtils.rejectIfExceeded(errors, - "description", - "The description must have less than " + Constants.MAX_MAP_DESCRIPTION_LENGTH + " characters.", - desc, - Constants.MAX_MAP_DESCRIPTION_LENGTH); - } - - public MindmapService getMindmapService() { - return mindmapService; - } - - public void setMindmapService(MindmapService mindmapService) { - this.mindmapService = mindmapService; - } +/* +* 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.model.Mindmap; +import com.wisemapping.model.User; +import com.wisemapping.model.Constants; +import com.wisemapping.service.MindmapService; +import com.wisemapping.view.MindMapInfoBean; +import org.jetbrains.annotations.NotNull; +import org.springframework.validation.Errors; +import org.springframework.validation.ValidationUtils; +import org.springframework.validation.Validator; + +public class MapInfoValidator implements Validator { + + + private MindmapService mindmapService; + + public boolean supports(final Class clazz) { + return clazz.equals(MindMapInfoBean.class); + } + + public MapInfoValidator() { + + } + + public MapInfoValidator(@NotNull MindmapService service) { + this.mindmapService = service; + } + + public void validate(Object obj, @NotNull Errors errors) { + final Mindmap map = (Mindmap) obj; + + + if (map == null) { + errors.rejectValue("map", "error.not-specified", null, "Value required."); + } else { + + final String title = map.getTitle(); + final String desc = map.getDescription(); + validateMapInfo(errors, title, desc); + } + + } + + protected void validateMapInfo(Errors errors, String title, String desc) { + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED); + + + if (title != null && title.length() > 0) { + if (title.length() > Constants.MAX_MAP_NAME_LENGTH) { + errors.rejectValue("title", "field.max.length", + new Object[]{Constants.MAX_MAP_NAME_LENGTH}, + "The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters."); + } else { + // Map already exists ? + final MindmapService service = this.getMindmapService(); + final User user = com.wisemapping.security.Utils.getUser(); + final Mindmap mindMap = service.getMindmapByTitle(title, user); + if (mindMap != null) { + errors.rejectValue("title", Messages.MAP_TITLE_ALREADY_EXISTS); + } + } + } + ValidatorUtils.rejectIfExceeded(errors, + "description", + "The description must have less than " + Constants.MAX_MAP_DESCRIPTION_LENGTH + " characters.", + desc, + Constants.MAX_MAP_DESCRIPTION_LENGTH); + } + + public MindmapService getMindmapService() { + return mindmapService; + } + + public void setMindmapService(MindmapService mindmapService) { + this.mindmapService = mindmapService; + } } \ No newline at end of file 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 8afc9879..ba6c9189 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -1,162 +1,162 @@ -/* -* 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.exceptions.WiseMappingException; -import com.wisemapping.model.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.text.DateFormat; -import java.util.*; - -public class MindMapBean { - private MindMap mindmap; - private List viewers; - private List collaborators; - private Collaborator collaborator; - - public MindMapBean(@NotNull final MindMap mindmap, @Nullable final Collaborator collaborator) { - this.mindmap = mindmap; - this.collaborator = collaborator; - this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); - this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); - } - - public boolean getPublic() { - return mindmap.isPublic(); - } - - public String getTitle() { - return mindmap.getTitle(); - } - - public String getDescription() { - return mindmap.getDescription(); - } - - public int getId() { - return mindmap.getId(); - } - - public boolean isStarred() { - return mindmap.isStarred(collaborator); - } - - public List getViewers() { - return viewers; - } - - public List getCollaborators() { - return collaborators; - } - - public String getLastEditor() { - final User lastEditor = mindmap.getLastEditor(); - return lastEditor != null ? lastEditor.getFullName() : ""; - } - - public String getLastEditTime() { - return DateFormat.getInstance().format(mindmap.getLastModificationTime().getTime()); - } - - public String getCreationTime() { - return DateFormat.getInstance().format(mindmap.getCreationTime().getTime()); - } - - public String getTags() { - return mindmap.getTags(); - } - - private List filterCollaboratorBy(Set source, CollaborationRole role) { - List col = new ArrayList(); - if (source != null) { - for (Collaboration mu : source) { - if (mu.getRole() == role) { - col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole())); - } - } - } - return col; - } - - public int getCountCollaborators() { - return collaborators != null ? collaborators.size() : 0; - } - - public int getCountViewers() { - return viewers != null ? viewers.size() : 0; - } - - public int getCountShared() { - return getCountCollaborators() + getCountViewers(); - } - - public boolean isShared() { - return getCountShared() > 0; - } - - public void setTitle(String t) { - mindmap.setTitle(t); - } - - public void setDescription(String d) { - mindmap.setDescription(d); - } - - public String getXmlAsJsLiteral() throws IOException { - return this.mindmap.getXmlAsJsLiteral(); - } - - public String getProperties() throws WiseMappingException { - String result; - if (collaborator != null) { - final CollaborationProperties properties = this.mindmap.findCollaborationProperties(collaborator); - result = properties.getMindmapProperties(); - } else { - // It must be public view ... - result = CollaborationProperties.DEFAULT_JSON_PROPERTIES; - } - return result; - } - - public User getCreator() { - return mindmap.getCreator(); - } - - public boolean isOwner() { - return mindmap.hasPermissions(collaborator, CollaborationRole.OWNER); - } - - public boolean isEditor() { - return mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR); - } - - public String getRole() { - final Collaboration collaboration = this.mindmap.findCollaboration(collaborator); - return collaboration.getRole().getLabel(); - } - - - public MindMap getDelegated() { - return mindmap; - } - -} +/* +* 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.exceptions.WiseMappingException; +import com.wisemapping.model.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.text.DateFormat; +import java.util.*; + +public class MindMapBean { + private Mindmap mindmap; + private List viewers; + private List collaborators; + private Collaborator collaborator; + + public MindMapBean(@NotNull final Mindmap mindmap, @Nullable final Collaborator collaborator) { + this.mindmap = mindmap; + this.collaborator = collaborator; + this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); + this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); + } + + public boolean getPublic() { + return mindmap.isPublic(); + } + + public String getTitle() { + return mindmap.getTitle(); + } + + public String getDescription() { + return mindmap.getDescription(); + } + + public int getId() { + return mindmap.getId(); + } + + public boolean isStarred() { + return mindmap.isStarred(collaborator); + } + + public List getViewers() { + return viewers; + } + + public List getCollaborators() { + return collaborators; + } + + public String getLastEditor() { + final User lastEditor = mindmap.getLastEditor(); + return lastEditor != null ? lastEditor.getFullName() : ""; + } + + public String getLastEditTime() { + return DateFormat.getInstance().format(mindmap.getLastModificationTime().getTime()); + } + + public String getCreationTime() { + return DateFormat.getInstance().format(mindmap.getCreationTime().getTime()); + } + + public String getTags() { + return mindmap.getTags(); + } + + private List filterCollaboratorBy(Set source, CollaborationRole role) { + List col = new ArrayList(); + if (source != null) { + for (Collaboration mu : source) { + if (mu.getRole() == role) { + col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole())); + } + } + } + return col; + } + + public int getCountCollaborators() { + return collaborators != null ? collaborators.size() : 0; + } + + public int getCountViewers() { + return viewers != null ? viewers.size() : 0; + } + + public int getCountShared() { + return getCountCollaborators() + getCountViewers(); + } + + public boolean isShared() { + return getCountShared() > 0; + } + + public void setTitle(String t) { + mindmap.setTitle(t); + } + + public void setDescription(String d) { + mindmap.setDescription(d); + } + + public String getXmlAsJsLiteral() throws IOException { + return this.mindmap.getXmlAsJsLiteral(); + } + + public String getProperties() throws WiseMappingException { + String result; + if (collaborator != null) { + final CollaborationProperties properties = this.mindmap.findCollaborationProperties(collaborator); + result = properties.getMindmapProperties(); + } else { + // It must be public view ... + result = CollaborationProperties.DEFAULT_JSON_PROPERTIES; + } + return result; + } + + public User getCreator() { + return mindmap.getCreator(); + } + + public boolean isOwner() { + return mindmap.hasPermissions(collaborator, CollaborationRole.OWNER); + } + + public boolean isEditor() { + return mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR); + } + + public String getRole() { + final Collaboration collaboration = this.mindmap.findCollaboration(collaborator); + return collaboration.getRole().getLabel(); + } + + + public Mindmap getDelegated() { + return mindmap; + } + +} diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java index 0025e53d..247415a4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java @@ -18,15 +18,15 @@ package com.wisemapping.view; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; public class MindMapInfoBean { private String title; private String description; - private MindMap mindMap; + private Mindmap mindMap; - public MindMapInfoBean(MindMap map) { + public MindMapInfoBean(Mindmap map) { this.title = map.getTitle(); this.description = map.getDescription(); @@ -55,7 +55,7 @@ public class MindMapInfoBean { } - public MindMap getMindMap() { + public Mindmap getMindMap() { if (mindMap != null) { mindMap.setTitle(title); mindMap.setDescription(description); diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml index 3b00d82c..a07f023f 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml index 9635fb87..84a14e18 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml @@ -1,30 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml index 88f47431..4936d3c3 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml @@ -25,7 +25,7 @@ com/wisemapping/model/Collaborator.hbm.xml - com/wisemapping/model/MindMap.hbm.xml + com/wisemapping/model/Mindmap.hbm.xml com/wisemapping/model/Collaboration.hbm.xml com/wisemapping/model/CollaborationProperties.hbm.xml com/wisemapping/model/AccessAuditory.hbm.xml diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 68427b9f..72fcc971 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -5,7 +5,7 @@ -<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%> +<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%> <%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditorToolbar.jsf b/wise-webapp/src/main/webapp/jsp/mindmapEditorToolbar.jsf index fac8f822..9194b454 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditorToolbar.jsf +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditorToolbar.jsf @@ -1,4 +1,4 @@ -<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%> +<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp index 2595ff9d..04a90c3b 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp @@ -3,7 +3,7 @@ -<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%> +<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%> <%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> diff --git a/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp b/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp index ebbeab5a..5a2a8143 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp @@ -1,7 +1,7 @@ <%@page pageEncoding="UTF-8" %> <%@include file="/jsp/init.jsp" %> -<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%> +<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%> <%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java index 797b46f4..03a8b92c 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java @@ -4,7 +4,7 @@ import com.wisemapping.exporter.ExportException; import com.wisemapping.exporter.FreemindExporter; import com.wisemapping.importer.ImporterException; -import com.wisemapping.model.MindMap; +import com.wisemapping.model.Mindmap; import org.apache.commons.io.FileUtils; import org.jetbrains.annotations.NotNull; import org.testng.Assert; @@ -22,7 +22,7 @@ public class ExportTest { public void exportImportExportTest(@NotNull final File wisemap, @NotNull final File recFile) throws ImporterException, IOException, ExportException { - final MindMap mindmap = load(wisemap); + final Mindmap mindmap = load(wisemap); final FreemindExporter freemindExporter = new FreemindExporter(); if (recFile.exists()) { @@ -43,9 +43,9 @@ public class ExportTest { } } - private MindMap load(@NotNull File wisemap) throws IOException { + private Mindmap load(@NotNull File wisemap) throws IOException { final byte[] recContent = FileUtils.readFileToByteArray(wisemap); - final MindMap result = new MindMap(); + final Mindmap result = new Mindmap(); result.setXml(recContent); return result; } diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java index c6af02e4..54e5268d 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java @@ -6,7 +6,7 @@ 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.Mindmap; import org.apache.commons.io.FileUtils; import org.jetbrains.annotations.NotNull; import org.testng.Assert; @@ -33,7 +33,7 @@ public class ImportExportTest { @Test(dataProvider = "Data-Provider-Function") public void exportImportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException { final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath()); - final MindMap mindMap = importer.importMap("basic", "basic", fileInputStream); + final Mindmap mindMap = importer.importMap("basic", "basic", fileInputStream); // Compare mindmap output ...