directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject directory-kerby git commit: o removed bad import o added checks to prevent insertion of a duplicate identity
Date Thu, 02 Jul 2015 08:29:31 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master c7df2dccf -> 9c3dd03ce


o removed bad import
o added checks to prevent insertion of a duplicate identity


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/9c3dd03c
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/9c3dd03c
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/9c3dd03c

Branch: refs/heads/master
Commit: 9c3dd03ceaa9b0713c02a639d459c6318877cf9d
Parents: c7df2dc
Author: Kiran Ayyagari <kayyagari@apache.org>
Authored: Thu Jul 2 16:28:34 2015 +0800
Committer: Kiran Ayyagari <kayyagari@apache.org>
Committed: Thu Jul 2 16:28:34 2015 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kerby/MavibotBackend.java  | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9c3dd03c/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java b/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
index c000b38..b216617 100644
--- a/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
+++ b/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
@@ -24,8 +24,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.management.openmbean.KeyAlreadyExistsException;
-
 import org.apache.directory.mavibot.btree.BTree;
 import org.apache.directory.mavibot.btree.BTreeFactory;
 import org.apache.directory.mavibot.btree.BTreeTypeEnum;
@@ -156,10 +154,15 @@ public class MavibotBackend extends AbstractIdentityBackend {
         
         String p = identity.getPrincipalName();
         try {
+            if(database.hasKey(p)) {
+                LOG.debug("Identity {} already exists", p);
+                return null;
+            }
+            
             return database.insert(p, identity);
         }
-        catch(KeyAlreadyExistsException e) {
-            LOG.debug("Identity {} already exists", p);
+        catch(KeyNotFoundException e) {
+            LOG.debug("No such identity {} exists", p);
             LOG.debug("", e);
             return null;
         }
@@ -186,11 +189,6 @@ public class MavibotBackend extends AbstractIdentityBackend {
             
             return database.insert(p, identity);
         }
-        catch(KeyAlreadyExistsException e) {
-            LOG.debug("Identity {} already exists", p);
-            LOG.debug("", e);
-            return null;
-        }
         catch(Exception e) {
             LOG.warn("Failed to update the identity {}", p);
             throw new RuntimeException(e);


Mime
View raw message