[MAGNOLIA-1983] txt2img throws a RepositoryException and does not produce an image result Created: 01/Jan/08  Updated: 23/Jan/13  Resolved: 07/Jul/08

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 3.5.2
Fix Version/s: 3.6, 3.5.9

Type: Bug Priority: Minor
Reporter: Ryan Gardner Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X, Windows XP - Magnolia 3.5.2, JDK 1.6, using Jackrabbit with Derby


Attachments: Text File BaseImageTag.patch     Text File MAGNOLIA-1983_stacktrace.txt    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

In a jsp template, including the following tag (assuming that cmsu is the prefix assigned to the cms-util taglib...):

<cmsu:txt2img imageContentNodeName="generatedImages" text="Snowmobile Vermont!" />

should create a JCR child node of the page called "generatedImages" and put a node under that node containing the generated image.

An error is thrown.

Instead of doing this, however, a RepositoryException is thrown (full stacktrace in attachment)

Another user on the magnolia-users list confirmed that this error occurred on his system as well.



 Comments   
Comment by Magnolia International [ 02/Jan/08 ]

moved the stacktrace in an attachment for readability - thanks for the report.

Comment by Ryan Gardner [ 16/Feb/08 ]

I've taken an initial look into this issue. It seems that when the image node is created, it is in a transient state (I can see the imageContentNode/node/state/transient = true when I step over it in my debugger)

(in BaseImageTag.java) >>

imageContentNode = parentContentNode.createContent(this.imageContentNodeName, ItemType.CONTENTNODE);

Someone with more knowledge of the inner-workings of JCR probably knows better than me, but it appears that transient nodes do not get saved. In order to save the node, you have to explicitly make it a persistent node. I don't see how Magnolia handles doing this - as I've looked around other places where nodes are being created and I don't see what's different about this case.

Does the ScaleImageTag still work in 3.5? Both of them extend the BaseImageTag, and it seems that the behavior in the BaseImageTag is what is broken.

Comment by Giancarlo Berner [ 21/Mar/08 ]

Good to know I am not the only one stumbling over the txt2img tag...

Thanks, Ryan, for pointing out the BaseImageTag class. That made it rather easy to find the error. The problem is that TWO nodes are created (the image node with the name from the attribute, plus an additional node to store the rendered image), but the save happens only on the latter, which does not work because it is in "transient" mode.

The attached patch saves the first image node after it's creation and saves the second image node (last line: imageNode.getParent().save()) after adding the image.

Yes, the save could be done at the end, by using save() on an ancestor node, but if you are in a top hierarchy, you might be running the save on the whole web site.

The fix works fine for me now.

Comment by Ryan Gardner [ 21/Mar/08 ]

Great work!

I applied your patch to my version and I'll play around with it over the weekend.

It's a pretty powerful tag, and I'm surprised more people haven't been wondering about it for 3.5.

Comment by Magnolia International [ 07/Jul/08 ]

Thanks for the patch ! Applied on both the 3.5 branch and the trunk (3.6)

Generated at Mon Feb 12 03:32:15 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.