directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: Should the BIND throw an Exception ?
Date Wed, 02 Jun 2010 05:42:19 GMT
Emmanuel Lecharny wrote:
> Hi guys,
> 
> long time, no see ... Lots of side work going on, but still progressing
> on the API.
> 
> I have a question though : should the LdapConnection.bind()operation
> throw an exception, or not ?
> 
> Currently we have a version that returns a BindResponse, which is
> convenient but a bit painful if you have got an error, as you have to
> check the response before using the connection.
> 
> Wouldn't it be better to just throw an LdapException, containing the
> Bindresponse elements, à la JNDI ?
> 
> wdyt ?

Short answer: yes, let's throw an exception.

I thought about it. There are two different paradigms:
- LDAP returns status codes. Not each status code > 0 is an error.
- In Java we are used to use Exceptions

I already falled in this trap when I used the modify operation and I
expected an exception but only received the response and had to check
the response.

Maybe we should take the list of all response codes and decide in which
cases we throw an exception and in which cases we just return the
response object. Additional we could make this list configurable by the
user of the API and provide some predefined configurations (throw
always, throw never, default settings).

Here is my first try, feel free to comment:

  success                      (0),
  operationsError              (1),     --> Exception
  protocolError                (2),     --> Exception
  timeLimitExceeded            (3),
  sizeLimitExceeded            (4),
  compareFalse                 (5),
  compareTrue                  (6),
  authMethodNotSupported       (7),     --> Exception
  strongerAuthRequired         (8),     --> Exception
       -- 9 reserved --
  referral                     (10),
  adminLimitExceeded           (11),
  unavailableCriticalExtension (12),    --> Exception
  confidentialityRequired      (13),    --> Exception
  saslBindInProgress           (14),
  noSuchAttribute              (16),    --> Exception
  undefinedAttributeType       (17),    --> Exception
  inappropriateMatching        (18),    --> Exception
  constraintViolation          (19),    --> Exception
  attributeOrValueExists       (20),    --> Exception
  invalidAttributeSyntax       (21),    --> Exception
       -- 22-31 unused --
  noSuchObject                 (32),    --> Exception
  aliasProblem                 (33),    --> Exception
  invalidDNSyntax              (34),    --> Exception
       -- 35 reserved for undefined isLeaf --
  aliasDereferencingProblem    (36),    --> Exception
       -- 37-47 unused --
  inappropriateAuthentication  (48),    --> Exception
  invalidCredentials           (49),    --> Exception
  insufficientAccessRights     (50),    --> Exception
  busy                         (51),    --> Exception
  unavailable                  (52),    --> Exception
  unwillingToPerform           (53),    --> Exception
  loopDetect                   (54),    --> Exception
       -- 55-63 unused --
  namingViolation              (64),    --> Exception
  objectClassViolation         (65),    --> Exception
  notAllowedOnNonLeaf          (66),    --> Exception
  notAllowedOnRDN              (67),    --> Exception
  entryAlreadyExists           (68),    --> Exception
  objectClassModsProhibited    (69),    --> Exception
       -- 70 reserved for CLDAP --
  affectsMultipleDSAs          (71),    --> Exception
       -- 72-79 unused --
  other                        (80),    --> Exception



Kind Regards,
Stefan


Mime
View raw message