コード例 #1
0
  @FilterWith({XSRFFilter.class, AdminFilter.class})
  public Result delete(Context context) {
    FlashScope flash = context.getFlashScope();
    Group group = context.getAttribute("group", Group.class);

    // TODO FIX ME locking until database modification done
    if (taskManager.isGoogleRunning()) {
      flash.error("admin.google.errorTaskRunning");
      return Results.redirect(
          router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    List<GoogleTarget> targets = googleDB.target.list(Arrays.asList(group.getId()));
    for (GoogleTarget target : targets) {
      googleDB.targetSummary.deleteByTarget(target.getId());
      googleDB.rank.deleteByTarget(group.getId(), target.getId());
      googleDB.target.delete(target.getId());
    }

    List<GoogleSearch> searches = googleDB.search.listByGroup(Arrays.asList(group.getId()));
    for (GoogleSearch search : searches) {
      deleteSearch(group, search);
    }

    baseDB.event.delete(group);
    baseDB.user.delPerm(group);
    if (!baseDB.group.delete(group)) {
      flash.error("admin.google.failedDeleteGroup");
      return Results.redirect(
          router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    } else {
      flash.success("admin.google.groupDeleted");
      return Results.redirect(router.getReverseRoute(GroupController.class, "groups"));
    }
  }
コード例 #2
0
  @FilterWith({XSRFFilter.class, AdminFilter.class})
  public Result delTarget(Context context, @Params("id[]") String[] ids) {
    FlashScope flash = context.getFlashScope();
    Group group = context.getAttribute("group", Group.class);

    // TODO FIX ME locking until database modification done
    if (taskManager.isGoogleRunning()) {
      flash.error("admin.google.errorTaskRunning");
      return Results.redirect(
          router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    if (ids == null || ids.length == 0) {
      flash.error("error.noWebsiteSelected");
      return Results.redirect(
          router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    for (String id : ids) {
      GoogleTarget target = null;
      try {
        target = getTarget(context, Integer.parseInt(id));
      } catch (Exception ex) {
        target = null;
      }

      if (target == null) {
        flash.error("error.invalidWebsite");
        return Results.redirect(
            router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
      }

      googleDB.targetSummary.deleteByTarget(target.getId());
      googleDB.rank.deleteByTarget(group.getId(), target.getId());
      googleDB.target.delete(target.getId());
    }

    return Results.redirect(
        router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
  }