java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigClientsHandler
Handles configuration changes for I2P client applications and web apps. Saves changes to
clients.config and webapps.config files, manages client installation, updates, and startup configuration.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
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
ConstructorsMethod Summary
Private MethodsModifier and TypeMethodDescriptionprivate voidcheckPlugin(String app) Checks the plugin for an update.private voiddeleteClient(int i) Deletes the client at the index.private voidInstalls the plugin from the form.private voidinstallPlugin(String app, String url) Install a plugin from a URL.private voidInstall a plugin from a local file upload.protected voidImplement this to perform the final processing (in turn, adding formNotice and formError messages, etc)private voidSaves the client changes from the form.private voidWrites the client changes to the config.private voidHandle interface form.private voidSaves the plugin changes from the form.private voidSaves the webapp changes from the form.private voidstartClient(int i) Starts the client at the index.private voidstartPlugin(String app) Starts the plugin.private voidstartWebApp(String app) Big hack for the moment, not using properties for directory and port Go through all the Jetty servers, find the one serving port 7657, requested and add the .war to that one.private voidstopClient(int i) Stop a running client by index.private voidUpdate all installed plugins.private voidupdatePlugin(String app) Updates the plugin from the update site.private booleanPlugin checks, updates, and installs are always proxied.Methods inherited from class FormHandler
_t, _t, _t, _x, addFormError, addFormError, addFormErrorNoEscape, addFormErrorNoEscape, addFormNotice, addFormNotice, addFormNoticeNoEscape, addFormNoticeNoEscape, getAllMessages, getErrors, getJettyString, getNotices, isAdvanced, resolveEffectiveAction, setAction, setContextId, 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.voidsetContextId(String contextId) Configure this bean to query a particular router context.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.
Constructor Details
ConfigClientsHandler
public ConfigClientsHandler()Construct a new ConfigClientsHandler.
Method Details
processForm
protected void processForm()Description copied from class:FormHandlerImplement this to perform the final processing (in turn, adding formNotice and formError messages, etc)Will only be called if _action is non-null and the nonce is valid.
- Specified by:
processFormin classFormHandler
saveClientChanges
private void saveClientChanges()Saves the client changes from the form.saveClientChanges2
Writes the client changes to the config.- Throws:
IOException- if the writing fails
stopClient
private void stopClient(int i) Stop a running client by index.- Parameters:
i- index into the client app list of the client to stop
startClient
private void startClient(int i) Starts the client at the index.- Parameters:
i- the index of the client
deleteClient
private void deleteClient(int i) Deletes the client at the index.- Parameters:
i- the index of the client
saveWebAppChanges
private void saveWebAppChanges()Saves the webapp changes from the form.savePluginChanges
private void savePluginChanges()Saves the plugin changes from the form.startWebApp
Big hack for the moment, not using properties for directory and port Go through all the Jetty servers, find the one serving port 7657, requested and add the .war to that one.- Parameters:
app- the web app name, also the base name of the .war file in webapps
installPlugin
private void installPlugin()Installs the plugin from the form.installPluginFromFile
private void installPluginFromFile()Install a plugin from a local file upload.updatePlugin
Updates the plugin from the update site.- Parameters:
app- the name of the plugin
updateAllPlugins
private void updateAllPlugins()Update all installed plugins.installPlugin
checkPlugin
Checks the plugin for an update.- Parameters:
app- the name of the plugin
verifyProxy
private boolean verifyProxy()Plugin checks, updates, and installs are always proxied. See if the proxy tunnel is available, unless we're configured to use something else (probably not). Outputs form error if returning false.- Returns:
- true if available
startPlugin
saveInterfaceChanges
private void saveInterfaceChanges()Handle interface form.