Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
java-library-glpi
Commits
27a7f4bd
Commit
27a7f4bd
authored
Nov 26, 2018
by
Ivan Del Pino
Committed by
Rafael Jesus Hernández Vasquez
Nov 29, 2018
Browse files
refactor(glpi): indentation code
Signed-off-by:
Ivan Del Pino
<
idelpino@teclib.com
>
parent
8e22d545
Changes
1
Show whitespace changes
Inline
Side-by-side
glpi/src/main/java/org/glpi/api/GLPI.java
View file @
27a7f4bd
...
...
@@ -57,6 +57,7 @@ public class GLPI extends ServiceGenerator {
/**
* GLPI REST API Constructor this class will help you to interact with GLPI endpoints
*
* @param context is the context
* @param glpiUrl is the url glpi instance
*/
...
...
@@ -69,6 +70,7 @@ public class GLPI extends ServiceGenerator {
/**
* Request a session token to uses other api endpoints.
*
* @param userToken defined in User Preference (See 'Remote access key' on GLPI)
* @param callback here you are going to get the asynchronous response
*/
...
...
@@ -78,6 +80,7 @@ public class GLPI extends ServiceGenerator {
/**
* Request a session token to uses other api endpoints.
*
* @param appToken authorization string provided by the GLPI api configuration. [Optional]
* @param userToken defined in User Preference (See 'Remote access key' on GLPI)
* @param callback here you are going to get the asynchronous response
...
...
@@ -90,7 +93,7 @@ public class GLPI extends ServiceGenerator {
responseCall
.
enqueue
(
new
Callback
<
InitSession
>()
{
@Override
public
void
onResponse
(
Call
<
InitSession
>
call
,
Response
<
InitSession
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
try
{
sessionToken
=
response
.
body
().
getSessionToken
();
...
...
@@ -98,7 +101,7 @@ public class GLPI extends ServiceGenerator {
Log
.
d
(
"initSession"
,
ex
.
getMessage
());
}
callback
.
onResponse
(
response
.
body
()
);
callback
.
onResponse
(
response
.
body
());
}
else
{
String
errorMessage
;
try
{
...
...
@@ -106,7 +109,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -119,12 +122,13 @@ public class GLPI extends ServiceGenerator {
/**
* Synchronous Request a session token to uses other api endpoints. with a couple login & password: 2 parameters to login with user authentication
*
* @param user valid user on GLPI
* @param password valid password on GLPI
* @return SessionToken
*/
public
String
initSessionByCredentialsSync
(
String
user
,
String
password
)
{
String
authorization
=
Helpers
.
base64encode
(
user
+
":"
+
password
);
String
authorization
=
Helpers
.
base64encode
(
user
+
":"
+
password
);
Call
<
InitSession
>
responseCall
=
interfaces
.
initSessionByCredentials
(
"Basic "
+
authorization
.
trim
());
...
...
@@ -138,6 +142,7 @@ public class GLPI extends ServiceGenerator {
/**
* Request a session token to uses other api endpoints. with a couple login & password: 2 parameters to login with user authentication
*
* @param user valid user on GLPI
* @param password valid password on GLPI
* @param callback here you are going to get the asynchronous response
...
...
@@ -148,6 +153,7 @@ public class GLPI extends ServiceGenerator {
/**
* Request a session token to uses other api endpoints. with a couple login & password: 2 parameters to login with user authentication
*
* @param appToken authorization string provided by the GLPI api configuration. [Optional]
* @param user valid user on GLPI
* @param password valid password on GLPI
...
...
@@ -157,20 +163,20 @@ public class GLPI extends ServiceGenerator {
this
.
appToken
=
appToken
;
String
authorization
=
Helpers
.
base64encode
(
user
+
":"
+
password
);
String
authorization
=
Helpers
.
base64encode
(
user
+
":"
+
password
);
Call
<
InitSession
>
responseCall
=
interfaces
.
initSessionByCredentials
(
"Basic "
+
authorization
.
trim
());
responseCall
.
enqueue
(
new
Callback
<
InitSession
>()
{
@Override
public
void
onResponse
(
Call
<
InitSession
>
call
,
Response
<
InitSession
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
try
{
sessionToken
=
response
.
body
().
getSessionToken
();
}
catch
(
NullPointerException
ex
)
{
Log
.
d
(
"initSession"
,
ex
.
getMessage
());
}
callback
.
onResponse
(
response
.
body
()
);
callback
.
onResponse
(
response
.
body
());
}
else
{
String
errorMessage
;
try
{
...
...
@@ -178,7 +184,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -191,13 +197,14 @@ public class GLPI extends ServiceGenerator {
/**
* Create a valid Array with common headers needs
* @return Map<String, String> with all the headers
*
* @return Map<String , String> with all the headers
*/
private
Map
<
String
,
String
>
getHeader
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"Session-Token"
,
this
.
sessionToken
);
if
(
appToken
!=
null
)
{
if
(
appToken
!=
null
)
{
map
.
put
(
"App-Token"
,
appToken
);
}
...
...
@@ -206,6 +213,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return all the profiles associated to logged user.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getMyProfiles
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -214,8 +222,8 @@ public class GLPI extends ServiceGenerator {
responseCall
.
enqueue
(
new
Callback
<
JsonObject
>()
{
@Override
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
()
);
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
());
}
else
{
String
errorMessage
;
try
{
...
...
@@ -223,7 +231,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -236,6 +244,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the current active profile.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getActiveProfile
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -244,8 +253,8 @@ public class GLPI extends ServiceGenerator {
responseCall
.
enqueue
(
new
Callback
<
JsonObject
>()
{
@Override
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
()
);
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
());
}
else
{
String
errorMessage
;
try
{
...
...
@@ -253,7 +262,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -266,6 +275,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return all the possible entities of the current logged user (and for current active profile).
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getMyEntities
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -274,8 +284,8 @@ public class GLPI extends ServiceGenerator {
responseCall
.
enqueue
(
new
Callback
<
JsonObject
>()
{
@Override
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
()
);
if
(
response
.
isSuccessful
())
{
callback
.
onResponse
(
response
.
body
());
}
else
{
String
errorMessage
;
try
{
...
...
@@ -283,7 +293,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -296,6 +306,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return active entities of current logged user.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getActiveEntities
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -313,7 +324,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -326,6 +337,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the current php $_SESSION.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getFullSession
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -343,7 +355,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -356,6 +368,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the current $CFG_GLPI.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
getGlpiConfig
(
final
JsonObjectCallback
callback
)
{
...
...
@@ -373,7 +386,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -386,6 +399,7 @@ public class GLPI extends ServiceGenerator {
/**
* Destroy a session identified by a session token.
*
* @param callback here you are going to get the asynchronous response
*/
public
void
killSession
(
final
VoidCallback
callback
)
{
...
...
@@ -405,7 +419,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -418,6 +432,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the itemtype.
*
* @param itemType These are the item type available on GLPI
* @param callback here you are going to get the asynchronous response
*/
...
...
@@ -427,6 +442,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the itemtype.
*
* @param options These are the parameters of this endpoint for example expand_dropdowns or get_hateoas
* @param itemType These are the item type available on GLPI
* @param callback here you are going to get the asynchronous response
...
...
@@ -446,7 +462,7 @@ public class GLPI extends ServiceGenerator {
}
catch
(
Exception
ex
)
{
errorMessage
=
context
.
getResources
().
getString
(
R
.
string
.
error_generic
);
}
callback
.
onFailure
(
errorMessage
);
callback
.
onFailure
(
errorMessage
);
}
}
...
...
@@ -459,6 +475,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the instance fields of itemtype identified by id.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
...
...
@@ -469,6 +486,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the instance fields of itemtype identified by id.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
...
...
@@ -479,6 +497,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the instance fields of itemtype identified by id.
*
* @param options These are the parameters of this endpoint for example expand_dropdowns or get_hateoas
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the itemtype
...
...
@@ -490,6 +509,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return the instance fields of itemtype identified by id.
*
* @param options These are the parameters of this endpoint for example expand_dropdowns or get_hateoas
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the itemtype
...
...
@@ -523,6 +543,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the sub_itemtype for the identified item.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the parent itemtype
* @param subItemType These are the item type available on GLPI
...
...
@@ -534,6 +555,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the sub_itemtype for the identified item.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the parent itemtype
* @param subItemType These are the item type available on GLPI
...
...
@@ -545,6 +567,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the sub_itemtype for the identified item.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the parent itemtype
* @param subItemType These are the item type available on GLPI
...
...
@@ -556,6 +579,7 @@ public class GLPI extends ServiceGenerator {
/**
* Return a collection of rows of the sub_itemtype for the identified item.
*
* @param options These are the parameters of this endpoint for example expand_dropdowns or get_hateoas
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the parent itemtype
...
...
@@ -590,6 +614,7 @@ public class GLPI extends ServiceGenerator {
/**
* Change active profile to the profiles_id one. See getMyProfiles endpoint for possible profiles.
*
* @param profilesId (default 'all') ID of the new active profile.
* @param callback here you are going to get the asynchronous response
*/
...
...
@@ -623,6 +648,7 @@ public class GLPI extends ServiceGenerator {
/**
* Change active entity to the entities_id one. See getMyEntities endpoint for possible entities.
*
* @param entitiesId (default 'all') ID of the new active entity ("all" => load all possible entities).
* @param is_recursive (default false) Also display sub entities of the active entity.
* @param callback here you are going to get the asynchronous response
...
...
@@ -657,6 +683,7 @@ public class GLPI extends ServiceGenerator {
/**
* Add an object (or multiple objects) into GLPI.
*
* @param itemType These are the item type available on GLPI
* @param payload input: an object with fields of itemtype to be inserted. You can add several items in one action by passing an array of objects.
* @param callback here you are going to get the asynchronous response
...
...
@@ -689,6 +716,7 @@ public class GLPI extends ServiceGenerator {
/**
* Update an object (or multiple objects) existing in GLPI.
*
* @param itemType These are the item type available on GLPI
* @param id the unique identifier of the itemtype
* @param payload Array of objects with fields of itemtype to be updated.
...
...
@@ -722,6 +750,7 @@ public class GLPI extends ServiceGenerator {
/**
* Delete an object existing in GLPI.
*
* @param itemType These are the item type available on GLPI
* @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
...
...
@@ -754,6 +783,7 @@ public class GLPI extends ServiceGenerator {
/**
* Delete multiples objects existing in GLPI.
*
* @param itemType These are the item type available on GLPI
* @param payload Array of id who need to be deleted
* @param callback here you are going to get the asynchronous response
...
...
@@ -786,6 +816,7 @@ public class GLPI extends ServiceGenerator {
/**
* This endpoint allows to request password reset
*
* @param email email address of the user to recover
* @param callback here you are going to get the asynchronous response
*/
...
...
@@ -819,6 +850,7 @@ public class GLPI extends ServiceGenerator {
/**
* This endpoint allows to request password recovery
*
* @param email email address of the user to recover
* @param token reset token
* @param newPassword the new password for the user
...
...
@@ -852,15 +884,21 @@ public class GLPI extends ServiceGenerator {
});
}
public
void
getMultipleItems
()
{}
public
void
listSearchOptions
()
{}
public
void
searchItems
()
{}
public
void
getMultipleItems
()
{
}
public
void
listSearchOptions
()
{
}
public
void
searchItems
()
{
}
/**
* Interface definition for a callback to be invoked when a user init session.
*/
public
interface
InitSessionCallback
{
void
onResponse
(
InitSession
response
);
void
onFailure
(
String
errorMessage
);
}
...
...
@@ -869,6 +907,7 @@ public class GLPI extends ServiceGenerator {
*/
public
interface
JsonObjectCallback
{
void
onResponse
(
JsonObject
response
);
void
onFailure
(
String
errorMessage
);
}
...
...
@@ -877,6 +916,7 @@ public class GLPI extends ServiceGenerator {
*/
public
interface
JsonArrayCallback
{
void
onResponse
(
JsonArray
response
);
void
onFailure
(
String
errorMessage
);
}
...
...
@@ -885,6 +925,7 @@ public class GLPI extends ServiceGenerator {
*/
public
interface
VoidCallback
{
void
onResponse
(
String
response
);
void
onFailure
(
String
errorMessage
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment