/**
  * Sets up the importer before it can start reading log events.
  *
  * @throws IOException
  */
 private void initialize() throws IOException {
   genericLogFile = new GenericLogFile();
   genericLogFile.setFileName(importContext.getFile().getName());
   genericLogFile.setImporterId(this.getClass().getName());
   genericLogFile.setImportedAt(System.currentTimeMillis());
   genericLogFile.setVersion(1);
 }
  public void setContext(ImportContext context) {
    // Check out FLEXlm license.
    try {
      LicenseManager lm = LicenseManager.getInstance();
      long cookie = (long) (Math.random() * Long.MAX_VALUE);
      long r = lm.registerPlugin(PLUGIN_ID, "1.000", cookie);
      long t = System.currentTimeMillis() / 10000;
      if ((r != (cookie ^ t)) && (r != (cookie ^ (t - 1)))) {
        throw new LicenseException("Incorrect response value");
      }
    } catch (LicenseException e) {
      throw new ImportException(
          "Could not check out a FLEXlm license "
              + "for the "
              + PLUGIN_NAME
              + " plugin ("
              + PLUGIN_ID
              + ").",
          e);
    }

    if (importContext != null) {
      throw new IllegalStateException("Can't import log twice!");
    }
    importContext = context;
    if (file != null) {
      throw new IllegalStateException("setContext should only be called once");
    }

    file = importContext.getFile();
    file = context.getFile();
    genericLogFile = GenericLogFile.valueOf(file);
    genericLogFile.setImportedAt(System.currentTimeMillis());

    if (!canRead(file)) {
      throw new ImportException(
          "Invalid file format. "
              + toString()
              + " can't read the file: "
              + file.getName()
              + " on path: "
              + file.getAbsolutePath());
    }
  }