This library provides services to send notifications to the GRU.
The main service is fr.paris.lutece.plugins.librarynotifygru.services.NotificationService
which consumes a fr.paris.lutece.plugins.grubusiness.business.notification.Notification
object (see javadoc for details on the object).
It requires an implementation of fr.paris.lutece.plugins.librarynotifygru.services.INotificationTransportProvider
to define the HTTP transport. Two implementations of this interface are provided in the library :
fr.paris.lutece.plugins.librarynotifygru.rs.service.NotificationTransportApiManagerRest
, which uses ApiManager WSO2 in order to secure requests to the API (by using tokens)fr.paris.lutece.plugins.librarynotifygru.rs.service.NotificationTransportRest
, which uses simple requests
Both implementations require URL definition of the notification service end point. This URL is stored in the attribute notificationEndPoint
. The NotificationTransportApiManagerRest
implementation requires extra properties.
First, define the bean for the HTTP transport you want to use:
- set the property for the URL of the notification service end point
- set other properties if using the HTTP transport
NotificationTransportApiManagerRest
Then, define the bean for the service NotificationService
:
- as a constructor argument, refer to the bean for HTTP transport
Here is an example of Spring configuration with the HTTP transport NotificationTransportRest
:
<bean id="lib-notifygru.simpleTransport" class="fr.paris.lutece.plugins.librarynotifygru.rs.service.NotificationTransportRest">
<property name="notificationEndPoint">
<value>http://mydomain.com/url/to/notification</value>
</property>
</bean>
<bean id="lib-notifygru.notificationService" class="fr.paris.lutece.plugins.librarynotifygru.services.NotificationService">
<constructor-arg ref="lib-notifygru.simpleTransport"/>
</bean>
Here is an example of Spring configuration with the HTTP transport NotificationTransportApiManagerRest
:
<bean id="lib-notifygru.apiManagerTransport" class="fr.paris.lutece.plugins.librarynotifygru.rs.service.NotificationTransportApiManagerRest">
<property name="notificationEndPoint">
<value>http://mydomain.com/url/to/apimanager/api/notification</value>
</property>
<property name="apiManagerEndPoint">
<value>http://mydomain.com/url/to/apimanager/token</value>
</property>
<property name="apiManagerCredentials">
<value>your_private_key</value>
</property>
</bean>
<bean id="lib-notifygru.notificationService" class="fr.paris.lutece.plugins.librarynotifygru.services.NotificationService">
<constructor-arg ref="lib-notifygru.apiManagerTransport"/>
</bean>
The service can directly be created in the Java code. Here is an example with the HTTP transport NotificationTransportApiManagerRest
(the same mechanism can be applied for the HTTP transport NotificationTransportRest
).
First, define the following keys in a properties file:
myplugin.endpoint.notification=http://mydomain.com/url/to/apimanager/api/notification
myplugin.endpoint.token=http://mydomain.com/url/to/apimanager/token
myplugin.apimanager.credentials=your_private_key
Then, add the following code in the Java code:
private static final String PROPERTY_ENDPOINT_NOTIFICATION = "myplugin.endpoint.notification";
private static final String PROPERTY_ENDPOINT_TOKEN = "myplugin.endpoint.token";
private static final String PROPERTY_APIMANAGER_CREDENTIALS = "myplugin.apimanager.credentials";
...
NotificationTransportApiManagerRest apiManagerTransport = new NotificationTransportApiManagerRest( );
apiManagerTransport.setNotificationEndPoint( AppPropertiesService.getProperty( PROPERTY_ENDPOINT_NOTIFICATION ) );
apiManagerTransport.setApiManagerEndPoint( AppPropertiesService.getProperty( PROPERTY_ENDPOINT_TOKEN ) );
apiManagerTransport.setApiManagerCredentials( AppPropertiesService.getProperty( PROPERTY_APIMANAGER_CREDENTIALS ) );
NotificationService notificationService = new NotificationService( apiManagerTransport );
Maven documentation and reports
generated by xdoc2md - do not edit directly.