From 6879d04bd633e99ef7013bffafce2ef04adc3006 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 19 Sep 2014 14:55:35 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1206 : Create a new ReplicationBackend/ChangelogBackend to support cn=changelog

---
 opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java |  150 +++++++++++--------------------------------------
 1 files changed, 34 insertions(+), 116 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
index 47f95ec..3b340a4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
@@ -34,8 +34,6 @@
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.ConditionResult;
 import org.forgerock.opendj.ldap.SearchScope;
-import org.forgerock.util.Reject;
-import org.opends.server.admin.Configuration;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.LDIFBackendCfg;
 import org.opends.server.api.AlertGenerator;
@@ -62,7 +60,7 @@
  * re-written on disk.
  */
 public class LDIFBackend
-       extends Backend
+       extends Backend<LDIFBackendCfg>
        implements ConfigurationChangeListener<LDIFBackendCfg>, AlertGenerator
 {
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -79,10 +77,8 @@
   private Set<DN> baseDNSet;
 
   /** The set of supported controls for this backend. */
-  private Set<String> supportedControls;
-
-  /** The set of supported features for this backend. */
-  private Set<String> supportedFeatures;
+  private final Set<String> supportedControls =
+      Collections.singleton(OID_SUBTREE_DELETE_CONTROL);
 
   /** The current configuration for this backend. */
   private LDIFBackendCfg currentConfig;
@@ -115,10 +111,8 @@
     backendLock = new ReentrantReadWriteLock(useFairLocking);
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void initializeBackend()
          throws ConfigException, InitializationException
   {
@@ -305,10 +299,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void finalizeBackend()
   {
     backendLock.writeLock().lock();
@@ -336,19 +328,15 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public DN[] getBaseDNs()
   {
     return baseDNs;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public long getEntryCount()
   {
     backendLock.readLock().lock();
@@ -368,29 +356,23 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean isLocal()
   {
     return true;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean isIndexed(AttributeType attributeType, IndexType indexType)
   {
     // All searches in this backend will always be considered indexed.
     return true;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public ConditionResult hasSubordinates(DN entryDN)
          throws DirectoryException
   {
@@ -424,10 +406,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public long numSubordinates(DN entryDN, boolean subtree)
          throws DirectoryException
   {
@@ -475,10 +455,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public Entry getEntry(DN entryDN)
   {
     backendLock.readLock().lock();
@@ -493,10 +471,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean entryExists(DN entryDN)
   {
     backendLock.readLock().lock();
@@ -511,10 +487,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void addEntry(Entry entry, AddOperation addOperation)
          throws DirectoryException
   {
@@ -586,10 +560,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
          throws DirectoryException
   {
@@ -713,10 +685,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void replaceEntry(Entry oldEntry, Entry newEntry,
       ModifyOperation modifyOperation) throws DirectoryException
   {
@@ -755,10 +725,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void renameEntry(DN currentDN, Entry entry,
                           ModifyDNOperation modifyDNOperation)
          throws DirectoryException
@@ -894,10 +862,8 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void search(SearchOperation searchOperation)
          throws DirectoryException
   {
@@ -964,37 +930,29 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public Set<String> getSupportedControls()
   {
     return supportedControls;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public Set<String> getSupportedFeatures()
   {
-    return supportedFeatures;
+    return Collections.emptySet();
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean supportsLDIFExport()
   {
     return true;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void exportLDIF(LDIFExportConfig exportConfig)
          throws DirectoryException
   {
@@ -1047,19 +1005,15 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean supportsLDIFImport()
   {
     return true;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
          throws DirectoryException
   {
@@ -1229,31 +1183,23 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean supportsBackup()
   {
-    // This backend does not provide a backup/restore mechanism.
     return false;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean supportsBackup(BackupConfig backupConfig,
                                 StringBuilder unsupportedReason)
   {
-    // This backend does not provide a backup/restore mechanism.
     return false;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void createBackup(BackupConfig backupConfig)
          throws DirectoryException
   {
@@ -1261,10 +1207,8 @@
     throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void removeBackup(BackupDirectory backupDirectory, String backupID)
          throws DirectoryException
   {
@@ -1272,20 +1216,15 @@
     throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public boolean supportsRestore()
   {
-    // This backend does not provide a backup/restore mechanism.
     return false;
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
+  @Override
   public void restoreBackup(RestoreConfig restoreConfig)
          throws DirectoryException
   {
@@ -1293,17 +1232,13 @@
     throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
   }
 
-
-
   /** {@inheritDoc} */
-  @Override()
-  public void configureBackend(Configuration config)
-         throws ConfigException
+  @Override
+  public void configureBackend(LDIFBackendCfg config) throws ConfigException
   {
     if (config != null)
     {
-      Reject.ifFalse(config instanceof LDIFBackendCfg);
-      currentConfig = (LDIFBackendCfg) config;
+      currentConfig = config;
       currentConfig.addLDIFChangeListener(this);
 
       baseDNs = new DN[currentConfig.getBaseDN().size()];
@@ -1316,17 +1251,10 @@
       baseDNSet = new HashSet<DN>();
       Collections.addAll(baseDNSet, baseDNs);
 
-      supportedControls = new HashSet<String>(1);
-      supportedControls.add(OID_SUBTREE_DELETE_CONTROL);
-
-      supportedFeatures = new HashSet<String>(0);
-
       ldifFilePath = currentConfig.getLDIFFile();
     }
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public boolean isConfigurationChangeAcceptable(LDIFBackendCfg configuration,
@@ -1344,8 +1272,6 @@
     return configAcceptable;
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public ConfigChangeResult applyConfigurationChange(
@@ -1379,8 +1305,6 @@
                                   messages);
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public DN getComponentEntryDN()
@@ -1388,8 +1312,6 @@
     return currentConfig.dn();
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public String getClassName()
@@ -1397,8 +1319,6 @@
     return LDIFBackend.class.getName();
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public Map<String,String> getAlerts()
@@ -1411,8 +1331,6 @@
     return alerts;
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public void preloadEntryCache() throws UnsupportedOperationException {

--
Gitblit v1.10.0