summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-12-06 21:57:14 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2013-01-04 09:46:49 -0500
commit776ba2fb2bb8d053aac09d6199e0e7b3fd18a915 (patch)
tree7d34bd6c7d048b8903d0fbe330383d58cb9737ec
parent58142dbf7ceb966c950db2e83373f8407e74dd56 (diff)
downloadpki-abhishek-34.zip
pki-abhishek-34.tar.gz
pki-abhishek-34.tar.xz
Ticket 214 - Proper error message when adding a duplicate userabhishek-34
-rw-r--r--base/common/src/UserMessages.properties1
-rw-r--r--base/common/src/com/netscape/cms/servlet/admin/UserService.java2
-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
4 files changed, 8 insertions, 2 deletions
diff --git a/base/common/src/UserMessages.properties b/base/common/src/UserMessages.properties
index 694c31d..01d5fbc 100644
--- a/base/common/src/UserMessages.properties
+++ b/base/common/src/UserMessages.properties
@@ -554,6 +554,7 @@ 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/cms/servlet/admin/UserService.java b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
index 4813d10..9a54802 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
@@ -298,7 +298,7 @@ public class UserService extends PKIService implements UserResource {
if (user.getUserID() == null) {
throw new BadRequestDataException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid"));
} else {
- throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED"));
+ throw new PKIException(e.getMessage());
}
} catch (LDAPException 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 2cd3371..506d608 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UsrGrpAdminServlet.java
@@ -897,7 +897,8 @@ 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"), null, resp);
+ CMS.getUserMessage(getLocale(req), "CMS_USRGRP_USER_ADD_FAILED_2", user.getUserID()), 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 034357b..6314c22 100644
--- a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -646,6 +646,10 @@ 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" };