Package com.tubeonfire.ajax.admin

Source Code of com.tubeonfire.ajax.admin.ProcessMission

package com.tubeonfire.ajax.admin;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tubeonfire.entity.Mission;
import com.tubeonfire.model.admin.MissionModel;

@SuppressWarnings("serial")
public class ProcessMission extends HttpServlet {
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String action = request.getParameter("action");
    if (action != null && action.equals("delete")) {
      try {
        String id = request.getParameter("id");
        Mission obj = MissionModel.getById(id);
        if (obj != null) {
          MissionModel.delete(obj);
          response.getWriter().print("");
        } else {
          response.getWriter().print(
              "Action fails ! Mission's not exits or has been deleted !");
        }
      } catch (Exception e) {
        response.getWriter().print("Action fails ! Please try again !");
      }

    } else if (action != null && action.equals("delete-all")) {
      try {
        String strIds = (String) request.getParameter("ids");
        String[] ids = strIds.split(",");
        for (int i = 0; i < ids.length; i++) {
          if (!ids[i].isEmpty()) {
            Mission obj = MissionModel.getById(ids[i]);
            if (obj != null) {
              MissionModel.delete(obj);
            }
          }
        }
        response.getWriter().print("");
      } catch (Exception e) {
        response.getWriter().print("Action fails ! Please try again !");
      }
    }
  }
}
TOP

Related Classes of com.tubeonfire.ajax.admin.ProcessMission

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.