protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaShadowObjectLink link = ActiveConfig.DB.GetShadowLink(this.Name);
                ActiveConfig.DB.DeleteShadowLink(link);
                ActiveConfig.DB.ClearCache();
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
예제 #2
0
        private static MAObjectHologram ExportShadowObject(CSEntryChange csentry)
        {
            if (!csentry.AttributeChanges.Contains("shadowLink"))
            {
                throw new ShadowObjectExportException("The shadowLink attribute was not present");
            }

            if (!csentry.AttributeChanges.Contains("shadowParent"))
            {
                throw new ShadowObjectExportException("The shadowParent attribute was not present");
            }

            ValueChange shadowParentValueChange = csentry.AttributeChanges["shadowParent"].ValueChanges.FirstOrDefault(t => t.ModificationType == ValueModificationType.Add);

            if (shadowParentValueChange == null)
            {
                throw new ShadowObjectExportException("The shadowParent attribute did not contain any value adds");
            }

            if (shadowParentValueChange.Value == null)
            {
                throw new ShadowObjectExportException("The shadowParent attribute was null");
            }

            Guid shadowParentID;

            if (shadowParentValueChange.Value is Guid)
            {
                shadowParentID = (Guid)shadowParentValueChange.Value;
            }
            else
            {
                shadowParentID = new Guid(shadowParentValueChange.Value.ToSmartString());
            }

            MAObjectHologram parentHologram = ActiveConfig.DB.GetMAObjectOrDefault(shadowParentID);

            if (parentHologram == null)
            {
                throw new ShadowObjectExportException(string.Format("The shadow parent {0} for object {1} was not found", shadowParentID, csentry.DN));
            }

            ValueChange shadowLinkValueChange = csentry.AttributeChanges["shadowLink"].ValueChanges.FirstOrDefault(t => t.ModificationType == ValueModificationType.Add);

            if (shadowLinkValueChange == null)
            {
                throw new ShadowObjectExportException("The shadowLink attribute did not contain any value adds");
            }

            string shadowLinkID = shadowLinkValueChange.Value as string;

            AcmaSchemaShadowObjectLink link = ActiveConfig.DB.ShadowObjectLinks.FirstOrDefault(t => t.Name == shadowLinkID);

            if (link == null)
            {
                throw new ShadowObjectExportException(string.Format("The shadowLink '{0}' was not found in the database", shadowLinkID));
            }

            AcmaSchemaObjectClass shadowObjectClass = ActiveConfig.DB.ObjectClasses.FirstOrDefault(t => t.Name == csentry.ObjectType);

            if (shadowObjectClass == null)
            {
                throw new NoSuchObjectTypeException(csentry.ObjectType);
            }

            if (shadowObjectClass != link.ShadowObjectClass)
            {
                throw new ShadowObjectExportException(
                          string.Format("The object class exported ({0}) does not match the expected object class ({1}) specified by the link '{2}'",
                                        shadowObjectClass.Name, link.ShadowObjectClass, link.Name));
            }

            if (link.ParentObjectClass != parentHologram.ObjectClass)
            {
                throw new ShadowObjectExportException(string.Format(
                                                          "The specified parent object '{0}' was of the object type '{1}', however the link '{2}' defines '{3}' as the expected parent object type",
                                                          parentHologram.ObjectID, parentHologram.ObjectClass.Name, link.Name, link.ParentObjectClass.Name));
            }

            AttributeValue provisioningAttribute = parentHologram.GetSVAttributeValue(link.ProvisioningAttribute);

            if (provisioningAttribute.ValueBoolean == true)
            {
                throw new ShadowObjectExportException(string.Format("The shadow parent {0} already has a shadow object referenced by the link '{1}'", shadowParentID, shadowLinkID));
            }

            return(parentHologram.ProvisionShadowObject(link, csentry));
        }