Preview NTFS auto ensure in diagnostics
This commit is contained in:
@@ -19,6 +19,20 @@ namespace LiamWorkflowActivities
|
||||
public string ErrorCode { get; set; } = string.Empty;
|
||||
public string ErrorMessage { get; set; } = string.Empty;
|
||||
public List<DataAreaEntry> DataAreas { get; set; } = new List<DataAreaEntry>();
|
||||
public List<NtfsAutomaticEnsurePreviewEntry> AutomaticEnsurePreview { get; set; } = new List<NtfsAutomaticEnsurePreviewEntry>();
|
||||
}
|
||||
|
||||
public class NtfsAutomaticEnsurePreviewEntry
|
||||
{
|
||||
public string FolderPath { get; set; } = string.Empty;
|
||||
public bool WhatIf { get; set; } = true;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
public List<string> WouldCreateGroups { get; set; } = new List<string>();
|
||||
public List<string> WouldReuseGroups { get; set; } = new List<string>();
|
||||
public List<string> WouldAddAclEntries { get; set; } = new List<string>();
|
||||
public List<string> ExistingAclEntries { get; set; } = new List<string>();
|
||||
public List<string> WouldEnsureTraverseGroups { get; set; } = new List<string>();
|
||||
public List<string> Warnings { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
public class GetSecurityGroupsOperationResult
|
||||
@@ -63,7 +77,7 @@ namespace LiamWorkflowActivities
|
||||
|
||||
public static class LiamWorkflowRuntime
|
||||
{
|
||||
public static async Task<GetDataAreasOperationResult> GetDataAreasFromProviderAsync(cLiamProviderBase provider, string configurationId = null)
|
||||
public static async Task<GetDataAreasOperationResult> GetDataAreasFromProviderAsync(cLiamProviderBase provider, string configurationId = null, bool simulateConfiguredNtfsPermissionEnsure = false)
|
||||
{
|
||||
var result = new GetDataAreasOperationResult();
|
||||
if (provider == null)
|
||||
@@ -82,7 +96,7 @@ namespace LiamWorkflowActivities
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!await EnsureNtfsPermissionGroupsIfConfiguredAsync(provider, dataAreas, result))
|
||||
if (!await EnsureNtfsPermissionGroupsIfConfiguredAsync(provider, dataAreas, result, simulateConfiguredNtfsPermissionEnsure))
|
||||
return result;
|
||||
|
||||
result.DataAreas = dataAreas
|
||||
@@ -395,7 +409,7 @@ namespace LiamWorkflowActivities
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static async Task<bool> EnsureNtfsPermissionGroupsIfConfiguredAsync(cLiamProviderBase provider, List<cLiamDataAreaBase> dataAreas, GetDataAreasOperationResult result)
|
||||
private static async Task<bool> EnsureNtfsPermissionGroupsIfConfiguredAsync(cLiamProviderBase provider, List<cLiamDataAreaBase> dataAreas, GetDataAreasOperationResult result, bool simulateOnly)
|
||||
{
|
||||
if (!(provider is cLiamProviderNtfs ntfsProvider))
|
||||
return true;
|
||||
@@ -421,7 +435,8 @@ namespace LiamWorkflowActivities
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false);
|
||||
false,
|
||||
simulateOnly);
|
||||
if (ensureResult == null)
|
||||
{
|
||||
result.ErrorCode = "WF_GET_DATAAREAS_ENSURE_NTFS_GROUPS_FAILED";
|
||||
@@ -436,6 +451,13 @@ namespace LiamWorkflowActivities
|
||||
return false;
|
||||
}
|
||||
|
||||
if (simulateOnly)
|
||||
{
|
||||
LogAutomaticNtfsEnsurePreviewDebug(folderPath, ensureResult);
|
||||
result.AutomaticEnsurePreview.Add(MapAutomaticEnsurePreview(folderPath, ensureResult));
|
||||
continue;
|
||||
}
|
||||
|
||||
LogAutomaticNtfsEnsureDebug(folderPath, ensureResult);
|
||||
await ntfsArea.ResolvePermissionGroupsAsync(folderPath);
|
||||
}
|
||||
@@ -443,6 +465,39 @@ namespace LiamWorkflowActivities
|
||||
return true;
|
||||
}
|
||||
|
||||
private static NtfsAutomaticEnsurePreviewEntry MapAutomaticEnsurePreview(string folderPath, ResultToken ensureResult)
|
||||
{
|
||||
return new NtfsAutomaticEnsurePreviewEntry
|
||||
{
|
||||
FolderPath = folderPath ?? string.Empty,
|
||||
WhatIf = true,
|
||||
Message = ensureResult?.resultMessage ?? string.Empty,
|
||||
WouldCreateGroups = ensureResult?.createdGroups?.ToList() ?? new List<string>(),
|
||||
WouldReuseGroups = ensureResult?.reusedGroups?.ToList() ?? new List<string>(),
|
||||
WouldAddAclEntries = ensureResult?.addedAclEntries?.ToList() ?? new List<string>(),
|
||||
ExistingAclEntries = ensureResult?.skippedAclEntries?.ToList() ?? new List<string>(),
|
||||
WouldEnsureTraverseGroups = ensureResult?.ensuredTraverseGroups?.ToList() ?? new List<string>(),
|
||||
Warnings = ensureResult?.warnings?.ToList() ?? new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
private static void LogAutomaticNtfsEnsurePreviewDebug(string folderPath, ResultToken ensureResult)
|
||||
{
|
||||
if (ensureResult == null)
|
||||
return;
|
||||
|
||||
LogEntry(
|
||||
$"Automatic NTFS permission group ensure preview finished for '{folderPath}'. " +
|
||||
$"WouldCreateGroups={ensureResult.createdGroups.Count}, " +
|
||||
$"WouldReuseGroups={ensureResult.reusedGroups.Count}, " +
|
||||
$"WouldAddAcls={ensureResult.addedAclEntries.Count}, " +
|
||||
$"ExistingAcls={ensureResult.skippedAclEntries.Count}, " +
|
||||
$"WouldEnsureTraverseGroups={ensureResult.ensuredTraverseGroups.Count}, " +
|
||||
$"Warnings={ensureResult.warnings.Count}, " +
|
||||
$"ResultMessage='{ensureResult.resultMessage ?? string.Empty}'",
|
||||
LogLevels.Debug);
|
||||
}
|
||||
|
||||
private static void LogAutomaticNtfsEnsureDebug(string folderPath, ResultToken ensureResult)
|
||||
{
|
||||
if (ensureResult == null)
|
||||
|
||||
Reference in New Issue
Block a user