public static void closeNodes(HttpServletRequest request, String treeId, String[] nodeIds) {

    while (true) {
      try {
        PortalPreferences portalPreferences =
            PortletPreferencesFactoryUtil.getPortalPreferences(request);

        String openNodesString =
            portalPreferences.getValue(SessionTreeJSClicks.class.getName(), treeId);

        for (String nodeId : nodeIds) {
          openNodesString = StringUtil.removeFromList(openNodesString, nodeId);
        }

        portalPreferences.setValue(SessionTreeJSClicks.class.getName(), treeId, openNodesString);

        return;
      } catch (ConcurrentModificationException cme) {
        continue;
      } catch (Exception e) {
        _log.error(e, e);

        return;
      }
    }
  }
  @Override
  public void removePortletId(long userId, String portletId, boolean cleanUp) {

    try {
      Portlet portlet = PortletLocalServiceUtil.getPortletById(getCompanyId(), portletId);

      if (portlet == null) {
        _log.error("Portlet " + portletId + " cannot be removed because it is not registered");

        return;
      }

      PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

      if (!LayoutPermissionUtil.contains(permissionChecker, getLayout(), ActionKeys.UPDATE)
          && !isCustomizable()) {

        return;
      }
    } catch (Exception e) {
      _log.error(e, e);

      return;
    }

    List<String> columns = getColumns();

    for (int i = 0; i < columns.size(); i++) {
      String columnId = columns.get(i);

      if (isCustomizable() && isColumnDisabled(columnId)) {
        continue;
      }

      String columnValue = StringPool.BLANK;

      if (hasUserPreferences()) {
        columnValue = getUserPreference(columnId);
      } else {
        columnValue = getTypeSettingsProperty(columnId);
      }

      columnValue = StringUtil.removeFromList(columnValue, portletId);

      if (hasUserPreferences()) {
        setUserPreference(columnId, columnValue);
      } else {
        setTypeSettingsProperty(columnId, columnValue);
      }
    }

    if (cleanUp) {
      try {
        onRemoveFromLayout(new String[] {portletId});
      } catch (Exception e) {
        _log.error(e, e);
      }
    }
  }
 @Override
 public void removeStateMinPortletId(String portletId) {
   setStateMin(StringUtil.removeFromList(getStateMin(), portletId));
 }
 @Override
 public void removeModePrintPortletId(String portletId) {
   setModePrint(StringUtil.removeFromList(getModePrint(), portletId));
 }
 @Override
 public void removeModeEditDefaultsPortletId(String portletId) {
   setModeEditDefaults(StringUtil.removeFromList(getModeEditDefaults(), portletId));
 }
 @Override
 public void removeModeConfigPortletId(String portletId) {
   setModeConfig(StringUtil.removeFromList(getModeConfig(), portletId));
 }