Skip to content

Commit 7379387

Browse files
committed
Added logging
1 parent 4c616dc commit 7379387

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ public async Task PostSave_Validate_Variants_Empty_Name()
412412
[Test]
413413
public async Task PostSave_Validates_Domains_Exist()
414414
{
415-
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
416415
ILocalizationService localizationService = GetRequiredService<ILocalizationService>();
417416
localizationService.Save(new LanguageBuilder()
418417
.WithCultureInfo("da-DK")
@@ -445,17 +444,21 @@ public async Task PostSave_Validates_Domains_Exist()
445444
body = body.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
446445
ContentItemDisplay display = JsonConvert.DeserializeObject<ContentItemDisplay>(body);
447446

447+
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
448+
ILocalizedTextService localizedTextService = GetRequiredService<ILocalizedTextService>();
449+
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithNoDomains", new []{"en-US"});
450+
448451
Assert.Multiple(() =>
449452
{
450453
Assert.IsNotNull(display);
451454
Assert.AreEqual(1, display.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
455+
Assert.AreEqual(expectedMessage, display.Notifications.FirstOrDefault(x => x.NotificationType == NotificationStyle.Warning)?.Message);
452456
});
453457
}
454458

455459
[Test]
456460
public async Task PostSave_Validates_All_Cultures_Has_Domains()
457461
{
458-
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
459462
var enString = "en-US";
460463
var dkString = "da-DK";
461464

@@ -504,11 +507,14 @@ public async Task PostSave_Validates_All_Cultures_Has_Domains()
504507
body = body.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
505508
ContentItemDisplay display = JsonConvert.DeserializeObject<ContentItemDisplay>(body);
506509

510+
ILocalizedTextService localizedTextService = GetRequiredService<ILocalizedTextService>();
511+
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithMissingDomain", new []{"en-US"});
507512

508513
Assert.Multiple(() =>
509514
{
510515
Assert.NotNull(display);
511516
Assert.AreEqual(1, display.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
517+
Assert.AreEqual(expectedMessage, display.Notifications.FirstOrDefault(x => x.NotificationType == NotificationStyle.Warning)?.Message);
512518
});
513519
}
514520

src/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ private ContentController CreateContentController(IDomainService domainService)
261261
Mock.Of<ISqlContext>(),
262262
Mock.Of<IJsonSerializer>(),
263263
Mock.Of<IScopeProvider>(),
264-
Mock.Of<IAuthorizationService>()
264+
Mock.Of<IAuthorizationService>(),
265+
Mock.Of<IUserDataService>()
265266
);
266267

267268
return controller;

src/Umbraco.Web.BackOffice/Controllers/ContentController.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class ContentController : ContentControllerBase
6565
private readonly Lazy<IDictionary<string, ILanguage>> _allLangs;
6666
private readonly ILogger<ContentController> _logger;
6767
private readonly IScopeProvider _scopeProvider;
68+
private readonly IUserDataService _userDataService;
6869

6970
public object Domains { get; private set; }
7071

@@ -90,7 +91,8 @@ public ContentController(
9091
ISqlContext sqlContext,
9192
IJsonSerializer serializer,
9293
IScopeProvider scopeProvider,
93-
IAuthorizationService authorizationService)
94+
IAuthorizationService authorizationService,
95+
IUserDataService userDataService)
9496
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, serializer)
9597
{
9698
_propertyEditors = propertyEditors;
@@ -112,6 +114,7 @@ public ContentController(
112114
_logger = loggerFactory.CreateLogger<ContentController>();
113115
_scopeProvider = scopeProvider;
114116
_allLangs = new Lazy<IDictionary<string, ILanguage>>(() => _localizationService.GetAllLanguages().ToDictionary(x => x.IsoCode, x => x, StringComparer.InvariantCultureIgnoreCase));
117+
_userDataService = userDataService;
115118
}
116119

117120
/// <summary>
@@ -1470,14 +1473,17 @@ internal void AddDomainWarnings(IContent persistedContent, string[] culturesPubl
14701473
{
14711474
assignedDomains.UnionWith(_domainService.GetAssignedDomains(ancestorID, true));
14721475
}
1473-
1476+
foreach (var data in _userDataService.GetUserData())
1477+
{
1478+
_logger.LogWarning($"{data.Name} : {data.Data}");
1479+
}
14741480
// No domains at all, add a warning, to add domains.
14751481
if (assignedDomains.Count == 0)
14761482
{
14771483
globalNotifications.AddWarningNotification(
14781484
_localizedTextService.Localize("auditTrails", "publish"),
14791485
_localizedTextService.Localize("speechBubbles", "publishWithNoDomains"));
1480-
1486+
_logger.LogWarning("NOT REGISTRED DOMAIN FOR: {Cultures}");
14811487
_logger.LogWarning("The root node {RootNodeName} was published with multiple cultures, but no domains are configured, this will cause routing and caching issues, please register domains for: {Cultures}",
14821488
persistedContent.Name, string.Join(", ", publishedCultures));
14831489
return;

0 commit comments

Comments
 (0)