incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1412583 - /sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
Date Thu, 22 Nov 2012 15:18:05 GMT
Author: bdelacretaz
Date: Thu Nov 22 15:18:04 2012
New Revision: 1412583

URL: http://svn.apache.org/viewvc?rev=1412583&view=rev
Log:
SLING-2674 - take new run mode options into account when starting on an older Sling instance

Modified:
    sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java

Modified: sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java?rev=1412583&r1=1412582&r2=1412583&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
(original)
+++ sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
Thu Nov 22 15:18:04 2012
@@ -74,7 +74,14 @@ public class SlingSettingsServiceImpl
     public SlingSettingsServiceImpl(final BundleContext context) {
         this.setupSlingHome(context);
         final boolean isInstall = this.setupSlingId(context);
-        this.setupRunModes(context, isInstall);
+        
+        // Detect if upgrading from a previous version (where OPTIONS_FILE did not exist),
+        // as in terms of run modes this needs to be handled like an install
+        final File options = context.getDataFile(OPTIONS_FILE);
+        final boolean isUpgrade = !isInstall && !options.exists();
+                
+        logger.info("isInstall={}, isUpgrade={}", isInstall, isUpgrade);
+        this.setupRunModes(context, isInstall, isUpgrade);
 
     }
 
@@ -157,7 +164,7 @@ public class SlingSettingsServiceImpl
      */
     @SuppressWarnings("unchecked")
     private void setupRunModes(final BundleContext context,
-            final boolean isInstall) {
+            final boolean isInstall, final boolean isUpgrade) {
         final Set<String> modesSet = new HashSet<String>();
 
         // check configuration property first
@@ -172,7 +179,7 @@ public class SlingSettingsServiceImpl
         // now options
         this.handleOptions(modesSet, context.getProperty(RUN_MODE_OPTIONS));
         // now install options
-        if ( isInstall ) {
+        if ( isInstall || isUpgrade) {
             final List<Options> optionsList = this.handleOptions(modesSet, context.getProperty(RUN_MODE_INSTALL_OPTIONS));
             if ( optionsList != null ) {
                 final File file = context.getDataFile(OPTIONS_FILE);



Mime
View raw message