/// <summary> /// Adds a new object to the database /// </summary> /// <param name="csentry">The CSEntryChange containing the new object and its attributes</param> /// <param name="dc">The DBDataContext in use on this thread</param> /// <param name="referenceRetryRequired">A value indicating whether a reference update failed due to a missing object and needs to be retried after all other CSEntryChanges have been processed</param> /// <returns>A list of anchor attributes for the new object</returns> private static IList <AttributeChange> PerformCSEntryExportAdd(CSEntryChange csentry, out bool referenceRetryRequired) { if (csentry.ObjectType == null) { throw new InvalidOperationException("No object class was specified for CSEntryChange with DN " + csentry.DN); } AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(csentry.ObjectType); bool isUndeleting = false; MAObjectHologram hologram; Guid guidFromDn = new Guid(csentry.DN); if (objectClass.IsShadowObject) { hologram = CSEntryExport.ExportShadowObject(csentry); } else { hologram = GetResurrectionObject(csentry); if (hologram == null) { hologram = ActiveConfig.DB.CreateMAObject(guidFromDn, csentry.ObjectType); } else { Logger.WriteLine("Resurrecting object with ID: " + hologram.ObjectID.ToString()); isUndeleting = true; if (hologram.ObjectID != guidFromDn) { Logger.WriteLine("Re-anchoring object with new ID: " + csentry.DN); ActiveConfig.DB.ChangeMAObjectId(hologram.ObjectID, guidFromDn, true); hologram = ActiveConfig.DB.GetMAObject(guidFromDn, objectClass); } csentry = CSEntryChangeExtensions.ConvertCSEntryChangeAddToUpdate(csentry); } } AttributeChange anchorChange = AttributeChange.CreateAttributeAdd("objectId", csentry.DN); List <AttributeChange> anchorChanges = new List <AttributeChange>() { anchorChange }; if (!hologram.ObjectClass.IsShadowObject) { // shadow objects must be provisioned by their parent object, which automatically calls the Commit method hologram.CommitCSEntryChange(csentry, isUndeleting); } referenceRetryRequired = hologram.ReferenceRetryRequired; return(anchorChanges); }
public static void ExportToXml(MAObjectHologram maObject, XmlWriter writer, ObjectModificationType modificationType) { CSEntryChange csentry = CSEntryChangeExtensions.CreateCSEntryChangeFromMAObjectHologram(maObject, modificationType); ExportToXml(csentry, writer); }
/// <summary> /// Creates a CSEntryChange of the type 'add' for the supplied MAObjectHologram /// </summary> /// <param name="maObject">The MAObjectHologram to create the CSEntryChange from</param> /// <returns>A new CSEntryChange object representing the current state of the specified MAObjectHologram </returns> public static AcmaCSEntryChange CreateCSEntryChangeFromMAObjectHologram(this MAObjectHologram maObject) { return(CSEntryChangeExtensions.CreateCSEntryChangeFromMAObjectHologram(maObject, ObjectModificationType.Add)); }