You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2010/01/26 15:32:44 UTC

svn commit: r903236 - /sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java

Author: fmeschbe
Date: Tue Jan 26 14:32:43 2010
New Revision: 903236

URL: http://svn.apache.org/viewvc?rev=903236&view=rev
Log:
SLING-1328 Try to recover missing repository.xml file if it has been deleted while the SlingServletRepository component was inactive.

Modified:
    sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java

Modified: sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java?rev=903236&r1=903235&r2=903236&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java Tue Jan 26 14:32:43 2010
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Dictionary;
 
@@ -110,12 +111,30 @@
             // check whether the URL is a file path
             File configFile = new File(configURLObj);
             if (configFile.canRead()) {
+
                 ins = new FileInputStream(configFile);
                 log(LogService.LOG_INFO, "Using configuration file " + configFile.getAbsolutePath());
+
             } else {
-                URL configURL = new URL(configURLObj);
-                ins = configURL.openStream();
-                log(LogService.LOG_INFO, "Using configuration URL " + configURL);
+
+                try {
+
+                    URL configURL = new URL(configURLObj);
+                    ins = configURL.openStream();
+                    log(LogService.LOG_INFO, "Using configuration URL " + configURL);
+
+                } catch (MalformedURLException mue) {
+
+                    log(LogService.LOG_INFO, "Configuration File "
+                        + configFile.getAbsolutePath()
+                        + " has been lost, trying to recreate");
+
+                    final Bundle bundle = getComponentContext().getBundleContext().getBundle();
+                    SlingServerRepository.copyFile(bundle, "repository.xml", configFile);
+
+                    ins = new FileInputStream(configFile);
+                    log(LogService.LOG_INFO, "Using configuration file " + configFile.getAbsolutePath());
+                }
             }
 
             RepositoryConfig crc = RepositoryConfig.create(ins, home);
@@ -165,9 +184,9 @@
                 "Repository is not a RepositoryImpl, nothing to do");
         }
     }
-    
-    
-    
+
+
+
 
     //---------- Helper -------------------------------------------------------