private void cleanupRequestDirectory() throws IOException {
    final Date cutoffDate = DateUtils.getDateSpecifiedTimeAgo(recommendationsArtifactsLifetime); // subdirectories older than this date will be deleted

    String[] oldDirectories = recommendationsDir.list(new FilenameFilter() {
      @Override
      public boolean accept(File current, String name) {
        File file = new File(current, name);
        return file.isDirectory() && !FileUtils.isFileNewer(file, cutoffDate);
      }
    });

    if (oldDirectories.length > 0) {
      LOG.info(String.format("Deleting old directories %s from %s", StringUtils.join(oldDirectories, ", "), recommendationsDir));
    }

    for (String oldDirectory : oldDirectories) {
      FileUtils.deleteQuietly(new File(recommendationsDir, oldDirectory));
    }
  }
Deletes folders older than (now - recommendationsArtifactsLifetime)
ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java