From e54e0f755679be2240f4ac4cd07c7ccec6f799d7 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 26 Jun 2024 15:27:32 +0530 Subject: [PATCH] Update entry not found error message --- native/src/main/java/io/ballerina/lib/ldap/Client.java | 2 +- .../java/io/ballerina/lib/ldap/CustomSearchEntryListener.java | 2 +- .../java/io/ballerina/lib/ldap/CustomSearchResultListener.java | 2 +- native/src/main/java/io/ballerina/lib/ldap/Utils.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/src/main/java/io/ballerina/lib/ldap/Client.java b/native/src/main/java/io/ballerina/lib/ldap/Client.java index b68ec1b..6764e11 100644 --- a/native/src/main/java/io/ballerina/lib/ldap/Client.java +++ b/native/src/main/java/io/ballerina/lib/ldap/Client.java @@ -191,7 +191,7 @@ public static Object getEntry(BObject ldapClient, BString dN, BTypedesc typePara validateConnection(ldapConnection); SearchResultEntry userEntry = ldapConnection.getEntry(dN.getValue()); if (Objects.isNull(userEntry)) { - return Utils.createError(ENTRY_NOT_FOUND + "'" + dN + "'", new LDAPException(NO_SUCH_OBJECT)); + return Utils.createError(String.format(ENTRY_NOT_FOUND, dN), new LDAPException(NO_SUCH_OBJECT)); } for (Attribute attribute : userEntry.getAttributes()) { processAttribute(attribute, entry); diff --git a/native/src/main/java/io/ballerina/lib/ldap/CustomSearchEntryListener.java b/native/src/main/java/io/ballerina/lib/ldap/CustomSearchEntryListener.java index c1dd626..33c3765 100644 --- a/native/src/main/java/io/ballerina/lib/ldap/CustomSearchEntryListener.java +++ b/native/src/main/java/io/ballerina/lib/ldap/CustomSearchEntryListener.java @@ -77,7 +77,7 @@ public void searchResultReceived(AsyncRequestID requestID, SearchResult searchRe return; } if (array.isEmpty()) { - String errorMessage = ENTRY_NOT_FOUND + "'" + dN + "'"; + String errorMessage = String.format(ENTRY_NOT_FOUND, dN); LDAPException ldapException = new LDAPException(ResultCode.OTHER, errorMessage); future.complete(Utils.createError(ldapException.getMessage(), ldapException)); return; diff --git a/native/src/main/java/io/ballerina/lib/ldap/CustomSearchResultListener.java b/native/src/main/java/io/ballerina/lib/ldap/CustomSearchResultListener.java index ae30c9c..ee152ac 100644 --- a/native/src/main/java/io/ballerina/lib/ldap/CustomSearchResultListener.java +++ b/native/src/main/java/io/ballerina/lib/ldap/CustomSearchResultListener.java @@ -66,7 +66,7 @@ public void searchResultReceived(AsyncRequestID requestID, SearchResult searchRe return; } if (entries.isEmpty()) { - String errorMessage = ENTRY_NOT_FOUND + "'" + dN + "'"; + String errorMessage = String.format(ENTRY_NOT_FOUND, dN); LDAPException ldapException = new LDAPException(ResultCode.OTHER, errorMessage); future.complete(Utils.createError(ldapException.getMessage(), ldapException)); return; diff --git a/native/src/main/java/io/ballerina/lib/ldap/Utils.java b/native/src/main/java/io/ballerina/lib/ldap/Utils.java index 5bafe68..34b1dd5 100644 --- a/native/src/main/java/io/ballerina/lib/ldap/Utils.java +++ b/native/src/main/java/io/ballerina/lib/ldap/Utils.java @@ -68,7 +68,7 @@ private Utils() { public static final String OID = "oid"; public static final String IS_CRITICAL = "isCritical"; public static final String VALUE = "value"; - public static final String ENTRY_NOT_FOUND = "Entry is not found for DN: "; + public static final String ENTRY_NOT_FOUND = "Entry is not found for DN: '%s'"; public static final String SID_REVISION_ERROR = "objectSid revision must be 1"; public static final String OBJECT_GUID_LENGTH_ERROR = "objectGUID must be a 16-byte array"; public static final String LDAP_CONNECTION_CLOSED_ERROR = "LDAP Connection has been closed";