Author: deepal
Date: Tue Dec 18 04:13:10 2007
New Revision: 11415

Log:

added a way to save the configuration file back to the web-inf

Removed:
   trunk/registry/modules/webapps/src/main/webapp/index.html
Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   trunk/registry/modules/webapps/conf/web.xml

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
       (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfiguration.java
       Tue Dec 18 04:13:10 2007
@@ -49,7 +49,7 @@
      * @throws org.wso2.registry.RegistryException
      *          : if something went wrong
      */
-    public void populateRegistryConfig(String xmlLocation, ServletConfig 
servletConfig) throws RegistryException {
+    public void  populateRegistryConfig(String xmlLocation, ServletConfig 
servletConfig) throws RegistryException {
         InputStream in;
         if (xmlLocation != null) {
             try {

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
    Tue Dec 18 04:13:10 2007
@@ -19,6 +19,7 @@
 
 package org.wso2.registry.servlet;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.Registry;
@@ -44,6 +45,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.sql.DataSource;
+import java.io.FileOutputStream;
 import java.io.IOException;
 
 /**
@@ -56,6 +58,8 @@
 
     //To store the conetxt path
     private String contextRoot = null;
+    private String configPath;
+    private RegistryConfiguration registryConfiguration;
 
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
@@ -64,9 +68,9 @@
         try {
             // read the registry.xml file from the configured location. if not 
configured, read the
             // default registry.xml file bundled with the webapp.
-            String configPath = 
config.getInitParameter(RegistryConstants.REGISTRY_CONFIG_PATH);
-            RegistryConfiguration registryConfiguration = new 
RegistryConfiguration();
-            registryConfiguration.populateRegistryConfig(configPath,config);
+            configPath = 
config.getInitParameter(RegistryConstants.REGISTRY_CONFIG_PATH);
+            registryConfiguration = new RegistryConfiguration();
+            registryConfiguration.populateRegistryConfig(configPath, config);
             config.getServletContext().
                     setAttribute(RegistryConstants.REGISTRY_CONFIG, 
registryConfiguration);
 
@@ -171,8 +175,6 @@
                          HttpServletResponse response)
             throws ServletException, IOException {
         initContextRoot(request);
-         request.getRequestDispatcher("/web")
-                    .forward(request, response);
     }
 
     /**
@@ -200,4 +202,22 @@
         httpServletRequest.getRequestDispatcher(jspName)
                 .include(httpServletRequest, httpServletResponse);
     }
+
+
+    public void destroy() {
+        super.destroy();
+        if (configPath == null) {
+            configPath = getServletConfig().getServletContext().
+                    getRealPath("/WEB-INF/registry.xml");
+        }
+        try {
+            FileOutputStream fio = new FileOutputStream(configPath);
+            OMElement registryXml = 
registryConfiguration.getRegistryConfigAsXML();
+            registryXml.serialize(fio);
+            fio.flush();
+            fio.close();
+        } catch (Exception e) {
+            //
+        }
+    }
 }

Modified: trunk/registry/modules/webapps/conf/web.xml
==============================================================================
--- trunk/registry/modules/webapps/conf/web.xml (original)
+++ trunk/registry/modules/webapps/conf/web.xml Tue Dec 18 04:13:10 2007
@@ -35,16 +35,10 @@
         <servlet-name>WebServlet</servlet-name>
         <url-pattern>/web/*</url-pattern>
     </servlet-mapping>
-
     <servlet-mapping>
         <servlet-name>WebServlet</servlet-name>
         <url-pattern>/system/*</url-pattern>
     </servlet-mapping>
-    <welcome-file-list>
-        <welcome-file>index.jsp</welcome-file>
-        <welcome-file>index.html</welcome-file>
-    </welcome-file-list>
-
     <!-- resource-ref>
         <description>DB Connection</description>
         <res-ref-name>jdbc/WSO2RegistryDB</res-ref-name>

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to