Fix classcast.

This commit is contained in:
Paulo Gustavo Veiga 2013-03-24 16:33:58 -03:00
parent 712cc2c60b
commit abfc06c7d5

View File

@ -131,9 +131,9 @@ 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) { 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); System.out.println("Looking for user:" + i);
final User user = userService.getUserBy(i); final User user = userService.getUserBy(i);
if (user != null) { if (user != null) {
@ -142,7 +142,6 @@ public class AdminController extends BaseController {
continue; continue;
} }
try {
// Iterate over the list of maps ... // Iterate over the list of maps ...
final List<Collaboration> collaborations = mindmapService.findCollaborations(user); final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
for (Collaboration collaboration : collaborations) { for (Collaboration collaboration : collaborations) {
@ -152,7 +151,10 @@ public class AdminController extends BaseController {
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 ..
System.out.println("Checking map id:" + mindmap.getId());
if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) { if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) {
System.out.println("Old map. Is simple ?:" + mindmap.getId());
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) {
@ -162,13 +164,7 @@ public class AdminController extends BaseController {
} }
} }
} }
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (WiseMappingException e) {
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
}
} }
} }