sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-settings] 04/09: SLING-2674 - take new run mode options into account when starting on an older Sling instance
Date Tue, 07 Nov 2017 10:16:40 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.settings-1.2.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-settings.git

commit 3ffd48407d5beeba6b57e8ab2b6cf7b78a843a07
Author: Bertrand Delacretaz <bdelacretaz@apache.org>
AuthorDate: Thu Nov 22 15:18:04 2012 +0000

    SLING-2674 - take new run mode options into account when starting on an older Sling instance
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/settings@1412583
13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/settings/impl/SlingSettingsServiceImpl.java       | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java b/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
index 7447681..b998690 100644
--- a/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
+++ b/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
@@ -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);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Mime
View raw message