@Override
    public void run() {
        try {
            log.info("Starting the archive process thread");
            running = true;
            while (running) {
                if (list.getNumArchiveJobs() > 0) {
                    Job job = list.getNextArchiveJob();

                    log.info("Checking for state validity...");
                    if (job == null) {
                        log.error("JobArchiver job is null");
                        return;
                    }

                    if (job.getState() != JobState.DOWNLOADED) {
                        log.error("Job with jobId: {} has invalid state! Found: {}, required: JobState.DOWNLOADED", job.getId(),
                                job.getState());
                    }
                    log.info("State valid. Starting archive...");
                    doNotify(job, JobState.ARCHIVING);
                    if (doArchive() == false) {
                        log.info("Failed to archive job with id: {}.", job.getId());
                        doNotify(job, JobState.ERROR);
                    } else {
                        log.info("Successfully archived job with id: {}. File: {}.", job.getId(), job.getFile());
                        doNotify(job, JobState.ARCHIVED);
                    }
                } else {
                    Thread.sleep(10000);
                }
            }
        } catch (InterruptedException ie) {

        } catch (Exception e) {
            log.error("Failed to archive!");
            for (StackTraceElement ee : e.getStackTrace()) {
                log.error(ee.toString());
            }
        }
    }