public class TicketGlpiManager extends AbstractLogEnabled implements Component, Initializable, Serviceable, PluginAware
| Modifier and Type | Class and Description |
|---|---|
protected class |
TicketGlpiManager.GlpiCacheLoader
The Glpi cache loader.
|
| Modifier and Type | Field and Description |
|---|---|
private static String |
__GLPI_INIT_SESSION |
private static String |
__GLPI_KILL_SESSION |
private static String |
__GLPI_SEARCH_TICKET |
private static String |
__GLPI_SEARCH_USERS |
protected LoadingCache<UserIdentity,Map<String,Object>> |
_cache
The user information cache.
|
protected Cache<String,Integer> |
_cacheIdentities
The user information cache.
|
protected long |
_cacheTtl
The cache TTL in minutes.
|
private Map<Integer,I18nizableText> |
_glpiStatus |
private Map<Integer,I18nizableText> |
_glpiType |
private JSONUtils |
_jsonUtils |
protected long |
_maxCacheSize
Maximum cache size, in number of records.
|
private String |
_pluginName |
static String |
ROLE
Avalon ROLE.
|
| Constructor and Description |
|---|
TicketGlpiManager() |
| Modifier and Type | Method and Description |
|---|---|
private Map<String,Object> |
_callWebServiceApi(CloseableHttpClient httpclient,
URI uri,
boolean getJsonObject) |
private String |
_getGlpiSessionToken(CloseableHttpClient httpclient,
String glpiUrl,
String usertoken,
String apptoken) |
private void |
_killGlpiSessionToken(CloseableHttpClient httpclient,
String glpiUrl,
String sessionToken,
String apptoken) |
int |
getCountOpenTickets(UserIdentity userIdentity)
Get the number of open tickets
|
I18nizableText |
getGlpiStatusLabel(int status)
Get the i18n label of a GLPI status
|
protected Map<String,Object> |
getGlpiTickets(CloseableHttpClient httpclient,
String glpiUrl,
String sessionToken,
String apptoken,
Integer userId)
Get the GLPI tickets
|
I18nizableText |
getGlpiTypeLabel(int type)
Get the i18n label of a GLPI ticket type
|
List<GlpiTicket> |
getOpenTickets(UserIdentity userIdentity)
Get all information about open tickets
|
protected String |
getTicketSearchQuery(Integer userId)
Get the part of rest API url for tickets search
|
protected Integer |
getUserIdentity(CloseableHttpClient httpclient,
UserIdentity userIdentity,
String glpiUrl,
String sessionToken,
String apptoken)
Get the user identity and fill the user identities cache
|
void |
initialize() |
protected Map<String,Object> |
loadUserInfo(UserIdentity userIdentity)
Get the user collaboration information from the exchange server.
|
protected GlpiTicket |
parseTicket(Map<String,Object> data)
Parse data into
GlpiTicket |
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. |
getLogger, setLoggerprivate static final String __GLPI_INIT_SESSION
private static final String __GLPI_SEARCH_USERS
private static final String __GLPI_SEARCH_TICKET
private static final String __GLPI_KILL_SESSION
protected long _maxCacheSize
protected long _cacheTtl
protected LoadingCache<UserIdentity,Map<String,Object>> _cache
protected Cache<String,Integer> _cacheIdentities
private JSONUtils _jsonUtils
private Map<Integer,I18nizableText> _glpiStatus
private Map<Integer,I18nizableText> _glpiType
private String _pluginName
public TicketGlpiManager()
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAwaresetPluginInfo in interface PluginAwarepluginName - Unique identifier for the plugin hosting the extensionfeatureName - Unique feature identifier (unique for a given pluginName)id - Unique identifier of this componentpublic void service(ServiceManager manager) throws ServiceException
service in interface ServiceableServiceExceptionpublic void initialize()
initialize in interface Initializableprotected Map<String,Object> loadUserInfo(UserIdentity userIdentity) throws Exception
userIdentity - the user identity.Exception - If an error occurredprivate String _getGlpiSessionToken(CloseableHttpClient httpclient, String glpiUrl, String usertoken, String apptoken) throws IOException, URISyntaxException
IOExceptionURISyntaxExceptionprotected Integer getUserIdentity(CloseableHttpClient httpclient, UserIdentity userIdentity, String glpiUrl, String sessionToken, String apptoken) throws Exception
httpclient - The http client to send a request to the webserviceuserIdentity - The current user identityglpiUrl - The GLPI UrlsessionToken - The session tokenapptoken - The app tokenException - if an error occurredprotected Map<String,Object> getGlpiTickets(CloseableHttpClient httpclient, String glpiUrl, String sessionToken, String apptoken, Integer userId) throws IOException, URISyntaxException
httpclient - the HTTP clientglpiUrl - The url of GLPI serversessionToken - The session tokenapptoken - The app tokenuserId - The user idIOException - if an error occurredURISyntaxException - if failed to build uriprotected GlpiTicket parseTicket(Map<String,Object> data)
GlpiTicketdata - the json dataGlpiTicketprotected String getTicketSearchQuery(Integer userId)
userId - The user idprivate void _killGlpiSessionToken(CloseableHttpClient httpclient, String glpiUrl, String sessionToken, String apptoken) throws IOException, URISyntaxException
IOExceptionURISyntaxExceptionprivate Map<String,Object> _callWebServiceApi(CloseableHttpClient httpclient, URI uri, boolean getJsonObject) throws IOException
IOExceptionpublic int getCountOpenTickets(UserIdentity userIdentity) throws ExecutionException
userIdentity - The user identityExecutionException - If an error occured during the connection to
the serverpublic List<GlpiTicket> getOpenTickets(UserIdentity userIdentity) throws ExecutionException
userIdentity - The user identityExecutionException - If an error occured during the connection to
the serverpublic I18nizableText getGlpiStatusLabel(int status)
status - The GLPI statusI18nizableTextpublic I18nizableText getGlpiTypeLabel(int type)
type - The GLPI typeI18nizableText