[MGNLDAM-264] Cannot delete duplicated asset Created: 14/Jun/13  Updated: 25/Jun/13  Resolved: 14/Jun/13

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

Type: Bug Priority: Critical
Reporter: Federico Grilli Assignee: Eric Hechinger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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:
Sprint: RC 2

 Description   

2013-06-13 16:18:27,925 ERROR info.magnolia.cms.core.version.BaseVersionManager : failed to copy versionable node to version store, reverting all changes made in this session
2013-06-13 16:18:27,925 ERROR gnolia.ui.framework.action.MarkNodeAsDeletedAction: Could not execute command operation.
info.magnolia.ui.api.action.ActionExecutionException: org.apache.commons.lang.exception.NestableException: Exception during executing command
at info.magnolia.ui.framework.action.AbstractCommandAction.execute(AbstractCommandAction.java:167)

This is due to the Reference property. Linking a Node using a reference involve integrity check (make a version of a Asset without having the original node already versioned will throw Integrity exception).

Solution is to use Weak reference, that do not required integrity check.

Strange is that the asset node type definition includes :
<propertyDefinition name="master" requiredType="WeakReference" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" isFullTextSearchable="false" isQueryOrderable="false"/>

but this is not taken into account when doing: workspace.copy(..

We have to explicitly ask for a weak reference:
Value refValue = copyNode.getSession().getValueFactory().createValue(originalNode, true);
copyNode.setProperty(DamNodeTypes.Asset.MASTER, refValue);



 Comments   
Comment by Eric Hechinger [ 14/Jun/13 ]

It works if the Parent node is Published (has a version)

The duplicated Asset has a reference to the original one :
<sv:property sv:name="master" sv:type="Reference">
<sv:value>1d2e3486-536c-400d-9b87-09357c095a35</sv:value>
</sv:property>
In CopyUtil.copyToversion()
root = this.getSession().getNodeByIdentifier(source.getUUID()); is done in the mgnlVersion workspace, but if the parent node is not already versionned, then the Reference --> parent Itentifier is nout found in this repository....

Comment by Eric Hechinger [ 14/Jun/13 ]

In fact we have the same problem with publication. If we try to publish a duplicated asset with the original asset not yet versioned, same behavior.

Comment by Espen Jervidalo [ 25/Jun/13 ]

this was sent to the userlist btw:
Subject: Jackrabbit creates a Reference typed property, despite the nt requesting a WeakReference ? Bug or feature ?
Date: 14 juin 2013 17:40:26 UTC+02:00
To: users@jackrabbit.apache.org

Hi there,

We have the following in a nodetype definition:
<propertyDefinition name="foobar" requiredType="WeakReference" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" isFullTextSearchable="false" isQueryOrderable="false"/>

.. and the following code …
nodeA.setProperty("foobar", nodeB);

The Javadoc of javax.jcr.Node#setProperty(String name, Node value) says:
[…]

  • If the named property does not yet exist and the repository cannot
  • determine whether a <code>REFERENCE</code> or <code>WEAKREFERENCE</code>
  • property is intended, then a <code>REFERENCE</code> property is created.
    […]

… so we assumed that the NT def would drive this decision.

But when exporting nodeA, we see that the property was created as a (hard) Reference. Looking at the code of org.apache.jackrabbit.commons.AbstractNode#setProperty(String name, Node value), it looks like it's not trying at all to make any sort of informed decision, and just delegates to javax.jcr.ValueFactory#createValue(Node value) which is explicitly spec'd to create (hard) Reference properties.

Generated at Mon Feb 12 04:58:07 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.