Package tenapull.run

Class ResetDatabase

java.lang.Object
tenapull.run.Job
tenapull.run.ResetDatabase

public class ResetDatabase
extends Job
A job that resets the database. Typically, this would be the only job run by the application if it were being run. When this job is constructed with the default constructor, the user will be prompted for confirmation before proceeding with the reset. Because it is done in the constructor, rather than in one of the job run methods, this will happen on the thread constructing the job (typically the main thread) not the thread running it. If the non-default constructor is used (with a single null argument), the user will NOT be prompted for confirmation.
  • Nested Class Summary

    Nested classes/interfaces inherited from class tenapull.run.Job

    Job.Accessor, Job.Stage
  • Field Summary

    Fields inherited from class tenapull.run.Job

    DEFAULT_TRY_AGAIN_TIME
  • Constructor Summary

    Constructors 
    Constructor Description
    ResetDatabase()
    Instantiates a new Reset database job, prompting the user for confirmation first.
    ResetDatabase​(java.lang.Void skipConfirm)
    Instantiates a new Reset database job WITHOUT prompting the user for confirmation.
  • Method Summary

    Modifier and Type Method Description
    protected boolean exceptionHandler​(java.lang.Exception e, Job.Stage stage)
    Handles any exceptions thrown by isReady, fetch, process, and output methods.
    protected void fetch​(NessusClient client)
    Fetch any API resources, using the NessusClient provided by the worker thread.
    protected boolean isReady()
    Is ready boolean.
    protected void output()
    Perform any outputting of the processed data The job will remain in the OUTPUT stage until fetch returns without an exception, or the job is marked as failed.
    protected void process()
    Perform any processing of the fetched data The job will remain in the PROCESS stage until fetch returns without an exception, or the job is marked as failed.

    Methods inherited from class tenapull.run.Job

    addJob, addJobs, equals, failed, getAccessor, getStage, notifyOfExit, start, tryAgainIn, waitForExit

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResetDatabase

      public ResetDatabase()
      Instantiates a new Reset database job, prompting the user for confirmation first. If the user does not confirm the reset, a flag will be set which tells the job to mark itself as failed once it starts running.
    • ResetDatabase

      public ResetDatabase​(java.lang.Void skipConfirm)
      Instantiates a new Reset database job WITHOUT prompting the user for confirmation. Use with extreme caution.
      Parameters:
      skipConfirm - null parameter, used to differentiate this constructor
  • Method Details

    • isReady

      protected boolean isReady()
      Description copied from class: Job
      Is ready boolean. Indicates whether the job is ready to run yet. If false is returned, the job will be placed in the JobFactory's waitingJobs queue, with either the default wait time, or another wait time if a new one is set before returning false from isReady. The job will remain in the IDLE stage until isReady returns true, or the job is marked as failed. Failed jobs are not marked as DONE until after the method has returned
      Specified by:
      isReady in class Job
      Returns:
      the boolean
    • fetch

      protected void fetch​(NessusClient client)
      Description copied from class: Job
      Fetch any API resources, using the NessusClient provided by the worker thread. The job will remain in the FETCH stage until fetch returns without an exception, or the job is marked as failed. Failed jobs are not marked as DONE until after the method has returned
      Specified by:
      fetch in class Job
      Parameters:
      client - the nessus client provided by the worker thread which is running this job
    • process

      protected void process() throws java.io.FileNotFoundException
      Description copied from class: Job
      Perform any processing of the fetched data The job will remain in the PROCESS stage until fetch returns without an exception, or the job is marked as failed. Failed jobs are not marked as DONE until after the method has returned
      Specified by:
      process in class Job
      Throws:
      java.io.FileNotFoundException
    • output

      protected void output()
      Description copied from class: Job
      Perform any outputting of the processed data The job will remain in the OUTPUT stage until fetch returns without an exception, or the job is marked as failed. Failed jobs are not marked as DONE until after the method has returned
      Specified by:
      output in class Job
    • exceptionHandler

      protected boolean exceptionHandler​(java.lang.Exception e, Job.Stage stage)
      Description copied from class: Job
      Handles any exceptions thrown by isReady, fetch, process, and output methods. Return true if the operation should be attempted again immediately. Mark as failed to permanently end the job. Otherwise, the job will be placed in the delayedJobs queue, and put back into readyJobs once its wait time is up
      Specified by:
      exceptionHandler in class Job
      Parameters:
      e - the e
      stage - the stage
      Returns:
      the boolean