From 9758ff6ce1458df98fa4889e7995f14b296a024a Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Thu, 17 Aug 2006 18:58:55 +0000
Subject: [PATCH] Added an extra byte before the ASN1 encoding of database entries for versioning purposes. Also, error handling mechnisms are also added for handling incompatible version numbers. Some extra catch statements are removed to allow the orginal exception to bubble up to the debug logger.

---
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
index 40e6f71..ce9d480 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
@@ -248,15 +248,32 @@
     {
       return null;
     }
-    try
+
+    byte[] entryBytes = data.getData();
+    byte entryVersion = JebFormat.getEntryVersion(entryBytes);
+
+    //Try to decode the entry based on the version number. On later versions,
+    //a case could be written to upgrade entries if it is not the current
+    //version
+    switch(entryVersion)
     {
-      return JebFormat.entryFromDatabase(data.getData());
-    }
-    catch (Exception e)
-    {
-      int msgID = MSGID_JEB_ENTRY_DATABASE_CORRUPT;
-      String message = getMessage(msgID, id.toString());
-      throw new JebException(msgID, message);
+      case JebFormat.FORMAT_VERSION :
+        try
+        {
+          return JebFormat.entryFromDatabase(entryBytes);
+        }
+        catch (Exception e)
+        {
+          int msgID = MSGID_JEB_ENTRY_DATABASE_CORRUPT;
+          String message = getMessage(msgID, id.toString());
+          throw new JebException(msgID, message);
+        }
+      //case 0x00                     :
+      //  Call upgrade method? Call 0x00 decode method?
+      default   :
+        int msgID = MSGID_JEB_INCOMPATIBLE_ENTRY_VERSION;
+        String message = getMessage(msgID, id.toString(), entryVersion);
+        throw new JebException(msgID, message);
     }
   }
 

--
Gitblit v1.10.0