Program: 115134
Project: 115134
Buggy source:
@RequestMapping(value="String_Node_Str",method=RequestMethod.POST) public @ResponseBody Response validateAndSave(@RequestBody org.openclinica.ns.rules.v31.Rules rules,Model model,HttpSession session,@PathVariable("String_Node_Str") String studyOid,@RequestParam("String_Node_Str") Boolean ignoreDuplicates) throws Exception {
  ResourceBundleProvider.updateLocale(new Locale("String_Node_Str"));
  RulesPostImportContainer rpic=mapRulesToRulesPostImportContainer(rules);
  StudyDAO studyDao=new StudyDAO(dataSource);
  StudyBean currentStudy=studyDao.findByOid(studyOid);
  UserAccountBean userAccount=getUserAccount();
  mayProceed(userAccount,currentStudy);
  getRulePostImportContainerService(currentStudy,userAccount);
  rpic=getRulePostImportContainerService(currentStudy,userAccount).validateRuleDefs(rpic);
  rpic=getRulePostImportContainerService(currentStudy,userAccount).validateRuleSetDefs(rpic);
  Response response=new Response();
  response.setValid(Boolean.TRUE);
  if (rpic.getInValidRuleDefs().size() > 0 || rpic.getInValidRuleSetDefs().size() > 0) {
    response.setValid(Boolean.FALSE);
    for (    AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getInValidRuleDefs()) {
      for (      String error : beanWrapper.getImportErrors()) {
        org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
        messageType.setMessage(error);
        response.getMessages().add(messageType);
      }
    }
    for (    AuditableBeanWrapper<RuleSetBean> beanWrapper : rpic.getInValidRuleSetDefs()) {
      for (      String error : beanWrapper.getImportErrors()) {
        org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
        messageType.setMessage(error);
        response.getMessages().add(messageType);
      }
    }
  }
 else   if ((rpic.getDuplicateRuleDefs().size() > 0) && !ignoreDuplicates) {
    response.setValid(Boolean.FALSE);
    for (    AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getDuplicateRuleDefs()) {
      org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
      messageType.setMessage(DUPLICATE_MESSAGE);
      response.getMessages().add(messageType);
    }
  }
 else {
    getRuleSetService().saveImport(rpic);
  }
  logger.debug("String_Node_Str");
  return response;
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method=RequestMethod.POST) public @ResponseBody Response validateAndSave(@RequestBody org.openclinica.ns.rules.v31.Rules rules,Model model,HttpSession session,@PathVariable("String_Node_Str") String studyOid,@RequestParam("String_Node_Str") Boolean ignoreDuplicates) throws Exception {
  ResourceBundleProvider.updateLocale(new Locale("String_Node_Str"));
  RulesPostImportContainer rpic=mapRulesToRulesPostImportContainer(rules);
  StudyDAO studyDao=new StudyDAO(dataSource);
  StudyBean currentStudy=studyDao.findByOid(studyOid);
  UserAccountBean userAccount=getUserAccount();
  mayProceed(userAccount,currentStudy);
  getRulePostImportContainerService(currentStudy,userAccount);
  rpic=getRulePostImportContainerService(currentStudy,userAccount).validateRuleDefs(rpic);
  rpic=getRulePostImportContainerService(currentStudy,userAccount).validateRuleSetDefs(rpic);
  Response response=new Response();
  response.setValid(Boolean.TRUE);
  if (rpic.getInValidRuleDefs().size() > 0 || rpic.getInValidRuleSetDefs().size() > 0) {
    response.setValid(Boolean.FALSE);
    for (    AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getInValidRuleDefs()) {
      for (      String error : beanWrapper.getImportErrors()) {
        org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
        messageType.setMessage(error);
        response.getMessages().add(messageType);
      }
    }
    for (    AuditableBeanWrapper<RuleSetBean> beanWrapper : rpic.getInValidRuleSetDefs()) {
      for (      String error : beanWrapper.getImportErrors()) {
        org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
        messageType.setMessage(error);
        response.getMessages().add(messageType);
      }
    }
  }
 else   if ((rpic.getDuplicateRuleDefs().size() > 0) && !ignoreDuplicates) {
    response.setValid(Boolean.FALSE);
    for (    AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getDuplicateRuleDefs()) {
      org.openclinica.ns.response.v31.MessagesType messageType=new MessagesType();
      messageType.setMessage(DUPLICATE_MESSAGE);
      response.getMessages().add(messageType);
    }
  }
 else {
    getRuleSetService().saveImportFromDesigner(rpic);
  }
  logger.debug("String_Node_Str");
  return response;
}