Change-Id: If98464cbe8ff948d2040aaf133edaba6bf1d9eae
This commit is contained in:
rui.zhang 2018-12-20 16:56:51 +08:00
parent 226eb0a9b9
commit b0b52a424d
5 changed files with 14 additions and 14 deletions

View File

@ -27,7 +27,7 @@ import java.util.List;
*/
class WPClient {
private WordPressConfig config;
private WPConfig config;
private XmlRpcClient client;
@ -43,7 +43,7 @@ class WPClient {
}
WPClient(WordPressConfig cfg) throws MalformedURLException {
WPClient(WPConfig cfg) throws MalformedURLException {
this(cfg.getXmlRpcUrl(), cfg.isTrustAll());
this.config = cfg;
}

View File

@ -3,7 +3,7 @@ package org.chobit.wp;
/**
* @author robin
*/
public final class WordPressConfig {
public final class WPConfig {
private int blogId;
@ -15,7 +15,7 @@ public final class WordPressConfig {
private boolean trustAll;
WordPressConfig() {
WPConfig() {
}
public int getBlogId() {

View File

@ -8,36 +8,36 @@ import java.util.List;
/**
* @author robin
*/
public final class WordPressConfigBuilder {
public final class WPConfigBuilder {
private WordPressConfig config = new WordPressConfig();
private WPConfig config = new WPConfig();
public WordPressConfigBuilder username(String username) {
public WPConfigBuilder username(String username) {
this.config.setUsername(username);
return this;
}
public WordPressConfigBuilder password(String password) {
public WPConfigBuilder password(String password) {
this.config.setPassword(password);
return this;
}
public WordPressConfigBuilder xmlRpcUrl(String xmlRpcUrl) {
public WPConfigBuilder xmlRpcUrl(String xmlRpcUrl) {
this.config.setXmlRpcUrl(xmlRpcUrl);
return this;
}
public WordPressConfigBuilder trustAll(boolean trustAll) {
public WPConfigBuilder trustAll(boolean trustAll) {
this.config.setTrustAll(trustAll);
return this;
}
public WordPressConfig build() {
public WPConfig build() {
try {
WPClient client = new WPClient(config.getXmlRpcUrl(), config.isTrustAll());
List<UserBlog> list = client.getUsersBlogs(config.getUsername(), config.getPassword());

View File

@ -16,7 +16,7 @@ public final class WordPress {
private WPClient client;
public WordPress(WordPressConfig config) {
public WordPress(WPConfig config) {
try {
client = new WPClient(config);
} catch (Exception e) {

View File

@ -102,8 +102,8 @@ public class WordPressTest {
}
private WordPressConfig buildConfig() {
return new WordPressConfigBuilder()
private WPConfig buildConfig() {
return new WPConfigBuilder()
.username(USERNAME)
.password(PASSWORD)
.xmlRpcUrl(XML_RPC_URL)