Sep 10, 2018 2:48:15 PM seb leridon avatar   1920

Lutece plugins

Introduction


Plugins are components that can be added to Lutece to extend its functionality. They are intended to integrate different types of features by respecting the same mode of installation. The common step of installing a plugin is as follows:

  • Stop the Webapp
  • Unzip the plugin binary distribution in the webapp directory
  • [optional] Execute the scripts for creating and / or initializing the tables associated with the plugin (Cf. below to locate these scripts in different distributions)
  • [optional] Configure plugin properties file
  • [optional] Configure the Lutece db.properties file to add a new specific connection pool to the plugin
  • Restart the Webapp
  • Log in ad Admin and go to the Manage plugins function
  • The new plugin should appear not installed in the list of plugins. Click on Install.
  • [optional] Select the connection pool that may be used by the plugin.

Extensions brought by the plugins

Several types of extensions are planned:

  • new type of porlet [Portlets]
  • new integrated application [Application]
  • new administration feature [Administrative functions]
  • new content service [ContentServices]
  • new insert link service [InsertServices]
  • new page inclusion service [PageIncludeServices]
  • new servlet or servlet filter [PageIncludeServices]

A plugin can contain one or more types of extensions. By example, it can introduce a new type of portlet and two administration functions to handle this type of portlet.

In summary, a plugin can contain:

  • 0 to n applications
  • 0 to n specific CSS style sheets
  • 0 to n specific Javascript scripts
  • 0 to n administration functions
  • 0 to n portlets
  • 0 to 1 content service
  • 0 to 1 LinkService insertion services
  • 0 to 1 insertion services of type HtmlService
  • 0 to n servlets or servlet filters
  • 0 to n dashboard

Plugins and databases

A plugin can access two databases. he can access the Lutece database through the class AppConnectionService , but it is also possible to assign a specific connection pool to it, declared in the db.properties configuration file.

Loading plugins

The plugins are loaded at the start of the webapp by the service PluginService that searches all XML files in the / WEB-INF / plugins directory. To not load a plugin, just remove the XML file from this directory.

Information about the local status of plugins (status installed / non-installed, specific connection pool, ...) are saved in the plugins.dat file located in the same directory.

If a plugin has a properties file, it must be found in the directory / WEB-INF / conf / plugins . The properties of this plugin will be automatically loaded and added to the properties of the application. They will then be accessible through the class AppPropertiesService . All properties of a plugin must be prefixed by the name of the plugin to avoid especially any conflict.

The plugin files

A plugin may require a fairly large set and various files. Here are the directories designated for hold these files

File Type Directory
JSP administrative functions / jsp / admin / plugins / <plugin_name> / *. Jsp
Accessible JSPs from the portal / jsp / site / plugins / <plugin_name> / *. Jsp
Administration function images / images / admin / skin / plugins / <plugin_name>
Presentation images of the application / images / local / skin / <plugin_name> /*.*
Images managed as plugin data / images / local / data / <plugin_name> /*.*
Plugin properties file / WEB-INF / conf / plugins / <plugin_name> .properties
The plugin definition file / WEB-INF / plugins / <plugin_name> .xml
Administrative function templates / WEB-INF / templates / admin / plugins / <plugin_name> .properties
Application templates accessible from the portal / WEB-INF / templates / skin / plugins / <plugin_name> .properties
The jar file containing the plugin classes / WEB-INF / lib / plugin_ <plugin_name> _ <version> .jar
SQL scripts for installing and initializing plugin tables (binary distribution) / WEB-INF / sql / plugins / <plugin_name> / *. Sql

The organization of the source files is also the following

File Type Directory
Java source files for the business layer / src / java / en / lutece / plugins / <plugin_name> / business / *. Java
Java source files from the service layer / src / java / en / lutece / plugins / <plugin_name> / service / *. Java
Java source files of the presentation layer / src / java / en / lutece / plugins / <plugin_name> / web / *. Java
Message type resources in different languages ​​/ src / java / en / lutece / plugins / <plugin_name> / resources / *. Properties
SQL scripts for installing and initializing plugin tables (source distribution) / src / sql / plugins / <plugin_name> / *. Sql
Documentation in XML format for Maven / src / site / xdoc / [en /] / xdoc / plugins / <plugin_name> / *. Xml

The plugin configuration file

The configuration file of a plugin is an XML file like :

<?xml version=1.0 encoding=ISO-8859-1?>
<plug-in>
      <name>myplugin</name>
      <class>fr.paris.lutece.portal.service.PluginDefaultImplementation</class>
      <version>1.0</version>
      <description>Description of the plugin</description>
      <provider>Mairie de Paris</provider>
      <provider-url>http://lutece.paris.fr</provider-url>
      <icon-url>../../images/admin/skin/plugins/myplugin/myplugin.gif</icon-url>
      <copyright>Copyright (c) 2001-2008 Mairie de Paris</copyright>

      <!-- Le plugin requiert-il un pool de connexions : 1 - oui, 0 - non -->
      <db-pool-required>1</db-pool-required>

      <!-- Feuilles de style CSS spécifiques éventuelles -->
      <css-stylesheets>
      <css-stylesheet>myplugin/myplugin.css</css-stylesheet>
      </css-stylesheets>

      <!-- Scripts eventuels -->
      <javascript-files>
             <javascript-file>myplugin/myplugin.css</javascript-file>
      </javascript-files>

      <!-- Listes des fonctionnalités d'administration éventuellement introduites par le plugin-->
      <admin-features>
             <admin-feature>
                    <feature-id>MYFEATURE_MANAGEMENT</feature-id>
                    <feature-title>My Feature</feature-title>
                    <feature-description>Description of my feature</feature-description>
                    <feature-level>3</feature-level>
                    <feature-url>plugins/myplugin/ManageMyFeature.jsp</feature-url>
             </admin-feature>
...
      </admin-features>

      <!-- Listes des portlets éventuellement introduits par le plugin-->
      <portlets>
             <portlet>
                    <portlet-class>fr.paris.lutece.plugins.myportlet.business.portlet.MyPortletHome</portlet-class>
                    <portlet-type-name>MyNew Portlet</portlet-type-name>
                    <portlet-creation-url>plugins/article/CreatePortletMyPortlet.jsp</portlet-creation-url>
                    <portlet-update-url>plugins/article/ModifyPortletMyPortlet.jsp</portlet-update-url>
             </portlet>
...
      </portlets>

      <!-- Application à base de pages spéciales introduite éventuellement par le plugin -->
      <applications>
             <application>
                    <application-id>app_page_name</application-id>
                    <application-class>fr.paris.lutece.plugins.myplugin.web.MyPluginApp</application-class>
                    <application-roles>role1,role2</application-roles>
             </application>
      </applications>

      <!-- Content Service -->
      <content-service>
             <content-service-class>fr.paris.lutece.plugins.myplugin.service.MyContentService</content-service-class>
      </content-service>

      <!-- Links Service -->
             <link-service>
                    <link-service-id>mylinkservice</link-service-id>
                    <link-service-class>fr.paris.lutece.plugins.mylinkservice.service.MyLinkService</link-service-class>
                    <link-service-bean-class>fr.paris.lutece.plugins.mylinkservice.web.MyLinkServiceJspBean</link-service-bean-class>
                    <link-service-label>Link to my URIs</link-service-label>
             </link-service>

      <!-- Servlets-->
      <servlets>
             <servlet>
                    <servlet-name>myServlet1</servlet-name>
                    <url-pattern>/servlet/plugins/myplugin/myServlet1</url-pattern>
                    <servlet-class>fr.paris.lutece.plugins.myplugin.web.MyFirstServlet</servlet-class>
             </servlet>
             <servlet>
                    <servlet-name>myServlet2</servlet-name>
                    <url-pattern>/servlet/plugins/myplugin/myServlet2</url-pattern>
                    <servlet-class>fr.paris.lutece.plugins.myplugin.web.MySecondServlet</servlet-class>
             </servlet>
      </servlets>

      <!-- filters -->
      <filters>
             <filter>
                    <filter-name>myFilter</filter-name>
                    <url-pattern>/*</url-pattern>
                    <filter-class>fr.paris.lutece.plugins.myplugin.web.MyFilter</filter-class>
                    <init-param>
                           <param-name>param1</param-name>
                           <param-value>value of param1</param-value>
                    </init-param>
             </filter>
      </filters>

</plug-in>

A plugin DTD is available in the directory /WEB-INF/plugins of the Lutece Webapp.

Modules

Some plugins may have their own plugins. These are called modules. Plugins such as mylutece, formengine, codewizard have modules.

The rules for the modules are as follows:

File Type Directory
Java source file packages / src / java / en / lutece / plugins / <plugin_name> / modules / <module_name> / / *. Java
HTML template file localization / plugins / <plugin_name> / modules / <module_name> / / *. Html
Name and location of plugin XML file / WEB-INF / plugins / <plugin_name> - <module_name> .xml
Name and location of the configuration file / WEB-INF / conf / plugins / <plugin_name> - <module_name> .properties