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 { class WPClient {
private WordPressConfig config; private WPConfig config;
private XmlRpcClient client; 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(cfg.getXmlRpcUrl(), cfg.isTrustAll());
this.config = cfg; this.config = cfg;
} }

View File

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

View File

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

View File

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

View File

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