init
Change-Id: If98464cbe8ff948d2040aaf133edaba6bf1d9eae
This commit is contained in:
parent
226eb0a9b9
commit
b0b52a424d
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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() {
|
|
@ -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());
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue