From 1c67282f3df6ce5ae04d2c750367e52582e78d09 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Sun, 02 Sep 2007 16:30:55 +0000
Subject: [PATCH] Minor refactoring of the admin driver API. Remove the hasManagedObject methods and replace them with a single managedObjectExists method. This will be more useful and more simple for dependency call-backs.

---
 opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java |   69 ++++++++++++++--------------------
 1 files changed, 29 insertions(+), 40 deletions(-)

diff --git a/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java b/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
index 481e8c0..497f100 100644
--- a/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
+++ b/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
@@ -119,7 +119,7 @@
       AuthorizationException, CommunicationException {
     validateRelationDefinition(parent, rd);
 
-    if (!entryExists(parent)) {
+    if (!managedObjectExists(parent)) {
       throw new ManagedObjectNotFoundException();
     }
 
@@ -140,7 +140,7 @@
       CommunicationException {
     validateRelationDefinition(parent, rd);
 
-    if (!entryExists(parent)) {
+    if (!managedObjectExists(parent)) {
       throw new ManagedObjectNotFoundException();
     }
 
@@ -158,7 +158,7 @@
       ManagedObjectPath<C, S> path) throws DefinitionDecodingException,
       ManagedObjectDecodingException, ManagedObjectNotFoundException,
       AuthorizationException, CommunicationException {
-    if (!entryExists(path)) {
+    if (!managedObjectExists(path)) {
       throw new ManagedObjectNotFoundException();
     }
 
@@ -232,7 +232,7 @@
       DefinitionDecodingException, AuthorizationException,
       ManagedObjectNotFoundException, CommunicationException,
       PropertyException {
-    if (!entryExists(path)) {
+    if (!managedObjectExists(path)) {
       throw new ManagedObjectNotFoundException();
     }
 
@@ -290,26 +290,6 @@
    */
   @Override
   public <C extends ConfigurationClient, S extends Configuration>
-  boolean hasManagedObject(
-      ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd)
-      throws IllegalArgumentException, ManagedObjectNotFoundException,
-      AuthorizationException, CommunicationException {
-    validateRelationDefinition(parent, rd);
-
-    if (!entryExists(parent)) {
-      throw new ManagedObjectNotFoundException();
-    }
-
-    return entryExists(parent.child(rd));
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public <C extends ConfigurationClient, S extends Configuration>
   String[] listManagedObjects(
       ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd,
       AbstractManagedObjectDefinition<? extends C, ? extends S> d)
@@ -317,7 +297,7 @@
       AuthorizationException, CommunicationException {
     validateRelationDefinition(parent, rd);
 
-    if (!entryExists(parent)) {
+    if (!managedObjectExists(parent)) {
       throw new ManagedObjectNotFoundException();
     }
 
@@ -351,6 +331,29 @@
 
 
   /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean managedObjectExists(ManagedObjectPath<?, ?> path)
+      throws ManagedObjectNotFoundException, AuthorizationException,
+      CommunicationException {
+    if (path.isEmpty()) {
+      return true;
+    }
+
+    ManagedObjectPath<?,?> parent = path.parent();
+    LdapName dn = LDAPNameBuilder.create(parent, profile);
+    if (!entryExists(dn)) {
+      throw new ManagedObjectNotFoundException();
+    }
+
+    dn = LDAPNameBuilder.create(path, profile);
+    return entryExists(dn);
+  }
+
+
+
+  /**
    * Adapts a naming exception to an appropriate admin client
    * exception.
    *
@@ -499,20 +502,6 @@
 
 
 
-  // Determines whether the LDAP entry associated with the managed
-  // object path exists.
-  private boolean entryExists(ManagedObjectPath<?, ?> path)
-      throws CommunicationException, AuthorizationException {
-    if (path.isEmpty()) {
-      return true;
-    }
-
-    LdapName dn = LDAPNameBuilder.create(path, profile);
-    return entryExists(dn);
-  }
-
-
-
   // Determine the type of managed object associated with the named
   // entry.
   private <C extends ConfigurationClient, S extends Configuration>
@@ -561,7 +550,7 @@
   private boolean removeManagedObject(ManagedObjectPath<?, ?> path)
       throws CommunicationException, AuthorizationException,
       OperationRejectedException, ManagedObjectNotFoundException {
-    if (!entryExists(path)) {
+    if (!managedObjectExists(path)) {
       return false;
     }
 

--
Gitblit v1.10.0