Chad has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155302
Change subject: Reduce config duplication
......................................................................
Reduce config duplication
Change-Id: I87d79e6e115fab338f30c864eaf9b379ecc9f828
---
M src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftService.java
1 file changed, 12 insertions(+), 15 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/search/repository-swift
refs/changes/02/155302/1
diff --git
a/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftService.java
b/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftService.java
index bd5e845..2366184 100644
---
a/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftService.java
+++
b/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftService.java
@@ -42,11 +42,7 @@
}
try {
- AccountConfig conf = new AccountConfig();
- conf.setUsername(username);
- conf.setPassword(password);
- conf.setAuthUrl(url);
-
conf.setAuthenticationMethod(AuthenticationMethod.BASIC);
+ AccountConfig conf = getStandardConfig(url, username,
password, AuthenticationMethod.BASIC);
swiftUser = new AccountFactory(conf).createAccount();
} catch (CommandException ce) {
throw new ElasticsearchIllegalArgumentException("Unable
to authenticate to Swift Basic " + url + "/" + username + "/" + password, ce);
@@ -60,12 +56,8 @@
}
try {
- AccountConfig conf = new AccountConfig();
- conf.setUsername(username);
- conf.setPassword(password);
- conf.setAuthUrl(url);
+ AccountConfig conf = getStandardConfig(url, username,
password, AuthenticationMethod.KEYSTONE);
conf.setTenantName(tenantName);
-
conf.setAuthenticationMethod(AuthenticationMethod.KEYSTONE);
swiftUser = new AccountFactory(conf).createAccount();
} catch (CommandException ce) {
throw new ElasticsearchIllegalArgumentException(
@@ -80,11 +72,7 @@
}
try {
- AccountConfig conf = new AccountConfig();
- conf.setUsername(username);
- conf.setPassword(password);
- conf.setAuthUrl(url);
-
conf.setAuthenticationMethod(AuthenticationMethod.TEMPAUTH);
+ AccountConfig conf = getStandardConfig(url, username,
password, AuthenticationMethod.TEMPAUTH);
swiftUser = new AccountFactory(conf).createAccount();
} catch (CommandException ce) {
throw new ElasticsearchIllegalArgumentException("Unable
to authenticate to Swift Temp", ce);
@@ -92,6 +80,15 @@
return swiftUser;
}
+ private AccountConfig getStandardConfig(String url, String username,
String password, AuthenticationMethod method) {
+ AccountConfig conf = new AccountConfig();
+ conf.setAuthUrl(url);
+ conf.setUsername(username);
+ conf.setPassword(password);
+ conf.setAuthenticationMethod(method);
+ return conf;
+ }
+
/**
* Start the service. No-op here.
*/
--
To view, visit https://gerrit.wikimedia.org/r/155302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I87d79e6e115fab338f30c864eaf9b379ecc9f828
Gerrit-PatchSet: 1
Gerrit-Project: search/repository-swift
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits