Fixed.
parent
0dcdc2c263
commit
52fdefb57e
|
@ -0,0 +1,5 @@
|
|||
RENAME TABLE USER TO ACCOUNT;
|
||||
RENAME TABLE LABEL TO MINDMAP_LABEL;
|
||||
|
||||
ALTER TABLE COLLABORATION
|
||||
RENAME COLUMN colaboration_id to collaboration_id
|
|
@ -1,7 +1,7 @@
|
|||
package com.wisemapping.config.common;
|
||||
|
||||
import com.wisemapping.dao.LabelManagerImpl;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.security.AuthenticationProvider;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapServiceImpl;
|
||||
|
@ -26,7 +26,7 @@ public class CommonConfig {
|
|||
return new AcceptHeaderLocaleResolver() {
|
||||
@Override
|
||||
public Locale resolveLocale(@NotNull HttpServletRequest request) {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
Locale result;
|
||||
if (user != null && user.getLocale() != null) {
|
||||
String locale = user.getLocale();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.wisemapping.config.common;
|
||||
|
||||
import com.wisemapping.dao.MindmapManagerImpl;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.MindmapServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class})
|
||||
@EntityScan(basePackageClasses= User.class)
|
||||
@EntityScan(basePackageClasses= Account.class)
|
||||
public class JPAConfig {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -9,18 +9,18 @@ import java.util.List;
|
|||
|
||||
public interface LabelManager {
|
||||
|
||||
void addLabel(@NotNull final Label label);
|
||||
void addLabel(@NotNull final MindmapLabel label);
|
||||
|
||||
void saveLabel(@NotNull final Label label);
|
||||
void saveLabel(@NotNull final MindmapLabel label);
|
||||
|
||||
@NotNull
|
||||
List<Label> getAllLabels(@NotNull final User user);
|
||||
List<MindmapLabel> getAllLabels(@NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id, @NotNull final User user);
|
||||
MindmapLabel getLabelById(int id, @NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
||||
MindmapLabel getLabelByTitle(@NotNull final String title, @NotNull final Account user);
|
||||
|
||||
void removeLabel(@NotNull final Label label);
|
||||
void removeLabel(@NotNull final MindmapLabel label);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
*/
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -35,51 +35,51 @@ public class LabelManagerImpl
|
|||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
public void addLabel(@NotNull final MindmapLabel label) {
|
||||
saveLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLabel(@NotNull final Label label) {
|
||||
public void saveLabel(@NotNull final MindmapLabel label) {
|
||||
entityManager.persist(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Label> getAllLabels(@NotNull final User user) {
|
||||
final TypedQuery<Label> query = entityManager.createQuery("from com.wisemapping.model.Label wisemapping where creator=:creatorId", Label.class);
|
||||
public List<MindmapLabel> getAllLabels(@NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where creator=:creatorId", MindmapLabel.class);
|
||||
query.setParameter("creatorId", user);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelById(int id, @NotNull final User user) {
|
||||
final TypedQuery<Label> query = entityManager.createQuery("from com.wisemapping.model.Label wisemapping where id=:id and creator=:creator", Label.class);
|
||||
public MindmapLabel getLabelById(int id, @NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where id=:id and creator=:creator", MindmapLabel.class);
|
||||
query.setParameter("id", id);
|
||||
query.setParameter("creator", user);
|
||||
|
||||
final List<Label> resultList = query.getResultList();
|
||||
final List<MindmapLabel> resultList = query.getResultList();
|
||||
return getFirst(resultList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
final TypedQuery<Label> query = entityManager.createQuery("from com.wisemapping.model.Label wisemapping where title=:title and creator=:creator", Label.class);
|
||||
public MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where title=:title and creator=:creator", MindmapLabel.class);
|
||||
query.setParameter("title", title);
|
||||
query.setParameter("creator", user);
|
||||
return query.getResultList().stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Label label) {
|
||||
public void removeLabel(@NotNull MindmapLabel label) {
|
||||
entityManager.remove(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Label getFirst(final List<Label> labels) {
|
||||
Label result = null;
|
||||
private MindmapLabel getFirst(final List<MindmapLabel> labels) {
|
||||
MindmapLabel result = null;
|
||||
if (labels != null && !labels.isEmpty()) {
|
||||
result = labels.get(0);
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ public interface MindmapManager {
|
|||
@Nullable
|
||||
Mindmap getMindmapById(int mindmapId);
|
||||
|
||||
Mindmap getMindmapByTitle(final String name, final User user);
|
||||
Mindmap getMindmapByTitle(final String name, final Account user);
|
||||
|
||||
void addCollaborator(Collaborator collaborator);
|
||||
|
||||
void addMindmap(User user, Mindmap mindmap);
|
||||
void addMindmap(Account user, Mindmap mindmap);
|
||||
|
||||
void saveMindmap(Mindmap mindmap);
|
||||
|
||||
|
@ -55,5 +55,5 @@ public interface MindmapManager {
|
|||
|
||||
void updateCollaboration(@NotNull Collaboration collaboration);
|
||||
|
||||
List<Mindmap> findMindmapByUser(User user);
|
||||
List<Mindmap> findMindmapByUser(Account user);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class MindmapManagerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Mindmap> findMindmapByUser(@NotNull User user) {
|
||||
public List<Mindmap> findMindmapByUser(@NotNull Account user) {
|
||||
|
||||
final TypedQuery<Mindmap> query = entityManager
|
||||
.createQuery("from com.wisemapping.model.Mindmap m where m.id in (select c.mindMap.id from com.wisemapping.model.Collaboration as c where c.collaborator.id=:collabId )", Mindmap.class);
|
||||
|
@ -123,7 +123,7 @@ public class MindmapManagerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mindmap getMindmapByTitle(final String title, final User user) {
|
||||
public Mindmap getMindmapByTitle(final String title, final Account user) {
|
||||
|
||||
final TypedQuery<Mindmap> query = entityManager.createQuery("from com.wisemapping.model.Mindmap wisemapping where title=:title and creator=:creator", Mindmap.class);
|
||||
query.setParameter("title", title);
|
||||
|
@ -139,7 +139,7 @@ public class MindmapManagerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addMindmap(User user, Mindmap mindMap) {
|
||||
public void addMindmap(Account user, Mindmap mindMap) {
|
||||
saveMindmap(mindMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,31 +20,31 @@ package com.wisemapping.dao;
|
|||
|
||||
import com.wisemapping.model.AccessAuditory;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserManager {
|
||||
|
||||
List<User> getAllUsers();
|
||||
List<Account> getAllUsers();
|
||||
|
||||
User getUserBy(String email);
|
||||
Account getUserBy(String email);
|
||||
|
||||
User getUserBy(int id);
|
||||
Account getUserBy(int id);
|
||||
|
||||
void createUser(User user);
|
||||
void createUser(Account user);
|
||||
|
||||
void auditLogin(@NotNull AccessAuditory accessAuditory);
|
||||
|
||||
void updateUser(User user);
|
||||
void updateUser(Account user);
|
||||
|
||||
User getUserByActivationCode(long code);
|
||||
Account getUserByActivationCode(long code);
|
||||
|
||||
Collaborator getCollaboratorBy(String email);
|
||||
|
||||
User createUser(User user, Collaborator col);
|
||||
Account createUser(Account user, Collaborator col);
|
||||
|
||||
void removeUser(@NotNull User user);
|
||||
void removeUser(@NotNull Account user);
|
||||
|
||||
}
|
||||
|
|
|
@ -48,19 +48,19 @@ public class UserManagerImpl
|
|||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
return entityManager.createQuery("from com.wisemapping.model.User user", User.class).getResultList();
|
||||
public List<Account> getAllUsers() {
|
||||
return entityManager.createQuery("from com.wisemapping.model.Account user", Account.class).getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public User getUserBy(@NotNull final String email) {
|
||||
User user = null;
|
||||
public Account getUserBy(@NotNull final String email) {
|
||||
Account user = null;
|
||||
|
||||
TypedQuery<User> query = entityManager.createQuery("from com.wisemapping.model.User colaborator where email=:email", User.class);
|
||||
TypedQuery<Account> query = entityManager.createQuery("from com.wisemapping.model.Account colaborator where email=:email", Account.class);
|
||||
query.setParameter("email", email);
|
||||
|
||||
final List<User> users = query.getResultList();
|
||||
final List<Account> users = query.getResultList();
|
||||
if (users != null && !users.isEmpty()) {
|
||||
assert users.size() == 1 : "More than one user with the same email!";
|
||||
user = users.get(0);
|
||||
|
@ -89,12 +89,12 @@ public class UserManagerImpl
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public User getUserBy(int id) {
|
||||
return entityManager.find(User.class, id);
|
||||
public Account getUserBy(int id) {
|
||||
return entityManager.find(Account.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUser(User user) {
|
||||
public void createUser(Account user) {
|
||||
assert user != null : "Trying to store a null user";
|
||||
if (!AuthenticationType.GOOGLE_OAUTH2.equals(user.getAuthenticationType())) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
|
@ -105,7 +105,7 @@ public class UserManagerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public User createUser(@NotNull User user, @NotNull Collaborator collaborator) {
|
||||
public Account createUser(@NotNull Account user, @NotNull Collaborator collaborator) {
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
// Migrate from previous temporal collab to new user ...
|
||||
|
@ -128,7 +128,7 @@ public class UserManagerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeUser(@NotNull final User user) {
|
||||
public void removeUser(@NotNull final Account user) {
|
||||
entityManager.remove(user);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class UserManagerImpl
|
|||
entityManager.persist(accessAuditory);
|
||||
}
|
||||
|
||||
public void updateUser(@NotNull User user) {
|
||||
public void updateUser(@NotNull Account user) {
|
||||
assert user != null : "user is null";
|
||||
|
||||
// Does the password need to be encrypted ?
|
||||
|
@ -149,14 +149,14 @@ public class UserManagerImpl
|
|||
entityManager.merge(user);
|
||||
}
|
||||
|
||||
public User getUserByActivationCode(long code) {
|
||||
final User user;
|
||||
public Account getUserByActivationCode(long code) {
|
||||
final Account user;
|
||||
|
||||
final TypedQuery<User> query = entityManager.createQuery("from com.wisemapping.model.User user where " +
|
||||
"activationCode=:activationCode", User.class);
|
||||
final TypedQuery<Account> query = entityManager.createQuery("from com.wisemapping.model.User user where " +
|
||||
"activationCode=:activationCode", Account.class);
|
||||
query.setParameter("activationCode", code);
|
||||
|
||||
final List<User> users = query.getResultList();
|
||||
final List<Account> users = query.getResultList();
|
||||
if (users != null && !users.isEmpty()) {
|
||||
|
||||
assert users.size() == 1 : "More than one user with the same username!";
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package com.wisemapping.exceptions;
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AccessDeniedSecurityException
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.exceptions;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class LockException
|
|||
super(message, Severity.INFO);
|
||||
}
|
||||
|
||||
public static LockException createLockLost(@NotNull Mindmap mindmap, @NotNull User user, @NotNull LockManager manager) {
|
||||
public static LockException createLockLost(@NotNull Mindmap mindmap, @NotNull Account user, @NotNull LockManager manager) {
|
||||
return new LockException("Lock can not be granted to " + user.getEmail() + ". The lock is assigned to " + manager.getLockInfo(mindmap));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SessionExpiredException
|
||||
extends ClientException {
|
||||
private static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||
private final User lastUpdater;
|
||||
private final Account lastUpdater;
|
||||
|
||||
public SessionExpiredException(@NotNull String debugInfo, @NotNull User lastUpdater) {
|
||||
public SessionExpiredException(@NotNull String debugInfo, @NotNull Account lastUpdater) {
|
||||
super(debugInfo, Severity.FATAL);
|
||||
this.lastUpdater = lastUpdater;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.listener;
|
|||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
|
@ -51,7 +51,7 @@ public class UnlockOnExpireListener implements HttpSessionListener {
|
|||
final MindmapService mindmapService = (MindmapService) wc.getBean("mindmapService");
|
||||
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final User user = Utils.getUser(false);
|
||||
final Account user = Utils.getUser(false);
|
||||
if (user != null) {
|
||||
synchronized (mindmapService.getLockManager()) {
|
||||
try {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class AccessAuditory
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id", nullable = true)
|
||||
private User user = null;
|
||||
private Account user = null;
|
||||
|
||||
public AccessAuditory() {
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ public class AccessAuditory
|
|||
return loginDate;
|
||||
}
|
||||
|
||||
public void setUser(@NotNull User user) {
|
||||
public void setUser(@NotNull Account user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
public Account getUser() {
|
||||
return this.user;
|
||||
}
|
||||
}
|
|
@ -26,9 +26,9 @@ import java.io.Serializable;
|
|||
import java.util.Calendar;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USER")
|
||||
@PrimaryKeyJoinColumn(name = "colaborator_id")
|
||||
public class User
|
||||
@Table(name = "ACCOUNT")
|
||||
@PrimaryKeyJoinColumn(name = "collaborator_id")
|
||||
public class Account
|
||||
extends Collaborator
|
||||
implements Serializable {
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class User
|
|||
@Column(name = "google_token")
|
||||
private String googleToken;
|
||||
|
||||
public User() {
|
||||
public Account() {
|
||||
}
|
||||
|
||||
public String getFullName() {
|
|
@ -42,7 +42,7 @@ public class Collaboration implements Serializable {
|
|||
private Mindmap mindMap;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "colaborator_id", nullable = false)
|
||||
@JoinColumn(name = "collaborator_id", nullable = false)
|
||||
private Collaborator collaborator;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MindMapHistory {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "editor_id", nullable = true,unique = false)
|
||||
private User editor;
|
||||
private Account editor;
|
||||
|
||||
@Column(name = "xml")
|
||||
private byte[] zippedXml;
|
||||
|
@ -76,11 +76,11 @@ public class MindMapHistory {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public User getEditor() {
|
||||
public Account getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void setEditor(@Nullable User editor) {
|
||||
public void setEditor(@Nullable Account editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
|||
import com.wisemapping.exceptions.InvalidMindmapException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.util.ZipUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
|
@ -54,12 +53,12 @@ public class Mindmap implements Serializable {
|
|||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "creator_id", unique = true)
|
||||
private User creator;
|
||||
private Account creator;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "last_editor_id", nullable = false)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
private User lastEditor;
|
||||
private Account lastEditor;
|
||||
|
||||
private String description;
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class Mindmap implements Serializable {
|
|||
name = "R_LABEL_MINDMAP",
|
||||
joinColumns = @JoinColumn(name = "mindmap_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "label_id"))
|
||||
private Set<Label> labels = new LinkedHashSet<>();
|
||||
private Set<MindmapLabel> labels = new LinkedHashSet<>();
|
||||
|
||||
private String title;
|
||||
|
||||
|
@ -153,15 +152,15 @@ public class Mindmap implements Serializable {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public Set<Label> getLabels() {
|
||||
public Set<MindmapLabel> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(@NotNull final Set<Label> labels) {
|
||||
public void setLabels(@NotNull final Set<MindmapLabel> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
public void addLabel(@NotNull final MindmapLabel label) {
|
||||
this.labels.add(label);
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ public class Mindmap implements Serializable {
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean isCreator(@NotNull User user) {
|
||||
public boolean isCreator(@NotNull Account user) {
|
||||
return this.getCreator() != null && this.getCreator().identityEquality(user);
|
||||
}
|
||||
|
||||
|
@ -206,11 +205,11 @@ public class Mindmap implements Serializable {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public User getLastEditor() {
|
||||
public Account getLastEditor() {
|
||||
return lastEditor;
|
||||
}
|
||||
|
||||
public void setLastEditor(@Nullable User lastEditor) {
|
||||
public void setLastEditor(@Nullable Account lastEditor) {
|
||||
this.lastEditor = lastEditor;
|
||||
}
|
||||
|
||||
|
@ -264,11 +263,11 @@ public class Mindmap implements Serializable {
|
|||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
public void setCreator(@NotNull Account creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public User getCreator() {
|
||||
public Account getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
|
@ -348,7 +347,7 @@ public class Mindmap implements Serializable {
|
|||
}
|
||||
|
||||
public boolean hasLabel(@NotNull final String name) {
|
||||
for (Label label : this.labels) {
|
||||
for (MindmapLabel label : this.labels) {
|
||||
if (label.getTitle().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -356,7 +355,7 @@ public class Mindmap implements Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void removeLabel(@NotNull final Label label) {
|
||||
public void removeLabel(@NotNull final MindmapLabel label) {
|
||||
this.labels.remove(label);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ import java.io.Serializable;
|
|||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "LABEL")
|
||||
@Table(name = "MINDMAP_LABEL")
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Label implements Serializable {
|
||||
public class MindmapLabel implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
@ -43,28 +43,28 @@ public class Label implements Serializable {
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "creator_id", nullable = true, unique = true)
|
||||
@NotNull
|
||||
private User creator;
|
||||
private Account creator;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_label_id", nullable = true)
|
||||
@Nullable
|
||||
private Label parent;
|
||||
private MindmapLabel parent;
|
||||
|
||||
public void setParent(@Nullable Label parent) {
|
||||
public void setParent(@Nullable MindmapLabel parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
public MindmapLabel getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
public void setCreator(@NotNull Account creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public User getCreator() {
|
||||
public Account getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,9 @@ public class Label implements Serializable {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Label)) return false;
|
||||
if (!(o instanceof MindmapLabel)) return false;
|
||||
|
||||
final Label label = (Label) o;
|
||||
final MindmapLabel label = (MindmapLabel) o;
|
||||
return id == label.id && creator.getId() == label.creator.getId()
|
||||
&& Objects.equals(parent, label.parent);
|
||||
}
|
|
@ -21,9 +21,9 @@ package com.wisemapping.rest;
|
|||
import com.wisemapping.exceptions.PasswordTooLongException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
|
@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -61,18 +60,18 @@ public class AccountController extends BaseController {
|
|||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
|
||||
if (password.length() > User.MAX_PASSWORD_LENGTH_SIZE) {
|
||||
if (password.length() > Account.MAX_PASSWORD_LENGTH_SIZE) {
|
||||
throw new PasswordTooLongException();
|
||||
}
|
||||
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setPassword(password);
|
||||
userService.changePassword(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "", produces = {"application/json"})
|
||||
public RestUser fetchAccount() {
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
return new RestUser(user);
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,7 @@ public class AccountController extends BaseController {
|
|||
throw new IllegalArgumentException("Firstname can not be null");
|
||||
}
|
||||
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setFirstname(firstname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
@ -95,7 +94,7 @@ public class AccountController extends BaseController {
|
|||
throw new IllegalArgumentException("lastname can not be null");
|
||||
|
||||
}
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setLastname(lastname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ public class AccountController extends BaseController {
|
|||
|
||||
}
|
||||
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setLocale(language);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
@ -117,7 +116,7 @@ public class AccountController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = "")
|
||||
public void deleteUser() throws WiseMappingException {
|
||||
// Delete collaborations ...
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
|
@ -125,7 +124,7 @@ public class AccountController extends BaseController {
|
|||
}
|
||||
|
||||
// Delete labels ....
|
||||
final List<Label> labels = labelService.getAll(user);
|
||||
final List<MindmapLabel> labels = labelService.getAll(user);
|
||||
labels.forEach(l -> {
|
||||
try {
|
||||
labelService.removeLabel(l, user);
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.wisemapping.exceptions.WiseMappingException;
|
|||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
|
@ -50,7 +50,7 @@ public class AdminController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = "/users/{id}", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestUser getUserById(@PathVariable int id) {
|
||||
final User userBy = userService.getUserBy(id);
|
||||
final Account userBy = userService.getUserBy(id);
|
||||
if (userBy == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class AdminController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = "/users/email/{email:.+}", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestUser getUserByEmail(@PathVariable String email) {
|
||||
final User user = userService.getUserBy(email);
|
||||
final Account user = userService.getUserBy(email);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + email + "' could not be found");
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class AdminController extends BaseController {
|
|||
}
|
||||
|
||||
// Run some other validations ...
|
||||
final User delegated = user.getDelegated();
|
||||
final Account delegated = user.getDelegated();
|
||||
final String lastname = delegated.getLastname();
|
||||
if (lastname == null || lastname.isEmpty()) {
|
||||
throw new IllegalArgumentException("lastname can not be null");
|
||||
|
@ -111,7 +111,7 @@ public class AdminController extends BaseController {
|
|||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
|
||||
final User user = userService.getUserBy(id);
|
||||
final Account user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class AdminController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = "/users/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteUserByEmail(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = userService.getUserBy(id);
|
||||
final Account user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.*;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestErrors;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.NotificationService;
|
||||
|
@ -124,7 +124,7 @@ public class BaseController {
|
|||
@ResponseBody
|
||||
public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
final User user = Utils.getUser(false);
|
||||
final Account user = Utils.getUser(false);
|
||||
notificationService.reportJavaException(ex, user, request);
|
||||
return new RestErrors(ex.getMessage(), Severity.SEVERE);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ package com.wisemapping.rest;
|
|||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.ValidationException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.security.Utils;
|
||||
|
@ -60,7 +60,7 @@ public class LabelController extends BaseController {
|
|||
// Validate ...
|
||||
validate(restLabel);
|
||||
|
||||
final Label label = createLabel(restLabel);
|
||||
final MindmapLabel label = createLabel(restLabel);
|
||||
|
||||
// Return the new created label ...
|
||||
response.setHeader("Location", "/api/restful/labels/" + label.getId());
|
||||
|
@ -69,17 +69,17 @@ public class LabelController extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
|
||||
public RestLabelList retrieveList() {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
assert user != null;
|
||||
final List<Label> all = labelService.getAll(user);
|
||||
final List<MindmapLabel> all = labelService.getAll(user);
|
||||
return new RestLabelList(all);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Label label = labelService.findLabelById(id, user);
|
||||
final Account user = Utils.getUser();
|
||||
final MindmapLabel label = labelService.findLabelById(id, user);
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
|
||||
}
|
||||
|
@ -87,10 +87,10 @@ public class LabelController extends BaseController {
|
|||
labelService.removeLabel(label, user);
|
||||
}
|
||||
|
||||
@NotNull private Label createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
|
||||
final Label label = restLabel.getDelegated();
|
||||
@NotNull private MindmapLabel createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
|
||||
final MindmapLabel label = restLabel.getDelegated();
|
||||
// Add new label ...
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
assert user != null;
|
||||
labelService.addLabel(label, user);
|
||||
return label;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
return new RestMindmap(mindMap, user);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = "/{id}/metadata", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestMindmapMetadata retrieveMetadata(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final MindMapBean mindMapBean = new MindMapBean(mindmap, user);
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class MindmapController extends BaseController {
|
|||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
|
||||
|
@ -131,7 +131,7 @@ public class MindmapController extends BaseController {
|
|||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException {
|
||||
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
|
||||
// Validate arguments ...
|
||||
final String properties = restMindmap.getProperties();
|
||||
|
@ -160,7 +160,7 @@ public class MindmapController extends BaseController {
|
|||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
|
||||
if (LATEST_HISTORY_REVISION.equals(hid)) {
|
||||
// Revert to the latest stored version ...
|
||||
|
@ -190,7 +190,7 @@ public class MindmapController extends BaseController {
|
|||
@ResponseBody
|
||||
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
mindmap.setXmlStr(xmlDoc);
|
||||
|
||||
saveMindmapDocument(false, mindmap, user);
|
||||
|
@ -214,7 +214,7 @@ public class MindmapController extends BaseController {
|
|||
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
|
||||
final String xml = restMindmap.getXml();
|
||||
if (xml != null && !xml.isEmpty()) {
|
||||
|
@ -250,7 +250,7 @@ public class MindmapController extends BaseController {
|
|||
@NotNull
|
||||
private Mindmap findMindmapById(int id) throws MapCouldNotFoundException, AccessDeniedSecurityException {
|
||||
// Has enough permissions ?
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) {
|
||||
throw new AccessDeniedSecurityException(id, user);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ public class MindmapController extends BaseController {
|
|||
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
|
||||
// Is there a map with the same name ?
|
||||
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
||||
|
@ -289,7 +289,7 @@ public class MindmapController extends BaseController {
|
|||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
// Only owner can change collaborators...
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
|
||||
throw new IllegalArgumentException("No enough permissions");
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public class MindmapController extends BaseController {
|
|||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
// Only owner can change collaborators...
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
|
||||
throw new AccessDeniedSecurityException("User must be owner to share mindmap");
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ public class MindmapController extends BaseController {
|
|||
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
|
||||
throw new IllegalArgumentException("No enough to execute this operation");
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteMapById(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ public class MindmapController extends BaseController {
|
|||
}
|
||||
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
|
||||
// Only owner can change collaborators...
|
||||
if (!mindmap.hasPermissions(user, CollaborationRole.OWNER)) {
|
||||
|
@ -492,7 +492,7 @@ public class MindmapController extends BaseController {
|
|||
|
||||
logger.debug("Update starred:" + value);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
|
||||
// Update map status ...
|
||||
final boolean starred = Boolean.parseBoolean(value);
|
||||
|
@ -509,7 +509,7 @@ public class MindmapController extends BaseController {
|
|||
@ResponseBody
|
||||
public String fetchStarred(@PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
if (collaboration.isEmpty()) {
|
||||
|
@ -523,7 +523,7 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = "/batch")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void batchDelete(@RequestParam() String ids) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
final String[] mapsIds = ids.split(",");
|
||||
try {
|
||||
for (final String mapId : mapsIds) {
|
||||
|
@ -565,7 +565,7 @@ public class MindmapController extends BaseController {
|
|||
mindmap.setXmlStr(mapXml);
|
||||
|
||||
// Add new mindmap ...
|
||||
final User user = Utils.getUser(true);
|
||||
final Account user = Utils.getUser(true);
|
||||
mindmapService.addMindmap(mindmap, user);
|
||||
|
||||
// Return the new created map ...
|
||||
|
@ -585,7 +585,7 @@ public class MindmapController extends BaseController {
|
|||
}
|
||||
|
||||
// Some basic validations ...
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
|
||||
// Create a shallowCopy of the map ...
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
@ -606,9 +606,9 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}/labels/{lid}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void removeLabelFromMap(@PathVariable int id, @PathVariable int lid) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final Label label = labelService.findLabelById(lid, user);
|
||||
final MindmapLabel label = labelService.findLabelById(lid, user);
|
||||
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + lid);
|
||||
|
@ -622,8 +622,8 @@ public class MindmapController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = "/{id}/labels", consumes = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void updateLabel(@PathVariable int id, @RequestBody int lid) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Label label = labelService.findLabelById(lid, user);
|
||||
final Account user = Utils.getUser();
|
||||
final MindmapLabel label = labelService.findLabelById(lid, user);
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + lid);
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ public class MindmapController extends BaseController {
|
|||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/{id}/lock", consumes = {"text/plain"}, produces = {"application/json"})
|
||||
public ResponseEntity<RestLockInfo> lockMindmap(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
|
||||
|
@ -652,7 +652,7 @@ public class MindmapController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
private void saveMindmapDocument(boolean minor, @NotNull final Mindmap mindMap, @NotNull final User user) throws WiseMappingException {
|
||||
private void saveMindmapDocument(boolean minor, @NotNull final Mindmap mindMap, @NotNull final Account user) throws WiseMappingException {
|
||||
final Calendar now = Calendar.getInstance();
|
||||
mindMap.setLastModificationTime(now);
|
||||
mindMap.setLastEditor(user);
|
||||
|
@ -665,7 +665,7 @@ public class MindmapController extends BaseController {
|
|||
return new ValidationException(result);
|
||||
}
|
||||
|
||||
private void verifyActiveCollabs(@NotNull RestCollaborationList restCollabs, User user) throws TooManyInactiveAccountsExceptions {
|
||||
private void verifyActiveCollabs(@NotNull RestCollaborationList restCollabs, Account user) throws TooManyInactiveAccountsExceptions {
|
||||
// Do not allow more than 20 new accounts per mindmap...
|
||||
final List<Mindmap> userMindmaps = mindmapService.findMindmapsByUser(user);
|
||||
final Set<String> allEmails = userMindmaps
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -29,35 +29,35 @@ public abstract class MindmapFilter {
|
|||
|
||||
public static final MindmapFilter ALL = new MindmapFilter("all") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public static final MindmapFilter MY_MAPS = new MindmapFilter("my_maps") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return mindmap.getCreator().identityEquality(user);
|
||||
}
|
||||
};
|
||||
|
||||
public static final MindmapFilter STARRED = new MindmapFilter("starred") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return mindmap.isStarred(user);
|
||||
}
|
||||
};
|
||||
|
||||
public static final MindmapFilter SHARED_WITH_ME = new MindmapFilter("shared_with_me") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return !MY_MAPS.accept(mindmap, user);
|
||||
}
|
||||
};
|
||||
|
||||
public static final MindmapFilter PUBLIC = new MindmapFilter("public") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return mindmap.isPublic();
|
||||
}
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ public abstract class MindmapFilter {
|
|||
return result;
|
||||
}
|
||||
|
||||
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user);
|
||||
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull Account user);
|
||||
|
||||
private static final class LabelFilter extends MindmapFilter {
|
||||
|
||||
|
@ -97,7 +97,7 @@ public abstract class MindmapFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
return mindmap.hasLabel(this.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestOath2CallbackResponse;
|
||||
import com.wisemapping.security.JwtTokenUtil;
|
||||
import com.wisemapping.service.UserService;
|
||||
|
@ -52,7 +52,7 @@ public class OAuth2Controller extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = "googlecallback", produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public RestOath2CallbackResponse processGoogleCallback(@NotNull @RequestParam String code, @NotNull HttpServletResponse response, @NotNull HttpServletRequest request) throws WiseMappingException {
|
||||
User user = userService.createAndAuthUserFromGoogle(code);
|
||||
Account user = userService.createAndAuthUserFromGoogle(code);
|
||||
if (user.getGoogleSync()) {
|
||||
jwtTokenUtil.doLogin(response, user.getEmail());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.wisemapping.exceptions.EmailNotExistsException;
|
|||
import com.wisemapping.exceptions.PasswordTooLongException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestResetPasswordResponse;
|
||||
import com.wisemapping.rest.model.RestUserRegistration;
|
||||
import com.wisemapping.service.*;
|
||||
|
@ -35,9 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -77,7 +75,7 @@ public class UserController extends BaseController {
|
|||
@NotNull HttpServletResponse response) throws WiseMappingException, BindException {
|
||||
logger.debug("Register new user:" + registration.getEmail());
|
||||
|
||||
if (registration.getPassword().length() > User.MAX_PASSWORD_LENGTH_SIZE) {
|
||||
if (registration.getPassword().length() > Account.MAX_PASSWORD_LENGTH_SIZE) {
|
||||
throw new PasswordTooLongException();
|
||||
}
|
||||
|
||||
|
@ -90,7 +88,7 @@ public class UserController extends BaseController {
|
|||
|
||||
verify(registration, remoteIp);
|
||||
|
||||
final User user = new User();
|
||||
final Account user = new Account();
|
||||
user.setEmail(registration.getEmail().trim());
|
||||
user.setFirstname(registration.getFirstname());
|
||||
user.setLastname(registration.getLastname());
|
||||
|
|
|
@ -21,7 +21,7 @@ package com.wisemapping.rest.model;
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -38,22 +38,22 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
|
|||
public class RestLabel {
|
||||
|
||||
@JsonIgnore
|
||||
private final Label label;
|
||||
private final MindmapLabel label;
|
||||
|
||||
public RestLabel() {
|
||||
this(new Label());
|
||||
this(new MindmapLabel());
|
||||
}
|
||||
|
||||
public RestLabel(@NotNull final Label label) {
|
||||
public RestLabel(@NotNull final MindmapLabel label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setParent(final Label parent) {
|
||||
public void setParent(final MindmapLabel parent) {
|
||||
this.label.setParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
public MindmapLabel getParent() {
|
||||
return this.label.getParent();
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class RestLabel {
|
|||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Label getDelegated() {
|
||||
public MindmapLabel getDelegated() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
@ -20,9 +20,9 @@ public class RestLabelList {
|
|||
this.restLabels = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RestLabelList(@NotNull final List<Label> labels) {
|
||||
public RestLabelList(@NotNull final List<MindmapLabel> labels) {
|
||||
this.restLabels = new ArrayList<>(labels.size());
|
||||
for (Label label : labels) {
|
||||
for (MindmapLabel label : labels) {
|
||||
this.restLabels.add(new RestLabel(label));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package com.wisemapping.rest.model;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.LockInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -40,7 +40,7 @@ public class RestLockInfo {
|
|||
|
||||
}
|
||||
|
||||
public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull User user) {
|
||||
public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull Account user) {
|
||||
this.email = user.getEmail();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,6 @@ import com.wisemapping.util.TimeUtils;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
@ -103,7 +100,7 @@ public class RestMindmap {
|
|||
}
|
||||
|
||||
public String getCreator() {
|
||||
final User creator = mindmap.getCreator();
|
||||
final Account creator = mindmap.getCreator();
|
||||
return creator != null ? creator.getEmail() : null;
|
||||
}
|
||||
|
||||
|
@ -112,7 +109,7 @@ public class RestMindmap {
|
|||
|
||||
|
||||
public RestCollaborator getLastModifierUser() {
|
||||
final User lastEditor = mindmap.getLastEditor();
|
||||
final Account lastEditor = mindmap.getLastEditor();
|
||||
|
||||
RestCollaborator result = null;
|
||||
if (lastEditor != null && mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR)) {
|
||||
|
@ -155,7 +152,7 @@ public class RestMindmap {
|
|||
}
|
||||
|
||||
public String getOwner() {
|
||||
final User owner = mindmap.getCreator();
|
||||
final Account owner = mindmap.getCreator();
|
||||
return owner != null ? owner.getEmail() : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.wisemapping.rest.model;
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -55,7 +55,7 @@ public class RestMindmapHistory {
|
|||
public RestMindmapHistory(@NotNull MindMapHistory history) {
|
||||
this.id = history.getId();
|
||||
this.creation = history.getCreationTime();
|
||||
final User editor = history.getEditor();
|
||||
final Account editor = history.getEditor();
|
||||
this.creator = editor != null ? editor.getFullName() : "";
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class RestMindmapInfo {
|
|||
// Support test deserialization...
|
||||
Set<RestLabel> result = this.restLabels;
|
||||
if (result == null) {
|
||||
final User me = Utils.getUser();
|
||||
final Account me = Utils.getUser();
|
||||
result = mindmap.getLabels().
|
||||
stream()
|
||||
.filter(l -> l.getCreator().equals(me))
|
||||
|
@ -119,7 +119,7 @@ public class RestMindmapInfo {
|
|||
}
|
||||
|
||||
public String getCreator() {
|
||||
final User creator = mindmap.getCreator();
|
||||
final Account creator = mindmap.getCreator();
|
||||
return creator != null ? creator.getFullName() : null;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class RestMindmapInfo {
|
|||
}
|
||||
|
||||
public String getRole() {
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
String result;
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
return collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
|
||||
|
@ -143,7 +143,7 @@ public class RestMindmapInfo {
|
|||
}
|
||||
|
||||
public String getLastModifierUser() {
|
||||
final User user = mindmap.getLastEditor();
|
||||
final Account user = mindmap.getLastEditor();
|
||||
return user != null ? user.getFullName() : "unknown";
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
@ -38,14 +38,14 @@ import java.util.Calendar;
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RestUser {
|
||||
|
||||
private final User user;
|
||||
private final Account user;
|
||||
private String password;
|
||||
|
||||
public RestUser() {
|
||||
this(new User());
|
||||
this(new Account());
|
||||
}
|
||||
|
||||
public RestUser(@NotNull User user) {
|
||||
public RestUser(@NotNull Account user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class RestUser {
|
|||
}
|
||||
|
||||
@JsonIgnore
|
||||
public User getDelegated() {
|
||||
public Account getDelegated() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ package com.wisemapping.rest.model;
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.User;
|
||||
|
||||
import java.awt.*;
|
||||
import com.wisemapping.model.Account;
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
|
@ -40,8 +38,8 @@ public class RestUserRegistration {
|
|||
private String recaptcha;
|
||||
|
||||
@JsonIgnore
|
||||
public User build() {
|
||||
final User user = new User();
|
||||
public Account build() {
|
||||
final Account user = new Account();
|
||||
user.setFirstname(firstname);
|
||||
user.setLastname(lastname);
|
||||
user.setEmail(email);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
@ -39,7 +39,7 @@ public class AuthenticationProvider implements org.springframework.security.auth
|
|||
final String email = auth.getName();
|
||||
|
||||
final UserDetails userDetails = getUserDetailsService().loadUserByUsername(email);
|
||||
final User user = userDetails.getUser();
|
||||
final Account user = userDetails.getUser();
|
||||
final String credentials = (String) auth.getCredentials();
|
||||
|
||||
if (user == null || credentials == null || !encoder.matches(user.getPassword(), credentials)) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
|
||||
public class GoogleAuthenticationProvider implements org.springframework.security.authentication.AuthenticationProvider {
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class GoogleAuthenticationProvider implements org.springframework.securit
|
|||
throw new BadCredentialsException("No pre-authenticated principal found in request.");
|
||||
}
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(inputToken.getName());
|
||||
final User user = userDetails.getUser();
|
||||
final Account user = userDetails.getUser();
|
||||
|
||||
if (!user.isActive()) {
|
||||
throw new BadCredentialsException("User has been disabled for login " + inputToken.getName());
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.wisemapping.security;
|
|||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -36,7 +36,7 @@ public class MapAccessPermissionEvaluation implements PermissionEvaluator {
|
|||
}
|
||||
|
||||
boolean result;
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
final MapAccessPermission perm = MapAccessPermission.valueOf((permission.toString().toUpperCase()));
|
||||
if (targetDomainObject instanceof Integer) {
|
||||
// Checking permissions by mapId ...
|
||||
|
@ -69,7 +69,7 @@ public class MapAccessPermissionEvaluation implements PermissionEvaluator {
|
|||
|
||||
private boolean hasPrivilege(@NotNull int mapId, @NotNull MapAccessPermission permission) {
|
||||
boolean result;
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (MapAccessPermission.READ == permission) {
|
||||
result = readAdvice.isAllowed(user, mapId);
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ public class MapAccessPermissionEvaluation implements PermissionEvaluator {
|
|||
|
||||
private boolean hasPrivilege(@NotNull Mindmap map, @NotNull MapAccessPermission permission) {
|
||||
boolean result;
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
if (MapAccessPermission.READ == permission) {
|
||||
result = readAdvice.isAllowed(user, map);
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -27,9 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
public abstract class MapPermissionsSecurityAdvice {
|
||||
@Autowired private MindmapService mindmapService;
|
||||
|
||||
protected abstract boolean isAllowed(@Nullable User user, Mindmap map);
|
||||
protected abstract boolean isAllowed(@Nullable Account user, Mindmap map);
|
||||
|
||||
protected abstract boolean isAllowed(@Nullable User user, int mapId);
|
||||
protected abstract boolean isAllowed(@Nullable Account user, int mapId);
|
||||
|
||||
protected MindmapService getMindmapService() {
|
||||
return mindmapService;
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.security;
|
|||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -28,11 +28,11 @@ import org.springframework.stereotype.Component;
|
|||
public class ReadSecurityAdvise
|
||||
extends MapPermissionsSecurityAdvice {
|
||||
|
||||
protected boolean isAllowed(@Nullable User user, Mindmap map) {
|
||||
protected boolean isAllowed(@Nullable Account user, Mindmap map) {
|
||||
return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER);
|
||||
}
|
||||
|
||||
protected boolean isAllowed(@Nullable User user, int mapId) {
|
||||
protected boolean isAllowed(@Nullable Account user, int mapId) {
|
||||
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.security;
|
|||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -30,7 +30,7 @@ public class UpdateSecurityAdvise
|
|||
extends MapPermissionsSecurityAdvice {
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, @NotNull Mindmap map) {
|
||||
protected boolean isAllowed(@Nullable Account user, @NotNull Mindmap map) {
|
||||
boolean result;
|
||||
if (map.getCreator() == null) {
|
||||
// This means that the map is new and is an add operation.
|
||||
|
@ -42,7 +42,7 @@ public class UpdateSecurityAdvise
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable User user, int mapId) {
|
||||
protected boolean isAllowed(@Nullable Account user, int mapId) {
|
||||
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
@ -27,10 +27,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
public class UserDetails implements org.springframework.security.core.userdetails.UserDetails {
|
||||
private final com.wisemapping.model.User user;
|
||||
private final Account user;
|
||||
private final boolean isAdmin;
|
||||
|
||||
public UserDetails(@NotNull final com.wisemapping.model.User user, boolean isAdmin) {
|
||||
public UserDetails(@NotNull final Account user, boolean isAdmin) {
|
||||
this.user = user;
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class UserDetails implements org.springframework.security.core.userdetail
|
|||
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
public Account getUser() {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -41,7 +41,7 @@ public class UserDetailsService
|
|||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(@NotNull String email) throws UsernameNotFoundException, DataAccessException {
|
||||
final User user = userService.getUserBy(email);
|
||||
final Account user = userService.getUserBy(email);
|
||||
|
||||
if (user != null) {
|
||||
return new UserDetails(user, isAdmin(email));
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
@ -30,12 +29,12 @@ final public class Utils {
|
|||
|
||||
@SuppressWarnings({"ConstantConditions"})
|
||||
@Nullable
|
||||
public static User getUser() {
|
||||
public static Account getUser() {
|
||||
return getUser(false);
|
||||
}
|
||||
|
||||
public static User getUser(boolean forceCheck) {
|
||||
User result = null;
|
||||
public static Account getUser(boolean forceCheck) {
|
||||
Account result = null;
|
||||
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null && auth.getDetails() != null)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -27,14 +27,14 @@ import java.util.List;
|
|||
|
||||
public interface LabelService {
|
||||
|
||||
void addLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||
void addLabel(@NotNull final MindmapLabel label, @NotNull final Account user) throws WiseMappingException;
|
||||
|
||||
@NotNull List<Label> getAll(@NotNull final User user);
|
||||
@NotNull List<MindmapLabel> getAll(@NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
Label findLabelById(int id, @NotNull final User user);
|
||||
MindmapLabel findLabelById(int id, @NotNull final Account user);
|
||||
|
||||
Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
||||
MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user);
|
||||
|
||||
void removeLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||
void removeLabel(@NotNull final MindmapLabel label, @NotNull final Account user) throws WiseMappingException;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package com.wisemapping.service;
|
|||
|
||||
import com.wisemapping.dao.LabelManager;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -40,7 +40,7 @@ public class LabelServiceImpl implements LabelService {
|
|||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'WRITE')")
|
||||
public void addLabel(@NotNull final Label label, @NotNull final User user) {
|
||||
public void addLabel(@NotNull final MindmapLabel label, @NotNull final Account user) {
|
||||
|
||||
label.setCreator(user);
|
||||
labelManager.addLabel(label);
|
||||
|
@ -49,26 +49,26 @@ public class LabelServiceImpl implements LabelService {
|
|||
@NotNull
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public List<Label> getAll(@NotNull final User user) {
|
||||
public List<MindmapLabel> getAll(@NotNull final Account user) {
|
||||
return labelManager.getAllLabels(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public Label findLabelById(int id, @NotNull final User user) {
|
||||
public MindmapLabel findLabelById(int id, @NotNull final Account user) {
|
||||
return labelManager.getLabelById(id, user);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
public MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user) {
|
||||
return labelManager.getLabelByTitle(title, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'WRITE')")
|
||||
public void removeLabel(@NotNull Label label, @NotNull User user) throws WiseMappingException {
|
||||
public void removeLabel(@NotNull MindmapLabel label, @NotNull Account user) throws WiseMappingException {
|
||||
if (label.getCreator().equals(user)) {
|
||||
labelManager.removeLabel(label);
|
||||
} else {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class LockInfo {
|
||||
final private User user;
|
||||
final private Account user;
|
||||
private Calendar timeout;
|
||||
private static final int EXPIRATION_MIN = 30;
|
||||
|
||||
|
@ -39,13 +39,13 @@ public class LockInfo {
|
|||
|
||||
private int mapId;
|
||||
|
||||
public LockInfo(@NotNull User user, @NotNull Mindmap mindmap) {
|
||||
public LockInfo(@NotNull Account user, @NotNull Mindmap mindmap) {
|
||||
this.user = user;
|
||||
this.mapId = mindmap.getId();
|
||||
this.updateTimeout();
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
public Account getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,8 @@ package com.wisemapping.service;
|
|||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.exceptions.SessionExpiredException;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface LockManager {
|
||||
|
@ -30,14 +29,14 @@ public interface LockManager {
|
|||
|
||||
LockInfo getLockInfo(@NotNull Mindmap mindmap);
|
||||
|
||||
void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException;
|
||||
void unlock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException;
|
||||
|
||||
void unlockAll(@NotNull User user) throws LockException, AccessDeniedSecurityException;
|
||||
void unlockAll(@NotNull Account user) throws LockException, AccessDeniedSecurityException;
|
||||
|
||||
boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User user);
|
||||
boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Account user);
|
||||
|
||||
long generateSession();
|
||||
|
||||
@NotNull
|
||||
LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException;
|
||||
LockInfo lock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
|||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -50,7 +50,7 @@ class LockManagerImpl implements LockManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unlockAll(@NotNull final User user) throws LockException, AccessDeniedSecurityException {
|
||||
public void unlockAll(@NotNull final Account user) throws LockException, AccessDeniedSecurityException {
|
||||
final Set<Integer> mapIds = lockInfoByMapId.keySet();
|
||||
for (final Integer mapId : mapIds) {
|
||||
final LockInfo lockInfo = lockInfoByMapId.get(mapId);
|
||||
|
@ -61,7 +61,7 @@ class LockManagerImpl implements LockManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException {
|
||||
public void unlock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException {
|
||||
verifyHasLock(mindmap, user);
|
||||
this.unlock(mindmap.getId());
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class LockManagerImpl implements LockManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator) {
|
||||
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Account collaborator) {
|
||||
boolean result = false;
|
||||
final LockInfo lockInfo = this.getLockInfo(mindmap);
|
||||
if (lockInfo != null && lockInfo.getUser().identityEquality(collaborator)) {
|
||||
|
@ -89,7 +89,7 @@ class LockManagerImpl implements LockManager {
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException {
|
||||
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException {
|
||||
if (isLocked(mindmap) && !isLockedBy(mindmap, user)) {
|
||||
throw LockException.createLockLost(mindmap, user, this);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class LockManagerImpl implements LockManager {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void verifyHasLock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException {
|
||||
private void verifyHasLock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException {
|
||||
// Only editor can have lock ...
|
||||
if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) {
|
||||
throw new AccessDeniedSecurityException(mindmap.getId(), user);
|
||||
|
|
|
@ -47,6 +47,9 @@ public final class MailerService {
|
|||
@Value("${app.mail.serverSendEmail}")
|
||||
private String serverFromEmail;
|
||||
|
||||
@Value("${app.mail.enabled:true}")
|
||||
private boolean isEnabled;
|
||||
|
||||
@Value("${app.mail.supportEmail}")
|
||||
private String supportEmail;
|
||||
|
||||
|
@ -58,18 +61,20 @@ public final class MailerService {
|
|||
|
||||
public void sendEmail(final String from, final String to, final String subject, final Map<String, Object> model,
|
||||
@NotNull final String templateMail) {
|
||||
final MimeMessagePreparator preparator =
|
||||
mimeMessage -> {
|
||||
final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, StandardCharsets.UTF_8.name());
|
||||
message.setTo(to);
|
||||
message.setFrom(from);
|
||||
message.setSubject(subject);
|
||||
if (isEnabled) {
|
||||
final MimeMessagePreparator preparator =
|
||||
mimeMessage -> {
|
||||
final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, StandardCharsets.UTF_8.name());
|
||||
message.setTo(to);
|
||||
message.setFrom(from);
|
||||
message.setSubject(subject);
|
||||
|
||||
final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngineWrapper.getVelocityEngine(), "/mail/" + templateMail, model);
|
||||
message.setText(messageBody, true);
|
||||
};
|
||||
final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngineWrapper.getVelocityEngine(), "/mail/" + templateMail, model);
|
||||
message.setText(messageBody, true);
|
||||
};
|
||||
|
||||
this.mailSender.send(preparator);
|
||||
this.mailSender.send(preparator);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMailSender(JavaMailSender mailer) {
|
||||
|
|
|
@ -32,28 +32,28 @@ public interface MindmapService {
|
|||
Mindmap findMindmapById(int id);
|
||||
|
||||
@NotNull
|
||||
List<Mindmap> findMindmapsByUser(@NotNull User user);
|
||||
List<Mindmap> findMindmapsByUser(@NotNull Account user);
|
||||
|
||||
Mindmap getMindmapByTitle(@NotNull String title, User user);
|
||||
Mindmap getMindmapByTitle(@NotNull String title, Account user);
|
||||
|
||||
List<Collaboration> findCollaborations(@NotNull User user);
|
||||
List<Collaboration> findCollaborations(@NotNull Account user);
|
||||
|
||||
void updateMindmap(Mindmap mindMap, boolean saveHistory) throws WiseMappingException;
|
||||
|
||||
void addMindmap(Mindmap map, User user) throws WiseMappingException;
|
||||
void addMindmap(Mindmap map, Account user) throws WiseMappingException;
|
||||
|
||||
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 removeMindmap(@NotNull final Mindmap mindmap, @NotNull final User user) throws WiseMappingException;
|
||||
void removeMindmap(@NotNull final Mindmap mindmap, @NotNull final Account user) throws WiseMappingException;
|
||||
|
||||
List<MindMapHistory> findMindmapHistory(int mindmapId);
|
||||
|
||||
boolean hasPermissions(@Nullable User user, Mindmap map, CollaborationRole allowedRole);
|
||||
boolean hasPermissions(@Nullable Account user, Mindmap map, CollaborationRole allowedRole);
|
||||
|
||||
boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
|
||||
boolean hasPermissions(@Nullable Account user, int mapId, CollaborationRole allowedRole);
|
||||
|
||||
boolean isMindmapPublic(int mapId);
|
||||
|
||||
|
@ -65,5 +65,5 @@ public interface MindmapService {
|
|||
|
||||
LockManager getLockManager();
|
||||
|
||||
boolean isAdmin(@Nullable User user);
|
||||
boolean isAdmin(@Nullable Account user);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class MindmapServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
||||
public boolean hasPermissions(@Nullable Account user, int mapId, @NotNull CollaborationRole grantedRole) {
|
||||
final Mindmap map = mindmapManager.getMindmapById(mapId);
|
||||
return hasPermissions(user, map, grantedRole);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class MindmapServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
|
||||
public boolean hasPermissions(@Nullable Account user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
|
||||
boolean result = false;
|
||||
if (map != null) {
|
||||
if ((map.isPublic() && role == CollaborationRole.VIEWER) || isAdmin(user)) {
|
||||
|
@ -93,13 +93,13 @@ public class MindmapServiceImpl
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean isAdmin(@Nullable User user) {
|
||||
public boolean isAdmin(@Nullable Account user) {
|
||||
return user != null && user.getEmail() != null && user.getEmail().equals(adminUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasPermission(#user, 'READ')")
|
||||
public Mindmap getMindmapByTitle(String title, User user) {
|
||||
public Mindmap getMindmapByTitle(String title, Account user) {
|
||||
return mindmapManager.getMindmapByTitle(title, user);
|
||||
}
|
||||
|
||||
|
@ -113,13 +113,13 @@ public class MindmapServiceImpl
|
|||
@NotNull
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public List<Mindmap> findMindmapsByUser(@NotNull User user) {
|
||||
public List<Mindmap> findMindmapsByUser(@NotNull Account user) {
|
||||
return mindmapManager.findMindmapByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public List<Collaboration> findCollaborations(@NotNull User user) {
|
||||
public List<Collaboration> findCollaborations(@NotNull Account user) {
|
||||
return mindmapManager.findCollaboration(user.getId());
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class MindmapServiceImpl
|
|||
public void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException {
|
||||
// remove collaborator association
|
||||
final Mindmap mindMap = collaboration.getMindMap();
|
||||
final User creator = mindMap.getCreator();
|
||||
final Account creator = mindMap.getCreator();
|
||||
if (creator.identityEquality(collaboration.getCollaborator())) {
|
||||
throw new CollaborationException("User is the creator and must have ownership permissions.Creator Email:" + mindMap.getCreator().getEmail() + ",Collaborator:" + collaboration.getCollaborator().getEmail());
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public class MindmapServiceImpl
|
|||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#mindmap, 'READ')")
|
||||
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
|
||||
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull Account user) throws WiseMappingException {
|
||||
if (mindmap.getCreator().identityEquality(user)) {
|
||||
mindmapManager.removeMindmap(mindmap);
|
||||
} else {
|
||||
|
@ -175,7 +175,7 @@ public class MindmapServiceImpl
|
|||
|
||||
@Override
|
||||
@PreAuthorize("hasPermission(#mindmap, 'WRITE')")
|
||||
public void addMindmap(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
public void addMindmap(@NotNull Mindmap mindmap, @NotNull Account user) {
|
||||
|
||||
final String title = mindmap.getTitle();
|
||||
|
||||
|
@ -195,7 +195,7 @@ public class MindmapServiceImpl
|
|||
mindmap.setCreator(user);
|
||||
|
||||
// Add map creator with owner permissions ...
|
||||
final User dbUser = userService.getUserBy(user.getId());
|
||||
final Account dbUser = userService.getUserBy(user.getId());
|
||||
final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, mindmap);
|
||||
mindmap.getCollaborations().add(collaboration);
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class MindmapServiceImpl
|
|||
mindmapManager.saveMindmap(mindmap);
|
||||
|
||||
// Notify by email ...
|
||||
final User user = Utils.getUser();
|
||||
final Account user = Utils.getUser();
|
||||
notificationService.newCollaboration(collaboration, mindmap, user, message);
|
||||
|
||||
} else if (collaboration.getRole() != role) {
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.service;
|
|||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestLogItem;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -56,7 +56,7 @@ final public class NotificationService {
|
|||
@Value("${site.baseurl:http://localhost:8080/}")
|
||||
private String baseUrl;
|
||||
|
||||
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 Account user, @Nullable String message) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
try {
|
||||
|
@ -91,7 +91,7 @@ final public class NotificationService {
|
|||
|
||||
}
|
||||
|
||||
public void resetPassword(@NotNull User user, @NotNull String temporalPassword) {
|
||||
public void resetPassword(@NotNull Account user, @NotNull String temporalPassword) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_SUBJECT", null, locale);
|
||||
|
@ -102,7 +102,7 @@ final public class NotificationService {
|
|||
}
|
||||
|
||||
|
||||
public void passwordChanged(@NotNull User user) {
|
||||
public void passwordChanged(@NotNull Account user) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_SUBJECT", null, locale);
|
||||
|
@ -112,7 +112,7 @@ final public class NotificationService {
|
|||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
public void newAccountCreated(@NotNull User user) {
|
||||
public void newAccountCreated(@NotNull Account user) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("REGISTRATION.EMAIL_SUBJECT", null, locale);
|
||||
|
@ -121,7 +121,7 @@ final public class NotificationService {
|
|||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
private void sendTemplateMail(@NotNull User user, @NotNull String mailSubject, @NotNull String messageTitle, @NotNull String messageBody) {
|
||||
private void sendTemplateMail(@NotNull Account user, @NotNull String mailSubject, @NotNull String messageTitle, @NotNull String messageBody) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
try {
|
||||
|
@ -150,13 +150,13 @@ final public class NotificationService {
|
|||
}
|
||||
|
||||
|
||||
public void activateAccount(@NotNull User user) {
|
||||
public void activateAccount(@NotNull Account user) {
|
||||
final Map<String, Object> model = new HashMap<>();
|
||||
model.put("user", user);
|
||||
mailerService.sendEmail(mailerService.getServerSenderEmail(), user.getEmail(), "[WiseMapping] Active account", model, "activationAccountMail.vm");
|
||||
}
|
||||
|
||||
public void sendRegistrationEmail(@NotNull User user) {
|
||||
public void sendRegistrationEmail(@NotNull Account user) {
|
||||
// throw new UnsupportedOperationException("Not implemented yet");
|
||||
// try {
|
||||
// final Map<String, String> model = new HashMap<String, String>();
|
||||
|
@ -170,7 +170,7 @@ final public class NotificationService {
|
|||
// }
|
||||
}
|
||||
|
||||
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @NotNull RestLogItem errorItem, @NotNull HttpServletRequest request) {
|
||||
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable Account user, @NotNull RestLogItem errorItem, @NotNull HttpServletRequest request) {
|
||||
|
||||
final Map<String, String> summary = new HashMap<>();
|
||||
summary.put("JS-MSG", errorItem.getJsErrorMsg());
|
||||
|
@ -190,7 +190,7 @@ final public class NotificationService {
|
|||
logger.error("Unexpected editor JS Stack => " + errorItem.getJsErrorMsg() + "-" + errorItem.getJsStack());
|
||||
}
|
||||
|
||||
private void logError(@NotNull Map<String, String> model, @Nullable User user, @NotNull HttpServletRequest request) {
|
||||
private void logError(@NotNull Map<String, String> model, @Nullable Account user, @NotNull HttpServletRequest request) {
|
||||
model.put("fullName", (user != null ? user.getFullName() : "'anonymous'"));
|
||||
final String userEmail = user != null ? user.getEmail() : "'anonymous'";
|
||||
|
||||
|
@ -208,7 +208,7 @@ final public class NotificationService {
|
|||
logger.error("Unexpected editor info => " + errorAsString);
|
||||
}
|
||||
|
||||
public void reportJavaException(@NotNull Throwable exception, @Nullable User user, @NotNull HttpServletRequest request) {
|
||||
public void reportJavaException(@NotNull Throwable exception, @Nullable Account user, @NotNull HttpServletRequest request) {
|
||||
final Map<String, String> model = new HashMap<>();
|
||||
model.put("errorMsg", stackTraceToString(exception));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestResetPasswordResponse;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -28,25 +28,25 @@ public interface UserService {
|
|||
|
||||
void activateAccount(long code) throws InvalidActivationCodeException;
|
||||
|
||||
User createUser(@NotNull User user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException;
|
||||
Account createUser(@NotNull Account user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException;
|
||||
|
||||
User createAndAuthUserFromGoogle(@NotNull String callbackCode) throws WiseMappingException;
|
||||
Account createAndAuthUserFromGoogle(@NotNull String callbackCode) throws WiseMappingException;
|
||||
|
||||
User confirmAccountSync(@NotNull String email, @NotNull String code) throws WiseMappingException;
|
||||
Account confirmAccountSync(@NotNull String email, @NotNull String code) throws WiseMappingException;
|
||||
|
||||
void changePassword(@NotNull User user);
|
||||
void changePassword(@NotNull Account user);
|
||||
|
||||
User getUserBy(String email);
|
||||
Account getUserBy(String email);
|
||||
|
||||
User getUserBy(int id);
|
||||
Account getUserBy(int id);
|
||||
|
||||
void updateUser(User user);
|
||||
void updateUser(Account user);
|
||||
|
||||
RestResetPasswordResponse resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
|
||||
|
||||
void removeUser(@NotNull User user);
|
||||
void removeUser(@NotNull Account user);
|
||||
|
||||
void auditLogin(@NotNull User user);
|
||||
void auditLogin(@NotNull Account user);
|
||||
|
||||
User getCasUserBy(String uid);
|
||||
Account getCasUserBy(String uid);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class UserServiceImpl
|
|||
@Override
|
||||
public void activateAccount(long code)
|
||||
throws InvalidActivationCodeException {
|
||||
final User user = userManager.getUserByActivationCode(code);
|
||||
final Account user = userManager.getUserByActivationCode(code);
|
||||
if (user == null || user.isActive()) {
|
||||
throw new InvalidActivationCodeException("Invalid Activation Code");
|
||||
} else {
|
||||
|
@ -76,7 +76,7 @@ public class UserServiceImpl
|
|||
@Override
|
||||
public RestResetPasswordResponse resetPassword(@NotNull String email)
|
||||
throws InvalidUserEmailException, InvalidAuthSchemaException {
|
||||
final User user = userManager.getUserBy(email);
|
||||
final Account user = userManager.getUserBy(email);
|
||||
if (user != null) {
|
||||
RestResetPasswordResponse response = new RestResetPasswordResponse();
|
||||
if (user.getAuthenticationType().equals(AuthenticationType.GOOGLE_OAUTH2)) {
|
||||
|
@ -121,14 +121,14 @@ public class UserServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeUser(@NotNull User user) {
|
||||
public void removeUser(@NotNull Account user) {
|
||||
// Force object reload before removing....
|
||||
final User userBy = userManager.getUserBy(user.getEmail());
|
||||
final Account userBy = userManager.getUserBy(user.getEmail());
|
||||
userManager.removeUser(userBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auditLogin(@NotNull User user) {
|
||||
public void auditLogin(@NotNull Account user) {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User can not be null");
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class UserServiceImpl
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public User createUser(@NotNull User user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException {
|
||||
public Account createUser(@NotNull Account user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
user.setCreationDate(Calendar.getInstance());
|
||||
user.setActivationCode(uuid.getLeastSignificantBits());
|
||||
|
@ -173,7 +173,7 @@ public class UserServiceImpl
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public User createAndAuthUserFromGoogle(@NotNull String callbackCode) throws WiseMappingException {
|
||||
public Account createAndAuthUserFromGoogle(@NotNull String callbackCode) throws WiseMappingException {
|
||||
GoogleAccountBasicData data;
|
||||
try {
|
||||
data = googleService.processCallback(callbackCode);
|
||||
|
@ -181,9 +181,9 @@ public class UserServiceImpl
|
|||
throw new OAuthAuthenticationException(e);
|
||||
}
|
||||
|
||||
User existingUser = userManager.getUserBy(data.getEmail());
|
||||
Account existingUser = userManager.getUserBy(data.getEmail());
|
||||
if (existingUser == null) {
|
||||
User newUser = new User();
|
||||
Account newUser = new Account();
|
||||
// new registrations from google starts sync
|
||||
newUser.setGoogleSync(true);
|
||||
newUser.setEmail(data.getEmail());
|
||||
|
@ -206,8 +206,8 @@ public class UserServiceImpl
|
|||
|
||||
}
|
||||
|
||||
public User confirmAccountSync(@NotNull String email, @NotNull String code) throws WiseMappingException {
|
||||
final User existingUser = userManager.getUserBy(email);
|
||||
public Account confirmAccountSync(@NotNull String email, @NotNull String code) throws WiseMappingException {
|
||||
final Account existingUser = userManager.getUserBy(email);
|
||||
// additional security check
|
||||
if (existingUser == null || !existingUser.getSyncCode().equals(code)) {
|
||||
throw new WiseMappingException("User not found / incorrect code");
|
||||
|
@ -244,24 +244,24 @@ public class UserServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changePassword(@NotNull User user) {
|
||||
public void changePassword(@NotNull Account user) {
|
||||
notificationService.passwordChanged(user);
|
||||
userManager.updateUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserBy(String email) {
|
||||
public Account getUserBy(String email) {
|
||||
return userManager.getUserBy(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public User getUserBy(int id) {
|
||||
public Account getUserBy(int id) {
|
||||
return userManager.getUserBy(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(@NotNull User user) {
|
||||
public void updateUser(@NotNull Account user) {
|
||||
userManager.updateUser(user);
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ public class UserServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public User getCasUserBy(String uid) {
|
||||
public Account getCasUserBy(String uid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package com.wisemapping.validator;
|
||||
|
||||
import com.wisemapping.model.Constants;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -37,12 +37,12 @@ public class LabelValidator implements Validator {
|
|||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return clazz.equals(Label.class);
|
||||
return clazz.equals(MindmapLabel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@Nullable final Object target, @NotNull final Errors errors) {
|
||||
final Label label = (Label) target;
|
||||
final MindmapLabel label = (MindmapLabel) target;
|
||||
if (label == null) {
|
||||
errors.rejectValue("map", "error.not-specified", null, "Value required.");
|
||||
} else {
|
||||
|
@ -51,7 +51,7 @@ public class LabelValidator implements Validator {
|
|||
}
|
||||
}
|
||||
|
||||
private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) {
|
||||
private void validateLabel(@NotNull final MindmapLabel label, @NotNull final Errors errors) {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED);
|
||||
final String title = label.getTitle();
|
||||
|
@ -63,9 +63,9 @@ public class LabelValidator implements Validator {
|
|||
title,
|
||||
Constants.MAX_LABEL_NAME_LENGTH);
|
||||
|
||||
final User user = com.wisemapping.security.Utils.getUser();
|
||||
final Account user = com.wisemapping.security.Utils.getUser();
|
||||
if (user != null && title != null) {
|
||||
final Label foundLabel = service.getLabelByTitle(title, user);
|
||||
final MindmapLabel foundLabel = service.getLabelByTitle(title, user);
|
||||
if (foundLabel != null) {
|
||||
errors.rejectValue("title", Messages.LABEL_TITLE_ALREADY_EXISTS);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.validator;
|
|||
|
||||
import com.wisemapping.model.Constants;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.view.MindMapInfoBean;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -72,7 +72,7 @@ public class MapInfoValidator implements Validator {
|
|||
} else {
|
||||
// Map already exists ?
|
||||
final MindmapService service = this.getMindmapService();
|
||||
final User user = com.wisemapping.security.Utils.getUser();
|
||||
final Account user = com.wisemapping.security.Utils.getUser();
|
||||
final Mindmap mindMap = service.getMindmapByTitle(title, user);
|
||||
if (mindMap != null) {
|
||||
errors.rejectValue("title", Messages.MAP_TITLE_ALREADY_EXISTS);
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.wisemapping.view;
|
|||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
|
||||
public class CollaboratorBean {
|
||||
private final CollaborationRole collaborationRole;
|
||||
|
@ -33,7 +33,7 @@ public class CollaboratorBean {
|
|||
this.isUser = false;
|
||||
}
|
||||
|
||||
public CollaboratorBean(User user, CollaborationRole role) {
|
||||
public CollaboratorBean(Account user, CollaborationRole role) {
|
||||
this.collaborator = user;
|
||||
this.collaborationRole = role;
|
||||
this.isUser = true;
|
||||
|
@ -48,7 +48,7 @@ public class CollaboratorBean {
|
|||
}
|
||||
|
||||
public String getUsername() {
|
||||
return isUser ? ((User) collaborator).getFullName() : collaborator.getEmail();
|
||||
return isUser ? ((Account) collaborator).getFullName() : collaborator.getEmail();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
|
|
|
@ -24,7 +24,6 @@ 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.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -79,7 +78,7 @@ public class MindMapBean {
|
|||
}
|
||||
|
||||
public String getLastEditor() {
|
||||
final User lastEditor = mindmap.getLastEditor();
|
||||
final Account lastEditor = mindmap.getLastEditor();
|
||||
return lastEditor != null ? lastEditor.getFullName() : "";
|
||||
}
|
||||
|
||||
|
@ -147,7 +146,7 @@ public class MindMapBean {
|
|||
return result;
|
||||
}
|
||||
|
||||
public User getCreator() {
|
||||
public Account getCreator() {
|
||||
return mindmap.getCreator();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
package com.wisemapping.view;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
|
||||
public class UserBean
|
||||
extends User {
|
||||
extends Account {
|
||||
private String retypePassword;
|
||||
private String captcha;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class UserBean
|
|||
|
||||
}
|
||||
|
||||
public UserBean(User model) {
|
||||
public UserBean(Account model) {
|
||||
this.setFirstname(model.getFirstname());
|
||||
this.setLastname(model.getLastname());
|
||||
this.setEmail(model.getEmail());
|
||||
|
|
|
@ -60,7 +60,7 @@ app:
|
|||
mail:
|
||||
serverSendEmail: root@localhost
|
||||
supportEmail: root@localhost
|
||||
|
||||
enabled: false
|
||||
#######################################################################################
|
||||
# Google OAuth Authentication
|
||||
#######################################################################################
|
||||
|
|
|
@ -1 +1 @@
|
|||
SET DATABASE SQL SYNTAX MYS TRUE;
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
||||
SET DATABASE SQL SYNTAX MYS TRUE;
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT IGNORE INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
INSERT IGNORE INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
|
@ -1 +1 @@
|
|||
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
INSERT IGNORE INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
INSERT IGNORE INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
|
@ -7,7 +7,7 @@ CREATE TABLE COLLABORATOR (
|
|||
CREATE TABLE "USER" (
|
||||
authentication_type TEXT NOT NULL,
|
||||
authenticator_uri VARCHAR(255),
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
collaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
|
@ -18,7 +18,7 @@ CREATE TABLE "USER" (
|
|||
google_sync BOOLEAN,
|
||||
sync_code VARCHAR(255),
|
||||
google_token VARCHAR(255),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE "LABEL" (
|
||||
|
@ -27,7 +27,7 @@ CREATE TABLE "LABEL" (
|
|||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES "USER" (colaborator_id)
|
||||
FOREIGN KEY (creator_id) REFERENCES "USER" (collaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
|
@ -40,7 +40,7 @@ CREATE TABLE MINDMAP (
|
|||
edition_date TIMESTAMP,
|
||||
creator_id INTEGER NOT NULL,
|
||||
last_editor_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(collaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
|
@ -69,11 +69,11 @@ CREATE TABLE COLLABORATION_PROPERTIES (
|
|||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
@ -82,5 +82,5 @@ CREATE TABLE ACCESS_AUDITORY (
|
|||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES "USER" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
FOREIGN KEY (user_id) REFERENCES "USER" (collaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
|
@ -5,10 +5,10 @@
|
|||
<cache name="com.wisemapping.model.Collaborator"
|
||||
maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600"
|
||||
timeToLiveSeconds="3600" overflowToDisk="false"/>
|
||||
<cache name="com.wisemapping.model.User"
|
||||
<cache name="com.wisemapping.model.Account"
|
||||
maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600"
|
||||
timeToLiveSeconds="3600" overflowToDisk="false"/>
|
||||
<cache name="com.wisemapping.model.Label"
|
||||
<cache name="com.wisemapping.model.MindmapLabel"
|
||||
maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600"
|
||||
timeToLiveSeconds="3600" overflowToDisk="false"/>
|
||||
</ehcache>
|
|
@ -1 +1 @@
|
|||
CREATE TABLE IF NOT EXISTS COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
email VARCHAR(255) NOT NULL UNIQUE,
creation_date DATE
);
CREATE TABLE IF NOT EXISTS USER (
colaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
activation_code BIGINT NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) NOT NULL,
locale VARCHAR(5),
google_sync BOOLEAN,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
);
CREATE TABLE IF NOT EXISTS MINDMAP (
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
xml LONGVARBINARY NOT NULL,
public BOOLEAN NOT NULL,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
);
CREATE TABLE IF NOT EXISTS LABEL (
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
title VARCHAR(30),
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
);
CREATE TABLE IF NOT EXISTS R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS MINDMAP_HISTORY (
id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
);
CREATE TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
id INTEGER NOT NULL IDENTITY,
starred BOOLEAN NOT NULL,
mindmap_properties VARCHAR(512)
);
CREATE TABLE IF NOT EXISTS COLLABORATION (
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
);
CREATE TABLE IF NOT EXISTS ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE,
lastname VARCHAR(255) NOT NULL,
firstname VARCHAR(255) NOT NULL,
laborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
|
||||
CREATE TABLE IF NOT EXISTS COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
email VARCHAR(255) NOT NULL UNIQUE,
creation_date DATE
);
CREATE TABLE IF NOT EXISTS ACCOUNT (
collaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
activation_code BIGINT NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) NOT NULL,
locale VARCHAR(5),
google_sync BOOLEAN,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id)
);
CREATE TABLE IF NOT EXISTS MINDMAP (
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
xml LONGVARBINARY NOT NULL,
public BOOLEAN NOT NULL,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL
--FOREIGN KEY(creator_id) REFERENCES ACCOUNT(collaborator_id)
);
CREATE TABLE IF NOT EXISTS MINDMAP_LABEL (
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
title VARCHAR(30),
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
--FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id)
);
CREATE TABLE IF NOT EXISTS R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES MINDMAP_LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS MINDMAP_HISTORY (
id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
);
CREATE TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
id INTEGER NOT NULL IDENTITY,
starred BOOLEAN NOT NULL,
mindmap_properties VARCHAR(512)
);
CREATE TABLE IF NOT EXISTS COLLABORATION (
id INTEGER NOT NULL IDENTITY,
collaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
);
CREATE TABLE IF NOT EXISTS ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE,
password VARCHAR(255) NOT NULL,
firstname VARCHAR(255) NOT NULL,
laborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
|
|
@ -5,8 +5,8 @@ CREATE TABLE IF NOT EXISTS COLLABORATOR (
|
|||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS USER (
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
CREATE TABLE IF NOT EXISTS ACCOUNT (
|
||||
collaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET UTF8MB4 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS USER (
|
|||
google_sync BOOL,
|
||||
sync_code VARCHAR(255),
|
||||
google_token VARCHAR(255),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
) CHARACTER SET UTF8MB4;
|
||||
|
@ -38,21 +38,21 @@ CREATE TABLE IF NOT EXISTS MINDMAP (
|
|||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS LABEL (
|
||||
CREATE TABLE IF NOT EXISTS MINDMAP_LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET UTF8MB4 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES MINDMAP_LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ CREATE TABLE IF NOT EXISTS R_LABEL_MINDMAP (
|
|||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
FOREIGN KEY (label_id) REFERENCES MINDMAP_LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
|
@ -91,12 +91,12 @@ CREATE TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
|
|||
|
||||
CREATE TABLE IF NOT EXISTS COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
UNIQUE KEY UC_ROLE (mindmap_id,colaborator_id),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
UNIQUE KEY UC_ROLE (mindmap_id,collaborator_id),
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
|
@ -110,7 +110,7 @@ CREATE TABLE IF NOT EXISTS ACCESS_AUDITORY (
|
|||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
FOREIGN KEY (user_id) REFERENCES ACCOUNT (collaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.wisemapping.test.rest;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wisemapping.config.common.CommonConfig;
|
||||
import com.wisemapping.config.rest.RestAppConfig;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.UserController;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.rest.model.RestUserRegistration;
|
||||
|
@ -74,7 +74,7 @@ public class RestUserControllerTest {
|
|||
.andExpect(status().isCreated());
|
||||
|
||||
// Check dao ...
|
||||
User userBy = userService.getUserBy(result.getEmail());
|
||||
Account userBy = userService.getUserBy(result.getEmail());
|
||||
assertNotNull(userBy);
|
||||
return result;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class RestUserControllerTest {
|
|||
.andExpect(status().isCreated());
|
||||
|
||||
// Check dao ...
|
||||
User userBy = userService.getUserBy(user.getEmail());
|
||||
Account userBy = userService.getUserBy(user.getEmail());
|
||||
assertNotNull(userBy);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue