mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Handle exceptions.
This commit is contained in:
parent
4dd7a82e32
commit
e36b0b8b52
@ -131,40 +131,44 @@ public class AdminController extends BaseController {
|
|||||||
|
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge")
|
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge")
|
||||||
public void purgeDB(@RequestParam(required = true) Integer muid, @RequestParam(required = true) Boolean apply) throws UnsupportedEncodingException, WiseMappingException {
|
public void purgeDB(@RequestParam(required = true) Integer muid, @RequestParam(required = true) Boolean apply) {
|
||||||
|
|
||||||
for (int i = 0; i < muid; i++) {
|
for (int i = 0; i < muid; i++) {
|
||||||
System.out.println("looking for user:" + i);
|
System.out.println("Looking for user:" + i);
|
||||||
User user;
|
User user = user = userService.getUserBy(i);
|
||||||
try {
|
|
||||||
user = userService.getUserBy(i);
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
// User does not exit's continue ...
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not process admin accounts ...
|
if (user != null) {
|
||||||
if (user.getEmail().contains("wisemapping")) {
|
// Do not process admin accounts ...
|
||||||
continue;
|
if (user.getEmail().contains("wisemapping")) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate over the list of maps ...
|
try {
|
||||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
// Iterate over the list of maps ...
|
||||||
for (Collaboration collaboration : collaborations) {
|
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||||
final Mindmap mindmap = collaboration.getMindMap();
|
for (Collaboration collaboration : collaborations) {
|
||||||
if (MindmapFilter.MY_MAPS.accept(mindmap, user)) {
|
final Mindmap mindmap = collaboration.getMindMap();
|
||||||
|
if (MindmapFilter.MY_MAPS.accept(mindmap, user)) {
|
||||||
|
|
||||||
final Calendar yearAgo = Calendar.getInstance();
|
final Calendar yearAgo = Calendar.getInstance();
|
||||||
yearAgo.add(Calendar.MONTH, -18);
|
yearAgo.add(Calendar.MONTH, -18);
|
||||||
// The use has only two maps... When they have been modified ..
|
// The use has only two maps... When they have been modified ..
|
||||||
if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) {
|
if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) {
|
||||||
if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) {
|
if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) {
|
||||||
System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId());
|
System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId());
|
||||||
if (apply) {
|
if (apply) {
|
||||||
mindmapService.removeMindmap(mindmap, user);
|
mindmapService.removeMindmap(mindmap, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (WiseMappingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user