aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHirotaka Matsumoto2014-03-26 13:27:54 (EDT)
committerHirotaka Matsumoto2014-03-26 13:27:54 (EDT)
commit4e4f462e95e998f4f0eaa67bd2c1b294cc802ea3 (patch)
treef9d3649600496871a3b89490d67cbc4d73c0a7ee
parentc305fb54ca92028374a3547b63277a18b0102d92 (diff)
downloadorg.eclipse.lyo.docs-4e4f462e95e998f4f0eaa67bd2c1b294cc802ea3.zip
org.eclipse.lyo.docs-4e4f462e95e998f4f0eaa67bd2c1b294cc802ea3.tar.gz
org.eclipse.lyo.docs-4e4f462e95e998f4f0eaa67bd2c1b294cc802ea3.tar.bz2
Bug 430264 - Enhance the integration with Rational Team Concertrefs/changes/40/23940/1
Change-Id: Id0f3ad051da7cb61d2d5e728b9b0ed0cf590d611 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/BugzillaManager.java20
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/resources/BugzillaChangeRequest.java26
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/ChangeBugzillaHistories.java4
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/UpdateURL.java80
-rw-r--r--org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/resources/bugz.properties15
5 files changed, 141 insertions, 4 deletions
diff --git a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/BugzillaManager.java b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/BugzillaManager.java
index f21e982..5bc00cb 100644
--- a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/BugzillaManager.java
+++ b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/BugzillaManager.java
@@ -66,6 +66,7 @@ import org.eclipse.lyo.oslc4j.bugzilla.servlet.ServiceProviderCatalogSingleton;
import org.eclipse.lyo.oslc4j.bugzilla.trs.GetComments;
import org.eclipse.lyo.oslc4j.bugzilla.trs.GetHistory;
import org.eclipse.lyo.oslc4j.bugzilla.trs.HistoryData;
+import org.eclipse.lyo.oslc4j.bugzilla.trs.UpdateURL;
import org.eclipse.lyo.oslc4j.bugzilla.utils.BugzillaHttpClient;
import org.eclipse.lyo.oslc4j.client.ServiceProviderRegistryURIs;
import org.eclipse.lyo.oslc4j.core.SingletonWildcardProperties;
@@ -94,6 +95,7 @@ public class BugzillaManager implements ServletContextListener {
private static String admin = null;
private static String admin_password = null; // Added in Lab 1.2
private static String adapter_host = null; // Added in Lab 1.2
+ private static boolean enable_url_as_cr = false;
private static String servletBase = null;
private static String bugzServiceBase = null;
@@ -129,6 +131,7 @@ public class BugzillaManager implements ServletContextListener {
adapter_host = props.getProperty("adapter_host"); // Added in Lab 1.2
System.out.println("bugzilla_uri: " + bugzillaUri);
System.out.println("admin: " + admin);
+ enable_url_as_cr = Boolean.parseBoolean(props.getProperty("enable_url_as_cr", "true"));
} catch (IOException e) {
e.printStackTrace();
@@ -982,6 +985,23 @@ public class BugzillaManager implements ServletContextListener {
CommentBug bugzillaMethod = new CommentBug(Integer.parseInt(cr.getIdentifier()), comment);
bc.executeMethod(bugzillaMethod);
}
+ // "URL" Experimental support
+ if (enable_url_as_cr) {
+ // Support RelatedChangeRequests
+ Link[] links = cr.getRelatedChangeRequests();
+ String url = "";
+ for (Link link : links) {
+ url = link.getValue().toString();
+ if ((url == null) || (url.startsWith(BugzillaManager.getBugzServiceBase()))) {// If so, this link comes from "see_also" field
+ url = "";
+ continue;
+ }
+ break;
+ }
+ UpdateURL updateMethod = new UpdateURL(Integer.parseInt(cr.getIdentifier()), url);
+ bc.executeMethod(updateMethod);
+ //
+ }
} catch (Exception e)
{
e.printStackTrace();
diff --git a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/resources/BugzillaChangeRequest.java b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/resources/BugzillaChangeRequest.java
index d5555c5..bd87906 100644
--- a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/resources/BugzillaChangeRequest.java
+++ b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/resources/BugzillaChangeRequest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corporation.
+ * Copyright (c) 2012, 2014 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -24,6 +24,7 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
+import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -58,6 +59,19 @@ import com.j2bugzilla.base.ConnectionException;
public final class BugzillaChangeRequest
extends ChangeRequest
{
+ private static boolean enable_url_as_cr = false;
+ //Bugzilla adapter properties from bugz.properties
+ static {
+ Properties props = new Properties();
+ try {
+ props.load(BugzillaManager.class.getResourceAsStream("/bugz.properties"));
+ enable_url_as_cr = Boolean.parseBoolean(props.getProperty("enable_url_as_cr", "true"));
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
public BugzillaChangeRequest() throws URISyntaxException {
super();
@@ -231,6 +245,16 @@ public final class BugzillaChangeRequest
}
}
}
+ // "URL" Experimental support
+ if (enable_url_as_cr) {
+ String url = (String) bug.getParameterMap().get("url"); //$NON-NLS-1$
+ if (url!= null) {
+ String trimmed_url = url.trim();
+ if (trimmed_url.length() > 0) {
+ changeRequest.addRelatedChangeRequest(new Link(new URI(trimmed_url)));
+ }
+ }
+ }
return changeRequest;
}
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 bd1869a..f72e6dd 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corporation.
+ * Copyright (c) 2012, 2014 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -101,7 +101,7 @@ public class ChangeBugzillaHistories {
if (month == -1) {
month = 0;
}
- String day_string = props.getProperty("start_date_date");//$NON-NLS-1$
+ String day_string = props.getProperty("start_date_day");//$NON-NLS-1$
int day=0;
if ((day_string != null) && (day_string.length() != 0)) {
day = Integer.valueOf(day_string).intValue();
diff --git a/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/UpdateURL.java b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/UpdateURL.java
new file mode 100644
index 0000000..1d9c650
--- /dev/null
+++ b/org.eclipse.lyo.oslc4j.bugzilla.trs/src/main/java/org/eclipse/lyo/oslc4j/bugzilla/trs/UpdateURL.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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:
+ *
+ * Hirotaka Matsumoto - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.oslc4j.bugzilla.trs;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.j2bugzilla.base.BugzillaMethod;
+
+public class UpdateURL implements BugzillaMethod {
+ /**
+ * The XML-RPC method Bugzilla will use
+ */
+ private static final String METHOD_NAME = "Bug.update";
+
+ private Map<Object, Object> hash = new HashMap<Object, Object>();
+ private Map<Object, Object> params = new HashMap<Object, Object>();
+
+ public UpdateURL() {
+ super();
+ }
+
+ public UpdateURL(int id, String url) {
+ super();
+ params.put("ids", id);
+ params.put("url", url);
+ }
+
+ @Override
+ public void setResultMap(Map<Object, Object> hash) {
+ this.hash = hash;
+
+ }
+
+ @Override
+ public Map<Object, Object> getParameterMap() {
+ return Collections.unmodifiableMap(params);
+ }
+
+ @Override
+ public String getMethodName() {
+ return METHOD_NAME;
+ }
+
+ public int getID() {
+ if (hash.containsKey("bugs")) {
+ Object[] objs = (Object[])hash.get("bugs");
+ Map<String, Object> maps = (Map<String, Object>)objs[0];
+ Map<String, Map> changesMaps = (Map<String, Map>)maps.get("changes");
+ if (changesMaps != null) {
+ Map<String, String> changes = (Map<String, String>)changesMaps.get("url");
+ if (changes != null) {
+ String removed = (String)changes.get("removed");
+ String added = (String)changes.get("added");
+ if (added !=null) {
+ int i = 0;
+ }
+ }
+ }
+ int id = ((Integer)maps.get("id")).intValue();
+ return id;
+ }
+ return -1;
+ }
+} \ No newline at end of file
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 c53fefc..455b9d6 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
@@ -27,7 +27,7 @@ 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
+# milliseconds than the previous call, all Base Resources
# will be rebuilt. If this is -1, TRS won't rebuild Base
# resources.
rebuild_interval=-1
@@ -49,3 +49,16 @@ start_date_year=2013
start_date_month=1
start_date_day=1
+# The following flag is used to enable the "URL" field value as a link to Change Request, for example, RTC's
+# workitem, to be indexed as a link to ChangeManagement's Change Request.
+# The original code supports the "See Also" field value as a link to another Bugzilla Bug to be indexed,
+# but this field accepts only links to Bugzilla Bugs.
+# If this value is set to "true", the value in "URL" field will be indexed as a link to ChangeManagement's
+# Change Request.
+# If this value is set to "false", the value in "URL" field won't be indexed.
+#
+# This option is useful when TRS adapter and RTC are integrated. When "Related Change Request" link is
+# going to be created from RTC workitem to Bugzilla bug, the back link to RTC workitem will be automatically
+# inserted in "URL" field. Also they are indexed so that TRS consumer, such as Rational Engineering Lifecycle
+# Manager can use it.
+enable_url_as_cr=false