working on public sxkeeper
[opensuse:sxkeeper.git] / src / de / suse / sx / KeeperInfo.java
1 /*
2  * Copyright (c) - 2005 by Klaas Freitag <freitag@suse.de>
3  * 
4  * This file is part of the SUSE XML (SX) project. 
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  */
10
11 package de.suse.sx;
12
13 import java.io.IOException;
14 import java.io.PrintWriter;
15 import java.util.*;
16
17 import javax.servlet.ServletException;
18 import javax.servlet.http.*;
19
20 import de.suse.xml.*;
21
22 /**
23  * @author freitag
24  *
25  * TODO To change the template for this generated type comment go to
26  * Window - Preferences - Java - Code Style - Code Templates
27  */
28 public class KeeperInfo extends HttpServlet {
29     
30     private static final long serialVersionUID = 7526452295622776149L;
31     
32     public void doGet(HttpServletRequest request,
33             HttpServletResponse response) throws ServletException, IOException {
34         
35         response.setContentType("text/html");
36             PrintWriter out = response.getWriter();
37             String title = "SXKeeper Information";
38             
39             out.print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" + 
40                         "<html><META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" + 
41                         "<title>" + title + "</title>" + 
42                         " </head><body text=\"#000000\" bgcolor=\"#FFFFFF\">");
43             
44             out.print("<style type=\"text/css\">" + 
45                         "<!--" + 
46                         ".title {background-color: #eae8e9;} " + 
47                         "-->" + 
48                         "</style>");
49             
50             dataManager dataMan = null;
51             try {
52                         dataMan = dataManager.getInstance();
53                 } catch (Exception e) {
54                         e.printStackTrace();
55                         throw new ServletException(e.getMessage());
56                 }
57             
58             PropertyManager propMan = PropertyManager.getInstance();
59             
60             out.println("<h2>Welcome to the SXKeeper </h2>");
61             
62             out.println("<h2>Available containers: </h2>");
63             out.println("<table>");
64             
65             try {
66                         for (Iterator it = dataMan.getContainers().keySet().iterator(); it.hasNext(); ){
67                                 String containerName = (String) it.next();
68                                 if (!containerName.toLowerCase().endsWith("history")){
69                                         out.print("<tr class=\"title\"><td colspan=\"2\"><b>" + containerName + "</b></td></tr>");
70                                         
71                                         int size = dataMan.getAllDocuments(new SXDocumentType(containerName)).size();
72                                         Properties config = propMan.getConfig(containerName);
73                                         if (config.getProperty("description") != null){ 
74                                                 out.print("<tr><td><b>Description:</b></td>");
75                                                 out.print("<td>" + config.getProperty("description") + "</td></tr>");
76                                         } else {
77                                                 out.print("<tr><td colspan=\"2\">No description available... </td></tr>");
78                                         }
79                                         out.print("<tr><td><b>Documents:</b></td><td>#" + size + "</td></tr>");
80                                         out.print("<tr><td><b>History backend: </b></td><td>" + config.getProperty("hist.mode") + "</td></tr>");
81                                         out.print("<tr><td><b>Update notification class: </b></td><td>" + config.getProperty("notification.class") + "</td></tr>");
82                                 }
83                         }
84                 } catch (Exception e) {
85                         // TODO Auto-generated catch block
86                         e.printStackTrace();
87                 }
88             out.println("</table>");
89     }
90             
91
92 }