public static PortletPreferencesImpl toPortletPreferencesImpl(
      PortletPreferences portletPreferences) throws Exception {

    return (PortletPreferencesImpl)
        PortletPreferencesFactoryUtil.fromXML(
            TestPropsValues.getCompanyId(),
            portletPreferences.getOwnerId(),
            portletPreferences.getOwnerType(),
            portletPreferences.getPlid(),
            portletPreferences.getPortletId(),
            portletPreferences.getPreferences());
  }
  private void _checkAssetEntries(com.liferay.portal.model.PortletPreferences portletPreferences)
      throws PortalException, SystemException {

    Layout layout = LayoutLocalServiceUtil.getLayout(portletPreferences.getPlid());

    PortletPreferences preferences =
        PortletPreferencesFactoryUtil.fromXML(
            layout.getCompanyId(),
            portletPreferences.getOwnerId(),
            portletPreferences.getOwnerType(),
            portletPreferences.getPlid(),
            portletPreferences.getPortletId(),
            portletPreferences.getPreferences());

    if (!getEmailAssetEntryAddedEnabled(preferences)) {
      return;
    }

    List<AssetEntry> assetEntries =
        getAssetEntries(
            preferences,
            layout,
            layout.getGroupId(),
            PropsValues.ASSET_PUBLISHER_DYNAMIC_SUBSCRIPTION_LIMIT,
            false);

    if (assetEntries.isEmpty()) {
      return;
    }

    long[] notifiedAssetEntryIds =
        GetterUtil.getLongValues(preferences.getValues("notifiedAssetEntryIds", null));

    List<AssetEntry> newAssetEntries = new ArrayList<AssetEntry>();

    for (int i = 0; i < assetEntries.size(); i++) {
      AssetEntry assetEntry = assetEntries.get(i);

      if (!ArrayUtil.contains(notifiedAssetEntryIds, assetEntry.getEntryId())) {

        newAssetEntries.add(assetEntry);
      }
    }

    notifySubscribers(
        preferences,
        portletPreferences.getPlid(),
        portletPreferences.getPortletId(),
        newAssetEntries);

    try {
      preferences.setValues(
          "notifiedAssetEntryIds",
          StringUtil.split(ListUtil.toString(assetEntries, AssetEntry.ENTRY_ID_ACCESSOR)));

      preferences.store();
    } catch (IOException ioe) {
      throw new SystemException(ioe);
    } catch (PortletException pe) {
      throw new SystemException(pe);
    }
  }