Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2014-01-28 02:08:32 +0000
committerSam Davis2014-02-18 22:47:18 +0000
commite5b2bc7f021b1195509905f3397bb5086cecb167 (patch)
tree49865fb26466680805fb836603f5afb3252af8a4 /org.eclipse.mylyn.tasks.core
parent2309ea7436e206bf5e4ec21b8a7548ef13c57b86 (diff)
downloadorg.eclipse.mylyn.tasks-e5b2bc7f021b1195509905f3397bb5086cecb167.tar.gz
org.eclipse.mylyn.tasks-e5b2bc7f021b1195509905f3397bb5086cecb167.tar.xz
org.eclipse.mylyn.tasks-e5b2bc7f021b1195509905f3397bb5086cecb167.zip
cleanup boolean properties in TaskRepository
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
index caa6fd098..01403de77 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
@@ -240,12 +240,12 @@ public final class TaskRepository extends PlatformObject {
setProperty(IRepositoryConstants.PROPERTY_ENCODING, encoding);
setProperty(IRepositoryConstants.PROPERTY_TIMEZONE, timeZoneId);
// use platform proxy by default (headless will need to set this to false)
- this.setProperty(TaskRepository.PROXY_USEDEFAULT, new Boolean(true).toString());
+ setBooleanProperty(TaskRepository.PROXY_USEDEFAULT, true);
// for backwards compatibility to versions prior to 2.2
- this.setProperty(AUTH_REPOSITORY + SAVE_PASSWORD, String.valueOf(true));
- this.setProperty(AUTH_HTTP + SAVE_PASSWORD, String.valueOf(true));
- this.setProperty(AUTH_PROXY + SAVE_PASSWORD, String.valueOf(true));
+ setBooleanProperty(AUTH_REPOSITORY + SAVE_PASSWORD, true);
+ setBooleanProperty(AUTH_HTTP + SAVE_PASSWORD, true);
+ setBooleanProperty(AUTH_PROXY + SAVE_PASSWORD, true);
}
private ICredentialsStore getCredentialsStore() {
@@ -377,14 +377,11 @@ public final class TaskRepository extends PlatformObject {
*/
public synchronized AuthenticationCredentials getCredentials(AuthenticationType authType) {
String key = getKeyPrefix(authType);
-
- String enabled = getProperty(key + ENABLED);
- if ("true".equals(enabled)) { //$NON-NLS-1$
+ if (getBooleanProperty(key + ENABLED)) {
String userName = getAuthInfo(key + USERNAME);
String password;
- String savePassword = getProperty(key + SAVE_PASSWORD);
- if (savePassword != null && "true".equals(savePassword)) { //$NON-NLS-1$
+ if (getBooleanProperty(key + SAVE_PASSWORD)) {
password = getAuthInfo(key + PASSWORD);
} else {
password = transientProperties.get(key + PASSWORD);
@@ -443,6 +440,10 @@ public final class TaskRepository extends PlatformObject {
return this.properties.get(name);
}
+ private boolean getBooleanProperty(String name) {
+ return Boolean.parseBoolean(getProperty(name));
+ }
+
/**
* @deprecated use {@link #getCredentials(AuthenticationType)} instead
*/
@@ -618,14 +619,14 @@ public final class TaskRepository extends PlatformObject {
boolean savePassword) {
String key = getKeyPrefix(authType);
- setProperty(key + SAVE_PASSWORD, String.valueOf(savePassword));
+ setBooleanProperty(key + SAVE_PASSWORD, savePassword);
if (credentials == null) {
- setProperty(key + ENABLED, String.valueOf(false));
+ setBooleanProperty(key + ENABLED, false);
transientProperties.remove(key + PASSWORD);
addAuthInfo(null, null, key + USERNAME, key + PASSWORD);
} else {
- setProperty(key + ENABLED, String.valueOf(true));
+ setBooleanProperty(key + ENABLED, true);
if (savePassword) {
addAuthInfo(credentials.getUserName(), credentials.getPassword(), key + USERNAME, key + PASSWORD);
transientProperties.remove(key + PASSWORD);
@@ -667,7 +668,7 @@ public final class TaskRepository extends PlatformObject {
}
public void setOffline(boolean offline) {
- properties.put(OFFLINE, String.valueOf(offline));
+ setBooleanProperty(OFFLINE, offline);
}
/**
@@ -699,6 +700,10 @@ public final class TaskRepository extends PlatformObject {
}
}
+ private void setBooleanProperty(String key, boolean newValue) {
+ setProperty(key, Boolean.toString(newValue));
+ }
+
private void notifyChangeListeners(String key, String old, String value) {
PropertyChangeEvent event = new PropertyChangeEvent(this, key, old, value);
for (PropertyChangeListener listener : propertyChangeListeners) {
@@ -790,7 +795,7 @@ public final class TaskRepository extends PlatformObject {
* @since 3.1
*/
public void setDefaultProxyEnabled(boolean useDefaultProxy) {
- setProperty(TaskRepository.PROXY_USEDEFAULT, String.valueOf(useDefaultProxy));
+ setBooleanProperty(TaskRepository.PROXY_USEDEFAULT, useDefaultProxy);
}
/**
@@ -800,7 +805,7 @@ public final class TaskRepository extends PlatformObject {
* @see #isCreatedFromTemplate()
*/
public void setCreatedFromTemplate(boolean value) {
- setProperty(TaskRepository.CREATED_FROM_TEMPLATE, String.valueOf(value));
+ setBooleanProperty(TaskRepository.CREATED_FROM_TEMPLATE, value);
}
/**

Back to the top