Details
-
Improvement
-
Resolution: Obsolete
-
Neutral
-
None
-
4.5.4
Description
Hi,
When calling the method "info.magnolia.templating.functions.TemplatingFunctions#link" from freemarker using:
<#assign dmsLink = cmsfn.link("dms", "/demo-docs/children/wizoz10") />
The only error visible for me is:
Error on line 95, column 11 in path/to/template
cmsfn.link("dms", "/demo-docs/children/wizoz10") is undefined.
It cannot be assigned to dmsLink
The problematic instruction:
----------
==> assignment: dmsLink=cmsfn.link("dms", "/demo-docs/children/wizoz10") [on line 95, column 11 in path/to/template]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Error on line 95, column 11 in path/to/template
cmsfn.link("dms", "/demo-docs/children/wizoz10") is undefined.
It cannot be assigned to dmsLink
at freemarker.core.Assignment.accept(Assignment.java:111)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
When downloading the source code I've found:
public String link(String workspace, String nodeIdentifier) {
try {
return LinkUtil.createLink(workspace, nodeIdentifier);
} catch (RepositoryException e) {
return null;
}
}
The real error "javax.jcr.RepositoryException: invalid identifier: /demo-docs/children/wizoz10" was hidden from me because of this. I first assumed that the method "link" was missing due to the error visible to me in the log.
Better consistency for the error handling in this file would be appreciated. Example:
public String link(String workspace, String nodeIdentifier) {
try {
return LinkUtil.createLink(workspace, nodeIdentifier);
} catch (RepositoryException e) {
log.error(e.getMessage(), e); // Print the real error in the log
return null;
}
}
Also I see other methods have the same problem, those should be updated as well.
Checklists
Acceptance criteria
Attachments
Issue Links
- is superseded by
-
MAGNOLIA-6868 TemplatingFunctions for fetching content in templating: Prevent flooding logs of non resolvable JCR items
-
- Closed
-