* Authentication to the jira system and the issue creation happening here
*/
public void run() {
IssueTrackerAdmin admin = new IssueTrackerAdmin();
List<AccountInfo> accountList;
try {
accountList = admin.getAccountInfo();
} catch (IssueTrackerException e) {
log.error("Error occured while ", e);
return;
}
for (AccountInfo account : accountList) {
if (account.isAutoReportingEnable()) {
if (log.isDebugEnabled()) {
log.debug("Reporting to project : \n\n" + account.getAutoReportingSettings().getProjectName());
}
String token = null;
try {
token= admin.login(account.getCredentials());
} catch (IssueTrackerException e) {
log.error("Error connceting to JIRA",e);
}
GenericIssue genericIssue = new GenericIssue();
genericIssue.setProjectKey(account.getAutoReportingSettings().getProjectName());
genericIssue.setPriority(account.getAutoReportingSettings().getPriority());
genericIssue.setType(account.getAutoReportingSettings().getIssueType());
genericIssue.setSummary(loggingEvent.getRenderedMessage());
// getting and adding the throwable information to the remote issue
String throwableStr[] = loggingEvent.getThrowableStrRep();
if (throwableStr != null) {
StringBuilder stringBuilder = new StringBuilder();
for (String description : throwableStr) {
stringBuilder.append(description).append("\n");
}
genericIssue.setDescription(stringBuilder.toString());
}
try {
admin.captureIssueInfo(genericIssue,token,account.getCredentials().getUrl());
} catch (IssueTrackerException e) {
log.error("Error reporting error to JIRA",e);
}