@@ -58,30 +58,6 @@ public Boolean isSchemaEnabled() {
5858 }
5959 }
6060
61- /**
62- * Récupère une route spécifique depuis le fichier YAML
63- * @param routeName
64- * @return
65- */
66- public String getRoute (String routeName ) {
67-
68- String yamlFilePath = ConnectorAPI .StoreAndRetrieve ().store .get (ConnectorAPI .StoreAndRetrieve ().FILE_LOCATION_KEY ) + "/infos.yml" ;
69-
70- try (InputStream inputStream = Files .newInputStream (Paths .get (yamlFilePath ))) {
71- Yaml yaml = new Yaml ();
72- Map <String , Object > yamlData = yaml .load (inputStream );
73-
74- // Récupérer la map "routes"
75- Map <String , Object > routes = (Map <String , Object >) yamlData .get ("routes" );
76- if (routes != null ) {
77- return (String ) routes .get (routeName );
78- }
79- return null ;
80- } catch (Exception ex ) {
81- return null ;
82- }
83- }
84-
8561 /**
8662 * Récupère toutes les routes définies dans le fichier YAML
8763 * @return une map contenant les routes, ou null en cas d'erreur
@@ -94,6 +70,8 @@ public Map<String,String> getRoutes() {
9470 Yaml yaml = new Yaml ();
9571 Map <String , Object > yamlData = yaml .load (inputStream );
9672
73+ System .out .println ("Récupération des routes " + yamlData .get ("routes" ));
74+
9775 // Récupérer la map "routes"
9876 return (Map <String , String >) yamlData .get ("routes" );
9977 } catch (Exception ex ) {
@@ -120,47 +98,46 @@ public void generateTemplateIfNotExists(ResourceType type, Map<Enum<?>, String>
12098 }
12199
122100 File file = new File (basePath , "infos.yml" );
123- if (!file .exists ()) {
124-
125- StringBuilder template = new StringBuilder (
126- "# properties Connector API By Sandro642\n \n " +
127- "urlPath: \" http://localhost:8080/api\" \n \n " +
128- "routes:\n " +
129- " #info: \" /info/version\" \n " +
130- " #ping: \" /ping\" \n " +
131- " #status: \" /status\" \n \n " );
132-
133-
134- for (Map .Entry <Enum <?>, String > entry : routes .entrySet ()) {
135- template .append (" " )
136- .append (entry .getKey ().name ().toLowerCase ())
137- .append (": \" " )
138- .append (entry .getValue ())
139- .append ("\" \n " );
140- }
141101
142- template .append ("\n schema:\n " +
143- " #Activer la création de schéma ?\n " +
144- " enable: false\n \n " +
145- " #Schéma par défaut:\n " +
146- " #\t msg : string\n " +
147- " #\t err: boolean\n " +
148- " #\t code: integer\n " +
149- " #\t data: Map<String, Object>\n \n " +
150- " #Composants à créer exemple, je vais créer plusieurs composant:\n " +
151- " # msg : str\n " +
152- " # status : bln\n " +
153- " # code : int\n " +
154- " # data_string-object : map / string pour une chaine de caractère et\n " +
155- " # / object pour la récupération de n'importe\n " +
156- " # / quel type de variable.\n " +
157- " # Grâce à cela vous pourrez les appeler pour récupérer vos propres valeurs\n " +
158- " # par rapport à votre schéma réponse API\n " );
159- try (FileWriter writer = new FileWriter (file )) {
160- writer .write (template .toString ());
161- } catch (IOException e ) {
162- throw new RuntimeException ("Erreur lors de la création du template infos.yml" , e );
163- }
102+ StringBuilder template = new StringBuilder (
103+ "# properties Connector API By Sandro642\n \n " +
104+ "urlPath: \" http://localhost:8080/api\" \n \n " +
105+ "routes:\n " +
106+ " #info: \" /info/version\" \n " +
107+ " #ping: \" /ping\" \n " +
108+ " #status: \" /status\" \n \n " );
109+
110+ for (Map .Entry <Enum <?>, String > entry : routes .entrySet ()) {
111+ template .append (" " )
112+ .append (entry .getKey ().name ().toLowerCase ())
113+ .append (": \" " )
114+ .append (entry .getValue ())
115+ .append ("\" \n " );
116+ }
117+
118+ template .append ("\n schema:\n " +
119+ " #Activer la création de schéma ?\n " +
120+ " enable: false\n \n " +
121+ " #Schéma par défaut:\n " +
122+ " #\t msg : string\n " +
123+ " #\t err: boolean\n " +
124+ " #\t code: integer\n " +
125+ " #\t data: Map<String, Object>\n \n " +
126+ " #Composants à créer exemple, je vais créer plusieurs composant:\n " +
127+ " # msg : str\n " +
128+ " # status : bln\n " +
129+ " # code : int\n " +
130+ " # data_string-object : map / string pour une chaine de caractère et\n " +
131+ " # / object pour la récupération de n'importe\n " +
132+ " # / quel type de variable.\n " +
133+ " #\n " +
134+ " # Grâce à cela vous pourrez les appeler pour récupérer vos propres valeurs\n " +
135+ " # par rapport à votre schéma réponse API\n " );
136+
137+ try (FileWriter writer = new FileWriter (file )) {
138+ writer .write (template .toString ());
139+ } catch (IOException e ) {
140+ throw new RuntimeException ("Erreur lors de la création du template infos.yml" , e );
164141 }
165142 }
166143}
0 commit comments