/*
* Search the database entry that is used to periodically
* save the generation id
*/
SearchResultEntry resultEntry = null;
InternalSearchOperation search = null;
LinkedHashSet<String> attributes = new LinkedHashSet<String>(1);
attributes.add(REPLICATION_GENERATION_ID);
search = conn.processSearch(asn1BaseDn,
SearchScope.BASE_OBJECT,
DereferencePolicy.DEREF_ALWAYS, 0, 0, false,
filter,attributes);
if (search.getResultCode() == ResultCode.NO_SUCH_OBJECT)
{
// if the base entry does not exist look for the generationID
// in the config entry.
asn1BaseDn = ByteString.valueOf(baseDn.toString());
search = conn.processSearch(asn1BaseDn,
SearchScope.BASE_OBJECT,
DereferencePolicy.DEREF_ALWAYS, 0, 0, false,
filter,attributes);
}
if (search.getResultCode() != ResultCode.SUCCESS)
{
if (search.getResultCode() == ResultCode.NO_SUCH_OBJECT)
{
// nothing initialized yet
// don't log an error generationID will be computed.
}
else
{
//
Message message = ERR_SEARCHING_GENERATION_ID.get(
search.getResultCode().getResultCodeName() + " " +
search.getErrorMessage(),
baseDn.toString());
logError(message);
}
}
else
{
LinkedList<SearchResultEntry> result = search.getSearchEntries();
resultEntry = result.getFirst();
if (resultEntry != null)
{
AttributeType synchronizationGenIDType =
DirectoryServer.getAttributeType(REPLICATION_GENERATION_ID);
List<Attribute> attrs =
resultEntry.getAttribute(synchronizationGenIDType);
if (attrs != null)
{
Attribute attr = attrs.get(0);
if (attr.size()>1)
{
Message message = ERR_LOADING_GENERATION_ID.get(
baseDn.toString(), "#Values=" + attr.size() +
" Must be exactly 1 in entry " +
resultEntry.toLDIFString());
logError(message);
}
else if (attr.size() == 1)
{
found=true;