Fork me on GitHub

Lutece Services : Base Services

AppPropertiesService

The service allows to access to all parameters defined in the properties files. The files taken into account by this service are Lutece configuration files placed into WEB-INF/conf folder and plugins configuration files placed in WEB-INF/conf/plugins folder.

Use this type of service as described below :

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

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

AppTemplateService

This service allows loading of HTML templates within which the bookmarks can be substituted. The templates are stored in the WEB-INF/templates folder. We can identify administrative templates (Back Office) and site templates (Front office).

Use the service as follows :

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

The service allows to obtaining information concerning the URI execution and the Lutece's installation folders. The plugins must not handle URL or absolute paths, it must generate with relative paths and use this service to obtain absolute references.

Use the service as follows :


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

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

AppConnectionService

This service help to obtain a portal database connection. This service is now encapsulated in DAOUtil objects. To obtain more information about databases refer to Development Guide : Data Access

Use the service as follows :


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

AppLogService

This service enables logging of particular events during runtime in log files (errors, information on loading , ...).

catch( Exception e )
{
     AppLogService.error( e.getMessage() , e );
}                       
To obtain more information refer to Development Standard : Logging rules and exception handling