use of com.google.samples.apps.iosched.server.schedule.model.DataCheck.CheckFailure in project iosched by google.
the class APIUpdater method reportDataCheckFailures.
private void reportDataCheckFailures(CheckResult result, OutputStream optionalOutput) throws IOException {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("\nHey,\n\n" + "(this message is autogenerated)\n" + "\n** UPDATE: ignore the part of the message below that says the updater is halted. Halting the updating process is not implemented yet. **\n\n" + "The IOSched 2014 data updater is halted because of inconsistent data.\n" + "Please, check the messages below and fix the sources. " + /*+ "If you are ok with the data "
+ "even in an inconsistent state, you or other app admin will need to force an update by "
+ "clicking on the \"Force update\" button at https://iosched-updater-dev.appspot.com/admin/\n\n"*/
"\n\n" + result.failures.size() + " data non-compliances:\n");
for (CheckFailure f : result.failures) {
errorMessage.append(f).append("\n\n");
}
// Log error message to syslog, so that it's available even if the log is truncated.
Logger syslog = Logger.getLogger(APIUpdater.class.getName());
syslog.log(Level.SEVERE, errorMessage.toString());
// Send email with error message to project admins.
if (SystemProperty.environment.value() != SystemProperty.Environment.Value.Development || optionalOutput == null) {
// send email if user is not running in dev or interactive mode (show=true)
Message message = new Message();
message.setSender(Config.EMAIL_FROM);
message.setSubject("[iosched-data-error] Updater - Inconsistent data");
String errorMessageStr = errorMessage.toString();
if (errorMessageStr.length() > ADMIN_MESSAGE_SIZE_LIMIT) {
int truncatedChars = errorMessage.length() - ADMIN_MESSAGE_SIZE_LIMIT;
errorMessageStr = errorMessageStr.substring(0, ADMIN_MESSAGE_SIZE_LIMIT);
errorMessageStr += "\n\n--- MESSAGE TRUNCATED, " + truncatedChars + " CHARS REMAINING (CHECK LOG) ---";
}
message.setTextBody(errorMessageStr);
// TODO(arthurthompson): Reimplement mailing, it currently fails due to invalid sender.
//MailServiceFactory.getMailService().sendToAdmins(message);
} else {
// dump errors to optionalOutput
optionalOutput.write(errorMessage.toString().getBytes());
}
}
Aggregations