From a259c7bd8cbbf53d179d99c5cfd51e1f6eebfdb4 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 31 Aug 2007 21:21:31 +0000
Subject: [PATCH] throw exceptions for backend operations when initialization fails
---
opendj-sdk/opends/src/messages/messages/backend.properties | 3 +
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java | 96 +++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 90 insertions(+), 9 deletions(-)
diff --git a/opendj-sdk/opends/src/messages/messages/backend.properties b/opendj-sdk/opends/src/messages/messages/backend.properties
index 078b3d5..3e6d6b1 100644
--- a/opendj-sdk/opends/src/messages/messages/backend.properties
+++ b/opendj-sdk/opends/src/messages/messages/backend.properties
@@ -943,3 +943,6 @@
to a file: %s
SEVERE_WARN_TRUSTSTORE_SET_PERMISSIONS_FAILED_328=Failed to set permissions \
on trust store file %s
+SEVERE_ERR_ROOT_CONTAINER_NOT_INITIALIZED_329=The root container for backend \
+ %s has not been initialized preventing this backend from processing the \
+ requested operation
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
index b9a7956..fc4ee52 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -623,7 +623,18 @@
*/
public long numSubordinates(DN entryDN) throws DirectoryException
{
- EntryContainer ec = rootContainer.getEntryContainer(entryDN);
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(entryDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
if(ec == null)
{
return -1;
@@ -669,7 +680,19 @@
public Entry getEntry(DN entryDN) throws DirectoryException
{
readerBegin();
- EntryContainer ec = rootContainer.getEntryContainer(entryDN);
+
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(entryDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
ec.sharedLock.lock();
Entry entry;
try
@@ -721,7 +744,19 @@
{
writerBegin();
DN entryDN = entry.getDN();
- EntryContainer ec = rootContainer.getEntryContainer(entryDN);
+
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(entryDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
ec.sharedLock.lock();
try
{
@@ -771,7 +806,18 @@
{
writerBegin();
- EntryContainer ec = rootContainer.getEntryContainer(entryDN);
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(entryDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
ec.sharedLock.lock();
try
{
@@ -822,7 +868,18 @@
writerBegin();
DN entryDN = entry.getDN();
- EntryContainer ec = rootContainer.getEntryContainer(entryDN);
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(entryDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
ec.sharedLock.lock();
try
@@ -878,8 +935,19 @@
throws DirectoryException, CancelledOperationException
{
writerBegin();
- EntryContainer currentContainer = rootContainer.getEntryContainer(
- currentDN);
+
+ EntryContainer currentContainer;
+ if (rootContainer != null)
+ {
+ currentContainer = rootContainer.getEntryContainer(currentDN);
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
+
EntryContainer container = rootContainer.getEntryContainer(entry.getDN());
if (currentContainer != container)
@@ -935,8 +1003,18 @@
throws DirectoryException
{
readerBegin();
- EntryContainer ec = rootContainer.getEntryContainer(
- searchOperation.getBaseDN());
+
+ EntryContainer ec;
+ if (rootContainer != null)
+ {
+ ec = rootContainer.getEntryContainer(searchOperation.getBaseDN());
+ }
+ else
+ {
+ Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID());
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message);
+ }
ec.sharedLock.lock();
try
--
Gitblit v1.10.0