public void finalizeReports(String currentSessionId) {
    // TODO: Need to implement procedure to skip finalizing the current session when this is
    //  called on app start, but keep the current session when called at crash time. Currently
    //  this only works when called at app start.
    List<File> sessionDirectories = capAndGetOpenSessions(currentSessionId);
    for (File sessionDirectory : sessionDirectories) {
      final List<File> eventFiles =
          getFilesInDirectory(
              sessionDirectory, (f, name) -> name.startsWith(EVENT_FILE_NAME_PREFIX));
      Collections.sort(eventFiles);
      // TODO: Fix nulls
      // Only process the session if it has associated events
      if (!eventFiles.isEmpty()) {
        final List<Event> events = new ArrayList<>();
        boolean isHighPriorityReport = false;
        for (File eventFile : eventFiles) {
          final Event event = TRANSFORM.eventFromJson(readTextFile(eventFile));
          isHighPriorityReport =
              isHighPriorityReport || isHighPriorityEventFile(eventFile.getName());
          events.add(event);
        }
        // FIXME: If we fail to parse the events, we'll need to bail.
        String userId = null;
        final File userFile = new File(sessionDirectory, USER_FILE_NAME);
        if (userFile.exists()) {
          userId = readTextFile(userFile);
        }
        CrashlyticsReport report =
            TRANSFORM.reportFromJson(readTextFile(new File(sessionDirectory, REPORT_FILE_NAME)));
        final String sessionId = report.getSession().getIdentifier();
        if (userId != null) {
          report = report.withUserId(userId);
        }
        final File outputDirectory =
            prepareDirectory(isHighPriorityReport ? priorityReportsDirectory : reportsDirectory);
        writeTextFile(
            new File(outputDirectory, sessionId),
            TRANSFORM.reportToJson(report.withEvents(ImmutableList.from(events))));
      }
      recursiveDelete(sessionDirectory);
    }
    capFinalizedReports();
  }
public void finalizeReports(String currentSessionId) {
   
   
   
    List<File> sessionDirectories = capAndGetOpenSessions(currentSessionId);
    for (File sessionDirectory : sessionDirectories) {
      final List<File> eventFiles =
          getFilesInDirectory(
              sessionDirectory, (f, name) -> name.startsWith(EVENT_FILE_NAME_PREFIX));
      Collections.sort(eventFiles);
     
     
      if (!eventFiles.isEmpty()) {
        final List<Event> events = new ArrayList<>();
        boolean isHighPriorityReport = false;
        for (File eventFile : eventFiles) {
          final Event event = TRANSFORM.eventFromJson(readTextFile(eventFile));
          isHighPriorityReport =
              isHighPriorityReport || isHighPriorityEventFile(eventFile.getName());
          events.add(event);
        }
       
        String userId = null;
        final File userFile = new File(sessionDirectory, USER_FILE_NAME);
        if (userFile.exists()) {
          userId = readTextFile(userFile);
        }
        CrashlyticsReport report =
            TRANSFORM.reportFromJson(readTextFile(new File(sessionDirectory, REPORT_FILE_NAME)));
        final String sessionId = report.getSession().getIdentifier();
        if (userId != null) {
          report = report.withUserId(userId);
        }
        final File outputDirectory =
            prepareDirectory(isHighPriorityReport ? priorityReportsDirectory : reportsDirectory);
        writeTextFile(
            new File(outputDirectory, sessionId),
            TRANSFORM.reportToJson(report.withEvents(ImmutableList.from(events))));
      }
      recursiveDelete(sessionDirectory);
    }
    capFinalizedReports();
  }
public void finalizereports(string currentsessionid) { list<file> sessiondirectories = capandgetopensessions(currentsessionid); for (file sessiondirectory : sessiondirectories) { final list<file> eventfiles = getfilesindirectory( sessiondirectory, (f, name) -> name.startswith(event_file_name_prefix)); collections.sort(eventfiles); if (!eventfiles.isempty()) { final list<event> events = new arraylist<>(); boolean ishighpriorityreport = false; for (file eventfile : eventfiles) { final event event = transform.eventfromjson(readtextfile(eventfile)); ishighpriorityreport = ishighpriorityreport || ishighpriorityeventfile(eventfile.getname()); events.add(event); } string userid = null; final file userfile = new file(sessiondirectory, user_file_name); if (userfile.exists()) { userid = readtextfile(userfile); } crashlyticsreport report = transform.reportfromjson(readtextfile(new file(sessiondirectory, report_file_name))); final string sessionid = report.getsession().getidentifier(); if (userid != null) { report = report.withuserid(userid); } final file outputdirectory = preparedirectory(ishighpriorityreport ? priorityreportsdirectory : reportsdirectory); writetextfile( new file(outputdirectory, sessionid), transform.reporttojson(report.withevents(immutablelist.from(events)))); } recursivedelete(sessiondirectory); } capfinalizedreports(); }