Skip to content

Commit

Permalink
*) Adding possibility to do a settings migration on yacy startup
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1149 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed Dec 1, 2005
1 parent eb9dacc commit b604654
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
14 changes: 11 additions & 3 deletions source/de/anomic/server/serverAbstractSwitch.java
Expand Up @@ -49,6 +49,7 @@
import java.util.TreeMap;

import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyVersion;

public abstract class serverAbstractSwitch implements serverSwitch {

Expand Down Expand Up @@ -77,7 +78,7 @@ public serverAbstractSwitch(String rootPath, String initPath, String configPath)
new File(configFile.getParent()).mkdir();

// predefine init's
Map initProps;
Map initProps, removedProps = new HashMap();
if (initFile.exists()) initProps = serverFileUtils.loadHashMap(initFile); else initProps = new HashMap();

// load config's from last save
Expand All @@ -89,10 +90,17 @@ public serverAbstractSwitch(String rootPath, String initPath, String configPath)
Iterator i = configProps.keySet().iterator();
String key;
while (i.hasNext()) {
key = (String) i.next();
if (!(initProps.containsKey(key))) i.remove();
key = (String) i.next();
if (!(initProps.containsKey(key))) {
removedProps.put(key,this.configProps.get(key));
i.remove();
}
}

// doing a config settings migration
HashMap migratedSettings = yacyVersion.migrateSwitchboardConfigSettings(this,(HashMap) removedProps);
configProps.putAll(migratedSettings);

// merge new props from init to config
// this is necessary for migration, when new properties are attached
initProps.putAll(configProps);
Expand Down
11 changes: 11 additions & 0 deletions source/de/anomic/yacy/yacyVersion.java
@@ -1,6 +1,9 @@
package de.anomic.yacy;

import java.util.HashMap;

import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverAbstractSwitch;
import de.anomic.server.serverCodings;

public final class yacyVersion {
Expand Down Expand Up @@ -42,4 +45,12 @@ public static void migrate(plasmaSwitchboard sb){
sb.setConfig("downloadAccountBase64", "");
}
}

public static HashMap migrateSwitchboardConfigSettings(serverAbstractSwitch sb, HashMap removedSettings) {
if ((removedSettings == null)||(removedSettings.size() == 0)) return null;
HashMap migratedSettings = new HashMap();

return migratedSettings;

}
}

0 comments on commit b604654

Please sign in to comment.