summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Padgett2011-11-09 11:46:34 (EST)
committer Michael Fiedler2011-11-09 14:03:41 (EST)
commit169b836aa1716a647da3ae0b90310951461c39fa (patch)
treea9804a2863d6c0ced532398a4045763bbf00047b
parentab7f2f8380f75d24d5bbbaaef9339ca974e25613 (diff)
downloadorg.eclipse.lyo.server-169b836aa1716a647da3ae0b90310951461c39fa.zip
org.eclipse.lyo.server-169b836aa1716a647da3ae0b90310951461c39fa.tar.gz
org.eclipse.lyo.server-169b836aa1716a647da3ae0b90310951461c39fa.tar.bz2
Bug 363352 - Bugzilla Adaptor: Store the BugzillaConnector object in the
HTTP session
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java24
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java10
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java6
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java2
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java4
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java4
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java4
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java2
-rw-r--r--org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java4
9 files changed, 39 insertions, 21 deletions
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java
index 94891c4..9af7cc0 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java
@@ -19,6 +19,9 @@ package org.eclipse.lyo.samples.bugzilla;
import java.io.IOException;
import java.util.Properties;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
import jbugz.base.BugzillaConnector;
import jbugz.exceptions.BugzillaException;
import jbugz.exceptions.ConnectionException;
@@ -26,7 +29,8 @@ import jbugz.rpc.LogIn;
public class BugzillaInitializer {
- private static String baseUri = null;
+ private static final String CONNECTOR_SESSION_ATTRIBUTE = "org.eclipse.lyo.samples.bugzilla.BugzillaConnector";
+ private static String baseUri = null;
private static String bugzillaUri = null;
private static String username = null;
private static String password = null;
@@ -60,8 +64,22 @@ public class BugzillaInitializer {
LogIn login = new LogIn(username, password);
bc.executeMethod(login);
return bc;
- }
-
+ }
+
+ public static BugzillaConnector getBugzillaConnector(
+ HttpServletRequest request) throws ConnectionException,
+ BugzillaException {
+ HttpSession session = request.getSession();
+ BugzillaConnector connector = (BugzillaConnector) session
+ .getAttribute(CONNECTOR_SESSION_ATTRIBUTE);
+ if (connector == null) {
+ connector = getBugzillaConnector();
+ session.setAttribute(CONNECTOR_SESSION_ATTRIBUTE, connector);
+ }
+
+ return connector;
+ }
+
public static String getBaseUri() {
return baseUri;
}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java
index 2d91cbd..edc78ac 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java
@@ -74,7 +74,7 @@ public class ChangeRequestCollectionService extends HttpServlet {
}
try {
- createChangeRequests(response, changeRequests);
+ createChangeRequests(request, response, changeRequests);
response.setHeader("OSLC-Core-Version", "2.0");
response.setStatus(HttpServletResponse.SC_CREATED);
} catch (Exception e) {
@@ -82,10 +82,10 @@ public class ChangeRequestCollectionService extends HttpServlet {
}
}
- private void createChangeRequests(HttpServletResponse response,
+ private void createChangeRequests(HttpServletRequest request, HttpServletResponse response,
Collection<BugzillaChangeRequest> changeRequests)
throws ConnectionException, BugzillaException, InvalidDescriptionException {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
for (BugzillaChangeRequest cr : changeRequests) {
ReportBug reportBug = new ReportBug(cr.toBug());
@@ -118,7 +118,7 @@ public class ChangeRequestCollectionService extends HttpServlet {
Product product = null;
try {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
String pageString = request.getParameter("page");
if (null != pageString) {
@@ -151,7 +151,7 @@ public class ChangeRequestCollectionService extends HttpServlet {
return;
}
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
ExtendedBugSearch bugSearch = new ExtendedBugSearch(
ExtendedBugSearch.ExtendedSearchLimiter.PRODUCT,
product.getName());
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java
index d5ec3de..35e6b06 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java
@@ -52,7 +52,7 @@ public class ChangeRequestCreatorService extends HttpServlet {
Product product = null;
try {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
int productId = Integer.parseInt(request.getParameter("productId"));
Integer[] productIds = { productId };
@@ -69,7 +69,7 @@ public class ChangeRequestCreatorService extends HttpServlet {
}
try {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
GetLegalValues getComponentValues =
new GetLegalValues("component", product.getId());
@@ -123,7 +123,7 @@ public class ChangeRequestCreatorService extends HttpServlet {
}
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
GetProducts getProducts = new GetProducts(productIds);
bc.executeMethod(getProducts);
List<Product> products = getProducts.getProducts();
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java
index 4ca7591..6d53788 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java
@@ -74,7 +74,7 @@ public class ChangeRequestSelectorService extends HttpServlet {
int productId, String terms, HttpServletRequest request, HttpServletResponse response)
throws ServletException {
try {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
ExtendedBugSearch bugSearch = new ExtendedBugSearch(BugSearch.SearchLimiter.SUMMARY, terms);
bc.executeMethod(bugSearch);
List<Bug> results = bugSearch.getSearchResults();
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 e1c993d..e4cde1a 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
@@ -76,7 +76,7 @@ public class ChangeRequestService extends HttpServlet {
Bug bug = null;
try {
bugId = Integer.parseInt(request.getParameter("id"));
- final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
final ExtendedGetBug getBug = new ExtendedGetBug(bugId);
bc.executeMethod(getBug);
bug = getBug.getBug();
@@ -192,7 +192,7 @@ public class ChangeRequestService extends HttpServlet {
private void updateBug(HttpServletRequest request, BugzillaChangeRequest cr)
throws ConnectionException, BugzillaException,
InvalidDescriptionException {
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
// No built in field to hold external links. Just add the new link as a comment for now.
String comment = getLinksComment(cr);
if (comment.length() != 0) {
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java
index 167dd27..f76d9ee 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java
@@ -52,7 +52,7 @@ public class CreationShapeService extends HttpServlet {
int productId = Integer.parseInt(request.getParameter("productId"));
Integer[] productIds = { productId };
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
GetProducts getProducts = new GetProducts(productIds);
bc.executeMethod(getProducts);
List<Product> products = getProducts.getProducts();
@@ -73,7 +73,7 @@ public class CreationShapeService extends HttpServlet {
return;
}
- final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri());
GetAccessibleProducts getProductIds = new GetAccessibleProducts();
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java
index 1f7b7ec..55da6bc 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java
@@ -54,7 +54,7 @@ public class QueryShapeService extends HttpServlet {
int productId = Integer.parseInt(request.getParameter("productId"));
Integer[] productIds = { productId };
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
GetProducts getProducts = new GetProducts(productIds);
bc.executeMethod(getProducts);
List<Product> products = getProducts.getProducts();
@@ -78,7 +78,7 @@ public class QueryShapeService extends HttpServlet {
return;
}
- final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri());
GetAccessibleProducts getProductIds = new GetAccessibleProducts();
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java
index f0e9145..fa13e19 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java
@@ -61,7 +61,7 @@ public class ServiceProviderCatalogService extends HttpServlet {
return;
}
- final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri());
GetAccessibleProducts getProductIds = new GetAccessibleProducts();
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java
index 81f9ac0..3eedf8c 100644
--- a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java
+++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java
@@ -51,7 +51,7 @@ public class ServiceProviderService extends HttpServlet {
int productId = Integer.parseInt(request.getParameter("productId"));
Integer[] productIds = { productId };
- BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
GetProducts getProducts = new GetProducts(productIds);
bc.executeMethod(getProducts);
List<Product> products = getProducts.getProducts();
@@ -77,7 +77,7 @@ public class ServiceProviderService extends HttpServlet {
return;
}
- final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(request);
request.setAttribute("baseUri", BugzillaInitializer.getBaseUri());
request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri());