Nov 9, 2021 3:32:39 PM Thomas Dumont avatar

ContentService

Definition

A content service is a content service that is responsible for producing himself his pages. Each content service has a call parameter that allows to the portal to dispatcher requests on the service.

Core's ContentServices

Lutece integrates by default several ContentServices :

Service Parameter Description
PageService id_page Lutece page construction and display service
ArticleService id_article Building and display service of Lutece items
SearchService query Lutece Research Service
XPageService page Lutear's XPage Application Container

Creating a ContentService

Declaration

Plugins can add new ContentServices by declaring them in their XML file as follows :

<!-- Contents Service -->
<content-services>
    ...
    <content-service>
        <content-service-id>myContentService</content-service-id>
        <content-service-class>fr.paris.lutece.plugins.myplugin.service.MyContentService</content-service-class>
    </content-service>
    ...
</content-services>

Implementation

A ContentService must extend the abstract class ContentService. The abstract methods of this class are as follows :

Method Description
getName Returns the name of the content service.
isInvoked Determines from the parameters of the HTTP request, if it is intended for it. For example, the PageService service will check that the query contains the id_page parameter.
getPage Constructs a page for query and mode parameters.

Through the ContentService class, the service inherits the AbstractCacheableService class that provides the cache functionality of the generated content. The following methods can be overriden to disable or modify it (see Cache management) :

Method Description
isCacheEnable Indicates whether the service has a cache enabled.
getCacheSize Returns the number of objects in the cache.
resetCache Empty the content service cache.