nus-yam/ex-repair huggingface dataset:
Program: 189312
Project: 189312
Buggy source:
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (duration == null && duration == this.duration)   return;
 else   if (duration.equals(this.duration))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.duration=duration;
}

Fixed version (ground truth):
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (duration == null && duration == this.duration)   return;
 else   if (duration == null && duration != this.duration) {
  }
 else   if (duration.equals(this.duration))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.duration=duration;
}
Program: 189314
Project: 189314
Buggy source:
private void createData(){
  adminGroup=(JpaAdministrativeGroupImpl)settingRepo.createAdministrativeGroup("String_Node_Str");
  adminGroup.addEmail("String_Node_Str");
  adminGroup.addEmail("String_Node_Str");
  adminGroup.setDisplayOrder(0);
  adminGroup.save();
  Map<String,State> stateBeanMap=Spring.getBeansOfType(State.class);
  for (  String key : stateBeanMap.keySet()) {
    State state=stateBeanMap.get(key);
    if (state != null) {
      JpaEmailWorkflowRuleImpl rule=(JpaEmailWorkflowRuleImpl)settingRepo.createEmailWorkflowRule(state);
      JpaEmailWorkflowRuleConditionImpl condition=(JpaEmailWorkflowRuleConditionImpl)settingRepo.createEmailWorkflowRuleCondition(ConditionType.Always);
      condition.save();
      rule.setCondition(condition);
      JpaEmailTemplateImpl emailTemplate=(JpaEmailTemplateImpl)settingRepo.findEmailTemplateByName("String_Node_Str");
      rule.setEmailTemplate(emailTemplate);
      rule.setRecipientType(RecipientType.AdminGroup);
      rule.setAdminGroupRecipient(adminGroup);
      rule.save();
      rules.add(rule);
    }
  }
  JPA.em().getTransaction().commit();
  JPA.em().clear();
  JPA.em().getTransaction().begin();
}

Fixed version (ground truth):
private void createData(){
  adminGroup=(JpaAdministrativeGroupImpl)settingRepo.createAdministrativeGroup("String_Node_Str");
  adminGroup.addEmail("String_Node_Str");
  adminGroup.addEmail("String_Node_Str");
  adminGroup.setDisplayOrder(0);
  adminGroup.save();
  Map<String,State> stateBeanMap=Spring.getBeansOfType(State.class);
  for (  String key : stateBeanMap.keySet()) {
    State state=stateBeanMap.get(key);
    if (state != null && EmailRuleService.doesStateMatchEWFLRuleStates(state)) {
      JpaEmailWorkflowRuleImpl rule=(JpaEmailWorkflowRuleImpl)settingRepo.createEmailWorkflowRule(state);
      JpaEmailWorkflowRuleConditionImpl condition=(JpaEmailWorkflowRuleConditionImpl)settingRepo.createEmailWorkflowRuleCondition(ConditionType.Always);
      condition.save();
      rule.setCondition(condition);
      JpaEmailTemplateImpl emailTemplate=(JpaEmailTemplateImpl)settingRepo.findEmailTemplateByName("String_Node_Str");
      rule.setEmailTemplate(emailTemplate);
      rule.setRecipientType(RecipientType.AdminGroup);
      rule.setAdminGroupRecipient(adminGroup);
      rule.enable();
      rule.save();
      rules.add(rule);
    }
  }
  JPA.em().getTransaction().commit();
  JPA.em().clear();
  JPA.em().getTransaction().begin();
}
Program: 189315
Project: 189315
Buggy source:
@Test public void testRunEmailRules() throws InterruptedException {
  Iterator<Submission> subIterator=subRepo.findAllSubmissions();
  while (subIterator.hasNext()) {
    Submission submission=subIterator.next();
    play.Logger.info("String_Node_Str",submission.getId());
    EmailRuleService.runEmailRules(submission);
    String emailContent=null;
    for (int i=0; i < 50; i++) {
      Thread.yield();
      Thread.sleep(100);
      emailContent=Mail.Mock.getLastMessageReceivedBy(adminGroup.getEmails().get(0));
      if (emailContent != null)       break;
    }
    assertNotNull(emailContent);
  }
}

Fixed version (ground truth):
@Test public void testRunEmailRules() throws InterruptedException {
  Iterator<Submission> subIterator=subRepo.findAllSubmissions();
  while (subIterator.hasNext()) {
    Submission submission=subIterator.next();
    play.Logger.info("String_Node_Str",submission.getId());
    EmailRuleService.runEmailRules(submission);
    String emailContent=null;
    for (int i=0; i < 50; i++) {
      Thread.yield();
      Thread.sleep(100);
      emailContent=Mail.Mock.getLastMessageReceivedBy(adminGroup.getEmails().get(0));
      if (emailContent != null)       break;
    }
    if (EmailRuleService.doesSubStateMatchEWFLRuleStates(submission)) {
      assertNotNull(emailContent);
    }
 else {
      assertNull(emailContent);
    }
    Mail.Mock.reset();
  }
}
Program: 189316
Project: 189316
Buggy source:
/** 
 * Convert plain text into passable HTML. Separate text into paragraphs, preserve intending, and try not to mess with any embedded tags.
 * @param value The input text.
 * @return HTML suitable for display.
 */
protected static String text2html(String value){
  String html=value.replaceAll("String_Node_Str","String_Node_Str");
  String[] paragraphs=html.split("String_Node_Str");
  html="String_Node_Str";
  for (  String paragraph : paragraphs) {
    html+="String_Node_Str" + paragraph + "String_Node_Str";
  }
  html=html.replaceAll("String_Node_Str","String_Node_Str");
  return html;
}

Fixed version (ground truth):
/** 
 * Convert plain text into passable HTML. Separate text into paragraphs, preserve intending, and try not to mess with any embedded tags.
 * @param value The input text.
 * @return HTML suitable for display.
 */
protected static String text2html(String value){
  if (value == null)   value="String_Node_Str";
  String html=value.replaceAll("String_Node_Str","String_Node_Str");
  String[] paragraphs=html.split("String_Node_Str");
  html="String_Node_Str";
  for (  String paragraph : paragraphs) {
    html+="String_Node_Str" + paragraph + "String_Node_Str";
  }
  html=html.replaceAll("String_Node_Str","String_Node_Str");
  return html;
}
Program: 189321
Project: 189321
Buggy source:
public void doJob(){
  SettingsRepository settingRepo=Spring.getBeanOfType(SettingsRepository.class);
  try {
    context.turnOffAuthorization();
    List<EmbargoType> embargoTypes=settingRepo.findAllEmbargoTypes();
    for (    EmbargoArray embargoDefinition : EMBARGO_DEFINTITIONS) {
      boolean found=false;
      for (      EmbargoType installedEmbargo : embargoTypes) {
        if (installedEmbargo.getName().equals(embargoDefinition.name)) {
          found=true;
          installedEmbargo.setSystemRequired(true);
          installedEmbargo.save();
        }
      }
      if (!found) {
        settingRepo.createEmbargoType(embargoDefinition.name,embargoDefinition.description,embargoDefinition.duration,embargoDefinition.active,embargoDefinition.guarantor).save();
      }
    }
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
  }
 finally {
    context.restoreAuthorization();
  }
}

Fixed version (ground truth):
public void doJob(){
  SettingsRepository settingRepo=Spring.getBeanOfType(SettingsRepository.class);
  try {
    context.turnOffAuthorization();
    List<EmbargoType> embargoTypes=settingRepo.findAllEmbargoTypes();
    for (    EmbargoArray embargoDefinition : EMBARGO_DEFINTITIONS) {
      boolean found=false;
      for (      EmbargoType installedEmbargo : embargoTypes) {
        if (installedEmbargo.getName().equals(embargoDefinition.name)) {
          found=true;
          installedEmbargo.setSystemRequired(true);
          installedEmbargo.save();
        }
      }
      if (!found) {
        EmbargoType newembargo=settingRepo.createEmbargoType(embargoDefinition.name,embargoDefinition.description,embargoDefinition.duration,embargoDefinition.active,embargoDefinition.guarantor);
        newembargo.setSystemRequired(true);
        newembargo.save();
      }
    }
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
  }
 finally {
    context.restoreAuthorization();
  }
}
Program: 189322
Project: 189322
Buggy source:
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  this.duration=duration;
}

Fixed version (ground truth):
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (duration.equals(this.duration))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.duration=duration;
}
Program: 189323
Project: 189323
Buggy source:
@Override public void setDescription(String description){
  if (description == null || description.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  this.description=description;
}

Fixed version (ground truth):
@Override public void setDescription(String description){
  if (description == null || description.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (description.equals(this.description))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.description=description;
}
Program: 189324
Project: 189324
Buggy source:
public void setGuarantor(EmbargoGuarantor guarantor){
  this.guarantor=guarantor;
}

Fixed version (ground truth):
public void setGuarantor(EmbargoGuarantor guarantor){
  assertManager();
  if (guarantor.equals(this.guarantor))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.guarantor=guarantor;
}
Program: 189328
Project: 189328
Buggy source:
/** 
 * Set the from address
 * @param address The address
 */
private void setFrom(InternetAddress address){
  _from=validateAddress(address);
}

Fixed version (ground truth):
/** 
 * Set the from address
 * @param address The address
 */
@Override public void setFrom(InternetAddress address){
  _from=validateAddress(address);
}
Program: 189329
Project: 189329
Buggy source:
@Override public String getSuccessLogMessage(){
  if (logSuccessMessage != null) {
    return logSuccessMessage;
  }
  String TOrecipients="String_Node_Str";
  for (  InternetAddress address : to) {
    if (TOrecipients.length() != 0)     TOrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     TOrecipients+=address.getPersonal();
 else     TOrecipients+=address.getAddress();
  }
  String CCrecipients="String_Node_Str";
  for (  InternetAddress address : cc) {
    if (CCrecipients.length() != 0)     CCrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     CCrecipients+=address.getPersonal();
 else     CCrecipients+=address.getAddress();
  }
  return String.format("String_Node_Str",TOrecipients,CCrecipients,subject,message);
}

Fixed version (ground truth):
@Override public String getSuccessLogMessage(){
  if (logSuccessMessage != null) {
    return logSuccessMessage;
  }
  String TOrecipients="String_Node_Str";
  for (  InternetAddress address : to) {
    if (TOrecipients.length() != 0)     TOrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     TOrecipients+=address.getPersonal();
 else     TOrecipients+=address.getAddress();
  }
  String CCrecipients="String_Node_Str";
  for (  InternetAddress address : cc) {
    if (CCrecipients.length() != 0)     CCrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     CCrecipients+=address.getPersonal();
 else     CCrecipients+=address.getAddress();
  }
  String ccString="String_Node_Str";
  if (CCrecipients.length() > 0) {
    ccString=String.format("String_Node_Str",CCrecipients);
  }
  return String.format("String_Node_Str" + ccString + "String_Node_Str",TOrecipients,subject,message);
}
Program: 189333
Project: 189333
Buggy source:
/** 
 * Test that an advisor can approve of the application & embargo
 */
@Test public void testAccepting(){
  LOGIN("String_Node_Str");
  Map<String,Object> routeArgs=new HashMap<String,Object>();
  routeArgs.put("String_Node_Str",token);
  final String ADVISOR_URL=Router.reverse("String_Node_Str",routeArgs).url;
  Response response=GET(ADVISOR_URL);
  assertIsOk(response);
  assertContentMatch("String_Node_Str",response);
  Map<String,String> params=new HashMap<String,String>();
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  response=POST(ADVISOR_URL,params);
  assertIsOk(response);
  assertContentMatch("String_Node_Str",response);
  assertFalse(getContent(response).contains("String_Node_Str"));
  assertFalse(getContent(response).contains("String_Node_Str"));
  JPA.em().getTransaction().commit();
  JPA.em().clear();
  JPA.em().getTransaction().begin();
  sub=subRepo.findSubmission(sub.getId());
  advisor=personRepo.findPerson(advisor.getId());
  assertNotNull(sub.getCommitteeApprovalDate());
  assertNotNull(sub.getCommitteeEmbargoApprovalDate());
  List<ActionLog> logs=subRepo.findActionLog(sub);
  boolean foundLog=false;
  for (  ActionLog log : logs) {
    if (log.getEntry().contains("String_Node_Str")) {
      foundLog=true;
      assertEquals(advisor,log.getPerson());
    }
  }
  assertTrue(foundLog);
}

Fixed version (ground truth):
/** 
 * Test that an advisor can approve of the application & embargo
 */
@Test public void testAccepting(){
  LOGIN("String_Node_Str");
  Map<String,Object> routeArgs=new HashMap<String,Object>();
  routeArgs.put("String_Node_Str",token);
  final String ADVISOR_URL=Router.reverse("String_Node_Str",routeArgs).url;
  Response response=GET(ADVISOR_URL);
  assertIsOk(response);
  assertContentMatch("String_Node_Str",response);
  Map<String,String> params=new HashMap<String,String>();
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  response=POST(ADVISOR_URL,params);
  assertIsOk(response);
  assertContentMatch("String_Node_Str",response);
  assertContentMatch("String_Node_Str",response);
  assertContentMatch("String_Node_Str",response);
  JPA.em().getTransaction().commit();
  JPA.em().clear();
  JPA.em().getTransaction().begin();
  sub=subRepo.findSubmission(sub.getId());
  advisor=personRepo.findPerson(advisor.getId());
  assertNotNull(sub.getCommitteeApprovalDate());
  assertNotNull(sub.getCommitteeEmbargoApprovalDate());
  List<ActionLog> logs=subRepo.findActionLog(sub);
  boolean foundLog=false;
  for (  ActionLog log : logs) {
    if (log.getEntry().contains("String_Node_Str")) {
      foundLog=true;
      assertEquals(advisor,log.getPerson());
    }
  }
  assertTrue(foundLog);
}
Program: 189335
Project: 189335
Buggy source:
/** 
 * Setup before running any tests, clear out the job queue, and create a test person.
 */
@Before public void setup() throws InterruptedException {
  indexer.rebuild(true);
  assertFalse(indexer.isJobRunning());
  context.login(MockPerson.getAdministrator());
  person=personRepo.createPerson("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",RoleType.NONE).save();
}

Fixed version (ground truth):
/** 
 * Setup before running any tests, clear out the job queue, and create a test person.
 */
@Before public void setup() throws InterruptedException {
  indexer.rebuild(true);
  assertFalse(indexer.isJobRunning());
  context.login(MockPerson.getAdministrator());
  person=personRepo.createPerson("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",RoleType.NONE);
  person.setOrcid("String_Node_Str");
  person.save();
}
Program: 189337
Project: 189337
Buggy source:
public void doJob(SettingsRepository settingRepo){
  try {
    context.turnOffAuthorization();
    List<EmbargoType> embargoTypes=settingRepo.findAllEmbargoTypes();
    for (    EmbargoArray embargoDefinition : EMBARGO_DEFINTITIONS) {
      boolean found=false;
      for (      EmbargoType installedEmbargo : embargoTypes) {
        if (installedEmbargo.getName().equals(embargoDefinition.name)) {
          found=true;
        }
      }
      if (!found) {
        settingRepo.createEmbargoType(embargoDefinition.name,embargoDefinition.description,embargoDefinition.duration,embargoDefinition.active,embargoDefinition.guarantor).save();
      }
    }
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
  }
 finally {
    context.restoreAuthorization();
  }
}

Fixed version (ground truth):
public void doJob(){
  SettingsRepository settingRepo=Spring.getBeanOfType(SettingsRepository.class);
  try {
    context.turnOffAuthorization();
    List<EmbargoType> embargoTypes=settingRepo.findAllEmbargoTypes();
    for (    EmbargoArray embargoDefinition : EMBARGO_DEFINTITIONS) {
      boolean found=false;
      for (      EmbargoType installedEmbargo : embargoTypes) {
        if (installedEmbargo.getName().equals(embargoDefinition.name)) {
          found=true;
          installedEmbargo.setSystemRequired(true);
          installedEmbargo.save();
        }
      }
      if (!found) {
        settingRepo.createEmbargoType(embargoDefinition.name,embargoDefinition.description,embargoDefinition.duration,embargoDefinition.active,embargoDefinition.guarantor).save();
      }
    }
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
  }
 finally {
    context.restoreAuthorization();
  }
}
Program: 189339
Project: 189339
Buggy source:
/** 
 * Remove an existing embargo type.
 * @param embargoId The id of the embargo type to be removed.
 */
@Security(RoleType.MANAGER) public static void removeEmbargoTypeJSON(String embargoTypeId){
  try {
    String[] parts=embargoTypeId.split("String_Node_Str");
    Long id=Long.valueOf(parts[1]);
    EmbargoType embargo=settingRepo.findEmbargoType(id);
    embargo.delete();
    Logger.info("String_Node_Str",context.getPerson().getFormattedName(NameFormat.FIRST_LAST),context.getPerson().getId(),context.getPerson().getEmail(),embargo.getId(),embargo.getName(),embargo.getDescription(),embargo.getDuration(),embargo.isActive(),embargo.getGuarantor());
    renderJSON("String_Node_Str");
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
    String message=escapeJavaScript(re.getMessage());
    renderJSON("String_Node_Str" + message + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Remove an existing embargo type.
 * @param embargoId The id of the embargo type to be removed.
 */
@Security(RoleType.MANAGER) public static void removeEmbargoTypeJSON(String embargoTypeId){
  try {
    Long id=Long.valueOf(embargoTypeId);
    EmbargoType embargo=settingRepo.findEmbargoType(id);
    embargo.delete();
    Logger.info("String_Node_Str",context.getPerson().getFormattedName(NameFormat.FIRST_LAST),context.getPerson().getId(),context.getPerson().getEmail(),embargo.getId(),embargo.getName(),embargo.getDescription(),embargo.getDuration(),embargo.isActive(),embargo.getGuarantor());
    renderJSON("String_Node_Str");
  }
 catch (  RuntimeException re) {
    Logger.error(re,"String_Node_Str");
    String message=escapeJavaScript(re.getMessage());
    renderJSON("String_Node_Str" + message + "String_Node_Str");
  }
}
Program: 189340
Project: 189340
Buggy source:
/** 
 * Remove all existing embargo types.
 */
@Security(RoleType.MANAGER) public static void removeAllEmbargoTypes(){
  List<EmbargoType> embargos=settingRepo.findAllEmbargoTypes();
  for (  EmbargoType embargo : embargos) {
    embargo.delete();
    Logger.info("String_Node_Str",context.getPerson().getFormattedName(NameFormat.FIRST_LAST),context.getPerson().getId(),context.getPerson().getEmail(),embargo.getId(),embargo.getName(),embargo.getDescription(),embargo.getDuration(),embargo.isActive());
  }
  flash.put("String_Node_Str","String_Node_Str");
  configurableSettings();
}

Fixed version (ground truth):
/** 
 * Remove all existing embargo types.
 */
@Security(RoleType.MANAGER) public static void removeAllEmbargoTypes(){
  List<EmbargoType> embargos=settingRepo.findAllEmbargoTypes();
  for (  EmbargoType embargo : embargos) {
    if (!embargo.isSystemRequired()) {
      embargo.delete();
      Logger.info("String_Node_Str",context.getPerson().getFormattedName(NameFormat.FIRST_LAST),context.getPerson().getId(),context.getPerson().getEmail(),embargo.getId(),embargo.getName(),embargo.getDescription(),embargo.getDuration(),embargo.isActive());
    }
  }
  flash.put("String_Node_Str","String_Node_Str");
  configurableSettings();
}
Program: 189341
Project: 189341
Buggy source:
@Override public void setName(String name){
  if (name == null || name.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  this.name=name;
}

Fixed version (ground truth):
@Override public void setName(String name){
  if (name == null || name.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (name.equals(this.name))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + this.name + "String_Node_Str");
  this.name=name;
}
Program: 189342
Project: 189342
Buggy source:
@Override public JpaEmbargoTypeImpl delete(){
  assertManager();
  List<Long> effectedIds=new ArrayList<Long>();
  for (  Submission sub : getSubmissions()) {
    effectedIds.add(sub.getId());
    sub.removeEmbargoType(this);
  }
  Logger.info("String_Node_Str" + effectedIds.size());
  Indexer indexer=Spring.getBeanOfType(Indexer.class);
  indexer.updated(effectedIds);
  return super.delete();
}

Fixed version (ground truth):
@Override public JpaEmbargoTypeImpl delete(){
  assertManager();
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  List<Long> effectedIds=new ArrayList<Long>();
  for (  Submission sub : getSubmissions()) {
    effectedIds.add(sub.getId());
    sub.removeEmbargoType(this);
  }
  Logger.info("String_Node_Str" + effectedIds.size());
  Indexer indexer=Spring.getBeanOfType(Indexer.class);
  indexer.updated(effectedIds);
  return super.delete();
}
Program: 189343
Project: 189343
Buggy source:
/** 
 * Create a new JpaEmbargoTypeImpl.
 * @param name The unique name of the embargo
 * @param description The description of the embargo.
 * @param duration The duration of the embargo, or null, may not be negative
 * @param active Weather the embargo is active.
 */
protected JpaEmbargoTypeImpl(String name,String description,Integer duration,boolean active,EmbargoGuarantor guarantor){
  if (name == null || name.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (description == null || description.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  this.displayOrder=0;
  this.name=name;
  this.description=description;
  this.duration=duration;
  this.active=active;
  if (guarantor == null)   this.guarantor=EmbargoGuarantor.DEFAULT;
 else   this.guarantor=guarantor;
}

Fixed version (ground truth):
/** 
 * Create a new JpaEmbargoTypeImpl.
 * @param name The unique name of the embargo
 * @param description The description of the embargo.
 * @param duration The duration of the embargo, or null, may not be negative
 * @param active Weather the embargo is active.
 */
protected JpaEmbargoTypeImpl(String name,String description,Integer duration,boolean active,EmbargoGuarantor guarantor){
  if (name == null || name.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (description == null || description.length() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  this.systemRequired=false;
  this.displayOrder=0;
  this.name=name;
  this.description=description;
  this.duration=duration;
  this.active=active;
  if (guarantor == null)   this.guarantor=EmbargoGuarantor.DEFAULT;
 else   this.guarantor=guarantor;
}
Program: 189344
Project: 189344
Buggy source:
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (duration.equals(this.duration))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.duration=duration;
}

Fixed version (ground truth):
@Override public void setDuration(Integer duration){
  if (duration != null && duration < 0)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (duration == null && duration == this.duration)   return;
 else   if (duration.equals(this.duration))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.duration=duration;
}
Program: 189345
Project: 189345
Buggy source:
public void setGuarantor(EmbargoGuarantor guarantor){
  assertManager();
  if (guarantor.equals(this.guarantor))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.guarantor=guarantor;
}

Fixed version (ground truth):
public void setGuarantor(EmbargoGuarantor guarantor){
  if (guarantor == null)   throw new IllegalArgumentException("String_Node_Str");
  assertManager();
  if (guarantor.equals(this.guarantor))   return;
  if (isSystemRequired())   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str");
  this.guarantor=guarantor;
}
Program: 189347
Project: 189347
Buggy source:
@Override public List<String> getRecipients(Submission submission){
  return EmailByRecipientType.getRecipients(submission,recipientType);
}

Fixed version (ground truth):
@Override public List<String> getRecipients(Submission submission){
  return EmailByRecipientType.getRecipients(submission,recipientType,this);
}
Program: 189352
Project: 189352
Buggy source:
@Override public String getSuccessLogMessage(){
  if (logSuccessMessage != null) {
    return logSuccessMessage;
  }
  String recipients="String_Node_Str";
  for (  InternetAddress address : to) {
    if (recipients.length() != 0)     recipients+="String_Node_Str";
    if (address.getPersonal() != null)     recipients+=address.getPersonal();
 else     recipients+=address.getAddress();
  }
  return String.format("String_Node_Str",recipients,subject,message);
}

Fixed version (ground truth):
@Override public String getSuccessLogMessage(){
  if (logSuccessMessage != null) {
    return logSuccessMessage;
  }
  String TOrecipients="String_Node_Str";
  for (  InternetAddress address : to) {
    if (TOrecipients.length() != 0)     TOrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     TOrecipients+=address.getPersonal();
 else     TOrecipients+=address.getAddress();
  }
  String CCrecipients="String_Node_Str";
  for (  InternetAddress address : cc) {
    if (CCrecipients.length() != 0)     CCrecipients+="String_Node_Str";
    if (address.getPersonal() != null)     CCrecipients+=address.getPersonal();
 else     CCrecipients+=address.getAddress();
  }
  return String.format("String_Node_Str",TOrecipients,CCrecipients,subject,message);
}
Program: 189353
Project: 189353
Buggy source:
/** 
 * Construct a new vireo email impl. This should only be called by spring.
 * @param context The security context.
 * @param personRepo The person repository.
 * @param subRepo The submisison repository.
 */
protected VireoEmailImpl(SecurityContext context,PersonRepository personRepo,SubmissionRepository subRepo,SettingsRepository settingRepo){
  this.settingRepo=settingRepo;
  this.personRepo=personRepo;
  this.subRepo=subRepo;
  this.setFrom(Play.configuration.getProperty("String_Node_Str"));
  this.setReplyTo(Play.configuration.getProperty("String_Node_Str"));
  Person person=context.getPerson();
  if (person != null && person.getPreference(AppPref.CC_EMAILS) != null) {
    String email=person.getEmail();
    if (person.getCurrentEmailAddress() != null)     email=person.getCurrentEmailAddress();
    this.addCc(email,person.getFormattedName(NameFormat.LAST_FIRST));
  }
}

Fixed version (ground truth):
/** 
 * Construct a new vireo email impl. This should only be called by spring.
 * @param context The security context.
 * @param personRepo The person repository.
 * @param subRepo The submisison repository.
 */
protected VireoEmailImpl(SecurityContext context,PersonRepository personRepo,SubmissionRepository subRepo,SettingsRepository settingRepo){
  this.settingRepo=settingRepo;
  this.personRepo=personRepo;
  this.subRepo=subRepo;
  this.setFrom(settingRepo.getConfigValue(AppConfig.EMAIL_FROM));
  this.setReplyTo(settingRepo.getConfigValue(AppConfig.EMAIL_REPLY_TO));
  Person person=context.getPerson();
  if (person != null && person.getPreference(AppPref.CC_EMAILS) != null) {
    String email=person.getEmail();
    if (person.getCurrentEmailAddress() != null)     email=person.getCurrentEmailAddress();
    this.addCc(email,person.getFormattedName(NameFormat.LAST_FIRST));
  }
}
Program: 189359
Project: 189359
Buggy source:
public void setBaseDirectory(String path){
  this.baseDir=new File(path);
}

Fixed version (ground truth):
public void setBaseDirectory(String path){
  this.baseDir=new File(Play.applicationPath + File.separator + path);
}
Program: 189361
Project: 189361
Buggy source:
public static File getStore(){
  String name=Play.configuration.getProperty("String_Node_Str","String_Node_Str");
  File store=null;
  if (new File(name).isAbsolute()) {
    store=new File(name);
  }
 else {
    store=Play.getFile(name);
  }
  if (!store.exists()) {
    store.mkdirs();
  }
  return store;
}

Fixed version (ground truth):
public static File getStore(){
  String name=Play.applicationPath + File.separator + Play.configuration.getProperty("String_Node_Str","String_Node_Str");
  File store=null;
  if (new File(name).isAbsolute()) {
    store=new File(name);
  }
 else {
    store=Play.getFile(name);
  }
  if (!store.exists()) {
    store.mkdirs();
  }
  return store;
}
Program: 189362
Project: 189362
Buggy source:
/** 
 * Construct a new LuceneIndexer
 */
public LuceneIndexerImpl() throws IOException {
  indexFile=new File(Play.configuration.getProperty("String_Node_Str","String_Node_Str"));
  index=FSDirectory.open(indexFile);
}

Fixed version (ground truth):
/** 
 * Construct a new LuceneIndexer
 */
public LuceneIndexerImpl() throws IOException {
  indexFile=new File(Play.applicationPath + File.separator + Play.configuration.getProperty("String_Node_Str","String_Node_Str"));
  index=FSDirectory.open(indexFile);
}
Program: 189364
Project: 189364
Buggy source:
@Override public JpaEmailWorkflowRuleConditionImpl save(){
  assertManager();
  JpaEmailWorkflowRuleConditionImpl ret;
  if (this.getId() == null) {
    ret=super.save();
    ret.setDisplayOrder(Integer.parseInt(String.valueOf(ret.getId())));
  }
 else {
    if (this.getDisplayOrder() != this.getId()) {
      this.setDisplayOrder(Integer.parseInt(String.valueOf(this.getId())));
    }
  }
  ret=super.save();
  return ret;
}

Fixed version (ground truth):
@Override public JpaEmailWorkflowRuleConditionImpl save(){
  assertManager();
  JpaEmailWorkflowRuleConditionImpl ret;
  if (this.getId() == null) {
    ret=super.save();
    ret.setDisplayOrder(Integer.parseInt(String.valueOf(ret.getId())));
  }
  ret=super.save();
  return ret;
}
Program: 189365
Project: 189365
Buggy source:
@Override public JpaEmailWorkflowRuleImpl save(){
  assertManager();
  JpaEmailWorkflowRuleImpl ret;
  if (this.getId() == null) {
    ret=super.save();
    ret.setDisplayOrder(Integer.parseInt(String.valueOf(ret.getId())));
  }
 else {
    if (this.getDisplayOrder() != this.getId()) {
      this.setDisplayOrder(Integer.parseInt(String.valueOf(this.getId())));
    }
  }
  ret=super.save();
  return ret;
}

Fixed version (ground truth):
@Override public JpaEmailWorkflowRuleImpl save(){
  assertManager();
  JpaEmailWorkflowRuleImpl ret;
  if (this.getId() == null) {
    ret=super.save();
    ret.setDisplayOrder(Integer.parseInt(String.valueOf(ret.getId())));
  }
  ret=super.save();
  return ret;
}
Program: 189367
Project: 189367
Buggy source:
/** 
 * This will generate and send the email to the right recipients from the rule
 * @param workflowEmailRule - the workflow email rule
 * @param submission - the submission
 */
private static void sendEmail(WorkflowEmailRule workflowEmailRule,Submission submission){
  EmailService emailService=Spring.getBeanOfType(EmailService.class);
  VireoEmail email=createEmail(emailService,workflowEmailRule,submission);
  emailService.sendEmail(email,false);
}

Fixed version (ground truth):
/** 
 * This will generate and send the email to the right recipients from the rule
 * @param workflowEmailRule - the workflow email rule
 * @param submission - the submission
 */
private static void sendEmail(WorkflowEmailRule workflowEmailRule,Submission submission){
  EmailService emailService=Spring.getBeanOfType(EmailService.class);
  VireoEmail email=createEmail(emailService,workflowEmailRule,submission);
  emailService.sendEmail(email,true);
}
Program: 189368
Project: 189368
Buggy source:
/** 
 * This will generate a VireoEmail from the right recipients from the rule
 * @param emailService - the emailService from Spring
 * @param workflowEmailRule - the workflow email rule
 * @param submission - the submission
 * @return - a new VireoEmail with the correct email template and recipients
 */
private static VireoEmail createEmail(EmailService emailService,WorkflowEmailRule workflowEmailRule,Submission submission){
  List<String> recipients=workflowEmailRule.getRecipients(submission);
  VireoEmail vireoEmail=emailService.createEmail();
  for (  String email : recipients) {
    vireoEmail.addTo(email);
  }
  vireoEmail.setTemplate(workflowEmailRule.getEmailTemplate());
  return vireoEmail;
}

Fixed version (ground truth):
/** 
 * This will generate a VireoEmail from the right recipients from the rule
 * @param emailService - the emailService from Spring
 * @param workflowEmailRule - the workflow email rule
 * @param submission - the submission
 * @return - a new VireoEmail with the correct email template and recipients
 */
private static VireoEmail createEmail(EmailService emailService,WorkflowEmailRule workflowEmailRule,Submission submission){
  List<String> recipients=workflowEmailRule.getRecipients(submission);
  VireoEmail vireoEmail=emailService.createEmail();
  for (  String email : recipients) {
    vireoEmail.addTo(email);
  }
  vireoEmail.setTemplate(workflowEmailRule.getEmailTemplate());
  vireoEmail.addParameters(submission);
  return vireoEmail;
}
Program: 189370
Project: 189370
Buggy source:
/** 
 * Checks the validity of a rule to make sure it should run or not
 * @param workflowEmailRule - the workflow email rule to check
 * @param submission - the submission to check against
 * @return - returns true if rule is valid, false if condition is not set or recipients is emtpy
 */
private static boolean ruleIsValid(WorkflowEmailRule workflowEmailRule,Submission submission){
  boolean ret=true;
  if (workflowEmailRule.getCondition() != null) {
    if (workflowEmailRule.getCondition().getConditionType() == null || workflowEmailRule.getCondition().getConditionId() == null) {
      ret=false;
    }
  }
 else {
    ret=false;
  }
  if (workflowEmailRule.getRecipients(submission).size() == 0) {
    ret=false;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Checks the validity of a rule to make sure it should run or not
 * @param workflowEmailRule - the workflow email rule to check
 * @param submission - the submission to check against
 * @return - returns true if rule is valid, false if condition is not set or recipients is emtpy
 */
private static boolean ruleIsValid(WorkflowEmailRule workflowEmailRule,Submission submission){
  boolean ret=true;
  if (workflowEmailRule.getCondition() != null) {
    if (workflowEmailRule.getCondition().getConditionType() == null) {
      ret=false;
    }
switch (workflowEmailRule.getCondition().getConditionType()) {
case College:
case Department:
case Program:
      if (workflowEmailRule.getCondition().getConditionId() == null) {
        ret=false;
      }
    break;
case Always:
  break;
default :
throw new UnsupportedOperationException();
}
}
 else {
ret=false;
}
if (workflowEmailRule.getRecipients(submission).size() == 0) {
ret=false;
}
return ret;
}
Program: 189371
Project: 189371
Buggy source:
/** 
 * Helper function to create a JSON encoded string for a hashMap of email addresses Will also modify the passed-in hashMap to add the email addresses Will validate the email addresses in the process 
 * @param emails - the emails String from the request
 * @param emails_map - a blank map to add emails to
 * @return - JSON encoded string representing the hashMap of emails
 */
private static String createEmailsJsonAndAddToMap(String emails,HashMap<Integer,String> emails_map){
  String jsonEmails="String_Node_Str";
  if (emails != null) {
    int i=0;
    List<String> emails_list=(emails.length() == 0 ? new ArrayList<String>() : Arrays.asList(emails.split("String_Node_Str")));
    for (    String email : emails_list) {
      if (!validateEmailAddress(email)) {
        throw new IllegalArgumentException("String_Node_Str" + email + "String_Node_Str");
      }
      emails_map.put(i,email);
      jsonEmails+="String_Node_Str" + i + "String_Node_Str"+ email+ "String_Node_Str";
      i++;
    }
    jsonEmails=jsonEmails.substring(0,jsonEmails.length() - 1);
  }
  jsonEmails+="String_Node_Str";
  return jsonEmails;
}

Fixed version (ground truth):
/** 
 * Helper function to create a JSON encoded string for a hashMap of email addresses Will also modify the passed-in hashMap to add the email addresses Will validate the email addresses in the process 
 * @param emails - the emails String from the request
 * @param emails_map - a blank map to add emails to
 * @return - JSON encoded string representing the hashMap of emails
 */
private static String createEmailsJsonAndAddToMap(String emails,HashMap<Integer,String> emails_map){
  String jsonEmails="String_Node_Str";
  if (emails != null) {
    int i=0;
    List<String> emails_list=(emails.length() == 0 ? new ArrayList<String>() : Arrays.asList(emails.split("String_Node_Str")));
    for (    String email : emails_list) {
      if (!validateEmailAddress(email)) {
        throw new IllegalArgumentException("String_Node_Str" + email + "String_Node_Str");
      }
      emails_map.put(i,email);
      jsonEmails+="String_Node_Str" + i + "String_Node_Str"+ email+ "String_Node_Str";
      i++;
    }
    if (jsonEmails.length() > 1) {
      jsonEmails=jsonEmails.substring(0,jsonEmails.length() - 1);
    }
  }
  jsonEmails+="String_Node_Str";
  return jsonEmails;
}
Program: 189378
Project: 189378
Buggy source:
@Override public List<String> getRecipients(Submission submission){
  List<String> recipients=new ArrayList<String>();
  SettingsRepository settingRepo=Spring.getBeanOfType(SettingsRepository.class);
switch (recipientType) {
case Student:
    recipients.add(submission.getSubmitter().getCurrentEmailAddress());
  break;
case Advisor:
recipients.add(submission.getCommitteeContactEmail());
break;
case College:
recipients.addAll(settingRepo.findCollege(this.emailGroupId).getEmails().values());
break;
case Department:
recipients.addAll(settingRepo.findDepartment(this.emailGroupId).getEmails().values());
break;
case Program:
recipients.addAll(settingRepo.findProgram(this.emailGroupId).getEmails().values());
break;
default :
throw new UnsupportedOperationException();
}
return recipients;
}

Fixed version (ground truth):
@Override public List<String> getRecipients(Submission submission){
  List<String> recipients=new ArrayList<String>();
  SettingsRepository settingRepo=Spring.getBeanOfType(SettingsRepository.class);
  if (recipientType == null)   return recipients;
switch (recipientType) {
case Student:
    recipients.add(submission.getSubmitter().getCurrentEmailAddress());
  break;
case Advisor:
recipients.add(submission.getCommitteeContactEmail());
break;
case College:
recipients.addAll(settingRepo.findCollege(this.emailGroupId).getEmails().values());
break;
case Department:
recipients.addAll(settingRepo.findDepartment(this.emailGroupId).getEmails().values());
break;
case Program:
recipients.addAll(settingRepo.findProgram(this.emailGroupId).getEmails().values());
break;
default :
throw new UnsupportedOperationException();
}
return recipients;
}
Program: 189380
Project: 189380
Buggy source:
/** 
 * @param mock True if shibboleth authentication should be mocked with test attributes. This allows you to use the application without it actualy running behind a shibboleth.
 */
public void setMock(boolean mock){
  if (null != mockShib) {
    mock=mockShib.equals("String_Node_Str");
  }
 else {
    mock=(Play.mode == Mode.DEV);
  }
  this.mock=mock;
}

Fixed version (ground truth):
/** 
 * @param mock True if shibboleth authentication should be mocked with test attributes. This allows you to use the application without it actualy running behind a shibboleth.
 */
public void setMock(boolean mock){
  this.mock=mock;
}
Program: 189384
Project: 189384
Buggy source:
@Override public long[] submissionSearch(SearchFilter filter,SearchOrder orderBy,SearchDirection direction){
  try {
    IndexReader reader=IndexReader.open(indexer.index);
    try {
      IndexSearcher searcher=new IndexSearcher(reader);
      BooleanQuery andQuery=new BooleanQuery();
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
      buildQuery(andQuery,filter,true);
      boolean reverse=(direction == SearchDirection.ASCENDING) ? false : true;
      SortField dynamicSortField=new SortField(SORT_SUB_FIELDS[orderBy.ordinal()],SORT_TYPES[orderBy.ordinal()],reverse);
      SortField idSortField=new SortField("String_Node_Str",SortField.LONG,reverse);
      Sort sort=new Sort(dynamicSortField,idSortField);
      Logger.debug("String_Node_Str" + andQuery.toString());
      TopDocs topDocs=searcher.search(andQuery,Integer.MAX_VALUE,sort);
      long[] sortedIds=new long[topDocs.scoreDocs.length];
      for (int i=0; i < topDocs.scoreDocs.length; i++) {
        Document doc=searcher.doc(topDocs.scoreDocs[i].doc);
        sortedIds[i]=Long.valueOf(doc.get("String_Node_Str")).longValue();
      }
      return sortedIds;
    }
  finally {
      reader.close();
    }
  }
 catch (  IOException ioe) {
    Logger.error(ioe,"String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
@Override public long[] submissionSearch(SearchFilter filter,SearchOrder orderBy,SearchDirection direction){
  try {
    IndexReader reader=IndexReader.open(indexer.index);
    try {
      IndexSearcher searcher=new IndexSearcher(reader);
      BooleanQuery andQuery=new BooleanQuery();
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
      buildQuery(andQuery,filter,true);
      boolean reverse=(direction == SearchDirection.ASCENDING) ? false : true;
      SortField dynamicSortField=new SortField(SORT_SUB_FIELDS[orderBy.ordinal()],SORT_TYPES[orderBy.ordinal()],reverse);
      SortField idSortField=new SortField("String_Node_Str",SortField.LONG,reverse);
      Sort sort=new Sort(dynamicSortField,idSortField);
      Logger.debug("String_Node_Str" + andQuery.toString());
      TopDocs topDocs=searcher.search(andQuery,Integer.MAX_VALUE,sort);
      long[] sortedIds=new long[topDocs.scoreDocs.length];
      for (int i=0; i < topDocs.scoreDocs.length; i++) {
        Document doc=searcher.doc(topDocs.scoreDocs[i].doc);
        sortedIds[i]=Long.valueOf(doc.get("String_Node_Str")).longValue();
      }
      searcher.close();
      return sortedIds;
    }
  finally {
      reader.close();
    }
  }
 catch (  IOException ioe) {
    Logger.error(ioe,"String_Node_Str");
  }
  return null;
}
Program: 189385
Project: 189385
Buggy source:
@Override public long[] actionLogSearch(SearchFilter filter,SearchOrder orderBy,SearchDirection direction){
  try {
    IndexReader reader=IndexReader.open(indexer.index);
    try {
      IndexSearcher searcher=new IndexSearcher(reader);
      BooleanQuery andQuery=new BooleanQuery();
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
      buildQuery(andQuery,filter,true);
      boolean reverse=(direction == SearchDirection.ASCENDING) ? false : true;
      SortField dynamicSortField=new SortField(SORT_SUB_FIELDS[orderBy.ordinal()],SORT_TYPES[orderBy.ordinal()],reverse);
      SortField idSortField=new SortField("String_Node_Str",SortField.LONG,reverse);
      Sort sort=new Sort(dynamicSortField,idSortField);
      Logger.debug("String_Node_Str" + andQuery.toString());
      TopDocs topDocs=searcher.search(andQuery,Integer.MAX_VALUE,sort);
      long[] sortedIds=new long[topDocs.scoreDocs.length];
      for (int i=0; i < topDocs.scoreDocs.length; i++) {
        Document doc=searcher.doc(topDocs.scoreDocs[i].doc);
        sortedIds[i]=Long.valueOf(doc.get("String_Node_Str")).longValue();
      }
      return sortedIds;
    }
  finally {
      reader.close();
    }
  }
 catch (  IOException ioe) {
    Logger.error(ioe,"String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
@Override public long[] actionLogSearch(SearchFilter filter,SearchOrder orderBy,SearchDirection direction){
  try {
    IndexReader reader=IndexReader.open(indexer.index);
    try {
      IndexSearcher searcher=new IndexSearcher(reader);
      BooleanQuery andQuery=new BooleanQuery();
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
      buildQuery(andQuery,filter,true);
      boolean reverse=(direction == SearchDirection.ASCENDING) ? false : true;
      SortField dynamicSortField=new SortField(SORT_SUB_FIELDS[orderBy.ordinal()],SORT_TYPES[orderBy.ordinal()],reverse);
      SortField idSortField=new SortField("String_Node_Str",SortField.LONG,reverse);
      Sort sort=new Sort(dynamicSortField,idSortField);
      Logger.debug("String_Node_Str" + andQuery.toString());
      TopDocs topDocs=searcher.search(andQuery,Integer.MAX_VALUE,sort);
      long[] sortedIds=new long[topDocs.scoreDocs.length];
      for (int i=0; i < topDocs.scoreDocs.length; i++) {
        Document doc=searcher.doc(topDocs.scoreDocs[i].doc);
        sortedIds[i]=Long.valueOf(doc.get("String_Node_Str")).longValue();
      }
      searcher.close();
      return sortedIds;
    }
  finally {
      reader.close();
    }
  }
 catch (  IOException ioe) {
    Logger.error(ioe,"String_Node_Str");
  }
  return null;
}
Program: 189388
Project: 189388
Buggy source:
/** 
 * Modiy the state of this search filter so that it copies the exact state of the other filter. The other filter will not be modified. Note, the current state of this filter will be completely lost.
 * @param otherFilter The filter to copy from.
 */
public void copyFrom(SearchFilter otherFilter);

Fixed version (ground truth):
/** 
 * Modify the state of this search filter so that it copies the exact state of the other filter. The other filter will not be modified. Note, the current state of this filter will be completely lost.
 * @param otherFilter The filter to copy from.
 */
public void copyFrom(SearchFilter otherFilter);