public void update()

in src/main/java/org/apache/sling/jobs/impl/JobImpl.java [157:202]


    public void update(@NotNull JobUpdate jobUpdate) {
        if  ( id.equals(jobUpdate.getId()) && ( jobQueue == Types.ANY_JOB_QUEUE || jobQueue.equals(jobUpdate.getQueue()))) {
            // Start Job commands always go onto a queue and dont expire.
            if ( jobUpdate.getCommand() != JobUpdate.JobUpdateCommand.START_JOB && jobUpdate.expires() < System.currentTimeMillis()) {
                throw new IllegalStateException(
                        "JobUpdate has expired, can't be applied. Expired at "+jobUpdate.expires()+
                                ", time now "+System.currentTimeMillis()+
                                " expired "+(System.currentTimeMillis()-jobUpdate.expires())+" ms ago.");
            }
            if (jobUpdate.updateTimestamp() < lastUpdate ) {
                throw new IllegalStateException("JobUpdate received out of sequence, cant be applied. Last Update was at "+lastUpdate+" this update is at "+jobUpdate.updateTimestamp());
            }
            lastUpdate = jobUpdate.updateTimestamp();
            switch(jobUpdate.getCommand()) {
                case START_JOB:
                    updateState(jobUpdate);
                    updateProperties(jobUpdate.getProperties());
                    break;
                case UPDATE_JOB:
                    // note, when job first comes into existence it is updated, then started.
                    // the start message is a queued message, the update is a jobQueue or pub sub message.
                    updateState(jobUpdate);
                    updateProperties(jobUpdate.getProperties());
                    break;
                case RETRY_JOB:
                    updateState(jobUpdate);
                    // Allow more retries.
                    numberOfRetries = retryCount + numberOfRetries;
                    // TODO: trigger retry if required.
                    updateProperties(jobUpdate.getProperties());
                    break;
                case STOP_JOB:
                    if (jobController != null) {
                        jobController.stop();
                    }
                    break;
                case ABORT_JOB:
                    if (jobController != null) {
                        jobController.abort();
                    }
                    break;
            }
        } else {
            throw new IllegalArgumentException("Cant update job with jobUpdate that doesn't match id and jobQueue ");
        }
    }