* @throws DirectoryException When an error occurs.
*/
public static Entry createEntryFromMsg(ECLUpdateMsg eclmsg)
throws DirectoryException
{
Entry clEntry = null;
// Get the meat fro the ecl msg
UpdateMsg msg = eclmsg.getUpdateMsg();
if (msg instanceof AddMsg)
{
AddMsg addMsg = (AddMsg)msg;
// Map the addMsg to an LDIF string for the 'changes' attribute
String LDIFchanges = addMsgToLDIFString(addMsg);
ArrayList<RawAttribute> eclAttributes = addMsg.getEclIncludes();
clEntry = createChangelogEntry(
eclmsg.getServiceId(),
eclmsg.getCookie().toString(),
DN.decode(addMsg.getDn()),
addMsg.getChangeNumber(),
LDIFchanges, // entry as created (in LDIF format)
addMsg.getUniqueId(),
null, // real time current entry
eclAttributes, // entry attributes
eclmsg.getDraftChangeNumber(),
"add", null);
} else
if (msg instanceof ModifyMsg)
{
ModifyMsg modMsg = (ModifyMsg)msg;
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
try
{
// Map the modMsg modifications to an LDIF string
// for the 'changes' attribute of the CL entry
ModifyOperation modifyOperation =
(ModifyOperation)modMsg.createOperation(conn);
String LDIFchanges = modToLDIF(modifyOperation.getModifications());
ArrayList<RawAttribute> eclAttributes = modMsg.getEclIncludes();
clEntry = createChangelogEntry(
eclmsg.getServiceId(),
eclmsg.getCookie().toString(),
DN.decode(modMsg.getDn()),
modMsg.getChangeNumber(),
LDIFchanges,
modMsg.getUniqueId(),
null, // real time current entry
eclAttributes, // entry attributes
eclmsg.getDraftChangeNumber(),
"modify",null);
}
catch(Exception e)
{
// Exceptions raised by createOperation for example
throw new DirectoryException(ResultCode.OTHER,
Message.raw(Category.SYNC, Severity.NOTICE,
" Server fails to create entry: "),e);
}
}
else if (msg instanceof ModifyDNMsg)
{
try
{
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
ModifyDNMsg modDNMsg = (ModifyDNMsg)msg;
ArrayList<RawAttribute> eclAttributes = modDNMsg.getEclIncludes();
ModifyDNOperation modifyDNOperation =
(ModifyDNOperation)modDNMsg.createOperation(conn);
String LDIFchanges = modToLDIF(modifyDNOperation.getModifications());
clEntry = createChangelogEntry(
eclmsg.getServiceId(),
eclmsg.getCookie().toString(),
DN.decode(modDNMsg.getDn()),
modDNMsg.getChangeNumber(),
LDIFchanges,
modDNMsg.getUniqueId(),
null, // real time current entry
eclAttributes, // entry attributes
eclmsg.getDraftChangeNumber(),
"modrdn", null);
Attribute a = Attributes.create("newrdn", modDNMsg.getNewRDN());
clEntry.addAttribute(a, null);
if (modDNMsg.getNewSuperior()!=null)
{
Attribute b = Attributes.create("newsuperior",
modDNMsg.getNewSuperior());
clEntry.addAttribute(b, null);
}
Attribute c = Attributes.create("deleteoldrdn",
String.valueOf(modDNMsg.deleteOldRdn()));
clEntry.addAttribute(c, null);
}
catch(Exception e)
{
// Exceptions raised by createOperation for example
throw new DirectoryException(ResultCode.OTHER,