gt:                 for (CmsAccessControlEntry entry : entries) {
context: /*
   * This library is part of OpenCms -
   * the Open Source Content Management System
   *
   * Copyright (c) Alkacon Software GmbH (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.workplace.tools.accounts;
  
  import au.com.bytecode.opencsv.CSVWriter;
  
  import org.opencms.file.CmsGroup;
  import org.opencms.file.CmsObject;
  import org.opencms.file.CmsResource;
  import org.opencms.file.CmsResourceFilter;
  import org.opencms.file.CmsUser;
  import org.opencms.jsp.CmsJspActionElement;
  import org.opencms.main.CmsException;
  import org.opencms.main.CmsLog;
  import org.opencms.main.OpenCms;
  import org.opencms.security.CmsAccessControlEntry;
  import org.opencms.security.CmsRole;
  import org.opencms.util.CmsUUID;
  import org.opencms.workplace.list.A_CmsListDialog;
  import org.opencms.workplace.list.CmsListColumnDefinition;
  import org.opencms.workplace.list.CmsListCsvExportIAction;
  import org.opencms.workplace.list.CmsListItem;
  import org.opencms.workplace.list.CmsListMetadata;
  import org.opencms.workplace.list.CmsListMetadata.I_CsvItemFormatter;
  import org.opencms.workplace.list.CmsListOrderEnum;
  import org.opencms.workplace.list.CmsListSearchAction;
  
  import java.io.IOException;
  import java.io.StringWriter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Locale;
  import java.util.Set;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.commons.logging.Log;
  
  import com.google.common.collect.ArrayListMultimap;
  import com.google.common.collect.Multimap;
  
  /**
   * Group dependencies list view.<p>
   */
  public class CmsAllPrincipalDependenciesList extends A_CmsListDialog {
  
      /** 
       * Helper class for generating the list entries. 
       */
      protected static class ElementGenerator {
  
          /** The access control entry cache. */
          private Multimap<CmsUUID, CmsAccessControlEntry> m_ace;
  
          /** The CMS object used for file operations. */
          private CmsObject m_cms;
  
          /** The generated list entries. */
          private List<String[]> m_entries = new ArrayList<String[]>();
  
          /** 
           * Creates a new instance.<p>
           * 
           * @param cms the CMS context to use for file operations 
           * 
           * @throws CmsException if something goes wrong 
           */
          public ElementGenerator(CmsObject cms)
          throws CmsException {
  
              m_cms = OpenCms.initCmsObject(cms);
              m_cms.getRequestContext().setSiteRoot("");
          }
  
          /**
           * Generates the list entries.<p>
           * 
           * @return a list of string arrays of the form ( name, credential, permissions, path )
           *  
           * @throws CmsException if something goes wrong 
           */
          public List<String[]> generateEntries() throws CmsException {
  
              Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms);
              addDirectEntries(
                  CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID,
                  CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME,
                  locale);
              addDirectEntries(
                  CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID,
                  CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME,
                  locale);
              for (CmsUser user : getUsers()) {
                  CmsUUID userId = user.getId();
                  String name = user.getName();
                  addDirectEntries(userId, name, locale);
                  for (CmsGroup group : m_cms.getGroupsOfUser(user.getName(), false)) {
                      for (CmsAccessControlEntry ace : getAces(group.getId())) {
                          for (CmsResource resource : getResources(ace.getResource())) {
                              String credentials = Messages.get().getBundle(locale).key(
                                  Messages.GUI_CREDENTIAL_GROUP_1,
                                  group.getName());
                              addEntry(user.getName(), credentials, getAceString(ace),
  
                              resource.getRootPath());
  
                          }
                      }
                  }
                  Set<CmsUUID> processedRoles = new HashSet<CmsUUID>();
                  List<CmsRole> roles = OpenCms.getRoleManager().getRolesOfUser(
                      m_cms,
                      user.getName(),
                      "",
                      true,
                      false,
                      true);
                  for (CmsRole role : roles) {
                      // only generate one entry for each role, independent of the number of OUs 
                      if (processedRoles.contains(role.getId())) {
                          continue;
                      } else {
                          processedRoles.add(role.getId());
                      }
                      for (CmsAccessControlEntry ace : getAces(role.getId())) {
                          for (CmsResource resource : getResources(ace.getResource())) {
                              String credentials = Messages.get().getBundle(locale).key(
                                  Messages.GUI_CREDENTIAL_ROLE_1,
                                  role.getName(locale));
                              addEntry(user.getName(), credentials, getAceString(ace),
  
                              resource.getRootPath());
  
                          }
                      }
                  }
              }
              LOG.info("Generated " + m_entries.size() + " entries for " + this.getClass().getName());
              return m_entries;
          }
  
          /** 
           * Helper method to add the direct ACEs for a principal.<p>
           * 
           * @param principalId the principal id 
           * @param name the principal name 
           * @param locale the locale 
           * 
           * @throws CmsException if something goes wrong 
           */
          protected void addDirectEntries(CmsUUID principalId, String name, Locale locale) throws CmsException {
  
              for (CmsAccessControlEntry ace : getAces(principalId)) {
                  for (CmsResource resource : getResources(ace.getResource())) {
                      String credentials = Messages.get().getBundle(locale).key(Messages.GUI_CREDENTIAL_DIRECT_0);
                      addEntry(name, credentials, getAceString(ace), resource.getRootPath());
                  }
              }
          }
  
          /**
           * Adds a new entry.<p>
           * 
           * @param user the user name 
           * @param principal the credential name 
           * @param permissions the permission string 
           * @param path the resource path 
           */
          private void addEntry(String user, String principal, String permissions, String path) {
  
              m_entries.add(new String[] {user, "" + principal, permissions, path});
          }
  
          /**
           * Gets the access control entries for a given principal id.<p>
           * 
           * @param principalId the principal id 
           * @return the access control entries for that principal id
           * 
           * @throws CmsException if something goes wrong 
           */
          private Collection<CmsAccessControlEntry> getAces(CmsUUID principalId) throws CmsException {
  
              if (m_ace == null) {
                  m_ace = ArrayListMultimap.create();
                  List<CmsAccessControlEntry> entries = m_cms.getAllAccessControlEntries();
  