Skip to content

Commit

Permalink
XML Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Dec 2, 2024
1 parent 1527386 commit b98ba07
Show file tree
Hide file tree
Showing 21 changed files with 282 additions and 62 deletions.
4 changes: 3 additions & 1 deletion uSync.BackOffice/Models/OrderedNodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ public OrderedNodeInfo(string filename, XElement node, int level, string path, b
/// <summary>
/// overwrites the node value for this ordered node element.
/// </summary>
/// <param name="node"></param>
public void SetNode(XElement node)
=> Node = node;

/// <summary>
/// set the filename for a node.
/// </summary>
public void SetFileName(string filename)
=> FileName = filename;

Expand Down
7 changes: 7 additions & 0 deletions uSync.BackOffice/Models/UploadImportResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace uSync.BackOffice.Models;
/// </summary>
public class UploadImportResult
{
/// <summary>
/// upload was successful.
/// </summary>
public required bool Success { get; set; }

/// <summary>
/// list of possible errors (if upload failed)
/// </summary>
public IEnumerable<string> Errors { get; set; } = [];
}
20 changes: 20 additions & 0 deletions uSync.BackOffice/Services/ISyncActionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public interface ISyncActionService
[Obsolete("use ExportHandlerAsync will be removed in v16")]
SyncActionResult ExportHandler(SyncActionOptions options, uSyncCallbacks? callbacks)
=> ExportHandlerAsync(options, callbacks).Result;

/// <summary>
/// run an export based on the options provided
/// </summary>
Task<SyncActionResult> ExportHandlerAsync(SyncActionOptions options, uSyncCallbacks? callbacks);

/// <summary>
Expand All @@ -37,6 +41,10 @@ SyncActionResult ExportHandler(SyncActionOptions options, uSyncCallbacks? callba
[Obsolete("use ImportHandlerAsync will be removed in v16")]
SyncActionResult ImportHandler(SyncActionOptions options, uSyncCallbacks? callbacks)
=> ImportHandlerAsync(options, callbacks).Result;

/// <summary>
/// run an export based on the options provided
/// </summary>
Task<SyncActionResult> ImportHandlerAsync(SyncActionOptions options, uSyncCallbacks? callbacks);

/// <summary>
Expand All @@ -45,6 +53,10 @@ SyncActionResult ImportHandler(SyncActionOptions options, uSyncCallbacks? callba
[Obsolete("use ImportPostAsync will be removed in v16")]
SyncActionResult ImportPost(SyncActionOptions options, uSyncCallbacks? callbacks)
=> ImportPostAsync(options, callbacks).Result;

/// <summary>
/// run an export based on the options provided
/// </summary>
Task<SyncActionResult> ImportPostAsync(SyncActionOptions options, uSyncCallbacks? callbacks);

/// <summary>
Expand All @@ -53,13 +65,21 @@ SyncActionResult ImportPost(SyncActionOptions options, uSyncCallbacks? callbacks
[Obsolete("use ReportHandlerAsync will be removed in v16")]
SyncActionResult ReportHandler(SyncActionOptions options, uSyncCallbacks? callbacks)
=> ReportHandlerAsync(options, callbacks).Result;

/// <summary>
/// run a report for a given handler based on the options provided.
/// </summary>
Task<SyncActionResult> ReportHandlerAsync(SyncActionOptions options, uSyncCallbacks? callbacks);

/// <summary>
/// start the bulk process
/// </summary>
[Obsolete("use StartProcessAsync will be removed in v16")]
void StartProcess(HandlerActions action) => StartProcessAsync(action).Wait();

/// <summary>
/// run an export based on the options provided
/// </summary>
Task StartProcessAsync(HandlerActions action);

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions uSync.BackOffice/Services/ISyncFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public interface ISyncFileService
/// <summary>
/// delete a folder (and all its contents)
/// </summary>
/// <param name="folder">Path to the folder to delete</param>
/// <param name="safe">don't throw an exception if this fails</param>
void DeleteFolder(string folder, bool safe = false);

Expand Down
65 changes: 65 additions & 0 deletions uSync.BackOffice/Services/ISyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
using uSync.BackOffice.SyncHandlers.Models;

namespace uSync.BackOffice;

/// <summary>
/// uSync service for syncing to and from.
/// </summary>
public interface ISyncService
{
/// <summary>
Expand Down Expand Up @@ -127,7 +131,14 @@ public interface ISyncService
/// </summary>
Task<IEnumerable<uSyncAction>> ReportPartialAsync(IList<OrderedNodeInfo> orderedNodes, uSyncPagedImportOptions options);

/// <summary>
/// run an export on startup
/// </summary>
Task<IEnumerable<uSyncAction>> StartupExportAsync(string folder, SyncHandlerOptions handlerOptions, uSyncCallbacks? callbacks = null);

/// <summary>
/// run an import on startup.
/// </summary>
Task<IEnumerable<uSyncAction>> StartupImportAsync(string[] folders, bool force, SyncHandlerOptions handlerOptions, uSyncCallbacks? callbacks = null);

/// <summary>
Expand All @@ -144,16 +155,28 @@ public interface ISyncService
// implementations are mostly here in the interface, but there are a couple still in
// the service which need to be removed too.

/// <summary>
/// OBSOLETE: Export handlers from a folder
/// </summary>
[Obsolete("use ExportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Export(string folder, IEnumerable<HandlerConfigPair> handlers, uSyncCallbacks? callbacks);

/// <summary>
/// OBSOLETE: Export handlers from a folder
/// </summary>
[Obsolete("use ExportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Export(string folder, IEnumerable<string> handlerAliases, uSyncCallbacks? callbacks);

/// <summary>
/// OBSOLETE: Export handler from a folder
/// </summary>
[Obsolete("use ExportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ExportHandler(string handler, uSyncImportOptions options)
=> ExportHandlerAsync(handler, options).Result;

/// <summary>
/// OBSOLETE: Import from a folder
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Import(string[] folders, bool force, IEnumerable<HandlerConfigPair> handlers, uSyncCallbacks? callbacks)
=> ImportAsync(folders, force, handlers, new SyncHandlerOptions
Expand All @@ -162,51 +185,93 @@ IEnumerable<uSyncAction> Import(string[] folders, bool force, IEnumerable<Handle
UserId = -1,
}, callbacks).Result;

/// <summary>
/// OBSOLETE: Import from a folder
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ImportHandler(string handlerAlias, uSyncImportOptions options)
=> ImportHandlerAsync(handlerAlias, options).Result;

/// <summary>
/// OBSOLETE: Partial Import from a folder
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ImportPartial(IList<OrderedNodeInfo> orderedNodes, uSyncPagedImportOptions options, out int total)
{
total = orderedNodes.Count;
return ImportPartialAsync(orderedNodes, options).Result;
}

/// <summary>
/// OBSOLETE: Partial import happens after.
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ImportPartialPostImport(IEnumerable<uSyncAction> actions, uSyncPagedImportOptions options)
=> ImportPartialPostImportAsync(actions, options).Result;

/// <summary>
/// OBSOLETE: Second pass import actions
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ImportPartialSecondPass(IEnumerable<uSyncAction> actions, uSyncPagedImportOptions options)
=> ImportPartialSecondPassAsync(actions, options).Result;

/// <summary>
/// OBSOLETE: Import post (cleans files)
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ImportPostCleanFiles(IEnumerable<uSyncAction> actions, uSyncPagedImportOptions options)
=> ImportPostCleanFilesAsync(actions, options).Result;

/// <summary>
/// OBSOLETE: Import a single item from an action
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
uSyncAction ImportSingleAction(uSyncAction action)
=> ImportSingleActionAsync(action).Result;

/// <summary>
/// OBSOLETE: Load the nodes in a order.
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IList<OrderedNodeInfo> LoadOrderedNodes(ISyncHandler handler, string[] handlerFolders)
=> LoadOrderedNodesAsync(handler, handlerFolders).Result;

/// <summary>
/// OBSOLETE: Perform any post import actions.
/// </summary>
[Obsolete("use ImportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> PerformPostImport(string[] folders, string handlerSet, IEnumerable<uSyncAction> actions)
=> PerformPostImportAsync(folders, handlerSet, actions).Result;

/// <summary>
/// OBSOLETE: Report changes from a folder
/// </summary>
[Obsolete("use ReportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Report(string folder, IEnumerable<HandlerConfigPair> handlers, uSyncCallbacks? callbacks);

/// <summary>
/// OBSOLETE: Report changes from a folder
/// </summary>
[Obsolete("use ReportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Report(string folder, IEnumerable<string> handlerAliases, uSyncCallbacks? callbacks);

/// <summary>
/// OBSOLETE: Report changes from a folder
/// </summary>
[Obsolete("use ReportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> Report(string folder, SyncHandlerOptions handlerOptions, uSyncCallbacks? callbacks = null);

/// <summary>
/// OBSOLETE: Report changes from a folder
/// </summary>
[Obsolete("use ReportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ReportHandler(string handler, uSyncImportOptions options)
=> ReportHandlerAsync(handler, options).Result;

/// <summary>
/// OBSOLETE: Partial Report changes from a folder
/// </summary>
[Obsolete("use ReportHandlerAsync will be removed in v16")]
IEnumerable<uSyncAction> ReportPartial(IList<OrderedNodeInfo> orderedNodes, uSyncPagedImportOptions options, out int total)
{
Expand Down
2 changes: 0 additions & 2 deletions uSync.BackOffice/SyncHandlers/Handlers/ContentHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ protected override bool DoActionsMatch(uSyncAction a, uSyncAction b)
/// <summary>
/// Handle the Umbraco Moved to recycle bin notification, (treated like a move)
/// </summary>
/// <param name="notification"></param>
public async Task HandleAsync(MovedToRecycleBinNotification<TObject> notification, CancellationToken cancellationToken)
{
if (!ShouldProcessEvent()) return;
Expand All @@ -211,7 +210,6 @@ public async Task HandleAsync(MovedToRecycleBinNotification<TObject> notificatio
/// <summary>
/// Check that roots isn't stopping an item from being recycled.
/// </summary>
/// <param name="notification"></param>
public async Task HandleAsync(MovingToRecycleBinNotification<TObject> notification, CancellationToken cancellationToken)
{
if (await ShouldBlockRootChangesAsync(notification.MoveInfoCollection.Select(x => x.Entity)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public ContentTemplateHandler(
throw new NullReferenceException("Can not load the contentTemplateSerializer");
}

/// <inheritdoc/>
protected override Task<IEnumerable<IEntity>> GetChildItemsAsync(Guid key)
{
if (key != Guid.Empty) return Task.FromResult(Enumerable.Empty<IEntity>());
Expand Down
2 changes: 2 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/ContentTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ protected override string GetEntityTreeName(IUmbracoEntity item, bool useGuid)
return item.Name?.ToSafeFileName(shortStringHelper) ?? item.Key.ToString();
}

/// <inheritdoc/>
protected override async Task<IEntity?> GetContainerAsync(Guid key)
=> await _contentTypeContainerService.GetAsync(key);

/// <inheritdoc/>
protected override async Task DeleteFolderAsync(Guid key)
=> await _contentTypeContainerService.DeleteAsync(key, Constants.Security.SuperUserKey);
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public override async Task<IEnumerable<uSyncAction>> ImportAsync(string file, Ha
protected override async Task<IEnumerable<IEntity>> GetFoldersAsync(Guid key)
=> await GetChildItemsAsync(key);

/// <inheritdoc/>
protected override async Task<IEnumerable<IEntity>> GetChildItemsAsync(Guid key)
{
if (key == Guid.Empty)
Expand Down
2 changes: 2 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/LanguageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ protected override IEnumerable<string> GetImportFiles(string folder)
}


/// <inheritdoc/>
protected override async Task<IEnumerable<IEntity>> GetChildItemsAsync(Guid key)
=> key == Guid.Empty
? await _languageService.GetAllAsync()
Expand Down Expand Up @@ -236,6 +237,7 @@ public override async Task HandleAsync(SavedNotification<ILanguage> notification
}
}

/// <inheritdoc/>
protected override Task<IEnumerable<uSyncAction>> DeleteMissingItemsAsync(ILanguage parent, IEnumerable<Guid> keysToKeep, bool reportOnly)
=> Task.FromResult(Enumerable.Empty<uSyncAction>());
}
2 changes: 2 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/MediaTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ protected override string GetEntityTreeName(IUmbracoEntity item, bool useGuid)
return item.Name?.ToSafeFileName(shortStringHelper) ?? item.Key.ToString();
}

/// <inheritdoc/>
protected override async Task DeleteFolderAsync(Guid key)
=> await _mediaTypeContainerService.DeleteAsync(key, Constants.Security.SuperUserKey);

/// <inheritdoc/>
protected override async Task<IEntity?> GetContainerAsync(Guid key)
=> await _mediaTypeContainerService.GetAsync(key);

Expand Down
2 changes: 2 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/MemberTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ public MemberTypeHandler(
}


/// <inheritdoc/>
protected override async Task DeleteFolderAsync(Guid key)
{
var container = await GetContainerAsync(key);
if (container is null) return;
memberTypeService.DeleteContainer(container.Id);
}

/// <inheritdoc/>
protected override Task<IEntity?> GetContainerAsync(Guid key)
=> Task.FromResult<IEntity?>(memberTypeService.GetContainer(key));

Expand Down
3 changes: 3 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/TemplateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public async Task<IEnumerable<uSyncAction>> ProcessPostImportAsync(IEnumerable<u
/// <inheritdoc/>
protected override string GetItemName(ITemplate item) => item.Name ?? item.Alias;

/// <inheritdoc/>
protected override async Task<IEnumerable<IEntity>> GetChildItemsAsync(Guid key)
{
if (key == Guid.Empty) return await _templateService.GetChildrenAsync(-1);
Expand All @@ -152,13 +153,15 @@ protected override async Task<IEnumerable<IEntity>> GetChildItemsAsync(Guid key)
}


/// <inheritdoc/>
protected override async Task<IEnumerable<IEntity>> GetFoldersAsync(Guid key)
=> await GetChildItemsAsync(key);

/// <inheritdoc/>
protected override string GetItemPath(ITemplate item, bool useGuid, bool isFlat)
=> useGuid ? item.Key.ToString() : item.Alias.ToSafeFileName(shortStringHelper);

/// <inheritdoc/>
protected override async Task<IEnumerable<IEntity>> GetFoldersAsync(IEntity? parent)
{
if (parent is null) return [];
Expand Down
2 changes: 2 additions & 0 deletions uSync.BackOffice/SyncHandlers/Handlers/WebhookHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public WebhookHandler(
protected override Task<IEnumerable<uSyncAction>> DeleteMissingItemsAsync(IWebhook parent, IEnumerable<Guid> keysToKeep, bool reportOnly)
=> Task.FromResult(Enumerable.Empty<uSyncAction>());

/// <inheritdoc/>
protected override async Task<IEnumerable<IWebhook>> GetChildItemsAsync(IWebhook? parent)
=> parent is not null ? [] : (await _webhookService.GetAllAsync(0, 1000)).Items;

/// <inheritdoc/>
protected override Task<IEnumerable<IWebhook>> GetFoldersAsync(IWebhook? parent)
=> Task.FromResult(Enumerable.Empty<IWebhook>());

Expand Down
Loading

0 comments on commit b98ba07

Please sign in to comment.