Skip to content

Commit

Permalink
Update entry not found error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Jun 26, 2024
1 parent a768f04 commit e54e0f7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion native/src/main/java/io/ballerina/lib/ldap/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion native/src/main/java/io/ballerina/lib/ldap/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit e54e0f7

Please sign in to comment.