-
Improvement
-
Resolution: Unresolved
-
Major
-
4.9.6
-
None
-
None
-
2 - Long term
-
2 - Normal
For example, I have an multiple attribute or property of type content. And I call the method like this:
content.dataToJSON("myMultipleContents/contentId", context);
It fails with the following error:
[...] Caused by: org.ametys.runtime.model.exception.BadDataPathCardinalityException: Unable to check if there is a value at path 'atlasLinkedContents/contentId'. The segment 'atlasLinkedContents' refers to a multiple data and can not be used inside the data path. at org.ametys.cms.data.holder.impl.DefaultModelAwareDataHolder._hasValue(DefaultModelAwareDataHolder.java:612) at org.ametys.cms.data.holder.impl.DefaultModelAwareDataHolder.hasValue(DefaultModelAwareDataHolder.java:544) at org.ametys.cms.data.holder.impl.IndexableDataHolderHelper.hasValue(IndexableDataHolderHelper.java:660) at org.ametys.cms.data.holder.impl.DefaultModelAwareDataHolder.dataToJSON(DefaultModelAwareDataHolder.java:849) at org.ametys.plugins.repository.data.ametysobject.DataAwareAmetysObject.dataToJSON(DataAwareAmetysObject.java:93) [...]
Also, in the method org.ametys.cms.data.holder.impl.DefaultModelAwareDataHolder.dataToJSON(String, DataContext), there is a difference while handling a property or an attribute, it seems that both cases could be handled with:
ModelItemType type = modelItem.getType(); Object value = getValue(dataPath); return type.valueToJSONForClient(value, newContext);
It works well with a content property.
Maybe the "multiple support" could be hold by the DataContext.