From e4194959ea0521e4bc9cc5dd4b048cd65812f292 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 26 Aug 2024 10:24:19 -0700 Subject: [PATCH 1/4] Issue 50179: Exceptions logged by Radeox are difficult to track back to the offending wiki --- .../announcements/model/AnnouncementManager.java | 2 +- .../announcements/model/AnnouncementModel.java | 5 +++-- .../announcements/query/AnnouncementTable.java | 3 ++- api/src/org/labkey/api/wiki/WikiRenderer.java | 6 +++++- .../labkey/api/wiki/WikiRendererDisplayColumn.java | 10 ++++++++-- .../org/labkey/api/wiki/WikiRenderingService.java | 12 ++++++++++-- core/build.gradle | 2 +- core/src/org/labkey/core/CoreController.java | 2 +- core/src/org/labkey/core/admin/AdminController.java | 4 ++-- core/src/org/labkey/core/login/LoginController.java | 2 +- core/src/org/labkey/core/wiki/HtmlRenderer.java | 2 +- core/src/org/labkey/core/wiki/MarkdownRenderer.java | 8 ++++---- .../src/org/labkey/core/wiki/PlainTextRenderer.java | 2 +- core/src/org/labkey/core/wiki/RadeoxRenderer.java | 12 +++++++----- .../labkey/core/wiki/WikiRenderingServiceImpl.java | 13 +++++++++---- .../src/org/labkey/issue/actions/ChangeSummary.java | 2 +- study/src/org/labkey/study/model/StudyImpl.java | 4 ++-- .../org/labkey/study/query/StudyObjectiveTable.java | 2 +- .../labkey/study/query/StudyPropertiesTable.java | 2 +- .../query/studydesign/StudyTreatmentTable.java | 4 +--- wiki/radeox/Changes.txt | 4 ++++ wiki/radeox/Radeox.version | 2 +- wiki/radeox/build.xml | 2 +- .../radeox/engine/context/BaseRenderContext.java | 10 ++++++++++ wiki/radeox/src/org/radeox/filter/FilterPipe.java | 2 +- .../src/org/radeox/filter/LinkTestFilter.java | 2 +- wiki/radeox/src/org/radeox/filter/ListFilter.java | 2 +- wiki/radeox/src/org/radeox/filter/MacroFilter.java | 2 +- .../src/org/radeox/filter/regex/RegexFilter.java | 2 +- .../org/radeox/filter/regex/RegexReplaceFilter.java | 6 +++--- .../org/radeox/filter/regex/RegexTokenFilter.java | 4 ++-- .../src/org/radeox/macro/BaseLocaleMacro.java | 2 +- wiki/src/org/labkey/wiki/RenderedWikiResource.java | 2 +- wiki/src/org/labkey/wiki/WikiManager.java | 2 +- 34 files changed, 91 insertions(+), 52 deletions(-) diff --git a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java index b843d213f08..71764726845 100644 --- a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java +++ b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java @@ -1370,7 +1370,7 @@ public EmailNotificationBean(Container c, if (settings.isSecureWithEmailOn() || settings.isSecureOff()) { WikiRenderingService renderingService = WikiRenderingService.get(); - this.body = renderingService.getFormattedHtml(currentRendererType, a.getBody()); + this.body = renderingService.getFormattedHtml(currentRendererType, a.getBody(), "Announcement " + a.getRowId() + " in " + a.getContainerPath()); } else { diff --git a/announcements/src/org/labkey/announcements/model/AnnouncementModel.java b/announcements/src/org/labkey/announcements/model/AnnouncementModel.java index ca3c565cd0c..a0e35d92f68 100644 --- a/announcements/src/org/labkey/announcements/model/AnnouncementModel.java +++ b/announcements/src/org/labkey/announcements/model/AnnouncementModel.java @@ -245,10 +245,11 @@ private HtmlString getFormattedHtml(@Nullable String attachPrefix) if (_rendererType == null) _rendererType = DEFAULT_MESSAGE_RENDERER_TYPE; + String sourceDescription = "Announcement " + getRowId() + " in " + getContainerPath(); if (null == attachPrefix) - return renderingService.getFormattedHtml(_rendererType, _body); + return renderingService.getFormattedHtml(_rendererType, _body, sourceDescription); else - return renderingService.getFormattedHtml(_rendererType, _body, attachPrefix, getAttachments()); + return renderingService.getFormattedHtml(_rendererType, _body, sourceDescription, attachPrefix, getAttachments()); } public String getStatus() diff --git a/announcements/src/org/labkey/announcements/query/AnnouncementTable.java b/announcements/src/org/labkey/announcements/query/AnnouncementTable.java index b384fe452b5..d41446d4091 100644 --- a/announcements/src/org/labkey/announcements/query/AnnouncementTable.java +++ b/announcements/src/org/labkey/announcements/query/AnnouncementTable.java @@ -103,7 +103,8 @@ public TableInfo getLookupTableInfo() bodyColumn.setShownInDetailsView(false); var formattedBodyColumn = wrapColumn("FormattedBody", getRealTable().getColumn("Body")); - formattedBodyColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, renderTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS)); + formattedBodyColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, renderTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS, + ctx -> "Announcement " + getColumn("RowId").getValue(ctx))); addColumn(formattedBodyColumn); formattedBodyColumn.setReadOnly(true); formattedBodyColumn.setUserEditable(false); diff --git a/api/src/org/labkey/api/wiki/WikiRenderer.java b/api/src/org/labkey/api/wiki/WikiRenderer.java index 60bbe8dc11c..74818e890b3 100644 --- a/api/src/org/labkey/api/wiki/WikiRenderer.java +++ b/api/src/org/labkey/api/wiki/WikiRenderer.java @@ -23,5 +23,9 @@ */ public interface WikiRenderer { - FormattedHtml format(String text); + /** + * @param text the original text that should be rendered into HTML + * @param sourceDescription info on where the text came from for debugging purposes. For example: Announcement 6654 in /MyContainer + */ + FormattedHtml format(String text, String sourceDescription); } diff --git a/api/src/org/labkey/api/wiki/WikiRendererDisplayColumn.java b/api/src/org/labkey/api/wiki/WikiRendererDisplayColumn.java index 519a72d7410..130e49eada6 100644 --- a/api/src/org/labkey/api/wiki/WikiRendererDisplayColumn.java +++ b/api/src/org/labkey/api/wiki/WikiRendererDisplayColumn.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Set; +import java.util.function.Function; /** * Renders the contents of a database column in one of the supported {@link WikiRendererType} formats, as specified @@ -38,13 +39,18 @@ public class WikiRendererDisplayColumn extends DataColumn { @NotNull private final String _renderTypeColumnName; + private final Function _sourceDescriptionGenerator; private WikiRendererType _defaultRenderer = WikiRendererType.TEXT_WITH_LINKS; private static final Logger _log = LogHelper.getLogger(WikiRendererDisplayColumn.class, "Renders wiki content for grid and detail views"); - public WikiRendererDisplayColumn(ColumnInfo contentColumn, @NotNull String renderTypeColumnName, WikiRendererType defaultRenderer) + public WikiRendererDisplayColumn(ColumnInfo contentColumn, + @NotNull String renderTypeColumnName, + WikiRendererType defaultRenderer, + @NotNull Function sourceDescriptionGenerator) { super(contentColumn); _renderTypeColumnName = renderTypeColumnName; + _sourceDescriptionGenerator = sourceDescriptionGenerator; if (null != defaultRenderer) _defaultRenderer = defaultRenderer; } @@ -82,7 +88,7 @@ public HtmlString getFormattedHtml(RenderContext ctx) } } - rendered = wikiService.getFormattedHtml(rendererType, content); + rendered = wikiService.getFormattedHtml(rendererType, content, _sourceDescriptionGenerator.apply(ctx)); Map newRow = new CaseInsensitiveHashMap<>(ctx.getRow()); newRow.put(renderedFK.encode(), rendered); diff --git a/api/src/org/labkey/api/wiki/WikiRenderingService.java b/api/src/org/labkey/api/wiki/WikiRenderingService.java index bd90c88a4da..c422dae96fd 100644 --- a/api/src/org/labkey/api/wiki/WikiRenderingService.java +++ b/api/src/org/labkey/api/wiki/WikiRenderingService.java @@ -1,6 +1,7 @@ package org.labkey.api.wiki; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.labkey.api.attachments.Attachment; import org.labkey.api.services.ServiceRegistry; import org.labkey.api.util.HtmlString; @@ -31,8 +32,15 @@ static void setInstance(WikiRenderingService impl) */ void registerMacroProvider(String name, MacroProvider provider); - HtmlString getFormattedHtml(WikiRendererType rendererType, String source); - HtmlString getFormattedHtml(WikiRendererType rendererType, String source, String attachPrefix, Collection attachments); + /** + * @param sourceDescription info on where the text came from for debugging purposes. For example: Announcement 6654 in /MyContainer + */ + HtmlString getFormattedHtml(WikiRendererType rendererType, String source, @Nullable String sourceDescription); + /** + * @param sourceDescription info on where the text came from for debugging purposes. For example: Announcement 6654 in /MyContainer + */ + HtmlString getFormattedHtml(WikiRendererType rendererType, String source, @Nullable String sourceDescription, + String attachPrefix, Collection attachments); WikiRenderer getRenderer(WikiRendererType rendererType, String hrefPrefix, String attachPrefix, Map nameTitleMap, diff --git a/core/build.gradle b/core/build.gradle index ea43a91ed67..1b7d831b192 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -34,7 +34,7 @@ dependencies { BuildUtils.addExternalDependency( project, new ExternalDependency( - 'radeox:radeox:1.0.5', + 'radeox:radeox:1.0.6', "Radeox", "Radeox", "http://www.radeox.org/", diff --git a/core/src/org/labkey/core/CoreController.java b/core/src/org/labkey/core/CoreController.java index 802bc3dafa2..15a2219917b 100644 --- a/core/src/org/labkey/core/CoreController.java +++ b/core/src/org/labkey/core/CoreController.java @@ -2750,7 +2750,7 @@ public ApiResponse execute(TransformWikiForm form, BindException errors) if (StringUtils.equals(WikiRendererType.HTML.name(), form.getToFormat())) { WikiRendererType fromType = WikiRendererType.valueOf(form.getFromFormat()); - newBody = WikiRenderingService.get().getFormattedHtml(fromType, newBody).toString(); + newBody = WikiRenderingService.get().getFormattedHtml(fromType, newBody, null).toString(); } response.put("toFormat", form.getToFormat()); diff --git a/core/src/org/labkey/core/admin/AdminController.java b/core/src/org/labkey/core/admin/AdminController.java index 3c6a1536fc6..b7b46e15f34 100644 --- a/core/src/org/labkey/core/admin/AdminController.java +++ b/core/src/org/labkey/core/admin/AdminController.java @@ -883,7 +883,7 @@ else if (startupInProgress) else if (maintenanceMode) { WikiRenderingService wikiService = WikiRenderingService.get(); - content = wikiService.getFormattedHtml(WikiRendererType.RADEOX, ModuleLoader.getInstance().getAdminOnlyMessage()); + content = wikiService.getFormattedHtml(WikiRendererType.RADEOX, ModuleLoader.getInstance().getAdminOnlyMessage(), "Admin only message"); } if (content == null) @@ -1121,7 +1121,7 @@ private static class CreditsView extends WebPartView if (StringUtils.isNotEmpty(wikiSource)) { WikiRenderingService wikiService = WikiRenderingService.get(); - HtmlString html = wikiService.getFormattedHtml(WikiRendererType.RADEOX, wikiSource); + HtmlString html = wikiService.getFormattedHtml(WikiRendererType.RADEOX, wikiSource, "Credits page"); _html = HtmlStringBuilder.of(HtmlString.unsafe("\n")).append(html).getHtmlString(); } } diff --git a/core/src/org/labkey/core/login/LoginController.java b/core/src/org/labkey/core/login/LoginController.java index 9aac1701c39..026f80b8766 100644 --- a/core/src/org/labkey/core/login/LoginController.java +++ b/core/src/org/labkey/core/login/LoginController.java @@ -1073,7 +1073,7 @@ else if (!ModuleLoader.getInstance().isStartupComplete()) else if (isAdminOnlyMode()) { WikiRenderingService wikiService = WikiRenderingService.get(); - HtmlString content = wikiService.getFormattedHtml(WikiRendererType.RADEOX, ModuleLoader.getInstance().getAdminOnlyMessage()); + HtmlString content = wikiService.getFormattedHtml(WikiRendererType.RADEOX, ModuleLoader.getInstance().getAdminOnlyMessage(), "Admin only message"); HtmlView adminMessageView = new HtmlView("The site is currently undergoing maintenance", content); vBox.addView(adminMessageView); } diff --git a/core/src/org/labkey/core/wiki/HtmlRenderer.java b/core/src/org/labkey/core/wiki/HtmlRenderer.java index e2935ed6b5a..d4f68df3a70 100644 --- a/core/src/org/labkey/core/wiki/HtmlRenderer.java +++ b/core/src/org/labkey/core/wiki/HtmlRenderer.java @@ -80,7 +80,7 @@ public HtmlRenderer(String hrefPrefix, String attachPrefix, Map } @Override - public FormattedHtml format(String text) + public FormattedHtml format(String text, String sourceDescription) { LinkedList errors = new LinkedList<>(); if (text == null) diff --git a/core/src/org/labkey/core/wiki/MarkdownRenderer.java b/core/src/org/labkey/core/wiki/MarkdownRenderer.java index 55f9c360295..683232b2751 100644 --- a/core/src/org/labkey/core/wiki/MarkdownRenderer.java +++ b/core/src/org/labkey/core/wiki/MarkdownRenderer.java @@ -33,7 +33,7 @@ public MarkdownRenderer(String hrefPrefix, String attachPrefix, MapAn exception occurred while converting markdown to HTML
The error message was: "); errorMsg.append(e.getMessage()); - return super.format(errorMsg.toString()); + return super.format(errorMsg.toString(), sourceDescription); } } else { // if no markdownService available then show an error message in the view of the html String errorMsg = "
No markdown service was available to convert the markdown to HTML

"; - return super.format(errorMsg); + return super.format(errorMsg, sourceDescription); } } } diff --git a/core/src/org/labkey/core/wiki/PlainTextRenderer.java b/core/src/org/labkey/core/wiki/PlainTextRenderer.java index 71eeae1ea06..1f6310abab4 100644 --- a/core/src/org/labkey/core/wiki/PlainTextRenderer.java +++ b/core/src/org/labkey/core/wiki/PlainTextRenderer.java @@ -39,7 +39,7 @@ public class PlainTextRenderer implements WikiRenderer * @param text Wiki source */ @Override - public FormattedHtml format(String text) + public FormattedHtml format(String text, String sourceDescription) { if (text == null) return new FormattedHtml(HtmlString.EMPTY_STRING); diff --git a/core/src/org/labkey/core/wiki/RadeoxRenderer.java b/core/src/org/labkey/core/wiki/RadeoxRenderer.java index a1d0059d062..df76a48f78b 100644 --- a/core/src/org/labkey/core/wiki/RadeoxRenderer.java +++ b/core/src/org/labkey/core/wiki/RadeoxRenderer.java @@ -69,6 +69,7 @@ import java.text.MessageFormat; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -115,13 +116,14 @@ public RadeoxRenderer(String hrefPrefix, String attachPrefix, } @Override - public FormattedHtml format(String text) + public FormattedHtml format(String text, String sourceDescription) { if (text == null) text = ""; - RenderContext context = new BaseRenderContext(); + RenderContext context = new BaseRenderContext(sourceDescription); context.setRenderEngine(this); + context.setParameters(new HashMap<>()); Set dependencies = new HashSet<>(); context.set(WIKI_DEPENDENCIES_KEY, dependencies); Set anchors = new HashSet<>(); @@ -948,14 +950,14 @@ public void testRendering() // Service should wrap rendered HTML in a
but renderer shouldn't. private void test(String wiki, String html) { - assertEquals(html, HtmlString.toString(_r.format(wiki).getHtml())); - assertEquals(HtmlStringBuilder.of(WikiRenderingService.WIKI_PREFIX).unsafeAppend(html).append(WikiRenderingService.WIKI_SUFFIX).getHtmlString(), _wrs.getFormattedHtml(WikiRendererType.RADEOX, wiki)); + assertEquals(html, HtmlString.toString(_r.format(wiki, null).getHtml())); + assertEquals(HtmlStringBuilder.of(WikiRenderingService.WIKI_PREFIX).unsafeAppend(html).append(WikiRenderingService.WIKI_SUFFIX).getHtmlString(), _wrs.getFormattedHtml(WikiRendererType.RADEOX, wiki, null)); } @Test public void testWikiDependencies() { - FormattedHtml html = _r.format("[this] [that] [some text|tother] [some other text|this] nolink anothernolink"); + FormattedHtml html = _r.format("[this] [that] [some text|tother] [some other text|this] nolink anothernolink", null); Set dependencies = html.getWikiDependencies(); assertNotNull(dependencies); assertEquals(3, dependencies.size()); diff --git a/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java b/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java index 71d6ac469f6..7c91b2d7036 100644 --- a/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java +++ b/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java @@ -1,5 +1,6 @@ package org.labkey.core.wiki; +import org.jetbrains.annotations.Nullable; import org.labkey.api.attachments.Attachment; import org.labkey.api.util.HtmlString; import org.labkey.api.util.HtmlStringBuilder; @@ -22,17 +23,21 @@ public void registerMacroProvider(String name, MacroProvider provider) } @Override - public HtmlString getFormattedHtml(WikiRendererType rendererType, String source, String attachPrefix, Collection attachments) + public HtmlString getFormattedHtml(WikiRendererType rendererType, + String source, + String attachPrefix, + @Nullable String sourceDescription, + Collection attachments) { return HtmlStringBuilder.of(WIKI_PREFIX) - .append(getRenderer(rendererType, null, attachPrefix, null, attachments).format(source).getHtml()) + .append(getRenderer(rendererType, null, attachPrefix, null, attachments).format(source, sourceDescription).getHtml()) .append(WIKI_SUFFIX).getHtmlString(); } @Override - public HtmlString getFormattedHtml(WikiRendererType rendererType, String source) + public HtmlString getFormattedHtml(WikiRendererType rendererType, String source, @Nullable String sourceDescription) { - return getFormattedHtml(rendererType, source, null, null); + return getFormattedHtml(rendererType, source, sourceDescription, null, null); } @Override diff --git a/issues/src/org/labkey/issue/actions/ChangeSummary.java b/issues/src/org/labkey/issue/actions/ChangeSummary.java index cdbba133429..d8c662da8e4 100644 --- a/issues/src/org/labkey/issue/actions/ChangeSummary.java +++ b/issues/src/org/labkey/issue/actions/ChangeSummary.java @@ -243,7 +243,7 @@ static public ChangeSummary createChangeSummary(ViewContext context, IssueListDe formattedComment.append(sbHTMLChanges); //render issues as plain text with links WikiRenderingService renderingService = WikiRenderingService.get(); - HtmlString html = renderingService.getFormattedHtml(WikiRendererType.TEXT_WITH_LINKS, comment); + HtmlString html = renderingService.getFormattedHtml(WikiRendererType.TEXT_WITH_LINKS, comment, "Issue change summary for issue " + issue.getIssueId() + " in " + issue.getContainerPath()); formattedComment.append(html); formattedComment.append("
"); diff --git a/study/src/org/labkey/study/model/StudyImpl.java b/study/src/org/labkey/study/model/StudyImpl.java index 987e6874754..3df101d3e43 100644 --- a/study/src/org/labkey/study/model/StudyImpl.java +++ b/study/src/org/labkey/study/model/StudyImpl.java @@ -684,7 +684,7 @@ public HtmlString getDescriptionHtml() { String description = getDescription(); - if (description == null || description.length() == 0) + if (description == null || description.isEmpty()) { long count = StudyManager.getInstance().getParticipantCount(this); String subjectNoun = (count == 1 ? this.getSubjectNounSingular() : this.getSubjectNounPlural()); @@ -701,7 +701,7 @@ public HtmlString getDescriptionHtml() else { WikiRenderingService wrs = WikiRenderingService.get(); - return wrs.getFormattedHtml(getDescriptionWikiRendererType(), description); + return wrs.getFormattedHtml(getDescriptionWikiRendererType(), description, "Study description in " + getContainer().getPath()); } } diff --git a/study/src/org/labkey/study/query/StudyObjectiveTable.java b/study/src/org/labkey/study/query/StudyObjectiveTable.java index 86904be68ed..36fa69552e3 100644 --- a/study/src/org/labkey/study/query/StudyObjectiveTable.java +++ b/study/src/org/labkey/study/query/StudyObjectiveTable.java @@ -63,7 +63,7 @@ public TableInfo getLookupTableInfo() } descriptionRendererTypeColumn.setHidden(true); - descriptionColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, descriptionRendererTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS)); + descriptionColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, descriptionRendererTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS, ctx -> "StudyObjective")); // setup lookups for the standard fields addWrapColumn(_rootTable.getColumn(FieldKey.fromParts("Container"))); diff --git a/study/src/org/labkey/study/query/StudyPropertiesTable.java b/study/src/org/labkey/study/query/StudyPropertiesTable.java index 31e41f6b0f2..787c3afc726 100644 --- a/study/src/org/labkey/study/query/StudyPropertiesTable.java +++ b/study/src/org/labkey/study/query/StudyPropertiesTable.java @@ -103,7 +103,7 @@ public TableInfo getLookupTableInfo() }); } - descriptionColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, descriptionRendererTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS)); + descriptionColumn.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, descriptionRendererTypeColumn.getName(), WikiRendererType.TEXT_WITH_LINKS, ctx -> "StudyProperties")); String bTRUE = getSchema().getSqlDialect().getBooleanTRUE(); String bFALSE = getSchema().getSqlDialect().getBooleanFALSE(); diff --git a/study/src/org/labkey/study/query/studydesign/StudyTreatmentTable.java b/study/src/org/labkey/study/query/studydesign/StudyTreatmentTable.java index fec54a17e38..032dfe5f392 100644 --- a/study/src/org/labkey/study/query/studydesign/StudyTreatmentTable.java +++ b/study/src/org/labkey/study/query/studydesign/StudyTreatmentTable.java @@ -16,7 +16,6 @@ package org.labkey.study.query.studydesign; import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.MutableColumnInfo; import org.labkey.api.data.TableInfo; @@ -24,7 +23,6 @@ import org.labkey.api.exp.property.Domain; import org.labkey.api.query.FieldKey; import org.labkey.api.query.LookupForeignKey; -import org.labkey.api.query.UserSchema; import org.labkey.api.wiki.WikiRendererDisplayColumn; import org.labkey.api.wiki.WikiRendererType; import org.labkey.api.wiki.WikiService; @@ -73,7 +71,7 @@ protected void initColumn(MutableColumnInfo col) { if ("Description".equalsIgnoreCase(col.getName())) { - col.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, "DescriptionRendererType", WikiRendererType.TEXT_WITH_LINKS)); + col.setDisplayColumnFactory(colInfo -> new WikiRendererDisplayColumn(colInfo, "DescriptionRendererType", WikiRendererType.TEXT_WITH_LINKS, ctx -> "StudyTreatment")); } else if ("DescriptionRendererType".equalsIgnoreCase(col.getName())) { diff --git a/wiki/radeox/Changes.txt b/wiki/radeox/Changes.txt index aa8754fae21..5b073798d3e 100644 --- a/wiki/radeox/Changes.txt +++ b/wiki/radeox/Changes.txt @@ -1,3 +1,7 @@ +1.0.6 2024-08-26 + +- Improve error logging + 1.0.5 2022-08-30 - Expunge example and test files diff --git a/wiki/radeox/Radeox.version b/wiki/radeox/Radeox.version index f1cd2a97a41..22043019824 100644 --- a/wiki/radeox/Radeox.version +++ b/wiki/radeox/Radeox.version @@ -1 +1 @@ -1.0.5 +1.0.6 diff --git a/wiki/radeox/build.xml b/wiki/radeox/build.xml index 84ce3429199..9d95d09e223 100644 --- a/wiki/radeox/build.xml +++ b/wiki/radeox/build.xml @@ -25,7 +25,7 @@ - + diff --git a/wiki/radeox/src/org/radeox/engine/context/BaseRenderContext.java b/wiki/radeox/src/org/radeox/engine/context/BaseRenderContext.java index cef34308c3c..9632b6f3709 100644 --- a/wiki/radeox/src/org/radeox/engine/context/BaseRenderContext.java +++ b/wiki/radeox/src/org/radeox/engine/context/BaseRenderContext.java @@ -46,9 +46,14 @@ public class BaseRenderContext implements RenderContext { private RenderEngine engine; private Map params; private Map values; + private final String sourceDescription; public BaseRenderContext() { + this(null); + } + public BaseRenderContext(String sourceDescription) { values = new HashMap(); + this.sourceDescription = sourceDescription; } public Object get(String key) { @@ -87,4 +92,9 @@ public void commitCache() { public boolean isCacheable() { return cacheable; } + + public String toString() + { + return super.toString() + sourceDescription == null ? "" : (" " + sourceDescription); + } } diff --git a/wiki/radeox/src/org/radeox/filter/FilterPipe.java b/wiki/radeox/src/org/radeox/filter/FilterPipe.java index 5c1b8af82ef..5e4f8d5d4c0 100644 --- a/wiki/radeox/src/org/radeox/filter/FilterPipe.java +++ b/wiki/radeox/src/org/radeox/filter/FilterPipe.java @@ -177,7 +177,7 @@ public String filter(String input, FilterContext context) { } renderContext.commitCache(); } catch (Exception e) { - log.warn("Filtering exception: " + f, e); + log.warn("Filtering exception: " + f + " in " + context.getRenderContext(), e); } } return output; diff --git a/wiki/radeox/src/org/radeox/filter/LinkTestFilter.java b/wiki/radeox/src/org/radeox/filter/LinkTestFilter.java index 17ddeb735c8..1d3d0c5cc5c 100644 --- a/wiki/radeox/src/org/radeox/filter/LinkTestFilter.java +++ b/wiki/radeox/src/org/radeox/filter/LinkTestFilter.java @@ -135,7 +135,7 @@ public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext c interWiki.expand(writer, extSpace, name, view); } } catch (IOException e) { - log.debug("InterWiki " + extSpace + " not found."); + log.debug("InterWiki " + extSpace + " not found in " + context.getRenderContext()); } } else { buffer.append("["); diff --git a/wiki/radeox/src/org/radeox/filter/ListFilter.java b/wiki/radeox/src/org/radeox/filter/ListFilter.java index f9d47b50993..94d11f61da1 100644 --- a/wiki/radeox/src/org/radeox/filter/ListFilter.java +++ b/wiki/radeox/src/org/radeox/filter/ListFilter.java @@ -101,7 +101,7 @@ public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext c BufferedReader reader = new BufferedReader(new StringReader(result.group(0))); addList(buffer, reader); } catch (Exception e) { - log.warn("ListFilter: unable get list content", e); + log.warn("ListFilter: unable get list content in " + context.getRenderContext(), e); } } diff --git a/wiki/radeox/src/org/radeox/filter/MacroFilter.java b/wiki/radeox/src/org/radeox/filter/MacroFilter.java index 826a9ac83ee..375a5de31c6 100644 --- a/wiki/radeox/src/org/radeox/filter/MacroFilter.java +++ b/wiki/radeox/src/org/radeox/filter/MacroFilter.java @@ -128,7 +128,7 @@ public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext c } catch (IllegalArgumentException e) { buffer.append("
" + command + ": " + e.getMessage() + "
"); } catch (Throwable e) { - log.warn("MacroFilter: unable to format macro: " + result.group(1), e); + log.warn("MacroFilter: unable to format macro: " + result.group(1) + " in " + context.getRenderContext(), e); buffer.append("
" + command + ": " + e.getMessage() + "
"); return; } diff --git a/wiki/radeox/src/org/radeox/filter/regex/RegexFilter.java b/wiki/radeox/src/org/radeox/filter/regex/RegexFilter.java index 46b64a8e434..b49380af93d 100644 --- a/wiki/radeox/src/org/radeox/filter/regex/RegexFilter.java +++ b/wiki/radeox/src/org/radeox/filter/regex/RegexFilter.java @@ -90,7 +90,7 @@ public void addRegex(String regex, String substitute, boolean multiline) { // Pattern.DOTALL this.substitute.add(substitute); } catch (Exception e) { - log.warn("bad pattern: " + regex + " -> " + substitute+" "+e); + log.warn("bad pattern: " + regex + " -> " + substitute, e); } } diff --git a/wiki/radeox/src/org/radeox/filter/regex/RegexReplaceFilter.java b/wiki/radeox/src/org/radeox/filter/regex/RegexReplaceFilter.java index 41f7e0e4101..6b155ce0a55 100644 --- a/wiki/radeox/src/org/radeox/filter/regex/RegexReplaceFilter.java +++ b/wiki/radeox/src/org/radeox/filter/regex/RegexReplaceFilter.java @@ -59,7 +59,7 @@ public RegexReplaceFilter(String regex, String substitute, boolean multiline) { public String filter(String input, FilterContext context) { String result = input; - int size = pattern.size(); + int size = Math.min(pattern.size(), substitute.size()); Pattern p; String s; for (int i = 0; i < size; i++) { @@ -72,10 +72,10 @@ public String filter(String input, FilterContext context) { // Util.substitute(matcher, p, new Perl5Substitution(s, interps), result, limit); } catch (Exception e) { //log.warn("Exception: " + this + ": " + e); - log.warn("Exception for: " + this+" "+e); + log.warn("Exception for: " + this + " in " + context.getRenderContext(), e); } catch (Error err) { //log.warn("Error: " + this + ": " + err); - log.warn("Error for: " + this + " " + err); + log.warn("Error for: " + this + " in " + context.getRenderContext(), err); } } return result; diff --git a/wiki/radeox/src/org/radeox/filter/regex/RegexTokenFilter.java b/wiki/radeox/src/org/radeox/filter/regex/RegexTokenFilter.java index 5bda7379f87..08df521703e 100644 --- a/wiki/radeox/src/org/radeox/filter/regex/RegexTokenFilter.java +++ b/wiki/radeox/src/org/radeox/filter/regex/RegexTokenFilter.java @@ -94,9 +94,9 @@ public void handleMatch(StringBuffer buffer, MatchResult result) { // result = Util.substitute(matcher, p, new ActionSubstitution(s, this, context), result, limit); } catch (Exception e) { - log.warn("Exception: " + this, e); + log.warn("Exception: " + this + " in " + context.getRenderContext(), e); } catch (Error err) { - log.warn("Error: " + this + ": " + err); + log.warn("Error: " + this + " in " + context.getRenderContext(), err); } input = result; } diff --git a/wiki/radeox/src/org/radeox/macro/BaseLocaleMacro.java b/wiki/radeox/src/org/radeox/macro/BaseLocaleMacro.java index 1a6f6ba62e3..06a99618ba4 100644 --- a/wiki/radeox/src/org/radeox/macro/BaseLocaleMacro.java +++ b/wiki/radeox/src/org/radeox/macro/BaseLocaleMacro.java @@ -65,7 +65,7 @@ public void setInitialContext(InitialRenderContext context) { try { description = messages.getString(getLocaleKey()+".description"); } catch (Exception e) { - log.warn("Cannot read description from properties " + inputName + " for " + getLocaleKey()); + log.warn("Cannot read description from properties " + inputName + " for " + getLocaleKey() + " from " + context); } } } \ No newline at end of file diff --git a/wiki/src/org/labkey/wiki/RenderedWikiResource.java b/wiki/src/org/labkey/wiki/RenderedWikiResource.java index 1a57c624805..edcf7fbec06 100644 --- a/wiki/src/org/labkey/wiki/RenderedWikiResource.java +++ b/wiki/src/org/labkey/wiki/RenderedWikiResource.java @@ -51,6 +51,6 @@ private HtmlString getHtml(String body, WikiRendererType type) { WikiRenderingService service = WikiRenderingService.get(); - return service.getFormattedHtml(type, body); + return service.getFormattedHtml(type, body, "Wiki WebDav document id " + getDocumentId() + " in container " + getContainerId()); } } diff --git a/wiki/src/org/labkey/wiki/WikiManager.java b/wiki/src/org/labkey/wiki/WikiManager.java index 12d09088061..b42831552c4 100644 --- a/wiki/src/org/labkey/wiki/WikiManager.java +++ b/wiki/src/org/labkey/wiki/WikiManager.java @@ -521,7 +521,7 @@ public FormattedHtml formatWiki(Container c, Wiki wiki, WikiVersion wikiversion) //get formatter specified for this version WikiRenderer w = wikiversion.getRenderer(hrefPrefix, attachPrefix, nameTitleMap, wiki.getAttachments()); - return w.format(wikiversion.getBody()); + return w.format(wikiversion.getBody(), "Wiki " + wiki.getEntityId() + " version " + wikiversion.getRowId() + " in " + wiki.getContainerPath()); } From 75ae98a2a6761839727592149adc46ce56066f57 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 26 Aug 2024 17:30:56 -0700 Subject: [PATCH 2/4] Fix argument ordering --- core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java b/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java index 7c91b2d7036..56952aff21f 100644 --- a/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java +++ b/core/src/org/labkey/core/wiki/WikiRenderingServiceImpl.java @@ -25,8 +25,8 @@ public void registerMacroProvider(String name, MacroProvider provider) @Override public HtmlString getFormattedHtml(WikiRendererType rendererType, String source, - String attachPrefix, @Nullable String sourceDescription, + String attachPrefix, Collection attachments) { return HtmlStringBuilder.of(WIKI_PREFIX) From 6093d79e676f2db3c9c1cd3e0be58a5fccaffabd Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 26 Aug 2024 22:38:20 -0700 Subject: [PATCH 3/4] Friendlier names --- wiki/src/org/labkey/wiki/WikiManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/src/org/labkey/wiki/WikiManager.java b/wiki/src/org/labkey/wiki/WikiManager.java index b42831552c4..48efd267033 100644 --- a/wiki/src/org/labkey/wiki/WikiManager.java +++ b/wiki/src/org/labkey/wiki/WikiManager.java @@ -521,7 +521,7 @@ public FormattedHtml formatWiki(Container c, Wiki wiki, WikiVersion wikiversion) //get formatter specified for this version WikiRenderer w = wikiversion.getRenderer(hrefPrefix, attachPrefix, nameTitleMap, wiki.getAttachments()); - return w.format(wikiversion.getBody(), "Wiki " + wiki.getEntityId() + " version " + wikiversion.getRowId() + " in " + wiki.getContainerPath()); + return w.format(wikiversion.getBody(), "Wiki '" + wiki.getName() + "' version " + wikiversion.getVersion() + " in " + wiki.getContainerPath()); } From c32f8450d52efe36f1a134c37dc9081028f5206d Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Tue, 27 Aug 2024 08:55:18 -0700 Subject: [PATCH 4/4] Friendlier names --- wiki/src/org/labkey/wiki/RenderedWikiResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/src/org/labkey/wiki/RenderedWikiResource.java b/wiki/src/org/labkey/wiki/RenderedWikiResource.java index edcf7fbec06..3cb0d781296 100644 --- a/wiki/src/org/labkey/wiki/RenderedWikiResource.java +++ b/wiki/src/org/labkey/wiki/RenderedWikiResource.java @@ -51,6 +51,6 @@ private HtmlString getHtml(String body, WikiRendererType type) { WikiRenderingService service = WikiRenderingService.get(); - return service.getFormattedHtml(type, body, "Wiki WebDav document id " + getDocumentId() + " in container " + getContainerId()); + return service.getFormattedHtml(type, body, "Wiki WebDav '" + getName() + "' in " + _c.getPath()); } }