|
From: Stefan F. <ste...@us...> - 2012-04-04 14:06:13
|
rails/common/ConfigProfile.java | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
New commits:
commit 8f3d0f38fae254c55c74930be3e4142b012af685
Author: Stefan Frey <ste...@we...>
Date: Wed Apr 4 16:05:42 2012 +0200
made selection of start profile and parent profile more robust
diff --git a/rails/common/ConfigProfile.java b/rails/common/ConfigProfile.java
index 3b9d101..2fb7762 100644
--- a/rails/common/ConfigProfile.java
+++ b/rails/common/ConfigProfile.java
@@ -111,20 +111,27 @@ public final class ConfigProfile implements Comparable<ConfigProfile> {
static ConfigProfile getStartProfile() {
// first checks cli
- String profile = System.getProperty(CLI_AND_RECENT_OPTION);
- if (Util.hasValue(profile) && profiles.containsKey(profile)) {
- return profiles.get(profile);
+ ConfigProfile profile = getProfile(System.getProperty(CLI_AND_RECENT_OPTION));
+ if (profile != null) {
+ return profile;
}
// second check recent
- profile = Config.getRecent(CLI_AND_RECENT_OPTION);
- if (Util.hasValue(profile) && profiles.containsKey(profile)) {
- return profiles.get(profile);
+ profile = getProfile(Config.getRecent(CLI_AND_RECENT_OPTION));
+ if (profile != null) {
+ return profile;
}
// third return standard profile
- return profiles.get(STANDARD_PROFILE);
+ profile = getProfile(STANDARD_PROFILE);
+ if (profile != null) {
+ return profile;
+ }
+ // last return root
+ return root;
}
static ConfigProfile getProfile(String name) {
+ if (name == null) return null;
+ if (name.equals(ROOT_PROFILE)) return root;
return profiles.get(name);
}
@@ -169,7 +176,7 @@ public final class ConfigProfile implements Comparable<ConfigProfile> {
}
private ConfigProfile setParent(String name) {
- return setParent(profiles.get(name));
+ return setParent(getProfile(name));
}
ConfigProfile getParent() {
|