public void updateProgress(final int progress) { event.setProgress(progress); } }
public String toString() { return "(Event: Level = " + (getLevel() == null ? "" : getLevel() + " ") + ", Key = " + (getKey() == null ? "" : getKey() + " ") + ", Desc = " + (getDesc() == null ? "" : getDesc() + " ") + ", Exception = " + (getException() == null ? "" : getException() + ")"); }
/** * 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)); }
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); } } }
/** * 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; }
public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof EventType) { EventType e = (EventType) o; return Objects.equals(getDescription(), e.getDescription()) && Objects.equals(getType(), e.getType()); } return false; }
protected String getStringForEvents(Collection<Event> events) { StringBuilder message = new StringBuilder(); for (Event event : events) { if (message.length() > 0) { message.append("\n"); } message.append(event.getDesc()); } return message.toString(); }
/** * Adds the Johnson {@link Event} wrapped by the provided {@link AddEvent} to the container. * * @param e the add event */ @EventListener public void onAdd(@Nonnull AddEvent e) { getContainer().addEvent(e.getEvent()); }
/** * Attempts to remove the Johnson {@link Event} wrapped by the provided {@link RemoveEvent} from the container. * * @param e the remove event */ @EventListener public void onRemove(@Nonnull RemoveEvent e) { getContainer().removeEvent(e.getEvent()); }
public Event(EventType key, String desc, String exception, EventLevel level) { this.desc = desc; this.exception = exception; this.key = key; this.level = level; attributes = new HashMap<>(); date = getFormattedDate(); progress = -1; }
public int hashCode() { return Objects.hash(getKey(), getDesc(), getException(), getLevel(), getDate()); }
/** * Matches events which have the specified {@link EventType type}. * * @param type the type to compare against * @return a {@code Predicate} which returns {@code true} for {@link Event events} whose {@link Event#getKey keys} * match the provided {@link EventType}, and {@code false} for all others */ @Nonnull public static Predicate<Event> type(EventType type) { requireNonNull(type, "type"); return event -> type.equals(event.getKey()); } }
/** * 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(getType(), getDescription()); }
@Override public void makeProgress(long taskProgress, String currentSubTask, String message) { event.setProgress((int) taskProgress); } }
/** * 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); }