summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/common/src/UserMessages.properties1
-rw-r--r--base/common/src/com/netscape/certsrv/ldap/LDAPExceptionUtil.java38
-rw-r--r--base/common/src/com/netscape/cms/servlet/admin/UserService.java5
-rw-r--r--base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java3
-rw-r--r--base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java4
5 files changed, 42 insertions, 9 deletions
diff --git a/base/common/src/UserMessages.properties b/base/common/src/UserMessages.properties
index 01d5fbc0f..694c31d65 100644
--- a/base/common/src/UserMessages.properties
+++ b/base/common/src/UserMessages.properties
@@ -554,7 +554,6 @@ CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID=Certificate not yet valid
CMS_USRGRP_SRVLT_CERT_O_ERROR=Certificate related error
CMS_USRGRP_USER_ADD_FAILED=Failed to add user
CMS_USRGRP_USER_ADD_FAILED_1=Failed to add user. Missing \"{0}\"
-CMS_USRGRP_USER_ADD_FAILED_2=An user already exits with the user id \"{0}\".
CMS_USRGRP_USER_MOD_FAILED=Failed to modify user.
CMS_USRGRP_USER_MOD_FAILED_1=Failed to modify user. Missing \"{0}\"
CMS_USRGRP_SRVLT_USER_CERT_EXISTS=Failed to add cert: The certificate you tried to add already exists
diff --git a/base/common/src/com/netscape/certsrv/ldap/LDAPExceptionUtil.java b/base/common/src/com/netscape/certsrv/ldap/LDAPExceptionUtil.java
new file mode 100644
index 000000000..cbf9f36ef
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/ldap/LDAPExceptionUtil.java
@@ -0,0 +1,38 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.ldap;
+
+import netscape.ldap.LDAPException;
+
+import com.netscape.certsrv.base.ConflictingOperationException;
+import com.netscape.certsrv.base.PKIException;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class LDAPExceptionUtil {
+
+ public static PKIException createPKIException(LDAPException le) {
+ switch (le.getLDAPResultCode()) {
+ case LDAPException.ENTRY_ALREADY_EXISTS:
+ return new ConflictingOperationException("Entry already exists", le);
+ default:
+ return new PKIException("LDAP error ("+le.getLDAPResultCode()+"): "+le.getMessage());
+ }
+ }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserService.java b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
index 9a54802ef..e0c7ca9f9 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
@@ -40,6 +40,7 @@ import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.base.UserNotFoundException;
import com.netscape.certsrv.common.OpDef;
import com.netscape.certsrv.common.ScopeDef;
+import com.netscape.certsrv.ldap.LDAPExceptionUtil;
import com.netscape.certsrv.logging.IAuditor;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.password.IPasswordCheck;
@@ -303,11 +304,11 @@ public class UserService extends PKIService implements UserResource {
} catch (LDAPException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_USER_FAIL", e.toString()));
- throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED"));
+ throw LDAPExceptionUtil.createPKIException(e);
} catch (Exception e) {
log(ILogger.LL_FAILURE, e.toString());
- throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED"));
+ throw new PKIException(e.getMessage(), e);
}
} catch (PKIException e) {
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java b/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java
index 506d608cd..2cd337123 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java
@@ -897,8 +897,7 @@ public class UsrGrpAdminServlet extends AdminServlet {
CMS.getUserMessage(getLocale(req), "CMS_USRGRP_USER_ADD_FAILED_1", "uid"), null, resp);
} else {
sendResponse(ERROR,
- CMS.getUserMessage(getLocale(req), "CMS_USRGRP_USER_ADD_FAILED_2", user.getUserID()), null,
- resp);
+ CMS.getUserMessage(getLocale(req), "CMS_USRGRP_USER_ADD_FAILED"), null, resp);
}
return;
} catch (LDAPException e) {
diff --git a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
index 6314c226f..034357b6e 100644
--- a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -646,10 +646,6 @@ public final class UGSubsystem implements IUGSubsystem {
throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_ADD_USER_FAIL_NO_UID"));
}
- if (getUser(id.getUserID()) != null) {
- throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_USER_ADD_FAILED_2", id.getUserID()));
- }
-
LDAPAttributeSet attrs = new LDAPAttributeSet();
String oc[] = { "top", "person", "organizationalPerson",
"inetOrgPerson", "cmsuser" };