Minor permissions modification.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-11 21:09:37 -03:00
parent 2e2e978c43
commit a263a05520
2 changed files with 16 additions and 2 deletions

View File

@ -44,6 +44,8 @@ public class MindmapServiceImpl
@Autowired
private NotificationService notificationService;
private String adminUser;
@Override
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) {
final Mindmap map = mindmapManager.getMindmapById(mapId);
@ -54,7 +56,7 @@ public class MindmapServiceImpl
public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
boolean result = false;
if (map != null) {
if (map.isPublic() && role == CollaborationRole.VIEWER) {
if ((map.isPublic() && role == CollaborationRole.VIEWER) || (isAdmin(user) && role == CollaborationRole.VIEWER)) {
result = true;
} else if (user != null) {
final Collaboration collaboration = map.findCollaboration(user);
@ -67,6 +69,10 @@ public class MindmapServiceImpl
return result;
}
private boolean isAdmin(User user) {
return (user != null && user.getEmail().equals(adminUser));
}
@Override
public Mindmap getMindmapByTitle(String title, User user) {
return mindmapManager.getMindmapByTitle(title, user);
@ -219,7 +225,6 @@ public class MindmapServiceImpl
}
@Override
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
return mindmapManager.getHistoryFrom(mindmapId);
@ -282,4 +287,12 @@ public class MindmapServiceImpl
public void setNotificationService(NotificationService notificationService) {
this.notificationService = notificationService;
}
public void setAdminUser(String adminUser) {
this.adminUser = adminUser;
}
public String getAdminUser() {
return adminUser;
}
}

View File

@ -35,6 +35,7 @@
<property name="mindmapManager" ref="mindmapManager"/>
<property name="userService" ref="userService"/>
<property name="notificationService" ref="notificationService"/>
<property name="adminUser" ref="${admin.user}/>
</bean>
<bean id="mindmapService"