Skip to content

Commit

Permalink
0004082: Sort the properties alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Aug 27, 2019
1 parent ad4f0b6 commit 34cb660
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Expand Up @@ -45,6 +45,7 @@
import org.apache.commons.lang.StringUtils;
import org.jumpmind.db.util.BasicDataSourcePropertyConstants;
import org.jumpmind.properties.DefaultParameterParser.ParameterMetaData;
import org.jumpmind.properties.SortedProperties;
import org.jumpmind.properties.TypedProperties;
import org.jumpmind.security.ISecurityService;
import org.jumpmind.security.SecurityConstants;
Expand Down Expand Up @@ -379,11 +380,12 @@ public ISymmetricEngine install(Properties passedInProperties) throws Exception

File enginesDir = new File(AbstractCommandLauncher.getEnginesDir());
File symmetricProperties = new File(enginesDir, engineName + ".properties");
try(FileOutputStream fileOs = new FileOutputStream(symmetricProperties)) {
properties.store(fileOs, "Updated by SymmetricDS Pro");
try (FileOutputStream fileOs = new FileOutputStream(symmetricProperties)) {
SortedProperties sortedProperties = new SortedProperties();
sortedProperties.putAll(properties);
sortedProperties.store(fileOs, "Updated by SymmetricDS Pro");
} catch (IOException ex) {
throw new RuntimeException("Failed to write symmetric.properties to engine directory",
ex);
throw new RuntimeException("Failed to write symmetric.properties to engine directory", ex);
}

ISymmetricEngine engine = null;
Expand Down
@@ -0,0 +1,23 @@
package org.jumpmind.properties;

import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;

public class SortedProperties extends Properties {

private static final long serialVersionUID = 1L;

@SuppressWarnings({ "rawtypes", "unchecked" })
public Enumeration keys() {
Enumeration keysEnum = super.keys();
Vector<String> keyList = new Vector<String>();
while (keysEnum.hasMoreElements()) {
keyList.add((String) keysEnum.nextElement());
}
Collections.sort(keyList);
return keyList.elements();
}

}

0 comments on commit 34cb660

Please sign in to comment.