01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: org_hsqldb_jdbcDriver.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.authentication.credentialsmanagers.databasedrivers;
09:
10: import com.uwyn.rife.authentication.credentialsmanagers.DatabaseUsers;
11: import com.uwyn.rife.authentication.credentialsmanagers.RoleUserAttributes;
12: import com.uwyn.rife.authentication.credentialsmanagers.exceptions.DuplicateLoginException;
13: import com.uwyn.rife.authentication.credentialsmanagers.exceptions.DuplicateUserIdException;
14: import com.uwyn.rife.authentication.exceptions.CredentialsManagerException;
15: import com.uwyn.rife.database.Datasource;
16:
17: public class org_hsqldb_jdbcDriver extends generic {
18: public org_hsqldb_jdbcDriver(Datasource datasource) {
19: super (datasource);
20: }
21:
22: public DatabaseUsers addUser(String login,
23: RoleUserAttributes attributes)
24: throws CredentialsManagerException {
25: try {
26: _addUser(mAddUserWithId, mGetFreeUserId, mGetRoleId,
27: mAddRoleLink, login, attributes);
28: } catch (CredentialsManagerException e) {
29: if (null != e.getCause() && null != e.getCause().getCause()) {
30: String message = e.getCause().getCause().getMessage()
31: .toUpperCase();
32: if (-1 != message.indexOf(mCreateTableUser
33: .getUniqueConstraints().get(0).getName())) {
34: throw new DuplicateLoginException(login);
35: }
36: if (-1 != message.indexOf("UNIQUE")) {
37: throw new DuplicateUserIdException(attributes
38: .getUserId());
39: }
40: }
41:
42: throw e;
43: }
44:
45: return this;
46: }
47: }
|