Program: 3592
Project: 3592
Buggy source:
/** 
 * Work out which page to show next, and show it
 * @param context
 * @param request
 * @param response
 * @param collection
 * @param stage  the stage the user just finished, or if PERMISSIONS, theparticular permissions page
 * @throws SQLException
 * @throws ServletException
 * @throws IOException
 * @throws AuthorizeException
 */
private void showNextPage(Context context,HttpServletRequest request,HttpServletResponse response,Collection collection,int stage) throws SQLException, ServletException, IOException, AuthorizeException {
  request.setAttribute("String_Node_Str",collection);
  if (Group.findByName(context,"String_Node_Str") != null) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + stage));
switch (stage) {
case BASIC_INFO:
    List anonReadPols=AuthorizeManager.getPoliciesActionFilter(context,collection,Constants.DEFAULT_ITEM_READ);
  if (anonReadPols.size() == 0) {
    request.setAttribute("String_Node_Str",new Integer(PERM_READ));
    JSPManager.showJSP(request,response,"String_Node_Str");
    break;
  }
case PERM_READ:
if (collection.getSubmitters() != null) {
  request.setAttribute("String_Node_Str",new Integer(PERM_SUBMIT));
  JSPManager.showJSP(request,response,"String_Node_Str");
  break;
}
case PERM_SUBMIT:
if (collection.getWorkflowGroup(1) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF1));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF1:
if (collection.getWorkflowGroup(2) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF2));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF2:
if (collection.getWorkflowGroup(3) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF3));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF3:
if (collection.getAdministrators() != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_ADMIN));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_ADMIN:
if (collection.getTemplateItem() != null) {
DCType[] types=DCType.findAll(context);
request.setAttribute("String_Node_Str",types);
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case DEFAULT_ITEM:
if (collection != null) {
Community[] communities=collection.getCommunities();
request.setAttribute("String_Node_Str",communities[0]);
}
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
}

Fixed version (ground truth):
/** 
 * Work out which page to show next, and show it
 * @param context
 * @param request
 * @param response
 * @param collection
 * @param stage  the stage the user just finished, or if PERMISSIONS, theparticular permissions page
 * @throws SQLException
 * @throws ServletException
 * @throws IOException
 * @throws AuthorizeException
 */
private void showNextPage(Context context,HttpServletRequest request,HttpServletResponse response,Collection collection,int stage) throws SQLException, ServletException, IOException, AuthorizeException {
  request.setAttribute("String_Node_Str",collection);
  if (Group.findByName(context,"String_Node_Str") != null) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + stage));
switch (stage) {
case BASIC_INFO:
    List anonReadPols=AuthorizeManager.getPoliciesActionFilter(context,collection,Constants.DEFAULT_ITEM_READ);
  if (anonReadPols.size() == 0) {
    request.setAttribute("String_Node_Str",new Integer(PERM_READ));
    JSPManager.showJSP(request,response,"String_Node_Str");
    break;
  }
case PERM_READ:
if (collection.getSubmitters() != null) {
  request.setAttribute("String_Node_Str",new Integer(PERM_SUBMIT));
  JSPManager.showJSP(request,response,"String_Node_Str");
  break;
}
case PERM_SUBMIT:
if (collection.getWorkflowGroup(1) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF1));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF1:
if (collection.getWorkflowGroup(2) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF2));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF2:
if (collection.getWorkflowGroup(3) != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_WF3));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_WF3:
if (collection.getAdministrators() != null) {
request.setAttribute("String_Node_Str",new Integer(PERM_ADMIN));
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case PERM_ADMIN:
if (collection.getTemplateItem() != null) {
DCType[] types=DCType.findAll(context);
request.setAttribute("String_Node_Str",types);
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
case DEFAULT_ITEM:
if (collection != null) {
Community[] communities=collection.getCommunities();
request.setAttribute("String_Node_Str",communities[0]);
if (AuthorizeManager.isAdmin(context)) {
request.setAttribute("String_Node_Str",new Boolean(true));
}
}
JSPManager.showJSP(request,response,"String_Node_Str");
break;
}
}