in src/main/java/org/apache/maven/plugins/changes/jira/JiraHelper.java [99:136]
public static String getPidFromJira(Log log, String issueManagementUrl, HttpClient client) {
String jiraId = null;
HttpGet request = new HttpGet(issueManagementUrl);
String projectPage;
try {
HttpResponse response = client.execute(request);
log.debug("Successfully reached JIRA.");
HttpEntity entity = response.getEntity();
if (entity != null) {
projectPage = EntityUtils.toString(entity);
} else {
if (log.isDebugEnabled()) {
log.error("Unable to read the JIRA project page");
}
return null;
}
} catch (IOException e) {
if (log.isDebugEnabled()) {
log.error("Unable to reach the JIRA project page:", e);
} else {
log.error("Unable to reach the JIRA project page. Cause is: " + e.getLocalizedMessage());
}
return null;
}
int pidIndex = projectPage.indexOf(PID);
if (pidIndex == -1) {
log.error("Unable to extract a JIRA pid from the page at the url " + issueManagementUrl);
} else {
NumberFormat nf = NumberFormat.getInstance();
Number pidNumber = nf.parse(projectPage, new ParsePosition(pidIndex + PID.length()));
jiraId = Integer.toString(pidNumber.intValue());
log.debug("Found the pid " + jiraId + " at " + issueManagementUrl);
}
return jiraId;
}