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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ package com.wisemapping.exporter;
import com.wisemapping.importer.freemind.FreemindIconConverter;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils;
import com.wisemapping.jaxb.freemind.*;
@ -48,7 +48,7 @@ public class FreemindExporter
private Map<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);
}

View File

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

View File

@ -22,7 +22,7 @@ import com.sun.org.apache.xerces.internal.dom.TextImpl;
import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.VersionNumber;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.ShapeStyle;
import com.wisemapping.util.JAXBUtils;
import com.wisemapping.jaxb.freemind.*;
@ -94,9 +94,9 @@ public class FreemindImporter
}
public MindMap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException {
public Mindmap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException {
final MindMap result = new MindMap();
final Mindmap result = new Mindmap();
nodesMap = new HashMap<String, TopicType>();
relationships = new ArrayList<RelationshipType>();
mindmapObjectFactory = new com.wisemapping.jaxb.wisemap.ObjectFactory();

View File

@ -19,14 +19,13 @@
package com.wisemapping.mail;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
@ -43,7 +42,7 @@ final public class NotificationService {
}
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull MindMap mindmap, @NotNull User user, @Nullable String message) {
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull User user, @Nullable String message) {
try {
// Sent collaboration email ...
@ -151,7 +150,7 @@ final public class NotificationService {
// }
}
public void reportMindmapEditorError(@NotNull MindMap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) {
public void reportMindmapEditorError(@NotNull Mindmap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) {
try {
final Map<String, Object> model = new HashMap<String, Object>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,16 +1,10 @@
package com.wisemapping.rest.model;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.MindMapHistory;
import com.wisemapping.security.Utils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

View File

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

View File

@ -2,7 +2,7 @@ package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.jetbrains.annotations.NotNull;
@ -26,12 +26,12 @@ public class RestMindmapList {
private List<RestMindmapInfo> mindmapsInfo;
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>();
for (MindMap mindMap : mindmaps) {
for (Mindmap mindMap : mindmaps) {
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.ImporterException;
import com.wisemapping.importer.ImporterFactory;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.view.AbstractView;
@ -51,7 +51,7 @@ public class ImportTransformationView extends AbstractView {
// Convert to map ...
final InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
final MindMap mindMap = importer.importMap("filename", "filename", is);
final Mindmap mindMap = importer.importMap("filename", "filename", is);
// Set file name...
final String fileName = (filename != null ? filename : "map") + "." + "xwise";

View File

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

View File

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

View File

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

View File

@ -24,40 +24,39 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.io.IOException;
public interface MindmapService {
static final String TAG_SEPARATOR = " ";
MindMap findMindmapById(int mindmapId);
Mindmap findMindmapById(int mindmapId);
MindMap getMindmapByTitle(String title, User user);
Mindmap getMindmapByTitle(String title, User user);
List<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;
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);
boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole);
boolean hasPermissions(@Nullable User user, Mindmap map, CollaborationRole allowedRole);
boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException;
void revertChange(@NotNull Mindmap map, int historyId) throws WiseMappingException;
MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@
<property name="mappingResources">
<list>
<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/CollaborationProperties.hbm.xml</value>
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value>

View File

@ -5,7 +5,7 @@
<!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.String"--%>
<%--@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="persist" class="buttonContainer">

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import com.wisemapping.exporter.ExportException;
import com.wisemapping.exporter.FreemindExporter;
import com.wisemapping.importer.ImporterException;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.Mindmap;
import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.testng.Assert;
@ -22,7 +22,7 @@ public class ExportTest {
public void exportImportExportTest(@NotNull final File wisemap, @NotNull final File recFile) throws ImporterException, IOException, ExportException {
final MindMap mindmap = load(wisemap);
final Mindmap mindmap = load(wisemap);
final FreemindExporter freemindExporter = new FreemindExporter();
if (recFile.exists()) {
@ -43,9 +43,9 @@ public class ExportTest {
}
}
private MindMap load(@NotNull File wisemap) throws IOException {
private Mindmap load(@NotNull File wisemap) throws IOException {
final byte[] recContent = FileUtils.readFileToByteArray(wisemap);
final MindMap result = new MindMap();
final Mindmap result = new Mindmap();
result.setXml(recContent);
return result;
}

View File

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