/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions copyright 2013 ForgeRock AS.
*/
/**
* This class provides a compressed schema implementation whose definitions are
* stored in a Berkeley DB JE database.
*/
{
/**
* The name of the database used to store compressed attribute description
* definitions.
*/
/**
* The name of the database used to store compressed object class set
* definitions.
*/
/**
* The tracer object for the debug logger.
*/
// The compressed attribute description schema database.
// The environment in which the databases are held.
// The compresesd object class set schema database.
new ByteStringBuilder();
new ByteStringBuilder();
/**
* Creates a new instance of this JE compressed schema manager.
*
* @param environment
* A reference to the database environment in which the databases
* will be held.
* @throws DatabaseException
* If a database problem occurs while loading the compressed schema
* definitions from the database.
* @throws InitializationException
* If an error occurs while loading and processing the compressed
* schema definitions.
*/
{
this.environment = environment;
load();
}
/**
* Closes the databases and releases any resources held by this compressed
* schema manager.
*/
public void close()
{
try
{
adDatabase.sync();
}
catch (final Exception e)
{
// Ignore.
}
try
{
adDatabase.close();
}
catch (final Exception e)
{
// Ignore.
}
try
{
ocDatabase.sync();
}
catch (final Exception e)
{
// Ignore.
}
try
{
ocDatabase.close();
}
catch (final Exception e)
{
// Ignore.
}
adDatabase = null;
ocDatabase = null;
environment = null;
}
/**
* {@inheritDoc}
*/
throws DirectoryException
{
try
{
{
}
}
catch (final IOException e)
{
// TODO: Shouldn't happen but should log a message
}
}
/**
* {@inheritDoc}
*/
{
try
{
{
}
}
catch (final IOException e)
{
// TODO: Shouldn't happen but should log a message
}
}
/**
* Loads the compressed schema information from the database.
*
* @throws DatabaseException
* If a database error occurs while loading the definitions from the
* database.
* @throws InitializationException
* If an error occurs while loading and processing the definitions.
*/
{
{
dbConfig.setReadOnly(true);
dbConfig.setAllowCreate(false);
dbConfig.setTransactional(false);
}
{
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(false);
dbConfig.setDeferredWrite(true);
}
else
{
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(true);
}
// Cursor through the object class database and load the object class set
// definitions. At the same time, figure out the highest token value and
// initialize the object class counter to one greater than that.
try
{
{
while (reader.hasNextElement())
{
}
}
}
catch (final ASN1Exception ae)
{
if (debugEnabled())
{
}
.getMessage());
throw new InitializationException(m, ae);
}
finally
{
}
// Cursor through the attribute description database and load the attribute
// set definitions.
try
{
{
while (reader.hasNextElement())
{
}
}
}
catch (final ASN1Exception ae)
{
if (debugEnabled())
{
}
.getMessage());
throw new InitializationException(m, ae);
}
finally
{
}
}
{
boolean successful = false;
for (int i = 0; i < 3; i++)
{
try
{
{
successful = true;
break;
}
else
{
.toString());
throw new DirectoryException(
}
}
catch (final LockConflictException ce)
{
continue;
}
catch (final DatabaseException de)
{
.getMessage());
throw new DirectoryException(
}
}
if (!successful)
{
m);
}
}
}