コード例 #1
0
ファイル: TestServlet.java プロジェクト: a531227909/tr069
 protected void doGet(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   try {
     PrintWriter out = res.getWriter();
     if (TestDatabase.database == null)
       TestDatabase.database = new FileDatabase("xAPS-TR069-Test.dat");
     Element html = new Element("html");
     html.head().title("xAPS Test Verification Process");
     Element body = html.body();
     body.h(1, "xAPS Test Verification Process");
     if (!Properties.isDiscoveryMode() || !Properties.isTestMode()) {
       body.add(
           "The server is not set up in both discovery and test mode, thus it will not support this process.");
       body.add(
           "Change configuration (or contact xAPS Administrator) to enable xAPS Test Verification Process.");
       out.println(html.toString(""));
       return;
     }
     intro(req, body);
     String username = null;
     if (req.getParameter("logout") == null) username = req.getParameter("username");
     if (username == null || username.trim().equals("")) {
       body.add("ACS username is required");
       Element form = body.form("test", "post", "form1");
       Element table = form.table();
       Element tr = table.tr();
       tr.td().input("username", "text");
       tr.td().input("login", "submit", "Login");
       username = null;
     } else {
       username = username.trim();
       TestDatabaseObject tdo = input(req, body, username);
       TestDatabase.database.insert(username, tdo.toString());
     }
     out.print(html.toString(""));
   } catch (Throwable t) {
     throw new ServletException(t);
   }
 }