boolean isBlocked(Workflow workflow,Step step) throws WorkflowException, CancelledException {
  if (step.waitFor == null) {
    return false;
  }
  Map<String,StepStatus> statusMap=new HashMap<String,StepStatus>();
  try {
    StepStatus status=workflow.getStepStatus(step.waitFor);
    statusMap.put(step.waitFor,status);
  }
 catch (  WorkflowException ex1) {
    try {
      statusMap=workflow.getStepGroupStatus(step.waitFor);
    }
 catch (    WorkflowException ex2) {
      throw new WorkflowException(String.format("Workflow step %s waitFor %s invalid, must be stepId or stepGroup name",step.stepId,step.waitFor));
    }
  }
  String[] errorMessage=new String[1];
  StepState state=Workflow.getOverallState(statusMap,errorMessage);
switch (state) {
case SUSPENDED_NO_ERROR:
case SUSPENDED_ERROR:
case CANCELLED:
    throw new CancelledException();
case ERROR:
  if ((workflow.getRollbackContOnError()) && (workflow.isRollbackState())) {
    _log.info("Allowing rollback to continue despite failure in previous rollback step.");
    return false;
  }
throw new CancelledException();
case SUCCESS:
return false;
case CREATED:
case BLOCKED:
case QUEUED:
case EXECUTING:
default :
return true;
}
}

boolean isBlocked ( Workflow workflow , Step step ) throws WorkflowException , CancelledException { if ( step . waitFor == null ) { return false ; } Map < String , StepStatus > statusMap = new HashMap < String , StepStatus > ( ) ; try { StepStatus status = workflow . getStepStatus ( step . waitFor ) ; statusMap . put ( step . waitFor , status ) ; } catch ( WorkflowException ex1 ) { try { statusMap = workflow . getStepGroupStatus ( step . waitFor ) ; } catch ( WorkflowException ex2 ) { throw new WorkflowException ( String . format ( "Workflow step %s waitFor %s invalid, must be stepId or stepGroup name" , step . stepId , step . waitFor ) ) ; } } String [ ] errorMessage = new String [ 1 ] ; StepState state = Workflow . getOverallState ( statusMap , errorMessage ) ; switch ( state ) { case SUSPENDED_NO_ERROR : case SUSPENDED_ERROR : case CANCELLED : throw new CancelledException ( ) ; case ERROR : if ( ( workflow . getRollbackContOnError ( ) ) && ( workflow . isRollbackState ( ) ) ) { _log . info ( "Allowing rollback to continue despite failure in previous rollback step." ) ; return false ; } throw new CancelledException ( ) ; case SUCCESS : return false ; case CREATED : case BLOCKED : case QUEUED : case EXECUTING : default : return true ; } }
determine if a workflow step is blocked . a step is blocked if it has a waitfor clause pointing to a step or step group that is not in the success state . if a pre - requisite step has errored or been cancelled , a cancelledexception is thrown .
