String localPluginVersion = getPluginDescriptor().getVersion();
String repositoryPluginVersion = DatabaseNavigator.getInstance().getRepositoryPluginVersion();
if (repositoryPluginVersion != null && repositoryPluginVersion.compareTo(localPluginVersion) > 0) {
NotificationUtil.sendWarningNotification(project, Constants.DBN_TITLE_PREFIX + "New Plugin Version Available", "A newer version of Database Navigator plugin is available in repository" + ". Error report not sent.");
return new SubmittedReportInfo(ISSUE_URL, "", FAILED);
}
IdeaLoggingEvent firstEvent = events[0];
String firstEventText = firstEvent.getThrowableText();
String summary = firstEventText.substring(0, Math.min(Math.max(80, firstEventText.length()), 80));
/*
Throwable t = firstEvent.getThrowable();
if (t != null) {
PluginId pluginId = IdeErrorsDialog.findPluginId(t);
if (pluginId != null) {
IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
localPluginVersion = ideaPluginDescriptor.getVersion();
}
}
}
*/
String platformBuild = ApplicationInfo.getInstance().getBuild().asString();
@NonNls StringBuilder description = new StringBuilder();
description.append("Java Version: ").append(System.getProperty("java.version")).append('\n');
description.append("Operating System: ").append(System.getProperty("os.name")).append('\n');
description.append("IDE Version: ").append(platformBuild).append('\n');
description.append("DBN Version: ").append(localPluginVersion).append("\n");
for (IdeaLoggingEvent event : events) {
LogMessage logMessage = (LogMessage) event.getData();
String additionalInfo = logMessage == null ? null : logMessage.getAdditionalInfo();
if (StringUtil.isNotEmpty(additionalInfo)) {
description.append("\n\nUser Message:");
description.append("\n__________________________________________________________________\n");
description.append(additionalInfo);
description.append("\n__________________________________________________________________");
}
description.append("\n\n").append(event.toString());
}
String result = submit(localPluginVersion, summary, description.toString());
LOGGER.info("Error report submitted, response: " + result);
if (result == null) {
NotificationUtil.sendErrorNotification(project, Constants.DBN_TITLE_PREFIX + "Error Reporting", "Failed to send error report");
return new SubmittedReportInfo(ISSUE_URL, "", FAILED);
}
String ticketId = null;
try {
Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
Matcher regexMatcher = regex.matcher(result);
if (regexMatcher.find()) {
ticketId = regexMatcher.group(1);
}
} catch (PatternSyntaxException ex) {
}
if (ticketId == null) {
NotificationUtil.sendErrorNotification(project, Constants.DBN_TITLE_PREFIX + "Error Reporting", "Failed to send error report");
return new SubmittedReportInfo(ISSUE_URL, "", FAILED);
}
String ticketUrl = URL + "issue/" + ticketId;
NotificationUtil.sendInfoNotification(project, Constants.DBN_TITLE_PREFIX + "Error Reporting",
"<html>Error report successfully sent. Ticket <a href='" + ticketUrl + "'>" + ticketId + "</a> created.</html>");
return new SubmittedReportInfo(ticketUrl, ticketId, NEW_ISSUE);
}