Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 54593 invoked from network); 2 Mar 2011 16:51:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Mar 2011 16:51:41 -0000 Received: (qmail 48081 invoked by uid 500); 2 Mar 2011 16:51:41 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 48016 invoked by uid 500); 2 Mar 2011 16:51:39 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 48009 invoked by uid 99); 2 Mar 2011 16:51:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 16:51:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 16:51:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F2B6523889EA; Wed, 2 Mar 2011 16:51:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076290 - /sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/SlingServerRepository.java Date: Wed, 02 Mar 2011 16:51:14 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110302165114.F2B6523889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Wed Mar 2 16:51:14 2011 New Revision: 1076290 URL: http://svn.apache.org/viewvc?rev=1076290&view=rev Log: SLING-2013 Support relative home property. To be resolved against sling.home if present or against current user directory if sling.home is not set. Also support default assumption (repository.xml is configuration inside home directory) if config property is missing or empty. 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=1076290&r1=1076289&r2=1076290&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 Wed Mar 2 16:51:14 2011 @@ -38,6 +38,7 @@ import org.apache.sling.jcr.base.Abstrac import org.apache.sling.jcr.jackrabbit.server.impl.security.AdministrativeCredentials; import org.apache.sling.jcr.jackrabbit.server.impl.security.AnonCredentials; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; import org.osgi.service.log.LogService; /** @@ -98,6 +99,19 @@ public class SlingServerRepository exten String configURLObj = (String) environment.get(REPOSITORY_CONFIG_URL); String home = (String) environment.get(REPOSITORY_HOME_DIR); + // ensure absolute home (path) + File homeFile = new File(home); + if (!homeFile.isAbsolute()) { + BundleContext context = getComponentContext().getBundleContext(); + String slingHomePath = context.getProperty("sling.home"); + if (slingHomePath != null) { + homeFile = new File(slingHomePath, home); + } else { + homeFile = homeFile.getAbsoluteFile(); + } + home = homeFile.getAbsolutePath(); + } + // somewhat dirty hack to have the derby.log file in a sensible // location, but don't overwrite anything already set if (System.getProperty("derby.stream.error.file") == null) { @@ -108,36 +122,41 @@ public class SlingServerRepository exten InputStream ins = null; try { - // check whether the URL is a file path - File configFile = new File(configURLObj); - if (configFile.canRead()) { + RepositoryConfig crc; + if (configURLObj != null && configURLObj.length() > 0) { + // 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()); + ins = new FileInputStream(configFile); + log(LogService.LOG_INFO, "Using configuration file " + configFile.getAbsolutePath()); - } else { + } else { - try { + 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"); + URL configURL = new URL(configURLObj); + ins = configURL.openStream(); + log(LogService.LOG_INFO, "Using configuration URL " + configURL); - final Bundle bundle = getComponentContext().getBundleContext().getBundle(); - SlingServerRepository.copyFile(bundle, "repository.xml", configFile); + } catch (MalformedURLException mue) { - ins = new FileInputStream(configFile); - log(LogService.LOG_INFO, "Using configuration file " + configFile.getAbsolutePath()); + 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()); + } } + crc = RepositoryConfig.create(ins, home); + } else { + crc = RepositoryConfig.create(homeFile); } - RepositoryConfig crc = RepositoryConfig.create(ins, home); return RepositoryImpl.create(crc); } catch (IOException ioe) {