From 45b8e1d2239ab6f2de91e3b73652e28b0af45ecb Mon Sep 17 00:00:00 2001 From: Meik Date: Wed, 1 Jul 2026 00:42:03 +0200 Subject: [PATCH] fix: fallback journal history when storage resolution fails --- F4SDM42WebApi/F4SD - M42WebApi.csproj | 6 ++++- F4SDM42WebApi/F4SDHelperService.cs | 39 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index 632e8ee..3023793 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.29 + 1.4.0.30 true @@ -34,6 +34,10 @@ M42Libraries\26.1\Matrix42.Contracts.ServiceManagement.dll false + + M42Libraries\26.1\Matrix42.BizLogic.Journal.dll + false + M42Libraries\26.1\Matrix42.Hosting.Contracts.dll false diff --git a/F4SDM42WebApi/F4SDHelperService.cs b/F4SDM42WebApi/F4SDHelperService.cs index f6f2040..c6fcc86 100644 --- a/F4SDM42WebApi/F4SDHelperService.cs +++ b/F4SDM42WebApi/F4SDHelperService.cs @@ -1,6 +1,7 @@ using C4IT.F4SDM; using C4IT.FASD.Base; using C4IT.Logging; +using Matrix42.BizLogic.Common.Journal; using Matrix42.Common; using Newtonsoft.Json; using System; @@ -1475,6 +1476,12 @@ namespace C4IT.F4SD } catch (TargetInvocationException ex) when (ex.InnerException != null) { + if (IsStorageWebApiExplorerResolutionFailure(ex.InnerException)) + { + LogEntry("JournalService.GetJournalList requires IStorageService in this Matrix42 build. Falling back to JournalManager.GetObjectEntries for sandbox compatibility.", LogLevels.Warning); + return LoadJournalEntriesFromJournalManager(activityEOID, objectLinkTemplate); + } + throw ex.InnerException; } } @@ -1482,6 +1489,38 @@ namespace C4IT.F4SD throw new MissingMethodException($"No compatible IJournalService.GetJournalList overload was found on '{serviceType.FullName}'. Available overloads: {string.Join("; ", methods.Select(FormatMethodSignature))}"); } + private static IReadOnlyList LoadJournalEntriesFromJournalManager(Guid activityEOID, string objectLinkTemplate) + { + var entries = JournalManager.GetObjectEntries( + activityEOID, + false, + null, + 0, + 50, + false, + objectLinkTemplate, + 120); + + return entries + .Select(item => new Matrix42.Contracts.Platform.Data.JournalEntryInfo + { + Id = item.Id, + Creator = item.CreatorName, + CreatedDate = item.CreatedDate, + Header = item.Header, + Text = item.Body ?? string.Empty, + VisibleInPortal = item.VisibleInPortal + }) + .ToList(); + } + + private static bool IsStorageWebApiExplorerResolutionFailure(Exception exception) + { + var details = exception.ToString(); + return details.Contains("Matrix42.StorageService.Contracts.IStorageService") + && details.Contains("System.Web.Http.Description.IApiExplorer"); + } + private static bool IsJournalReaderMethod(MethodInfo method) { var methodName = method.Name;