gt:                 for (CmsResource res : resources) {
context: /*
   * This library is part of OpenCms -
   * the Open Source Content Management System
   *
   * Copyright (C) Alkacon Software (http://www.alkacon.com)
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * For further information about Alkacon Software, please see the
   * company website: http://www.alkacon.com
   *
   * For further information about OpenCms, please see the
   * project website: http://www.opencms.org
   * 
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
  
  package org.opencms.ade.configuration;
  
  import org.opencms.ade.detailpage.CmsDetailPageConfigurationWriter;
  import org.opencms.ade.detailpage.CmsDetailPageInfo;
  import org.opencms.ade.detailpage.CmsSitemapDetailPageFinder;
  import org.opencms.ade.detailpage.I_CmsDetailPageFinder;
  import org.opencms.configuration.CmsSystemConfiguration;
  import org.opencms.db.CmsDriverManager;
  import org.opencms.db.CmsPublishedResource;
  import org.opencms.db.I_CmsProjectDriver;
  import org.opencms.file.CmsObject;
  import org.opencms.file.CmsProject;
  import org.opencms.file.CmsResource;
  import org.opencms.file.CmsUser;
  import org.opencms.file.types.CmsResourceTypeXmlContent;
  import org.opencms.file.types.I_CmsResourceType;
  import org.opencms.json.JSONArray;
  import org.opencms.json.JSONException;
  import org.opencms.json.JSONObject;
  import org.opencms.jsp.util.CmsJspStandardContextBean;
  import org.opencms.main.CmsEvent;
  import org.opencms.main.CmsException;
  import org.opencms.main.CmsLog;
  import org.opencms.main.I_CmsEventListener;
  import org.opencms.main.OpenCms;
  import org.opencms.monitor.CmsMemoryMonitor;
  import org.opencms.util.CmsCollectionsGenericWrapper;
  import org.opencms.util.CmsUUID;
  import org.opencms.xml.CmsXmlContentDefinition;
  import org.opencms.xml.containerpage.CmsADECache;
  import org.opencms.xml.containerpage.CmsADECacheSettings;
  import org.opencms.xml.containerpage.CmsContainerElementBean;
  import org.opencms.xml.containerpage.Messages;
  import org.opencms.xml.content.CmsXmlContentProperty;
  import org.opencms.xml.content.CmsXmlContentPropertyHelper;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.servlet.ServletRequest;
  
  import org.apache.commons.logging.Log;
  
  /**
   * This is the main class used to access the ADE configuration and also accomplish some other related tasks
   * like loading/saving favorite and recent lists.<p>
   */
  public class CmsADEManager implements I_CmsEventListener {
  
      /** JSON property name constant. */
      protected enum FavListProp {
          /** element property. */
          ELEMENT,
          /** formatter property. */
          FORMATTER,
          /** properties property. */
          PROPERTIES;
      }
  
      /**
       * A status enum for the initialization status.<p>
       */
      protected enum Status {
          /** already initialized. */
          initialized,
          /** currently initializing. */
          initializing,
          /** not initialized. */
          notInitialized
      }
  
      /** User additional info key constant. */
      public static final String ADDINFO_ADE_FAVORITE_LIST_SIZE = "ADE_FAVORITE_LIST_SIZE";
      /** User additional info key constant. */
      public static final String ADDINFO_ADE_RECENT_LIST_SIZE = "ADE_RECENT_LIST_SIZE";
  
      /** User additional info key constant. */
      public static final String ADDINFO_ADE_SEARCH_PAGE_SIZE = "ADE_SEARCH_PAGE_SIZE";
  
      /** The client id separator. */
      public static final String CLIENT_ID_SEPERATOR = "#";
  
      /** The configuration file name. */
      public static final String CONFIG_FILE_NAME = ".config";
  
      /** The content folder name. */
      public static final String CONFIG_FOLDER_NAME = ".content";
  
      /** The name of the sitemap configuration file type. */
      public static final String CONFIG_FOLDER_TYPE = "content_folder";
  
      /** The path for sitemap configuration files relative from the base path. */
      public static final String CONFIG_SUFFIX = "/"
          + CmsADEManager.CONFIG_FOLDER_NAME
          + "/"
          + CmsADEManager.CONFIG_FILE_NAME;
  
      /** The name of the sitemap configuration file type. */
      public static final String CONFIG_TYPE = "sitemap_config";
  
      /** Default favorite list size constant. */
      public static final int DEFAULT_FAVORITE_LIST_SIZE = 10;
  
      /** Default recent list size constant. */
      public static final int DEFAULT_RECENT_LIST_SIZE = 10;
  
      /** The name of the module configuration file type. */
      public static final String MODULE_CONFIG_TYPE = "module_config";
  
      /** The path to the sitemap editor JSP. */
      public static final String PATH_SITEMAP_EDITOR_JSP = "/system/modules/org.opencms.ade.sitemap/pages/sitemap.jsp";
  
      /** User additional info key constant. */
      protected static final String ADDINFO_ADE_FAVORITE_LIST = "ADE_FAVORITE_LIST";
  
      /** User additional info key constant. */
      protected static final String ADDINFO_ADE_RECENT_LIST = "ADE_RECENT_LIST";
  
      /** The logger instance for this class. */
      private static final Log LOG = CmsLog.getLog(CmsADEManager.class);
  
      /** The cache instance. */
      private CmsADECache m_cache;
  
      /** The sitemap configuration file type. */
      private I_CmsResourceType m_configType;
  
      /** The detail page finder. */
      private I_CmsDetailPageFinder m_detailPageFinder = new CmsSitemapDetailPageFinder();
  
      /** The initialization status. */
      private Status m_initStatus = Status.notInitialized;
  
      /** The module configuration file type. */
      private I_CmsResourceType m_moduleConfigType;
  
      /** The online cache instance. */
      private CmsConfigurationCache m_offlineCache;
  
      /** The offline CMS context. */
      private CmsObject m_offlineCms;
  
      /** The offline cache instance. */
      private CmsConfigurationCache m_onlineCache;
  
      /** The online CMS context. */
      private CmsObject m_onlineCms;
  
      /**
       * Creates a new ADE manager.<p>
       *
       * @param adminCms a CMS context with admin privileges 
       * @param memoryMonitor the memory monitor instance
       * @param systemConfiguration the system configuration
       */
      public CmsADEManager(CmsObject adminCms, CmsMemoryMonitor memoryMonitor, CmsSystemConfiguration systemConfiguration) {
  
          // initialize the ade cache
          CmsADECacheSettings cacheSettings = systemConfiguration.getAdeCacheSettings();
          if (cacheSettings == null) {
              cacheSettings = new CmsADECacheSettings();
          }
          m_onlineCms = adminCms;
          m_cache = new CmsADECache(memoryMonitor, cacheSettings);
  
          // further initialization is done by the initialize() method. We don't do that in the constructor,
          // because during the setup the configuration resource types don't exist yet.
      }
  
      /**
       * @see org.opencms.main.I_CmsEventListener#cmsEvent(org.opencms.main.CmsEvent)
       */
      public void cmsEvent(CmsEvent event) {
  
          CmsResource resource = null;
          List<CmsResource> resources = null;
          //System.out.println();
          switch (event.getType()) {
              case I_CmsEventListener.EVENT_RESOURCE_AND_PROPERTIES_MODIFIED:
              case I_CmsEventListener.EVENT_RESOURCE_MODIFIED:
              case I_CmsEventListener.EVENT_RESOURCE_CREATED:
                  //System.out.print(getEventName(event.getType()));
                  Object change = event.getData().get(I_CmsEventListener.KEY_CHANGE);
                  if ((change != null) && change.equals(new Integer(CmsDriverManager.NOTHING_CHANGED))) {
                      // skip lock & unlock
                      return;
                  }
                  resource = (CmsResource)event.getData().get(I_CmsEventListener.KEY_RESOURCE);
                  m_offlineCache.update(resource);
                  //System.out.print(" " + resource.getRootPath());
                  break;
              case I_CmsEventListener.EVENT_RESOURCES_AND_PROPERTIES_MODIFIED:
                  // a list of resources and all of their properties have been modified
                  //System.out.print(getEventName(event.getType()));
                  resources = CmsCollectionsGenericWrapper.list(event.getData().get(I_CmsEventListener.KEY_RESOURCES));
                  for (CmsResource res : resources) {
                      m_offlineCache.update(res);
                      //System.out.print(" " + res.getRootPath());
                  }
                  break;
  
              case I_CmsEventListener.EVENT_RESOURCE_MOVED:
                  resources = CmsCollectionsGenericWrapper.list(event.getData().get(I_CmsEventListener.KEY_RESOURCES));
                  // source, source folder, dest, dest folder 
                  // - OR -  
                  // source, dest, dest folder
                  m_offlineCache.remove(resources.get(0));
                  m_offlineCache.update(resources.get(resources.size() - 2));
                  break;
  
              case I_CmsEventListener.EVENT_RESOURCE_DELETED:
                  resources = CmsCollectionsGenericWrapper.list(event.getData().get(I_CmsEventListener.KEY_RESOURCES));
                  for (CmsResource res : resources) {
                      m_offlineCache.remove(res);
                  }
                  break;
              case I_CmsEventListener.EVENT_RESOURCES_MODIFIED:
                  //System.out.print(getEventName(event.getType()));
                  // a list of resources has been modified
                  resources = CmsCollectionsGenericWrapper.list(event.getData().get(I_CmsEventListener.KEY_RESOURCES));
  