code: public Set<CmsResource> getResourcesForPrincipal(
          CmsDbContext dbc,
          CmsProject project,
          CmsUUID principalId,
          CmsPermissionSet permissions,
          boolean includeAttr)
      throws CmsException {
  
          Set<CmsResource> resources = new HashSet<CmsResource>(
              getVfsDriver(dbc).readResourcesForPrincipalACE(dbc, project, principalId));
          if (permissions != null) {
              Iterator<CmsResource> itRes = resources.iterator();
              while (itRes.hasNext()) {
                  CmsAccessControlEntry ace = readAccessControlEntry(dbc, itRes.next(), principalId);
                  if ((ace.getPermissions().getPermissions()
                      & permissions.getPermissions()) != permissions.getPermissions()) {
                      // remove if permissions does not match
                      itRes.remove();
                  }
              }
          }
          if (includeAttr) {
              resources.addAll(getVfsDriver(dbc).readResourcesForPrincipalAttr(dbc, project, principalId));
          }
          return resources;
      }
docs: Returns all resources associated to a given principal via an ACE with the given permissions.<p>
  
  If the <code>includeAttr</code> flag is set it returns also all resources associated to
  a given principal through some of following attributes.<p>
  
  <ul>
  <li>User Created</li>
  <li>User Last Modified</li>
  </ul><p>
  
  @param dbc the current database context
  @param project the to read the entries from
  @param principalId the id of the principal
  @param permissions a set of permissions to match, can be <code>null</code> for all ACEs
  @param includeAttr a flag to include resources associated by attributes
  
  @return a set of <code>{@link CmsResource}</code> objects
  
  @throws CmsException if something goes wrong