java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.EventLogHelper
Helper for router event log display and filtering. Renders system events including startup, crashes, network changes, and configuration updates. Provides filtering by event type and time range. Supports /events.jsp page in router console.
Nested Class Summary
Nested classes/interfaces inherited from class FormHandler
FormHandler.MessageModifier and TypeClassDescriptionstatic classMessage class to encapsulate the message text and the canClose flag.Field Summary
FieldsModifier and TypeFieldDescriptionprivate longAge of the events shown.private StringThe event type filtered for.private static final String[]The event names offered in the form.private longStart time of the events shown.private static final long[]The age options offered in the form, in seconds.The EventLog names mapped to translated display strings.private static final StringFilter value selecting every event.private static final longOne day, in seconds.private static final PatternMatches a single digit.private static final PatternMatches the text after an event name.Fields inherited from class FormHandler
_action, _context, _log, _method, _out, _requestWrapper, _session, _settingsModifier and TypeFieldDescriptionprotected StringForm action.protected RouterContextRouter context.protected LogClass logger.protected StringRequest method.protected WriterOutput writer.protected RequestWrapperOnly for multipart/form-data.protected HttpSessionHTTP session for nonce validation.protected MapNot for multipart/form-data, will be null.Constructor Summary
ConstructorsConstructorDescriptionPrepares the helper with an empty, pre-sized event translation map.Method Summary
Modifier and TypeMethodDescriptionGet the events.getForm()Get the form.protected voidDoes nothing; the event log page submits no form.voidsetContextId(String contextId) Configure this bean to query a particular router context.voidSet the from.voidSet the type.private voidwriteOption(long age) Write one age filter option.private voidwriteOption(String key, String val) Writes one option of the filter form.Methods inherited from class FormHandler
_t, _t, _t, _x, addFormError, addFormError, addFormErrorNoEscape, addFormErrorNoEscape, addFormNotice, addFormNotice, addFormNoticeNoEscape, addFormNoticeNoEscape, getAllMessages, getErrors, getJettyString, getNotices, isAdvanced, resolveEffectiveAction, setAction, setNonce, setRequestWrapper, setSettings, storeMethod, storeSession, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter This is a lot more expensive than _t(s), so use sparingly.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected voidaddFormError(String errorMsg) Add an error message to display Use if it does not include a link.protected voidaddFormError(String errorMsg, boolean canClose) Add an error message to display Use if it does not include a link.protected voidAdd an error message to display Use if it includes a link or other formatting.protected voidaddFormErrorNoEscape(String msg, boolean canClose) Add an error message to display Use if it includes a link or other formatting.protected voidaddFormNotice(String msg) Add a non-error message to display Use if it does not include a link.protected voidaddFormNotice(String msg, boolean canClose) Add a non-error message to display Use if it does not include a link.protected voidAdd a non-error message to display Use if it includes a link or other formatting.protected voidaddFormNoticeNoEscape(String msg, boolean canClose) Add a non-error message to display Use if it includes a link or other formatting.Display everything, wrap it in a div for consistent presentation.Display any error messages (processing the form if it hasn't been yet).protected StringgetJettyString(String key) FormHandler.setSettings(Map)must have been called previously Curses Jetty for returning arrays.Display any non-error messages (processing the form if it hasn't been yet).booleanSame as HelperBase.static StringresolveEffectiveAction(String action, Map<?, ?> settings) Resolve which operation the user actually requested.voidAction value.voidNonce value.voidOnly set by formhandler.jsi for multipart/form-data.voidsetSettings(Map settings) For many forms, it's easiest just to put all the parameters here.voidstoreMethod(String val) Call this to prevent changes using GET.voidstoreSession(HttpSession session) For nonce validation.voidstoreWriter(Writer out) Store the output writer for inline form processing.
Field Details
EVENT_SPACE
Matches the text after an event name.EVENT_DIGIT
Matches a single digit._from
private long _fromStart time of the events shown._age
private long _ageAge of the events shown._event
The event type filtered for._xevents
ALL
_events
The event names offered in the form.DAY
_times
private static final long[] _timesThe age options offered in the form, in seconds.
Constructor Details
EventLogHelper
public EventLogHelper()Prepares the helper with an empty, pre-sized event translation map.
Method Details
processForm
protected void processForm()Does nothing; the event log page submits no form.- Specified by:
processFormin classFormHandler
setContextId
Description copied from class:FormHandlerConfigure this bean to query a particular router context.- Overrides:
setContextIdin classFormHandler- Parameters:
contextId- beginning few characters of the routerHash, or null to pick the first one we come across.
setFrom
Set the from.- Parameters:
s- the age of the events to list, in seconds; anything unparsable or zero shows all
setType
Set the type.- Parameters:
s- the event category to list, or the all-categories value to show every type
getForm
Get the form.- Returns:
- always the empty string, as required by the JSP getter convention; the markup is written to the response writer
writeOption
Writes one option of the filter form.- Parameters:
key- the option valueval- the option label- Throws:
IOException- if the writing fails
writeOption
Write one age filter option.- Parameters:
age- lookback window in seconds; 0 renders as "All events"- Throws:
IOException- if the output writer fails
getEvents