Commit 27a7f4bd authored by Ivan Del Pino's avatar Ivan Del Pino Committed by Rafael Jesus Hernández Vasquez
Browse files

refactor(glpi): indentation code


Signed-off-by: default avatarIvan Del Pino <idelpino@teclib.com>
parent 8e22d545
......@@ -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,8 +70,9 @@ 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
* @param callback here you are going to get the asynchronous response
*/
public void initSessionByUserToken(String userToken, final InitSessionCallback callback) {
initSessionByUserToken(null, userToken, callback);
......@@ -78,9 +80,10 @@ 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 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
* @param callback here you are going to get the asynchronous response
*/
public void initSessionByUserToken(String appToken, String userToken, final InitSessionCallback callback) {
......@@ -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 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,7 +142,8 @@ 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 user valid user on GLPI
* @param password valid password on GLPI
* @param callback here you are going to get the asynchronous response
*/
......@@ -148,8 +153,9 @@ 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 appToken authorization string provided by the GLPI api configuration. [Optional]
* @param user valid user on GLPI
* @param password valid password on GLPI
* @param callback here you are going to get the asynchronous response
*/
......@@ -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,7 +442,8 @@ 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 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,8 +475,9 @@ 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 id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
*/
public void getItem(itemType itemType, String id, final JsonObjectCallback callback) {
......@@ -469,8 +486,9 @@ 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 id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
*/
public void getItem(String itemType, String id, final JsonObjectCallback callback) {
......@@ -479,9 +497,10 @@ 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 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
* @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
*/
public void getItem(GetAnItemQuery options, itemType itemType, String id, final JsonObjectCallback callback) {
......@@ -489,10 +508,11 @@ 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
* 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
* @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
*/
public void getItem(GetAnItemQuery options, String itemType, String id, final JsonObjectCallback callback) {
......@@ -523,10 +543,11 @@ 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 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
* @param callback here you are going to get the asynchronous response
* @param callback here you are going to get the asynchronous response
*/
public void getSubItems(String itemType, String id, String subItemType, final JsonObjectCallback callback) {
getSubItems(new GetSubItemQuery(GLPI.this.context), itemType, id, subItemType, callback);
......@@ -534,10 +555,11 @@ 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 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
* @param callback here you are going to get the asynchronous response
* @param callback here you are going to get the asynchronous response
*/
public void getSubItems(itemType itemType, String id, itemType subItemType, final JsonObjectCallback callback) {
getSubItems(new GetSubItemQuery(GLPI.this.context), itemType, id, subItemType, callback);
......@@ -545,10 +567,11 @@ 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 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
* @param callback here you are going to get the asynchronous response
* @param callback here you are going to get the asynchronous response
*/
public void getSubItems(GetSubItemQuery options, itemType itemType, String id, itemType subItemType, final JsonObjectCallback callback) {
getSubItems(options, itemType.name(), id, subItemType.name(), callback);
......@@ -556,11 +579,12 @@ 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
*
* @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
* @param subItemType These are the item type available on GLPI
* @param callback here you are going to get the asynchronous response
* @param callback here you are going to get the asynchronous response
*/
public void getSubItems(GetSubItemQuery options, String itemType, String id, String subItemType, final JsonObjectCallback callback) {
......@@ -590,8 +614,9 @@ 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
* @param callback here you are going to get the asynchronous response
*/
public void changeActiveProfile(String profilesId, final VoidCallback callback) {
......@@ -623,9 +648,10 @@ 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 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
* @param callback here you are going to get the asynchronous response
*/
public void changeActiveEntities(String entitiesId, Boolean is_recursive, final VoidCallback callback) {
......@@ -657,8 +683,9 @@ 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 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
*/
public void addItems(itemType itemType, Object payload, final JsonArrayCallback callback) {
......@@ -689,9 +716,10 @@ 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.
* @param id the unique identifier of the itemtype
* @param payload Array of objects with fields of itemtype to be updated.
* @param callback here you are going to get the asynchronous response
*/
public void updateItems(itemType itemType, String id, Object payload, final JsonArrayCallback callback) {
......@@ -722,8 +750,9 @@ 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 id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response
*/
public void deleteItems(itemType itemType, String id, final JsonArrayCallback callback) {
......@@ -754,8 +783,9 @@ 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 payload Array of id who need to be deleted
* @param callback here you are going to get the asynchronous response
*/
public void deleteItems(itemType itemType, Object payload, final JsonArrayCallback callback) {
......@@ -786,7 +816,8 @@ public class GLPI extends ServiceGenerator {
/**
* This endpoint allows to request password reset
* @param email email address of the user to recover
*
* @param email email address of the user to recover
* @param callback here you are going to get the asynchronous response
*/
public void recoveryPassword(String email, final VoidCallback callback) {
......@@ -819,10 +850,11 @@ 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 email email address of the user to recover
* @param token reset token
* @param newPassword the new password for the user
* @param callback here you are going to get the asynchronous response
* @param callback here you are going to get the asynchronous response
*/
public void resetPassword(String email, String token, String newPassword, final VoidCallback callback) {
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment