public com.dotcms.repackage.portlet.javax.portlet.PortletPreferences getDefaultPreferences(
      String companyId, String portletId) throws PortalException, SystemException {

    Portlet portlet = PortletManagerUtil.getPortletById(companyId, portletId);

    return PortletPreferencesSerializer.fromDefaultXML(portlet.getDefaultPreferences());
  }
  public PortletPreferences updatePreferences(PortletPreferencesPK pk, PortletPreferencesImpl prefs)
      throws PortalException, SystemException {

    PortletPreferences portletPrefences = PortletPreferencesUtil.findByPrimaryKey(pk);

    String xml = PortletPreferencesSerializer.toXML(prefs);

    PortletPreferencesLocalUtil.getPreferencesPool(pk.userId).put(pk, prefs);

    portletPrefences.setPreferences(xml);

    PortletPreferencesUtil.update(portletPrefences);

    return portletPrefences;
  }
  public com.dotcms.repackage.portlet.javax.portlet.PortletPreferences getPreferences(
      String companyId, PortletPreferencesPK pk) throws PortalException, SystemException {

    //		String groupId = Layout.getGroupId(pk.layoutId);

    //		if (groupId != null) {
    //			if (!GetterUtil.getBoolean(
    //					PropsUtil.get(PropsUtil.GROUP_PAGES_PERSONALIZATION))) {
    //
    //				pk.userId = Layout.GROUP + groupId;
    //			}
    //		}

    Map prefsPool = PortletPreferencesLocalUtil.getPreferencesPool(pk.userId);

    PortletPreferencesImpl prefs = (PortletPreferencesImpl) prefsPool.get(pk);

    if (prefs == null) {
      PortletPreferences portletPreferences = null;

      Portlet portlet = null;
      //			if (groupId != null) {
      //				portlet = PortletManagerUtil.getPortletById(
      //					companyId, groupId, pk.portletId);
      //			}
      //			else {
      portlet = PortletManagerUtil.getPortletById(companyId, pk.portletId);
      //			}

      try {
        portletPreferences = PortletPreferencesUtil.findByPrimaryKey(pk);
      } catch (NoSuchPortletPreferencesException nsppe) {
        portletPreferences = PortletPreferencesUtil.create(pk);

        portletPreferences.setPreferences(portlet.getDefaultPreferences());

        PortletPreferencesUtil.update(portletPreferences);
      }

      prefs =
          PortletPreferencesSerializer.fromXML(companyId, pk, portletPreferences.getPreferences());

      prefsPool.put(pk, prefs);
    }

    return (PortletPreferencesImpl) prefs.clone();
  }