Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions uSync.BackOffice/SyncHandlers/Handlers/TemplateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using uSync.BackOffice.SyncHandlers.Models;
using uSync.Core;
using uSync.Core.Serialization;
using uSync.Core.Templates;

using static Umbraco.Cms.Core.Constants;

Expand All @@ -43,7 +42,7 @@ public class TemplateHandler : SyncHandlerLevelBase<ITemplate>, ISyncHandler, IS
INotificationAsyncHandler<MovingNotification<ITemplate>>
{
private readonly IFileSystem? _viewFileSystem;
private readonly ISyncTemplateService _templateService;
private readonly ITemplateService _templateService;

private readonly ITemplateContentParserService _templateContentParserService;

Expand All @@ -52,20 +51,20 @@ public class TemplateHandler : SyncHandlerLevelBase<ITemplate>, ISyncHandler, IS
public TemplateHandler(
ILogger<TemplateHandler> logger,
IEntityService entityService,
ITemplateService templateService,
FileSystems fileSystems,
ITemplateContentParserService templateContentParserService,
AppCaches appCaches,
IShortStringHelper shortStringHelper,
ISyncFileService syncFileService,
ISyncEventService mutexService,
ISyncConfigService uSyncConfig,
ISyncItemFactory syncItemFactory,
ISyncTemplateService syncTemplateService)
ISyncItemFactory syncItemFactory)
: base(logger, entityService, appCaches, shortStringHelper, syncFileService, mutexService, uSyncConfig, syncItemFactory)
{
_templateService = templateService;
_viewFileSystem = fileSystems.MvcViewsFileSystem;
_templateContentParserService = templateContentParserService;
_templateService = syncTemplateService;
}

/// <inheritdoc/>
Expand Down
11 changes: 5 additions & 6 deletions uSync.Core/Serialization/Serializers/ContentSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using uSync.Core.Extensions;
using uSync.Core.Mapping;
using uSync.Core.Models;
using uSync.Core.Templates;

namespace uSync.Core.Serialization.Serializers;

Expand All @@ -24,7 +23,7 @@ public class ContentSerializer : ContentSerializerBase<IContent>, ISyncSerialize
protected readonly IContentService contentService;
protected readonly IUserService userService;

protected readonly ISyncTemplateService _templateService;
protected readonly ITemplateService _templateService;
protected readonly ISyncDocumentUrlCleaner? _urlCleaner;

[Obsolete("Use the constructor with urlCleaner, will be removed in v19")]
Expand All @@ -37,8 +36,8 @@ public ContentSerializer(
IContentService contentService,
SyncValueMapperCollection syncMappers,
IUserService userService,
ISyncTemplateService syncTemplateService
) : this(entityService, languageService, relationService, shortStringHelper, logger, contentService, syncMappers, userService, syncTemplateService, null)
ITemplateService templateService
) : this(entityService, languageService, relationService, shortStringHelper, logger, contentService, syncMappers, userService, templateService, null)
{ }

public ContentSerializer(
Expand All @@ -50,15 +49,15 @@ public ContentSerializer(
IContentService contentService,
SyncValueMapperCollection syncMappers,
IUserService userService,
ISyncTemplateService syncTemplateService,
ITemplateService templateService,
ISyncDocumentUrlCleaner? urlCleaner)
: base(entityService, languageService, relationService, shortStringHelper, logger, UmbracoObjectTypes.Document, syncMappers)
{
this.contentService = contentService;

this.relationAlias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias;
this.userService = userService;
_templateService = syncTemplateService;
_templateService = templateService;
_urlCleaner = urlCleaner;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using uSync.Core.Extensions;
using uSync.Core.Mapping;
using uSync.Core.Models;
using uSync.Core.Templates;

namespace uSync.Core.Serialization.Serializers;

Expand All @@ -31,7 +30,7 @@ public ContentTemplateSerializer(
IContentTypeService contentTypeService,
SyncValueMapperCollection syncMappers,
IUserService userService,
ISyncTemplateService templateService,
ITemplateService templateService,
ISyncDocumentUrlCleaner urlCleaner)
: base(entityService, languageService, relationService, shortStringHelper, logger, contentService, syncMappers, userService, templateService, urlCleaner)
{
Expand Down
33 changes: 20 additions & 13 deletions uSync.Core/Serialization/Serializers/TemplateSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.Extensions.Configuration;
using Lucene.Net.Queries.Function.ValueSources;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand All @@ -8,20 +10,21 @@
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Extensions;

using uSync.Core.Models;
using uSync.Core.Templates;
using uSync.Core.Versions;

namespace uSync.Core.Serialization.Serializers;

[SyncSerializer("D0E0769D-CCAE-47B4-AD34-4182C587B08A", "Template Serializer", uSyncConstants.Serialization.Template)]
public class TemplateSerializer : SyncSerializerBase<ITemplate>, ISyncSerializer<ITemplate>
{
private readonly IShortStringHelper _shortStringHelper;
private readonly IFileSystem? _viewFileSystem;

private readonly ISyncTemplateService _templateService;
private readonly ITemplateService _templateService;
private readonly IUserIdKeyResolver _userIdKeyResolver;

private readonly uSyncCapabilityChecker _capabilityChecker;
Expand All @@ -31,18 +34,21 @@ public class TemplateSerializer : SyncSerializerBase<ITemplate>, ISyncSerializer
public TemplateSerializer(
IEntityService entityService,
ILogger<TemplateSerializer> logger,
IShortStringHelper shortStringHelper,
FileSystems fileSystems,
IConfiguration configuration,
uSyncCapabilityChecker capabilityChecker,
IUserIdKeyResolver userIdKeyResolver,
ISyncTemplateService syncTemplateService)
ITemplateService templateService,
IUserIdKeyResolver userIdKeyResolver)
: base(entityService, logger)
{
_shortStringHelper = shortStringHelper;

_viewFileSystem = fileSystems.MvcViewsFileSystem;
_configuration = configuration;
_capabilityChecker = capabilityChecker;
_templateService = templateService;
_userIdKeyResolver = userIdKeyResolver;
_templateService = syncTemplateService;
}

protected override async Task<SyncAttempt<ITemplate>> ProcessDeleteAsync(Guid key, string alias, SerializerFlags flags)
Expand Down Expand Up @@ -97,13 +103,7 @@ protected override async Task<SyncAttempt<ITemplate>> DeserializeCoreAsync(XElem
userKey, key);

if (attempt.Success is false)
{
logger.LogWarning("Failed to create template {alias} {name} - {error} - {status}",
alias, name, attempt.Exception?.Message ?? "Unknown error", attempt.Status);

return SyncAttempt<ITemplate>.Fail(name, ChangeType.Import,
$"Failed to create template {alias} {name} - {attempt.Exception?.Message ?? "Unknown error"} - {attempt.Status}");
}
return SyncAttempt<ITemplate>.Fail(name, ChangeType.Import, "Failed to create template");

item = attempt.Result;
details.AddNew(alias, alias, "Template");
Expand All @@ -115,6 +115,13 @@ protected override async Task<SyncAttempt<ITemplate>> DeserializeCoreAsync(XElem
return SyncAttempt<ITemplate>.Succeed(name, item, ChangeType.Import, "Created", true, details);
}

if (item is null)
{
// creating went wrong
logger.LogWarning("Failed to create template");
return SyncAttempt<ITemplate>.Fail(name, ChangeType.Import, "Failed to create template");
}

if (item.Key != key)
{
details.AddUpdate(uSyncConstants.Xml.Key, item.Key, key);
Expand Down
16 changes: 0 additions & 16 deletions uSync.Core/Templates/ISyncTemplateService.cs

This file was deleted.

106 changes: 0 additions & 106 deletions uSync.Core/Templates/SyncTemplateService.cs

This file was deleted.

4 changes: 0 additions & 4 deletions uSync.Core/uSyncCoreBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using uSync.Core.Mapping.Tracking;
using uSync.Core.Roots.Configs;
using uSync.Core.Serialization;
using uSync.Core.Templates;
using uSync.Core.Tracking;

namespace uSync.Core;
Expand Down Expand Up @@ -42,9 +41,6 @@ public static IUmbracoBuilder AdduSyncCore(this IUmbracoBuilder builder)
// cache for entity items, we use it to speed up lookups.
builder.Services.AddSingleton<SyncEntityCache>();

// templates have a wrapper service because we have to do work when in production mode
builder.Services.AddSingleton<ISyncTemplateService, SyncTemplateService>();

// register *all* ConfigurationSerializers except those marked [HideFromTypeFinder]
// has to happen before the DataTypeSerializer is loaded, because that is where
// they are used
Expand Down
Loading