如何获取网页内容元数据类别&标记Liferay 7中自定义模块中的信息?

时间:2017-10-28 17:23:27

标签: metadata liferay-7 liferay-dxp

如何获取webcontent元数据类别&标记liferay 7中自定义模块中的信息。 我需要覆盖Journal Article

的服务包装器钩子

addArticle(long userId,long groupId,long folderId,long classNameId,long classPK,             String articleId,boolean autoArticleId,double version,Map titleMap,             映射descriptionMap,String content,String ddmStructureKey,String ddmTemplateKey,             String layoutUuid,int displayDateMonth,int displayDateDay,int displayDateYear,int displayDateHour,             int displayDateMinute,int expirationDateMonth,int expirationDateDay,int expirationDateYear,             int expirationDateHour,int expirationDateMinute,boolean neverExpire,int reviewDateMonth,             int reviewDateDay,int reviewDateYear,int reviewDateHour,int reviewDateMinute,boolean neverReview,             boolean indexable,boolean smallImage,String smallImageURL,File smallImageFile,             Map images,String articleURL,ServiceContext serviceContext)抛出PortalException { }

此方法中没有元数据信息的参数如何获取期刊文章的元数据信息。

1 个答案:

答案 0 :(得分:0)

有两种方法可以解决这个问题。模型侦听器方式有点棘手,因为在调用模型侦听器之后建立了Article和类别之间的关联。 id已经被分配了(article.getId())但是需要有一些技巧来克服这个问题。

直接的方法是创建服务包装器,调用原始代码,然后使用服务上下文来确定进一步的操作。

考虑通过Liferay消息总线解耦将使用异步消息发送邮件的代码。

如果您在Liferay中配置了SMTP服务器,您还可以使用MailService从门户网站发送电子邮件。

参见示例代码

@Component(immediate = true, property = {}, service = 
ServiceWrapper.class)
public class MailServiceWrapper extends JournalArticleServiceWrapper {

  private static final Log _log = LogFactoryUtil.getLog(MailServiceWrapper.class);

  @Reference
  private  MailService mailService;

  @Reference
  private AssetCategoryService assetCategoryService;


  @Override
  public JournalArticle addArticle(long groupId, long folderId, long classNameId, long classPK, String articleId, boolean autoArticleId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, String articleURL, ServiceContext serviceContext) throws PortalException {
    JournalArticle journalArticle = super.addArticle(groupId, folderId, classNameId, classPK, articleId, autoArticleId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, indexable, articleURL, serviceContext);
    sendNotification(serviceContext.getAssetCategoryIds(), journalArticle);
    return journalArticle;
  }


  @Override
  public JournalArticle addArticle(long groupId, long folderId, long classNameId, long classPK, String articleId, boolean autoArticleId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, boolean smallImage, String smallImageURL, File smallFile, Map<String, byte[]> images, String articleURL, ServiceContext serviceContext) throws PortalException {
    JournalArticle journalArticle = super.addArticle(groupId, folderId, classNameId, classPK, articleId, autoArticleId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, indexable, smallImage, smallImageURL, smallFile, images, articleURL, serviceContext);
    sendNotification(serviceContext.getAssetCategoryIds(), journalArticle);
    return journalArticle;
  }

  private void sendNotification(long[] assetCategoryIds, JournalArticle journalArticle) throws PortalException {
    // send mail

  }
}