From abfc06c7d5057ef26f7958eb63b032029b48c7da Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 24 Mar 2013 16:33:58 -0300 Subject: [PATCH] Fix classcast. --- .../com/wisemapping/rest/AdminController.java | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java index b37115c9..c3a34e62 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java @@ -131,44 +131,40 @@ public class AdminController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) @RequestMapping(method = RequestMethod.GET, value = "admin/database/purge") - public void purgeDB(@RequestParam(required = true) Integer muid, @RequestParam(required = true) Boolean apply) { + public void purgeDB(@RequestParam(required = true) Integer minUid, @RequestParam(required = true) Integer maxUid, @RequestParam(required = true) Boolean apply) throws WiseMappingException, UnsupportedEncodingException { - for (int i = 0; i < muid; i++) { + for (int i = minUid; i < maxUid; i++) { System.out.println("Looking for user:" + i); - final User user = userService.getUserBy(i); + final User user = userService.getUserBy(i); if (user != null) { // Do not process admin accounts ... if (user.getEmail().contains("wisemapping")) { continue; } - try { - // Iterate over the list of maps ... - final List collaborations = mindmapService.findCollaborations(user); - for (Collaboration collaboration : collaborations) { - final Mindmap mindmap = collaboration.getMindMap(); - if (MindmapFilter.MY_MAPS.accept(mindmap, user)) { + // Iterate over the list of maps ... + final List collaborations = mindmapService.findCollaborations(user); + for (Collaboration collaboration : collaborations) { + final Mindmap mindmap = collaboration.getMindMap(); + if (MindmapFilter.MY_MAPS.accept(mindmap, user)) { - final Calendar yearAgo = Calendar.getInstance(); - yearAgo.add(Calendar.MONTH, -18); - // The use has only two maps... When they have been modified .. - if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) { - if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) { - System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId()); - if (apply) { - mindmapService.removeMindmap(mindmap, user); - } + final Calendar yearAgo = Calendar.getInstance(); + yearAgo.add(Calendar.MONTH, -18); + // The use has only two maps... When they have been modified .. + System.out.println("Checking map id:" + mindmap.getId()); + if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) { + System.out.println("Old map. Is simple ?:" + mindmap.getId()); + + if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) { + System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId()); + if (apply) { + mindmapService.removeMindmap(mindmap, user); } } } } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } catch (WiseMappingException e) { - e.printStackTrace(); - } catch (RuntimeException e) { - e.printStackTrace(); } + } }