From cbdd6dd146092ef19e1c63618933919483d70029 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 12 Jun 2012 11:23:47 -0300 Subject: [PATCH] Simplify security model. --- .../wisemapping/dao/MindmapManagerImpl.java | 2 +- .../com/wisemapping/dao/UserManagerImpl.java | 2 +- .../com/wisemapping/model/Collaboration.java | 19 ++---- .../model/CollaborationProperties.java | 8 +-- .../wisemapping/model/CollaborationRole.java | 24 +------ .../com/wisemapping/model/Collaborator.java | 6 +- .../java/com/wisemapping/model/MindMap.java | 33 +++++----- .../wisemapping/rest/MindmapController.java | 10 +-- .../com/wisemapping/rest/MindmapFilter.java | 2 +- .../wisemapping/rest/model/RestMindmap.java | 5 +- .../rest/model/RestMindmapInfo.java | 26 ++++---- .../com/wisemapping/rest/model/RestUser.java | 2 +- .../security/aop/UpdateSecurityAdvise.java | 8 +-- .../security/aop/ViewBaseSecurityAdvise.java | 5 +- .../wisemapping/service/MindmapService.java | 10 +-- .../service/MindmapServiceImpl.java | 62 ++++++------------- .../com/wisemapping/view/MindMapBean.java | 8 +-- .../wisemapping/model/Collaborator.hbm.xml | 8 +-- .../com/wisemapping/model/MindMap.hbm.xml | 3 +- wise-webapp/src/main/webapp/js/mymaps.js | 6 +- .../src/main/webapp/jsp/mindmapDetail.jsp | 4 +- .../src/main/webapp/jsp/mindmapEmbed.jsp | 2 +- .../src/main/webapp/jsp/mindmapPrint.jsp | 2 +- .../src/test/sql/hsql/create-schemas.sql | 5 +- .../src/test/sql/mysql/create-schemas.sql | 5 +- 25 files changed, 101 insertions(+), 166 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index c93695fd..eb62ae23 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -166,7 +166,7 @@ public class MindmapManagerImpl @Override public MindMap getMindmapByTitle(final String title, final User user) { final MindMap result; - List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user.getUsername()}); + List mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user}); if (mindMaps != null && !mindMaps.isEmpty()) { result = mindMaps.get(0); } else { diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index 42613772..7ccf6f32 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -115,7 +115,7 @@ public class UserManagerImpl newMapUser.setRoleId(collaboration.getRole().ordinal()); newMapUser.setMindMap(collaboration.getMindMap()); newMapUser.setCollaborator(user); - user.addMindmapUser(newMapUser); + user.addCollaboration(newMapUser); } getHibernateTemplate().delete(col); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 3c99e296..b2cbaee6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -38,7 +38,7 @@ public class Collaboration { // Guarantee referential integrity mindmap.addCollaboration(this); - collaborator.addMindmapUser(this); + collaborator.addCollaboration(this); } public long getId() { @@ -65,18 +65,6 @@ public class Collaboration { this.role = role; } - public boolean isOwner() { - return getRole() == CollaborationRole.OWNER; - } - - public boolean isEditor() { - return getRole() == CollaborationRole.EDITOR; - } - - public boolean isViewer() { - return getRole() == CollaborationRole.VIEWER; - } - public MindMap getMindMap() { return mindMap; } @@ -101,4 +89,9 @@ public class Collaboration { public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { this.collaborationProperties = collaborationProperties; } + + public boolean hasPermissions(@NotNull CollaborationRole role) { + return this.getRole().ordinal() <= role.ordinal(); + + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java index c93d5335..417f48d1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java @@ -18,10 +18,8 @@ package com.wisemapping.model; -import org.jetbrains.annotations.NotNull; - public class CollaborationProperties { - private long id; + private int id; private boolean starred; public CollaborationProperties(){ @@ -36,11 +34,11 @@ public class CollaborationProperties { this.starred = starred; } - public long getId() { + public int getId() { return id; } - public void setId(long id) { + public void setId(int id) { this.id = id; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java index 43174b14..3cad1fbc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java @@ -19,27 +19,9 @@ package com.wisemapping.model; public enum CollaborationRole { - OWNER(true, true, true), EDITOR(true, true, false), VIEWER(false, true, false); + OWNER, EDITOR, VIEWER; - private final boolean hasEditPermission; - private final boolean hasViewPermission; - private final boolean hasDeletePermission; - - private CollaborationRole(boolean hasEditPermission, boolean hasViewPermission, boolean hasDeletePermission) { - this.hasEditPermission = hasEditPermission; - this.hasViewPermission = hasViewPermission; - this.hasDeletePermission = hasDeletePermission; - } - - public boolean hasEditPermission() { - return hasEditPermission; - } - - public boolean hasViewPermission() { - return hasViewPermission; - } - - public boolean hasDeletePermission() { - return hasDeletePermission; + public String getLabel(){ + return this.name().toLowerCase(); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java index 9a7e0ee3..0bc5b9a6 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java @@ -18,6 +18,8 @@ package com.wisemapping.model; +import org.jetbrains.annotations.NotNull; + import java.util.Calendar; import java.util.Set; import java.util.HashSet; @@ -40,9 +42,9 @@ public class Collaborator { this.collaborations = collaborations; } - public void addMindmapUser(Collaboration mindmaUser) + public void addCollaboration(@NotNull Collaboration collaboration) { - collaborations.add(mindmaUser); + collaborations.add(collaboration); } public Set getCollaborations() diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java index d30e0d1b..c4dfe12b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -36,7 +36,6 @@ public class MindMap { //~ Instance fields ...................................................................................... private int id; private Calendar creationTime; - private String creator; private String description; private boolean isPublic; @@ -45,7 +44,7 @@ public class MindMap { private Set collaborations = new HashSet(); - private User owner; + private User creator; private String properties; private String tags; private String title; @@ -169,14 +168,6 @@ public class MindMap { this.lastModifierUser = lastModifierUser; } - public String getCreator() { - return creator; - } - - public void setCreator(String creatorUser) { - this.creator = creatorUser; - } - public int getId() { return id; } @@ -229,15 +220,15 @@ public class MindMap { this.creationTime = creationTime; } - public void setOwner(@NotNull User owner) { - if (owner == null) { + public void setCreator(@NotNull User creator) { + if (creator == null) { throw new IllegalArgumentException("Owner can not be null"); } - this.owner = owner; + this.creator = creator; } - public User getOwner() { - return owner; + public User getCreator() { + return creator; } private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { @@ -251,7 +242,7 @@ public class MindMap { } final Collaboration collaboration = this.findCollaboration(collaborator); - if(collaboration==null){ + if (collaboration == null) { throw new WiseMappingException("User is not collaborator"); } @@ -286,4 +277,14 @@ public class MindMap { return result; } + + public boolean hasPermissions(@NotNull Collaborator collaborator, @NotNull CollaborationRole role) { + final Collaboration collaboration = this.findCollaboration(collaborator); + boolean result = false; + if (collaboration != null) { + result = collaboration.hasPermissions(role); + } + return result; + + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 7274b405..8cf7ecb8 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -207,8 +207,10 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException { final MindMap mindMap = mindmapService.getMindmapById(id); + + // Only owner can change collaborators... final User user = Utils.getUser(); - if (!mindMap.getOwner().equals(user)) { + if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) { throw new IllegalArgumentException("No enough permissions"); } @@ -276,9 +278,9 @@ public class MindmapController extends BaseController { public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { final MindMap mindMap = mindmapService.getMindmapById(id); - final User user = Utils.getUser(); - if (!mindMap.getOwner().equals(user)) { + final User user = Utils.getUser(); + if (!!mindMap.hasPermissions(user, CollaborationRole.OWNER)) { throw new IllegalArgumentException("No enough to execute this operation"); } @@ -393,7 +395,7 @@ public class MindmapController extends BaseController { final MindMap clonedMap = mindMap.shallowClone(); clonedMap.setTitle(restMindmap.getTitle()); clonedMap.setDescription(restMindmap.getDescription()); - clonedMap.setOwner(user); + clonedMap.setCreator(user); // Add new mindmap ... mindmapService.addMindmap(clonedMap, user); diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java index be6b53d0..a41bd7df 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java @@ -36,7 +36,7 @@ public enum MindmapFilter { MY_MAPS("my_maps") { @Override boolean accept(@NotNull MindMap mindmap, @NotNull User user) { - return mindmap.getOwner().equals(user); + return mindmap.getCreator().equals(user); } }, STARRED("starred") { diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java index 0b2e36eb..47d3e66a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java @@ -5,7 +5,6 @@ import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.Collaborator; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; -import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,7 +74,7 @@ public class RestMindmap { } public String getCreator() { - return mindmap.getCreator(); + return mindmap.getCreator().getEmail(); } public String getLastModifierUser() { @@ -132,7 +131,7 @@ public class RestMindmap { } public String getOwner() { - final User owner = mindmap.getOwner(); + final User owner = mindmap.getCreator(); return owner != null ? owner.getEmail() : null; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java index ee8a741a..8e60c846 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java @@ -1,9 +1,11 @@ package com.wisemapping.rest.model; +import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaborator; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; +import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,16 +71,20 @@ public class RestMindmapInfo { } public String getCreator() { - return mindmap.getCreator(); + return mindmap.getCreator().getUsername(); } - public String getOwnerEmail() { - return mindmap.getOwner().getEmail(); + public void setCreator() { + // Do nothing ... } - public String getOwner() { - final User owner = mindmap.getOwner(); - return owner.getUsername(); + public String getRole() { + final Collaboration collaboration = mindmap.findCollaboration(Utils.getUser()); + return collaboration != null ? collaboration.getRole().getLabel() : "none"; + } + + public void setRole() { + // Do nothing ... } public String getLastModifierUser() { @@ -117,7 +123,7 @@ public class RestMindmapInfo { mindmap.setDescription(description); } - public void setCreator(String creatorUser) { + public void setCreator(String email) { } @@ -127,12 +133,6 @@ public class RestMindmapInfo { public void setLastModifierUser(String value) { } - public void setOwnerEmail(String value) { - } - - public void setOwner(String value) { - } - @JsonIgnore public MindMap getDelegated() { return this.mindmap; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java index ff59a707..986fb60e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java @@ -78,7 +78,7 @@ public class RestUser { return user.getId(); } - public void setId(long id) { + public void setId(int id) { user.setId(id); } diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java index ff6ee64d..dd3083f8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java @@ -30,8 +30,6 @@ public class UpdateSecurityAdvise extends BaseSecurityAdvice implements MethodInterceptor { - private CollaborationRole grantedRole = CollaborationRole.EDITOR; - public Object invoke(MethodInvocation methodInvocation) throws Throwable { checkRole(methodInvocation); return methodInvocation.proceed(); @@ -39,16 +37,16 @@ public class UpdateSecurityAdvise protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) { boolean result; - if (map.getOwner() == null) { + if (map.getCreator() == null) { // This means that the map is new and is an add operation. result = true; } else { - result = getMindmapService().isAllowedToView(user, map, grantedRole); + result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR); } return result; } protected boolean isAllowed(User user, int mapId) { - return getMindmapService().isAllowedToView(user, mapId, grantedRole); + return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java index e20a163a..14df1e16 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java @@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull; public class ViewBaseSecurityAdvise extends BaseSecurityAdvice implements MethodInterceptor { - private CollaborationRole grantedRole = CollaborationRole.VIEWER; public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable { checkRole(methodInvocation); @@ -36,10 +35,10 @@ public class ViewBaseSecurityAdvise } protected boolean isAllowed(User user, MindMap map) { - return getMindmapService().isAllowedToView(user, map, grantedRole); + return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER); } protected boolean isAllowed(User user, int mapId) { - return getMindmapService().isAllowedToView(user, mapId, grantedRole); + return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java index 4f9576ed..f62a3249 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -29,8 +29,6 @@ public interface MindmapService { public static final String TAG_SEPARATOR = " "; - public Collaboration getMindmapUserBy(int mindmapId, User user); - public MindMap getMindmapById(int mindmapId); public MindMap getMindmapByTitle(String title, User user); @@ -54,13 +52,9 @@ public interface MindmapService { public List getMindMapHistory(int mindmapId); - public boolean isAllowedToView(User user, MindMap map, CollaborationRole allowedRole); + public boolean hasPermissions(User user, MindMap map, CollaborationRole allowedRole); - public boolean isAllowedToView(User user, int mapId, CollaborationRole allowedRole); - - public boolean isAllowedToCollaborate(User user, int mapId, CollaborationRole grantedRole); - - public boolean isAllowedToCollaborate(User user, MindMap map, CollaborationRole grantedRole); + public boolean hasPermissions(User user, int mapId, CollaborationRole allowedRole); public void addWelcomeMindmap(User user) throws WiseMappingException; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index 8f3f90f8..f8382cfe 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -36,54 +36,29 @@ public class MindmapServiceImpl private UserService userService; private Mailer mailer; - public boolean isAllowedToCollaborate(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) { + @Override + public boolean hasPermissions(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) { final MindMap map = mindmapManager.getMindmapById(mapId); - return isAllowedToCollaborate(user, map, grantedRole); + return hasPermissions(user, map, grantedRole); } - public boolean isAllowedToView(User user, int mapId, CollaborationRole grantedRole) { - final MindMap map = mindmapManager.getMindmapById(mapId); - return isAllowedToView(user, map, grantedRole); - } - - public boolean isAllowedToView(@NotNull User user, @NotNull MindMap map, @NotNull CollaborationRole grantedRole) { + @Override + public boolean hasPermissions(@Nullable User user, @Nullable MindMap map, @NotNull CollaborationRole role) { boolean result = false; if (map != null) { - if (map.isPublic()) { + if (map.isPublic() && role == CollaborationRole.VIEWER) { result = true; } else if (user != null) { - result = isAllowedToCollaborate(user, map, grantedRole); + final Collaboration collaboration = map.findCollaboration(user); + if (collaboration != null) { + result = collaboration.hasPermissions(role); + } + } } return result; } - public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, CollaborationRole grantedRole) { - boolean isAllowed = false; - if (map != null) { - if (map.getOwner().getId() == user.getId()) { - isAllowed = true; - } else { - final Set users = map.getCollaborations(); - CollaborationRole rol = null; - for (Collaboration collaboration : users) { - if (collaboration.getCollaborator().getId() == user.getId()) { - rol = collaboration.getRole(); - break; - } - } - // only if the user has a role for the current map - isAllowed = rol != null && - (grantedRole.equals(rol) || rol.ordinal() < grantedRole.ordinal()); - } - } - return isAllowed; - } - - public Collaboration getMindmapUserBy(int mindmapId, User user) { - return mindmapManager.getMindmapUserBy(mindmapId, user); - } - @Override public MindMap getMindmapByTitle(String title, User user) { return mindmapManager.getMindmapByTitle(title, user); @@ -119,18 +94,18 @@ public class MindmapServiceImpl final MindMap mindMap = collaboration.getMindMap(); final Set collaborations = mindMap.getCollaborations(); - // When you delete an object from hibernate you have to delete it from *all* collections it exists in... - if (mindMap.getOwner().getEmail().equals(collaboration.getCollaborator().getEmail())) { + if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) { throw new CollaborationException("User is the creator and must have ownership permissions"); } + // When you delete an object from hibernate you have to delete it from *all* collections it exists in... mindmapManager.removeCollaboration(collaboration); collaborations.remove(collaboration); } @Override public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException { - if (mindmap.getOwner().equals(user)) { + if (mindmap.getCreator().equals(user)) { mindmapManager.removeMindmap(mindmap); } else { final Collaboration collaboration = mindmap.findCollaboration(user); @@ -155,11 +130,10 @@ public class MindmapServiceImpl final Calendar creationTime = Calendar.getInstance(); final String username = user.getUsername(); - map.setCreator(username); map.setLastModifierUser(username); map.setCreationTime(creationTime); map.setLastModificationTime(creationTime); - map.setOwner(user); + map.setCreator(user); // Add map creator with owner permissions ... final User dbUser = userService.getUserBy(user.getId()); @@ -174,8 +148,7 @@ public class MindmapServiceImpl throws CollaborationException { // Validate - final Collaborator owner = mindmap.getOwner(); - final Set collaborations = mindmap.getCollaborations(); + final Collaborator owner = mindmap.getCreator(); if (owner.getEmail().equals(email)) { throw new CollaborationException("The user " + owner.getEmail() + " is the owner"); } @@ -185,6 +158,7 @@ public class MindmapServiceImpl } + final Set collaborations = mindmap.getCollaborations(); Collaboration collaboration = getCollaborationBy(email, collaborations); if (collaboration == null) { final Collaborator collaborator = addCollaborator(email); @@ -224,7 +198,7 @@ public class MindmapServiceImpl mindmapManager.updateMindmap(mindmap, false); if (tags != null && tags.length() > 0) { final String tag[] = tags.split(TAG_SEPARATOR); - final User user = mindmap.getOwner(); + final User user = mindmap.getCreator(); // Add new Tags to User boolean updateUser = false; for (String userTag : tag) { diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index 0b1a8b8f..5711f5c9 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -82,10 +82,6 @@ public class MindMapBean { return DateFormat.getInstance().format(mindMap.getCreationTime().getTime()); } - public String getCreationUser() { - return mindMap.getCreator(); - } - public String getTags() { return mindMap.getTags(); } @@ -126,7 +122,7 @@ public class MindMapBean { mindMap.setDescription(d); } - public User getOwner() { - return mindMap.getOwner(); + public User getCreator() { + return mindMap.getCreator(); } } diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml index ba67a873..74298b56 100755 --- a/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml @@ -13,11 +13,11 @@ + cascade="all, delete-orphan" + inverse="true"> - + @@ -30,7 +30,7 @@ - + diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml index 76d965d9..8083d53f 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml @@ -16,11 +16,10 @@ - - + @@ -13,7 +13,7 @@
  • : ${wisemapDetail.title}
  • : ${wisemapDetail.description}
  • -
  • : ${wisemapDetail.creationUser}
  • +
  • : ${wisemapDetail.creator.username}
  • : ${wisemapDetail.creationTime}
  • : ${wisemapDetail.lastEditTime}
  • : ${wisemapDetail.lastEditor}
  • diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp index 2fa20425..ee895b78 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEmbed.jsp @@ -82,7 +82,7 @@
    - :${mindmap.creator} + :${mindmap.creator.username} :${mindmap.title}
    diff --git a/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp b/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp index 798f8049..7a4c3428 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapPrint.jsp @@ -124,7 +124,7 @@
    - :${mindmap.creator} + :${mindmap.creator.username} :${mindmap.title}
    diff --git a/wise-webapp/src/test/sql/hsql/create-schemas.sql b/wise-webapp/src/test/sql/hsql/create-schemas.sql index 75e0a486..c840059b 100644 --- a/wise-webapp/src/test/sql/hsql/create-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/create-schemas.sql @@ -24,12 +24,11 @@ xml LONGVARBINARY NOT NULL, public BOOLEAN NOT NULL, creation_date DATETIME, edition_date DATETIME, -owner_id INTEGER NOT NULL, +creator_id INTEGER NOT NULL, tags varchar(1014) , last_editor varchar(255) , -creator_user varchar(255) , editor_properties varchar(512) ---FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id) +--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id) ); diff --git a/wise-webapp/src/test/sql/mysql/create-schemas.sql b/wise-webapp/src/test/sql/mysql/create-schemas.sql index fcb9fb88..04f80f1a 100644 --- a/wise-webapp/src/test/sql/mysql/create-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/create-schemas.sql @@ -25,12 +25,11 @@ xml blob NOT NULL, public BOOL not null default 0, creation_date datetime, edition_date datetime, -owner_id INTEGER not null, +creator_id INTEGER not null, tags varchar(1014) CHARACTER SET utf8 , last_editor varchar(255) CHARACTER SET utf8 , -creator_user varchar(255) CHARACTER SET utf8 , editor_properties varchar(512) CHARACTER SET utf8 , -FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id) +FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id) ) CHARACTER SET utf8 ;