[MGNLDAM-621] Property "name" on JcrAsset is very hard to obtain with ftl only Created: 29/Sep/15  Updated: 12/Mar/21  Resolved: 12/Mar/21

Status: Closed
Project: Magnolia DAM Module
Component/s: None
Affects Version/s: 2.1.1
Fix Version/s: None

Type: Story Priority: Neutral
Reporter: Christoph Meier Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File jcrAsset_name_property.png    
Issue Links:
duplicate
is duplicated by MGNLDAM-604 Name of Asset is not available via DA... Open
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)
Date of First Response:

 Description   

DAM app (based on jcr assets) has a jcr property "name". To obtain the property with ftl you must fetch the jcr node first, otherwise - directly on the asset - seems impossible.

When adding an asset, 2 properties are set automatically with the name of the node (actually with the name of the uploaded image/file).
See screenshot.
The second property - on the UI named "Asset name" - saved as jcr property "name" can be changed without changing the node name. However, to read that property with ftl is cumbersome. ...
Operating on the asset directly always returns the node name but not the value of the jcr property "name".

To improve the situation - the implementation of JcrAsset#getName() could be changed. Currently JcrAsset#getName() always returns the name of the node. Instead the method should try to return the jcr property "name" - if failing fall back to the file name.



 Comments   
Comment by Christoph Meier [ 29/Sep/15 ]

I've created a little ftl macro to tyr out this stuff:

[#macro assetNameBrainFuck assetRef]
    <div>
    [#if assetRef??]
        [#assign asset = damfn.getAsset(assetRef) /]
        [#if asset??]
            asset.name = ${asset.name!""}<br/>
            asset.class.name = ${asset.class.name!""}<br/>
            asset.node.name = ${asset.node.name!""}<br/>
            [#assign assetMap = damfn.getAssetMap(asset)]
            assetMap.name = ${assetMap.name!""}<br/>
            [#--asset.getItemKey().getAssetId() = ${asset.getItemKey().getAssetId()}<br/>--]
            [#assign damJcrNode = cmsfn.asJCRNode(cmsfn.contentById(asset.getItemKey().getAssetId(), "dam")) /]
            [#if damJcrNode??]
                damJcrNode@name =  ${damJcrNode.getProperty("name").getString()}<br/>
            [#else]
                no damJcrNode<br/>
            [/#if]
        [/#if]
    [/#if]
    </div>
[/#macro]
Comment by Magnolia International [ 29/Sep/15 ]

The problem is that JcrAsset (JcrAssetProvider) systematically returns node.getName(), while it should [maybe|probably] look at the name property before falling back on the node name.

Generated at Mon Feb 12 05:01:38 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.