public void importServicePortletPreferences(
      PortletDataContext portletDataContext, Element serviceElement) throws PortalException {

    long ownerId = GetterUtil.getLong(serviceElement.attributeValue("owner-id"));
    int ownerType = GetterUtil.getInteger(serviceElement.attributeValue("owner-type"));
    String serviceName = serviceElement.attributeValue("service-name");

    if (ownerType == PortletKeys.PREFS_OWNER_TYPE_GROUP) {
      ownerId = portletDataContext.getGroupId();
    } else if (ownerType == PortletKeys.PREFS_OWNER_TYPE_COMPANY) {
      ownerId = portletDataContext.getCompanyId();
    }

    PortletPreferences portletPreferences =
        getPortletPreferences(
            portletDataContext.getCompanyId(),
            ownerId,
            ownerType,
            LayoutConstants.DEFAULT_PLID,
            serviceName);

    for (Attribute attribute : serviceElement.attributes()) {
      serviceElement.remove(attribute);
    }

    String xml = serviceElement.asXML();

    portletPreferences.setPreferences(xml);

    _portletPreferencesLocalService.updatePortletPreferences(portletPreferences);
  }
  /**
   * @deprecated As of 4.0.0, replaced by {@link deletePortletData(PortletDataContext
   *     portletDataContext, javax.portlet.PortletPreferences portletPreferences)}
   */
  @Deprecated
  protected String deletePortletData(
      PortletDataContext portletDataContext, PortletPreferences portletPreferences)
      throws Exception {

    javax.portlet.PortletPreferences portletPreferencesImpl =
        PortletPreferencesFactoryUtil.fromDefaultXML(portletPreferences.getPreferences());

    return deletePortletData(portletDataContext, portletPreferencesImpl);
  }
  /**
   * @deprecated As of 4.0.0, replaced by {@link #importPortletData(PortletDataContext
   *     portletDataContext, javax.portlet.PortletPreferences portletPreferences, Element
   *     portletDataElement)}
   */
  @Deprecated
  public String importPortletData(
      PortletDataContext portletDataContext,
      PortletPreferences portletPreferences,
      Element portletDataElement)
      throws Exception {

    PortletPreferencesImpl portletPreferencesImpl = null;

    if (portletPreferences != null) {
      portletPreferencesImpl =
          (PortletPreferencesImpl)
              PortletPreferencesFactoryUtil.fromDefaultXML(portletPreferences.getPreferences());
    }

    return importPortletData(portletDataContext, portletPreferencesImpl, portletDataElement);
  }