590d18
From f021f35447a0b71957b2294b1000f9229ea064f6 Mon Sep 17 00:00:00 2001
590d18
From: David Kupka <dkupka@redhat.com>
590d18
Date: Thu, 13 Aug 2015 08:11:38 +0200
590d18
Subject: [PATCH] user-undel: Fix error messages.
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5207
590d18
590d18
Reviewed-By: Martin Basti <mbasti@redhat.com>
590d18
---
590d18
 ipalib/plugins/user.py | 12 +++++-------
590d18
 1 file changed, 5 insertions(+), 7 deletions(-)
590d18
590d18
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
590d18
index 90ae7260abf935abf92b49da04c11bc76e836e49..418c51bdafc4e462e2decfe1e8541aaf49705cb0 100644
590d18
--- a/ipalib/plugins/user.py
590d18
+++ b/ipalib/plugins/user.py
590d18
@@ -827,16 +827,14 @@ class user_undel(LDAPQuery):
590d18
 
590d18
         # First check that the user exists and is a delete one
590d18
         delete_dn = self.obj.get_either_dn(*keys, **options)
590d18
-        if delete_dn.endswith(DN(self.obj.active_container_dn, api.env.basedn)):
590d18
-            raise errors.ValidationError(
590d18
-                        name=self.obj.primary_key.cli_name,
590d18
-                        error=_('User %r is already active') % keys[-1][0])
590d18
         try:
590d18
             entry_attrs = self._exc_wrapper(keys, options, ldap.get_entry)(delete_dn)
590d18
         except errors.NotFound:
590d18
-            raise errors.ValidationError(
590d18
-                        name=self.obj.primary_key.cli_name,
590d18
-                        error=_('User %r not found') % keys[-1][0])
590d18
+            self.obj.handle_not_found(*keys)
590d18
+        if delete_dn.endswith(DN(self.obj.active_container_dn,
590d18
+                                 api.env.basedn)):
590d18
+            raise errors.InvocationError(
590d18
+                message=_('user "%s" is already active') % keys[-1])
590d18
 
590d18
         active_dn = DN(delete_dn[0], self.obj.active_container_dn, api.env.basedn)
590d18
 
590d18
-- 
590d18
2.4.3
590d18