@@ -33,20 +33,13 @@ public JobGetInfos() {
3333 ConnectorAPI .YamlUtils ();
3434 }
3535
36- private String getRouteName (Enum <?> routeName ) {
37- return routeName .name ().toLowerCase ();
38- }
3936 /**
40- * Récupère les routes depuis le fichier YAML et construit l'URL complète
41- * @param versionType Version de l'API (V1_BRANCH, V2_BRANCH)
42- * @param methodType Type de méthode HTTP (GET, POST)
43- * @param routeName Nom de la route dans le fichier YAML
44- * @param body Corps de la requête pour POST (peut être null pour GET)
45- * @param params Paramètres supplémentaires pour la requête (optionnel)
46- * @return JobGetInfos pour chaînage
37+ * Méthode utilitaire pour obtenir le nom de la route en minuscules.
38+ * @param routeName Nom de la route (Enum)
39+ * @return Nom de la route en minuscules
4740 */
48- public JobGetInfos getRoutes ( VersionType versionType , MethodType methodType , Enum <?> routeName , Map < String , Object > body , Map < String , Object > params ) {
49- return getRoutes ( versionType , methodType , routeName , body , params );
41+ private String getRouteName ( Enum <?> routeName ) {
42+ return routeName . name (). toLowerCase ( );
5043 }
5144
5245 /**
@@ -56,7 +49,7 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Enu
5649 * @param routeName Nom de la route dans le fichier YAML
5750 * @return JobGetInfos pour chaînage
5851 */
59- public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , Enum <?> routeName , Map <String , Object > body ) {
52+ public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , Enum <?> routeName , Map <String , ? > body ) {
6053 return getRoutes (versionType , methodType , getRouteName (routeName ), body , null );
6154 }
6255
@@ -88,7 +81,7 @@ public JobGetInfos getRoutes(MethodType methodType, Enum<?> routeName) {
8881 * @param body Corps de la requête pour POST (peut être null pour GET)
8982 * @return JobGetInfos pour chaînage
9083 */
91- public JobGetInfos getRoutes (MethodType methodType , Enum <?> routeName , Map <String , Object > body ) {
84+ public JobGetInfos getRoutes (MethodType methodType , Enum <?> routeName , Map <String , ? > body ) {
9285 return getRoutes (null , methodType , getRouteName (routeName ), body , null );
9386 }
9487
@@ -99,7 +92,7 @@ public JobGetInfos getRoutes(MethodType methodType, Enum<?> routeName, Map<Strin
9992 * @param params Paramètres supplémentaires pour la requête
10093 * @return JobGetInfos pour chaînage
10194 */
102- public JobGetInfos getRoutes (MethodType methodType , Enum <?> routeName , Map <String , Object > body , Map <String , Object > params ) {
95+ public JobGetInfos getRoutes (MethodType methodType , Enum <?> routeName , Map <String , ? > body , Map <String , ? > params ) {
10396 return getRoutes (null , methodType , getRouteName (routeName ), body , params );
10497 }
10598
@@ -120,7 +113,7 @@ public JobGetInfos getRoutes(MethodType methodType, String routeName) {
120113 * @param body Corps de la requête pour POST (peut être null pour GET)
121114 * @return JobGetInfos pour chaînage
122115 */
123- public JobGetInfos getRoutesWithBody (MethodType methodType , String routeName , Map <String , Object > body ) {
116+ public JobGetInfos getRoutesWithBody (MethodType methodType , String routeName , Map <String , ? > body ) {
124117 return getRoutes (null , methodType , routeName , body , null );
125118 }
126119
@@ -131,7 +124,7 @@ public JobGetInfos getRoutesWithBody(MethodType methodType, String routeName, Ma
131124 * @param params Paramètres supplémentaires pour la requête
132125 * @return JobGetInfos pour chaînage
133126 */
134- public JobGetInfos getRoutesWithParams (MethodType methodType , String routeName , Map <String , Object > params ) {
127+ public JobGetInfos getRoutesWithParams (MethodType methodType , String routeName , Map <String , ? > params ) {
135128 return getRoutes (null , methodType , routeName , null , params );
136129 }
137130
@@ -143,7 +136,7 @@ public JobGetInfos getRoutesWithParams(MethodType methodType, String routeName,
143136 * @param params Paramètres supplémentaires pour la requête
144137 * @return JobGetInfos pour chaînage
145138 */
146- public JobGetInfos getRoutesBoth (MethodType methodType , String routeName , Map <String , Object > body , Map <String , Object > params ) {
139+ public JobGetInfos getRoutesBoth (MethodType methodType , String routeName , Map <String , ? > body , Map <String , ? > params ) {
147140 return getRoutes (null , methodType , routeName , body , params );
148141 }
149142
@@ -166,7 +159,7 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Str
166159 * @param body Corps de la requête pour POST (peut être null pour GET)
167160 * @return JobGetInfos pour chaînage
168161 */
169- public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , String routeName , Map <String , Object > body ) {
162+ public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , String routeName , Map <String , ? > body ) {
170163 return getRoutes (versionType , methodType , routeName , body , null );
171164 }
172165
@@ -179,7 +172,66 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Str
179172 * @param params Paramètres supplémentaires pour la requête (optionnel)
180173 * @return JobGetInfos pour chaînage
181174 */
182- public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , String routeName , Map <String , Object > body , Map <String , Object > params ) {
175+ public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , String routeName , Map <String , ?> body , Map <String , ?> params ) {
176+ try {
177+ // Récupère la route depuis le fichier YAML
178+ String route = ConnectorAPI .getRoute (routeName );
179+
180+ String fullRoute ;
181+
182+ // Vérification de null pour éviter NullPointerException
183+ if (versionType != null && versionType .getVersion () != null ) {
184+ // Construit l'URL complète avec la version
185+ fullRoute = "/" + versionType .getVersion () + route ;
186+ } else {
187+ // Construit l'URL complète sans version
188+ fullRoute = route ;
189+ }
190+
191+ // Remplace les paramètres dans la route si présents
192+ if (params != null && !params .isEmpty ()) {
193+ for (Map .Entry <String , ?> entry : params .entrySet ()) {
194+ String paramKey = "{" + entry .getKey () + "}" ;
195+ String paramValue = entry .getValue ().toString ();
196+
197+ // Remplace toutes les occurrences du paramètre dans la route
198+ fullRoute = fullRoute .replace (paramKey , paramValue );
199+ }
200+ }
201+
202+ // Stocke les informations pour la requête
203+ ConnectorAPI .StoreAndRetrieve ().store .put ("currentRoute" , fullRoute );
204+ ConnectorAPI .StoreAndRetrieve ().store .put ("currentMethod" , methodType );
205+
206+ if (body != null ) {
207+ ConnectorAPI .StoreAndRetrieve ().store .put ("currentBody" , body );
208+ }
209+
210+ // Stocke les paramètres si présents
211+ if (params != null ) {
212+ ConnectorAPI .StoreAndRetrieve ().store .put ("currentParams" , params );
213+ }
214+
215+ ConnectorAPI .Logger ().INFO ("Route construite: " + fullRoute );
216+
217+ } catch (Exception e ) {
218+ ConnectorAPI .Logger ().ERROR ("Erreur lors de la construction de la route: " + e .getMessage ());
219+ throw new RuntimeException ("Erreur lors de la construction de la route" , e );
220+ }
221+
222+ return this ;
223+ }
224+
225+ /**
226+ * Récupère les routes depuis le fichier YAML et construit l'URL complète
227+ * @param versionType Version de l'API (V1_BRANCH, V2_BRANCH)
228+ * @param methodType Type de méthode HTTP (GET, POST)
229+ * @param routeName Nom de la route dans le fichier YAML
230+ * @param body Corps de la requête pour POST (peut être null pour GET)
231+ * @param params Paramètres supplémentaires pour la requête (optionnel)
232+ * @return JobGetInfos pour chaînage
233+ */
234+ public JobGetInfos getRoutes (VersionType versionType , MethodType methodType , Enum <?> routeName , Map <String , ?> body , Map <String , ?> params ) {
183235 try {
184236 // Récupère la route depuis le fichier YAML
185237 String route = ConnectorAPI .getRoute (routeName );
@@ -197,7 +249,7 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Str
197249
198250 // Remplace les paramètres dans la route si présents
199251 if (params != null && !params .isEmpty ()) {
200- for (Map .Entry <String , Object > entry : params .entrySet ()) {
252+ for (Map .Entry <String , ? > entry : params .entrySet ()) {
201253 String paramKey = "{" + entry .getKey () + "}" ;
202254 String paramValue = entry .getValue ().toString ();
203255
0 commit comments