- IE window.open does not support base href tag. Fixed.

This commit is contained in:
Paulo Gustavo Veiga 2012-08-15 21:28:51 -03:00
parent dde7806b38
commit 5f441c2c20
38 changed files with 1310 additions and 1327 deletions

View File

@ -1,67 +1,67 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.dao; package com.wisemapping.dao;
import com.wisemapping.model.*; import com.wisemapping.model.*;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public interface MindmapManager { public interface MindmapManager {
Collaborator findCollaborator(@NotNull String email); Collaborator findCollaborator(@NotNull String email);
Collaborator findCollaborator(long id); Collaborator findCollaborator(long id);
List<Collaboration> findCollaboration(final long collaboratorId); List<Collaboration> findCollaboration(final long collaboratorId);
List<Collaboration> findCollaboration(final CollaborationRole userRole); List<Collaboration> findCollaboration(final CollaborationRole userRole);
Collaboration findCollaboration(final int mindmapId, final User user); Collaboration findCollaboration(final int mindmapId, final User user);
List<MindMap> getAllMindmaps(); List<Mindmap> getAllMindmaps();
MindMap getMindmapById(int mindmapId); Mindmap getMindmapById(int mindmapId);
MindMap getMindmapByTitle(final String name, final User user); Mindmap getMindmapByTitle(final String name, final User user);
void addCollaborator(Collaborator collaborator); void addCollaborator(Collaborator collaborator);
void addMindmap(User user, MindMap mindMap); void addMindmap(User user, Mindmap mindMap);
void saveMindmap(MindMap mindMap); void saveMindmap(Mindmap mindMap);
void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory); void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory);
void removeCollaborator(@NotNull Collaborator collaborator); void removeCollaborator(@NotNull Collaborator collaborator);
void removeMindmap(MindMap mindap); void removeMindmap(Mindmap mindap);
void removeCollaboration(Collaboration collaboration); void removeCollaboration(Collaboration collaboration);
public List<MindMap> search(MindMapCriteria criteria); public List<Mindmap> search(MindMapCriteria criteria);
public List<MindMap> search(MindMapCriteria criteria, int maxResult); public List<Mindmap> search(MindMapCriteria criteria, int maxResult);
public List<MindMapHistory> getHistoryFrom(int mindmapId); public List<MindMapHistory> getHistoryFrom(int mindmapId);
public MindMapHistory getHistory(int historyId); public MindMapHistory getHistory(int historyId);
void updateCollaboration(@NotNull Collaboration collaboration); void updateCollaboration(@NotNull Collaboration collaboration);
} }

View File

@ -1,218 +1,218 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.dao; package com.wisemapping.dao;
import com.wisemapping.model.*; import com.wisemapping.model.*;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression; import org.hibernate.criterion.SimpleExpression;
import org.hibernate.criterion.Junction; import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Order; import org.hibernate.criterion.Order;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import java.util.List; import java.util.List;
import java.util.Calendar; import java.util.Calendar;
public class MindmapManagerImpl public class MindmapManagerImpl
extends HibernateDaoSupport extends HibernateDaoSupport
implements MindmapManager { implements MindmapManager {
@Override @Override
public Collaborator findCollaborator(@NotNull final String email) { public Collaborator findCollaborator(@NotNull final String email) {
final Collaborator collaborator; final Collaborator collaborator;
final List<Collaborator> collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email); final List<Collaborator> collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
if (collaborators != null && !collaborators.isEmpty()) { if (collaborators != null && !collaborators.isEmpty()) {
assert collaborators.size() == 1 : "More than one user with the same email!"; assert collaborators.size() == 1 : "More than one user with the same email!";
collaborator = collaborators.get(0); collaborator = collaborators.get(0);
} else { } else {
collaborator = null; collaborator = null;
} }
return collaborator; return collaborator;
} }
@Override @Override
public List<MindMap> search(MindMapCriteria criteria) { public List<Mindmap> search(MindMapCriteria criteria) {
return search(criteria, -1); return search(criteria, -1);
} }
@Override @Override
public List<MindMapHistory> getHistoryFrom(int mindmapId) { public List<MindMapHistory> getHistoryFrom(int mindmapId) {
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class); final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId)); hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId));
hibernateCriteria.addOrder(Order.desc("creationTime")); hibernateCriteria.addOrder(Order.desc("creationTime"));
// Mientras no haya paginacion solo los 10 primeros // Mientras no haya paginacion solo los 10 primeros
// This line throws errors in some environments, so getting all history and taking firsts 10 records // This line throws errors in some environments, so getting all history and taking firsts 10 records
// hibernateCriteria.setMaxResults(10); // hibernateCriteria.setMaxResults(10);
List list = hibernateCriteria.list(); List list = hibernateCriteria.list();
return list.subList(0, (10 < list.size() ? 10 : list.size())); return list.subList(0, (10 < list.size() ? 10 : list.size()));
} }
@Override @Override
public MindMapHistory getHistory(int historyId) { public MindMapHistory getHistory(int historyId) {
return getHibernateTemplate().get(MindMapHistory.class, historyId); return getHibernateTemplate().get(MindMapHistory.class, historyId);
} }
@Override @Override
public void updateCollaboration(@NotNull Collaboration collaboration) { public void updateCollaboration(@NotNull Collaboration collaboration) {
getHibernateTemplate().save(collaboration); getHibernateTemplate().save(collaboration);
} }
@Override @Override
public List<MindMap> search(MindMapCriteria criteria, int maxResult) { public List<Mindmap> search(MindMapCriteria criteria, int maxResult) {
final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class); final Criteria hibernateCriteria = getSession().createCriteria(Mindmap.class);
//always search public maps //always search public maps
hibernateCriteria.add(Restrictions.like("public", Boolean.TRUE)); hibernateCriteria.add(Restrictions.like("public", Boolean.TRUE));
if (criteria != null) { if (criteria != null) {
final Junction junction; final Junction junction;
if (criteria.isOrCriteria()) { if (criteria.isOrCriteria()) {
junction = Restrictions.disjunction(); junction = Restrictions.disjunction();
} else { } else {
junction = Restrictions.conjunction(); junction = Restrictions.conjunction();
} }
if (criteria.getTitle() != null && criteria.getTitle().length() > 0) { if (criteria.getTitle() != null && criteria.getTitle().length() > 0) {
final SimpleExpression titleRestriction = Restrictions.like("title", "%" + criteria.getTitle() + "%"); final SimpleExpression titleRestriction = Restrictions.like("title", "%" + criteria.getTitle() + "%");
junction.add(titleRestriction); junction.add(titleRestriction);
} }
if (criteria.getDescription() != null && criteria.getDescription().length() > 0) { if (criteria.getDescription() != null && criteria.getDescription().length() > 0) {
final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%"); final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%");
junction.add(descriptionRestriction); junction.add(descriptionRestriction);
} }
if (criteria.getTags().size() > 0) { if (criteria.getTags().size() > 0) {
for (String tag : criteria.getTags()) { for (String tag : criteria.getTags()) {
final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%"); final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%");
junction.add(tagRestriction); junction.add(tagRestriction);
} }
} }
hibernateCriteria.add(junction); hibernateCriteria.add(junction);
} }
// if (maxResult>0) // if (maxResult>0)
// { // {
// hibernateCriteria.setMaxResults(maxResult); // hibernateCriteria.setMaxResults(maxResult);
// } // }
return hibernateCriteria.list(); return hibernateCriteria.list();
} }
@Override @Override
public Collaborator findCollaborator(long id) { public Collaborator findCollaborator(long id) {
return getHibernateTemplate().get(Collaborator.class, id); return getHibernateTemplate().get(Collaborator.class, id);
} }
@Override @Override
public List<Collaboration> findCollaboration(final long collaboratorId) { public List<Collaboration> findCollaboration(final long collaboratorId) {
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where colaborator_id=?", collaboratorId); return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where colaborator_id=?", collaboratorId);
} }
@Override @Override
public List<Collaboration> findCollaboration(final CollaborationRole collaborationRole) { public List<Collaboration> findCollaboration(final CollaborationRole collaborationRole) {
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where roleId=?", collaborationRole.ordinal()); return getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where roleId=?", collaborationRole.ordinal());
} }
@Override @Override
public Collaboration findCollaboration(final int mindmapId, final User user) { public Collaboration findCollaboration(final int mindmapId, final User user) {
final Collaboration result; final Collaboration result;
final List<Collaboration> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Collaboration collaboration where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()}); final List<Collaboration> 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()) { if (mindMaps != null && !mindMaps.isEmpty()) {
result = mindMaps.get(0); result = mindMaps.get(0);
} else { } else {
result = null; result = null;
} }
return result; return result;
} }
@Override @Override
public void addCollaborator(@NotNull Collaborator collaborator) { public void addCollaborator(@NotNull Collaborator collaborator) {
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!"; assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
getHibernateTemplate().save(collaborator); getHibernateTemplate().save(collaborator);
} }
@Override @Override
public void removeCollaboration(Collaboration collaboration) { public void removeCollaboration(Collaboration collaboration) {
getHibernateTemplate().delete(collaboration); getHibernateTemplate().delete(collaboration);
} }
@Override @Override
public void removeCollaborator(@NotNull Collaborator collaborator) { public void removeCollaborator(@NotNull Collaborator collaborator) {
getHibernateTemplate().delete(collaborator); getHibernateTemplate().delete(collaborator);
} }
@Override @Override
public List<MindMap> getAllMindmaps() { public List<Mindmap> getAllMindmaps() {
return getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping"); return getHibernateTemplate().find("from com.wisemapping.model.Mindmap wisemapping");
} }
@Override @Override
public MindMap getMindmapById(int mindmapId) { public Mindmap getMindmapById(int mindmapId) {
return getHibernateTemplate().get(MindMap.class, mindmapId); return getHibernateTemplate().get(Mindmap.class, mindmapId);
} }
@Override @Override
public MindMap getMindmapByTitle(final String title, final User user) { public Mindmap getMindmapByTitle(final String title, final User user) {
final MindMap result; final Mindmap result;
List<MindMap> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user}); List<Mindmap> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Mindmap wisemapping where title=? and creator=?", new Object[]{title, user});
if (mindMaps != null && !mindMaps.isEmpty()) { if (mindMaps != null && !mindMaps.isEmpty()) {
result = mindMaps.get(0); result = mindMaps.get(0);
} else { } else {
result = null; result = null;
} }
return result; return result;
} }
@Override @Override
public void addMindmap(User user, MindMap mindMap) { public void addMindmap(User user, Mindmap mindMap) {
saveMindmap(mindMap); saveMindmap(mindMap);
} }
@Override @Override
public void saveMindmap(MindMap mindMap) { public void saveMindmap(Mindmap mindMap) {
assert mindMap != null : "Save Mindmap: Mindmap is required!"; assert mindMap != null : "Save Mindmap: Mindmap is required!";
getSession().save(mindMap); getSession().save(mindMap);
} }
@Override @Override
public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) { public void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory) {
assert mindMap != null : "Save Mindmap: Mindmap is required!"; assert mindMap != null : "Save Mindmap: Mindmap is required!";
getHibernateTemplate().saveOrUpdate(mindMap); getHibernateTemplate().saveOrUpdate(mindMap);
if (saveHistory) { if (saveHistory) {
saveHistory(mindMap); saveHistory(mindMap);
} }
} }
@Override @Override
public void removeMindmap(@NotNull final MindMap mindMap) { public void removeMindmap(@NotNull final Mindmap mindMap) {
getHibernateTemplate().delete(mindMap); getHibernateTemplate().delete(mindMap);
} }
private void saveHistory(@NotNull final MindMap mindMap) { private void saveHistory(@NotNull final Mindmap mindMap) {
final MindMapHistory history = new MindMapHistory(); final MindMapHistory history = new MindMapHistory();
history.setXml(mindMap.getXml()); history.setXml(mindMap.getXml());
history.setCreationTime(Calendar.getInstance()); history.setCreationTime(Calendar.getInstance());
history.setEditor(mindMap.getLastEditor()); history.setEditor(mindMap.getLastEditor());
history.setMindmapId(mindMap.getId()); history.setMindmapId(mindMap.getId());
getHibernateTemplate().saveOrUpdate(history); getHibernateTemplate().saveOrUpdate(history);
} }
} }

View File

@ -1,28 +1,28 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.exporter; package com.wisemapping.exporter;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import java.io.OutputStream; import java.io.OutputStream;
public interface Exporter { public interface Exporter {
public void export(byte[] xml, OutputStream outputStream) throws ExportException; public void export(byte[] xml, OutputStream outputStream) throws ExportException;
public void export(MindMap map, OutputStream outputStream) throws ExportException; public void export(Mindmap map, OutputStream outputStream) throws ExportException;
} }

View File

@ -20,7 +20,7 @@ package com.wisemapping.exporter;
import com.wisemapping.importer.freemind.FreemindIconConverter; import com.wisemapping.importer.freemind.FreemindIconConverter;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle; import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils; import com.wisemapping.util.JAXBUtils;
import com.wisemapping.jaxb.freemind.*; import com.wisemapping.jaxb.freemind.*;
@ -48,7 +48,7 @@ public class FreemindExporter
private Map<String, Node> nodesMap = null; private Map<String, Node> nodesMap = null;
public void export(MindMap map, OutputStream outputStream) throws ExportException { public void export(Mindmap map, OutputStream outputStream) throws ExportException {
export(map.getXml(), outputStream); export(map.getXml(), outputStream);
} }

View File

@ -1,29 +1,28 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.importer; package com.wisemapping.importer;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.InputStream;
import java.io.InputStream;
public interface Importer {
public interface Importer { 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; }
}

View File

@ -22,7 +22,7 @@ import com.sun.org.apache.xerces.internal.dom.TextImpl;
import com.wisemapping.importer.Importer; import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.VersionNumber; import com.wisemapping.importer.VersionNumber;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle; import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils; import com.wisemapping.util.JAXBUtils;
import com.wisemapping.jaxb.freemind.*; 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<String, TopicType>(); nodesMap = new HashMap<String, TopicType>();
relationships = new ArrayList<RelationshipType>(); relationships = new ArrayList<RelationshipType>();
mindmapObjectFactory = new com.wisemapping.jaxb.wisemap.ObjectFactory(); mindmapObjectFactory = new com.wisemapping.jaxb.wisemap.ObjectFactory();

View File

@ -19,14 +19,13 @@
package com.wisemapping.mail; package com.wisemapping.mail;
import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaboration;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.HashMap; 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 { try {
// Sent collaboration email ... // 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 { try {
final Map<String, Object> model = new HashMap<String, Object>(); final Map<String, Object> model = new HashMap<String, Object>();

View File

@ -1,103 +1,103 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.model; package com.wisemapping.model;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class Collaboration { public class Collaboration {
private long id; private long id;
private CollaborationRole role; private CollaborationRole role;
private MindMap mindMap; private Mindmap mindMap;
private Collaborator collaborator; private Collaborator collaborator;
private CollaborationProperties collaborationProperties; private CollaborationProperties collaborationProperties;
public Collaboration() { public Collaboration() {
} }
public Collaboration(@NotNull CollaborationRole role, @NotNull Collaborator collaborator, @NotNull MindMap mindmap) { public Collaboration(@NotNull CollaborationRole role, @NotNull Collaborator collaborator, @NotNull Mindmap mindmap) {
this.role = role; this.role = role;
this.mindMap = mindmap; this.mindMap = mindmap;
this.collaborator = collaborator; this.collaborator = collaborator;
// Guarantee referential integrity // Guarantee referential integrity
mindmap.addCollaboration(this); mindmap.addCollaboration(this);
collaborator.addCollaboration(this); collaborator.addCollaboration(this);
} }
public long getId() { public long getId() {
return id; return id;
} }
public void setId(long id) { public void setId(long id) {
this.id = id; this.id = id;
} }
public int getRoleId() { public int getRoleId() {
return role.ordinal(); return role.ordinal();
} }
public void setRoleId(int roleId) { public void setRoleId(int roleId) {
this.role = CollaborationRole.values()[roleId]; this.role = CollaborationRole.values()[roleId];
} }
public CollaborationRole getRole() { public CollaborationRole getRole() {
return role; return role;
} }
public void setRole(@NotNull CollaborationRole role) { public void setRole(@NotNull CollaborationRole role) {
this.role = role; this.role = role;
} }
public MindMap getMindMap() { public Mindmap getMindMap() {
return mindMap; return mindMap;
} }
public void setMindMap(MindMap mindMap) { public void setMindMap(Mindmap mindMap) {
this.mindMap = mindMap; this.mindMap = mindMap;
} }
@NotNull @NotNull
public Collaborator getCollaborator() { public Collaborator getCollaborator() {
return collaborator; return collaborator;
} }
public void setCollaborator(@NotNull Collaborator collaborator) { public void setCollaborator(@NotNull Collaborator collaborator) {
this.collaborator = collaborator; this.collaborator = collaborator;
} }
@NotNull @NotNull
public CollaborationProperties getCollaborationProperties() { public CollaborationProperties getCollaborationProperties() {
CollaborationProperties result = collaborationProperties; CollaborationProperties result = collaborationProperties;
if (result == null) { if (result == null) {
collaborationProperties = new CollaborationProperties(); collaborationProperties = new CollaborationProperties();
result = collaborationProperties; result = collaborationProperties;
} }
return result; return result;
} }
public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) {
this.collaborationProperties = collaborationProperties; this.collaborationProperties = collaborationProperties;
} }
public boolean hasPermissions(@NotNull CollaborationRole role) { public boolean hasPermissions(@NotNull CollaborationRole role) {
return this.getRole().ordinal() <= role.ordinal(); return this.getRole().ordinal() <= role.ordinal();
} }
} }

View File

@ -1,276 +1,275 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.model; package com.wisemapping.model;
import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.util.ZipUtils; import com.wisemapping.util.ZipUtils;
import org.jetbrains.annotations.NotNull; import org.apache.commons.lang.StringEscapeUtils;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.IOException;
import java.util.Calendar; import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Calendar;
import java.util.HashSet; import java.util.Date;
import java.util.Set; import java.util.HashSet;
import java.util.Set;
public class MindMap {
private static final String UTF_8 = "UTF-8"; public class Mindmap {
private static final String UTF_8 = "UTF-8";
//~ Instance fields ......................................................................................
private int id; //~ Instance fields ......................................................................................
private Calendar creationTime; private int id;
private String description; private Calendar creationTime;
private String description;
private boolean isPublic;
private Calendar lastModificationTime; private boolean isPublic;
private User lastEditor; private Calendar lastModificationTime;
private User lastEditor;
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
private User creator;
private String tags; private User creator;
private String title; private String tags;
private byte[] xml; private String title;
private byte[] xml;
//~ Constructors .........................................................................................
//~ Constructors .........................................................................................
public MindMap() {
} public Mindmap() {
}
//~ Methods ..............................................................................................
//~ Methods ..............................................................................................
public void setXml(byte[] xml) {
this.xml = xml; public void setXml(byte[] xml) {
} this.xml = xml;
}
public void setXmlStr(@NotNull String xml)
throws IOException { public void setXmlStr(@NotNull String xml)
this.xml = xml.getBytes(UTF_8); throws IOException {
} this.xml = xml.getBytes(UTF_8);
}
public byte[] getXml() {
return xml; public byte[] getXml() {
} return xml;
}
public String getXmlStr() throws UnsupportedEncodingException {
String result = null; public String getXmlStr() throws UnsupportedEncodingException {
if (this.xml != null) { String result = null;
result = new String(this.xml, UTF_8); if (this.xml != null) {
} result = new String(this.xml, UTF_8);
return result; }
} return result;
}
public byte[] getZippedXml()
throws IOException { public byte[] getZippedXml()
byte[] result = this.xml; throws IOException {
if (result != null) { byte[] result = this.xml;
result = ZipUtils.stringToZip(new String(result, UTF_8)); if (result != null) {
} result = ZipUtils.stringToZip(new String(result, UTF_8));
return result; }
} return result;
}
public void setZippedXml(byte[] xml)
throws IOException { public void setZippedXml(byte[] xml)
this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8); throws IOException {
} this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8);
}
public Set<Collaboration> getCollaborations() {
return collaborations; public Set<Collaboration> getCollaborations() {
} return collaborations;
}
public void setCollaborations(Set<Collaboration> collaborations) {
this.collaborations = collaborations; public void setCollaborations(Set<Collaboration> collaborations) {
} this.collaborations = collaborations;
}
public void addCollaboration(@NotNull Collaboration collaboration) {
collaborations.add(collaboration); public void addCollaboration(@NotNull Collaboration collaboration) {
} collaborations.add(collaboration);
}
public void removedCollaboration(@NotNull Collaboration collaboration) {
collaborations.add(collaboration); public void removedCollaboration(@NotNull Collaboration collaboration) {
} collaborations.add(collaboration);
}
@Nullable
public Collaboration findCollaboration(@NotNull Collaborator collaborator) { @Nullable
return this.findCollaboration(collaborator.getEmail()); public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
} return this.findCollaboration(collaborator.getEmail());
}
@Nullable
public Collaboration findCollaboration(@NotNull String email) { @Nullable
Collaboration result = null; public Collaboration findCollaboration(@NotNull String email) {
for (Collaboration collaboration : collaborations) { Collaboration result = null;
if (collaboration.getCollaborator().getEmail().equals(email)) { for (Collaboration collaboration : collaborations) {
result = collaboration; if (collaboration.getCollaborator().getEmail().equals(email)) {
break; result = collaboration;
} break;
} }
return result; }
} return result;
}
public boolean isPublic() {
return isPublic; public boolean isPublic() {
} return isPublic;
}
public void setPublic(boolean isPublic) {
this.isPublic = isPublic; public void setPublic(boolean isPublic) {
} this.isPublic = isPublic;
}
public Calendar getLastModificationTime() {
return lastModificationTime; public Calendar getLastModificationTime() {
} return lastModificationTime;
}
public Date getLastModificationDate() {
return new Date(); public Date getLastModificationDate() {
} return new Date();
}
public void setLastModificationTime(Calendar lastModificationTime) {
this.lastModificationTime = lastModificationTime; public void setLastModificationTime(Calendar lastModificationTime) {
} this.lastModificationTime = lastModificationTime;
}
@Nullable
public User getLastEditor() { @Nullable
return lastEditor; public User getLastEditor() {
} return lastEditor;
}
public void setLastEditor(@Nullable User lastEditor) {
this.lastEditor = lastEditor; public void setLastEditor(@Nullable User lastEditor) {
} this.lastEditor = lastEditor;
}
public int getId() {
return id; public int getId() {
} return id;
}
public void setId(int id) {
this.id = id; public void setId(int id) {
} this.id = id;
}
public String getTitle() {
return title; public String getTitle() {
} return title;
}
public void setTitle(String title) {
this.title = title; public void setTitle(String title) {
} this.title = title;
}
public String getXmlAsJsLiteral()
throws IOException { public String getXmlAsJsLiteral()
String xml = this.getXmlStr(); throws IOException {
if (xml != null) { String xml = this.getXmlStr();
xml = xml.replace("'", "\\'"); if (xml != null) {
xml = xml.replaceAll("\\r|\\n", ""); xml = StringEscapeUtils.escapeJavaScript(xml);
xml = xml.trim(); }
} return xml;
return xml; }
}
public void setTags(String tags) {
public void setTags(String tags) { this.tags = tags;
this.tags = tags; }
}
public String getTags() {
public String getTags() { return tags;
return tags; }
}
public String getDescription() {
public String getDescription() { return description;
return description; }
}
public void setDescription(String description) {
public void setDescription(String description) { this.description = description;
this.description = description; }
}
public Calendar getCreationTime() {
public Calendar getCreationTime() { return creationTime;
return creationTime; }
}
public void setCreationTime(Calendar creationTime) {
public void setCreationTime(Calendar creationTime) { this.creationTime = creationTime;
this.creationTime = creationTime; }
}
public void setCreator(@NotNull User creator) {
public void setCreator(@NotNull User creator) { if (creator == null) {
if (creator == null) { throw new IllegalArgumentException("Owner can not be null");
throw new IllegalArgumentException("Owner can not be null"); }
} this.creator = creator;
this.creator = creator; }
}
public User getCreator() {
public User getCreator() { return creator;
return creator; }
}
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { final Collaboration collaboration = this.findCollaboration(collaborator);
final Collaboration collaboration = this.findCollaboration(collaborator); return collaboration != null ? collaboration.getCollaborationProperties() : null;
return collaboration != null ? collaboration.getCollaborationProperties() : null; }
}
public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException {
public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException { final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator);
final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator); collaborationProperties.setStarred(value);
collaborationProperties.setStarred(value); }
}
@NotNull
@NotNull public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException {
public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException { if (collaborator == null) {
if (collaborator == null) { throw new IllegalStateException("Collaborator can not be null");
throw new IllegalStateException("Collaborator can not be null"); }
}
final Collaboration collaboration = this.findCollaboration(collaborator);
final Collaboration collaboration = this.findCollaboration(collaborator); if (collaboration == null) {
if (collaboration == null) { throw new WiseMappingException("User is not collaborator");
throw new WiseMappingException("User is not collaborator"); }
} return collaboration.getCollaborationProperties();
return collaboration.getCollaborationProperties(); }
}
public boolean isStarred(@NotNull Collaborator collaborator) {
public boolean isStarred(@NotNull Collaborator collaborator) { final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator); return collaboratorProperty != null && collaboratorProperty.getStarred();
return collaboratorProperty != null && collaboratorProperty.getStarred(); }
}
public static String getDefaultMindmapXml(@NotNull final String title) {
public static String getDefaultMindmapXml(@NotNull final String title) {
final StringBuilder result = new StringBuilder();
final StringBuilder result = new StringBuilder(); result.append("<map version=\"tango\">");
result.append("<map version=\"tango\">"); result.append("<topic central=\"true\" text=\"");
result.append("<topic central=\"true\" text=\""); result.append(StringEscapeUtils.escapeXml(title));
result.append(title); result.append("\"/></map>");
result.append("\"/></map>"); return result.toString();
return result.toString(); }
}
public Mindmap shallowClone() {
public MindMap shallowClone() { final Mindmap result = new Mindmap();
final MindMap result = new MindMap(); result.setDescription(this.getDescription());
result.setDescription(this.getDescription()); result.setTitle(this.getTitle());
result.setTitle(this.getTitle()); result.setXml(this.getXml());
result.setXml(this.getXml()); result.setTags(this.getTags());
result.setTags(this.getTags());
return result;
return result; }
}
public boolean hasPermissions(@NotNull Collaborator collaborator, @NotNull CollaborationRole role) {
public boolean hasPermissions(@NotNull Collaborator collaborator, @NotNull CollaborationRole role) { final Collaboration collaboration = this.findCollaboration(collaborator);
final Collaboration collaboration = this.findCollaboration(collaborator); boolean result = false;
boolean result = false; if (collaboration != null) {
if (collaboration != null) { result = collaboration.hasPermissions(role);
result = collaboration.hasPermissions(role); }
} return result;
return result;
}
} }
}

View File

@ -18,7 +18,7 @@
package com.wisemapping.ncontroller; package com.wisemapping.ncontroller;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@ -37,7 +37,7 @@ public class ExtensionsController {
@RequestMapping(value = "try") @RequestMapping(value = "try")
public ModelAndView tryEditor() throws IOException { 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); ModelAndView view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
final String xmlMap = mindmap.getXmlAsJsLiteral(); final String xmlMap = mindmap.getXmlAsJsLiteral();

View File

@ -21,9 +21,8 @@ package com.wisemapping.ncontroller;
import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.MindMapHistory; import com.wisemapping.model.MindMapHistory;
import com.wisemapping.model.User;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
import com.wisemapping.view.MindMapBean; import com.wisemapping.view.MindMapBean;
@ -77,7 +76,7 @@ public class MindmapController {
@RequestMapping(value = "maps/{id}/export") @RequestMapping(value = "maps/{id}/export")
public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException { 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); model.addAttribute("mindmap", mindmap);
return "mindmapExport"; return "mindmapExport";
} }
@ -90,7 +89,7 @@ public class MindmapController {
@RequestMapping(value = "maps/{id}/share") @RequestMapping(value = "maps/{id}/share")
public String showSharePage(@PathVariable int id, @NotNull Model model) { public String showSharePage(@PathVariable int id, @NotNull Model model) {
final MindMap mindmap = findMindmap(id); final Mindmap mindmap = findMindmap(id);
model.addAttribute("mindmap", mindmap); model.addAttribute("mindmap", mindmap);
return "mindmapShare"; return "mindmapShare";
} }
@ -103,7 +102,7 @@ public class MindmapController {
@RequestMapping(value = "maps/{id}/publish") @RequestMapping(value = "maps/{id}/publish")
public String showPublishPage(@PathVariable int id, @NotNull Model model) { 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("mindmap", mindmap);
model.addAttribute("baseUrl", siteBaseUrl); model.addAttribute("baseUrl", siteBaseUrl);
return "mindmapPublish"; return "mindmapPublish";
@ -137,7 +136,7 @@ public class MindmapController {
@RequestMapping(value = "maps/{id}/edit", method = RequestMethod.GET) @RequestMapping(value = "maps/{id}/edit", method = RequestMethod.GET)
public String showMindmapEditorPage(@PathVariable int id, @NotNull Model model) { public String showMindmapEditorPage(@PathVariable int id, @NotNull Model model) {
final MindMapBean mindmapBean = findMindmapBean(id); final MindMapBean mindmapBean = findMindmapBean(id);
final MindMap mindmap = mindmapBean.getDelegated(); final Mindmap mindmap = mindmapBean.getDelegated();
String result; String result;
if (mindmap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR)) { if (mindmap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR)) {
@ -202,8 +201,8 @@ public class MindmapController {
return "redirect:maps/" + mapId + "/embed?zoom=" + zoom; return "redirect:maps/" + mapId + "/embed?zoom=" + zoom;
} }
private MindMap findMindmap(long mapId) { private Mindmap findMindmap(long mapId) {
final MindMap mindmap = mindmapService.findMindmapById((int) mapId); final Mindmap mindmap = mindmapService.findMindmapById((int) mapId);
if (mindmap == null) { if (mindmap == null) {
throw new IllegalArgumentException("Mindmap could not be found"); throw new IllegalArgumentException("Mindmap could not be found");
} }

View File

@ -19,7 +19,7 @@
package com.wisemapping.rest; package com.wisemapping.rest;
import com.wisemapping.mail.NotificationService; import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestLogItem; import com.wisemapping.rest.model.RestLogItem;
import com.wisemapping.security.Utils; 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"}) @RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changePassword(@RequestBody RestLogItem item) { 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(); final User user = Utils.getUser();
notificationService.reportMindmapEditorError(mindmap, user, item.getUserAgent(), item.getJsErrorMsg() + "\n" + item.getJsStack()); notificationService.reportMindmapEditorError(mindmap, user, item.getUserAgent(), item.getJsErrorMsg() + "\n" + item.getJsStack());
} }

View File

@ -57,7 +57,7 @@ public class MindmapController extends BaseController {
@ResponseBody @ResponseBody
public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException { public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser(); final User user = Utils.getUser();
final MindMap mindMap = mindmapService.findMindmapById(id); final Mindmap mindMap = mindmapService.findMindmapById(id);
final RestMindmap map = new RestMindmap(mindMap, user); final RestMindmap map = new RestMindmap(mindMap, user);
return new ModelAndView("mapView", "map", map); 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"}) @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/wisemapping+xml"}, params = {"download=wxml"})
@ResponseBody @ResponseBody
public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException { public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.findMindmapById(id); final Mindmap mindMap = mindmapService.findMindmapById(id);
final Map<String, Object> values = new HashMap<String, Object>(); final Map<String, Object> values = new HashMap<String, Object>();
final User user = Utils.getUser(); 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"}) @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"})
@ResponseBody @ResponseBody
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException { public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException {
final MindMap mindMap = mindmapService.findMindmapById(id); final Mindmap mindMap = mindmapService.findMindmapById(id);
final Map<String, Object> values = new HashMap<String, Object>(); final Map<String, Object> values = new HashMap<String, Object>();
values.put("content", mindMap.getXmlStr()); values.put("content", mindMap.getXmlStr());
values.put("filename", mindMap.getTitle()); values.put("filename", mindMap.getTitle());
@ -92,9 +92,9 @@ public class MindmapController extends BaseController {
final MindmapFilter filter = MindmapFilter.parse(q); final MindmapFilter filter = MindmapFilter.parse(q);
final List<Collaboration> collaborations = mindmapService.findCollaborations(user); final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
final List<MindMap> mindmaps = new ArrayList<MindMap>(); final List<Mindmap> mindmaps = new ArrayList<Mindmap>();
for (Collaboration collaboration : collaborations) { for (Collaboration collaboration : collaborations) {
final MindMap mindmap = collaboration.getMindMap(); final Mindmap mindmap = collaboration.getMindMap();
if (filter.accept(mindmap, user)) { if (filter.accept(mindmap, user)) {
mindmaps.add(mindmap); mindmaps.add(mindmap);
} }
@ -118,7 +118,7 @@ public class MindmapController extends BaseController {
@RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST) @RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException { 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(); final User user = Utils.getUser();
if (LATEST_HISTORY_REVISION.equals(hid)) { if (LATEST_HISTORY_REVISION.equals(hid)) {
@ -138,7 +138,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException { 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(); final User user = Utils.getUser();
// Validate arguments ... // Validate arguments ...
@ -169,7 +169,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void update(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException { 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 User user = Utils.getUser();
final String xml = restMindmap.getXml(); final String xml = restMindmap.getXml();
@ -213,7 +213,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException { 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(); final User user = Utils.getUser();
// Is there a map with the same name ? // Is there a map with the same name ?
@ -223,7 +223,7 @@ public class MindmapController extends BaseController {
} }
// Update map ... // Update map ...
final MindMap mindmap = mindmapService.findMindmapById(id); final Mindmap mindmap = mindmapService.findMindmapById(id);
mindmap.setTitle(title); mindmap.setTitle(title);
saveMindmap(true, mindMap, user); 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"}) @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) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException { 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... // Only owner can change collaborators...
final User user = Utils.getUser(); 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"}) @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"})
public ModelAndView retrieveList(@PathVariable int id) { public ModelAndView retrieveList(@PathVariable int id) {
final MindMap mindMap = mindmapService.findMindmapById(id); final Mindmap mindMap = mindmapService.findMindmapById(id);
final Set<Collaboration> collaborations = mindMap.getCollaborations(); final Set<Collaboration> collaborations = mindMap.getCollaborations();
final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>(); final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>();
@ -290,11 +290,11 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException { 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(); final User user = Utils.getUser();
// Update map ... // Update map ...
final MindMap mindmap = mindmapService.findMindmapById(id); final Mindmap mindmap = mindmapService.findMindmapById(id);
mindmap.setDescription(description); mindmap.setDescription(description);
saveMindmap(true, mindMap, user); saveMindmap(true, mindMap, user);
} }
@ -303,7 +303,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { 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(); final User user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) { if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
@ -320,7 +320,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { 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(); final User user = Utils.getUser();
// Update map status ... // Update map status ...
@ -337,7 +337,7 @@ public class MindmapController extends BaseController {
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateMap(@PathVariable int id) throws IOException, WiseMappingException { public void updateMap(@PathVariable int id) throws IOException, WiseMappingException {
final User user = Utils.getUser(); final User user = Utils.getUser();
final MindMap mindmap = mindmapService.findMindmapById(id); final Mindmap mindmap = mindmapService.findMindmapById(id);
mindmapService.removeMindmap(mindmap, user); mindmapService.removeMindmap(mindmap, user);
} }
@ -347,7 +347,7 @@ public class MindmapController extends BaseController {
final User user = Utils.getUser(); final User user = Utils.getUser();
final String[] mapsIds = ids.split(","); final String[] mapsIds = ids.split(",");
for (final String mapId : mapsIds) { 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); mindmapService.removeMindmap(mindmap, user);
} }
} }
@ -372,10 +372,10 @@ public class MindmapController extends BaseController {
} }
// If the user has not specified the xml content, add one ... // 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(); String xml = restMindmap.getXml();
if (xml == null || xml.isEmpty()) { if (xml == null || xml.isEmpty()) {
xml = MindMap.getDefaultMindmapXml(restMindmap.getTitle()); xml = Mindmap.getDefaultMindmapXml(restMindmap.getTitle());
} }
delegated.setXmlStr(xml); 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 { public void createMapFromFreemind(@RequestBody byte[] freemindXml, @RequestParam(required = true) String title, @RequestParam(required = false) String description, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
// Convert map ... // Convert map ...
final MindMap mindMap; final Mindmap mindMap;
try { try {
final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND); final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND);
final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml); final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml);
@ -421,8 +421,8 @@ public class MindmapController extends BaseController {
final User user = Utils.getUser(); final User user = Utils.getUser();
// Create a shallowCopy of the map ... // Create a shallowCopy of the map ...
final MindMap mindMap = mindmapService.findMindmapById(id); final Mindmap mindMap = mindmapService.findMindmapById(id);
final MindMap clonedMap = mindMap.shallowClone(); final Mindmap clonedMap = mindMap.shallowClone();
clonedMap.setTitle(restMindmap.getTitle()); clonedMap.setTitle(restMindmap.getTitle());
clonedMap.setDescription(restMindmap.getDescription()); clonedMap.setDescription(restMindmap.getDescription());
@ -434,7 +434,7 @@ public class MindmapController extends BaseController {
response.setHeader("ResourceId", Integer.toString(clonedMap.getId())); 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(); final Calendar now = Calendar.getInstance();
mindMap.setLastModificationTime(now); mindMap.setLastModificationTime(now);
mindMap.setLastEditor(user); mindMap.setLastEditor(user);

View File

@ -20,7 +20,7 @@
package com.wisemapping.rest; package com.wisemapping.rest;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -28,32 +28,32 @@ import org.jetbrains.annotations.Nullable;
public enum MindmapFilter { public enum MindmapFilter {
ALL("all") { ALL("all") {
@Override @Override
public boolean accept(@NotNull MindMap mindmap, @NotNull User user) { public boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return true; return true;
} }
}, },
MY_MAPS("my_maps") { MY_MAPS("my_maps") {
@Override @Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) { boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return mindmap.getCreator().equals(user); return mindmap.getCreator().equals(user);
} }
}, },
STARRED("starred") { STARRED("starred") {
@Override @Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) { boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return mindmap.isStarred(user); return mindmap.isStarred(user);
} }
}, },
SHARED_WITH_ME("shared_with_me") { SHARED_WITH_ME("shared_with_me") {
@Override @Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) { boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return !MY_MAPS.accept(mindmap, user); return !MY_MAPS.accept(mindmap, user);
} }
}, },
PUBLIC("public") { PUBLIC("public") {
@Override @Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) { boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
return mindmap.isPublic(); return mindmap.isPublic();
} }
}; };
@ -76,6 +76,6 @@ public enum MindmapFilter {
return result; return result;
} }
abstract boolean accept(@NotNull MindMap mindmap, @NotNull User user); abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user);
} }

View File

@ -1,8 +1,6 @@
package com.wisemapping.rest.model; package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -27,7 +27,7 @@ public class RestMindmap {
@JsonIgnore @JsonIgnore
private Collaborator collaborator; private Collaborator collaborator;
@JsonIgnore @JsonIgnore
private MindMap mindmap; private Mindmap mindmap;
@JsonIgnore @JsonIgnore
static private SimpleDateFormat sdf; static private SimpleDateFormat sdf;
private String properties; private String properties;
@ -38,11 +38,11 @@ public class RestMindmap {
} }
public RestMindmap() throws WiseMappingException { 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.mindmap = mindmap;
this.collaborator = collaborator; this.collaborator = collaborator;
if (collaborator != null) { if (collaborator != null) {
@ -172,7 +172,7 @@ public class RestMindmap {
} }
@JsonIgnore @JsonIgnore
public MindMap getDelegated() { public Mindmap getDelegated() {
return this.mindmap; return this.mindmap;
} }

View File

@ -1,16 +1,10 @@
package com.wisemapping.rest.model; 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.model.MindMapHistory;
import com.wisemapping.security.Utils;
import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;

View File

@ -3,7 +3,7 @@ package com.wisemapping.rest.model;
import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.annotate.*;
@ -30,7 +30,7 @@ import java.util.TimeZone;
public class RestMindmapInfo { public class RestMindmapInfo {
@JsonIgnore @JsonIgnore
private MindMap mindmap; private Mindmap mindmap;
private Collaborator collaborator; private Collaborator collaborator;
@JsonIgnore @JsonIgnore
static private SimpleDateFormat sdf; static private SimpleDateFormat sdf;
@ -41,11 +41,11 @@ public class RestMindmapInfo {
} }
public 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.mindmap = mindmap;
this.collaborator = collaborator; this.collaborator = collaborator;
} }
@ -135,7 +135,7 @@ public class RestMindmapInfo {
} }
@JsonIgnore @JsonIgnore
public MindMap getDelegated() { public Mindmap getDelegated() {
return this.mindmap; return this.mindmap;
} }

View File

@ -2,7 +2,7 @@ package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -26,12 +26,12 @@ public class RestMindmapList {
private List<RestMindmapInfo> mindmapsInfo; private List<RestMindmapInfo> mindmapsInfo;
public RestMindmapList() { public RestMindmapList() {
this(Collections.<MindMap>emptyList(), null); this(Collections.<Mindmap>emptyList(), null);
} }
public RestMindmapList(@NotNull List<MindMap> mindmaps, @NotNull Collaborator collaborator) { public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
this.mindmapsInfo = new ArrayList<RestMindmapInfo>(); this.mindmapsInfo = new ArrayList<RestMindmapInfo>();
for (MindMap mindMap : mindmaps) { for (Mindmap mindMap : mindmaps) {
this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator)); this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator));
} }
} }

View File

@ -22,7 +22,7 @@ import com.wisemapping.importer.ImportFormat;
import com.wisemapping.importer.Importer; import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.ImporterFactory; import com.wisemapping.importer.ImporterFactory;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.view.AbstractView; import org.springframework.web.servlet.view.AbstractView;
@ -51,7 +51,7 @@ public class ImportTransformationView extends AbstractView {
// Convert to map ... // Convert to map ...
final InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8")); 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... // Set file name...
final String fileName = (filename != null ? filename : "map") + "." + "xwise"; final String fileName = (filename != null ? filename : "map") + "." + "xwise";

View File

@ -1,67 +1,66 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.security.aop; package com.wisemapping.security.aop;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.exceptions.UnexpectedArgumentException; import com.wisemapping.exceptions.UnexpectedArgumentException;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Nullable;
public abstract class BaseSecurityAdvice {
public abstract class BaseSecurityAdvice { private MindmapService mindmapService = null;
private MindmapService mindmapService = null;
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException {
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException { final User user = Utils.getUser();
final User user = Utils.getUser(); final Object argument = methodInvocation.getArguments()[0];
final Object argument = methodInvocation.getArguments()[0]; boolean isAllowed;
boolean isAllowed;
if (argument instanceof Mindmap) {
if (argument instanceof MindMap) { isAllowed = isAllowed(user, (Mindmap) argument);
isAllowed = isAllowed(user, (MindMap) argument); } else if (argument instanceof Integer) {
} else if (argument instanceof Integer) { isAllowed = isAllowed(user, ((Integer) argument));
isAllowed = isAllowed(user, ((Integer) argument)); } else if (argument instanceof Collaborator) {
} else if (argument instanceof Collaborator) { // Read operation find on the user are allowed ...
// Read operation find on the user are allowed ... isAllowed = user.equals(argument);
isAllowed = user.equals(argument); } else {
} else { throw new UnexpectedArgumentException("Argument " + argument);
throw new UnexpectedArgumentException("Argument " + argument); }
}
if (!isAllowed) {
if (!isAllowed) { throw new AccessDeniedSecurityException("User '" + (user != null ? user.getEmail() : "none") + "' not allowed to invoke:" + methodInvocation);
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, MindMap map);
protected abstract boolean isAllowed(@Nullable User user, int mapId);
protected abstract boolean isAllowed(@Nullable User user, int mapId);
protected MindmapService getMindmapService() {
protected MindmapService getMindmapService() { return mindmapService;
return mindmapService; }
}
public void setMindmapService(MindmapService service) {
public void setMindmapService(MindmapService service) { this.mindmapService = service;
this.mindmapService = service; }
} }
}

View File

@ -1,53 +1,53 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.security.aop; package com.wisemapping.security.aop;
import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.User; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.MindMap; import com.wisemapping.model.User;
import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class UpdateSecurityAdvise public class UpdateSecurityAdvise
extends BaseSecurityAdvice extends BaseSecurityAdvice
implements MethodInterceptor { implements MethodInterceptor {
public Object invoke(MethodInvocation methodInvocation) throws Throwable { public Object invoke(MethodInvocation methodInvocation) throws Throwable {
checkRole(methodInvocation); checkRole(methodInvocation);
return methodInvocation.proceed(); return methodInvocation.proceed();
} }
protected boolean isAllowed(@Nullable User user, @NotNull MindMap map) { protected boolean isAllowed(@Nullable User user, @NotNull Mindmap map) {
boolean result; boolean result;
if (map.getCreator() == null) { if (map.getCreator() == null) {
// This means that the map is new and is an add operation. // This means that the map is new and is an add operation.
result = true; result = true;
} else { } else {
result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR); result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR);
} }
return result; return result;
} }
protected boolean isAllowed(@Nullable User user, int mapId) { protected boolean isAllowed(@Nullable User user, int mapId) {
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR); return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
} }
} }

View File

@ -1,45 +1,45 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.security.aop; package com.wisemapping.security.aop;
import org.aopalliance.intercept.MethodInterceptor; import com.wisemapping.model.Mindmap;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInterceptor;
import com.wisemapping.model.CollaborationRole; import org.aopalliance.intercept.MethodInvocation;
import com.wisemapping.model.User; import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.MindMap; import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class ViewBaseSecurityAdvise public class ViewBaseSecurityAdvise
extends BaseSecurityAdvice extends BaseSecurityAdvice
implements MethodInterceptor { implements MethodInterceptor {
public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable { public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable {
checkRole(methodInvocation); checkRole(methodInvocation);
return methodInvocation.proceed(); return methodInvocation.proceed();
} }
protected boolean isAllowed(@Nullable User user, MindMap map) { protected boolean isAllowed(@Nullable User user, Mindmap map) {
return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER); return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER);
} }
protected boolean isAllowed(@Nullable User user, int mapId) { protected boolean isAllowed(@Nullable User user, int mapId) {
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER); return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER);
} }
} }

View File

@ -24,40 +24,39 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.io.IOException;
public interface MindmapService { public interface MindmapService {
static final String TAG_SEPARATOR = " "; 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<Collaboration> findCollaborations(@NotNull User user); List<Collaboration> 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; 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<MindMap> search(MindMapCriteria criteria); List<Mindmap> search(MindMapCriteria criteria);
List<MindMapHistory> findMindmapHistory(int mindmapId); List<MindMapHistory> 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); 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; MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException;

View File

@ -46,12 +46,12 @@ public class MindmapServiceImpl
@Override @Override
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) { 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); return hasPermissions(user, map, grantedRole);
} }
@Override @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; boolean result = false;
if (map != null) { if (map != null) {
if (map.isPublic() && role == CollaborationRole.VIEWER) { if (map.isPublic() && role == CollaborationRole.VIEWER) {
@ -68,12 +68,12 @@ public class MindmapServiceImpl
} }
@Override @Override
public MindMap getMindmapByTitle(String title, User user) { public Mindmap getMindmapByTitle(String title, User user) {
return mindmapManager.getMindmapByTitle(title, user); return mindmapManager.getMindmapByTitle(title, user);
} }
@Override @Override
public MindMap findMindmapById(int mindmapId) { public Mindmap findMindmapById(int mindmapId) {
return mindmapManager.getMindmapById(mindmapId); return mindmapManager.getMindmapById(mindmapId);
} }
@ -83,7 +83,7 @@ public class MindmapServiceImpl
} }
@Override @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) { if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) {
throw new WiseMappingException("The tile can not be empty"); throw new WiseMappingException("The tile can not be empty");
} }
@ -91,14 +91,14 @@ public class MindmapServiceImpl
} }
@Override @Override
public List<MindMap> search(MindMapCriteria criteria) { public List<Mindmap> search(MindMapCriteria criteria) {
return mindmapManager.search(criteria); return mindmapManager.search(criteria);
} }
@Override @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 // remove collaborator association
final MindMap mindMap = collaboration.getMindMap(); final Mindmap mindMap = collaboration.getMindMap();
final Set<Collaboration> collaborations = mindMap.getCollaborations(); final Set<Collaboration> collaborations = mindMap.getCollaborations();
if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) { if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) {
@ -111,7 +111,7 @@ public class MindmapServiceImpl
} }
@Override @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)) { if (mindmap.getCreator().equals(user)) {
mindmapManager.removeMindmap(mindmap); mindmapManager.removeMindmap(mindmap);
} else { } else {
@ -123,7 +123,7 @@ public class MindmapServiceImpl
} }
@Override @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(); final String title = map.getTitle();
@ -151,7 +151,7 @@ public class MindmapServiceImpl
} }
@Override @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 { throws CollaborationException {
// Validate // Validate
@ -197,7 +197,7 @@ public class MindmapServiceImpl
} }
@Override @Override
public void addTags(@NotNull MindMap mindmap, String tags) { public void addTags(@NotNull Mindmap mindmap, String tags) {
mindmap.setTags(tags); mindmap.setTags(tags);
mindmapManager.updateMindmap(mindmap, false); mindmapManager.updateMindmap(mindmap, false);
if (tags != null && tags.length() > 0) { if (tags != null && tags.length() > 0) {
@ -226,7 +226,7 @@ public class MindmapServiceImpl
} }
@Override @Override
public void revertChange(@NotNull MindMap mindmap, int historyId) public void revertChange(@NotNull Mindmap mindmap, int historyId)
throws WiseMappingException { throws WiseMappingException {
final MindMapHistory history = mindmapManager.getHistory(historyId); final MindMapHistory history = mindmapManager.getHistory(historyId);
mindmap.setXml(history.getXml()); mindmap.setXml(history.getXml());

View File

@ -23,9 +23,8 @@ import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.mail.NotificationService; import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.AccessAuditory; import com.wisemapping.model.AccessAuditory;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.app.VelocityEngine;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -33,8 +32,6 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.ui.velocity.VelocityEngineUtils; import org.springframework.ui.velocity.VelocityEngineUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.*;
public class UserServiceImpl public class UserServiceImpl
@ -130,7 +127,7 @@ public class UserServiceImpl
} }
//create welcome map //create welcome map
final MindMap mindMap = buildWelcomeMindmap(user.getFirstname()); final Mindmap mindMap = buildWelcomeMindmap(user.getFirstname());
mindmapService.addMindmap(mindMap, user); mindmapService.addMindmap(mindMap, user);
@ -145,13 +142,13 @@ public class UserServiceImpl
return user; 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. //To change body of created methods use File | Settings | File Templates.
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
// @TODO: Remove this once is translated // @TODO: Remove this once is translated
locale = Locale.ENGLISH; locale = Locale.ENGLISH;
MindMap result = new MindMap(); Mindmap result = new Mindmap();
final Map<String, Object> model = new HashMap<String, Object>(); final Map<String, Object> model = new HashMap<String, Object>();
model.put("messages", messageSource); model.put("messages", messageSource);
model.put("noArgs", new Object[]{}); model.put("noArgs", new Object[]{});

View File

@ -1,96 +1,96 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.validator; package com.wisemapping.validator;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.model.Constants; import com.wisemapping.model.Constants;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
import com.wisemapping.view.MindMapInfoBean; import com.wisemapping.view.MindMapInfoBean;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils; import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
public class MapInfoValidator implements Validator { public class MapInfoValidator implements Validator {
private MindmapService mindmapService; private MindmapService mindmapService;
public boolean supports(final Class clazz) { public boolean supports(final Class clazz) {
return clazz.equals(MindMapInfoBean.class); return clazz.equals(MindMapInfoBean.class);
} }
public MapInfoValidator() { public MapInfoValidator() {
} }
public MapInfoValidator(@NotNull MindmapService service) { public MapInfoValidator(@NotNull MindmapService service) {
this.mindmapService = service; this.mindmapService = service;
} }
public void validate(Object obj, @NotNull Errors errors) { public void validate(Object obj, @NotNull Errors errors) {
final MindMap map = (MindMap) obj; final Mindmap map = (Mindmap) obj;
if (map == null) { if (map == null) {
errors.rejectValue("map", "error.not-specified", null, "Value required."); errors.rejectValue("map", "error.not-specified", null, "Value required.");
} else { } else {
final String title = map.getTitle(); final String title = map.getTitle();
final String desc = map.getDescription(); final String desc = map.getDescription();
validateMapInfo(errors, title, desc); validateMapInfo(errors, title, desc);
} }
} }
protected void validateMapInfo(Errors errors, String title, String desc) { protected void validateMapInfo(Errors errors, String title, String desc) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
if (title != null && title.length() > 0) { if (title != null && title.length() > 0) {
if (title.length() > Constants.MAX_MAP_NAME_LENGTH) { if (title.length() > Constants.MAX_MAP_NAME_LENGTH) {
errors.rejectValue("title", "field.max.length", errors.rejectValue("title", "field.max.length",
new Object[]{Constants.MAX_MAP_NAME_LENGTH}, new Object[]{Constants.MAX_MAP_NAME_LENGTH},
"The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters."); "The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters.");
} else { } else {
// Map already exists ? // Map already exists ?
final MindmapService service = this.getMindmapService(); final MindmapService service = this.getMindmapService();
final User user = com.wisemapping.security.Utils.getUser(); final User user = com.wisemapping.security.Utils.getUser();
final MindMap mindMap = service.getMindmapByTitle(title, user); final Mindmap mindMap = service.getMindmapByTitle(title, user);
if (mindMap != null) { if (mindMap != null) {
errors.rejectValue("title", Messages.MAP_TITLE_ALREADY_EXISTS); errors.rejectValue("title", Messages.MAP_TITLE_ALREADY_EXISTS);
} }
} }
} }
ValidatorUtils.rejectIfExceeded(errors, ValidatorUtils.rejectIfExceeded(errors,
"description", "description",
"The description must have less than " + Constants.MAX_MAP_DESCRIPTION_LENGTH + " characters.", "The description must have less than " + Constants.MAX_MAP_DESCRIPTION_LENGTH + " characters.",
desc, desc,
Constants.MAX_MAP_DESCRIPTION_LENGTH); Constants.MAX_MAP_DESCRIPTION_LENGTH);
} }
public MindmapService getMindmapService() { public MindmapService getMindmapService() {
return mindmapService; return mindmapService;
} }
public void setMindmapService(MindmapService mindmapService) { public void setMindmapService(MindmapService mindmapService) {
this.mindmapService = mindmapService; this.mindmapService = mindmapService;
} }
} }

View File

@ -1,162 +1,162 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.wisemapping.view; package com.wisemapping.view;
import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.*; import com.wisemapping.model.*;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.*; import java.util.*;
public class MindMapBean { public class MindMapBean {
private MindMap mindmap; private Mindmap mindmap;
private List<CollaboratorBean> viewers; private List<CollaboratorBean> viewers;
private List<CollaboratorBean> collaborators; private List<CollaboratorBean> collaborators;
private Collaborator collaborator; private Collaborator collaborator;
public MindMapBean(@NotNull final MindMap mindmap, @Nullable final Collaborator collaborator) { public MindMapBean(@NotNull final Mindmap mindmap, @Nullable final Collaborator collaborator) {
this.mindmap = mindmap; this.mindmap = mindmap;
this.collaborator = collaborator; this.collaborator = collaborator;
this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
} }
public boolean getPublic() { public boolean getPublic() {
return mindmap.isPublic(); return mindmap.isPublic();
} }
public String getTitle() { public String getTitle() {
return mindmap.getTitle(); return mindmap.getTitle();
} }
public String getDescription() { public String getDescription() {
return mindmap.getDescription(); return mindmap.getDescription();
} }
public int getId() { public int getId() {
return mindmap.getId(); return mindmap.getId();
} }
public boolean isStarred() { public boolean isStarred() {
return mindmap.isStarred(collaborator); return mindmap.isStarred(collaborator);
} }
public List<CollaboratorBean> getViewers() { public List<CollaboratorBean> getViewers() {
return viewers; return viewers;
} }
public List<CollaboratorBean> getCollaborators() { public List<CollaboratorBean> getCollaborators() {
return collaborators; return collaborators;
} }
public String getLastEditor() { public String getLastEditor() {
final User lastEditor = mindmap.getLastEditor(); final User lastEditor = mindmap.getLastEditor();
return lastEditor != null ? lastEditor.getFullName() : ""; return lastEditor != null ? lastEditor.getFullName() : "";
} }
public String getLastEditTime() { public String getLastEditTime() {
return DateFormat.getInstance().format(mindmap.getLastModificationTime().getTime()); return DateFormat.getInstance().format(mindmap.getLastModificationTime().getTime());
} }
public String getCreationTime() { public String getCreationTime() {
return DateFormat.getInstance().format(mindmap.getCreationTime().getTime()); return DateFormat.getInstance().format(mindmap.getCreationTime().getTime());
} }
public String getTags() { public String getTags() {
return mindmap.getTags(); return mindmap.getTags();
} }
private List<CollaboratorBean> filterCollaboratorBy(Set<Collaboration> source, CollaborationRole role) { private List<CollaboratorBean> filterCollaboratorBy(Set<Collaboration> source, CollaborationRole role) {
List<CollaboratorBean> col = new ArrayList<CollaboratorBean>(); List<CollaboratorBean> col = new ArrayList<CollaboratorBean>();
if (source != null) { if (source != null) {
for (Collaboration mu : source) { for (Collaboration mu : source) {
if (mu.getRole() == role) { if (mu.getRole() == role) {
col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole())); col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole()));
} }
} }
} }
return col; return col;
} }
public int getCountCollaborators() { public int getCountCollaborators() {
return collaborators != null ? collaborators.size() : 0; return collaborators != null ? collaborators.size() : 0;
} }
public int getCountViewers() { public int getCountViewers() {
return viewers != null ? viewers.size() : 0; return viewers != null ? viewers.size() : 0;
} }
public int getCountShared() { public int getCountShared() {
return getCountCollaborators() + getCountViewers(); return getCountCollaborators() + getCountViewers();
} }
public boolean isShared() { public boolean isShared() {
return getCountShared() > 0; return getCountShared() > 0;
} }
public void setTitle(String t) { public void setTitle(String t) {
mindmap.setTitle(t); mindmap.setTitle(t);
} }
public void setDescription(String d) { public void setDescription(String d) {
mindmap.setDescription(d); mindmap.setDescription(d);
} }
public String getXmlAsJsLiteral() throws IOException { public String getXmlAsJsLiteral() throws IOException {
return this.mindmap.getXmlAsJsLiteral(); return this.mindmap.getXmlAsJsLiteral();
} }
public String getProperties() throws WiseMappingException { public String getProperties() throws WiseMappingException {
String result; String result;
if (collaborator != null) { if (collaborator != null) {
final CollaborationProperties properties = this.mindmap.findCollaborationProperties(collaborator); final CollaborationProperties properties = this.mindmap.findCollaborationProperties(collaborator);
result = properties.getMindmapProperties(); result = properties.getMindmapProperties();
} else { } else {
// It must be public view ... // It must be public view ...
result = CollaborationProperties.DEFAULT_JSON_PROPERTIES; result = CollaborationProperties.DEFAULT_JSON_PROPERTIES;
} }
return result; return result;
} }
public User getCreator() { public User getCreator() {
return mindmap.getCreator(); return mindmap.getCreator();
} }
public boolean isOwner() { public boolean isOwner() {
return mindmap.hasPermissions(collaborator, CollaborationRole.OWNER); return mindmap.hasPermissions(collaborator, CollaborationRole.OWNER);
} }
public boolean isEditor() { public boolean isEditor() {
return mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR); return mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR);
} }
public String getRole() { public String getRole() {
final Collaboration collaboration = this.mindmap.findCollaboration(collaborator); final Collaboration collaboration = this.mindmap.findCollaboration(collaborator);
return collaboration.getRole().getLabel(); return collaboration.getRole().getLabel();
} }
public MindMap getDelegated() { public Mindmap getDelegated() {
return mindmap; return mindmap;
} }
} }

View File

@ -18,15 +18,15 @@
package com.wisemapping.view; package com.wisemapping.view;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
public class MindMapInfoBean { public class MindMapInfoBean {
private String title; private String title;
private String description; private String description;
private MindMap mindMap; private Mindmap mindMap;
public MindMapInfoBean(MindMap map) { public MindMapInfoBean(Mindmap map) {
this.title = map.getTitle(); this.title = map.getTitle();
this.description = map.getDescription(); this.description = map.getDescription();
@ -55,7 +55,7 @@ public class MindMapInfoBean {
} }
public MindMap getMindMap() { public Mindmap getMindMap() {
if (mindMap != null) { if (mindMap != null) {
mindMap.setTitle(title); mindMap.setTitle(title);
mindMap.setDescription(description); mindMap.setDescription(description);

View File

@ -1,34 +1,34 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC <!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <hibernate-mapping>
<class name="com.wisemapping.model.Collaboration" table="COLLABORATION"> <class name="com.wisemapping.model.Collaboration" table="COLLABORATION">
<id name="id"> <id name="id">
<generator class="increment"/> <generator class="increment"/>
</id> </id>
<property name="roleId" column="ROLE_ID" unique="true" not-null="true"/> <property name="roleId" column="ROLE_ID" unique="true" not-null="true"/>
<!-- Read-only association property --> <!-- Read-only association property -->
<many-to-one name="mindMap" <many-to-one name="mindMap"
column="MINDMAP_ID" column="MINDMAP_ID"
not-null="true" not-null="true"
class="com.wisemapping.model.MindMap" class="com.wisemapping.model.Mindmap"
/> />
<many-to-one name="collaborator" <many-to-one name="collaborator"
column="COLABORATOR_ID" column="COLABORATOR_ID"
not-null="true" not-null="true"
class="com.wisemapping.model.Collaborator" class="com.wisemapping.model.Collaborator"
/> />
<many-to-one name="collaborationProperties" class="com.wisemapping.model.CollaborationProperties" <many-to-one name="collaborationProperties" class="com.wisemapping.model.CollaborationProperties"
column="properties_id" not-null="false" cascade="all" unique="true"/> column="properties_id" not-null="false" cascade="all" unique="true"/>
</class> </class>
</hibernate-mapping> </hibernate-mapping>

View File

@ -1,30 +1,30 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC <!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <hibernate-mapping>
<class name="com.wisemapping.model.MindMap" table="MINDMAP"> <class name="com.wisemapping.model.Mindmap" table="MINDMAP">
<id name="id"> <id name="id">
<generator class="increment"/> <generator class="increment"/>
</id> </id>
<property name="title"/> <property name="title"/>
<property name="public"/> <property name="public"/>
<property name="description"/> <property name="description"/>
<property name="zippedXml" column="XML"/> <property name="zippedXml" column="XML"/>
<property name="lastModificationTime" column="edition_date"/> <property name="lastModificationTime" column="edition_date"/>
<property name="creationTime" column="creation_date"/> <property name="creationTime" column="creation_date"/>
<property name="tags" column="tags"/> <property name="tags" column="tags"/>
<many-to-one name="creator" column="creator_id" unique="true" not-null="false" lazy="proxy"/> <many-to-one name="creator" column="creator_id" unique="true" not-null="false" lazy="proxy"/>
<many-to-one name="lastEditor" column="last_editor_id" unique="false" not-null="true" lazy="proxy"/> <many-to-one name="lastEditor" column="last_editor_id" unique="false" not-null="true" lazy="proxy"/>
<set name="collaborations" <set name="collaborations"
cascade="all,delete-orphan" cascade="all,delete-orphan"
inverse="true"> inverse="true">
<key column="MINDMAP_ID" not-null="true"/> <key column="MINDMAP_ID" not-null="true"/>
<one-to-many class="com.wisemapping.model.Collaboration"/> <one-to-many class="com.wisemapping.model.Collaboration"/>
</set> </set>
</class> </class>
</hibernate-mapping> </hibernate-mapping>

View File

@ -25,7 +25,7 @@
<property name="mappingResources"> <property name="mappingResources">
<list> <list>
<value>com/wisemapping/model/Collaborator.hbm.xml</value> <value>com/wisemapping/model/Collaborator.hbm.xml</value>
<value>com/wisemapping/model/MindMap.hbm.xml</value> <value>com/wisemapping/model/Mindmap.hbm.xml</value>
<value>com/wisemapping/model/Collaboration.hbm.xml</value> <value>com/wisemapping/model/Collaboration.hbm.xml</value>
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value> <value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value> <value>com/wisemapping/model/AccessAuditory.hbm.xml</value>

View File

@ -5,7 +5,7 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<%--@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.Boolean"--%>
<%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%>
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>

View File

@ -1,4 +1,4 @@
<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%> <%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
<div id="toolbar"> <div id="toolbar">
<div id="persist" class="buttonContainer"> <div id="persist" class="buttonContainer">

View File

@ -3,7 +3,7 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<%--@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.Boolean"--%>
<%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%>
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>

View File

@ -1,7 +1,7 @@
<%@page pageEncoding="UTF-8" %> <%@page pageEncoding="UTF-8" %>
<%@include file="/jsp/init.jsp" %> <%@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.Boolean"--%>
<%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%>
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>

View File

@ -4,7 +4,7 @@ import com.wisemapping.exporter.ExportException;
import com.wisemapping.exporter.FreemindExporter; import com.wisemapping.exporter.FreemindExporter;
import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.ImporterException;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.testng.Assert; 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 { 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(); final FreemindExporter freemindExporter = new FreemindExporter();
if (recFile.exists()) { 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 byte[] recContent = FileUtils.readFileToByteArray(wisemap);
final MindMap result = new MindMap(); final Mindmap result = new Mindmap();
result.setXml(recContent); result.setXml(recContent);
return result; return result;
} }

View File

@ -6,7 +6,7 @@ import com.wisemapping.importer.ImportFormat;
import com.wisemapping.importer.Importer; import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.ImporterFactory; import com.wisemapping.importer.ImporterFactory;
import com.wisemapping.model.MindMap; import com.wisemapping.model.Mindmap;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.testng.Assert; import org.testng.Assert;
@ -33,7 +33,7 @@ public class ImportExportTest {
@Test(dataProvider = "Data-Provider-Function") @Test(dataProvider = "Data-Provider-Function")
public void exportImportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException { 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 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 ... // Compare mindmap output ...