throws IOException {
String action = request.getParameter("action");
if (action != null && action.equals("delete")) {
try {
String id = request.getParameter("id");
Page obj = PageModel.getById(id);
if (obj != null) {
PageModel.delete(obj);
response.getWriter().print("");
} else {
response.getWriter()
.print("Action fails ! Page's not exits or has been deleted !");
}
} catch (Exception e) {
response.getWriter().print("Action fails ! Please try again !");
}
} else if (action != null && action.equals("deactive")) {
try {
String id = request.getParameter("id");
Page obj = PageModel.getById(id);
if (obj != null) {
obj.setUpdated(Calendar.getInstance().getTime());
obj.setStatus(2);
PageModel.insert(obj);
response.getWriter().print("");
} else {
response.getWriter()
.print("Action fails ! Page's not exits or has been deleted !");
}
} catch (Exception e) {
response.getWriter().print("Action fails ! Please try again !");
}
} else if (action != null && action.equals("active")) {
try {
String id = request.getParameter("id");
Page obj = PageModel.getById(id);
if (obj != null) {
obj.setUpdated(Calendar.getInstance().getTime());
obj.setStatus(1);
PageModel.insert(obj);
response.getWriter().print("");
} else {
response.getWriter()
.print("Action fails ! Page'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()) {
Page obj = PageModel.getById(ids[i]);
if (obj != null) {
PageModel.delete(obj);
}
}
}