Details

    • Liferay Contributor's Agreement:
      Accept

      Description

      Currently the Asset Publisher allows to show some metadata about the assets but some good are missing. My suggestion: add the asset description and the last author of an asset. To do so, follow these steps:

      1. Add these imports to this file https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/init.jsp
        <%@ page import="com.liferay.portlet.documentlibrary.model.DLFileVersion" %>
        <%@ page import="com.liferay.portlet.documentlibrary.service.DLFileVersionLocalServiceUtil" %>
        
      2. Change this line https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/init.jsp#L215
        String allMetadataFields = "create-date,modified-date,publish-date,expiration-date,priority,author,view-count,categories,tags,description,last-author";
        
      3. Change this line https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/css/main.css#L145
        	.metadata-author, .metadata-last-author {
        
      4. Add this style here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/css/main.css#L173
        	.metadata-description {
        		margin-right: 10px;
        	}
        
      5. Add these lines here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L177
        		else if (metadataFields[m].equals("description")) {
        			value = HtmlUtil.escape(assetEntry.getDescription());
        		}
        		else if (metadataFields[m].equals("last-author")) {
        			if (assetEntry.getClassName().equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) {
        				DLFileVersion fileVersion = DLFileVersionLocalServiceUtil.getLatestFileVersion(assetEntry.getClassPK(), true);
        				
        				value = HtmlUtil.escape(fileVersion.getStatusByUserName());
        			} else {
        				String userName = PortalUtil.getUserName(assetRenderer.getUserId(), assetRenderer.getUserName());
        
        				value = HtmlUtil.escape(userName);
        			}
        		}
        
      6. Add these lines here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/asset_metadata.jspf#L64
        	else if (metadataFields[j].equals("description")) {
        		value = HtmlUtil.escape(assetEntry.getDescription());
        	}
        	else if (metadataFields[j].equals("last-author")) {
        		if (assetEntry.getClassName().equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) {
        			DLFileVersion fileVersion = DLFileVersionLocalServiceUtil.getLatestFileVersion(assetEntry.getClassPK(), true);
        			
        			value = LanguageUtil.get(pageContext, "by") + StringPool.SPACE + HtmlUtil.escape(fileVersion.getStatusByUserName());
        		} else {
        			String userName = PortalUtil.getUserName(assetRenderer.getUserId(), assetRenderer.getUserName());
        
        			value = LanguageUtil.get(pageContext, "by") + StringPool.SPACE + HtmlUtil.escape(userName);
        		}
        	}
        

      Furthermore there's a problem with author<>last author. The author for dlfiles is always the creator while on journals/web content the author is the last editor. To fix this, change these lines: https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L144 and https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/asset_metadata.jspf#L49

      		String userName = assetEntry.getUserName();
      

      You will also need to add "last-author" to the language files.

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            mod David Kubitza
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Packages

                Version Package