internal static ConfigurationObjectType GetConfigurationObjectTypeFromString(string objectTypeString) { ConfigurationObjectType result = ConfigurationObjectType.Policy; if (typeof(PolicyStorage).Name.Equals(objectTypeString, StringComparison.OrdinalIgnoreCase)) { result = ConfigurationObjectType.Policy; } else if (typeof(RuleStorage).Name.Equals(objectTypeString, StringComparison.OrdinalIgnoreCase)) { result = ConfigurationObjectType.Rule; } else if (typeof(AssociationStorage).Name.Equals(objectTypeString, StringComparison.OrdinalIgnoreCase)) { result = ConfigurationObjectType.Association; } else if (typeof(BindingStorage).Name.Equals(objectTypeString, StringComparison.OrdinalIgnoreCase)) { result = ConfigurationObjectType.Binding; } else if (typeof(ScopeStorage).Name.Equals(objectTypeString, StringComparison.OrdinalIgnoreCase)) { result = ConfigurationObjectType.Scope; } return(result); }
public PolicyConfigConverter(ADPropertyDefinition policyIdProperty, ConfigurationObjectType configurationObjectType, Action <TPolicyStorage, TPolicyConfig> copyPropertiesToPolicyConfigDelegate, Action <TPolicyConfig, TPolicyStorage> copyPropertiesToStorageDelegate) : base(typeof(TPolicyConfig), configurationObjectType, typeof(TPolicyStorage), policyIdProperty) { ArgumentValidator.ThrowIfNull("copyPropertiesToPolicyConfigDelegate", copyPropertiesToPolicyConfigDelegate); ArgumentValidator.ThrowIfNull("copyPropertiesToStorageDelegate", copyPropertiesToStorageDelegate); this.copyPropertiesToPolicyConfigDelegate = copyPropertiesToPolicyConfigDelegate; this.copyPropertiesToStorageDelegate = copyPropertiesToStorageDelegate; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationObjectTag" /> class. /// </summary> /// <param name="id">The unique ID of the configuration object.</param> /// <param name="objectType">The <see cref="ConfigurationObjectType" />.</param> /// <param name="resourceType">The <see cref="VirtualResourceType" />.</param> /// <param name="metadataType">The virtual resource metadata type.</param> internal ConfigurationObjectTag(Guid id, ConfigurationObjectType objectType, VirtualResourceType resourceType, string metadataType) { Id = id; ObjectType = objectType; ResourceType = resourceType; MetadataType = metadataType; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationObject"/> with a given type. /// </summary> /// <param name="objectType">The type of the object.</param> protected ConfigurationObject(ConfigurationObjectType objectType) { ObjectType = objectType; #if DEBUG // Setup the id in the debug mode SetupId(); #endif }
protected PolicyConfigConverterBase(Type policyConfigType, ConfigurationObjectType configurationObjectType, Type storageType, ADPropertyDefinition policyIdProperty) { ArgumentValidator.ThrowIfNull("policyConfigType", policyConfigType); ArgumentValidator.ThrowIfNull("storageType", storageType); ArgumentValidator.ThrowIfNull("policyIdProperty", policyIdProperty); this.PolicyConfigType = policyConfigType; this.ConfigurationObjectType = configurationObjectType; this.StorageType = storageType; this.PolicyIdProperty = policyIdProperty; }
/// <summary> /// Determines whether the specified map type can be enabled/disabled. /// </summary> /// <param name="mapType">Type of the map.</param> /// <returns> /// <c>true</c> if the specified map type can be enabled/disabled; otherwise, <c>false</c>. /// </returns> public static bool CanEnableDisable(this ConfigurationObjectType mapType) { switch (mapType) { case ConfigurationObjectType.VirtualResource: case ConfigurationObjectType.ResourceMetadata: return(true); default: return(false); } }
private void LoadSortedConfigFolders(EnterpriseTestContext context, ConfigurationObjectType folderType, IEnumerable <ConfigurationObjectTag> parentTags) { List <ConfigurationTreeFolder> folders = context.ConfigurationTreeFolders.Where(n => n.FolderType == folderType.ToString()).ToList(); Dictionary <Guid, VirtualResourceType> parentResourceTypes = parentTags.ToDictionary(n => n.Id, n => n.ResourceType); // Loop over folders collection until we reach a point where no folders are added. // The remainder of the folders don't have parents in the tree and will be ignored. bool foundFoldersToAdd; do { foundFoldersToAdd = false; // While loop used here so that we can modify the collection as we iterate int i = 0; while (i < folders.Count) { ConfigurationTreeFolder folder = folders[i]; // Determine whether or not we can create a tag for this folder right now ConfigurationObjectTag folderTag = null; if (folder.ParentId == null) { // Folder has no parent - add it now folderTag = new ConfigurationObjectTag(folder); } else { // Check to see if parent has already been added if (parentResourceTypes.TryGetValue(folder.ParentId.Value, out VirtualResourceType resourceType)) { // Parent has been added, so this folder can be added now folderTag = new ConfigurationObjectTag(folder, resourceType); } } // If we were able to create a tag, add it to the new list and remove it from the old if (folderTag != null) { foundFoldersToAdd = true; _configMap.Add(folderTag); parentResourceTypes.Add(folderTag.Id, folderTag.ResourceType); folders.RemoveAt(i); } else { // Cannot add this folder - move to the next one i++; } } } while (foundFoldersToAdd); }
internal ChangeNotificationData(Guid id, Guid parentId, ConfigurationObjectType objectType, ChangeType changeType, Workload workload, PolicyVersion version, UnifiedPolicyErrorCode errorCode = UnifiedPolicyErrorCode.Unknown, string errorMessage = "") { this.Id = id; this.ParentId = parentId; this.ObjectType = objectType; this.ChangeType = changeType; this.Workload = workload; this.Version = version; this.ErrorCode = errorCode; this.ErrorMessage = errorMessage; this.ShouldNotify = true; this.UseFullSync = false; }
private static ChangeNotificationData CreateChangeData(Workload workload, UnifiedPolicyStorageBase policyStorageObject) { Guid parentId = Guid.Empty; ConfigurationObjectType objectType = (policyStorageObject is ScopeStorage) ? ConfigurationObjectType.Scope : PolicyConfigConverterTable.GetConfigurationObjectType(policyStorageObject); if (policyStorageObject is RuleStorage) { parentId = ((RuleStorage)policyStorageObject).ParentPolicyId; } else if (policyStorageObject is BindingStorage) { parentId = ((BindingStorage)policyStorageObject).PolicyId; } return(new ChangeNotificationData(policyStorageObject.Id.ObjectGuid, parentId, objectType, (policyStorageObject.ObjectState == ObjectState.Deleted) ? ChangeType.Delete : ChangeType.Update, workload, PolicyVersion.Create(policyStorageObject.PolicyVersion), UnifiedPolicyErrorCode.Unknown, "")); }
protected override void InternalProcessRecord() { string parameterSetName; if ((parameterSetName = base.ParameterSetName) != null) { if (!(parameterSetName == "SyncByType")) { if (!(parameterSetName == "SyncUpdateObject")) { if (!(parameterSetName == "SyncDeleteObject")) { goto IL_124; } goto IL_D1; } } else { using (MultiValuedProperty <ConfigurationObjectType> .Enumerator enumerator = this.ObjectType.GetEnumerator()) { while (enumerator.MoveNext()) { ConfigurationObjectType objectType = enumerator.Current; this.syncChangeInfos.Add(new SyncChangeInfo(objectType)); } goto IL_124; } } using (IEnumerator <Guid> enumerator2 = this.objectSyncGuids.GetEnumerator()) { while (enumerator2.MoveNext()) { Guid value = enumerator2.Current; this.syncChangeInfos.Add(new SyncChangeInfo(this.ObjectType.First <ConfigurationObjectType>(), ChangeType.Update, null, new Guid?(value))); } goto IL_124; } IL_D1: foreach (Guid value2 in this.DeleteObjectId) { this.syncChangeInfos.Add(new SyncChangeInfo(this.ObjectType.First <ConfigurationObjectType>(), ChangeType.Delete, null, new Guid?(value2))); } } IL_124: this.SendNotification(); }
public PolicyConfigurationBase GetObject(Guid tenantId, ConfigurationObjectType objectType, Guid objectId, bool includeDeletedObjects = false) { switch (objectType) { case ConfigurationObjectType.Policy: return(this.GetObjectInternal <PolicyStorage, PolicyConfiguration>(tenantId, objectId, includeDeletedObjects, new Func <PolicyStorage, PolicyConfiguration>(UnifiedPolicyStorageFactory.FromPolicyStorage))); case ConfigurationObjectType.Rule: return(this.GetObjectInternal <RuleStorage, RuleConfiguration>(tenantId, objectId, includeDeletedObjects, new Func <RuleStorage, RuleConfiguration>(UnifiedPolicyStorageFactory.FromRuleStorage))); case ConfigurationObjectType.Association: return(this.GetObjectInternal <AssociationStorage, AssociationConfiguration>(tenantId, objectId, includeDeletedObjects, new Func <AssociationStorage, AssociationConfiguration>(UnifiedPolicyStorageFactory.FromAssociationStorage))); case ConfigurationObjectType.Binding: return(this.GetObjectInternal <BindingStorage, BindingConfiguration>(tenantId, objectId, includeDeletedObjects, new Func <BindingStorage, BindingConfiguration>(UnifiedPolicyStorageFactory.FromBindingStorage))); default: throw new NotSupportedException(); } }
public PolicyDistributionErrorDetails(string endpoint, Guid objectId, ConfigurationObjectType objectType, Workload workload, UnifiedPolicyErrorCode errorCode, string errorMessage, DateTime lastErrorTime, string additionalDiagnostics) { this.Endpoint = endpoint; this.ObjectId = objectId; this.ObjectType = objectType; this.Workload = workload; this.ResultCode = errorCode; this.ResultMessage = errorMessage; this.LastResultTime = new DateTime?(lastErrorTime); this.AdditionalDiagnostics = additionalDiagnostics; this.Severity = PolicyDistributionResultSeverity.Error; if (string.IsNullOrEmpty(this.ResultMessage)) { string resultMessage; if (!PolicyDistributionErrorDetails.errorCodeToStringMap.TryGetValue(this.ResultCode, out resultMessage)) { resultMessage = Strings.UnknownErrorMsg; } this.ResultMessage = resultMessage; } }
/// <summary> /// Determines whether this instance can contain the specified map type. /// </summary> /// <param name="mapType">Type of the map.</param> /// <param name="childType">Type of the child.</param> /// <returns> /// <c>true</c> if this instance can contain the specified map type; otherwise, <c>false</c>. /// </returns> public static bool CanContain(this ConfigurationObjectType mapType, ConfigurationObjectType childType) { switch (mapType) { case ConfigurationObjectType.ScenarioFolder: return(childType == ConfigurationObjectType.ScenarioFolder || childType == ConfigurationObjectType.EnterpriseScenario); case ConfigurationObjectType.EnterpriseScenario: case ConfigurationObjectType.ResourceFolder: return(childType == ConfigurationObjectType.ResourceFolder || childType == ConfigurationObjectType.VirtualResource); case ConfigurationObjectType.VirtualResource: case ConfigurationObjectType.MetadataFolder: return(childType == ConfigurationObjectType.MetadataFolder || childType == ConfigurationObjectType.ResourceMetadata); default: return(false); } }
private static string ConvertToSettingType(ConfigurationObjectType objectType) { switch (objectType) { case ConfigurationObjectType.Policy: return(typeof(PolicyStorage).Name); case ConfigurationObjectType.Rule: return(typeof(RuleStorage).Name); case ConfigurationObjectType.Association: return(typeof(AssociationStorage).Name); case ConfigurationObjectType.Binding: return(typeof(BindingStorage).Name); case ConfigurationObjectType.Scope: return(typeof(ScopeStorage).Name); default: throw new NotSupportedException(string.Format("Object type {0} not supported", objectType)); } }
/// <summary> /// Manages the copying of any of the nodes used. Tries to link the UI structure to the database /// structure of the trees. /// </summary> /// <param name="SourceNodes">List representation of the tree. In couplet format - /// [0] is parent, [1] is the 'node'. Using List because any node can be parent to multiple /// other nodes and reversing it to use a dictionary negates the performance benefit of dictioanries</param> /// <param name="Ndx">Index into the tree representation list.</param> /// <param name="Mappings">Dictionary. Key is the original node ID, and the Value is the new/copy /// node Id</param> /// <returns>Guid / Node ID of the node that was created during the copy.</returns> public Guid CopyNode(List <Guid?> SourceNodes, int Ndx, Dictionary <Guid?, Guid?> Mappings, ConfigurationObjectType rootMovedType) { if (SourceNodes.Count <= (Ndx + 1)) { throw new Exception("Bad Source List / Index in CopyNode ::" + Ndx.ToString()); } if (Mappings.ContainsKey(SourceNodes[Ndx + 1])) { throw new Exception("Doubly Linked Node in UI Tree: " + SourceNodes[Ndx + 1].ToString()); } EnterpriseTestMapNode src = _databaseMap[(Guid)SourceNodes[Ndx + 1]]; switch (src.NodeType) { case ConfigurationObjectType.ScenarioFolder: case ConfigurationObjectType.ResourceFolder: case ConfigurationObjectType.MetadataFolder: return(CopyFolder((Guid)SourceNodes[Ndx + 1], Mappings[(Guid?)SourceNodes[Ndx]])); case ConfigurationObjectType.EnterpriseScenario: return(CopyScenario((Guid)SourceNodes[Ndx + 1], Mappings[(Guid?)SourceNodes[Ndx]])); case ConfigurationObjectType.VirtualResource: return(CopyResource((Guid)SourceNodes[Ndx + 1], (Guid)SourceNodes[Ndx], (Guid)Mappings[(Guid?)SourceNodes[Ndx]], Mappings)); case ConfigurationObjectType.ResourceMetadata: bool partOfResource = (rootMovedType != ConfigurationObjectType.ResourceMetadata && rootMovedType != ConfigurationObjectType.MetadataFolder); return(CopyActivity((Guid)SourceNodes[Ndx + 1], (Guid)SourceNodes[Ndx], (Guid)Mappings[(Guid?)SourceNodes[Ndx]], Mappings, partOfResource)); default: throw new Exception("Unknown Node type in CopyNode?"); } }
private static Dictionary <Workload, List <ChangeNotificationData> > GenerateSyncs(IEnumerable <UnifiedPolicySettingStatus> syncStatuses, IEnumerable <Workload> workloads, IConfigDataProvider dataSession, UnifiedPolicyStorageBase storageObject, ConfigurationObjectType objectType) { Dictionary <Workload, List <ChangeNotificationData> > dictionary = new Dictionary <Workload, List <ChangeNotificationData> >(); if (syncStatuses.Any((UnifiedPolicySettingStatus s) => SetCompliancePolicyBase.HasDistributionFailed(storageObject, s))) { storageObject.PolicyVersion = CombGuidGenerator.NewGuid(); dataSession.Save(storageObject); foreach (Workload workload in workloads) { dictionary[workload] = new List <ChangeNotificationData> { AggregatedNotificationClients.CreateChangeData(workload, storageObject) }; } } return(dictionary); }
/// <summary> /// Initializes a new instance of the <see cref="ObjectConstructionParameter"/> class. /// </summary> /// <param name="expectedType">The object type represented by this parameter.</param> public ObjectConstructionParameter(ConfigurationObjectType expectedType) { ObjectType = expectedType; }
/// <summary> /// Determines whether the specified map type is a folder type. /// </summary> /// <param name="mapType">Type of the map.</param> /// <returns> /// <c>true</c> if the specified map type is a folder type; otherwise, <c>false</c>. /// </returns> public static bool IsFolder(this ConfigurationObjectType mapType) { return(mapType == ConfigurationObjectType.ScenarioFolder || mapType == ConfigurationObjectType.ResourceFolder || mapType == ConfigurationObjectType.MetadataFolder); }
/// <summary> /// Initializes a new instance of the <see cref="LooseConfigurationObject"/> with a given type. /// </summary> /// <param name="objectType">The type of the object.</param> public LooseConfigurationObject(ConfigurationObjectType objectType) : base(objectType) { }
/// <summary> /// Initializes a new instance of the <see cref="PredefinedConstruction"/> class. /// </summary> /// <param name="type">The type of the predefined construction.</param> /// <param name="parameters">The parameters representing the signature of the construction.</param> /// <param name="outputType">The output type of the construction.</param> public PredefinedConstruction(PredefinedConstructionType type, IReadOnlyList <ConstructionParameter> parameters, ConfigurationObjectType outputType) : base(type.ToString(), parameters, outputType) { Type = type; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationObjectTag"/> class. /// </summary> /// <param name="type">The type.</param> internal ConfigurationObjectTag(ConfigurationObjectType type) { Id = Guid.Empty; ObjectType = type; }
/// <summary> /// Initializes a new instance of the <see cref="Construction"/> class. /// </summary> /// <param name="name">The name of the construction.</param> /// <param name="parameters">The parameters representing the signature of the construction.</param> /// <param name="outputType">The output type of the construction.</param> protected Construction(string name, IReadOnlyList <ConstructionParameter> parameters, ConfigurationObjectType outputType) { Name = name ?? throw new ArgumentNullException(nameof(name)); Signature = new Signature(parameters); OutputType = outputType; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationObjectTag"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="resourceType">Type of the resource.</param> /// <param name="metadataType">Type of the metadata.</param> internal ConfigurationObjectTag(ConfigurationObjectType type, VirtualResourceType resourceType, string metadataType) : this(type, resourceType) { MetadataType = metadataType; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationObjectTag"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="resourceType">Type of the resource.</param> internal ConfigurationObjectTag(ConfigurationObjectType type, VirtualResourceType resourceType) : this(type) { ResourceType = resourceType; }