/** * Returns the {@link EventLevel#WARNING} event level, if it has been defined. * * @return the {@link EventLevel#WARNING} level, or {@code null} if the application does not define it * @throws IllegalStateException if Johnson has not been initialised */ @Nullable public static EventLevel warning() { return get(WARNING); } }
public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof EventLevel) { EventLevel e = (EventLevel) o; return Objects.equals(getDescription(), e.getDescription()) && Objects.equals(getLevel(), e.getLevel()); } return false; }
@Override protected boolean matchesSafely(Event item, Description mismatchDescription) { return level.equals(item.getLevel().getLevel()); }
/** * We go through all the johnson events and see if we find any ERROR or FATAL message. * * @return true if the server is reporting errors, false if not */ public boolean hasErrors() { final JohnsonEventContainer johnsonEventContainer = getJohnsonContainer(); if (johnsonEventContainer != null && johnsonEventContainer.hasEvents()) { final Collection<Event> events = johnsonEventContainer.getEvents(); for (Event event : events) { if (event.getLevel() != null) { final String level = event.getLevel().getLevel(); if (EventLevel.ERROR.equals(level) || EventLevel.FATAL.equals(level)) { return true; } } } } return false; }
/** * Returns the {@link EventLevel#FATAL} event level, if it has been defined. * * @return the {@link EventLevel#FATAL} level, or {@code null} if the application does not define it * @throws IllegalStateException if Johnson has not been initialised */ @Nullable public static EventLevel fatal() { return get(FATAL); }
public int hashCode() { return Objects.hash(getLevel(), getDescription()); }
for (Event event : container.getEvents()) { EventLevel level = event.getLevel(); if (EventLevel.FATAL.equals(level.getLevel())) { LOG.error("Bypassing Spring ApplicationContext initialisation; a previous {} error was found: {}", level.getLevel(), event.getDesc()); servletContext.setAttribute(ATTR_BYPASSED, Boolean.TRUE); level.getLevel() + " error"; container.addEvent(new Event(EventType.get(eventType), message, level));
/** * Returns the {@link EventLevel#ERROR} event level, if it has been defined. * * @return the {@link EventLevel#ERROR} level, or {@code null} if the application does not define it * @throws IllegalStateException if Johnson has not been initialised */ @Nullable public static EventLevel error() { return get(ERROR); }
/** * A fail-safe event creator with reliable semantics to fall back on when a more specific {@link Event event} is * not available. * * @param eventType the event type to use * @param message the message to use * @param t the exception thrown while attempting to initialise the WebApplicationContext * @return the event to add to Johnson, which will never be {@code null} */ @Nonnull public static Event createDefaultEvent(@Nonnull String eventType, @Nonnull String message, @Nonnull Throwable t) { return new Event(EventType.get(eventType), message, Event.toString(t), EventLevel.get(EventLevel.FATAL)); }
void addErrors( final Set<Plugin> outdatedPlugins) { final String description = "Plugins found that are not compatible with JIRA v" + buildUtilsInfo.getVersion() + ". " + "The following plugins need to be either removed or updated in order for JIRA to start successfully:"; final StringBuilder pluginNames = new StringBuilder(); for (Plugin outdatedPlugin : outdatedPlugins) { pluginNames.append(pluginsToCheck.get(outdatedPlugin.getKey()).getErrorMessage(outdatedPlugin)).append("\n"); } final String cacMessage = "Please visit " + PAC_LINK + " to download the latest versions of these plugins."; final List<String> messages = CollectionBuilder.newBuilder("", description, "", pluginNames.toString().trim(), "", cacMessage, "").asList(); startupLog.printMessage(messages, Level.ERROR); final Event event = new Event(EventType.get("outdated-plugins-installed"), description + "<p/>" + TextUtils.plainTextToHtml(pluginNames.toString()) + "<p/>" + TextUtils.plainTextToHtml(cacMessage), EventLevel.get(EventLevel.ERROR)); final JohnsonEventContainer eventCont = johnsonProvider.getContainer(); eventCont.addEvent(event); }
private static void addEventsForErrors(final JohnsonEventContainer cont, final UpgradeManager.Status status) { if (cont != null && status != null && !status.successful()) { for (final String exception : status.getErrors()) { final Event errorEvent = new Event(EventType.get("upgrade"), "An error occurred performing JIRA upgrade", exception, EventLevel.get(EventLevel.ERROR)); cont.addEvent(errorEvent); } } }
private void raiseJohnson(final StartupCheck failedCheck) { String desc = failedCheck.getFaultDescription(); log.error(failedCheck.getName() + " failed: " + desc); log.error("Clustering startup check failed."); final EventType eventType; if (failedCheck instanceof ClusterLicenseStartupCheck) { eventType = EventType.get(LicenseJohnsonEventRaiser.CLUSTERING_UNLICENSED); } else { eventType = EventType.get(LicenseJohnsonEventRaiser.CLUSTERING); } Event event = new Event(eventType, failedCheck.getHTMLFaultDescription(), EventLevel.get(ERROR)); johnsonProvider.getContainer().addEvent(event); }
final Event event = new Event(eventType, "Please restart JIRA to complete the HSQL to H2 database migration", EventLevel.get(FATAL)); johnsonProvider.getContainer().addEvent(event);
final Event appEvent = new Event(EventType.get("reindex"), johnsonMessage, EventLevel.get(EventLevel.WARNING)); try
EventType.get(STARTUP_UNEXPECTED), "Unexpected exception during JIRA startup. This JIRA instance " + "will not be able to recover. Please check the logs for details", EventLevel.get("fatal")));
@Override public void start() { final JiraDatabaseConfigChecklist jiraPostDatabaseChecklist = new JiraDatabaseConfigChecklist(dbcm, jiraSystemProperties, buildUtilsInfo); if (jiraPostDatabaseChecklist.startupOK()) { log.info("JIRA database startup checks completed successfully."); } else { final StartupCheck failedCheck = jiraPostDatabaseChecklist.getFailedStartupCheck(); final String desc = failedCheck.getFaultDescription(); log.error(failedCheck.getName() + " failed: " + desc); log.error("Database startup check failed - this is FATAL - JIRA will not be in a working state."); final EventType eventType = EventType.get("database"); final Event event = new Event(eventType, failedCheck.getHTMLFaultDescription(), EventLevel.get(ERROR)); johnsonProvider.getContainer().addEvent(event); } }
EventLevel.get(EventLevel.ERROR)); event.addAttribute("lockfiles", sb.toString()); addJohnsonEvent(event);
@Override public IndexCommandResult call() throws Exception { final Event appEvent = new Event(EventType.get("reindex"), JIRA_INDEX_RECOVERY_MSG, EventLevel.get(EventLevel.WARNING)); try { final Context context = Contexts.builder() .sized(indexRecoveryService) .event(appEvent) .progress(taskProgressSink, i18nHelper, REINDEX_PERCENT, REINDEX_CURRENT) .log(log, "Index Recovery: {0}%") .build(); log.info("Re-indexing started"); return indexRecoveryService.recoverIndexFromBackup(user, context, i18nHelper, recoveryFilename, taskProgressSink); } finally { log.info("Index Recovery finished"); } }
public IndexCommandResult call() { // We use a null user here to get the Johnson message in the default language for this JIRA instance. final String johnsonMessage = i18nBeanFactory.getInstance((ApplicationUser) null).getText("admin.reindex.in.progress.johnson.summary"); final Event appEvent = new Event(EventType.get("reindex"), johnsonMessage, EventLevel.get(EventLevel.WARNING)); if (eventCont != null) { eventCont.addEvent(appEvent); } try { final Context context = Contexts.percentageReporter(indexManager, taskProgressSink, i18nHelper, log, appEvent); log.info("Re-indexing started"); return doReindex(context, indexManager); } finally { if (eventCont != null) { eventCont.removeEvent(appEvent); } log.info("Re-indexing finished"); } }