Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-10299

[SearchModel] Search does not work if 'title' is multilingual

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.3.0
    • Fix Version/s: 4.3.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      4.3 RC2

      Description

      The ReferenceTableSearchUIModel are not impacted and work well
      Create a static Search Model configured with a content type which has a 'multilingual' title attribute

      For instance:

      <content-types>
          <content-type id="odf-enumeration.Mention"/>
      </content-types>
      

      Then when searching, we got an error like this:

      2020-03-20 11:43:23,008 ERROR [org.ametys.plugins.core.ui] (http-nio-10004-exec-7;/cms/plugins/core-ui/servercomm/messages.xml) Can not dispatch request '3' : 'cms' 'select-content-search/list.json' '{query=, model=search-ui.my-search-model, id=null, excludeSubContents=true, contextualParameters={language=fr}, values={metadata-title-like=, property-contentLanguage-eq=fr, property-contentTypeOrMixin-eq=odf-enumeration.Mention}, page=1, start=0, limit=50, sort=[{"property":"title","direction":"ASC"}]}'
      org.apache.cocoon.util.location.LocatedException: Can not dispatch request '3' : 'cms' 'select-content-search/list.json' '{query=, model=search-ui.my-search-model, id=null, excludeSubContents=true, contextualParameters={language=fr}, values={metadata-title-like=, property-contentLanguage-eq=fr, property-contentTypeOrMixin-eq=odf-enumeration.Mention}, page=1, start=0, limit=50, sort=[{"property":"title","direction":"ASC"}]}'
      	at org.ametys.core.ui.dispatcher.DispatchGenerator._dispatching(DispatchGenerator.java:194)
      	at org.ametys.core.ui.dispatcher.DispatchGenerator.generate(DispatchGenerator.java:92)
      	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:581)
      	[...]
      Caused by: org.apache.excalibur.source.SourceException: Exception during processing of cocoon://_plugins/cms/select-content-search/list.json?query=&model=search-ui.my-search-model&excludeSubContents=true&contextualParameters={language%3Dfr}&values={metadata-title-like%3D, property-contentLanguage-eq%3Dfr, property-contentTypeOrMixin-eq%3Dodf-enumeration.Mention}&page=1&start=0&limit=50&sort=[{"property":"title","direction":"ASC"}]&
      	at org.apache.cocoon.components.source.impl.SitemapSource.getInputStream(SitemapSource.java:277)
      	at org.ametys.core.ui.dispatcher.DispatchGenerator._dispatching(DispatchGenerator.java:153)
      	... 69 more
      Caused by: org.apache.cocoon.ProcessingException: Failed to process reader
      	at <map:read type="search-json"> - file:/G:/Dev/Ametys/kernel/07_CMS/master/main/plugin-cms/sitemap.xmap:501:51
      	at org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.java:113)
      	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.handleException(AbstractProcessingPipeline.java:959)
      	at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processReader(AbstractCachingProcessingPipeline.java:940)
      	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:475)
      	at org.apache.cocoon.components.source.impl.SitemapSource.getInputStream(SitemapSource.java:267)
      	... 70 more
      Caused by: java.lang.IllegalArgumentException: Try to convert the non java.lang.String value 'org.ametys.plugins.repository.metadata.MultilingualString@e2ba6be' to JSON
      	at org.ametys.core.model.type.AbstractElementType.valueToJSONForClient(AbstractElementType.java:103)
      	at org.ametys.cms.search.content.ContentSearchHelper._transformSingleValue(ContentSearchHelper.java:690)
      	at org.ametys.cms.search.content.ContentSearchHelper._transformValue(ContentSearchHelper.java:639)
      	at org.ametys.cms.search.content.ContentSearchHelper.getAttributeValue(ContentSearchHelper.java:487)
      	at org.ametys.cms.search.ui.model.impl.MetadataSearchUIColumn.getValue(MetadataSearchUIColumn.java:401)
      	at org.ametys.cms.search.content.ContentValuesExtractorFactory$SearchModelContentValuesExtractor.getValues(ContentValuesExtractorFactory.java:164)
      	at org.ametys.cms.search.cocoon.SearchJsonReader.getContentData(SearchJsonReader.java:285)
      	at org.ametys.cms.search.cocoon.SearchJsonReader.setContents(SearchJsonReader.java:212)
      	at org.ametys.cms.search.cocoon.SearchJsonReader.convertResults2JsonObject(SearchJsonReader.java:163)
      	at org.ametys.cms.search.cocoon.SearchJsonReader.generate(SearchJsonReader.java:124)
      	at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processReader(AbstractCachingProcessingPipeline.java:921)
      	... 72 more
      

      It seems that the model of 'title' is considered as 'string' and not 'multilingual'

      Because on startup of the application, during the following trace:

      StaticSearchUIModel(AbstractSearchUIModel).addContentTypesConfiguration(DefaultConfiguration, Set<String>) line: 520	
      	StaticSearchUIModel(AbstractSearchUIModel).getMetadataColumnConfiguration(Configuration, Set<String>, String) line: 470	
      	StaticSearchUIModel._addMetadataColumnComponents(Set<ContentType>, Configuration, String, List<String>) line: 882	
      	StaticSearchUIModel._addColumnsComponents(Set<ContentType>, Configuration, List<String>) line: 846	
      	StaticSearchUIModel.configure(Configuration) line: 198	
      	ContainerUtil.configure(Object, Configuration) line: 202	
      	ThreadSafeComponentManager$ComponentFactory.configureAndStart(T) line: 359	
      	ThreadSafeComponentManager$ComponentFactory.newInstance() line: 378	
      	ThreadSafeComponentManager<T>.initialize() line: 206	
      	SearchUIModelExtensionPoint(AbstractThreadSafeComponentExtensionPoint<T>).initializeExtensions() line: 96	
      [...]
      

       baseContentTypeIds is an empty set, because in org.ametys.cms.search.ui.model.StaticSearchUIModel._addMetadataColumnComponents(Set<ContentType>, Configuration, String, List<String>) (line 882), when the metadataPath is tittle, we explicitly pass an empty set
      And then, when configuring the corresponding MetadataSearchUIColumn, in org.ametys.cms.search.ui.model.impl.MetadataSearchUIColumn._configureModelItems(Set<String>, String) (line 227), the type is explictly and harcoded set to 'STRING'

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bmaurel Bérénice Maurel
              Reporter:
              sprieul Simon Prieul (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: