aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHirotaka Matsumoto2013-06-07 05:43:39 (EDT)
committerHirotaka Matsumoto2013-06-07 05:43:39 (EDT)
commitd0e610650c24ce0cf6097d5bb0c04307f34bb0ac (patch)
tree59f70d621b38e6993bbe9cdaed4436a6efb03dad
parentb94d0a5efc85991e84d906fd15d1503591374ad1 (diff)
downloadorg.eclipse.lyo.docs-d0e610650c24ce0cf6097d5bb0c04307f34bb0ac.zip
org.eclipse.lyo.docs-d0e610650c24ce0cf6097d5bb0c04307f34bb0ac.tar.gz
org.eclipse.lyo.docs-d0e610650c24ce0cf6097d5bb0c04307f34bb0ac.tar.bz2
Bug 410019 - Support for Hosted Bugzilla on Landfillerefs/changes/11/13611/3
Change-Id: I08a9285857b3fe166f2b933d1f0737070a287e4d Signed-off-by: Hirotaka Matsumoto <jljlmatu@jp.ibm.com>
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java74
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties22
2 files changed, 90 insertions, 6 deletions
diff --git a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java
index 36ca8d2..68bb049 100644
--- a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java
+++ b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -52,7 +53,66 @@ import com.j2bugzilla.rpc.GetProduct;
* This class represents the list of History data in Bugzilla
*/
public class ChangeBugzillaHistories {
- private static final int MAXNUMBEROFBUGS = 100;
+ private static int MAXNUMBEROFBUGS;
+ private static int MAXNUMBEROFPRODUCTS;
+ static {
+ Properties props = new Properties();
+ try {
+ props.load(BugzillaManager.class.getResourceAsStream("/bugz.properties"));//$NON-NLS-1$
+ String numberOfBugs = props.getProperty("max_number_of_bugs");//$NON-NLS-1$
+ if ((numberOfBugs != null) && (numberOfBugs.length() != 0)) {
+ MAXNUMBEROFBUGS = Integer.valueOf(numberOfBugs).intValue();
+ }
+ if (MAXNUMBEROFBUGS == 0) {
+ MAXNUMBEROFBUGS = 100;
+ }
+ String numberOfProducts = props.getProperty("max_number_of_products");//$NON-NLS-1$
+ if ((numberOfProducts != null) && (numberOfProducts.length() != 0)) {
+ MAXNUMBEROFPRODUCTS = Integer.valueOf(numberOfProducts).intValue();
+ }
+ if (MAXNUMBEROFPRODUCTS == 0) {
+ MAXNUMBEROFPRODUCTS = 5;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static Date STARTCHECKDATE;
+ static {
+ Properties props = new Properties();
+ try {
+ props.load(BugzillaManager.class.getResourceAsStream("/bugz.properties"));//$NON-NLS-1$
+ String year_string = props.getProperty("start_date_year");//$NON-NLS-1$
+ int year=0;
+ if ((year_string != null) && (year_string.length() != 0)) {
+ year = Integer.valueOf(year_string).intValue();
+ }
+ if (year == 0) {
+ year = 2013;
+ }
+ String month_string = props.getProperty("start_date_month");//$NON-NLS-1$
+ int month=0;
+ if ((month_string != null) && (month_string.length() != 0)) {
+ month = Integer.valueOf(month_string).intValue() - 1;
+ }
+ if (month == -1) {
+ month = 0;
+ }
+ String day_string = props.getProperty("start_date_date");//$NON-NLS-1$
+ int day=0;
+ if ((day_string != null) && (day_string.length() != 0)) {
+ day = Integer.valueOf(day_string).intValue();
+ }
+ if (day == 0) {
+ day = 1;
+ }
+ STARTCHECKDATE = (new GregorianCalendar(year, month, day)).getTime();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
private static final SimpleDateFormat XSD_DATETIME_FORMAT;
static {
XSD_DATETIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");//$NON-NLS-1$
@@ -73,8 +133,11 @@ public class ChangeBugzillaHistories {
GetAccessibleProducts getProductIds = new GetAccessibleProducts();
bc.executeMethod(getProductIds);
Integer[] ids = getProductIds.getIds();
+ int numberOfProduct = 0;
for (Integer p : ids) {
productIds.add(Integer.toString(p));
+ numberOfProduct++;
+ if (numberOfProduct >= ChangeBugzillaHistories.MAXNUMBEROFPRODUCTS) break;
}
// get basePath
@@ -83,8 +146,11 @@ public class ChangeBugzillaHistories {
// get bugs from each product
List<HistoryData> allhistories = new ArrayList<HistoryData>();
+ if (dayAfter == null) {
+ dayAfter = ChangeBugzillaHistories.STARTCHECKDATE;
+ }
for (String productid : productIds) {
- List<Bug> bugList = ChangeBugzillaHistories.getBugsByProduct(httpServletRequest, productid, /* page */0, /* limit */ChangeBugzillaHistories.MAXNUMBEROFBUGS, dayAfter);
+ List<Bug> bugList = ChangeBugzillaHistories.getBugsByProduct(httpServletRequest, productid, /* page */0, /* limit */ ChangeBugzillaHistories.MAXNUMBEROFBUGS, dayAfter);
for (Bug bug : bugList) {
Collections.addAll(allhistories, BugzillaManager.getBugHistoryById(httpServletRequest, bug, productid, Integer.toString(bug.getID()), dayAfter));
}
@@ -217,12 +283,11 @@ public class ChangeBugzillaHistories {
*/
private static void buildBaseResourcesAndChangeLogsInternal(HttpServletRequest httpServletRequest) {
Date nowDate = new Date();
- if ((lastBaseResourceUpdatedDate != null) &&
+ if ((lastBaseResourceUpdatedDate != null) && (UPDATEINTERVAL != -1) &&
(nowDate.getTime() - lastBaseResourceUpdatedDate.getTime() > UPDATEINTERVAL)) {
mostRecentChangeLogDate = null; // enforce to build all
}
boolean buildAll = ((mostRecentChangeLogDate == null) || (baseResouces == null));
-
HistoryData[] updatedHistories = null;
if (!buildAll) {
// Get only updated Histories
@@ -231,6 +296,7 @@ public class ChangeBugzillaHistories {
return;
}
} else {
+ System.out.println("Rebuild Base and ChangeLogs");
baseResouces = null;
mostRecentChangeLogDate = null;
lastBaseResourceUpdatedDate = nowDate;
diff --git a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties
index c1faa32..cdc4714 100644
--- a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties
+++ b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties
@@ -23,6 +23,24 @@ adapter_host=localhost
# This is used when all Base resources will be rebuilt.
# If the request to get TRS is after "rebuild_interval"
# milliseconds than the precious call, all Base Resources
-# will be rebuilt.
-rebuild_interval=300000
+# will be rebuilt. If this is -1, TRS won't rebuild Base
+# resources.
+rebuild_interval=-1
+
+# The following values are the max number of some Bugzilla artifacts TRS Provider will access.
+# max_number_of_producs : The max number of Products TRS Provider will access.
+# max_number_of_bugs : The max number of Bugs TRS provider will access to generate their Change Logs.
+# The default values are the recommendation for Bugzilla which is installed on your own PC.
+# If you will use the hosted Bugzilla installation on landfill.bugzilla.org. the recommended values are
+# the following
+# max_number_of_producs=1
+# max_number_of_bugs=3
+max_number_of_products=5
+max_number_of_bugs=100
+
+# The following values are used to specify a date. TRS Provider will access Bugs which were modified
+# after this specified date. The time zone of this date is same as your PC setting.
+start_date_year=2013
+start_date_month=1
+start_date_day=1