From c5a7902386da8b89f3d3389e0b6b779888e8d1df Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 25 May 2023 16:50:43 +0530 Subject: [PATCH] Fix error message and minor fixes in loop and if condition --- .../apimgt/webapp/publisher/APIPublisherServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 44391fb712..5b0f094a4c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -111,7 +111,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { - String errorMsg = "Error while generating application"; + String errorMsg = "Error occurred while generating the API application"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); } @@ -165,6 +165,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { Constants.EMPTY_STRING))){ apiFound = true; apiIdentifier.setUuid(apiObj.getString("id")); + break; } } if (!apiFound) { @@ -387,7 +388,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { JSONArray documentList = (JSONArray) publisherRESTAPIServices.getDocumentations(apiApplicationKey, accessTokenInfo, api.getId()).get("list"); - if (!(documentList.length() == 0)) { + if (documentList.length() > 0) { for (int i = 0; i < documentList.length(); i++) { JSONObject existingDoc = documentList.getJSONObject(i); if (existingDoc.getString("name").equals(apiConfig.getApiDocumentationName()) @@ -438,7 +439,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { - String errorMsg = "Error while generating application"; + String errorMsg = "Error occurred while generating the API application"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); }