if (splitCredentials[1] != null) {
password = splitCredentials[1];
}
}
Config config = new Config();
API api = new API(username, password, config.getURL(), config.getProxyUser(), config.getProxyPassword(),
config.getProxyURL(), config.getProxyPort(), config.getUserAgent(), config.isDevel());
// check if we are authorized
api.getProblems().diagnoseStr("test");
if (SERVER_REPORT.equalsIgnoreCase(attachment)) {
String report = new JdrReportRunner().getReport();
api.getAttachments().add(caseNum, true, report, attachment);
log.info("File attached to URL " + api.getConfigHelper().getUrl());
try {
new File(report).delete();
log.debug("Report " + report + " deleted");
} catch (Exception e) {
log.error("Failed to delete JDR Report File", e);
}
}
if (attachment.startsWith(RESOURCE_REPORT)) {
String resourceId = attachment.replaceAll(".*/", "").replaceAll("\\:.*", "").trim();
log.info("About to attach report for resourceId=" + resourceId);
int resId = Integer.parseInt(resourceId);
String report = new ResourceJdrReportRunner(resId).getReport();
if (report != null) {
api.getAttachments().add(caseNum, true, report, attachment);
try {
new File(report).delete();
log.debug("Report " + report + " deleted");
} catch (Exception e) {
log.error("Failed to delete JDR Report File", e);