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

Asset Publisher doesn't add </table> tag

    Details

    • Story Points:
      3
    • Fix Priority:
      4

      Description

      Steps:
      1. Create two roles RoleA and RoleB
      2. Create two files FileA with view permissions for role RoleA and FileB with view permissions for role RoleB
      3. Create an user UserAB who is in role RoleA and RoleB and an user UserB who is just in RoleB
      4. Add an Asset Publisher to any page and configure it:
      4.1 Enable Permissions = true
      4.1 Asset Selection = manual (not dynamic!)
      4.2 Add both files to the Asset Publisher
      4.2 Order: 1. FileB - FileA (this is not important but will have a better visible effect)

      Now user UserAB sees a list with first FileB and second FileA and UserB sees just FileB, as expected. But for UserB the whole page looks different now, e.g. the Liferay footer of the page is now part of the Asset Publisher.

      This is due to the fact, that Liferay sets the result count BEFORE it actually knows how many results it will show later.
      The </table>-Tag is set here:
      https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L198
      It's only set if the index + 1 == the results count. The problem is, that it sets the count (https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/view_manual.jspf#L18) before it filters out results without permissions (https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/view_manual.jspf#L70), so the count will never fit if any result is filtered and so the </table>-tag isn't set.

      You could possibly fix it by adding the following in front of https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/view_manual.jspf#L18

      List<String> tempResults = new ArrayList<String>();
      
      for (String assetEntryXml : assetEntryXmls) {
      	Document document = SAXReaderUtil.read(assetEntryXml);
      	Element rootElement = document.getRootElement();
      	String assetEntryUuid = rootElement.elementText("asset-entry-uuid");
      	AssetEntry assetEntry = null;
      	for (long groupId : groupIds) {
      		try {
      			assetEntry = AssetEntryLocalServiceUtil.getEntry(groupId, assetEntryUuid);
      			break;
      		} catch (NoSuchEntryException nsee) {
      			
      		}
      	}
      	if ((assetEntry == null) || !assetEntry.isVisible()) {
      		continue;
      	}
      	AssetRendererFactory assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(assetEntry.getClassName());
      	AssetRenderer assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK());
      	if (!assetRenderer.isDisplayable() || (enablePermissions && !assetRenderer.hasViewPermission(permissionChecker))) {
      		continue;
      	}
      	tempResults.add(assetEntryXml);
      }
      
      assetEntryXmls = tempResults.toArray(new String[0]);
      

      But there must be another, better way to solve this.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 1 week, 5 days ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.0 CE B2