@@ -63,7 +63,7 @@ public Mono<JsonNode> getBotNodeFromStartingMessage(String startingMessage) {
6363 .build ())
6464 .retrieve ().bodyToMono (String .class ).map (response -> {
6565 if (response != null ) {
66- log .info (response );
66+ log .info ("Call getBotNodeFromStartingMessage : " + response + " cache : " + cache . getIfPresent ( cacheKey ) );
6767 try {
6868 ObjectMapper mapper = new ObjectMapper ();
6969 JsonNode root = mapper .readTree (response );
@@ -106,7 +106,7 @@ public Mono<JsonNode> getBotNodeFromName(String botName) {
106106 .build ())
107107 .retrieve ().bodyToMono (String .class ).map (response -> {
108108 if (response != null ) {
109- log .info (response );
109+ log .info ("Call getBotNodeFromName : " + response + " cache : " + cache . getIfPresent ( cacheKey ) );
110110 try {
111111 ObjectMapper mapper = new ObjectMapper ();
112112 JsonNode root = mapper .readTree (response );
@@ -146,6 +146,7 @@ public Mono<JsonNode> getBotNodeFromId(String botId) {
146146 .bodyToMono (String .class )
147147 .map (response -> {
148148 if (response != null ) {
149+ log .info ("Call getBotNodeFromId : " + response + " cache : " + cache .getIfPresent (cacheKey ));
149150 ObjectMapper mapper = new ObjectMapper ();
150151 try {
151152 JsonNode root = mapper .readTree (response );
@@ -165,48 +166,49 @@ public Mono<JsonNode> getBotNodeFromId(String botId) {
165166 .log ("cache" );
166167 }
167168
168- /**
169- * Get Adapter id by bot name
170- * @param botName
171- * @return
172- */
173- public Mono <String > getAdapterIdFromBotName (String botName ) {
174- String cacheKey = "valid-adpater-from-bot-name: " + botName ;
175- return CacheMono .lookup (key -> Mono .justOrEmpty (cache .getIfPresent (cacheKey ) != null ? cache .getIfPresent (key ).toString () : null )
176- .map (Signal ::next ), cacheKey )
177- .onCacheMissResume (() -> webClient .get ()
178- .uri (builder -> builder .path ("admin/bot/search/internal" )
179- .queryParam ("perPage" , 5 )
180- .queryParam ("page" , 1 )
181- .queryParam ("match" , true )
182- .queryParam ("name" , botName )
183- .build ())
184- .retrieve ()
185- .bodyToMono (String .class ).map (response -> {
186- if (response != null ) {
187- ObjectMapper mapper = new ObjectMapper ();
188- try {
189- JsonNode root = mapper .readTree (response );
190- if (root .path ("result" ) != null && root .path ("result" ).get (0 ) != null
191- && !root .path ("result" ).get (0 ).isEmpty ()) {
192- JsonNode botNode = root .path ("result" ).get (0 );
193- return BotUtil .getBotNodeAdapterId (botNode );
194- }
195- return null ;
196- } catch (JsonProcessingException jsonMappingException ) {
197- return null ;
198- }
199-
200- } else {
201- }
202- return null ;
203- })
204- .doOnError (throwable -> log .info ("Error in getting adpater: " + throwable .getMessage ()))
205- .onErrorReturn ("" ))
206- .andWriteWith ((key , signal ) -> Mono .fromRunnable (
207- () -> Optional .ofNullable (signal .get ()).ifPresent (value -> cache .put (key , value ))))
208- .log ("cache" );
209- }
169+ // /**
170+ // * Get Adapter id by bot name
171+ // * @param botName
172+ // * @return
173+ // */
174+ // public Mono<String> getAdapterIdFromBotName(String botName) {
175+ // String cacheKey = "valid-adpater-from-bot-name: " + botName;
176+ // return CacheMono.lookup(key -> Mono.justOrEmpty(cache.getIfPresent(cacheKey) != null ? cache.getIfPresent(key).toString() : null)
177+ // .map(Signal::next), cacheKey)
178+ // .onCacheMissResume(() -> webClient.get()
179+ // .uri(builder -> builder.path("admin/bot/search/internal")
180+ // .queryParam("perPage", 5)
181+ // .queryParam("page", 1)
182+ // .queryParam("match", true)
183+ // .queryParam("name", botName)
184+ // .build())
185+ // .retrieve()
186+ // .bodyToMono(String.class).map(response -> {
187+ // if (response != null) {
188+ // log.info("Call getAdapterIdFromBotName : " + response);
189+ // ObjectMapper mapper = new ObjectMapper();
190+ // try {
191+ // JsonNode root = mapper.readTree(response);
192+ // if(root.path("result") != null && root.path("result").get(0) != null
193+ // && !root.path("result").get(0).isEmpty()) {
194+ // JsonNode botNode = root.path("result").get(0);
195+ // return BotUtil.getBotNodeAdapterId(botNode);
196+ // }
197+ // return null;
198+ // } catch (JsonProcessingException jsonMappingException) {
199+ // return null;
200+ // }
201+ //
202+ // } else {
203+ // }
204+ // return null;
205+ // })
206+ // .doOnError(throwable -> log.info("Error in getting adpater: " + throwable.getMessage()))
207+ // .onErrorReturn(""))
208+ // .andWriteWith((key, signal) -> Mono.fromRunnable(
209+ // () -> Optional.ofNullable(signal.get()).ifPresent(value -> cache.put(key, value))))
210+ // .log("cache");
211+ // }
210212
211213 /**
212214 * Retrieve bot id from bot name (from validated bot)
@@ -227,6 +229,7 @@ public Mono<String> getBotIdFromBotName(String botName) {
227229 @ Override
228230 public String apply (String response ) {
229231 if (response != null ) {
232+ log .info ("Call getBotIdFromBotName : " + response + " cache : " + cache .getIfPresent (cacheKey ));
230233 ObjectMapper mapper = new ObjectMapper ();
231234 try {
232235 JsonNode root = mapper .readTree (response );
@@ -315,6 +318,7 @@ public URI apply(UriBuilder builder) {
315318 }).retrieve ().bodyToMono (String .class ).map (new Function <String , JsonNode >() {
316319 @ Override
317320 public JsonNode apply (String response ) {
321+ log .info ("Call getAdapterByID cache key : " + cacheKey + " cache data : " +cache .getIfPresent (cacheKey ));
318322 if (response != null ) {
319323 ObjectMapper mapper = new ObjectMapper ();
320324 try {
@@ -349,7 +353,7 @@ public Mono<JsonNode> getAdapterCredentials(String adapterID) {
349353 return getAdapterByID (adapterID ).map (new Function <JsonNode , Mono <JsonNode >>() {
350354 @ Override
351355 public Mono <JsonNode > apply (JsonNode adapter ) {
352- log .info ("adapter : " +adapter );
356+ log .info ("getAdapterByID : " +adapter );
353357 if (adapter != null ) {
354358 String vaultKey ;
355359 try {
@@ -423,6 +427,7 @@ public Mono<JsonNode> getVaultCredentials(String secretKey) {
423427 httpHeaders .set ("admin-token" , adminToken );
424428 })
425429 .retrieve ().bodyToMono (String .class ).map (response -> {
430+ log .info ("Call getVaultCredentials cache key : " + cacheKey +" cache data : " + cache .getIfPresent (cacheKey ));
426431 if (response != null ) {
427432 ObjectMapper mapper = new ObjectMapper ();
428433 try {
@@ -462,6 +467,7 @@ public Mono<String> getFirstFormByBotID(String botId) {
462467 @ Override
463468 public String apply (String response ) {
464469 if (response != null ) {
470+ log .info ("Call getFirstFormByBotID : " + response + " cache : " + cache .getIfPresent (cacheKey ));
465471 ObjectMapper mapper = new ObjectMapper ();
466472 try {
467473 JsonNode root = mapper .readTree (response );
@@ -503,6 +509,7 @@ public Mono<String> getBotNameByBotID(String botId) {
503509 @ Override
504510 public String apply (String response ) {
505511 if (response != null ) {
512+ log .info ("Call getBotNameByBotID : " + response + " cache : " + cache .getIfPresent (cacheKey ));
506513 ObjectMapper mapper = new ObjectMapper ();
507514 try {
508515 JsonNode root = mapper .readTree (response );
0 commit comments