MPJIRA-4 <issueTrackingUrl> must contain an "id" attribute

Fixed by downloading the project page and extracting a project id from it

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@344007 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
fgiust 2005-11-13 23:49:11 +00:00
parent 1363f63469
commit a8d71f4ad9
3 changed files with 43 additions and 9 deletions

View File

@ -27,7 +27,7 @@
<description>This plugin downloads issues from Jira and creates a report.</description>
<shortDescription>Download issues from Jira</shortDescription>
<url>http://maven.apache.org/maven-1.x/reference/plugins/jira/</url>
<issueTrackingUrl>http://jira.codehaus.org/secure/IssueNavigator.jspa?id=10450</issueTrackingUrl>
<issueTrackingUrl>http://jira.codehaus.org/browse/MPJIRA</issueTrackingUrl>
<siteDirectory>/www/maven.apache.org/maven-1.x/reference/plugins/jira/</siteDirectory>
<repository>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/jira/</connection>

View File

@ -21,6 +21,8 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.HashMap;
import java.util.Map;
@ -186,11 +188,12 @@ public final class JiraDownloader {
public void doExecute() throws Exception {
if (project == null) {
throw new Exception("No project set.");
} else {
}
if (project.getIssueTrackingUrl() == null) {
throw new Exception("No issue tracking url set.");
}
}
try {
HttpClient cl = new HttpClient();
@ -205,20 +208,49 @@ public final class JiraDownloader {
// chop off the parameter part
int pos = url.indexOf("?");
// and get the id while we're at it
String id = "";
String id = null;
if (pos >= 0) {
// url
id = url.substring(url.lastIndexOf("=") + 1);
}
// TODO: fail the build in the else block, issueTrackingUrl has to include id
String jiraUrl = url.substring(0, url.lastIndexOf("/"));
if (jiraUrl.endsWith("secure")) {
if (jiraUrl.endsWith("secure") || jiraUrl.endsWith("browse")) {
jiraUrl = jiraUrl.substring(0, jiraUrl.lastIndexOf("/"));
}
log.info("Jira lives at: " + jiraUrl);
doAuthentication(cl, jiraUrl);
if (id == null) {
GetMethod gm = new GetMethod(url);
log.info("Jira URL " + url + " doesn't include a pid, trying to get it");
try {
cl.executeMethod(gm);
log.info("Succesfully reached JIRA.");
}
catch (Exception e) {
if (log.isDebugEnabled()) {
log.error("Unable to reach JIRA project page:", e);
}
else {
log.error("Unable to reach JIRA project page. Cause is: " + e.getLocalizedMessage());
}
}
String projectPage = gm.getResponseBodyAsString();
int pidIndex = projectPage.indexOf("pid="); // @todo, a safer way to get the PID
if (pidIndex == -1) {
// fail
log.error("Unable to get JIRA pid using url " + project.getIssueTrackingUrl());
return;
}
NumberFormat nf = NumberFormat.getInstance();
Number pidNumber = nf.parse(projectPage, new ParsePosition(pidIndex + 4));
id = Integer.toString(pidNumber.intValue());
}
// create the URL for getting the proper iussues from JIRA
String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + id;
fullURL += createFilter();

View File

@ -25,6 +25,8 @@
</properties>
<body>
<release version="1.2-SNAPSHOT" date="in SVN">
<action dev="fgiust" type="fix" issue="MPJIRA-4">Make the Jira report work also using a fancy JIRA url like http://jira.codehaus.org/browse/MPJIRA (it doesn't require
the url with a numeric project id anymore)</action>
<action dev="aheritier" type="update" issue="MAVEN-1712">Update dependencies to match ones in maven 1.1 core and to unify them between plugins. The following dependencies are updated :
<ul>
<li>log4j v1.2.8 -> v1.2.12</li>