code: protected CmsResource getDefaultFileOrSelf(CmsResource res) {
  
          CmsResource defaultfile = null;
          if (res.isFolder()) {
              try {
                  defaultfile = m_cms.readDefaultFile("" + res.getStructureId());
              } catch (CmsSecurityException e) {
                  LOG.error(e.getLocalizedMessage(), e);
                  return null;
              } catch (CmsException e) {
                  LOG.error(e.getLocalizedMessage(), e);
                  return null;
              }
              return defaultfile;
          }
          return res;
  
      }
docs: Helper method for reading the default file of a folder.<p>
  
  If the resource given already is a file, it will be returned, otherwise
  the default file (or null, if none exists) of the folder will be returned.
  
  @param res the resource whose default file to read
  @return the default file