Line 16... |
Line 16... |
16 |
* @description La classe utilDAO fournit des méthodes communes pour les outils DAO
|
16 |
* @description La classe utilDAO fournit des méthodes communes pour les outils DAO
|
17 |
* */
|
17 |
* */
|
18 |
public class UtilDAO {
|
18 |
public class UtilDAO {
|
Line 19... |
Line 19... |
19 |
|
19 |
|
- |
|
20 |
private static String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
|
20 |
private static String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
|
21 |
private static String baseAuthUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getAuthServiceBaseUrl();
|
21 |
public static final String GET = "GET";
|
22 |
public static final String GET = "GET";
|
22 |
public static final String POST = "POST";
|
23 |
public static final String POST = "POST";
|
23 |
public static final String DELETE = "DELETE";
|
24 |
public static final String DELETE = "DELETE";
|
24 |
public static final String PUT = "PUT";
|
25 |
public static final String PUT = "PUT";
|
Line 93... |
Line 94... |
93 |
cheminUrl += (UtilString.isEmpty(morceauxDuChemin[i]) ? CONTENU_CHEMIN_VIDE : morceauxDuChemin[i]) + SEPARATEUR_CHEMIN;
|
94 |
cheminUrl += (UtilString.isEmpty(morceauxDuChemin[i]) ? CONTENU_CHEMIN_VIDE : morceauxDuChemin[i]) + SEPARATEUR_CHEMIN;
|
94 |
}
|
95 |
}
|
95 |
}
|
96 |
}
|
96 |
return cheminUrl;
|
97 |
return cheminUrl;
|
97 |
}
|
98 |
}
|
98 |
|
99 |
|
- |
|
100 |
/**
|
- |
|
101 |
* Construit un JsonRestRequestBuilder avec le header Authorization
|
- |
|
102 |
*/
|
- |
|
103 |
public static JsonRestRequestBuilder construireRequeteAuth(String nomService, HashMap<String, String> parametres) {
|
- |
|
104 |
return construireRequeteAuth(nomService, parametres, true);
|
- |
|
105 |
}
|
- |
|
106 |
|
- |
|
107 |
/**
|
- |
|
108 |
* Construit un JsonRestRequestBuilder simple; si authorizationHeader vaut true, ajoute le header
|
- |
|
109 |
* "Authorization" pour le service d'authentification SSO (annuaire::auth)
|
- |
|
110 |
*
|
- |
|
111 |
* @param nomService le nom du service (identite, login, logout...)
|
- |
|
112 |
* @param parametres tableau de paramètres
|
- |
|
113 |
* @param boolean authorizationHeader si true, enverra le jeton (si existant) dans un header Authorization
|
- |
|
114 |
* @return JsonRestRequestBuilder
|
- |
|
115 |
*/
|
- |
|
116 |
public static JsonRestRequestBuilder construireRequeteAuth(String nomService, HashMap<String, String> parametres, boolean authorizationHeader) {
|
- |
|
117 |
String parametresUrl = construireUrlParametres(parametres);
|
- |
|
118 |
String urlComplete = baseAuthUrl + nomService + parametresUrl;
|
- |
|
119 |
String urlCompleteEncodee = URL.encode(urlComplete);
|
- |
|
120 |
JsonRestRequestBuilder jrrb = new JsonRestRequestBuilder(JsonRestRequestBuilder.GET, urlCompleteEncodee, authorizationHeader);
|
- |
|
121 |
return jrrb;
|
- |
|
122 |
}
|
- |
|
123 |
|
99 |
public static String getUrlService(String nomService) {
|
124 |
public static String getUrlService(String nomService) {
|
100 |
return baseUrl + nomService;
|
125 |
return baseUrl + nomService;
|
101 |
}
|
126 |
}
|
102 |
|
- |
|
103 |
}
|
127 |
}
|
104 |
|
128 |
|