solving merge conflict

This commit is contained in:
Ezequiel Bergamaschi
2014-02-05 21:21:00 -03:00
committed by Ezequiel Bergamaschi
20 changed files with 427 additions and 143 deletions

View File

@@ -45,6 +45,6 @@ public interface UserManager {
public User createUser(User user, Collaborator col);
public void deleteUser(User user);
public void removeUser(@NotNull User user);
}

View File

@@ -110,11 +110,8 @@ public class UserManagerImpl
}
@Override
public void deleteUser(@NotNull User user) {
final Collaborator collaborator = this.getCollaboratorBy(user.getEmail());
getHibernateTemplate().delete(collaborator);
public void removeUser(@NotNull final User user) {
getHibernateTemplate().delete(user);
getHibernateTemplate().flush();
}
public void auditLogin(@NotNull AccessAuditory accessAuditory) {

View File

@@ -19,7 +19,9 @@
package com.wisemapping.rest;
import com.mangofactory.swagger.annotations.ApiIgnore;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
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 javax.servlet.http.HttpServletRequest;
import java.util.List;
@Api(value="UserApi",description = "Account Account Related Objects.")
@Controller
@@ -76,7 +79,7 @@ public class AccountController extends BaseController {
throw new IllegalArgumentException("Firstname can not be null");
}
final User user = Utils.getUser();
final User user = Utils.getUser(true);
user.setFirstname(firstname);
userService.updateUser(user);
}
@@ -88,7 +91,7 @@ public class AccountController extends BaseController {
throw new IllegalArgumentException("lastname can not be null");
}
final User user = Utils.getUser();
final User user = Utils.getUser(true);
user.setLastname(lastname);
userService.updateUser(user);
}
@@ -106,6 +109,21 @@ public class AccountController extends BaseController {
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
@RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)

View File

@@ -18,7 +18,6 @@
package com.wisemapping.rest;
import com.mangofactory.swagger.annotations.ApiModel;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.Collaboration;
@@ -56,6 +55,7 @@ public class AdminController extends BaseController {
@Qualifier("userService")
@Autowired
private UserService userService;
@Qualifier("mindmapService")
@Autowired
private MindmapService mindmapService;
@@ -133,12 +133,19 @@ public class AdminController extends BaseController {
@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
@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);
if (user == null) {
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.")

View File

@@ -21,12 +21,9 @@ package com.wisemapping.security;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import javax.servlet.http.HttpServletRequest;
final public class Utils {
private Utils() {
}
@@ -37,7 +34,7 @@ final public class Utils {
return getUser(false);
}
@Nullable
@NotNull
public static User getUser(boolean forceCheck) {
User result = null;
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();

View File

@@ -46,8 +46,6 @@ public interface MindmapService {
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;
List<Mindmap> search(MindMapCriteria criteria);

View File

@@ -243,28 +243,6 @@ public class MindmapServiceImpl
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
public List<MindMapHistory> findMindmapHistory(int mindmapId) {

View File

@@ -38,7 +38,7 @@ public interface UserService {
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);

View File

@@ -21,7 +21,11 @@ package com.wisemapping.service;
import com.wisemapping.dao.UserManager;
import com.wisemapping.exceptions.WiseMappingException;
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.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,8 +33,11 @@ import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.ui.velocity.VelocityEngineUtils;
import java.io.IOException;
import java.util.*;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
public class UserServiceImpl
implements UserService {
@@ -95,8 +102,10 @@ public class UserServiceImpl
}
@Override
public void deleteUser(@NotNull User user) {
userManager.deleteUser(user);
public void removeUser(@NotNull User user) {
// Force object reload before removing....
final User userBy = userManager.getUserBy(user.getEmail());
userManager.removeUser(userBy);
}
@Override