[MAGNOLIA-8505] ChangeAllPropertiesWithCertainValueTask fails on multivalue properties Created: 18/Jul/22  Updated: 13/Oct/22  Resolved: 13/Oct/22

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 6.2.21
Fix Version/s: 6.3.0, 6.2.26

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Marek Strucka
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: XML File website.test (23).xml    
Issue Links:
Relates
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MAGNOLIA-8585 Implementation Sub-task Completed Marek Strucka  
MAGNOLIA-8586 Review Sub-task Completed Milan Divilek  
MAGNOLIA-8587 PiQA Sub-task Completed Milan Divilek  
MAGNOLIA-8588 QA Sub-task Completed Jaroslav Simak  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: Nucleus Quality Maintenance
Sprint: DevX 21
Story Points: 2
Team: DeveloperX

 Description   

Currently, delta task info.magnolia.module.delta.ChangeAllPropertiesWithCertainValueTask only works with single String values. It would be useful if this task also worked with multivalue properties. Instead, it throws an exception if there's a multivalued property and the execution is interrupted.

Steps to reproduce

  1. Import the website.test (23).xml into website workspace. It contains a property named test with value this.is.a.test.property
  2. Add an Install/update task to any module that makes use of ChangeAllPropertiesWithCertainValueTask. For example:
    public CustomModuleVersionHandler() {
    		register(DeltaBuilder.update("1.2", "Testing ChangeAllPropertiesWithCertainValueTask").addTask(new ChangeAllPropertiesWithCertainValueTask("website", "/", "this.is.a.test.property", "this.is.a.MODIFIED.test.property"))
    	    );
    	} 
  1. Install/update the module

Expected results

Test property is modified during installation/update task

Actual results

There's an error and test property is not modified

ERROR info.magnolia.module.InstallContextImpl           : [0/3 tasks - custom-module Magnolia Module (version 1.2.0)]> Could not install or update custom-module module. Task 'Change value of all properties with certain value.' failed. (ValueFormatException: property /test2/main/0/assignedSegments is a multi-valued property, so it's values can only be retrieved as an array)
info.magnolia.module.delta.TaskExecutionException: Could not execute task: Value format: property /test2/main/0/assignedSegments is a multi-valued property, so it's values can only be retrieved as an array
	at info.magnolia.module.delta.AbstractRepositoryTask.execute(AbstractRepositoryTask.java:59) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:491) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.ModuleManagerImpl.installOrUpdateModule(ModuleManagerImpl.java:473) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.ModuleManagerImpl$1.doExec(ModuleManagerImpl.java:271) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:407) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:404) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:378) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.ModuleManagerImpl.performInstallOrUpdate(ModuleManagerImpl.java:265) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.ui.ModuleManagerWebUI$2.run(ModuleManagerWebUI.java:126) ~[magnolia-core-6.2.20.jar:?]
	at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_121]
Caused by: javax.jcr.ValueFormatException: property /test2/main/0/assignedSegments is a multi-valued property, so it's values can only be retrieved as an array
	at org.apache.jackrabbit.core.PropertyImpl.internalGetValue(PropertyImpl.java:483) ~[jackrabbit-core-2.20.4.jar:2.20.4]
	at org.apache.jackrabbit.core.PropertyImpl.getValue(PropertyImpl.java:510) ~[jackrabbit-core-2.20.4.jar:2.20.4]
	at org.apache.jackrabbit.core.PropertyImpl.getString(PropertyImpl.java:520) ~[jackrabbit-core-2.20.4.jar:2.20.4]
	at info.magnolia.module.delta.ChangeAllPropertiesWithCertainValueTask.doExecute(ChangeAllPropertiesWithCertainValueTask.java:106) ~[magnolia-core-6.2.20.jar:?]
	at info.magnolia.module.delta.AbstractRepositoryTask.execute(AbstractRepositoryTask.java:57) ~[magnolia-core-6.2.20.jar:?]
	... 9 more

Development notes

The error occurs in line 129 of info.magnolia.module.delta.ChangeAllPropertiesWithCertainValueTask, where a conditional statement could be added in order to avoid the javax.jcr.ValueFormatException

if (property.getString().equals(currentValue)) {

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