01: /*
02: * Ajax
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package org.enhydra.snapperAdmin.presentation;
09:
10: // Enhydra SuperServlet imports
11: import java.io.IOException;
12:
13: import org.enhydra.snapperAdmin.spec.Site;
14: import org.enhydra.snapperAdmin.spec.SiteList;
15: import org.enhydra.snapperAdmin.spec.SiteListFactory;
16:
17: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
18: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
19: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
20:
21: public class Check implements HttpPresentation {
22:
23: public void run(HttpPresentationComms comms)
24: throws HttpPresentationException, IOException {
25:
26: if (comms.request.getParameter("id") != null) {
27:
28: SiteList sl;
29:
30: Site[] list;
31: try {
32: sl = SiteListFactory
33: .getSiteList("org.enhydra.snapperAdmin.business.SiteListImpl");
34: list = sl.getList();
35: String target = comms.request.getParameter("id");
36:
37: if (list != null) {
38: for (int i = 0; i < list.length; i++) {
39: if (list[i].getNAME().equals(target)) {
40: comms.response.setContentType("text/xml");
41: comms.response.setHeader("Cache-Control",
42: "no-cache");
43: comms.response.writeHTML("false");
44:
45: return;
46: }
47: }
48: }
49: comms.response.setContentType("text/xml");
50: comms.response.setHeader("Cache-Control", "no-cache");
51: comms.response.writeHTML("true");
52:
53: } catch (Exception ex) {
54: System.out.println("Exception: " + ex);
55: list = null;
56: }
57: }
58:
59: if (comms.request.getParameter("size") != null) {
60: try {
61: Integer.parseInt(comms.request.getParameter("size"));
62: comms.response.setContentType("text/xml");
63: comms.response.setHeader("Cache-Control", "no-cache");
64: comms.response.writeHTML("true");
65: } catch (Exception e) {
66: comms.response.setContentType("text/xml");
67: comms.response.setHeader("Cache-Control", "no-cache");
68: comms.response.writeHTML("false");
69: }
70:
71: }
72:
73: if (comms.request.getParameter("age") != null) {
74: try {
75: Integer.parseInt(comms.request.getParameter("age"));
76: comms.response.setContentType("text/xml");
77: comms.response.setHeader("Cache-Control", "no-cache");
78: comms.response.writeHTML("true");
79: } catch (Exception e) {
80: comms.response.setContentType("text/xml");
81: comms.response.setHeader("Cache-Control", "no-cache");
82: comms.response.writeHTML("false");
83: }
84:
85: }
86:
87: }
88:
89: }
|