Esempio n. 1
0
  protected void importPortletData(
      PortletDataContext portletDataContext,
      String portletId,
      long plid,
      Element portletDataElement)
      throws Exception {

    long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;

    PortletPreferences portletPreferences =
        PortletPreferencesUtil.fetchByO_O_P_P(ownerId, ownerType, plid, portletId);

    if (portletPreferences == null) {
      portletPreferences = new com.liferay.portal.model.impl.PortletPreferencesImpl();
    }

    String xml =
        importPortletData(portletDataContext, portletId, portletPreferences, portletDataElement);

    if (xml != null) {
      PortletPreferencesLocalServiceUtil.updatePreferences(
          ownerId, ownerType, plid, portletId, xml);
    }
  }
  protected void deletePortletData(PortletDataContext portletDataContext) throws Exception {

    long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;

    PortletPreferences portletPreferences =
        PortletPreferencesUtil.fetchByO_O_P_P(
            ownerId, ownerType, portletDataContext.getPlid(), portletDataContext.getPortletId());

    if (portletPreferences == null) {
      portletPreferences = new com.liferay.portal.model.impl.PortletPreferencesImpl();
    }

    String xml = deletePortletData(portletDataContext, portletPreferences);

    if (xml != null) {
      _portletPreferencesLocalService.updatePreferences(
          ownerId, ownerType, portletDataContext.getPlid(), portletDataContext.getPortletId(), xml);
    }
  }