private void doStep(Context context, HttpServletRequest request,
HttpServletResponse response, SubmissionInfo subInfo, int stepNumber)
throws ServletException, IOException, SQLException,
AuthorizeException
{
SubmissionStepConfig currentStepConfig = null;
if (subInfo.getSubmissionConfig() != null)
{
// get step to perform
currentStepConfig = subInfo.getSubmissionConfig().getStep(stepNumber);
}
else
{
log.fatal(LogManager.getHeader(context, "no_submission_process",
"trying to load step=" + stepNumber
+ ", but submission process is null"));
JSPManager.showInternalError(request, response);
}
// if this is the furthest step the user has been to, save that info
if (!subInfo.isInWorkflow() && (currentStepConfig.getStepNumber() > getStepReached(subInfo)))
{
// update submission info
userHasReached(subInfo, currentStepConfig.getStepNumber());
// commit changes to database
context.commit();
// flag that we just started this step (for JSPStepManager class)
setBeginningOfStep(request, true);
}
// save current step to request attribute
saveCurrentStepConfig(request, currentStepConfig);
log.debug("Calling Step Class: '"
+ currentStepConfig.getProcessingClassName() + "'");
try
{
JSPStepManager stepManager = JSPStepManager.loadStep(currentStepConfig);
//tell the step class to do its processing
boolean stepFinished = stepManager.processStep(context, request, response, subInfo);
//if this step is finished, continue to next step
if(stepFinished)
{
// If we finished up an upload, then we need to change
// the FileUploadRequest object back to a normal HTTPServletRequest
if(request instanceof FileUploadRequest)
{
request = ((FileUploadRequest)request).getOriginalRequest();
}
//retrieve any changes to the SubmissionInfo object
subInfo = getSubmissionInfo(context, request);
//do the next step!
doNextStep(context, request, response, subInfo, currentStepConfig);
}
else
{
//commit & close context
context.complete();
}
}
catch (Exception e)
{
log.error("Error loading step class'" + currentStepConfig.getProcessingClassName() + "':", e);
JSPManager.showInternalError(request, response);
}
}