Mar 6, 2018 4:50:41 PM seb leridon avatar   672

Basic Services of Lutece

AppPropertiesService

This service provides access to all the parameters defined in the properties files. The files taken into account by this service are the Lutece configuration files located in the WEB-INF / conf directory and those of the plugins located in WEB-INF / conf / plugins.

The typical use of this service is:

private static final String PROPERTY_NAME = "myplugin.name";
...

{
    ...
    String strName = AppPropertiesService.getProperty (PROPERTY_NAME);
    ...
}

AppTemplateService

This service allows to load HTML templates on which substitutions can be made to value bookmarks (bookmarks). Templates are stored under the WEB-INF / templates directory. However, there are templates for administration (Back Office) and those of the site (Front Office).

The typical use of this service is:

private static final String TEMPLATE_MANAGE_MYPLUGIN = "admin / plugins / myplugin / manage_myplugin.html";
...
private static final String BOOKMARK_NAME = "@ name @";
...

{
    ...
    HtmlTemplate template = AppTemplateService.getTemplate (TEMPLATE_MANAGE_MYPLUGIN);
    template.subtitute (BOOKMARK_NAME, strName);
    ...
}

AppPathService

This service allows you to obtain information about the execution URIs or Lut├Ęce installation directories. Plugins must not handle URIs or absolute paths, they must handle them in a relative way and use this service to obtain absolute references.

The typical use of this service is:

{
    // Get the base URL (ie: "http: // localhost: 8080 / lutece /")
    String strBaseUrl = AppPathService.getBaseUrl (request);

    ...

    // Get the WebApp absolute path (ie: "/ usr / local / tomcat / webapps / lutece")
    String strWebAppPath = AppPathService.getWebAppPath ();

}

AppConnectionService

This service provides a connection to the portal database. This service is now encapsulated in DAOUtil objects. For more information on accessing data see the document Development Guide: Accessing Data

The typical use of this service is:

{
    Connection connection = AppConnectionService.getConnection ();
    ...

    AppConnectionService.freeConnection ();

}

AppLogService

This service makes it possible to record in a log file particular events in the execution of the application (errors, loading information, ...).

catch (Exception e)
{
     AppLogService.error (e.getMessage (), e);
}