Pre-requisites : create some documents where subjects and nature are set to some values. it's not mandatory but it helps to see that the search is working well
Steps to reproduce:
- Deploy the attached jar to nxserver/plugins
- Start Nuxeo
- Log in
- Select the "Multival" search in the left menu
- Choose some values for the "Subjects" and "Nature" fields
- Click on the Search button
- Observe that some documents are retrieved
- Click on the button to save the search: give a name and save
- make some changes to the Subjects field and search
- Click on the button "Save"
- Observe that no toast is displayed. And in the logs there is an error like
ERROR [WebEngineExceptionMapper] java.lang.ClassCastException: class org.nuxeo.ecm.core.schema.types.SimpleTypeImpl cannot be cast to class org.nuxeo.ecm.core.schema.types.ComplexType (org.nuxeo.ecm.core.schema.types.SimpleTypeImpl and org.nuxeo.ecm.core.schema.types.ComplexType are in unnamed module of loader org.nuxeo.runtime.tomcat.NuxeoWebappClassLoader @d1d8e1a) java.lang.ClassCastException: class org.nuxeo.ecm.core.schema.types.SimpleTypeImpl cannot be cast to class org.nuxeo.ecm.core.schema.types.ComplexType (org.nuxeo.ecm.core.schema.types.SimpleTypeImpl and org.nuxeo.ecm.core.schema.types.ComplexType are in unnamed module of loader org.nuxeo.runtime.tomcat.NuxeoWebappClassLoader @d1d8e1a) at org.nuxeo.ecm.automation.core.util.ComplexTypeJSONDecoder.decodeList(ComplexTypeJSONDecoder.java:80) ~[nuxeo-automation-core-2021.18.6.jar:?] at org.nuxeo.ecm.automation.core.util.ComplexTypeJSONDecoder.decodeList(ComplexTypeJSONDecoder.java:69) ~[nuxeo-automation-core-2021.18.6.jar:?] at org.nuxeo.ecm.automation.core.util.DocumentHelper.setListProperty(DocumentHelper.java:377) ~[nuxeo-automation-core-2021.18.6.jar:?] at org.nuxeo.ecm.automation.core.util.DocumentHelper.setProperty(DocumentHelper.java:328) ~[nuxeo-automation-core-2021.18.6.jar:?] at org.nuxeo.ecm.automation.core.util.DocumentHelper.setProperty(DocumentHelper.java:308) ~[nuxeo-automation-core-2021.18.6.jar:?] at org.nuxeo.ecm.restapi.server.jaxrs.search.SearchObject.setSaveSearchParams(SearchObject.java:273) ~[nuxeo-search-rest-api-2021.12.6.jar:?] at org.nuxeo.ecm.restapi.server.jaxrs.search.SearchObject.doUpdateSavedSearch(SearchObject.java:238) ~[nuxeo-search-rest-api-2021.12.6.jar:?]
The problem is related to the JSON payload sent to save the changes. The directory entity are sent with the JSON payload instead of sending only the values, which is done with the first save.
We have a payload like
"searchmultival_pp:dublincore_nature": [ { "entity-type": "directoryEntry", "directoryName": "nature", "id": "article", "properties": { "ordering": 10000000, "obsolete": 0, "id": "article", "label": "Article" } }, { "entity-type": "directoryEntry", "directoryName": "nature", "id": "acknowledgement", "properties": { "ordering": 10000000, "obsolete": 0, "id": "acknowledgement", "label": "Accusé de réception" } } ],
whereas the first save has
{ "entity-type": "savedSearch", "pageProviderName": "searchmultival", "params": { "dublincore_subjects": [ "art/architecture", "art/cinema" ], "dublincore_nature": [ "acknowledgement", "article" ] }, "title": "azaz" }
Expected behavior: the search is correctly saved (or renamed)