{{sidenavigation.sidenavigationExpandLabel}}
{{getMsg('Help_YouAreHere')}}: {{page.title}} {{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}} {{helpModel.downloadHelpPdfDataStatus}}

Core API

The following API is provided in inetcore.jar. Additional plugins may be needed, depending on how many of the user-facing features are required.

Logging API

There is a wide range of popular logging APIs in the wild, however we offer our own API, since the logging is intended to be exposed within the "Statistics" web application for searching and reading log entries. Logging can be configured in the configuration manager if the "Configuration" plugin is available.

A typical usage looks like:

import com.inet.logging.*;
...
static final Logger LOGGER = LogManager.getLogger( "MyPlugin" );
...
try {
    ...
} catch( Exception ex ) {
    LOGGER.error( ex );
}

For the name of the logger you need to note the following guidelines:

  • It is case-sensitive.
  • It is used in the configuration manager web application to enable the log level.
  • It is shown in log file in the log entries' line prefix.
  • It should be initialized very early on, for example in the ServerPlugin class itself. If the logger was not initialized at all, it will not be visible in the server's web applications.

If you use your own exceptions in your plugin, then it is recommended to implement the interface com.inet.error.HasErrorCode. This has advantages for the "errorhandler" plugin. This error handler can send errors as emails to an administrator. The administrator can filter emails based on the error code provided by implementors of this interface in order to ignore unimportant or minor errors.

If you want change the log level of your logger, then you need select the customized log level in the configuration manager, and then change the level of your logger. Otherwise, the default log level of your logger is only Error. If you want your logger to always have the same log level as the global logger, then you need to register it as a core logger with:

CoreLoggers.addLoggers( "MyPlugin" );

Configuration API

To access a configuration value you can use the following code.

import com.inet.config.*;
...
Configuration config = ConfigurationManager.getCurrent();
//get a value
String val = config.get( "MyKey" );
 
//put a value
config.put( "MyKey", "MyValue" );

Configuration values can be changed by the user via the configuration manager. The configuration manager is contained in the plugin "configuration". If you use your own configuration key names then the user can see and change them in the dialog "Other" in the configuration manager web interface.

If you want add your own dialog to the configuration manager web application then you need to extend com.inet.config.structure.provider.AbstractStructureProvider and register it as com.inet.config.structure.provider.ConfigStructureProvider in your ServerPlugin in the initialization phase.

import com.inet.plugin.*;
import com.inet.config.structure.provider.*;
...
public void registerExtension( ServerPluginManager spm ) {
    spm.register( ConfigStructureProvider.class, new MyPluginStructureProvider() );
}

Help API

If you want add your own help content for your users, then this is also possible. The help must be written in the JavaHelp format. The helpset must be saved in the sub-package help relative to the ServerPlugin. You can find examples of this in existing plugin zip files. To be able to display the help files to the user, the "help" plugin is needed.

import com.inet.plugin.*;
import com.inet.plugin.help.*;
...
public void registerHelp( HelpProviderContainer container ) {
    //If this ServerPlugin is named com.mycompany.myplugin.MyPluginServerPlugin 
    //then there must be a file /com/mycompany/myplugin/help/myhelpset.hs
    container.add( new HelpProviderImpl( "myhelpset", 0, null ) {} );
}

Mail API

The server has also email settings if the mail plugin is installed. If you want use the global settings then you need only to extends from com.inet.mail.BaseEmail, implement the needed methods and then call send(). You need also add a dependency to the 'mail' plugin in your plugin.

Permissions API

In case you do not want every user to be able access to your feature, you will need to check the permission of the currently logged in user.

First you register a new permission in the permission manager. You should do this as early in your plugin's lifecycle as possible. The best is directly in your ServerPlugin class, like so:

import com.inet.permissions.*;
...
public static final Permission MY_PERMISSION = SystemPermissionManager.add( "myplugin", false, MyPlugin.class );

Later you can check the access rights like so:

import com.inet.permissions.*;
...
if( !SystemPermissionChecker.checkAccess( MY_PERMISSION ) ) {
    throw new AccessDeniedException("You need to login for myplugin.");
}

Throwing an AccessDeniedException may send a login request to the client depending the login configuration to enable a user who is not logged in to log in right away.

i-net Clear Reports
This application uses cookies to allow login. By continuing to use this application, you agree to the use of cookies.


Help - Core API