You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2007/05/25 03:43:43 UTC

svn commit: r541504 [3/7] - in /xml/xindice/trunk: ./ config/ java/scratchpad/webadmin/ java/src/org/apache/xindice/client/xmldb/embed/ java/src/org/apache/xindice/core/ java/src/org/apache/xindice/core/data/ java/src/org/apache/xindice/core/filer/ jav...

Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/HtmlViewerComponent.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/HtmlViewerComponent.java?view=diff&rev=541504&r1=541498&r2=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/HtmlViewerComponent.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/HtmlViewerComponent.java Thu May 24 18:43:39 2007
@@ -27,241 +27,94 @@
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.avalon.fortress.impl.DefaultContainer;
-import org.apache.avalon.fortress.util.CompositeException;
 import org.apache.xindice.server.Xindice;
+import org.apache.xindice.webadmin.WebAdminManager;
 
 /**
  * Xindice Html Viewer.
- * 
+ *
  * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
  * @version $Id$
  */
-public class HtmlViewerComponent extends DefaultContainer {
-
+public abstract class HtmlViewerComponent {
     static Object[][] entitiesArray =
-        { { "quot", new Integer(34)}, // " - double-quote
-        {
-            "amp", new Integer(38)
-            }, // & - ampersand
-        {
-            "lt", new Integer(60)
-            }, // < - less-than
-        {
-            "gt", new Integer(62)
-            }, // > - greater-than
-        {
-            "nbsp", new Integer(160)
-            }, // non-breaking space
-        {
-            "copy", new Integer(169)
-            }, // ? - copyright
-        {
-            "reg", new Integer(174)
-            }, // ? - registered trademark
-        {
-            "Agrave", new Integer(192)
-            }, // ? - uppercase A, grave accent
-        {
-            "Aacute", new Integer(193)
-            }, // ? - uppercase A, acute accent
-        {
-            "Acirc", new Integer(194)
-            }, // ? - uppercase A, circumflex accent
-        {
-            "Atilde", new Integer(195)
-            }, // ? - uppercase A, tilde
-        {
-            "Auml", new Integer(196)
-            }, // ? - uppercase A, umlaut
-        {
-            "Aring", new Integer(197)
-            }, // ? - uppercase A, ring
-        {
-            "AElig", new Integer(198)
-            }, // ? - uppercase AE
-        {
-            "Ccedil", new Integer(199)
-            }, // ? - uppercase C, cedilla
-        {
-            "Egrave", new Integer(200)
-            }, // ? - uppercase E, grave accent
-        {
-            "Eacute", new Integer(201)
-            }, // ? - uppercase E, acute accent
-        {
-            "Ecirc", new Integer(202)
-            }, // ? - uppercase E, circumflex accent
-        {
-            "Euml", new Integer(203)
-            }, // ? - uppercase E, umlaut
-        {
-            "Igrave", new Integer(204)
-            }, // ? - uppercase I, grave accent
-        {
-            "Iacute", new Integer(205)
-            }, // ? - uppercase I, acute accent
-        {
-            "Icirc", new Integer(206)
-            }, // ? - uppercase I, circumflex accent
-        {
-            "Iuml", new Integer(207)
-            }, // ? - uppercase I, umlaut
-        {
-            "ETH", new Integer(208)
-            }, // ? - uppercase Eth, Icelandic
-        {
-            "Ntilde", new Integer(209)
-            }, // ? - uppercase N, tilde
-        {
-            "Ograve", new Integer(210)
-            }, // ? - uppercase O, grave accent
-        {
-            "Oacute", new Integer(211)
-            }, // ? - uppercase O, acute accent
-        {
-            "Ocirc", new Integer(212)
-            }, // ? - uppercase O, circumflex accent
-        {
-            "Otilde", new Integer(213)
-            }, // ? - uppercase O, tilde
-        {
-            "Ouml", new Integer(214)
-            }, // ? - uppercase O, umlaut
-        {
-            "Oslash", new Integer(216)
-            }, // ? - uppercase O, slash
-        {
-            "Ugrave", new Integer(217)
-            }, // ? - uppercase U, grave accent
-        {
-            "Uacute", new Integer(218)
-            }, // ? - uppercase U, acute accent
-        {
-            "Ucirc", new Integer(219)
-            }, // ? - uppercase U, circumflex accent
-        {
-            "Uuml", new Integer(220)
-            }, // ? - uppercase U, umlaut
-        {
-            "Yacute", new Integer(221)
-            }, // ? - uppercase Y, acute accent
-        {
-            "THORN", new Integer(222)
-            }, // ? - uppercase THORN, Icelandic
-        {
-            "szlig", new Integer(223)
-            }, // ? - lowercase sharps, German
-        {
-            "agrave", new Integer(224)
-            }, // ? - lowercase a, grave accent
-        {
-            "aacute", new Integer(225)
-            }, // ? - lowercase a, acute accent
-        {
-            "acirc", new Integer(226)
-            }, // ? - lowercase a, circumflex accent
-        {
-            "atilde", new Integer(227)
-            }, // ? - lowercase a, tilde
-        {
-            "auml", new Integer(228)
-            }, // ? - lowercase a, umlaut
-        {
-            "aring", new Integer(229)
-            }, // ? - lowercase a, ring
-        {
-            "aelig", new Integer(230)
-            }, // ? - lowercase ae
-        {
-            "ccedil", new Integer(231)
-            }, // ? - lowercase c, cedilla
-        {
-            "egrave", new Integer(232)
-            }, // ? - lowercase e, grave accent
-        {
-            "eacute", new Integer(233)
-            }, // ? - lowercase e, acute accent
-        {
-            "ecirc", new Integer(234)
-            }, // ? - lowercase e, circumflex accent
-        {
-            "euml", new Integer(235)
-            }, // ? - lowercase e, umlaut
-        {
-            "igrave", new Integer(236)
-            }, // ? - lowercase i, grave accent
-        {
-            "iacute", new Integer(237)
-            }, // ? - lowercase i, acute accent
-        {
-            "icirc", new Integer(238)
-            }, // ? - lowercase i, circumflex accent
-        {
-            "iuml", new Integer(239)
-            }, // ? - lowercase i, umlaut
-        {
-            "igrave", new Integer(236)
-            }, // ? - lowercase i, grave accent
-        {
-            "iacute", new Integer(237)
-            }, // ? - lowercase i, acute accent
-        {
-            "icirc", new Integer(238)
-            }, // ? - lowercase i, circumflex accent
-        {
-            "iuml", new Integer(239)
-            }, // ? - lowercase i, umlaut
-        {
-            "eth", new Integer(240)
-            }, // ? - lowercase eth, Icelandic
-        {
-            "ntilde", new Integer(241)
-            }, // ? - lowercase n, tilde
-        {
-            "ograve", new Integer(242)
-            }, // ? - lowercase o, grave accent
-        {
-            "oacute", new Integer(243)
-            }, // ? - lowercase o, acute accent
-        {
-            "ocirc", new Integer(244)
-            }, // ? - lowercase o, circumflex accent
-        {
-            "otilde", new Integer(245)
-            }, // ? - lowercase o, tilde
-        {
-            "ouml", new Integer(246)
-            }, // ? - lowercase o, umlaut
-        {
-            "oslash", new Integer(248)
-            }, // ? - lowercase o, slash
-        {
-            "ugrave", new Integer(249)
-            }, // ? - lowercase u, grave accent
-        {
-            "uacute", new Integer(250)
-            }, // ? - lowercase u, acute accent
-        {
-            "ucirc", new Integer(251)
-            }, // ? - lowercase u, circumflex accent
-        {
-            "uuml", new Integer(252)
-            }, // ? - lowercase u, umlaut
-        {
-            "yacute", new Integer(253)
-            }, // ? - lowercase y, acute accent
-        {
-            "thorn", new Integer(254)
-            }, // ? - lowercase thorn, Icelandic
-        {
-            "yuml", new Integer(255)
-            }, // ? - lowercase y, umlaut
-        {
-            "euro", new Integer(8364)
-            }, // Euro symbol
-    };
+            {{"quot", new Integer(34)}, // " - double-quote
+             {"amp", new Integer(38)}, // & - ampersand
+             {"lt", new Integer(60)}, // < - less-than
+             {"gt", new Integer(62)}, // > - greater-than
+             {"nbsp", new Integer(160)}, // non-breaking space
+             {"copy", new Integer(169)}, // ? - copyright
+             {"reg", new Integer(174)}, // ? - registered trademark
+             {"Agrave", new Integer(192)}, // ? - uppercase A, grave accent
+             {"Aacute", new Integer(193)}, // ? - uppercase A, acute accent
+             {"Acirc", new Integer(194)}, // ? - uppercase A, circumflex accent
+             {"Atilde", new Integer(195)}, // ? - uppercase A, tilde
+             {"Auml", new Integer(196)}, // ? - uppercase A, umlaut
+             {"Aring", new Integer(197)}, // ? - uppercase A, ring
+             {"AElig", new Integer(198)}, // ? - uppercase AE
+             {"Ccedil", new Integer(199)}, // ? - uppercase C, cedilla
+             {"Egrave", new Integer(200)}, // ? - uppercase E, grave accent
+             {"Eacute", new Integer(201)}, // ? - uppercase E, acute accent
+             {"Ecirc", new Integer(202)}, // ? - uppercase E, circumflex accent
+             {"Euml", new Integer(203)}, // ? - uppercase E, umlaut
+             {"Igrave", new Integer(204)}, // ? - uppercase I, grave accent
+             {"Iacute", new Integer(205)}, // ? - uppercase I, acute accent
+             {"Icirc", new Integer(206)}, // ? - uppercase I, circumflex accent
+             {"Iuml", new Integer(207)}, // ? - uppercase I, umlaut
+             {"ETH", new Integer(208)}, // ? - uppercase Eth, Icelandic
+             {"Ntilde", new Integer(209)}, // ? - uppercase N, tilde
+             {"Ograve", new Integer(210)}, // ? - uppercase O, grave accent
+             {"Oacute", new Integer(211)}, // ? - uppercase O, acute accent
+             {"Ocirc", new Integer(212)}, // ? - uppercase O, circumflex accent
+             {"Otilde", new Integer(213)}, // ? - uppercase O, tilde
+             {"Ouml", new Integer(214)}, // ? - uppercase O, umlaut
+             {"Oslash", new Integer(216)}, // ? - uppercase O, slash
+             {"Ugrave", new Integer(217)}, // ? - uppercase U, grave accent
+             {"Uacute", new Integer(218)}, // ? - uppercase U, acute accent
+             {"Ucirc", new Integer(219)}, // ? - uppercase U, circumflex accent
+             {"Uuml", new Integer(220)}, // ? - uppercase U, umlaut
+             {"Yacute", new Integer(221)}, // ? - uppercase Y, acute accent
+             {"THORN", new Integer(222)}, // ? - uppercase THORN, Icelandic
+             {"szlig", new Integer(223)}, // ? - lowercase sharps, German
+             {"agrave", new Integer(224)}, // ? - lowercase a, grave accent
+             {"aacute", new Integer(225)}, // ? - lowercase a, acute accent
+             {"acirc", new Integer(226)}, // ? - lowercase a, circumflex accent
+             {"atilde", new Integer(227)}, // ? - lowercase a, tilde
+             {"auml", new Integer(228)}, // ? - lowercase a, umlaut
+             {"aring", new Integer(229)}, // ? - lowercase a, ring
+             {"aelig", new Integer(230)}, // ? - lowercase ae
+             {"ccedil", new Integer(231)}, // ? - lowercase c, cedilla
+             {"egrave", new Integer(232)}, // ? - lowercase e, grave accent
+             {"eacute", new Integer(233)}, // ? - lowercase e, acute accent
+             {"ecirc", new Integer(234)}, // ? - lowercase e, circumflex accent
+             {"euml", new Integer(235)}, // ? - lowercase e, umlaut
+             {"igrave", new Integer(236)}, // ? - lowercase i, grave accent
+             {"iacute", new Integer(237)}, // ? - lowercase i, acute accent
+             {"icirc", new Integer(238)}, // ? - lowercase i, circumflex accent
+             {"iuml", new Integer(239)}, // ? - lowercase i, umlaut
+             {"igrave", new Integer(236)}, // ? - lowercase i, grave accent
+             {"iacute", new Integer(237)}, // ? - lowercase i, acute accent
+             {"icirc", new Integer(238)}, // ? - lowercase i, circumflex accent
+             {"iuml", new Integer(239)}, // ? - lowercase i, umlaut
+             {"eth", new Integer(240)}, // ? - lowercase eth, Icelandic
+             {"ntilde", new Integer(241)}, // ? - lowercase n, tilde
+             {"ograve", new Integer(242)}, // ? - lowercase o, grave accent
+             {"oacute", new Integer(243)}, // ? - lowercase o, acute accent
+             {"ocirc", new Integer(244)}, // ? - lowercase o, circumflex accent
+             {"otilde", new Integer(245)}, // ? - lowercase o, tilde
+             {"ouml", new Integer(246)}, // ? - lowercase o, umlaut
+             {"oslash", new Integer(248)}, // ? - lowercase o, slash
+             {"ugrave", new Integer(249)}, // ? - lowercase u, grave accent
+             {"uacute", new Integer(250)}, // ? - lowercase u, acute accent
+             {"ucirc", new Integer(251)}, // ? - lowercase u, circumflex accent
+             {"uuml", new Integer(252)}, // ? - lowercase u, umlaut
+             {"yacute", new Integer(253)}, // ? - lowercase y, acute accent
+             {"thorn", new Integer(254)}, // ? - lowercase thorn, Icelandic
+             {"yuml", new Integer(255)}, // ? - lowercase y, umlaut
+             {"euro", new Integer(8364)}, // Euro symbol
+            };
     static Map entities = new HashMap();
+
     static {
         for (int i = 0; i < entitiesArray.length; ++i) {
             entities.put(entitiesArray[i][1], entitiesArray[i][0]);
@@ -270,7 +123,7 @@
 
     /**
      * Turns funky characters into HTML entity equivalents
-     * 
+     *
      * @param unescaped unescaped String.
      * @return escaped String.
      */
@@ -280,25 +133,24 @@
 
     /**
      * Turns funky characters into HTML entity equivalents
-     * 
+     *
      * @param unescaped unescaped String.
-     * @param brake if true a new line will be inserted after every closing tag.
+     * @param brake     if true a new line will be inserted after every closing tag.
      * @return escaped String.
      */
     public static String htmlescape(String unescaped, boolean brake) {
         StringBuffer buf = new StringBuffer();
-        int i;
-        for (i = 0; i < unescaped.length(); ++i) {
+        for (int i = 0; i < unescaped.length(); ++i) {
             char ch = unescaped.charAt(i);
-            String entity = (String)entities.get(new Integer((int)ch));
+            String entity = (String) entities.get(new Integer((int) ch));
             if (entity == null) {
-                if (((int)ch) > 128) {
-                    buf.append("&#" + ((int)ch) + ";");
+                if (((int) ch) > 128) {
+                    buf.append("&#").append ((int) ch).append(";");
                 } else {
                     buf.append(ch);
                 }
             } else {
-                buf.append("&" + entity + ";");
+                buf.append("&").append(entity).append(";");
             }
             if (brake && ch == '>') {
                 buf.append("\n");
@@ -307,41 +159,10 @@
         return buf.toString();
     }
 
-    /** holds the shorthint name of this component */
-    protected String thisViewer = "";
-
-    /** holds a list of all available viewers */
-    protected String[] viewers = null;
-
-    public void initialize() throws CompositeException, Exception {
-        super.initialize();
-        if (m_metaManager != null) {
-            this.thisViewer =
-                m_metaManager
-                    .getMetaInfoForClassname(this.getClass().getName())
-                    .getConfigurationName();
-        } else {
-            getLogger().debug("cannot set this viewer name");
-        }
-        if (m_context != null) {
-            if (this instanceof HtmlCollectionViewer) {
-                viewers = (String[])m_context.get("collectionViewers");
-            } else if (this instanceof HtmlResourceViewer) {
-                viewers = (String[])m_context.get("resourceViewers");
-            }
-        } else {
-            viewers = new String[0];
-            getLogger().debug("cannot set configured viewers");
-        }
-    }
-
-    // ------------------------------------------------------ Protected Methods
+    protected abstract String getName();
 
-    protected ServletOutputStream startViewer(
-        String title,
-        String path,
-        HttpServletResponse res)
-        throws ServletException, IOException {
+    protected ServletOutputStream startViewer(String title, String path, HttpServletResponse res)
+            throws ServletException, IOException {
 
         res.setContentType("text/html; charset=utf-8");
         ServletOutputStream output = res.getOutputStream();
@@ -350,32 +171,39 @@
         return output;
     }
 
-    protected void finishViewer(ServletOutputStream output)
-        throws IOException {
+    protected void finishViewer(ServletOutputStream output) throws IOException {
         output.print(FOOTER);
         output.print(HTML_TAIL_SECTION);
         output.flush();
     }
 
-    protected void printHeader(ServletOutputStream output, String title)
-        throws IOException {
+    protected void printHeader(ServletOutputStream output, String title) throws IOException {
         output.print(HTML_HEADER_SECTION);
         output.print(title);
         output.print(END_HTML_HEADER_SECTION);
         output.print(LOGO_SECTION);
     }
 
-    protected void printTabs(ServletOutputStream output, String path)
-        throws IOException {
+    protected void printTabs(ServletOutputStream output, String path) throws IOException {
 
         output.print(START_TABS_SECTION);
+
+        String[] viewers = new String[]{};
+        if (this instanceof HtmlCollectionViewer) {
+            viewers = WebAdminManager.getCollectionViewers();
+        } else if (this instanceof HtmlResourceViewer) {
+            viewers = WebAdminManager.getResourceViewers();
+        } else if (this instanceof HtmlDatabaseViewer) {
+            viewers = WebAdminManager.getDatabaseViewers();
+        }
+
         for (int i = 0; i < viewers.length; i++) {
-            if (viewers[i].equals(thisViewer)) {
+            if (viewers[i].equals(getName())) {
                 if (i > 0) {
                     output.print(TAB_SPACE_SELECTED);
                 }
                 output.print(START_TAB_SELECTED);
-                output.print(thisViewer);
+                output.print(getName());
                 output.print(END_TAB);
             } else {
                 if (i > 0) {
@@ -398,7 +226,7 @@
 
         // path section
         output.print(LEFT_PATH_SECTION);
-        if (path != null || path.length() > 1) {
+        if (path != null && path.length() > 1) {
             output.print(path);
         } else {
             output.print("/");
@@ -408,14 +236,12 @@
         output.print(END_PATH_SECTION);
     }
 
-    protected void printStartTable(String title, ServletOutputStream output)
-        throws IOException {
-        String[] titles = { title };
+    protected void printStartTable(String title, ServletOutputStream output) throws IOException {
+        String[] titles = {title};
         printStartTable(titles, output);
     }
 
-    protected void printStartTable(String[] titles, ServletOutputStream output)
-        throws IOException {
+    protected void printStartTable(String[] titles, ServletOutputStream output) throws IOException {
         output.print(START_TABLE);
         output.print(START_TABLE_ROW);
 
@@ -432,19 +258,16 @@
         output.print(END_TABLE_ROW);
     }
 
-    protected void printEndTable(ServletOutputStream output)
-        throws IOException {
+    protected void printEndTable(ServletOutputStream output) throws IOException {
         output.print(END_TABLE);
     }
 
-    protected void printTableRow(String content, ServletOutputStream output)
-        throws IOException {
-        String[] contents = { content };
+    protected void printTableRow(String content, ServletOutputStream output) throws IOException {
+        String[] contents = {content};
         printTableRow(contents, output);
     }
 
-    protected void printTableRow(String[] contents, ServletOutputStream output)
-        throws IOException {
+    protected void printTableRow(String[] contents, ServletOutputStream output) throws IOException {
         output.print(START_TABLE_ROW);
 
         for (int i = 0; i < contents.length; i++) {
@@ -460,27 +283,20 @@
         output.print(END_TABLE_ROW);
     }
 
-    protected void printStartSingleTableBox(ServletOutputStream output)
-        throws IOException {
+    protected void printStartSingleTableBox(ServletOutputStream output) throws IOException {
         output.print(START_TABLE_ROW);
         output.print(START_TABLE_BOX);
     }
 
-    protected void printEndSingleTableBox(ServletOutputStream output)
-        throws IOException {
+    protected void printEndSingleTableBox(ServletOutputStream output) throws IOException {
         output.print(END_TABLE_BOX);
         output.print(END_TABLE_ROW);
     }
 
-    protected void printSearchFromRow(
-        String viewer,
-        String query,
-        String[] ns,
-        ServletOutputStream output)
-        throws IOException {
+    protected void printSearchFromRow(String viewer, String query, String[] ns, ServletOutputStream output)
+            throws IOException {
 
         query = query.replaceAll("\"", "&quot;");
-        //query.replace('\"', '#');
 
         output.print(START_TABLE_ROW);
         output.print(START_TABLE_BOX);
@@ -530,7 +346,7 @@
     // ---------------------------------------------------- Protected Constants
 
     protected static final String HTML_HEADER_SECTION =
-        "<html> \n"
+            "<html> \n"
             + "<head> \n"
             + "<style type=\"text/css\"><!-- \n"
             + "small { \n"
@@ -615,133 +431,133 @@
             + "  text-align: left; \n"
             + "  font-size: 12px; \n"
             + "} \n"
-            + 
-    /* xml highlighting */
-    ".xml-misc, .xml-element-name, .xml-attribute-name, .xml-attribute-content, "
-        + ".xml-element-content, .xml-comment, .xml-processing, .xml-cdata { \n"
-        + "  font-family: verdana,sans-serif; \n"
-        + "  font-size: 12px; \n"
-        + "} \n"
-        + ".xml-misc { \n"
-        + "  color: #000000; \n"
-        + "} \n"
-        + ".xml-element-name { \n"
-        + "  color: #cc0000; \n"
-        + "} \n"
-        + ".xml-attribute-name { \n"
-        + "  color: #660099; \n"
-        + "} \n"
-        + ".xml-attribute-content { \n"
-        + "  color: #000099; \n"
-        + "} \n"
-        + ".xml-element-content { \n"
-        + "  color: #000000; \n"
-        + "} \n"
-        + ".xml-comment { \n"
-        + "  color: #006600; \n"
-        + "} \n"
-        + ".xml-processing { \n"
-        + "  color: #cc0000; \n"
-        + "} \n"
-        + ".xml-cdata { \n"
-        + "  color: #006600; \n"
-        + "} \n"
-        + 
-    /* forms */
-    ".search-form, .create-form, .upload-form input { \n"
-        + "  color: #294563; \n"
-        + "  font-family: verdana,sans-serif; \n"
-        + "  font-weight: bold; \n"
-        + "  text-align: left; \n"
-        + "  font-size: 12px; \n"
-        + "  border: 0px none #ffffff; \n"
-        + "} \n"
-        + ".search-form td[colspan=3] { \n"
-        + "  width: 480px; \n"
-        + "} \n"
-        + ".search-form input { \n"
-        + "  border: 2px solid #294563; \n"
-        + "  background-color: #f0f0ff; \n"
-        + "  width: 200px; \n"
-        + "} \n"
-        + ".search-form input[name=query] { \n"
-        + "  border: 2px solid #294563; \n"
-        + "  background-color: #f0f0ff; \n"
-        + "  width: 400px; \n"
-        + "} \n"
-        + ".search-form td, .create-form td, .upload-form td { \n"
-        + "  border: 0px none #ffffff; \n"
-        + "} \n"
-        + ".search-form select { \n"
-        + "  font-size: 10px; \n"
-        + " background-color: #f0f0ff; \n"
-        + "}	 \n"
-        + ".create-form td[colspan=2] { \n"
-        + "  width: 450px; \n"
-        + "} \n"
-        + ".create-form input { \n"
-        + "  border: 2px solid #294563; \n"
-        + "  background-color: #f0f0ff; \n"
-        + "  width: 300px; \n"
-        + "} \n"
-        + "select { \n"
-        + "  font-size: 10px; \n"
-        + "  background-color: #f0f0ff; \n"
-        + "} \n"
-        + ".upload-form input { \n"
-        + "  border: 2px solid #294563; \n"
-        + "  background-color: #f0f0ff; \n"
-        + "} \n"
-        + "--></style> \n"
-        + "<title>";
+            +
+            /* xml highlighting */
+            ".xml-misc, .xml-element-name, .xml-attribute-name, .xml-attribute-content, "
+            + ".xml-element-content, .xml-comment, .xml-processing, .xml-cdata { \n"
+            + "  font-family: verdana,sans-serif; \n"
+            + "  font-size: 12px; \n"
+            + "} \n"
+            + ".xml-misc { \n"
+            + "  color: #000000; \n"
+            + "} \n"
+            + ".xml-element-name { \n"
+            + "  color: #cc0000; \n"
+            + "} \n"
+            + ".xml-attribute-name { \n"
+            + "  color: #660099; \n"
+            + "} \n"
+            + ".xml-attribute-content { \n"
+            + "  color: #000099; \n"
+            + "} \n"
+            + ".xml-element-content { \n"
+            + "  color: #000000; \n"
+            + "} \n"
+            + ".xml-comment { \n"
+            + "  color: #006600; \n"
+            + "} \n"
+            + ".xml-processing { \n"
+            + "  color: #cc0000; \n"
+            + "} \n"
+            + ".xml-cdata { \n"
+            + "  color: #006600; \n"
+            + "} \n"
+            +
+            /* forms */
+            ".search-form, .create-form, .upload-form input { \n"
+            + "  color: #294563; \n"
+            + "  font-family: verdana,sans-serif; \n"
+            + "  font-weight: bold; \n"
+            + "  text-align: left; \n"
+            + "  font-size: 12px; \n"
+            + "  border: 0px none #ffffff; \n"
+            + "} \n"
+            + ".search-form td[colspan=3] { \n"
+            + "  width: 480px; \n"
+            + "} \n"
+            + ".search-form input { \n"
+            + "  border: 2px solid #294563; \n"
+            + "  background-color: #f0f0ff; \n"
+            + "  width: 200px; \n"
+            + "} \n"
+            + ".search-form input[name=query] { \n"
+            + "  border: 2px solid #294563; \n"
+            + "  background-color: #f0f0ff; \n"
+            + "  width: 400px; \n"
+            + "} \n"
+            + ".search-form td, .create-form td, .upload-form td { \n"
+            + "  border: 0px none #ffffff; \n"
+            + "} \n"
+            + ".search-form select { \n"
+            + "  font-size: 10px; \n"
+            + " background-color: #f0f0ff; \n"
+            + "}	 \n"
+            + ".create-form td[colspan=2] { \n"
+            + "  width: 450px; \n"
+            + "} \n"
+            + ".create-form input { \n"
+            + "  border: 2px solid #294563; \n"
+            + "  background-color: #f0f0ff; \n"
+            + "  width: 300px; \n"
+            + "} \n"
+            + "select { \n"
+            + "  font-size: 10px; \n"
+            + "  background-color: #f0f0ff; \n"
+            + "} \n"
+            + ".upload-form input { \n"
+            + "  border: 2px solid #294563; \n"
+            + "  background-color: #f0f0ff; \n"
+            + "} \n"
+            + "--></style> \n"
+            + "<title>";
 
     protected static final String END_HTML_HEADER_SECTION =
-        "</title> \n" + "<body> \n\n";
+            "</title> \n" + "<body> \n\n";
 
     protected static final String LOGO_SECTION =
-        "<table width=\"100%\"><tr> \n"
+            "<table width=\"100%\"><tr> \n"
             + "<td width=\"100%\">&nbsp;</td> \n"
             + "<td align=\"right\" width=\"1px\"> \n"
             + "<div class=\"logo\"> xindice <div class=\"smallLogo\">(zeen-de-chay)</div> </div> \n"
             + "</td></tr></table> \n";
 
     protected static final String START_TABS_SECTION =
-        "<table class=\"tabs\" cellspacing=\"0\" cellpadding=\"0\"> \n"
+            "<table class=\"tabs\" cellspacing=\"0\" cellpadding=\"0\"> \n"
             + "  <tr> \n";
 
     protected static final String END_TABS_SECTION =
-        "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n"
+            "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n"
             + "  </tr>  \n"
             + "</table> \n";
 
     protected static final String START_TAB =
-        "    <td class=\"unselected\">&nbsp;";
+            "    <td class=\"unselected\">&nbsp;";
 
     protected static final String START_TAB_SELECTED =
-        "    <td class=\"selected\">&nbsp;";
+            "    <td class=\"selected\">&nbsp;";
 
     protected static final String TAB_SPACE =
-        "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n"
+            "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n"
             + "    <td width=\"1\" bgcolor=\"#ffffff\"><img width=\"1\" height=\"1\" alt=\"\"></td> \n";
 
     protected static final String TAB_SPACE_SELECTED =
-        "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n";
+            "    <td width=\"1\" bgcolor=\"#808080\"><img width=\"1\" height=\"\" alt=\"\"></td> \n";
 
     protected static final String END_TAB = "&nbsp;</td> \n";
 
     protected static final String LEFT_PATH_SECTION =
-        "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\"> \n"
+            "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\"> \n"
             + "  <tr> \n"
             + "    <td class=\"misc\">&nbsp;";
 
     protected static final String RIGHT_PATH_SECTION =
-        "</td> \n" + "    <td class=\"misc-right\">";
+            "</td> \n" + "    <td class=\"misc-right\">";
 
     protected static final String END_PATH_SECTION =
-        "</td> \n" + "  </tr>  \n" + "</table> \n" + "<br /> \n";
+            "</td> \n" + "  </tr>  \n" + "</table> \n" + "<br /> \n";
 
     protected static final String START_TABLE =
-        "<table cellspacing=\"0\" cellpadding=\"3\" class=\"contents\"> \n";
+            "<table cellspacing=\"0\" cellpadding=\"3\" class=\"contents\"> \n";
 
     protected static final String END_TABLE = "</table> \n";
 
@@ -754,10 +570,10 @@
     protected static final String END_TABLE_BOX = "</td> \n";
 
     protected static final String START_TABLE_BOX_TITLE =
-        "<td class=\"title\"> \n";
+            "<td class=\"title\"> \n";
 
     protected static final String FOOTER =
-        "\n<br /> \n"
+            "\n<br /> \n"
             + "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\"> \n"
             + "  <tr> \n"
             + "    <td class=\"misc\">&nbsp; "
@@ -774,72 +590,72 @@
     /* search form */
 
     protected static final String START_SEARCH_FORM =
-        "<form action=\"\" method=\"get\"> \n"
+            "<form action=\"\" method=\"get\"> \n"
             + "<table class=\"search-form\"> \n";
 
     protected static final String SEARCH_FROM_START_HIDDEN_VIEWER =
-        "<input name=\"viewer\" value=\"";
+            "<input name=\"viewer\" value=\"";
 
     protected static final String SEARCH_FROM_END_HIDDEN_VIEWER =
-        "\" type=\"hidden\" /> \n";
+            "\" type=\"hidden\" /> \n";
 
     protected static final String SEARCH_FROM_START_QUERY =
-        "<tr><td colspan=\"3\"> \n"
+            "<tr><td colspan=\"3\"> \n"
             + "      query:  \n"
             + "      <input name=\"query\" type=\"text\" value=\"";
 
     protected static final String SEARCH_FROM_END_QUERY =
-        "\" /><br /><div style=\"text-align:right;\">"
+            "\" /><br /><div style=\"text-align:right;\">"
             + "<input type=\"submit\" name=\"submit\" value=\"search\" "
             + " style=\"margin-top:10px; width:auto;\"/> \n"
             + "</div><br /> \n"
             + "</td></tr> \n";
 
     protected static final String SEARCH_FROM_START_NS_HEADER =
-        "<tr><td colspan=\"2\">optional namespaces:</td> \n"
-            + "<td>nuber of ns: <select name=\"nssize\" size=\"1\"> \n";
+            "<tr><td colspan=\"2\">optional namespaces:</td> \n"
+            + "<td>number of ns: <select name=\"nssize\" size=\"1\"> \n";
 
     protected static final String SEARCH_FROM_START_NS_HEADER_OPT = "<option>";
 
     protected static final String SEARCH_FROM_START_NS_HEADER_OPT_SEL =
-        "<option selected=\"selected\">";
+            "<option selected=\"selected\">";
 
     protected static final String SEARCH_FROM_END_NS_HEADER_OPT = "</option>";
 
     protected static final String SEARCH_FROM_END_NS_HEADER =
-        "</select></td></tr>"
+            "</select></td></tr>"
             + "<tr><td>&nbsp;</td><td>prefix</td><td>uri</td></tr> \n"
             + "<tr> \n";
 
     protected static final String SEARCH_FROM_START_NS = "<td>ns";
 
     protected static final String SEARCH_FROM_START_NS_PREFIX =
-        ":</td> \n" + "<td><input name=\"prefix";
+            ":</td> \n" + "<td><input name=\"prefix";
 
     protected static final String SEARCH_FROM_END_NS_PREFIX =
-        "\" type=\"text\" value=\"";
+            "\" type=\"text\" value=\"";
 
     protected static final String SEARCH_FROM_START_NS_URI =
-        "\"/></td> \n" + "<td><input name=\"uri";
+            "\"/></td> \n" + "<td><input name=\"uri";
 
     protected static final String SEARCH_FROM_MIDDLE_NS_URI =
-        "\" type=\"text\" value=\"";
+            "\" type=\"text\" value=\"";
 
     protected static final String SEARCH_FROM_END_NS_URI =
-        "\" /></td> \n" + "</tr> \n";
+            "\" /></td> \n" + "</tr> \n";
 
     protected static final String END_SEARCH_FORM =
-        "</table> \n" + "</form> \n";
+            "</table> \n" + "</form> \n";
 
     protected static final String START_CONFIG_FORM =
-        "<form action=\"?viewer=config\" method=\"post\"><textarea " +
-        "name=\"config\" style=\"width:100%;\" rows=\"8\">";
+            "<form action=\"?viewer=config\" method=\"post\"><textarea " +
+            "name=\"config\" style=\"width:100%;\" rows=\"8\">";
 
     protected static final String END_CONFIG_FORM =
-        "</textarea><br /><input type=\"submit\" name=\"submit\" value=\"update\"></form>";
+            "</textarea><br /><input type=\"submit\" name=\"submit\" value=\"update\"></form>";
 
     protected static final String CREATE_FORM_START =
-        "<form action=\"\" method=\"get\"> \n"
+            "<form action=\"\" method=\"get\"> \n"
             + "<input name=\"viewer\" value=\"create\" type=\"hidden\" /> \n"
             + "<table class=\"create-form\"> \n"
             + "<tr><td colspan=\"2\"> \n"
@@ -858,10 +674,10 @@
             + "	<option selected=\"selected\">";
 
     protected static final String CREATE_FORM_META_DEFAULT =
-        "</option> \n" + "	<option>";
+            "</option> \n" + "	<option>";
 
     protected static final String CREATE_FORM_META_END =
-        "</option>       \n"
+            "</option>       \n"
             + "  </select> \n"
             + "</td> \n"
             + " </tr> \n"
@@ -872,10 +688,10 @@
             + "	<option selected=\"selected\">";
 
     protected static final String CREATE_FORM_COMPRESSED_DEFAULT =
-        "</option> \n" + "	<option>";
+            "</option> \n" + "	<option>";
 
     protected static final String CREATE_FORM_COMPRESSED_END =
-        "</option>       \n"
+            "</option>       \n"
             + "  </select> \n"
             + "</td> \n"
             + " </tr> \n"
@@ -884,27 +700,32 @@
             + "<td><input name=\"filer\" type=\"text\" value=\"";
 
     protected static final String CREATE_FORM_FILER =
-        "\"/></td> \n" + " </tr> \n" + " </table> \n" + " </form> \n";
+            "\"/></td> \n" + " </tr> \n" + " </table> \n" + " </form> \n";
 
     protected static final String UPLOAD_FORM =
-        "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"> \n"
+            "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"> \n"
             + "<table class=\"upload-form\"> \n"
             + "<tr> \n"
             + "<td>upload file: </td> \n"
             + "<td><input name=\"file\" type=\"file\" /></td> \n"
             + "</td></tr> \n"
-            + "<tr><td> \n"
-            + "type: \n"
-            + "<select name=\"type\" size=\"1\"> \n"
+            + "<tr> \n"
+            + "<td>name: </td> \n"
+            + "<td><input name=\"name\" type=\"text\" /></td> \n"
+            + "</td></tr> \n"
+            + "<tr> \n"
+            + "<td>type: </td>\n"
+            + "<td><select name=\"type\" size=\"1\"> \n"
             + " <option>xml</option> \n"
             + " <option selected=\"selected\">detect</option> \n"
             + " <option>binary</option> \n"
             + "</select> \n"
-            + "</td><td><center> \n"
-            + "overwrite:  \n"
-            + "no<input type=\"radio\" name=\"overwrite\" value=\"false\" checked=\"checked\" /> \n"
+            + "</td></tr> \n"
+            + "<tr> \n"
+            + "<td>overwrite: </td>\n"
+            + "<td>no<input type=\"radio\" name=\"overwrite\" value=\"false\" checked=\"checked\" /> \n"
             + "yes<input type=\"radio\" name=\"overwrite\" value=\"true\" />       \n"
-            + "</center> </td></tr> \n"
+            + "</td></tr> \n"
             + "<tr><td> \n"
             + "<input type=\"submit\" name=\"submit\" value=\"upload\" /> \n"
             + "</td><td> "

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/HtmlViewerComponent.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu May 24 18:43:39 2007
@@ -1 +1 @@
-Author Date Id Revision
+Id Revision Author Date

Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionConfigurationViewer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionConfigurationViewer.java?view=diff&rev=541504&r1=541498&r2=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionConfigurationViewer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionConfigurationViewer.java Thu May 24 18:43:39 2007
@@ -27,102 +27,50 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.xindice.core.Collection;
-import org.apache.xindice.util.Configuration;
 import org.apache.xindice.util.ReadOnlyException;
-import org.apache.xindice.util.XindiceException;
 import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer;
 import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
-import org.apache.xindice.xml.TextWriter;
 import org.apache.xindice.xml.Xml2HtmlWriter;
-import org.apache.xindice.xml.dom.DOMParser;
-import org.w3c.dom.Document;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Xindice Html Viewer for Collection configuration.
  * 
- * @avalon.component
- * @avalon.service type=HtmlCollectionViewer
- * @x-avalon.info name=config
- * @x-avalon.lifestyle type=singleton
- *
  * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
  * @version $Id$
  */
-public class CollectionConfigurationViewer
-    extends HtmlViewerComponent
-    implements HtmlCollectionViewer {
-
-    public void execute(
-        HttpServletRequest req,
-        HttpServletResponse res,
-        Collection col)
-        throws ServletException, IOException {
+public class CollectionConfigurationViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
+
+    private static final Log log = LogFactory.getLog(CollectionConfigurationViewer.class);
+
+    public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
+            throws ServletException, IOException {
 
         String path = col.getCanonicalName();
         String title = "Collection Configuration for " + path;
 
         ServletOutputStream output = startViewer(title, path, res);
-
-        String configParam = req.getParameter("config");
-        if (configParam != null && configParam.length() > 0) {
-            printStartTable("Update Configuration", output);
-            printStartSingleTableBox(output);
-            try {
-                Document configDoc =
-                    DOMParser.toDocument(configParam.getBytes());
-                Configuration config = null;
-                if (configDoc != null) {
-                    config = new Configuration(configDoc, false);
-                }
-                if (config != null) {
-                    col.setConfig(config);
-                    col.getDatabase().flushConfig(); // update config
-                    output.print("<b>Configuration changed! </b>");
-                } else {
-                    output.print("Cannot read Configuration: <br /><pre>");
-                    output.print(htmlescape(configParam, true));
-                    output.print("</pre>");
-                }
-            } catch (XindiceException e1) {
-                e1.printStackTrace();
-                output.print("Cannot set Configuration: ");
-                output.print(e1.getMessage());
-            }
-            printEndSingleTableBox(output);
-            printEndTable(output);
-            output.print("<br />");
-        }
-
         printStartTable(title, output);
         printStartSingleTableBox(output);
 
-        String configHtml = "";
         try {
             Xml2HtmlWriter.write(col.getConfig().getElement(), output);
             printEndSingleTableBox(output);
             printEndTable(output);
-
-            configHtml =
-                htmlescape(TextWriter.toString(col.getConfig().getElement()));
-
         } catch (ReadOnlyException e) {
-            e.printStackTrace();
-            output.print("Sorry cannot read configuration: ");
+            log.error(e);
+            output.print("Cannot read configuration: ");
             output.print(e.getMessage());
         }
 
-        output.print("<br />");
-        printStartTable("Edit Configuration", output);
-        printStartSingleTableBox(output);
-        output.print(START_CONFIG_FORM);
-        output.print(configHtml);
-        output.print(END_CONFIG_FORM);
-        printEndSingleTableBox(output);
-        printEndTable(output);
-
         printEndSingleTableBox(output);
         printEndTable(output);
         finishViewer(output);
+    }
+
+    protected String getName() {
+        return "config";
     }
 
 }

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionConfigurationViewer.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu May 24 18:43:39 2007
@@ -1 +1 @@
-Author Date Id Revision
+Id Revision Author Date

Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionIndexesViewer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionIndexesViewer.java?view=diff&rev=541504&r1=541498&r2=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionIndexesViewer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionIndexesViewer.java Thu May 24 18:43:39 2007
@@ -30,336 +30,258 @@
 import org.apache.xindice.core.DBException;
 import org.apache.xindice.core.indexer.Indexer;
 import org.apache.xindice.util.Configuration;
-import org.apache.xindice.util.ReadOnlyException;
-import org.apache.xindice.webadmin.viewer.*;
 import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
+import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer;
 import org.apache.xindice.xml.dom.DocumentImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
  * Xindice Html Viewer for Collection Indexers.
- * 
- * @avalon.component
- * @avalon.service type=HtmlCollectionViewer
- * @x-avalon.info name=indexes
- * @x-avalon.lifestyle type=singleton
  *
  * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
  * @version $Id$
  */
-public class CollectionIndexesViewer
-	extends HtmlViewerComponent
-	implements HtmlCollectionViewer {
-	
-	protected static final String XINDICE_VAL_INDEXER = 
-		"org.apache.xindice.core.indexer.ValueIndexer";
-	
-	protected static final String XINDICE_NAME_INDEXER = 
-		"org.apache.xindice.core.indexer.NameIndexer"; 
-	
-	public void execute(HttpServletRequest req, HttpServletResponse res,
-		Collection col)	throws ServletException, IOException {
-    	
-		String path = col.getCanonicalName();
-		String title = "Collection Indexes for "+path;
-    	
-		ServletOutputStream output = startViewer(title, path, res);
-		
-		String name = req.getParameter("name");
-		if(name == null) {
-			name = "";
-		}
-		String pattern = req.getParameter("pattern");
-		if(pattern == null) {
-			pattern = "";
-		}
-		String type = req.getParameter("type");
-		if(type == null) {
-			type = "";
-		}
-		String pagesize = req.getParameter("pagesize");
-		if(pagesize == null) {
-			pagesize = "";
-		}
-		String maxkeysize = req.getParameter("maxkeysize");
-		if(maxkeysize == null) {
-			maxkeysize = "";
-		}
-		String update = req.getParameter("update");
-		String delete = req.getParameter("delete");
-		
-		if(update == null && name.length() > 0 && pattern.length() > 0) {
-			// create/update index
-			try {
-				createIndex(col, name, pattern, type, pagesize, maxkeysize);
-				// set the default values for the form
-				name = "";
-				pattern = "";
-				type = "";
-				pagesize = "";
-				maxkeysize = "";
-			} catch (DBException e1) {
-				e1.printStackTrace();
-				printStartTable("Message", output);
-				printStartSingleTableBox(output);
-				output.println("<b>Cannot update/create Indexer "+name+": "
-					+e1.getMessage()+"</b>");
-				printEndSingleTableBox(output);
-				printEndTable(output);
-				output.println("<br />\n");
-			} catch (ReadOnlyException e1) {
-				e1.printStackTrace();
-				printStartTable("Message", output);
-				printStartSingleTableBox(output);
-				output.println("<b>Cannot update/create Indexer "+name+": "
-					+e1.getMessage()+"</b>");
-				printEndSingleTableBox(output);
-				printEndTable(output);
-				output.println("<br />\n");
-			}
-		} else if(update != null && update.length() > 0) {
-			// get index parameters
-			try {
-				Configuration updateConf = col.getIndexer(update).getConfig();
-				name = update;
-				pattern = updateConf.getAttribute("pattern");
-				type = updateConf.getAttribute("type", "");
-				if(updateConf.getAttribute("class", "")
-					.equalsIgnoreCase(XINDICE_NAME_INDEXER)) {
-					type = "name";					
-				}
-				pagesize = updateConf.getAttribute("pagesize", "");
-				maxkeysize = updateConf.getAttribute("maxkeysize", "");
-			} catch (DBException e1) { // cannot get indexer
-				e1.printStackTrace();
-				printStartTable("Message", output);
-				printStartSingleTableBox(output);
-				output.println("<b>Cannot get Indexer "+update+": "
-					+e1.getMessage()+"</b>");
-				printEndSingleTableBox(output);
-				printEndTable(output);
-				output.println("<br />\n");
-			}
-		} else if(delete != null && delete.length() > 0) {
-			printStartTable("Message", output);
-			printStartSingleTableBox(output);
-			try {
-				// delete indexer
-				Indexer delIndex = col.getIndexer(delete);
-				if(delIndex != null) {
-					if(col.dropIndexer(delIndex)) {
-						output.println("<b>Indexer "+delete+" deleted!</b>");
-					} else {
-						output.println("<b>Cannot delete Indexer "+delete+"!</b>");
-					}
-				} else {
-					output.println("<b>Cannot get Indexer "+delete+"!</b>");
-				}
-			} catch (DBException e1) {
-				e1.printStackTrace();
-				output.println("<b>Cannot delete Indexer "+delete+": "
-					+e1.getMessage()+"</b>");
-			}
-			printEndSingleTableBox(output);
-			printEndTable(output);
-			output.println("<br />\n");
-		}
-		
-		
-		// form
-		printStartTable("Add/Update Index for "+path, output);
-		printStartSingleTableBox(output);
-		output.print(INDEXES_UPDATE_FORM_1);
-		output.print(name);
-		output.print(INDEXES_UPDATE_FORM_2);
-		output.print(pattern);
-		output.print(INDEXES_UPDATE_FORM_3);
-		printTypeSelector(type, output);
-		output.print(INDEXES_UPDATE_FORM_4);
-		output.print(pagesize);
-		output.print(INDEXES_UPDATE_FORM_5);
-		output.print(maxkeysize);
-		output.print(INDEXES_UPDATE_FORM_6);
-		printEndSingleTableBox(output);
-		printEndTable(output);
-		
-		output.print("<br />");
-		output.flush();
-				
-		try {
-			String[] indexes = col.listIndexers();
-			if(indexes.length == 0) {
-				String message = "Collection contains no Indexes!"; 
-				printStartTable(message, output);
-				printStartSingleTableBox(output);
-				output.print(message);
-				printEndSingleTableBox(output);
-				printEndTable(output);
-			} else {
-				String[] columnTitles = { "name", "pattern", "class", "type", 
-													"pagesize", "max key size", "delete"	};
-				printStartTable(columnTitles, output);
-				for(int i = 0; i < indexes.length; i++) {
-					Configuration thisConf = col.getIndexer(indexes[i]).getConfig();
-					String indexerName = thisConf.getAttribute("name");
-					String indexerType = thisConf.getAttribute("type", "");
-					String indexerClass = thisConf.getAttribute("class");
-					if(indexerClass.equalsIgnoreCase(XINDICE_NAME_INDEXER)) {
-						indexerClass = "NameIndexer";
-						indexerType = "name";
-					} else {
-						indexerClass = "ValueIndexer";
-					}
-					String[] contents = {
-						"<a href=\"?viewer="+this.thisViewer+"&update="
-							+indexerName+"\"><b>"+indexerName+"</b></a>",
-						"<b>"+thisConf.getAttribute("pattern")+"</b>",
-						indexerClass,
-						indexerType,
-						thisConf.getAttribute("pagesize", ""),
-						thisConf.getAttribute("maxkeysize", ""),
-						"<a href=\"?viewer="+this.thisViewer+"&delete="
-							+indexerName+"\">delete</a>"
-					};					
-					printTableRow(contents, output);
-				}
-				printEndTable(output);
-			}
-		} catch (DBException e) {
-			e.printStackTrace();
-			printStartTable("Error", output);
-			printStartSingleTableBox(output);
-			output.print("Sorry cannot get Indexes: ");
-			output.print(e.getMessage());
-			printEndSingleTableBox(output);
-			printEndTable(output);
-		}
-		finishViewer(output);
-	}
-	
-	protected Indexer createIndex(Collection col, String name, String pattern, 
-		String type, String pagesize, String maxkeysize)
-		throws DBException, ReadOnlyException {
-			
-		Document doc = new DocumentImpl();
-		Element idxEle;
-		Indexer indexer = col.getIndexer(name);
-		if(indexer != null) {
-			idxEle = indexer.getConfig().getElement();
-		} else {
-			idxEle = doc.createElement("index");
-		}
-		
-		idxEle.setAttribute("name", name);
-		idxEle.setAttribute("pattern", pattern);
-		idxEle.setAttribute("class", XINDICE_VAL_INDEXER);
-		
-		if(type.length() > 0) {
-			if(type.equalsIgnoreCase("name")) {
-				idxEle.setAttribute("class", XINDICE_NAME_INDEXER);
-			} else {
-				idxEle.setAttribute("type", type);
-			}
-		} else {
-			if(idxEle.hasAttribute("type")) {
-				idxEle.removeAttribute("type");
-			}
-		}
-		
-		if(pagesize.length() > 0) {
-			idxEle.setAttribute("pagesize", pagesize);
-		} else {
-			if(idxEle.hasAttribute("pagesize")) {
-				idxEle.removeAttribute("pagesize");
-			}
-		}
-		
-		if(maxkeysize.length() > 0) {
-			idxEle.setAttribute("maxkeysize", maxkeysize);
-		} else {
-			if(idxEle.hasAttribute("maxkeysize")) {
-				idxEle.removeAttribute("maxkeysize");
-			} 
-		}
-				
-		doc.appendChild(idxEle);
-		return col.createIndexer(new Configuration(doc, false));
-	}
-	
-	protected void printTypeSelector(String type, ServletOutputStream output) 
-		throws IOException {
-		output.println("<select name=\"type\" size\"1\">");
-		output.println("<option value=\"\">default</option>");
-		for(int i = 0; i < IDX_TYPES.length; i += 2) {
-			output.print("<option value=\""+IDX_TYPES[i]+"\"");
-			if(type.equalsIgnoreCase(IDX_TYPES[i])) {
-				output.print(" selected=\"selected\"");
-			}
-			output.print(" >"+IDX_TYPES[i]+": "+IDX_TYPES[i+1]+"</option>");
-		}
-		output.println("</select>");
-	}
-	
-	/** index types as pair: type, description */
-	protected static final String[] IDX_TYPES = {
-		"string", "Non-normalized string value",
-		"trimmed", "Normalized (whitespace stripped) string value",
-		"short", "16-bit signed short integer",
-		"int", "32-bit signed integer",
-		"long", "64-bit signed integer",
-		"float", "32-bit floating point value",
-		"double", "64-bit floating point value (XPath number)",
-		"byte", "8-bit signed byte",
-		"char", "16-bit signed character",
-		"boolean", "8-bit boolean value",
-		"name", "Store document keys that contain the pattern",
-	};
-	
-	protected static final String INDEXES_UPDATE_FORM_1 =
-	  "<form action=\"\" method=\"get\"> \n" +
-	  "<input name=\"viewer\" value=\"indexes\" type=\"hidden\" /> \n" +
-	  "<table class=\"upload-form\"> \n" +
-	  "<tr><td> \n" +
-	  "	index name:  \n" +
-	  "</td><td> \n" +    
-	  "	<input name=\"name\" type=\"text\" value=\"";
-
-	protected static final String INDEXES_UPDATE_FORM_2 =    
-	  "\" /> \n" +
-	  "</td><td> \n" +    
-	  "	pattern:  \n" +
-	  "</td><td> \n" +	
-	  "	<input name=\"pattern\" type=\"text\" value=\"";
-	
-	protected static final String INDEXES_UPDATE_FORM_3 =
-	  "\" /> \n" +
-	  " </td></tr> \n" +
-	  " <tr><td colspan=\"4\">&nbsp;</td></tr> \n" +
-	  "<tr><td> \n" +
-	  "	type:  \n" +
-	  "</td><td colspan=\"3\"> \n";
-	
-	protected static final String INDEXES_UPDATE_FORM_4 =
-	  " </td></tr> \n" +
-	  "<tr><td> \n" +
-	  "  pagesize:  \n" +
-	  "</td><td> \n" +    
-	  "  <input name=\"pagesize\" type=\"text\" value=\"";
-	  
-	protected static final String INDEXES_UPDATE_FORM_5 =
-	  "\" /> \n" +
-	  " </td><td> \n" +
-	  "  max key size:  \n" +
-	  "</td><td> \n" +    
-	  "  <input name=\"maxkeyesize\" type=\"text\" value=\"";		  	
-	
-	protected static final String INDEXES_UPDATE_FORM_6 =
-	  "\" /> \n" +  	
-	  " <tr><td colspan=\"4\" align=\"center\"> \n" +	
-	  "  <input type=\"submit\" name=\"submit\" value=\"add/update\" /> \n" +
-	  " </td></tr> \n" +	
-	  " </table> \n" +
-	  " </form> \n";
+public class CollectionIndexesViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
 
+    protected static final String XINDICE_VAL_INDEXER = "org.apache.xindice.core.indexer.ValueIndexer";
+    protected static final String XINDICE_NAME_INDEXER = "org.apache.xindice.core.indexer.NameIndexer";
+
+    private static final Log log = LogFactory.getLog(CollectionIndexesViewer.class);
+
+    public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
+            throws ServletException, IOException {
+
+        String path = col.getCanonicalName();
+        String title = "Collection Indexes for " + path;
+
+        ServletOutputStream output = startViewer(title, path, res);
+
+        String name = req.getParameter("name");
+        String pattern = req.getParameter("pattern");
+        String type = req.getParameter("type");
+        String pagesize = req.getParameter("pagesize");
+        String maxkeysize = req.getParameter("maxkeysize");
+
+        String delete = req.getParameter("delete");
+
+        if (name != null && pattern != null && name.length() > 0 && pattern.length() > 0) {
+            // create index
+            try {
+                createIndex(col, name, pattern, type, pagesize, maxkeysize);
+            } catch (DBException e) {
+                log.error(e);
+                printStartTable("Message", output);
+                printStartSingleTableBox(output);
+                output.println("<b>Cannot create Indexer " + name + ": " + e.getMessage() + "</b>");
+                printEndSingleTableBox(output);
+                printEndTable(output);
+                output.println("<br />\n");
+            }
+        } else if (delete != null && delete.length() > 0) {
+            printStartTable("Message", output);
+            printStartSingleTableBox(output);
+            try {
+                deleteIndex(col, delete, output);
+            } catch (DBException e) {
+                log.error(e);
+                output.println("<b>Cannot delete Indexer " + name + ": " + e.getMessage() + "</b>");
+            }
+            printEndSingleTableBox(output);
+            printEndTable(output);
+            output.println("<br />\n");
+        }
+
+        // form
+        printStartTable("Add Index for " + path, output);
+        printStartSingleTableBox(output);
+        output.print(INDEXES_UPDATE_FORM_1);
+        output.print(INDEXES_UPDATE_FORM_2);
+        output.print(INDEXES_UPDATE_FORM_3);
+        printTypeSelector(output);
+        output.print(INDEXES_UPDATE_FORM_4);
+        output.print(INDEXES_UPDATE_FORM_5);
+        output.print(INDEXES_UPDATE_FORM_6);
+        printEndSingleTableBox(output);
+        printEndTable(output);
+
+        output.print("<br />");
+        output.flush();
+
+        try {
+            listIndexes(col, output);
+        } catch (DBException e) {
+            log.error(e);
+            printStartTable("Error", output);
+            printStartSingleTableBox(output);
+            output.print("Sorry, cannot get Indexes: ");
+            output.print(e.getMessage());
+            printEndSingleTableBox(output);
+            printEndTable(output);
+        }
+        finishViewer(output);
+    }
+
+    private void listIndexes(Collection col, ServletOutputStream output) throws DBException, IOException {
+        String[] indexes = col.listIndexers();
+        if (indexes.length == 0) {
+            String message = "Collection contains no Indexes!";
+            printStartTable(message, output);
+            printStartSingleTableBox(output);
+            output.print(message);
+            printEndSingleTableBox(output);
+            printEndTable(output);
+        } else {
+            String[] columnTitles = {"name", "pattern", "class", "type",
+                                     "pagesize", "max key size", "delete"};
+            printStartTable(columnTitles, output);
+            for (int i = 0; i < indexes.length; i++) {
+                Configuration thisConf = col.getIndexer(indexes[i]).getConfig();
+                String indexerName = thisConf.getAttribute("name");
+                String indexerType = thisConf.getAttribute("type", "");
+                String indexerClass = thisConf.getAttribute("class");
+                if (indexerClass.equalsIgnoreCase(XINDICE_NAME_INDEXER)) {
+                    indexerClass = "NameIndexer";
+                    indexerType = "name";
+                } else {
+                    indexerClass = "ValueIndexer";
+                }
+                String[] contents = {
+                        "<b>" + indexerName + "</b>",
+                        "<b>" + thisConf.getAttribute("pattern") + "</b>",
+                        indexerClass,
+                        indexerType,
+                        thisConf.getAttribute("pagesize", ""),
+                        thisConf.getAttribute("maxkeysize", ""),
+                        "<a href=\"?viewer=" + getName() + "&delete="
+                        + indexerName + "\">delete</a>"
+                };
+                printTableRow(contents, output);
+            }
+            printEndTable(output);
+        }
+    }
+
+    private void deleteIndex(Collection col, String name, ServletOutputStream output) throws IOException, DBException {
+        // delete indexer
+        Indexer delIndex = col.getIndexer(name);
+        if (delIndex != null) {
+            if (col.dropIndexer(delIndex)) {
+                output.println("<b>Indexer " + name + " deleted!</b>");
+            } else {
+                output.println("<b>Cannot delete Indexer " + name + "!</b>");
+            }
+        } else {
+            output.println("<b>Cannot get Indexer " + name + "!</b>");
+        }
+    }
+
+    private Indexer createIndex(Collection col, String name, String pattern, String type, String pagesize, String maxkeysize)
+            throws DBException {
+
+        Document doc = new DocumentImpl();
+
+        Element idxEle = doc.createElement("index");
+        idxEle.setAttribute("name", name);
+        idxEle.setAttribute("pattern", pattern);
+        idxEle.setAttribute("class", XINDICE_VAL_INDEXER);
+
+        if (type != null && type.length() > 0) {
+            if (type.equalsIgnoreCase("name")) {
+                idxEle.setAttribute("class", XINDICE_NAME_INDEXER);
+            } else {
+                idxEle.setAttribute("type", type);
+            }
+        }
+
+        if (pagesize != null && pagesize.length() > 0) {
+            idxEle.setAttribute("pagesize", pagesize);
+        }
+
+        if (maxkeysize != null && maxkeysize.length() > 0) {
+            idxEle.setAttribute("maxkeysize", maxkeysize);
+        }
+
+        doc.appendChild(idxEle);
+        return col.createIndexer(new Configuration(doc, false));
+    }
+
+    private void printTypeSelector(ServletOutputStream output) throws IOException {
+        output.println("<select name=\"type\" size\"1\">");
+        output.println("<option value=\"\">default</option>");
+        for (int i = 0; i < IDX_TYPES.length; i += 2) {
+            output.print("<option value=\"" + IDX_TYPES[i] + "\"");
+            output.print(" >" + IDX_TYPES[i] + ": " + IDX_TYPES[i + 1] + "</option>");
+        }
+        output.println("</select>");
+    }
+
+    /**
+     * index types as pair: type, description
+     */
+    private static final String[] IDX_TYPES = {
+            "string", "Non-normalized string value",
+            "trimmed", "Normalized (whitespace stripped) string value",
+            "short", "16-bit signed short integer",
+            "int", "32-bit signed integer",
+            "long", "64-bit signed integer",
+            "float", "32-bit floating point value",
+            "double", "64-bit floating point value (XPath number)",
+            "byte", "8-bit signed byte",
+            "char", "16-bit signed character",
+            "boolean", "8-bit boolean value",
+            "name", "Store document keys that contain the pattern",
+    };
+
+    private static final String INDEXES_UPDATE_FORM_1 =
+            "<form action=\"\" method=\"get\"> \n" +
+            "<input name=\"viewer\" value=\"indexes\" type=\"hidden\" /> \n" +
+            "<table class=\"upload-form\"> \n" +
+            "<tr><td> \n" +
+            "	index name:  \n" +
+            "</td><td> \n" +
+            "	<input name=\"name\" type=\"text\" value=\"";
+
+    private static final String INDEXES_UPDATE_FORM_2 =
+            "\" /> \n" +
+            "</td><td> \n" +
+            "	pattern:  \n" +
+            "</td><td> \n" +
+            "	<input name=\"pattern\" type=\"text\" value=\"";
+
+    private static final String INDEXES_UPDATE_FORM_3 =
+            "\" /> \n" +
+            " </td></tr> \n" +
+            " <tr><td colspan=\"4\">&nbsp;</td></tr> \n" +
+            "<tr><td> \n" +
+            "	type:  \n" +
+            "</td><td colspan=\"3\"> \n";
+
+    private static final String INDEXES_UPDATE_FORM_4 =
+            " </td></tr> \n" +
+            "<tr><td> \n" +
+            "  pagesize:  \n" +
+            "</td><td> \n" +
+            "  <input name=\"pagesize\" type=\"text\" value=\"";
+
+    private static final String INDEXES_UPDATE_FORM_5 =
+            "\" /> \n" +
+            " </td><td> \n" +
+            "  max key size:  \n" +
+            "</td><td> \n" +
+            "  <input name=\"maxkeyesize\" type=\"text\" value=\"";
+
+    private static final String INDEXES_UPDATE_FORM_6 =
+            "\" /> \n" +
+            " <tr><td colspan=\"4\" align=\"center\"> \n" +
+            "  <input type=\"submit\" name=\"submit\" value=\"add\" /> \n" +
+            " </td></tr> \n" +
+            " </table> \n" +
+            " </form> \n";
+
+    protected String getName() {
+        return "indexes";
+    }
 }

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CollectionIndexesViewer.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu May 24 18:43:39 2007
@@ -1 +1 @@
-Author Date Id Revision
+Id Revision Author Date

Added: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java?view=auto&rev=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java (added)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java Thu May 24 18:43:39 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.xindice.webadmin.viewer.components;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.w3c.dom.Document;
+
+import org.apache.xindice.core.Collection;
+import org.apache.xindice.core.DBException;
+import org.apache.xindice.core.data.Entry;
+import org.apache.xindice.webadmin.viewer.*;
+import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
+import org.apache.xindice.xml.Xml2HtmlWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Xindice Html Contents Viewer for Resources
+ *
+ * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
+ * @version $Id$
+ */
+public class ContentResourceViewer extends HtmlViewerComponent implements HtmlResourceViewer {
+
+    private static final Log log = LogFactory.getLog(ContentResourceViewer.class);
+
+    public void execute(HttpServletRequest req, HttpServletResponse res, Collection col, String name)
+            throws ServletException, IOException {
+
+        String path = col.getCanonicalName() + "/" + name;
+        String title = "Document " + path;
+
+        Entry resource;
+        try {
+            resource = col.getEntry(name);
+        } catch (DBException e) {
+            log.error(e);
+            throw new ServletException(e);
+        }
+
+        ServletOutputStream output = startViewer(title, path, res);
+        printStartTable(title, output);
+        printStartSingleTableBox(output);
+        output.print("<a href=\"./?viewer=default\">up to parent collection</a>");
+        printEndSingleTableBox(output);
+        printStartSingleTableBox(output);
+        if (resource.getEntryType() == Entry.DOCUMENT) {
+            Xml2HtmlWriter.write((Document) resource.getValue(), output);
+        } else {
+            output.print("binary resource <a href=\"./");
+            output.print(name);
+            output.print("\">view content</a>");
+        }
+        printEndSingleTableBox(output);
+        printEndTable(output);
+        finishViewer(output);
+    }
+
+    protected String getName() {
+        return "content";
+    }
+}

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/ContentResourceViewer.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision Author Date

Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CreateCollectionViewer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CreateCollectionViewer.java?view=diff&rev=541504&r1=541498&r2=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CreateCollectionViewer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CreateCollectionViewer.java Thu May 24 18:43:39 2007
@@ -26,33 +26,25 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.xindice.core.Collection;
 import org.apache.xindice.util.Configuration;
 import org.apache.xindice.webadmin.util.CollectionConfigurationHelper;
 import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer;
 import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Xindice Html Viewer for creating a new collection.
- * 
- * @avalon.component
- * @avalon.service type=HtmlCollectionViewer
- * @x-avalon.info name=create
- * @x-avalon.lifestyle type=singleton
  *
  * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
  * @version $Id$
  */
-public class CreateCollectionViewer
-    extends HtmlViewerComponent
-    implements HtmlCollectionViewer {
-
-    public void execute(
-        HttpServletRequest req,
-        HttpServletResponse res,
-        Collection col)
-        throws ServletException, IOException {
+public class CreateCollectionViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
+    private static final Log log = LogFactory.getLog(CreateCollectionViewer.class);
+
+    public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
+            throws ServletException, IOException {
 
         String path = col.getCanonicalName();
         String title = "Create Subcollection in " + path;
@@ -65,64 +57,24 @@
         String filer = req.getParameter("filer");
 
         if (name == null || name.length() == 0) {
-
-            try {
-                CollectionConfigurationHelper helper;
-                Object object =
-                    m_serviceManager.lookup(CollectionConfigurationHelper.ROLE);
-                if (object instanceof ServiceSelector) {
-                    helper =
-                        (CollectionConfigurationHelper)
-                            ((ServiceSelector)object).select(
-                            "col-config");
-                } else {
-                    helper = (CollectionConfigurationHelper)object;
-                }
-
-                printStartTable(title, output);
-                printStartSingleTableBox(output);
-                output.print(CREATE_FORM_START); 
-                output.print(helper.getDefaultInlineMetadata());
-				output.print(CREATE_FORM_META_DEFAULT);
-				output.print(!helper.getDefaultInlineMetadata());
-				output.print(CREATE_FORM_META_END);
-				output.print(helper.getDefaultCompressed());
-				output.print(CREATE_FORM_COMPRESSED_DEFAULT);
-				output.print(!helper.getDefaultCompressed());
-				output.print(CREATE_FORM_COMPRESSED_END);
-				output.print(helper.getDefaultFilerClass());
-                output.print(CREATE_FORM_FILER);
-                printEndSingleTableBox(output);
-                printEndTable(output);
-            } catch (Exception e) {
-                if (getLogger().isWarnEnabled()) {
-                    getLogger().error(
-                        "Could not get CollectionConfigurationHelper!");
-                }
-                e.printStackTrace();
-                throw new ServletException(e);
-            }
+            printStartTable(title, output);
+            printStartSingleTableBox(output);
+            output.print(CREATE_FORM_START);
+            output.print(CollectionConfigurationHelper.getDefaultInlineMetadata());
+            output.print(CREATE_FORM_META_DEFAULT);
+            output.print(!CollectionConfigurationHelper.getDefaultInlineMetadata());
+            output.print(CREATE_FORM_META_END);
+            output.print(CollectionConfigurationHelper.getDefaultCompressed());
+            output.print(CREATE_FORM_COMPRESSED_DEFAULT);
+            output.print(!CollectionConfigurationHelper.getDefaultCompressed());
+            output.print(CREATE_FORM_COMPRESSED_END);
+            output.print(CollectionConfigurationHelper.getDefaultFilerClass());
+            output.print(CREATE_FORM_FILER);
+            printEndSingleTableBox(output);
+            printEndTable(output);
         } else {
             try {
-                CollectionConfigurationHelper helper;
-                Object object =
-                    m_serviceManager.lookup(CollectionConfigurationHelper.ROLE);
-                if (object instanceof ServiceSelector) {
-                    helper =
-                        (CollectionConfigurationHelper)
-                            ((ServiceSelector)object).select(
-                            "col-config");
-                } else {
-                    helper = (CollectionConfigurationHelper)object;
-                }
-
-                Configuration config =
-                    helper.createConfiguration(
-                        name,
-                        compressed,
-                        inlineMeta,
-                        filer);
-
+                Configuration config = CollectionConfigurationHelper.createConfiguration(name, compressed, inlineMeta, filer);
                 col.createCollection(name, config);
 
                 printStartTable(title, output);
@@ -135,8 +87,7 @@
                 printEndSingleTableBox(output);
                 printEndTable(output);
             } catch (Exception e) {
-                e.printStackTrace();
-
+                log.error(e);
                 title = "Error while creating new Collection!";
                 printStartTable(title, output);
                 printStartSingleTableBox(output);
@@ -150,6 +101,10 @@
         }
 
         finishViewer(output);
+    }
+
+    protected String getName() {
+        return "create";
     }
 
 }

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/CreateCollectionViewer.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu May 24 18:43:39 2007
@@ -1 +1 @@
-Author Date Id Revision
+Id Revision Author Date

Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/DeleteCollectionViewer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/DeleteCollectionViewer.java?view=diff&rev=541504&r1=541498&r2=541504
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/DeleteCollectionViewer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/DeleteCollectionViewer.java Thu May 24 18:43:39 2007
@@ -30,91 +30,102 @@
 import org.apache.xindice.core.Collection;
 import org.apache.xindice.webadmin.viewer.*;
 import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Xindice Html Viewer for deleting a collection.
- * 
- * @avalon.component
- * @avalon.service type=HtmlCollectionViewer
- * @x-avalon.info name=delete
- * @x-avalon.lifestyle type=singleton
  *
  * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
  * @version $Id$
  */
-public class DeleteCollectionViewer
-	extends HtmlViewerComponent
-	implements HtmlCollectionViewer {
-
-	public void execute(
-		HttpServletRequest req,
-		HttpServletResponse res,
-		Collection col)
-		throws ServletException, IOException {
-			
-		String colName = col.getName();
-		String path = col.getCanonicalName();
-		
-		String title = "Delete Collection "+colName;
-
-		String action = req.getParameter("action");
-		String redirect = req.getParameter("redirect");
-		if(redirect == null) {
-			redirect = "";
-		}
-		if(action == null || !action.equals("yes")) {
-			ServletOutputStream output = startViewer(title, path, res);
-			printStartTable(title, output);
-			printStartSingleTableBox(output);
-			output.print("Do you really want to delete the collection ");
-			output.print(colName);
-			output.print("? <a href=\"javascript:history.back()\">no</a> ");
-			output.print(" <a href=\"?viewer=delete&action=yes&redirect=");
-			output.print(redirect);
-			output.print("\">yes</a>");
-			printEndSingleTableBox(output);
-			printEndTable(output);
-			finishViewer(output);
-		} else {
-			try {
-				//	delete collection
-				col.getParentCollection().dropCollection(col);
-
-				// display output or redirect
-				if(redirect.length() > 0) {
-					res.sendRedirect(redirect);
-				} else {
-					ServletOutputStream output = startViewer(title, path, res);
-					printStartTable(title, output);
-					printStartSingleTableBox(output);
-					output.print( "<a href=\"../?viewer=default\">up to parent collection</a>");
-					printEndSingleTableBox(output);
-					printStartSingleTableBox(output);
-					output.print("<b>Collection ");
-					output.print(colName);
-					output.print(" deleted!</b>" );
-					printEndSingleTableBox(output);
-					printEndTable(output);
-					finishViewer(output);
-				}
-			} catch (DBException e) {
-				e.printStackTrace();
-				ServletOutputStream output = startViewer(title, path, res);
-				printStartTable(title, output);
-				printStartSingleTableBox(output);
-				output.print( "<a href=\"../../?viewer=default\">up to parent collection</a>");
-				printEndSingleTableBox(output);
-				printStartSingleTableBox(output);
-				output.print("Cannot delete Collection");
-				output.print(colName);
-				output.print("! <br />");
-				output.print(e.getMessage());
-				printEndSingleTableBox(output);
-				printEndTable(output);
-				finishViewer(output);
-			}
-		}
+public class DeleteCollectionViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
+    private static final Log log = LogFactory.getLog(DeleteCollectionViewer.class);
 
-	}
+    public void execute(HttpServletRequest req, HttpServletResponse res, Collection col) throws ServletException, IOException {
+
+        String colName = col.getName();
+        String path = col.getCanonicalName();
+
+        String title = "Delete Collection " + colName;
+
+        String action = req.getParameter("action");
+        String redirect = req.getParameter("redirect");
+        if (redirect == null) {
+            redirect = "";
+        }
+        if (!"yes".equals(action)) {
+            ServletOutputStream output = startViewer(title, path, res);
+            printStartTable(title, output);
+            printStartSingleTableBox(output);
+            output.print("Do you really want to delete the collection ");
+            output.print(colName);
+            output.print("? <a href=\"javascript:history.back()\">no</a> ");
+            output.print(" <a href=\"?viewer=delete&action=yes&redirect=");
+            output.print(redirect);
+            output.print("\">yes</a>");
+            printEndSingleTableBox(output);
+            printEndTable(output);
+            finishViewer(output);
+        } else {
+            try {
+                // check if it is a database
+                if (col.getParentCollection() == null) {
+                    ServletOutputStream output = startViewer(title, path, res);
+                    title = "Error while deleting Collection!";
+                    printStartTable(title, output);
+                    printStartSingleTableBox(output);
+                    output.print("<b>Database cannot be deleted. Please manually change configuration files to delete or add a database.");
+                    output.print("</b><br />");
+                    printEndSingleTableBox(output);
+                    printEndTable(output);
+                    finishViewer(output);
+                    return;
+                }
+
+                //	delete collection
+                col.getParentCollection().dropCollection(col);
+
+                // display output or redirect
+                if (redirect.length() > 0) {
+                    res.sendRedirect(redirect);
+                } else {
+                    ServletOutputStream output = startViewer(title, path, res);
+                    printStartTable(title, output);
+                    printStartSingleTableBox(output);
+                    output.print("<a href=\"../?viewer=default\">up to parent collection</a>");
+                    printEndSingleTableBox(output);
+                    printStartSingleTableBox(output);
+                    output.print("<b>Collection ");
+                    output.print(colName);
+                    output.print(" deleted!</b>");
+                    printEndSingleTableBox(output);
+                    printEndTable(output);
+                    finishViewer(output);
+                }
+            } catch (DBException e) {
+                log.error(e);
+
+                ServletOutputStream output = startViewer(title, path, res);
+                printStartTable(title, output);
+                printStartSingleTableBox(output);
+                output.print("<a href=\"../../?viewer=default\">up to parent collection</a>");
+                printEndSingleTableBox(output);
+                printStartSingleTableBox(output);
+                output.print("Cannot delete Collection");
+                output.print(colName);
+                output.print("! <br />");
+                output.print(e.getMessage());
+                printEndSingleTableBox(output);
+                printEndTable(output);
+                finishViewer(output);
+            }
+        }
+
+    }
+
+    protected String getName() {
+        return "delete";
+    }
 
 }

Propchange: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/viewer/components/DeleteCollectionViewer.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu May 24 18:43:39 2007
@@ -1 +1 @@
-Author Date Id Revision
+Id Revision Author Date