XML-RPC インターフェイスを bugzilla にラップする (スタンドアロン!) Java API はありますか? 私はそれのために自分のAPIをプログラムしたくありません。実際にこれを行うライブラリを見つけることができません(そしてこれだけです)。
アップデート:
私はこのようなものを探していますhttp://oss.dbc.dk/bugzproxy/ Javaでのみ書かれています
XML-RPC インターフェイスを bugzilla にラップする (スタンドアロン!) Java API はありますか? 私はそれのために自分のAPIをプログラムしたくありません。実際にこれを行うライブラリを見つけることができません(そしてこれだけです)。
アップデート:
私はこのようなものを探していますhttp://oss.dbc.dk/bugzproxy/ Javaでのみ書かれています
これが少し古いスレッドであることは承知していますが、同じ質問をする人がここにたどり着く可能性は十分にあるので、Bugzilla にアクセスするために見つけた 4 つの Java クライアント ライブラリについて書いたブログ投稿を共有することを考えました: J2Bugzilla、B4J (Bugzilla Java 用)、Bugzilla ライブラリ、LightingBugAPI。
http://www.dzone.com/links/r/bugzilla_web_service_and_java_client_libraries.html
よろしく、 ナンダナ
XML-RPCの完全な実装であるApache WS XML-RPC があります(これは一口です!) 。BugZilla についてはよくわかりませんが、XML-RPC をサポートしていると仮定すると、先ほどリンクした巨大な一口を使用しても問題はないはずです。
ライブラリ/API は JAX-WS (または JAXB) と呼ばれ、任意の性質の WS を呼び出すことができます。スキーマを取得し、Bean とプロキシを生成して呼び出します。
Java で bugzilla API を使用する簡単な例を次に示します。 http://codehelpline.blogspot.com/2010/08/how-to-access-bugzilla-webservice-api.html
以下は、Nandana Mihindukulasooriya による4 つの Bugzilla API ライブラリの優れた比較です。
Eclipse の外部でスタンドアロンで実行されることになっている Mylyn もあります。しかし、私はまだそれをスタンドアロンにすることはできませんでした。最も緊急のニーズをカバーしようとする私自身の Bugzilla Java API を試すことができます: http://techblog.ralph-schuster.eu/b4j-bugzilla-for-java/
ミリンはあなたにとって良い選択かもしれません。
セットアップを簡素化したり、状況をより適切に制御する必要がある場合は、独自の XML-RPC 呼び出しを Bugzilla Web サービス インターフェイスに記述できます。私のブログでプロセスを要約しました: Chat to Bugzilla from Java using Apache XML-RPC。
要約すると:
次に、次のクラスを基本クラスとして使用し (Cookie などを処理します)、オーバーライドします。
/**
* @author joshis_tweets
*/
public class BugzillaAbstractRPCCall {
private static XmlRpcClient client = null;
// Very simple cookie storage
private final static LinkedHashMap<String, String> cookies = new LinkedHashMap<String, String>();
private HashMap<String, Object> parameters = new HashMap<String, Object>();
private String command;
// path to Bugzilla XML-RPC interface
private static final String BZ_PATH = "https://localhost/bugzilla/xmlrpc.cgi";
/**
* Creates a new instance of the Bugzilla XML-RPC command executor for a specific command
* @param command A remote method associated with this instance of RPC call executor
*/
public BugzillaAbstractRPCCall(String command) {
synchronized (this) {
this.command = command;
if (client == null) { // assure the initialization is done only once
client = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(BZ_PATH));
} catch (MalformedURLException ex) {
Logger.getLogger(BugzillaAbstractRPCCall.class.getName()).log(Level.SEVERE, null, ex);
}
XmlRpcTransportFactory factory = new XmlRpcTransportFactory() {
public XmlRpcTransport getTransport() {
return new XmlRpcSunHttpTransport(client) {
private URLConnection conn;
@Override
protected URLConnection newURLConnection(URL pURL) throws IOException {
conn = super.newURLConnection(pURL);
return conn;
}
@Override
protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException {
super.initHttpHeaders(pRequest);
setCookies(conn);
}
@Override
protected void close() throws XmlRpcClientException {
getCookies(conn);
}
private void setCookies(URLConnection pConn) {
String cookieString = "";
for (String cookieName : cookies.keySet()) {
cookieString += "; " + cookieName + "=" + cookies.get(cookieName);
}
if (cookieString.length() > 2) {
setRequestHeader("Cookie", cookieString.substring(2));
}
}
private void getCookies(URLConnection pConn) {
String headerName = null;
for (int i = 1; (headerName = pConn.getHeaderFieldKey(i)) != null; i++) {
if (headerName.equals("Set-Cookie")) {
String cookie = pConn.getHeaderField(i);
cookie = cookie.substring(0, cookie.indexOf(";"));
String cookieName = cookie.substring(0, cookie.indexOf("="));
String cookieValue = cookie.substring(cookie.indexOf("=") + 1, cookie.length());
cookies.put(cookieName, cookieValue);
}
}
}
};
}
};
client.setTransportFactory(factory);
client.setConfig(config);
}
}
}
/**
* Get the parameters of this call, that were set using setParameter method
* @return Array with a parameter hashmap
*/
protected Object[] getParameters() {
return new Object[] {parameters};
}
/**
* Set parameter to a given value
* @param name Name of the parameter to be set
* @param value A value of the parameter to be set
* @return Previous value of the parameter, if it was set already.
*/
public Object setParameter(String name, Object value) {
return this.parameters.put(name, value);
}
/**
* Executes the XML-RPC call to Bugzilla instance and returns a map with result
* @return A map with response
* @throws XmlRpcException
*/
public Map execute() throws XmlRpcException {
return (Map) client.execute(command, this.getParameters());
}
}
カスタム コンストラクターを提供し、メソッドを追加して、クラスをオーバーライドします。
public class BugzillaLoginCall extends BugzillaAbstractRPCCall {
/**
* Create a Bugzilla login call instance and set parameters
*/
public BugzillaLoginCall(String username, String password) {
super("User.login");
setParameter("login", username);
setParameter("password", password);
}
/**
* Perform the login action and set the login cookies
* @returns True if login is successful, false otherwise. The method sets Bugzilla login cookies.
*/
public static boolean login(String username, String password) {
Map result = null;
try {
// the result should contain one item with ID of logged in user
result = new BugzillaLoginCall(username, password).execute();
} catch (XmlRpcException ex) {
Logger.getLogger(BugzillaLoginCall.class.getName()).log(Level.SEVERE, null, ex);
}
// generally, this is the place to initialize model class from the result map
return !(result == null || result.isEmpty());
}
}