Package org.ametys.plugins.glpi
Class TicketGlpiManager
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.glpi.TicketGlpiManager
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Initializable
,Component
,Serviceable
public class TicketGlpiManager
extends AbstractLogEnabled
implements Component, Initializable, Serviceable, PluginAware
Connection and information from GLPI webservice
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
The Glpi cache loader. -
Field Summary
Modifier and TypeFieldDescriptionprotected LoadingCache<UserIdentity,
Map<String, Object>> The user information cache.The user information cache.protected long
The cache TTL in minutes.protected long
Maximum cache size, in number of records.static final String
Avalon ROLE. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getCountOpenTickets
(UserIdentity userIdentity) Get the number of open ticketsgetGlpiStatusLabel
(int status) Get the i18n label of a GLPI statusgetGlpiTickets
(CloseableHttpClient httpclient, String glpiUrl, String sessionToken, String apptoken, Integer userId) Get the GLPI ticketsgetGlpiTypeLabel
(int type) Get the i18n label of a GLPI ticket typegetOpenTickets
(UserIdentity userIdentity) Get all information about open ticketsprotected String
getTicketSearchQuery
(Integer userId) Get the part of rest API url for tickets searchprotected Integer
getUserIdentity
(CloseableHttpClient httpclient, UserIdentity userIdentity, String glpiUrl, String sessionToken, String apptoken) Get the user identity and fill the user identities cachevoid
loadUserInfo
(UserIdentity userIdentity) Get the user collaboration information from the exchange server.protected GlpiTicket
parseTicket
(Map<String, Object> data) Parse data intoGlpiTicket
void
service
(ServiceManager manager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon ROLE. -
_maxCacheSize
Maximum cache size, in number of records. -
_cacheTtl
The cache TTL in minutes. -
_cache
The user information cache. The key of the cache is the user identity it self -
_cacheIdentities
The user information cache. The key of the cache is the user identity it self
-
-
Constructor Details
-
TicketGlpiManager
public TicketGlpiManager()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
-
loadUserInfo
Get the user collaboration information from the exchange server.- Parameters:
userIdentity
- the user identity.- Returns:
- the user collaboration information as a Map.
- Throws:
Exception
- If an error occurred
-
getUserIdentity
protected Integer getUserIdentity(CloseableHttpClient httpclient, UserIdentity userIdentity, String glpiUrl, String sessionToken, String apptoken) throws Exception Get the user identity and fill the user identities cache- Parameters:
httpclient
- The http client to send a request to the webserviceuserIdentity
- The current user identityglpiUrl
- The GLPI UrlsessionToken
- The session tokenapptoken
- The app token- Returns:
- The user identity corresponding, or null if not found
- Throws:
Exception
- if an error occurred
-
getGlpiTickets
protected Map<String,Object> getGlpiTickets(CloseableHttpClient httpclient, String glpiUrl, String sessionToken, String apptoken, Integer userId) throws IOException, URISyntaxException Get the GLPI tickets- Parameters:
httpclient
- the HTTP clientglpiUrl
- The url of GLPI serversessionToken
- The session tokenapptoken
- The app tokenuserId
- The user id- Returns:
- The tickets
- Throws:
IOException
- if an error occurredURISyntaxException
- if failed to build uri
-
parseTicket
Parse data intoGlpiTicket
- Parameters:
data
- the json data- Returns:
- the
GlpiTicket
-
getTicketSearchQuery
Get the part of rest API url for tickets search- Parameters:
userId
- The user id- Returns:
- The search query to concat to rest API url
-
getCountOpenTickets
Get the number of open tickets- Parameters:
userIdentity
- The user identity- Returns:
- the number of unread mail
-
getOpenTickets
Get all information about open tickets- Parameters:
userIdentity
- The user identity- Returns:
- List of all information about open tickets
-
getGlpiStatusLabel
Get the i18n label of a GLPI status- Parameters:
status
- The GLPI status- Returns:
- the label of status as
I18nizableText
-
getGlpiTypeLabel
Get the i18n label of a GLPI ticket type- Parameters:
type
- The GLPI type- Returns:
- the label of status as
I18nizableText
-