/*
(non-Javadoc)

@see org.springframework.batch.core.StepExecutionListener#beforeStep(org.
springframework.batch.core.StepExecution)
494469
@Override
    public void beforeStep(StepExecution stepExecution) {
        super.beforeStep(stepExecution);
        resetContextState();
        try {

            this.manifestSet = ManifestFileHelper.loadManifestSetFromFile(this.manifestFile);

            new Retrier().execute(new Retriable() {
                /*
                 * (non-Javadoc)
                 *
                 * @see org.duracloud.common.retry.Retriable#retry()
                 */
                @Override
                public Object retry() throws Exception {
                    RestoreStatus newStatus = RestoreStatus.VERIFYING_SNAPSHOT_REPO_AGAINST_MANIFEST;
                    restoreManager.transitionRestoreStatus(restoreId, newStatus, "");
                    return null;
                }
            });

        } catch (Exception ex) {
            addError("failed to transition status to "
                     + RestoreStatus.VERIFYING_SNAPSHOT_REPO_AGAINST_MANIFEST + ": " + ex.getMessage());
            stepExecution.addFailureException(ex);
        }
    }
25010
@Override
    public void process(Step step) {
        step.setName(getName());
        step.setStatus(Status.PASSED);
        step.setStart(System.currentTimeMillis());
        step.setTitle(getTitle());
    }
270995
public Javalin before(@NotNull String path, @NotNull Handler handler) {
        return addHandler(HandlerType.BEFORE, path, handler);
    }
1208648
public void setStep(final String pstep) {
    try {
      this.setStep(Integer.valueOf(pstep));
    } catch (final NumberFormatException e) {
      this.setStep((Integer) null);
    }
  }
854324
public static void before(String path, String acceptType, Filter... filters) {
        for (Filter filter : filters) {
            getInstance().before(path, acceptType, filter);
        }
    }
522948
@Override
    public void process(Step step) {
        Status status = throwable instanceof AssertionError ? Status.FAILED : Status.BROKEN;
        step.setStatus(status);
    }
346825
@Override
    public void beforeCompletion() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { 
            Tr.entry(this, tc, "beforeCompletion");
            Tr.exit(this, tc, "beforeCompletion");
        }
    }
99114
@Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        ExitStatus status = stepExecution.getExitStatus();
        return status;
    }
1195570
public static function before($clazz, $actions, $beforeClazz, $warpAction, $call = null) {
        $actions = static::actionsBuild($actions);
        if (!isset(static::$beforeActions[ $clazz ])) {
            static::$beforeActions[ $clazz ] = array();
        }
        if (!isset(static::$beforeActions[ $clazz ][ $actions[ 'type' ] ])) {
            static::$beforeActions[ $clazz ][ $actions[ 'type' ] ] = array();
        }
        $info = array('methods' => $actions[ 'methods' ],
                      'class' => $beforeClazz,
                      'action' => $warpAction,
                      "call" => $call,
                      "range" => static::$range);
        static::$range++;
        static::$beforeActions[ $clazz ][ $actions[ 'type' ] ][] = $info;
    }
535619
protected function beforeStart()
    {
        // If no explicit request was given (via Enlighten::setRequest), create one based on the current PHP globals
        if (empty($this->request)) {
            $this->setRequest(Request::extractFromEnvironment());
        }

        $this->bootstrapRouter();
    }
637154
function( currentStep, nextStep ) {
            if ( lastEntered === currentStep ) {
                lib.util.triggerEvent( currentStep, "impress:stepleave", { next: nextStep } );
                lastEntered = null;
            }
        }
732558
@Nullable
  public LegStep upComingStep() {
    if (routeLeg().steps().size() - 1 > stepIndex()) {
      return routeLeg().steps().get(stepIndex() + 1);
    }
    return null;
  }
175752
void runWithinPeriod(Runnable runnable, ExecuteStepMessage executeStepMessage, int timeout, TimeUnit unit) {
        if ( ! isRunningAStep.getAndSet(true)) {
            this.currentlyExecutingStep = executeStepMessage;
            Future<String> future = null;
            try {
                future = scheduledExecutorService.submit(runStepAndResetIsRunning(runnable), "OK");
                future.get(timeout, unit);
            } catch (TimeoutException e) {
                //Timed out waiting for the step to run
                //We should try to cancel and interrupt the thread which is running the step - although this isn't
                //guaranteed to succeed.
                future.cancel(true);
                log.warn("A step failed to execute within " + timeout + " " + unit + ", attempting to cancel the step");
                //Here the step server should have timed out the step and proceed already - we don't need to send a failure message
            } catch (Exception e) {
                String ms = "Exception while executing step [" + e.getMessage() + "]";
                log.error(ms, e);
                stepFailureConsumer.accept(ms, executeStepMessage);
            }
        } else {
            //server will time out this step
            String message = "Cannot execute a test step, a step is already in progress [" + currentlyExecutingStep.getStepId() + ", " + currentlyExecutingStep.getPattern() + "]";
            log.error(message);
            stepFailureConsumer.accept(message, executeStepMessage);
        }
    }
1258867
public void setSteps(java.util.Collection<Step> steps) {
        if (steps == null) {
            this.steps = null;
            return;
        }

        this.steps = new java.util.ArrayList<Step>(steps);
    }
814087
@Override
    protected void invokePreStepArtifacts() {

        if (stepListeners != null) {
            for (StepListenerProxy listenerProxy : stepListeners) {
                // Call beforeStep on all the step listeners
                listenerProxy.beforeStep();
            }
        }

        // Invoke the reducer before all parallel steps start (must occur
        // before mapper as well)
        if (this.partitionReducerProxy != null) {
            this.partitionReducerProxy.beginPartitionedStep();
        }
    }
1071269
protected function BeforeInit()
    {
        if ($this->RemoveTemplate())
        {
            Response::Redirect(Request::Uri());
            return true;
        }
        parent::BeforeInit();
    }
317394
public static void before(Object request, Object response) {
        /*
         * Use reflection to access the HttpServletRequest/Response as using the
         * true method signature caused ClassLoader issues.
         */
        Class<?> reqClass = request.getClass();
        try {
            /*
             * Retrieve the tracker from the request and increment nesting level
             */
            HttpRequestTracker tracker;
            Method getAttribute = reqClass.getMethod(GET_ATTRIBUTE, String.class);
            tracker = (HttpRequestTracker) (getAttribute.invoke(request, TRACKER_ATTRIBUTE));
            if (tracker == null) {
                tracker = new HttpRequestTracker();
            }
            tracker.increment();
            Method setAttribute = reqClass.getMethod(SET_ATTRIBUTE, String.class, Object.class);
            setAttribute.invoke(request, TRACKER_ATTRIBUTE, tracker);
        } catch (Exception e) {
            // Log any exception caused by our injected code
            System.err.println("Javametrics: Servlet callback exception: " + e.toString());
            e.printStackTrace();
        }
    }