summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Padgett2012-01-31 12:41:57 (EST)
committer Michael Fiedler2012-01-31 13:02:28 (EST)
commit21d3402f46b3697f9b2421a5c8abb95a3864ee64 (patch)
tree94205b1c313544e689fb8bf631b4f09d96aa5787
parent34e3643180a95bacc63873b1a3c6fea6e49234db (diff)
downloadorg.eclipse.lyo.server-21d3402f46b3697f9b2421a5c8abb95a3864ee64.zip
org.eclipse.lyo.server-21d3402f46b3697f9b2421a5c8abb95a3864ee64.tar.gz
org.eclipse.lyo.server-21d3402f46b3697f9b2421a5c8abb95a3864ee64.tar.bz2
Bug 370249 - Bugzilla: NullPointerException getting a ChangeRequest
j2bugzilla 1.0 fixed the bug we were working around previously with ExtendedGetBug, so the class is no longer necessary. Also do not look for an "internals" in the Bug parameter map since this is no longer in j2bugzilla. (Now we can work with the Bug parameter map directly.)
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java6
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java75
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java2
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties2
4 files changed, 5 insertions, 80 deletions
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java
index f58a9bc..0f0834a 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java
@@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.lyo.samples.bugzilla.exception.UnauthroziedException;
-import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.ExtendedGetBug;
import org.eclipse.lyo.samples.bugzilla.resources.BugzillaChangeRequest;
import org.eclipse.lyo.samples.bugzilla.resources.Person;
import org.eclipse.lyo.samples.bugzilla.utils.AcceptType;
@@ -46,6 +45,7 @@ import com.j2bugzilla.base.BugzillaConnector;
import com.j2bugzilla.base.BugzillaException;
import com.j2bugzilla.base.ConnectionException;
import com.j2bugzilla.rpc.CommentBug;
+import com.j2bugzilla.rpc.GetBug;
/**
@@ -76,13 +76,13 @@ public class ChangeRequestService extends HttpServlet {
try {
bugId = Integer.parseInt(request.getParameter("id"));
final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
- final ExtendedGetBug getBug = new ExtendedGetBug(bugId);
+ final GetBug getBug = new GetBug(bugId);
bc.executeMethod(getBug);
bug = getBug.getBug();
if (bug == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
- }
+ }
} catch (ConnectionException e) {
e.printStackTrace();
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java
deleted file mode 100644
index a94a97a..0000000
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.j2bugzilla.base.Bug;
-import com.j2bugzilla.base.BugFactory;
-import com.j2bugzilla.rpc.GetBug;
-
-/**
- * Allows users to retrieve a specific bug for which the ID is already known.
- * Extends {@link GetBug} to work around problems with specific Bugzilla
- * versions.
- *
- * @author Samuel Padgett <spadgett@us.ibm.com>
- */
-public class ExtendedGetBug extends GetBug {
- private Map<Object, Object> hash = new HashMap<Object, Object>();
-
- /**
- * Creates a new {@link ExtendedGetBug} object to retrieve the {@code Bug}
- * specified by the ID parameter
- *
- * @param id
- * An {@code int} representing the ID of an existing bug in the
- * installation connected to
- */
- public ExtendedGetBug(int id) {
- super(id);
- }
-
- @Override
- public void setResultMap(Map<Object, Object> hash) {
- this.hash = hash;
- super.setResultMap(hash);
- }
-
- /**
- * Retrieves the {@link jbugz.base.Bug} corresponding to the given ID
- *
- * @return A {@code Bug} matching the ID, or null if the returned hash does
- * not contain a match
- */
- public Bug getBug() {
- Object[] bugs = (Object[]) hash.get("bugs");
- if (bugs != null) {
- for (Object o : bugs) {
- @SuppressWarnings("unchecked")
- Map<String, Object> bugMap = (HashMap<String, Object>) o;
- // Work around a bug in j2bugzilla where version isn't correctly
- // recognized.
- Map<?, ?> internals = (Map<?, ?>) bugMap.get("internals");
- bugMap.put("version", internals.get("version"));
- return new BugFactory().createBug(bugMap);
- }
- }
-
- return null;
- }
-}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java
index be96cb0..63afa52 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java
@@ -116,7 +116,7 @@ public class BugzillaChangeRequest extends ChangeRequest {
// Do nothing, priority is not set.
}
- Map<?, ?> internals = (Map<?, ?>) bug.getParameterMap().get("internals");
+ Map<?, ?> internals = bug.getParameterMap();
cr.setPlatform((String) internals.get("rep_platform"));
cr.setOperatingSystem((String) internals.get("op_sys"));
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties b/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties
index a68c92d..cf5b3e5 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties
@@ -13,7 +13,7 @@
#
# IBM Corporation - initial API and implementation
###############################################################################
-adapter_uri=http://9.12.224.58:8282/bugz
+adapter_uri=http://localhost:8282/bugz
bugzilla_uri=https://landfill.bugzilla.org/bugzilla-4.0-branch
provideHtml=true
admin=spadgett@us.ibm.com