mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-24 23:17:56 +01:00
solving merge conflict
This commit is contained in:
commit
29acc46d34
@ -6,6 +6,22 @@ INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemappin
|
|||||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURDATE(), 1,'D');
|
VALUES (2, 'Admin', 'User', 'admin', 1237, CURDATE(), 1,'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURDATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURDATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURDATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURDATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURDATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURDATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURDATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURDATE(), 1, 'D');
|
||||||
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SHUTDOWN;
|
SHUTDOWN;
|
@ -5,8 +5,7 @@ CREATE TABLE COLLABORATOR (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE USER (
|
CREATE TABLE USER (
|
||||||
id INTEGER NOT NULL IDENTITY,
|
colaborator_id INTEGER NOT NULL IDENTITY,
|
||||||
colaborator_id INTEGER NOT NULL,
|
|
||||||
authentication_type CHAR(1) NOT NULL,
|
authentication_type CHAR(1) NOT NULL,
|
||||||
authenticator_uri VARCHAR(255) NULL,
|
authenticator_uri VARCHAR(255) NULL,
|
||||||
firstname VARCHAR(255) NOT NULL,
|
firstname VARCHAR(255) NOT NULL,
|
||||||
@ -87,7 +86,10 @@ CREATE TABLE TAG (
|
|||||||
CREATE TABLE ACCESS_AUDITORY (
|
CREATE TABLE ACCESS_AUDITORY (
|
||||||
id INTEGER NOT NULL IDENTITY,
|
id INTEGER NOT NULL IDENTITY,
|
||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
login_date DATE
|
login_date DATE,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -10,5 +10,20 @@ INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemappin
|
|||||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURRENT_DATE(), 1,'D');
|
VALUES (2, 'Admin', 'User', 'admin', 1237, CURRENT_DATE(), 1,'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURRENT_DATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURRENT_DATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURRENT_DATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURRENT_DATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURRENT_DATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURRENT_DATE(), 1, 'D');
|
||||||
|
|
||||||
|
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURRENT_DATE());
|
||||||
|
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||||
|
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURRENT_DATE(), 1, 'D');
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -13,8 +13,7 @@ CREATE TABLE COLLABORATOR (
|
|||||||
CHARACTER SET utf8;
|
CHARACTER SET utf8;
|
||||||
|
|
||||||
CREATE TABLE USER (
|
CREATE TABLE USER (
|
||||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||||
colaborator_id INTEGER NOT NULL,
|
|
||||||
authentication_type CHAR(1)
|
authentication_type CHAR(1)
|
||||||
CHARACTER SET utf8 NOT NULL,
|
CHARACTER SET utf8 NOT NULL,
|
||||||
authenticator_uri VARCHAR(255)
|
authenticator_uri VARCHAR(255)
|
||||||
@ -127,7 +126,10 @@ CREATE TABLE TAG (
|
|||||||
CREATE TABLE ACCESS_AUDITORY (
|
CREATE TABLE ACCESS_AUDITORY (
|
||||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
login_date DATE,
|
login_date DATE,
|
||||||
user_id INTEGER NOT NULL
|
user_id INTEGER NOT NULL,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE NO ACTION
|
||||||
)
|
)
|
||||||
CHARACTER SET utf8;
|
CHARACTER SET utf8;
|
||||||
|
|
||||||
|
7
config/database/mysql/v3.0-to-v3.2.sql
Normal file
7
config/database/mysql/v3.0-to-v3.2.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE `USER` DROP COLUMN `id`;
|
||||||
|
|
||||||
|
ALTER TABLE `ACCESS_AUDITORY`
|
||||||
|
ADD CONSTRAINT
|
||||||
|
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE NO ACTION;
|
@ -5,10 +5,9 @@ CREATE TABLE COLLABORATOR (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "user" (
|
CREATE TABLE "user" (
|
||||||
id SERIAL NOT NULL PRIMARY KEY,
|
|
||||||
authentication_type TEXT NOT NULL,
|
authentication_type TEXT NOT NULL,
|
||||||
authenticator_uri VARCHAR(255),
|
authenticator_uri VARCHAR(255),
|
||||||
colaborator_id INTEGER NOT NULL,
|
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||||
firstname VARCHAR(255) NOT NULL,
|
firstname VARCHAR(255) NOT NULL,
|
||||||
lastname VARCHAR(255) NOT NULL,
|
lastname VARCHAR(255) NOT NULL,
|
||||||
password VARCHAR(255) NOT NULL,
|
password VARCHAR(255) NOT NULL,
|
||||||
@ -89,7 +88,8 @@ CREATE TABLE TAG (
|
|||||||
CREATE TABLE ACCESS_AUDITORY (
|
CREATE TABLE ACCESS_AUDITORY (
|
||||||
id SERIAL NOT NULL PRIMARY KEY,
|
id SERIAL NOT NULL PRIMARY KEY,
|
||||||
login_date DATE,
|
login_date DATE,
|
||||||
user_id INTEGER NOT NULL
|
user_id INTEGER NOT NULL,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES "user" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,6 @@ public interface UserManager {
|
|||||||
|
|
||||||
public User createUser(User user, Collaborator col);
|
public User createUser(User user, Collaborator col);
|
||||||
|
|
||||||
public void deleteUser(User user);
|
public void removeUser(@NotNull User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,11 +110,8 @@ public class UserManagerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser(@NotNull User user) {
|
public void removeUser(@NotNull final User user) {
|
||||||
final Collaborator collaborator = this.getCollaboratorBy(user.getEmail());
|
|
||||||
getHibernateTemplate().delete(collaborator);
|
|
||||||
getHibernateTemplate().delete(user);
|
getHibernateTemplate().delete(user);
|
||||||
getHibernateTemplate().flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.mangofactory.swagger.annotations.ApiIgnore;
|
import com.mangofactory.swagger.annotations.ApiIgnore;
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.mail.NotificationService;
|
import com.wisemapping.mail.NotificationService;
|
||||||
|
import com.wisemapping.model.Collaboration;
|
||||||
import com.wisemapping.model.Mindmap;
|
import com.wisemapping.model.Mindmap;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.rest.model.RestLogItem;
|
import com.wisemapping.rest.model.RestLogItem;
|
||||||
@ -39,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Api(value="UserApi",description = "Account Account Related Objects.")
|
@Api(value="UserApi",description = "Account Account Related Objects.")
|
||||||
@Controller
|
@Controller
|
||||||
@ -76,7 +79,7 @@ public class AccountController extends BaseController {
|
|||||||
throw new IllegalArgumentException("Firstname can not be null");
|
throw new IllegalArgumentException("Firstname can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser(true);
|
||||||
user.setFirstname(firstname);
|
user.setFirstname(firstname);
|
||||||
userService.updateUser(user);
|
userService.updateUser(user);
|
||||||
}
|
}
|
||||||
@ -88,7 +91,7 @@ public class AccountController extends BaseController {
|
|||||||
throw new IllegalArgumentException("lastname can not be null");
|
throw new IllegalArgumentException("lastname can not be null");
|
||||||
|
|
||||||
}
|
}
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser(true);
|
||||||
user.setLastname(lastname);
|
user.setLastname(lastname);
|
||||||
userService.updateUser(user);
|
userService.updateUser(user);
|
||||||
}
|
}
|
||||||
@ -106,6 +109,21 @@ public class AccountController extends BaseController {
|
|||||||
userService.updateUser(user);
|
userService.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = "account")
|
||||||
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
|
public void deleteUser() throws WiseMappingException
|
||||||
|
|
||||||
|
{
|
||||||
|
final User user = Utils.getUser(true);
|
||||||
|
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||||
|
for (Collaboration collaboration : collaborations) {
|
||||||
|
final Mindmap mindmap = collaboration.getMindMap();
|
||||||
|
mindmapService.removeMindmap(mindmap,user);
|
||||||
|
}
|
||||||
|
userService.removeUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
@RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.mangofactory.swagger.annotations.ApiModel;
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.AuthenticationType;
|
import com.wisemapping.model.AuthenticationType;
|
||||||
import com.wisemapping.model.Collaboration;
|
import com.wisemapping.model.Collaboration;
|
||||||
@ -56,6 +55,7 @@ public class AdminController extends BaseController {
|
|||||||
@Qualifier("userService")
|
@Qualifier("userService")
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Qualifier("mindmapService")
|
@Qualifier("mindmapService")
|
||||||
@Autowired
|
@Autowired
|
||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
@ -133,12 +133,19 @@ public class AdminController extends BaseController {
|
|||||||
@ApiOperation("Note: Administration permissions required.")
|
@ApiOperation("Note: Administration permissions required.")
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
|
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
public void getUserByEmail(@PathVariable @ApiParam(required = true, allowableValues = "range[1," + Long.MAX_VALUE + "]") long id) throws WiseMappingException {
|
public void deleteUserByEmail(@PathVariable long id) throws WiseMappingException {
|
||||||
final User user = userService.getUserBy(id);
|
final User user = userService.getUserBy(id);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||||
}
|
}
|
||||||
userService.deleteUser(user);
|
|
||||||
|
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||||
|
for (Collaboration collaboration : collaborations) {
|
||||||
|
final Mindmap mindmap = collaboration.getMindMap();
|
||||||
|
mindmapService.removeMindmap(mindmap,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
userService.removeUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("Note: Administration permissions required.")
|
@ApiOperation("Note: Administration permissions required.")
|
||||||
|
@ -21,12 +21,9 @@ package com.wisemapping.security;
|
|||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
final public class Utils {
|
final public class Utils {
|
||||||
private Utils() {
|
private Utils() {
|
||||||
}
|
}
|
||||||
@ -37,7 +34,7 @@ final public class Utils {
|
|||||||
return getUser(false);
|
return getUser(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@NotNull
|
||||||
public static User getUser(boolean forceCheck) {
|
public static User getUser(boolean forceCheck) {
|
||||||
User result = null;
|
User result = null;
|
||||||
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
@ -46,8 +46,6 @@ public interface MindmapService {
|
|||||||
|
|
||||||
void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
||||||
|
|
||||||
void addTags(@NotNull Mindmap mindmap, String tags);
|
|
||||||
|
|
||||||
void removeMindmap(@NotNull final Mindmap mindmap, @NotNull final User user) throws WiseMappingException;
|
void removeMindmap(@NotNull final Mindmap mindmap, @NotNull final User user) throws WiseMappingException;
|
||||||
|
|
||||||
List<Mindmap> search(MindMapCriteria criteria);
|
List<Mindmap> search(MindMapCriteria criteria);
|
||||||
|
@ -243,28 +243,6 @@ public class MindmapServiceImpl
|
|||||||
return collaborator;
|
return collaborator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTags(@NotNull Mindmap mindmap, String tags) {
|
|
||||||
mindmap.setTags(tags);
|
|
||||||
mindmapManager.updateMindmap(mindmap, false);
|
|
||||||
if (tags != null && tags.length() > 0) {
|
|
||||||
final String tag[] = tags.split(TAG_SEPARATOR);
|
|
||||||
final User user = mindmap.getCreator();
|
|
||||||
// Add new Tags to User
|
|
||||||
boolean updateUser = false;
|
|
||||||
for (String userTag : tag) {
|
|
||||||
if (!user.getTags().contains(userTag)) {
|
|
||||||
user.getTags().add(userTag);
|
|
||||||
updateUser = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (updateUser) {
|
|
||||||
//update user
|
|
||||||
userService.updateUser(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
|
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
|
||||||
|
@ -38,7 +38,7 @@ public interface UserService {
|
|||||||
|
|
||||||
public void resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
|
public void resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
|
||||||
|
|
||||||
public void deleteUser(@NotNull User user);
|
public void removeUser(@NotNull User user);
|
||||||
|
|
||||||
public void auditLogin(@NotNull User user);
|
public void auditLogin(@NotNull User user);
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@ package com.wisemapping.service;
|
|||||||
import com.wisemapping.dao.UserManager;
|
import com.wisemapping.dao.UserManager;
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.mail.NotificationService;
|
import com.wisemapping.mail.NotificationService;
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.AccessAuditory;
|
||||||
|
import com.wisemapping.model.AuthenticationType;
|
||||||
|
import com.wisemapping.model.Collaborator;
|
||||||
|
import com.wisemapping.model.Mindmap;
|
||||||
|
import com.wisemapping.model.User;
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -29,8 +33,11 @@ import org.springframework.context.MessageSource;
|
|||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.ui.velocity.VelocityEngineUtils;
|
import org.springframework.ui.velocity.VelocityEngineUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.Calendar;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserServiceImpl
|
public class UserServiceImpl
|
||||||
implements UserService {
|
implements UserService {
|
||||||
@ -95,8 +102,10 @@ public class UserServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser(@NotNull User user) {
|
public void removeUser(@NotNull User user) {
|
||||||
userManager.deleteUser(user);
|
// Force object reload before removing....
|
||||||
|
final User userBy = userManager.getUserBy(user.getEmail());
|
||||||
|
userManager.removeUser(userBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,7 @@ LOGOUT=Logout
|
|||||||
PASSWORD=Password
|
PASSWORD=Password
|
||||||
NEW_PASSWORD=New password
|
NEW_PASSWORD=New password
|
||||||
CONFIRM_NEW_PASSWORD=Confirm new password
|
CONFIRM_NEW_PASSWORD=Confirm new password
|
||||||
|
DELETE__ACCOUNT=Delete My Account
|
||||||
MY_WISEMAPS=My Wisemaps
|
MY_WISEMAPS=My Wisemaps
|
||||||
RETYPE_PASSWORD=Retype Password
|
RETYPE_PASSWORD=Retype Password
|
||||||
REGISTER=Register
|
REGISTER=Register
|
||||||
@ -31,6 +32,7 @@ YOUR_ROLE=Your Role
|
|||||||
FORGOT_PASSWORD=Forgot Password ?
|
FORGOT_PASSWORD=Forgot Password ?
|
||||||
CHANGE_PASSWORD=Change Password
|
CHANGE_PASSWORD=Change Password
|
||||||
CHANGE_LANGUAGE=Change Language
|
CHANGE_LANGUAGE=Change Language
|
||||||
|
WARNING_DELETE_USER=If you do not think you will use WiseMapping again and would like your account deleted, we can take care of this for you. Keep in mind that you will not be able retrieve any mindmap you have added. <br/><br/> If you would still like your account deleted, click "Delete My Account".
|
||||||
FAQ=Frequent Asked Questions
|
FAQ=Frequent Asked Questions
|
||||||
SHORT_FAQ=FAQ
|
SHORT_FAQ=FAQ
|
||||||
LOGIN=Login
|
LOGIN=Login
|
||||||
@ -72,7 +74,6 @@ SHARED=Shared
|
|||||||
ONLY_VIEW_PRIVATE = This mindmap can be viewed by you only.
|
ONLY_VIEW_PRIVATE = This mindmap can be viewed by you only.
|
||||||
ALL_VIEW_PUBLIC = This mindmap can be viewed by any user.
|
ALL_VIEW_PUBLIC = This mindmap can be viewed by any user.
|
||||||
NEW_MAP_MSG=Create a new map
|
NEW_MAP_MSG=Create a new map
|
||||||
NEW_LABEL_MSG=Create a new label
|
|
||||||
PUBLISH=Publish
|
PUBLISH=Publish
|
||||||
PUBLISH_DETAILS=By publishing the map you make it visible to everyone on the Internet.
|
PUBLISH_DETAILS=By publishing the map you make it visible to everyone on the Internet.
|
||||||
ACCOUNT_DETAIL=Do you want to change you user options?. Here is the place.
|
ACCOUNT_DETAIL=Do you want to change you user options?. Here is the place.
|
||||||
@ -98,7 +99,7 @@ HISTORY=History
|
|||||||
SHARE=Share
|
SHARE=Share
|
||||||
UNEXPECTED_ERROR=Outch!!. An unexpected error has occurred.
|
UNEXPECTED_ERROR=Outch!!. An unexpected error has occurred.
|
||||||
UNEXPECTED_ERROR_DETAILS=We're sorry, an error has occurred and we can't process your request. Please try again, or go to the home page.
|
UNEXPECTED_ERROR_DETAILS=We're sorry, an error has occurred and we can't process your request. Please try again, or go to the home page.
|
||||||
UNEXPECTED_ERROR_SERVER_ERROR=We're sorry, an error has occurred and we can't process your request. Refresh the page and try again. If the problem persist, click below on "Raise a Issue" to report a ticket.
|
UNEXPECTED_ERROR_SERVER_ERROR=We're sorry, an error has occurred and we can't process your request. Refresh the page and try again. If the problem persist, click below on "Raise An Issue" to open a ticket.
|
||||||
NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore.
|
NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore.
|
||||||
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
|
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
|
||||||
IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 and WiseMapping maps to your list of maps. Select the file you want to import.
|
IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 and WiseMapping maps to your list of maps. Select the file you want to import.
|
||||||
@ -136,25 +137,17 @@ LANGUAGE=Language
|
|||||||
FILTERS=Filter
|
FILTERS=Filter
|
||||||
MORE=More
|
MORE=More
|
||||||
ADD_NEW_MAP=Add New Map
|
ADD_NEW_MAP=Add New Map
|
||||||
ADD_NEW_LABEL=Add New Label
|
|
||||||
LABEL=Label
|
|
||||||
IMPORTING=Importing ...
|
IMPORTING=Importing ...
|
||||||
NEW=New
|
NEW=New
|
||||||
MIND_FILE=File
|
MIND_FILE=File
|
||||||
PARENT_LABEL=Nest label under
|
|
||||||
COLOR=Color
|
|
||||||
CHOOSE_LABEL=Choose a label
|
|
||||||
SELECT_LABEL=Please select a label
|
|
||||||
NO_SEARCH_RESULT=No mindmap available for the selected filter criteria
|
NO_SEARCH_RESULT=No mindmap available for the selected filter criteria
|
||||||
SEARCH=Search
|
SEARCH=Search
|
||||||
GENERAL=General
|
GENERAL=General
|
||||||
SECURITY=Security
|
SECURITY=Security
|
||||||
MAP_NAME_HINT=Name of the new map to create
|
MAP_NAME_HINT=Name of the new map to create
|
||||||
LABEL_NAME_HINT=Name of the new label to create
|
|
||||||
MAP_DESCRIPTION_HINT=Some description for your map
|
MAP_DESCRIPTION_HINT=Some description for your map
|
||||||
WARNING=Warning
|
WARNING=Warning
|
||||||
DELETE_MAPS_WARNING=Deleted mindmap can not be recovered. Do you want to continue ?.
|
DELETE_MAPS_WARNING=Deleted mindmap can not be recovered. Do you want to continue ?.
|
||||||
DELETE_LABELS_WARNING=All labelled mindmaps will be untagged. Do you want to continue ?.
|
|
||||||
THANKS_FOR_SIGN_UP=Thanks for signing up\!
|
THANKS_FOR_SIGN_UP=Thanks for signing up\!
|
||||||
SIGN_UP_CONFIRMATION_EMAIL=\ You will receive a confirmation message shortly from WiseMapping. This message will ask you to activate your WiseMapping account.</br>Please select the link to activate and start creating and sharing maps.
|
SIGN_UP_CONFIRMATION_EMAIL=\ You will receive a confirmation message shortly from WiseMapping. This message will ask you to activate your WiseMapping account.</br>Please select the link to activate and start creating and sharing maps.
|
||||||
SIGN_UP_SUCCESS=Your account has been created successfully, click <a href\="c/login">here</a> to sign in and start enjoying WiseMapping.
|
SIGN_UP_SUCCESS=Your account has been created successfully, click <a href\="c/login">here</a> to sign in and start enjoying WiseMapping.
|
||||||
@ -254,7 +247,6 @@ CONTACT_US=Contact Us
|
|||||||
CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Google ReCaptcha service.
|
CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Google ReCaptcha service.
|
||||||
ACCESS_HAS_BEEN_REVOKED= Upps. your access permissions to this map has been revoked. Contact map owner.
|
ACCESS_HAS_BEEN_REVOKED= Upps. your access permissions to this map has been revoked. Contact map owner.
|
||||||
MAP_CAN_NOT_BE_FOUND= Upps. The map can not be found. It must have been deleted.
|
MAP_CAN_NOT_BE_FOUND= Upps. The map can not be found. It must have been deleted.
|
||||||
LABEL_CAN_NOT_BE_FOUND= Upps. The label can not be found. It must have been deleted.
|
|
||||||
LICENSE=License
|
LICENSE=License
|
||||||
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
||||||
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>.
|
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>.
|
||||||
|
@ -120,6 +120,7 @@ SAVING=Grabando ...
|
|||||||
PUBLIC_MAPS=Mapas Publicos
|
PUBLIC_MAPS=Mapas Publicos
|
||||||
MY_MAPS=Mis Mapas
|
MY_MAPS=Mis Mapas
|
||||||
NEW_PASSWORD=Nueva Contraseña
|
NEW_PASSWORD=Nueva Contraseña
|
||||||
|
DELETE__ACCOUNT=Eliminar cuenta
|
||||||
LANGUAGE=Idioma
|
LANGUAGE=Idioma
|
||||||
SHARED_WITH_ME=Compartidos
|
SHARED_WITH_ME=Compartidos
|
||||||
ACCEPT=Aceptar
|
ACCEPT=Aceptar
|
||||||
|
@ -91,55 +91,68 @@ jQuery.fn.dialogForm = function (options) {
|
|||||||
formData[elem.name] = elem.value;
|
formData[elem.name] = elem.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Success actions ...
|
||||||
|
var onSuccess = function (jqXHR, textStatus, data) {
|
||||||
|
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||||
|
if (options.redirect) {
|
||||||
|
var redirectUrl = options.redirect;
|
||||||
|
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
||||||
|
|
||||||
|
// Hack: IE ignore the base href tag ...
|
||||||
|
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
|
||||||
|
window.open(baseUrl + redirectUrl, '_self');
|
||||||
|
|
||||||
|
} else if (options.postUpdate) {
|
||||||
|
options.postUpdate(formData, resourceId);
|
||||||
|
}
|
||||||
|
dialogElem.modal('hide');
|
||||||
|
};
|
||||||
|
|
||||||
|
// On error message
|
||||||
|
var onFailure = function (jqXHR, textStatus, data) {
|
||||||
|
var errors = JSON.parse(jqXHR.responseText);
|
||||||
|
// Mark fields with errors ...
|
||||||
|
var fieldErrors = errors.fieldErrors;
|
||||||
|
if (fieldErrors) {
|
||||||
|
for (var fieldName in fieldErrors) {
|
||||||
|
// Mark the field with errors ...
|
||||||
|
var message = fieldErrors[fieldName];
|
||||||
|
var inputField = $("#" + containerId + " input[name='" + fieldName + "']");
|
||||||
|
|
||||||
|
$("#" + containerId).find(".errorMessage").text(message).addClass("alert alert-error");
|
||||||
|
inputField.parent().addClass('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
|
acceptBtn.button('reset');
|
||||||
|
};
|
||||||
|
|
||||||
|
var onError = function (jqXHR, textStatus, errorThrown) {
|
||||||
|
console.log(errorThrown);
|
||||||
|
console.log(jqXHR);
|
||||||
|
dialogElem.modal('hide');
|
||||||
|
$('#messagesPanel div div').text(errorThrown);
|
||||||
|
$('#messagesPanel').show()
|
||||||
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
|
acceptBtn.button('reset');
|
||||||
|
};
|
||||||
|
|
||||||
$(acceptBtn).button('loading');
|
$(acceptBtn).button('loading');
|
||||||
var dialogElem = this;
|
var dialogElem = this;
|
||||||
jQuery.ajax(url, {
|
jQuery.ajax(url, {
|
||||||
async:false,
|
async: false,
|
||||||
//dataType:'json', comentado momentaneamente, problema con jquery 2.1.0
|
dataType: 'json',
|
||||||
data:JSON.stringify(formData),
|
data: JSON.stringify(formData),
|
||||||
type:options.type ? options.type : 'POST',
|
type: options.type ? options.type : 'POST',
|
||||||
contentType:"application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
success:function (data, textStatus, jqXHR) {
|
statusCode: {
|
||||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
200: onSuccess,
|
||||||
if (options.redirect) {
|
201: onSuccess,
|
||||||
var redirectUrl = options.redirect;
|
204: onSuccess,
|
||||||
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
400: onFailure,
|
||||||
|
444: onError,
|
||||||
// Hack: IE ignore the base href tag ...
|
500: onError,
|
||||||
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
|
501: onError
|
||||||
window.open(baseUrl + redirectUrl, '_self');
|
|
||||||
|
|
||||||
} else if (options.postUpdate) {
|
|
||||||
options.postUpdate(formData, resourceId);
|
|
||||||
}
|
|
||||||
dialogElem.modal('hide');
|
|
||||||
},
|
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
|
||||||
if (jqXHR.status == 400) {
|
|
||||||
var errors = JSON.parse(jqXHR.responseText);
|
|
||||||
// Mark fields with errors ...
|
|
||||||
var fieldErrors = errors.fieldErrors;
|
|
||||||
if (fieldErrors) {
|
|
||||||
for (var fieldName in fieldErrors) {
|
|
||||||
// Mark the field with errors ...
|
|
||||||
var message = fieldErrors[fieldName];
|
|
||||||
var inputField = $("#" + containerId + " input[name='" + fieldName + "']");
|
|
||||||
|
|
||||||
$("#" + containerId).find(".errorMessage").text(message).addClass("alert alert-error");
|
|
||||||
inputField.parent().addClass('error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log(errorThrown);
|
|
||||||
console.log(jqXHR);
|
|
||||||
dialogElem.modal('hide');
|
|
||||||
$('#messagesPanel div div').text(errorThrown);
|
|
||||||
$('#messagesPanel').show()
|
|
||||||
}
|
|
||||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
|
||||||
acceptBtn.button('reset');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -205,12 +218,12 @@ function updateStarred(spanElem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jQuery.ajax("c/restful/maps/" + mapId + "/starred", {
|
jQuery.ajax("c/restful/maps/" + mapId + "/starred", {
|
||||||
async:false,
|
async: false,
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:"" + starred,
|
data: "" + starred,
|
||||||
type:'PUT',
|
type: 'PUT',
|
||||||
contentType:"text/plain",
|
contentType: "text/plain",
|
||||||
success:function () {
|
success: function () {
|
||||||
if (starred) {
|
if (starred) {
|
||||||
$(spanElem).removeClass('starredOff');
|
$(spanElem).removeClass('starredOff');
|
||||||
$(spanElem).addClass('starredOn');
|
$(spanElem).addClass('starredOn');
|
||||||
@ -219,7 +232,7 @@ function updateStarred(spanElem) {
|
|||||||
$(spanElem).addClass('starredOff');
|
$(spanElem).addClass('starredOff');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -248,8 +261,8 @@ $(function () {
|
|||||||
$("#newBtn").click(
|
$("#newBtn").click(
|
||||||
function () {
|
function () {
|
||||||
$("#new-dialog-modal").dialogForm({
|
$("#new-dialog-modal").dialogForm({
|
||||||
redirect:"c/maps/{header.resourceId}/edit",
|
redirect: "c/maps/{header.resourceId}/edit",
|
||||||
url:"c/restful/maps"
|
url: "c/restful/maps"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -308,8 +321,8 @@ $(function () {
|
|||||||
|
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#duplicate-dialog-modal").dialogForm({
|
$("#duplicate-dialog-modal").dialogForm({
|
||||||
redirect:"c/maps/{header.resourceId}/edit",
|
redirect: "c/maps/{header.resourceId}/edit",
|
||||||
url:"c/restful/maps/" + mapId
|
url: "c/restful/maps/" + mapId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -334,16 +347,16 @@ $(function () {
|
|||||||
|
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#rename-dialog-modal").dialogForm({
|
$("#rename-dialog-modal").dialogForm({
|
||||||
type:'PUT',
|
type: 'PUT',
|
||||||
clearForm:false,
|
clearForm: false,
|
||||||
postUpdate:function (reqBodyData) {
|
postUpdate: function (reqBodyData) {
|
||||||
tableElem.dataTableExt.removeSelectedRows();
|
tableElem.dataTableExt.removeSelectedRows();
|
||||||
|
|
||||||
rowData.title = reqBodyData.title;
|
rowData.title = reqBodyData.title;
|
||||||
rowData.description = reqBodyData.description;
|
rowData.description = reqBodyData.description;
|
||||||
dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
|
dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
|
||||||
},
|
},
|
||||||
url:"c/restful/maps/" + mapId
|
url: "c/restful/maps/" + mapId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -356,12 +369,12 @@ $(function () {
|
|||||||
if (mapIds.length > 0) {
|
if (mapIds.length > 0) {
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#delete-dialog-modal").dialogForm({
|
$("#delete-dialog-modal").dialogForm({
|
||||||
type:'DELETE',
|
type: 'DELETE',
|
||||||
postUpdate:function () {
|
postUpdate: function () {
|
||||||
// Remove old entry ...
|
// Remove old entry ...
|
||||||
tableUI.dataTableExt.removeSelectedRows();
|
tableUI.dataTableExt.removeSelectedRows();
|
||||||
},
|
},
|
||||||
url:"c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
|
url: "c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<li><a href="#changePasswordPanel" data-toggle="pill"><spring:message code="SECURITY"/></a></li>
|
<li><a href="#changePasswordPanel" data-toggle="pill"><spring:message code="SECURITY"/></a></li>
|
||||||
</c:if>
|
</c:if>
|
||||||
<li><a href="#languagePanel" data-toggle="pill"><spring:message code="LANGUAGE"/></a></li>
|
<li><a href="#languagePanel" data-toggle="pill"><spring:message code="LANGUAGE"/></a></li>
|
||||||
|
<li><a href="#deleteAccountPanel" data-toggle="pill"><spring:message code="DELETE__ACCOUNT"/></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
@ -88,6 +89,16 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane fade" id="deleteAccountPanel">
|
||||||
|
<div id="deleteAccountMsg" class="alert alert-error" style="display: block;"><spring:message code="WARNING_DELETE_USER"/></div>
|
||||||
|
<form action="#" method="POST" id="deleteAccountForm">
|
||||||
|
<fieldset>
|
||||||
|
<input type="checkbox" name="confirmAccountDelete" id="accountMarkedForDelete" required="required"/>
|
||||||
|
<input type="submit" id="deleteAccountBtn" class="btn btn-primary"
|
||||||
|
value="<spring:message code="DELETE__ACCOUNT"/>"/>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -96,52 +107,115 @@
|
|||||||
$('#changeInfoMsg').hide();
|
$('#changeInfoMsg').hide();
|
||||||
$('#languageMsg').hide();
|
$('#languageMsg').hide();
|
||||||
|
|
||||||
function postChange(url, postBody, msgContainerId, successMsg) {
|
function postChange(url, postBody, onSuccess, onError, type) {
|
||||||
// Change success message ...
|
// Change success message ...
|
||||||
jQuery.ajax(url, {
|
jQuery.ajax(url, {
|
||||||
async: false,
|
async: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: postBody,
|
data: postBody,
|
||||||
type: 'PUT',
|
type: type ? type : 'PUT',
|
||||||
contentType: "text/plain; charset=utf-8",
|
contentType: "text/plain; charset=utf-8",
|
||||||
success: function (data, textStatus, jqXHR) {
|
success: function (data, textStatus, jqXHR) {
|
||||||
$('#' + msgContainerId).removeClass('alert-error').addClass('alert-info').show();
|
onSuccess()
|
||||||
$('#' + msgContainerId).text(successMsg);
|
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
$('#' + msgContainerId).removeClass('alert-info').addClass('alert-error').show();
|
onError(textStatus)
|
||||||
$('#' + msgContainerId).text(textStatus);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#changePasswordForm').submit(function (event) {
|
$('#changePasswordForm').submit(function (event) {
|
||||||
|
|
||||||
var inputVal = $('#changePasswordForm #password').val();
|
var inputVal = $('#changePasswordForm #password').val();
|
||||||
var rinputVal = $('#changePasswordForm #repassword').val();
|
var rinputVal = $('#changePasswordForm #repassword').val();
|
||||||
|
var changePasswordMsg = $('#changePasswordMsg');
|
||||||
if (inputVal != rinputVal) {
|
if (inputVal != rinputVal) {
|
||||||
// Password mismatch message ...
|
// Password mismatch message ...
|
||||||
$('#changePasswordMsg').removeClass('alert-info').addClass('alert-error').show();
|
changePasswordMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
$('#changePasswordMsg').text('<spring:message code="PASSWORD_MISSMATCH"/>');
|
changePasswordMsg.text('<spring:message code="PASSWORD_MISSMATCH"/>');
|
||||||
} else {
|
} else {
|
||||||
postChange("c/restful/account/password", inputVal, 'changePasswordMsg', "<spring:message code="CHANGE_PASSWORD_SUCCESS"/>");
|
postChange(
|
||||||
|
"c/restful/account/password",
|
||||||
|
inputVal,
|
||||||
|
function() {
|
||||||
|
changePasswordMsg.removeClass('alert-error').addClass('alert-info').show();
|
||||||
|
changePasswordMsg.text('<spring:message code="CHANGE_PASSWORD_SUCCESS"/>');
|
||||||
|
},
|
||||||
|
function(textStatus) {
|
||||||
|
changePasswordMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
|
changePasswordMsg.text(textStatus);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#changeUserForm').submit(function (event) {
|
$('#changeUserForm').submit(function (event) {
|
||||||
|
var firstname = $('#changeUserForm #firstname').val();
|
||||||
var fistname = $('#changeUserForm #firstname').val();
|
|
||||||
var lastname = $('#changeUserForm #lastname').val();
|
var lastname = $('#changeUserForm #lastname').val();
|
||||||
postChange("c/restful/account/firstname", fistname, 'changeInfoMsg', "<spring:message code="INFO_UPDATE_SUCCESS"/>");
|
var changeInfoMsg = $('#changeInfoMsg');
|
||||||
postChange("c/restful/account/lastname", lastname, 'changeInfoMsg', "<spring:message code="INFO_UPDATE_SUCCESS"/>");
|
postChange(
|
||||||
|
"c/restful/account/firstname",
|
||||||
|
firstname,
|
||||||
|
function() {
|
||||||
|
var changeInfoMsg = $('#changeInfoMsg');
|
||||||
|
changeInfoMsg.removeClass('alert-error').addClass('alert-info').show();
|
||||||
|
changeInfoMsg.text('<spring:message code="INFO_UPDATE_SUCCESS"/>');
|
||||||
|
},
|
||||||
|
function(textStatus) {
|
||||||
|
changeInfoMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
|
changeInfoMsg.text(textStatus);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
postChange(
|
||||||
|
"c/restful/account/lastname",
|
||||||
|
lastname,
|
||||||
|
function() {
|
||||||
|
changeInfoMsg.removeClass('alert-error').addClass('alert-info').show();
|
||||||
|
changeInfoMsg.text('<spring:message code="INFO_UPDATE_SUCCESS"/>');
|
||||||
|
},
|
||||||
|
function(textStatus) {
|
||||||
|
changeInfoMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
|
changeInfoMsg.text(textStatus);
|
||||||
|
}
|
||||||
|
);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#languageForm').submit(function (event) {
|
$('#languageForm').submit(function (event) {
|
||||||
|
|
||||||
var locale = $('#languageForm option:selected').val();
|
var locale = $('#languageForm option:selected').val();
|
||||||
postChange("c/restful/account/locale", locale, 'languageMsg', "<spring:message code="INFO_UPDATE_SUCCESS"/>");
|
var languageMsg = $('#languageMsg');
|
||||||
|
postChange(
|
||||||
|
"c/restful/account/locale",
|
||||||
|
locale,
|
||||||
|
function() {
|
||||||
|
languageMsg.removeClass('alert-error').addClass('alert-info').show();
|
||||||
|
languageMsg.text('<spring:message code="INFO_UPDATE_SUCCESS"/>');
|
||||||
|
},
|
||||||
|
function(textStatus) {
|
||||||
|
languageMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
|
languageMsg.text(textStatus);
|
||||||
|
}
|
||||||
|
);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#deleteAccountForm').submit(function (event) {
|
||||||
|
var locale = $('#deleteAccountForm option:selected').val();
|
||||||
|
postChange(
|
||||||
|
"c/restful/account",
|
||||||
|
locale,
|
||||||
|
function() {
|
||||||
|
window.location.href = "/c/logout"
|
||||||
|
},
|
||||||
|
function(textStatus) {
|
||||||
|
var deleteAccountMsg = $('#deleteAccountMsg');
|
||||||
|
deleteAccountMsg.removeClass('alert-info').addClass('alert-error').show();
|
||||||
|
deleteAccountMsg.text(textStatus);
|
||||||
|
},
|
||||||
|
'DELETE'
|
||||||
|
)
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2012] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.test.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.rest.model.RestUser;
|
||||||
|
import org.jetbrains.annotations.NonNls;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
|
import org.springframework.security.crypto.codec.Base64;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public class RestAccountITCase {
|
||||||
|
|
||||||
|
@NonNls
|
||||||
|
private static final String HOST_PORT = "http://localhost:8080";
|
||||||
|
private static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||||
|
private static final String ADMIN_CREDENTIALS = "admin@wisemapping.org" + ":" + "admin";
|
||||||
|
|
||||||
|
|
||||||
|
@Test(dataProvider = "ContentType-Provider-Function")
|
||||||
|
public void deleteUser(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
final RestTemplate adminTemplate = createTemplate(ADMIN_CREDENTIALS);
|
||||||
|
|
||||||
|
final RestUser dummyUser = createDummyUser();
|
||||||
|
createUser(requestHeaders, adminTemplate, dummyUser);
|
||||||
|
|
||||||
|
// Delete user ...
|
||||||
|
final RestTemplate dummyTemplate = createTemplate(dummyUser.getEmail() + ":fooPassword");
|
||||||
|
dummyTemplate.delete(BASE_REST_URL + "/account");
|
||||||
|
|
||||||
|
// Is the user there ?
|
||||||
|
// Check that the user has been created ...
|
||||||
|
// try {
|
||||||
|
// findUser(requestHeaders, adminTemplate, location);
|
||||||
|
// fail("User could not be deleted !");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createNewUser(final @NotNull MediaType mediaType) {
|
||||||
|
|
||||||
|
// Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
final RestTemplate templateRest = createTemplate(ADMIN_CREDENTIALS);
|
||||||
|
|
||||||
|
// Fill user data ...
|
||||||
|
final RestUser restUser = createDummyUser();
|
||||||
|
|
||||||
|
// Create a new user ...
|
||||||
|
final URI location = createUser(requestHeaders, templateRest, restUser);
|
||||||
|
|
||||||
|
// Check that the user has been created ...
|
||||||
|
ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);
|
||||||
|
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
||||||
|
|
||||||
|
// Find by email and check ...
|
||||||
|
result = findUserByEmail(requestHeaders, templateRest, restUser.getEmail());
|
||||||
|
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
||||||
|
|
||||||
|
return restUser.getEmail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ResponseEntity<RestUser> findUser(HttpHeaders requestHeaders, RestTemplate templateRest, URI location) {
|
||||||
|
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
|
||||||
|
final String url = HOST_PORT + location;
|
||||||
|
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, RestTemplate templateRest, final String email) {
|
||||||
|
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
|
||||||
|
|
||||||
|
// Add extension only to avoid the fact that the last part is extracted ...
|
||||||
|
final String url = BASE_REST_URL + "/admin/users/email/{email}.json";
|
||||||
|
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class, email);
|
||||||
|
}
|
||||||
|
|
||||||
|
private URI createUser(HttpHeaders requestHeaders, RestTemplate templateRest, RestUser restUser) {
|
||||||
|
HttpEntity<RestUser> createUserEntity = new HttpEntity<RestUser>(restUser, requestHeaders);
|
||||||
|
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||||
|
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||||
|
acceptableMediaTypes.add(mediaType);
|
||||||
|
|
||||||
|
final HttpHeaders result = new HttpHeaders();
|
||||||
|
result.setAccept(acceptableMediaTypes);
|
||||||
|
result.setContentType(mediaType);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestTemplate createTemplate(@NotNull final String authorisation) {
|
||||||
|
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
||||||
|
@Override
|
||||||
|
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
||||||
|
super.prepareConnection(connection, httpMethod);
|
||||||
|
|
||||||
|
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
|
||||||
|
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
return new RestTemplate(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestUser createDummyUser() {
|
||||||
|
final RestUser restUser = new RestUser();
|
||||||
|
final String username = "foo-to-delete" + System.nanoTime();
|
||||||
|
final String email = username + "@example.org";
|
||||||
|
restUser.setEmail(email);
|
||||||
|
restUser.setFirstname("foo first name");
|
||||||
|
restUser.setLastname("foo last name");
|
||||||
|
restUser.setPassword("fooPassword");
|
||||||
|
return restUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DataProvider(name = "ContentType-Provider-Function")
|
||||||
|
public Object[][] contentTypes() {
|
||||||
|
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user