code: protected void addSubResources(CmsObject cms, Set<CmsResource> resources) throws CmsException {
  
          List<CmsResource> subResources = new ArrayList<CmsResource>();
          CmsObject rootCms = OpenCms.initCmsObject(cms);
          rootCms.getRequestContext().setSiteRoot("");
          for (CmsResource res : resources) {
              if (res.isFolder()) {
                  try {
                      List<CmsResource> childrenOfCurrentResource = rootCms.readResources(
                          res.getRootPath(),
                          CmsResourceFilter.ALL,
                          true);
                      subResources.addAll(childrenOfCurrentResource);
                  } catch (CmsException e) {
                      LOG.error(e.getLocalizedMessage(), e);
                  }
              }
          }
          resources.addAll(subResources);
      }
docs: Adds contents of folders to a list of resources.<p>
  
  @param cms the CMS context to use
  @param resources the resource list to which to add the folder contents
  @throws CmsException if something goes wrong