@@ -414,7 +414,7 @@ private <T> CompletionStage<T> executeRequest(final String url, Class<T> tClass)
414414
415415
416416 if (skipCache ) {
417- return retrieveFromKentico (request , url , tClass , 0 );
417+ return retrieveFromKontent (request , url , tClass , 0 );
418418 } else {
419419 return cacheManager .get (url ).thenApply (jsonNode -> {
420420 try {
@@ -423,20 +423,20 @@ private <T> CompletionStage<T> executeRequest(final String url, Class<T> tClass)
423423 }
424424 return objectMapper .treeToValue (jsonNode , tClass );
425425 } catch (JsonProcessingException e ) {
426- log .error ("JsonProcessingException parsing Kentico object: {}" , e .toString ());
426+ log .error ("JsonProcessingException parsing Kontent.ai object: {}" , e .toString ());
427427 }
428428 return null ;
429429 }).thenCompose (result -> {
430430 if (result != null ) {
431431 return CompletableFuture .completedFuture (result );
432432 } else {
433- return retrieveFromKentico (request , url , tClass , 0 );
433+ return retrieveFromKontent (request , url , tClass , 0 );
434434 }
435435 });
436436 }
437437 }
438438
439- private <T > CompletionStage <T > retrieveFromKentico (Request request , final String url , Class <T > tClass , int retryTurn ) {
439+ private <T > CompletionStage <T > retrieveFromKontent (Request request , final String url , Class <T > tClass , int retryTurn ) {
440440 return send (request )
441441 .thenApply (this ::logResponseInfo )
442442 .thenApply (this ::handleErrorIfNecessary )
@@ -471,16 +471,16 @@ private <T> CompletionStage<T> retrieveFromKentico(Request request, final String
471471 if (error instanceof CompletionException ) {
472472 Throwable cause = error .getCause ();
473473
474- // Don't retry when when not KenticoException or not set to retry
475- boolean retry = cause instanceof KenticoException && ((KenticoException ) cause ).shouldRetry ();
474+ // Don't retry when when not KontentException or not set to retry
475+ boolean retry = cause instanceof KontentException && ((KontentException ) cause ).shouldRetry ();
476476
477477 if (!retry ) {
478478 throw (CompletionException ) error ;
479479 }
480480 }
481481
482482 if (counter .incrementAndGet () > deliveryOptions .getRetryAttempts ()) {
483- KenticoRetryException ex = new KenticoRetryException (deliveryOptions .getRetryAttempts ());
483+ KontentRetryException ex = new KontentRetryException (deliveryOptions .getRetryAttempts ());
484484 ex .initCause (error .getCause ());
485485 throw ex ;
486486 }
@@ -494,15 +494,15 @@ private <T> CompletionStage<T> retrieveFromKentico(Request request, final String
494494 return CompletableFuture .supplyAsync (
495495 () -> {
496496 try {
497- return retrieveFromKentico (request , url , tClass , counter .get ())
497+ return retrieveFromKontent (request , url , tClass , counter .get ())
498498 .toCompletableFuture ().get ();
499499 } catch (InterruptedException e ) {
500500 log .error (String .format ("InterruptedException have been raised on retial no. %d" , counter .get ()));
501501 throw new CompletionException (e );
502502 } catch (ExecutionException e ) {
503503 log .error (String .format ("ExecutionException have been raised on retrial no. %d" , counter .get ()));
504- if (e .getCause () instanceof KenticoRetryException ) {
505- KenticoRetryException exception = new KenticoRetryException (((KenticoRetryException ) e .getCause ()).getMaxRetryAttempts ());
504+ if (e .getCause () instanceof KontentRetryException ) {
505+ KontentRetryException exception = new KontentRetryException (((KontentRetryException ) e .getCause ()).getMaxRetryAttempts ());
506506 exception .initCause (error .getCause ());
507507 throw exception ;
508508 }
@@ -518,8 +518,8 @@ private <T> CompletionStage<T> retrieveFromKentico(Request request, final String
518518 throw new CompletionException (e );
519519 } catch (ExecutionException e ) {
520520 log .error ("ExecutionException have been raised for timeout" );
521- if (e .getCause () instanceof KenticoRetryException ) {
522- KenticoRetryException exception = new KenticoRetryException (((KenticoRetryException ) e .getCause ()).getMaxRetryAttempts ());
521+ if (e .getCause () instanceof KontentRetryException ) {
522+ KontentRetryException exception = new KontentRetryException (((KontentRetryException ) e .getCause ()).getMaxRetryAttempts ());
523523 exception .initCause (error .getCause ());
524524 throw exception ;
525525 }
@@ -529,33 +529,33 @@ private <T> CompletionStage<T> retrieveFromKentico(Request request, final String
529529 });
530530 }
531531
532- private Response handleErrorIfNecessary (Response response ) throws KenticoIOException , KenticoErrorException {
532+ private Response handleErrorIfNecessary (Response response ) throws KontentIOException , KontentErrorException {
533533 final int status = response .code ();
534534 if (RETRY_STATUSES .contains (status )) {
535- log .error ("Kentico API retry status returned: {} (one of {})" , status , RETRY_STATUSES .toString ());
535+ log .error ("Kontent.ai API retry status returned: {} (one of {})" , status , RETRY_STATUSES .toString ());
536536 try {
537- KenticoError kenticoError = objectMapper .readValue (response .body ().bytes (), KenticoError .class );
538- throw new KenticoErrorException ( kenticoError , true );
537+ KontentError kontentError = objectMapper .readValue (response .body ().bytes (), KontentError .class );
538+ throw new KontentErrorException ( kontentError , true );
539539 } catch (IOException e ) {
540540 log .error ("IOException when trying to parse the error response body: {}" , e .toString ());
541- throw new KenticoIOException (String .format ("Kentico API retry status returned: %d (one of %s)" , status , RETRY_STATUSES .toString ()), true );
541+ throw new KontentIOException (String .format ("Kontent.ai API retry status returned: %d (one of %s)" , status , RETRY_STATUSES .toString ()), true );
542542 }
543543 } else if (status >= 500 ) {
544- log .error ("Kentico API server error, status: {}" , status );
544+ log .error ("Kontent.ai API server error, status: {}" , status );
545545 log .info ("Request URL: " , response .request ().url ().toString ());
546546 String message =
547547 String .format (
548- "Unknown error with Kentico API. Kentico is likely suffering site issues. Status: %s" ,
548+ "Unknown error with Kontent.ai API. Kontent.ai is likely suffering site issues. Status: %s" ,
549549 status );
550- throw new CompletionException (new KenticoIOException (message , false ));
550+ throw new CompletionException (new KontentIOException (message , false ));
551551 } else if (status >= 400 ) {
552- log .error ("Kentico API server error, status: {}" , status );
552+ log .error ("Kontent.ai API server error, status: {}" , status );
553553 try {
554- KenticoError kenticoError = objectMapper .readValue (response .body ().bytes (), KenticoError .class );
555- throw new CompletionException (new KenticoErrorException ( kenticoError , false ));
554+ KontentError kontentError = objectMapper .readValue (response .body ().bytes (), KontentError .class );
555+ throw new CompletionException (new KontentErrorException ( kontentError , false ));
556556 } catch (IOException e ) {
557- log .error ("IOException connecting to Kentico : {}" , e .toString ());
558- throw new CompletionException (new KenticoIOException (e , false ));
557+ log .error ("IOException connecting to Kontent.ai : {}" , e .toString ());
558+ throw new CompletionException (new KontentIOException (e , false ));
559559 }
560560 }
561561
0 commit comments