From 533c2edaf64545a0269f4181cec2702abd15b151 Mon Sep 17 00:00:00 2001 From: Tristan Marks Date: Wed, 14 Aug 2013 19:46:39 -0400 Subject: [PATCH 1/2] Added the ConnectionException. It's taken straight from the old J2Bugzilla implementation. It belonged here because the BugzillaConnector throws it from its connectTo() methods, but the Bugzilla class did not. This was also changed; Bugzilla's connectTo() methods now throw ConnectionException in their signatures. --- .../java/com/j2bugzilla/api/Bugzilla.java | 11 ++--- .../j2bugzilla/api/ConnectionException.java | 45 +++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/j2bugzilla/api/ConnectionException.java diff --git a/src/main/java/com/j2bugzilla/api/Bugzilla.java b/src/main/java/com/j2bugzilla/api/Bugzilla.java index 2c23f80..2026661 100644 --- a/src/main/java/com/j2bugzilla/api/Bugzilla.java +++ b/src/main/java/com/j2bugzilla/api/Bugzilla.java @@ -3,6 +3,7 @@ import java.net.URI; import java.util.ServiceLoader; import java.util.Set; +import com.j2bugzilla.api.ConnectionException; /** * The {@code Bugzilla} class is the entry point into the API. This class adheres to the SPI contract. @@ -11,7 +12,7 @@ * * @author Tom */ -public abstract class Bugzilla { +public abstract class Bugzilla{ /** * Loads and returns a new instance of {@link Bugzilla} to provide access to the various @@ -34,13 +35,13 @@ public static final Bugzilla newBugzilla() { * Connects to the given host. * @param host A {@code String} which can be parsed as a URL, pointing to the Bugzilla base. */ - public abstract void connectTo(String host); + public abstract void connectTo(String host) throws ConnectionException; /** * Connects to the given host. * @param host A {@link URI} which points to the Bugzilla base. */ - public abstract void connectTo(URI host); + public abstract void connectTo(URI host) throws ConnectionException; /** * Connects to the given host, providing HTTP Basic authentication credentials. Note that this does @@ -49,7 +50,7 @@ public static final Bugzilla newBugzilla() { * @param httpUser A {@code String} representing an HTTP Basic username. * @param httpPass A {@code String} representing an HTTP Basic password. */ - public abstract void connectTo(String host, String httpUser, String httpPass); + public abstract void connectTo(String host, String httpUser, String httpPass) throws ConnectionException; /** * Connects to the given host, providing HTTP Basic authentication credentials. Note that this does @@ -58,7 +59,7 @@ public static final Bugzilla newBugzilla() { * @param httpUser A {@code String} representing an HTTP Basic username. * @param httpPass A {@code String} representing an HTTP Basic password. */ - public abstract void connectTo(URI host, String httpUser, String httpPass); + public abstract void connectTo(URI host, String httpUser, String httpPass) throws ConnectionException; /** * Retrieves a configured instance of {@link BugRepository} to allow consumers to make queries about diff --git a/src/main/java/com/j2bugzilla/api/ConnectionException.java b/src/main/java/com/j2bugzilla/api/ConnectionException.java new file mode 100644 index 0000000..86b23f4 --- /dev/null +++ b/src/main/java/com/j2bugzilla/api/ConnectionException.java @@ -0,0 +1,45 @@ +/* + * Copyright 2011 Thomas Golden + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.j2bugzilla.api; + +/** + * ConnectionException is thrown any time there is an error trying to access + * the Bugzilla installation over the network. It may be a network-related problem such as + * a timeout or malformed URL, or it may be an underlying XML-RPC exception, but it + * generally indicates that any further Bugzilla calls will fail. + * + * ConnectionException will always be a wrapper for a nested Exception which + * indicates the cause of the error. + * @author Tom + * + */ +public class ConnectionException extends Exception { + + /** + * Eclipse-generated SUID + */ + private static final long serialVersionUID = 2957676868743832929L; + + /** + * Public constructor which calls super() + * @param message A custom error message describing the issue + * @param cause The root cause of the exception + */ + public ConnectionException(String message, Throwable cause) { + super(message, cause); + } + +} From 6784ca870879d60a191a1505f59248cf832d5686 Mon Sep 17 00:00:00 2001 From: Tristan Marks Date: Sun, 27 Apr 2014 22:25:23 -0400 Subject: [PATCH 2/2] SearchBy.java: - *Finally* changed getName()'s visibility to public... - Fixed a comment on the constructor to say SearchBy instead of SearchLimiter. Must've been an old name. pom.xml: - Added dependency for xmlrpc-client. Bugzilla.java: - Removed throws declarations of ConnectionException from all methods, since... ConnectionException.java: - ... now extends RuntimeException. Bugzilla.java: --- pom.xml | 10 ++++++++++ src/main/java/com/j2bugzilla/api/Bugzilla.java | 8 ++++---- .../java/com/j2bugzilla/api/ConnectionException.java | 2 +- src/main/java/com/j2bugzilla/api/SearchBy.java | 5 ++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index a743314..65dd170 100644 --- a/pom.xml +++ b/pom.xml @@ -34,5 +34,15 @@ guava 14.0.1 + + org.apache.xmlrpc + xmlrpc-client + 3.1.3 + + + com.google.guava + guava + 14.0.1 + \ No newline at end of file diff --git a/src/main/java/com/j2bugzilla/api/Bugzilla.java b/src/main/java/com/j2bugzilla/api/Bugzilla.java index 2026661..2163ed6 100644 --- a/src/main/java/com/j2bugzilla/api/Bugzilla.java +++ b/src/main/java/com/j2bugzilla/api/Bugzilla.java @@ -35,13 +35,13 @@ public static final Bugzilla newBugzilla() { * Connects to the given host. * @param host A {@code String} which can be parsed as a URL, pointing to the Bugzilla base. */ - public abstract void connectTo(String host) throws ConnectionException; + public abstract void connectTo(String host); /** * Connects to the given host. * @param host A {@link URI} which points to the Bugzilla base. */ - public abstract void connectTo(URI host) throws ConnectionException; + public abstract void connectTo(URI host); /** * Connects to the given host, providing HTTP Basic authentication credentials. Note that this does @@ -50,7 +50,7 @@ public static final Bugzilla newBugzilla() { * @param httpUser A {@code String} representing an HTTP Basic username. * @param httpPass A {@code String} representing an HTTP Basic password. */ - public abstract void connectTo(String host, String httpUser, String httpPass) throws ConnectionException; + public abstract void connectTo(String host, String httpUser, String httpPass); /** * Connects to the given host, providing HTTP Basic authentication credentials. Note that this does @@ -59,7 +59,7 @@ public static final Bugzilla newBugzilla() { * @param httpUser A {@code String} representing an HTTP Basic username. * @param httpPass A {@code String} representing an HTTP Basic password. */ - public abstract void connectTo(URI host, String httpUser, String httpPass) throws ConnectionException; + public abstract void connectTo(URI host, String httpUser, String httpPass); /** * Retrieves a configured instance of {@link BugRepository} to allow consumers to make queries about diff --git a/src/main/java/com/j2bugzilla/api/ConnectionException.java b/src/main/java/com/j2bugzilla/api/ConnectionException.java index 86b23f4..2d0a2f8 100644 --- a/src/main/java/com/j2bugzilla/api/ConnectionException.java +++ b/src/main/java/com/j2bugzilla/api/ConnectionException.java @@ -26,7 +26,7 @@ * @author Tom * */ -public class ConnectionException extends Exception { +public class ConnectionException extends RuntimeException { /** * Eclipse-generated SUID diff --git a/src/main/java/com/j2bugzilla/api/SearchBy.java b/src/main/java/com/j2bugzilla/api/SearchBy.java index e21ef2e..0508dd7 100644 --- a/src/main/java/com/j2bugzilla/api/SearchBy.java +++ b/src/main/java/com/j2bugzilla/api/SearchBy.java @@ -81,7 +81,7 @@ public enum SearchBy { private final String name; /** - * Creates a new {@link SearchLimiter} with the + * Creates a new {@link SearchBy} with the * designated name * @param name The name Bugzilla expects for this search limiter */ @@ -92,8 +92,7 @@ public enum SearchBy { * Get the name Bugzilla expects for this search limiter * @return A String representing the search limiter */ - String getName() { + public String getName() { return this.name; } - }