Map<ObjectClass, String> objectclasses =
new HashMap<ObjectClass, String>();
for (RawAttribute a : addOperation.getRawAttributes())
{
Attribute attr = a.toAttribute();
if (attr.getAttributeType().isObjectClassType())
{
for (ByteString os : a.getValues())
{
String ocName = os.toString();
ObjectClass oc =
DirectoryServer.getObjectClass(toLowerCase(ocName));
if (oc == null)
{
oc = DirectoryServer.getDefaultObjectClass(ocName);
}
objectclasses.put(oc,ocName);
}
}
else
{
addAttribute(attributes, attr);
}
}
Attribute changetype = Attributes.create("changetype", "add");
addAttribute(attributes, changetype);
if (exportConfig != null)
{
AddChangeRecordEntry changeRecord =
new AddChangeRecordEntry(dn, attributes);
ldifWriter.writeChangeRecord(changeRecord);
}
else
{
entry = new Entry(dn, objectclasses, attributes, null);
}
}
else if (msg instanceof DeleteMsg)
{
DeleteMsg delMsg = (DeleteMsg)msg;
dn = DN.decode("uuid=" + msg.getUniqueId() + "," +
CHANGE_NUMBER + "=" + delMsg.getChangeNumber().toString()+ "," +
msg.getDn() +","+ BASE_DN);
DeleteChangeRecordEntry changeRecord =
new DeleteChangeRecordEntry(dn);
if (exportConfig != null)
{
ldifWriter.writeChangeRecord(changeRecord);
}
else
{
Writer writer = new Writer();
LDIFWriter ldifWriter2 = writer.getLDIFWriter();
ldifWriter2.writeChangeRecord(changeRecord);
LDIFReader reader = writer.getLDIFReader();
entry = reader.readEntry();
}
}
else if (msg instanceof ModifyMsg)
{
ModifyOperation op = (ModifyOperation)msg.createOperation(conn);
dn = DN.decode("uuid=" + msg.getUniqueId() + "," +
CHANGE_NUMBER + "=" + msg.getChangeNumber().toString()+ "," +
msg.getDn() +","+ BASE_DN);
op.setInternalOperation(true);
ModifyChangeRecordEntry changeRecord =
new ModifyChangeRecordEntry(dn, op.getRawModifications());
if (exportConfig != null)
{
ldifWriter.writeChangeRecord(changeRecord);
}
else
{
Writer writer = new Writer();
LDIFWriter ldifWriter2 = writer.getLDIFWriter();
ldifWriter2.writeChangeRecord(changeRecord);
LDIFReader reader = writer.getLDIFReader();
entry = reader.readEntry();
}
}
else if (msg instanceof ModifyDNMsg)
{
ModifyDNOperation op = (ModifyDNOperation)msg.createOperation(conn);
dn = DN.decode("uuid=" + msg.getUniqueId() + "," +
CHANGE_NUMBER + "=" + msg.getChangeNumber().toString()+ "," +
msg.getDn() +","+ BASE_DN);
op.setInternalOperation(true);
ModifyDNChangeRecordEntry changeRecord =
new ModifyDNChangeRecordEntry(dn, op.getNewRDN(), op.deleteOldRDN(),
op.getNewSuperior());
if (exportConfig != null)
{
ldifWriter.writeChangeRecord(changeRecord);
}
else
{
Writer writer = new Writer();
LDIFWriter ldifWriter2 = writer.getLDIFWriter();
ldifWriter2.writeChangeRecord(changeRecord);
LDIFReader reader = writer.getLDIFReader();
Entry modDNEntry = reader.readEntry();
entry = modDNEntry;
}
}
if (exportConfig != null)
{
this.exportedCount++;
}
else
{
// Add extensibleObject objectclass and the ChangeNumber
// in the entry.
if (!entry.getObjectClasses().containsKey(objectclass))
entry.addObjectClass(objectclass);
Attribute changeNumber =
Attributes.create(CHANGE_NUMBER,
msg.getChangeNumber().toString());
addAttribute(entry.getUserAttributes(), changeNumber);
Attribute domain = Attributes.create("replicationDomain", baseDN);
addAttribute(entry.getUserAttributes(), domain);
// Get the base DN, scope, and filter for the search.
DN searchBaseDN = searchOperation.getBaseDN();
SearchScope scope = searchOperation.getScope();