Program: 115073
Project: 115073
Buggy source:
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_XML) public String doSubmission(@Context HttpServletRequest request,@Context HttpServletResponse response,@Context ServletContext servletContext,@PathParam("String_Node_Str") String studyOID,@QueryParam(FORM_CONTEXT) String context){
  String output=null;
  String studySubjectOid=null;
  Integer studyEventDefnId=null;
  Integer studyEventOrdinal=null;
  String crfVersionOID=null;
  CRFVersionDAO crfvdao=new CRFVersionDAO(dataSource);
  try {
    if (ServletFileUpload.isMultipartContent(request)) {
      LOGGER.warn("String_Node_Str");
    }
    PFormCache cache=PFormCache.getInstance(servletContext);
    HashMap<String,String> userContext=cache.getSubjectContext(context);
    StudySubjectDAO ssdao=new StudySubjectDAO<String,ArrayList>(dataSource);
    StudySubjectBean ssBean=ssdao.findByOid(userContext.get("String_Node_Str"));
    if (!mayProceedSubmission(studyOID,ssBean))     return null;
    studySubjectOid=userContext.get("String_Node_Str");
    studyEventDefnId=Integer.valueOf(userContext.get("String_Node_Str"));
    studyEventOrdinal=Integer.valueOf(userContext.get("String_Node_Str"));
    crfVersionOID=userContext.get("String_Node_Str");
    StringWriter writer=new StringWriter();
    String body=IOUtils.toString(request.getInputStream(),"String_Node_Str");
    body=body.substring(body.indexOf("String_Node_Str"));
    int length=body.indexOf("String_Node_Str");
    body=body.replace(body.substring(body.indexOf("String_Node_Str"),body.indexOf("String_Node_Str") + 7),"String_Node_Str");
    body=body.substring(0,body.indexOf("String_Node_Str") + length + 2);
    body="String_Node_Str" + body + "String_Node_Str";
    Errors errors=getPformSubmissionService().saveProcess(body,studySubjectOid,studyEventDefnId,studyEventOrdinal);
    Calendar cal=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
    Date currentDate=new Date();
    cal.setTime(currentDate);
    SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
    format.setCalendar(cal);
    response.setHeader("String_Node_Str",format.format(currentDate));
    response.setHeader("String_Node_Str","String_Node_Str");
    response.setContentType("String_Node_Str");
    response.setStatus(201);
    if (!errors.hasErrors()) {
      output="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      LOGGER.debug("String_Node_Str");
    }
 else {
      LOGGER.error("String_Node_Str");
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      response.flushBuffer();
    }
  }
 catch (  Exception e) {
    LOGGER.error(e.getMessage());
    LOGGER.error(ExceptionUtils.getStackTrace(e));
    return "String_Node_Str" + e.getMessage() + "String_Node_Str";
  }
  try {
    String pManageUrl=CoreResources.getField("String_Node_Str") + "String_Node_Str";
    Submission submission=new Submission();
    Study pManageStudy=new Study();
    pManageStudy.setInstanceUrl(CoreResources.getField("String_Node_Str") + "String_Node_Str" + studyOID);
    pManageStudy.setStudyOid(studyOID);
    submission.setStudy(pManageStudy);
    submission.setStudy_event_def_id(studyEventDefnId);
    submission.setStudy_event_def_ordinal(studyEventOrdinal);
    submission.setCrf_version_id(crfvdao.findByOid(crfVersionOID).getId());
    RestTemplate rest=new RestTemplate();
    String result=rest.postForObject(pManageUrl,submission,String.class);
    LOGGER.debug("String_Node_Str" + result);
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str");
    LOGGER.error(e.getMessage());
    LOGGER.error(ExceptionUtils.getStackTrace(e));
  }
  return output;
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_XML) public String doSubmission(@Context HttpServletRequest request,@Context HttpServletResponse response,@Context ServletContext servletContext,@PathParam("String_Node_Str") String studyOID,@QueryParam(FORM_CONTEXT) String context){
  String output=null;
  String studySubjectOid=null;
  Integer studyEventDefnId=null;
  Integer studyEventOrdinal=null;
  String crfVersionOID=null;
  CRFVersionDAO crfvdao=new CRFVersionDAO(dataSource);
  try {
    if (ServletFileUpload.isMultipartContent(request)) {
      LOGGER.warn("String_Node_Str");
    }
    if (!mayProceedSubmission(studyOID))     return null;
    PFormCache cache=PFormCache.getInstance(servletContext);
    HashMap<String,String> userContext=cache.getSubjectContext(context);
    StudySubjectDAO ssdao=new StudySubjectDAO<String,ArrayList>(dataSource);
    StudySubjectBean ssBean=ssdao.findByOid(userContext.get("String_Node_Str"));
    if (!mayProceedSubmission(studyOID,ssBean))     return null;
    studySubjectOid=userContext.get("String_Node_Str");
    studyEventDefnId=Integer.valueOf(userContext.get("String_Node_Str"));
    studyEventOrdinal=Integer.valueOf(userContext.get("String_Node_Str"));
    crfVersionOID=userContext.get("String_Node_Str");
    StringWriter writer=new StringWriter();
    String body=IOUtils.toString(request.getInputStream(),"String_Node_Str");
    body=body.substring(body.indexOf("String_Node_Str"));
    int length=body.indexOf("String_Node_Str");
    body=body.replace(body.substring(body.indexOf("String_Node_Str"),body.indexOf("String_Node_Str") + 7),"String_Node_Str");
    body=body.substring(0,body.indexOf("String_Node_Str") + length + 2);
    body="String_Node_Str" + body + "String_Node_Str";
    Errors errors=getPformSubmissionService().saveProcess(body,studySubjectOid,studyEventDefnId,studyEventOrdinal);
    Calendar cal=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
    Date currentDate=new Date();
    cal.setTime(currentDate);
    SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
    format.setCalendar(cal);
    response.setHeader("String_Node_Str",format.format(currentDate));
    response.setHeader("String_Node_Str","String_Node_Str");
    response.setContentType("String_Node_Str");
    response.setStatus(201);
    if (!errors.hasErrors()) {
      output="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      LOGGER.debug("String_Node_Str");
    }
 else {
      LOGGER.error("String_Node_Str");
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      response.flushBuffer();
    }
  }
 catch (  Exception e) {
    LOGGER.error(e.getMessage());
    LOGGER.error(ExceptionUtils.getStackTrace(e));
    return "String_Node_Str" + e.getMessage() + "String_Node_Str";
  }
  try {
    String pManageUrl=CoreResources.getField("String_Node_Str") + "String_Node_Str";
    Submission submission=new Submission();
    Study pManageStudy=new Study();
    pManageStudy.setInstanceUrl(CoreResources.getField("String_Node_Str") + "String_Node_Str" + studyOID);
    pManageStudy.setStudyOid(studyOID);
    submission.setStudy(pManageStudy);
    submission.setStudy_event_def_id(studyEventDefnId);
    submission.setStudy_event_def_ordinal(studyEventOrdinal);
    submission.setCrf_version_id(crfvdao.findByOid(crfVersionOID).getId());
    RestTemplate rest=new RestTemplate();
    String result=rest.postForObject(pManageUrl,submission,String.class);
    LOGGER.debug("String_Node_Str" + result);
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str");
    LOGGER.error(e.getMessage());
    LOGGER.error(ExceptionUtils.getStackTrace(e));
  }
  return output;
}