Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-109837

Unable to pass array of categories to embedded Asset Publisher

    Details

      Description

      Steps to Reproduce - Master

      1. Startup Liferay
      2. Create 2 categories within the "Topic" vocabulary
        • Cat1 and Cat2
      3. Retrieve the categoryId from each created category
        • This can be found in the URL when viewing a category
          • e.g. localhost:8080/group/guest/~/control_panel/manage/-/categories_admin/vocabulary/35323/category/35324
      4. Create a Liferay theme (or use the attached sample poc)
        • Include the following logic to introduce an Asset Publisher portlet:
          		<#assign prefs = {
          		"queryContains0":"true",
          		"queryAndOperator0":"false",
          		"queryName0":"assetCategories",
          		"queryValues0": ["35324","35325"]
          		} />
          
          		<@liferay_portlet["runtime"]
          		defaultPreferences = freeMarkerPortletPreferences.getPreferences(prefs)
          		instanceId="coolInstanceId333"
          		portletProviderAction=portletProviderAction.VIEW
          		portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
          		/> 
          
        • Note: Make sure the categoryIds: ["35324","35325"], are replaced with the actual categoryIds from the Liferay site
      5. Compile and deploy the theme
      6. Switch default site to use deployed theme
      7. Navigate to the home page
      8. Notice an Asset Publisher portlet is available
      9. Navigate to the portlet's configuration page
      10. Unfold the filter tab

      Expected:
      A rule exists for: Contains All Categories: Cat1, Cat2

      Actual: 
      No rule exists

      Sample POC:

      QA Notes
      The portlet preferences for the Asset Publisher portlet above, is only created/updated once, since the logic above only adds the preferences as defaultPreferences.

      This means if you use the same DB to test the before/after solution, make sure you clear the database or manually delete the existing portlet preferences + clear cache.


      Steps to Reproduce - Alternative + Additional Info
      The array parameter value is not working anymore in the Freemarker freeMarkerPortletPreferences.

      In 7.0, this worked fine:

      <#assign VOID = freeMarkerPortletPreferences.setValue("queryValues0",["assetCategory1.getCategoryId()","assetCategory2.getCategoryId()"]
      
      <@liferay_portlet["runtime"]
      defaultPreferences="${freeMarkerPortletPreferences}"
      instanceId="CoolId123"
      portletProviderAction=portletProvideAction.VIEW
      portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
      />
      

      It appears, in 7.1, setValue can no longer be used. What is the right way to pass an array of categories through Freemarker when embedding an Asset Publisher?

      Reproduction steps:

      0) Have a productive DB ready (for example, MySql) and connect it to Liferay as you will need to have a look at it during the test

      1) Patch 7.2 with dxp-4 and start the server, login as Admin
      2) Create 2 categories in the Global site inside the "Topic" vocabulary
      3) Open the DB table AssetCategory and take note of the categoryId for both. Let's guess for example these are 35148 and 35149
      4) Create a theme with the Theme Generator and edit the portal_normal.ftl by adding this code before the closing </section> tag:

      		<#assign prefs = {
      		"queryContains0":"true",
      		"queryAndOperator0":"false",
      		"queryName0":"assetCategories",
      		"queryValues0": ["35148","35149"]
      		} />
      
      		<@liferay_portlet["runtime"]
      		defaultPreferences = freeMarkerPortletPreferences.getPreferences(prefs)
      		instanceId="coolInstanceId333"
      		portletProviderAction=portletProviderAction.VIEW
      		portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
      		/> 
      

      (Theme attached)

      5) Compile and deploy the theme, create a new page and set that page to use the custom theme
      6) Once the page has been displayed at least once in your browser, open the PortletPreferences DB table and look for the entry having portletId of your embedded Asset Publisher and observe the preferences column:

      Expected:

      <portlet-preferences><preference><name>queryContains0</name><value>true</value></preference><preference><name>queryAndOperator0</name><value>false</value></preference><preference><name>queryName0</name><value>assetCategories</value><name>queryValues0</name><value>35148</value><value>35149</value></preference></portlet-preferences>
      

      Actual behavior:

      <portlet-preferences><preference><name>queryContains0</name><value>true</value></preference><preference><name>queryAndOperator0</name><value>false</value></preference><preference><name>queryName0</name><value>assetCategories</value></preference></portlet-preferences>
      

       

        Attachments

          Activity

            People

            Assignee:
            summer.zhang Summer Zhang
            Reporter:
            roland.pakai Roland Pákai
            Participants of an Issue:
            Recent user:
            Jason Pince
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              32 weeks, 5 days ago

                Packages

                Version Package
                7.2.10 DXP FP5
                7.2.10.2 DXP SP2
                7.2.X
                7.3.1 CE GA2
                7.3.2 CE GA3
                7.3.10 DXP GA1
                Master