nus-yam/ex-repair huggingface dataset:
Program: 3371
Project: 3371
Buggy source:
/** 
 * read in the action map file which converts log file line actions into actions which are more understandable to humans
 * @param map     the map file
 */
public static void readMap(String map) throws IOException {
  FileReader fr=null;
  BufferedReader br=null;
  String record=null;
  try {
    fr=new FileReader(map);
    br=new BufferedReader(fr);
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str");
    return;
  }
  while ((record=br.readLine()) != null) {
    Matcher matchReal=real.matcher(record);
    if (matchReal.matches()) {
      actionMap.put(matchReal.group(1).trim(),matchReal.group(2).trim());
    }
  }
}

Fixed version (ground truth):
/** 
 * read in the action map file which converts log file line actions into actions which are more understandable to humans
 * @param map     the map file
 */
public static void readMap(String map) throws IOException {
  FileReader fr=null;
  BufferedReader br=null;
  try {
    String record=null;
    try {
      fr=new FileReader(map);
      br=new BufferedReader(fr);
    }
 catch (    IOException e) {
      System.err.println("String_Node_Str");
      return;
    }
    while ((record=br.readLine()) != null) {
      Matcher matchReal=real.matcher(record);
      if (matchReal.matches()) {
        actionMap.put(matchReal.group(1).trim(),matchReal.group(2).trim());
      }
    }
  }
  finally {
    if (br != null)     try {
      br.close();
    }
 catch (    IOException ioe) {
    }
    if (fr != null)     try {
      fr.close();
    }
 catch (    IOException ioe) {
    }
  }
}
Program: 3372
Project: 3372
Buggy source:
/** 
 * Return a List of the policies for a group
 * @param c  current context
 * @param g  group to retrieve policies for
 * @return List of <code>ResourcePolicy</code> objects
 */
public static List<ResourcePolicy> getPoliciesForGroup(Context c,Group g) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",g.getID());
  List<ResourcePolicy> policies=new ArrayList<ResourcePolicy>();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
    if (cachepolicy != null) {
      policies.add(cachepolicy);
    }
 else {
      policies.add(new ResourcePolicy(c,row));
    }
  }
  tri.close();
  return policies;
}

Fixed version (ground truth):
/** 
 * Return a List of the policies for a group
 * @param c  current context
 * @param g  group to retrieve policies for
 * @return List of <code>ResourcePolicy</code> objects
 */
public static List<ResourcePolicy> getPoliciesForGroup(Context c,Group g) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",g.getID());
  List<ResourcePolicy> policies=new ArrayList<ResourcePolicy>();
  try {
    while (tri.hasNext()) {
      TableRow row=tri.next();
      ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
      if (cachepolicy != null) {
        policies.add(cachepolicy);
      }
 else {
        policies.add(new ResourcePolicy(c,row));
      }
    }
  }
  finally {
    if (tri != null)     tri.close();
  }
  return policies;
}
Program: 3373
Project: 3373
Buggy source:
/** 
 * Return a list of policies for an object that match the action
 * @param c context
 * @param o DSpaceObject policies relate to
 * @param actionID action (defined in class Constants)
 * @throws SQLException if there's a database problem
 */
public static List<ResourcePolicy> getPoliciesActionFilter(Context c,DSpaceObject o,int actionID) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + "String_Node_Str",o.getType(),o.getID(),actionID);
  List<ResourcePolicy> policies=new ArrayList<ResourcePolicy>();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
    if (cachepolicy != null) {
      policies.add(cachepolicy);
    }
 else {
      policies.add(new ResourcePolicy(c,row));
    }
  }
  tri.close();
  return policies;
}

Fixed version (ground truth):
/** 
 * Return a list of policies for an object that match the action
 * @param c context
 * @param o DSpaceObject policies relate to
 * @param actionID action (defined in class Constants)
 * @throws SQLException if there's a database problem
 */
public static List<ResourcePolicy> getPoliciesActionFilter(Context c,DSpaceObject o,int actionID) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + "String_Node_Str",o.getType(),o.getID(),actionID);
  List<ResourcePolicy> policies=new ArrayList<ResourcePolicy>();
  try {
    while (tri.hasNext()) {
      TableRow row=tri.next();
      ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
      if (cachepolicy != null) {
        policies.add(cachepolicy);
      }
 else {
        policies.add(new ResourcePolicy(c,row));
      }
    }
  }
  finally {
    if (tri != null)     tri.close();
  }
  return policies;
}
Program: 3374
Project: 3374
Buggy source:
/** 
 * Returns all groups authorized to perform an action on an object. Returns empty array if no matches.
 * @param c current context
 * @param o object
 * @param actionID ID of action frm <code>org.dspace.core.Constants</code>
 * @return array of <code>Group</code>s that can perform the specifiedaction on the specified object
 * @throws java.sql.SQLException if there's a database problem
 */
public static Group[] getAuthorizedGroups(Context c,DSpaceObject o,int actionID) throws java.sql.SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + "String_Node_Str",o.getType(),o.getID(),actionID);
  List<Group> groups=new ArrayList<Group>();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
    ResourcePolicy myPolicy=null;
    if (cachepolicy != null) {
      myPolicy=cachepolicy;
    }
 else {
      myPolicy=new ResourcePolicy(c,row);
    }
    Group myGroup=myPolicy.getGroup();
    if (myGroup != null) {
      groups.add(myGroup);
    }
  }
  tri.close();
  Group[] groupArray=new Group[groups.size()];
  groupArray=groups.toArray(groupArray);
  return groupArray;
}

Fixed version (ground truth):
/** 
 * Returns all groups authorized to perform an action on an object. Returns empty array if no matches.
 * @param c current context
 * @param o object
 * @param actionID ID of action frm <code>org.dspace.core.Constants</code>
 * @return array of <code>Group</code>s that can perform the specifiedaction on the specified object
 * @throws java.sql.SQLException if there's a database problem
 */
public static Group[] getAuthorizedGroups(Context c,DSpaceObject o,int actionID) throws java.sql.SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str" + "String_Node_Str",o.getType(),o.getID(),actionID);
  List<Group> groups=new ArrayList<Group>();
  try {
    while (tri.hasNext()) {
      TableRow row=tri.next();
      ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
      ResourcePolicy myPolicy=null;
      if (cachepolicy != null) {
        myPolicy=cachepolicy;
      }
 else {
        myPolicy=new ResourcePolicy(c,row);
      }
      Group myGroup=myPolicy.getGroup();
      if (myGroup != null) {
        groups.add(myGroup);
      }
    }
  }
  finally {
    if (tri != null)     tri.close();
  }
  Group[] groupArray=new Group[groups.size()];
  groupArray=groups.toArray(groupArray);
  return groupArray;
}
Program: 3375
Project: 3375
Buggy source:
/** 
 * Return a List of the policies for an object
 * @param c  current context
 * @param o  object to retrieve policies for
 * @return List of <code>ResourcePolicy</code> objects
 */
public static List<ResourcePolicy> getPolicies(Context c,DSpaceObject o) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",o.getType(),o.getID());
  List<ResourcePolicy> policies=new ArrayList();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
    if (cachepolicy != null) {
      policies.add(cachepolicy);
    }
 else {
      policies.add(new ResourcePolicy(c,row));
    }
  }
  tri.close();
  return policies;
}

Fixed version (ground truth):
/** 
 * Return a List of the policies for an object
 * @param c  current context
 * @param o  object to retrieve policies for
 * @return List of <code>ResourcePolicy</code> objects
 */
public static List<ResourcePolicy> getPolicies(Context c,DSpaceObject o) throws SQLException {
  TableRowIterator tri=DatabaseManager.queryTable(c,"String_Node_Str","String_Node_Str",o.getType(),o.getID());
  List<ResourcePolicy> policies=new ArrayList();
  try {
    while (tri.hasNext()) {
      TableRow row=tri.next();
      ResourcePolicy cachepolicy=(ResourcePolicy)c.fromCache(ResourcePolicy.class,row.getIntColumn("String_Node_Str"));
      if (cachepolicy != null) {
        policies.add(cachepolicy);
      }
 else {
        policies.add(new ResourcePolicy(c,row));
      }
    }
  }
  finally {
    if (tri != null)     tri.close();
  }
  return policies;
}
Program: 3380
Project: 3380
Buggy source:
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  if (CreativeCommons.isEnabled() && ccLicenseStep != null) {
    ccLicenseStep.addBody(body);
    return;
  }
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str";
  String licenseText=collection.getLicense();
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  addSubmissionProgressList(div);
  Division inner=div.addDivision("String_Node_Str");
  inner.setHead(T_head);
  inner.addPara(T_info1);
  inner.addPara(T_info2);
  Division displayLicense=inner.addDivision("String_Node_Str","String_Node_Str");
  displayLicense.addSimpleHTMLFragment(true,licenseText);
  inner.addPara(T_info3);
  List controls=inner.addList("String_Node_Str",List.TYPE_FORM);
  CheckBox decision=controls.addItem().addCheckBox("String_Node_Str");
  decision.setLabel(T_decision_label);
  decision.addOption("String_Node_Str",T_decision_checkbox);
  if (this.errorFlag == org.dspace.submit.step.LicenseStep.STATUS_LICENSE_REJECTED) {
    decision.addError(T_decision_error);
  }
  addControlButtons(controls);
  div.addHidden("String_Node_Str").setValue(knot.getId());
}

Fixed version (ground truth):
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  if (CreativeCommons.isEnabled() && ccLicenseStep != null) {
    ccLicenseStep.addBody(body);
    return;
  }
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str" + knot.getId()+ "String_Node_Str";
  String licenseText=collection.getLicense();
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  addSubmissionProgressList(div);
  Division inner=div.addDivision("String_Node_Str");
  inner.setHead(T_head);
  inner.addPara(T_info1);
  inner.addPara(T_info2);
  Division displayLicense=inner.addDivision("String_Node_Str","String_Node_Str");
  displayLicense.addSimpleHTMLFragment(true,licenseText);
  inner.addPara(T_info3);
  List controls=inner.addList("String_Node_Str",List.TYPE_FORM);
  CheckBox decision=controls.addItem().addCheckBox("String_Node_Str");
  decision.setLabel(T_decision_label);
  decision.addOption("String_Node_Str",T_decision_checkbox);
  if (this.errorFlag == org.dspace.submit.step.LicenseStep.STATUS_LICENSE_REJECTED) {
    decision.addError(T_decision_error);
  }
  addControlButtons(controls);
}
Program: 3381
Project: 3381
Buggy source:
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Item item=submission.getItem();
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str";
  Request request=ObjectModelHelper.getRequest(objectModel);
  String showfull=request.getParameter("String_Node_Str");
  if (showfull != null && request.getParameter("String_Node_Str") != null)   showfull=null;
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  if (showfull == null) {
    ReferenceSet referenceSet=div.addReferenceSet("String_Node_Str",ReferenceSet.TYPE_SUMMARY_VIEW);
    referenceSet.addReference(item);
    div.addPara().addButton("String_Node_Str").setValue(T_showfull);
  }
 else {
    ReferenceSet referenceSet=div.addReferenceSet("String_Node_Str",ReferenceSet.TYPE_DETAIL_VIEW);
    referenceSet.addReference(item);
    div.addPara().addButton("String_Node_Str").setValue(T_showsimple);
    div.addHidden("String_Node_Str").setValue("String_Node_Str");
  }
  List form=div.addList("String_Node_Str",List.TYPE_FORM);
  org.dspace.app.xmlui.wing.element.Item actions=form.addItem();
  actions.addButton("String_Node_Str").setValue(T_submit_resume);
  actions.addButton("String_Node_Str").setValue(T_submit_cancel);
  div.addHidden("String_Node_Str").setValue(knot.getId());
}

Fixed version (ground truth):
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Item item=submission.getItem();
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str" + knot.getId()+ "String_Node_Str";
  Request request=ObjectModelHelper.getRequest(objectModel);
  String showfull=request.getParameter("String_Node_Str");
  if (showfull != null && request.getParameter("String_Node_Str") != null)   showfull=null;
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  if (showfull == null) {
    ReferenceSet referenceSet=div.addReferenceSet("String_Node_Str",ReferenceSet.TYPE_SUMMARY_VIEW);
    referenceSet.addReference(item);
    div.addPara().addButton("String_Node_Str").setValue(T_showfull);
  }
 else {
    ReferenceSet referenceSet=div.addReferenceSet("String_Node_Str",ReferenceSet.TYPE_DETAIL_VIEW);
    referenceSet.addReference(item);
    div.addPara().addButton("String_Node_Str").setValue(T_showsimple);
    div.addHidden("String_Node_Str").setValue("String_Node_Str");
  }
  List form=div.addList("String_Node_Str",List.TYPE_FORM);
  org.dspace.app.xmlui.wing.element.Item actions=form.addItem();
  actions.addButton("String_Node_Str").setValue(T_submit_resume);
  actions.addButton("String_Node_Str").setValue(T_submit_cancel);
}
Program: 3383
Project: 3383
Buggy source:
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str";
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  addSubmissionProgressList(div);
  List saveOrCancel=div.addList("String_Node_Str",List.TYPE_FORM);
  saveOrCancel.setHead(T_head);
  saveOrCancel.addItem(T_info1);
  saveOrCancel.addItem().addButton("String_Node_Str").setValue(T_submit_back);
  org.dspace.app.xmlui.wing.element.Item actions=saveOrCancel.addItem();
  actions.addButton("String_Node_Str").setValue(T_submit_save);
  actions.addButton("String_Node_Str").setValue(T_submit_remove);
  div.addHidden("String_Node_Str").setValue(knot.getId());
}

Fixed version (ground truth):
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Collection collection=submission.getCollection();
  String actionURL=IdentifierService.getURL(collection).toString() + "String_Node_Str" + knot.getId()+ "String_Node_Str";
  Division div=body.addInteractiveDivision("String_Node_Str",actionURL,Division.METHOD_POST,"String_Node_Str");
  div.setHead(T_submission_head);
  addSubmissionProgressList(div);
  List saveOrCancel=div.addList("String_Node_Str",List.TYPE_FORM);
  saveOrCancel.setHead(T_head);
  saveOrCancel.addItem(T_info1);
  saveOrCancel.addItem().addButton("String_Node_Str").setValue(T_submit_back);
  org.dspace.app.xmlui.wing.element.Item actions=saveOrCancel.addItem();
  actions.addButton("String_Node_Str").setValue(T_submit_save);
  actions.addButton("String_Node_Str").setValue(T_submit_remove);
}
Program: 3387
Project: 3387
Buggy source:
public ServiceDocument doServiceDocument(ServiceDocumentRequest request) throws SWORDAuthenticationException, SWORDException {
  if (log.isDebugEnabled()) {
    log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  }
  try {
    SWORDContext sc=this.authenticate(request);
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + request.getUsername() + "String_Node_Str"+ request.getOnBehalfOf()));
    SWORDService service=new SWORDService();
    service.setContext(context);
    service.setSWORDContext(sc);
    ServiceDocument doc=service.getServiceDocument();
    return doc;
  }
 catch (  DSpaceSWORDException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
 finally {
    if (context != null) {
      context.abort();
    }
  }
}

Fixed version (ground truth):
public ServiceDocument doServiceDocument(ServiceDocumentRequest request) throws SWORDAuthenticationException, SWORDException {
  Context context=constructContext(request.getIPAddress());
  if (log.isDebugEnabled()) {
    log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  }
  try {
    SWORDContext sc=this.authenticate(context,request);
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + request.getUsername() + "String_Node_Str"+ request.getOnBehalfOf()));
    SWORDService service=new SWORDService();
    service.setContext(context);
    service.setSWORDContext(sc);
    ServiceDocument doc=service.getServiceDocument();
    return doc;
  }
 catch (  DSpaceSWORDException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
 finally {
    if (context != null) {
      context.abort();
    }
  }
}
Program: 3388
Project: 3388
Buggy source:
/** 
 * Construct the context object member variable of this class using the passed IP address as part of the loggable information
 * @param ip	the ip address of the incoming request
 * @throws SWORDException
 */
private void constructContext(String ip) throws SWORDException {
  try {
    this.context=new Context();
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
  this.context.setExtraLogInfo("String_Node_Str" + ip);
}

Fixed version (ground truth):
/** 
 * Construct the context object member variable of this class using the passed IP address as part of the loggable information
 * @param ip	the ip address of the incoming request
 * @throws SWORDException
 */
private Context constructContext(String ip) throws SWORDException {
  try {
    Context context=new Context();
    context.setExtraLogInfo("String_Node_Str" + ip);
    return context;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
}
Program: 3390
Project: 3390
Buggy source:
public DepositResponse doDeposit(Deposit deposit) throws SWORDAuthenticationException, SWORDException {
  try {
    if (log.isDebugEnabled()) {
      log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
    }
    SWORDContext sc=this.authenticate(deposit);
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + deposit.getUsername() + "String_Node_Str"+ deposit.getOnBehalfOf()));
    DepositManager dm=new DepositManager();
    dm.setContext(context);
    dm.setDeposit(deposit);
    dm.setSWORDContext(sc);
    DepositResponse response=dm.deposit();
    if (context != null && context.isValid()) {
      context.commit();
    }
    return response;
  }
 catch (  DSpaceSWORDException e) {
    log.error("String_Node_Str",e);
    throw new SWORDAuthenticationException("String_Node_Str",e);
  }
catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
 finally {
    if (context != null && context.isValid()) {
      context.abort();
    }
  }
}

Fixed version (ground truth):
public DepositResponse doDeposit(Deposit deposit) throws SWORDAuthenticationException, SWORDException {
  Context context=constructContext(deposit.getIPAddress());
  try {
    if (log.isDebugEnabled()) {
      log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
    }
    SWORDContext sc=this.authenticate(context,deposit);
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + deposit.getUsername() + "String_Node_Str"+ deposit.getOnBehalfOf()));
    DepositManager dm=new DepositManager();
    dm.setContext(context);
    dm.setDeposit(deposit);
    dm.setSWORDContext(sc);
    DepositResponse response=dm.deposit();
    if (context != null && context.isValid()) {
      context.commit();
    }
    return response;
  }
 catch (  DSpaceSWORDException e) {
    log.error("String_Node_Str",e);
    throw new SWORDAuthenticationException("String_Node_Str",e);
  }
catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new SWORDException("String_Node_Str",e);
  }
 finally {
    if (context != null && context.isValid()) {
      context.abort();
    }
  }
}
Program: 3391
Project: 3391
Buggy source:
/** 
 * Moves the item from one collection to another one
 * @throws SQLException
 * @throws AuthorizeException
 * @throws IOException
 */
public void move(Collection from,Collection to) throws SQLException, AuthorizeException, IOException {
  if (isOwningCollection(from)) {
    setOwningCollection(to);
    update();
  }
  to.addItem(this);
  from.removeItem(this);
}

Fixed version (ground truth):
/** 
 * Moves the item from one collection to another one
 * @throws SQLException
 * @throws AuthorizeException
 * @throws IOException
 */
public void move(Collection from,Collection to) throws SQLException, AuthorizeException, IOException {
  to.addItem(this);
  from.removeItem(this);
  if (isOwningCollection(from)) {
    setOwningCollection(to);
    update();
  }
 else {
    ourContext.addEvent(new Event(Event.MODIFY,Constants.ITEM,getID(),null));
  }
}
Program: 3392
Project: 3392
Buggy source:
/** 
 * Log the given user in as a real authenticated user. This should only be used after  a user has presented their credintals and they have been validated. 
 * @param context DSpace context
 * @param request HTTP request
 * @param eperson the eperson logged in
 */
private static void logIn(Context context,HttpServletRequest request,EPerson eperson) throws SQLException {
  if (eperson == null)   return;
  HttpSession session=request.getSession();
  context.setCurrentUser(eperson);
  if (!AuthorizeManager.isAdmin(context) && !SystemwideAlerts.canUserStartSession()) {
    context.setCurrentUser(null);
    return;
  }
  int[] groupIDs=AuthenticationManager.getSpecialGroups(context,request);
  for (  int groupID : groupIDs)   context.setSpecialGroup(groupID);
  session.setAttribute(CURRENT_IP_ADDRESS,request.getRemoteAddr());
  session.setAttribute(EFFECTIVE_USER_ID,eperson.getID());
  session.setAttribute(AUTHENTICATED_USER_ID,eperson.getID());
}

Fixed version (ground truth):
/** 
 * Log the given user in as a real authenticated user. This should only be used after  a user has presented their credintals and they have been validated. This method  signature is provided to be easier to call from flow scripts.
 * @param objectModel The cocoon object model.
 * @param eperson the eperson logged in
 */
public static void logIn(Map objectModel,EPerson eperson) throws SQLException {
  final HttpServletRequest request=(HttpServletRequest)objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
  Context context=ContextUtil.obtainContext(objectModel);
  logIn(context,request,eperson);
}
Program: 3393
Project: 3393
Buggy source:
/** 
 * Log the given user in as a real authenticated user. This should only be used after  a user has presented their credintals and they have been validated. 
 * @param context DSpace context
 * @param request HTTP request
 * @param eperson the eperson logged in
 */
private static void logIn(Context context,HttpServletRequest request,EPerson eperson) throws SQLException {
  if (eperson == null)   return;
  HttpSession session=request.getSession();
  context.setCurrentUser(eperson);
  if (!AuthorizeManager.isAdmin(context) && !SystemwideAlerts.canUserStartSession()) {
    context.setCurrentUser(null);
    return;
  }
  int[] groupIDs=AuthenticationManager.getSpecialGroups(context,request);
  for (  int groupID : groupIDs)   context.setSpecialGroup(groupID);
  session.setAttribute(CURRENT_IP_ADDRESS,request.getRemoteAddr());
  session.setAttribute(EFFECTIVE_USER_ID,eperson.getID());
  session.setAttribute(AUTHENTICATED_USER_ID,eperson.getID());
}

Fixed version (ground truth):
/** 
 * Log the given user in as a real authenticated user. This should only be used after  a user has presented their credintals and they have been validated. This method  signature is provided to be easier to call from flow scripts.
 * @param objectModel The cocoon object model.
 * @param eperson the eperson logged in
 */
public static void logIn(Map objectModel,EPerson eperson) throws SQLException {
  final HttpServletRequest request=(HttpServletRequest)objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
  Context context=ContextUtil.obtainContext(objectModel);
  logIn(context,request,eperson);
}
Program: 3399
Project: 3399
Buggy source:
public int doStartTag() throws JspException {
  try {
    if (ids.size() < 1) {
      return SKIP_BODY;
    }
    JspWriter out=pageContext.getOut();
    String header=this.getHeaderText();
    out.println("String_Node_Str");
    out.println("String_Node_Str" + header + "String_Node_Str");
    for (    ExternalIdentifier eid : ids) {
      writeIdentifier(eid,out);
    }
    return SKIP_BODY;
  }
 catch (  IOException e) {
    throw new JspException(e);
  }
}

Fixed version (ground truth):
public int doStartTag() throws JspException {
  try {
    if (ids.size() < 1) {
      return SKIP_BODY;
    }
    JspWriter out=pageContext.getOut();
    String header=this.getHeaderText();
    out.println("String_Node_Str");
    out.println("String_Node_Str" + header + "String_Node_Str");
    for (    ExternalIdentifier eid : ids) {
      writeIdentifier(eid,out);
    }
    out.println("String_Node_Str");
    return SKIP_BODY;
  }
 catch (  IOException e) {
    throw new JspException(e);
  }
}
Program: 3400
Project: 3400
Buggy source:
public static Identifiable getResource(Context context,ResolvableIdentifier ri) throws IdentifierException {
  try {
    ObjectIdentifier oid=ri.getObjectIdentifier();
    if (oid.getResourceTypeID() == -1 || oid.getResourceID() == -1) {
      ObjectIdentifierDAO dao=ObjectIdentifierDAOFactory.getInstance(context);
      ObjectIdentifier noid=dao.retrieve(oid.getUUID());
      if (noid == null) {
        return null;
      }
    }
    return IdentifierService.getObjectByResourceID(context,oid);
  }
 catch (  ObjectIdentifierStorageException e) {
    log.error("String_Node_Str",e);
    throw new IdentifierException(e);
  }
}

Fixed version (ground truth):
public static Identifiable getResource(Context context,ResolvableIdentifier ri) throws IdentifierException {
  try {
    ObjectIdentifier oid=ri.getObjectIdentifier();
    if (oid.getResourceTypeID() == -1 || oid.getResourceID() == -1) {
      ObjectIdentifierDAO dao=ObjectIdentifierDAOFactory.getInstance(context);
      ObjectIdentifier noid=dao.retrieve(oid.getUUID());
      if (noid == null) {
        return null;
      }
      oid=noid;
    }
    return IdentifierService.getObjectByResourceID(context,oid);
  }
 catch (  ObjectIdentifierStorageException e) {
    log.error("String_Node_Str",e);
    throw new IdentifierException(e);
  }
}
Program: 3403
Project: 3403
Buggy source:
public int doOffsetQuery(String column,String value,boolean isAscending) throws BrowseException {
  TableRowIterator tri=null;
  try {
    List paramsList=new ArrayList();
    StringBuffer queryBuf=new StringBuffer();
    queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
    buildSelectStatement(queryBuf,paramsList);
    if (isAscending) {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value);
    }
 else {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value + Character.MAX_VALUE);
    }
    if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null)) {
      queryBuf.append("String_Node_Str").append("String_Node_Str");
      queryBuf.append(table).append("String_Node_Str");
    }
    tri=DatabaseManager.query(context,queryBuf.toString(),paramsList.toArray());
    TableRow row;
    if (tri.hasNext()) {
      row=tri.next();
      return row.getIntColumn("String_Node_Str");
    }
 else {
      return 0;
    }
  }
 catch (  SQLException e) {
    throw new BrowseException(e);
  }
 finally {
    if (tri != null) {
      tri.close();
    }
  }
}

Fixed version (ground truth):
public int doOffsetQuery(String column,String value,boolean isAscending) throws BrowseException {
  TableRowIterator tri=null;
  if (column == null || value == null)   return 0;
  try {
    List paramsList=new ArrayList();
    StringBuffer queryBuf=new StringBuffer();
    queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
    buildSelectStatement(queryBuf,paramsList);
    if (isAscending) {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value);
    }
 else {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value + Character.MAX_VALUE);
    }
    if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null)) {
      queryBuf.append("String_Node_Str").append("String_Node_Str");
      queryBuf.append(table).append("String_Node_Str");
    }
    tri=DatabaseManager.query(context,queryBuf.toString(),paramsList.toArray());
    TableRow row;
    if (tri.hasNext()) {
      row=tri.next();
      return row.getIntColumn("String_Node_Str");
    }
 else {
      return 0;
    }
  }
 catch (  SQLException e) {
    throw new BrowseException(e);
  }
 finally {
    if (tri != null) {
      tri.close();
    }
  }
}
Program: 3404
Project: 3404
Buggy source:
public int doOffsetQuery(String column,String value,boolean isAscending) throws BrowseException {
  TableRowIterator tri=null;
  try {
    List paramsList=new ArrayList();
    StringBuffer queryBuf=new StringBuffer();
    queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
    buildSelectStatement(queryBuf,paramsList);
    if (isAscending) {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value);
    }
 else {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value + Character.MAX_VALUE);
    }
    if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null)) {
      queryBuf.append("String_Node_Str").append("String_Node_Str");
      queryBuf.append(table).append("String_Node_Str");
    }
    tri=DatabaseManager.query(context,queryBuf.toString(),paramsList.toArray());
    TableRow row;
    if (tri.hasNext()) {
      row=tri.next();
      return (int)row.getLongColumn("String_Node_Str");
    }
 else {
      return 0;
    }
  }
 catch (  SQLException e) {
    throw new BrowseException(e);
  }
 finally {
    if (tri != null) {
      tri.close();
    }
  }
}

Fixed version (ground truth):
public int doOffsetQuery(String column,String value,boolean isAscending) throws BrowseException {
  TableRowIterator tri=null;
  if (column == null || value == null)   return 0;
  try {
    List paramsList=new ArrayList();
    StringBuffer queryBuf=new StringBuffer();
    queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
    buildSelectStatement(queryBuf,paramsList);
    if (isAscending) {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value);
    }
 else {
      queryBuf.append("String_Node_Str").append(column).append("String_Node_Str");
      paramsList.add(value + Character.MAX_VALUE);
    }
    if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null)) {
      queryBuf.append("String_Node_Str").append("String_Node_Str");
      queryBuf.append(table).append("String_Node_Str");
    }
    tri=DatabaseManager.query(context,queryBuf.toString(),paramsList.toArray());
    TableRow row;
    if (tri.hasNext()) {
      row=tri.next();
      return (int)row.getLongColumn("String_Node_Str");
    }
 else {
      return 0;
    }
  }
 catch (  SQLException e) {
    throw new BrowseException(e);
  }
 finally {
    if (tri != null) {
      tri.close();
    }
  }
}
Program: 3408
Project: 3408
Buggy source:
/** 
 * Query DSpace for a list of all items / collections / or communities that match the given search query.
 * @return The associated query results.
 */
protected void performSearch() throws SQLException, IOException {
  if (queryResults != null)   return;
  Context context=ContextUtil.obtainContext(objectModel);
  String query=getQuery();
  DSpaceObject scope=getScope();
  int page=getParameterPage();
  QueryArgs qArgs=new QueryArgs();
  qArgs.setPageSize(getParameterRpp());
  try {
    qArgs.setSortOption(SortOption.getSortOption(getParameterSortBy()));
  }
 catch (  SortException se) {
  }
  qArgs.setSortOrder(getParameterOrder());
  qArgs.setQuery(query);
  if (page > 1)   qArgs.setStart((Integer.valueOf(page) - 1) * qArgs.getPageSize());
 else   qArgs.setStart(0);
  QueryResults qResults=null;
  if (scope instanceof Community) {
    qResults=DSQuery.doQuery(context,qArgs,(Community)scope);
  }
 else   if (scope instanceof Collection) {
    qResults=DSQuery.doQuery(context,qArgs,(Collection)scope);
  }
 else {
    qResults=DSQuery.doQuery(context,qArgs);
  }
  this.queryResults=qResults;
}

Fixed version (ground truth):
/** 
 * Query DSpace for a list of all items / collections / or communities that match the given search query.
 * @return The associated query results.
 */
protected void performSearch() throws SQLException, IOException, UIException {
  if (queryResults != null)   return;
  Context context=ContextUtil.obtainContext(objectModel);
  String query=getQuery();
  DSpaceObject scope=getScope();
  int page=getParameterPage();
  QueryArgs qArgs=new QueryArgs();
  qArgs.setPageSize(getParameterRpp());
  try {
    qArgs.setSortOption(SortOption.getSortOption(getParameterSortBy()));
  }
 catch (  SortException se) {
  }
  qArgs.setSortOrder(getParameterOrder());
  qArgs.setQuery(query);
  if (page > 1)   qArgs.setStart((Integer.valueOf(page) - 1) * qArgs.getPageSize());
 else   qArgs.setStart(0);
  QueryResults qResults=null;
  if (scope instanceof Community) {
    qResults=DSQuery.doQuery(context,qArgs,(Community)scope);
  }
 else   if (scope instanceof Collection) {
    qResults=DSQuery.doQuery(context,qArgs,(Collection)scope);
  }
 else {
    qResults=DSQuery.doQuery(context,qArgs);
  }
  this.queryResults=qResults;
}
Program: 3409
Project: 3409
Buggy source:
/** 
 * Extract the query string. Under most implementations this will be derived from the url parameters.
 * @return The query string.
 */
abstract protected String getQuery();

Fixed version (ground truth):
/** 
 * Extract the query string. Under most implementations this will be derived from the url parameters.
 * @return The query string.
 */
abstract protected String getQuery() throws UIException ;
Program: 3410
Project: 3410
Buggy source:
/** 
 * Build the query field for the given cell.
 * @param row The current row.
 * @param cell The current cell.
 */
private void buildQueryField(int row,Cell cell) throws WingException {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String current=request.getParameter("String_Node_Str" + row);
  Text text=cell.addText("String_Node_Str" + row);
  if (current != null)   text.setValue(current);
}

Fixed version (ground truth):
/** 
 * Build the query field for the given cell.
 * @param row The current row.
 * @param cell The current cell.
 */
private void buildQueryField(int row,Cell cell) throws WingException {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String current=URLDecode(request.getParameter("String_Node_Str" + row));
  Text text=cell.addText("String_Node_Str" + row);
  if (current != null)   text.setValue(current);
}
Program: 3411
Project: 3411
Buggy source:
/** 
 * Get a list of search fields from the request object and parse them into a linear array of fileds. The field's index is preserved, so if it comes in as index 17 it will  be outputted as field 17.
 * @param request The http request object
 * @return Array of search fields
 */
public ArrayList<SearchField> getSearchFields(Request request){
  if (this.fields != null)   return this.fields;
  int numSearchField;
  try {
    String numSearchFieldStr=request.getParameter("String_Node_Str");
    numSearchField=Integer.valueOf(numSearchFieldStr);
  }
 catch (  NumberFormatException nfe) {
    numSearchField=FIELD_MAX_COUNT;
  }
  ArrayList<SearchField> fields=new ArrayList<SearchField>();
  for (int i=1; i <= numSearchField; i++) {
    String field=request.getParameter("String_Node_Str" + i);
    String query=request.getParameter("String_Node_Str" + i);
    String conjunction=request.getParameter("String_Node_Str" + i);
    if (field != null) {
      field=field.trim();
      if (field.length() == 0)       field=null;
    }
    if (query != null) {
      query=query.trim();
      if (query.length() == 0)       query=null;
    }
    if (conjunction != null) {
      conjunction=conjunction.trim();
      if (conjunction.length() == 0)       conjunction=null;
    }
    if (field == null)     field="String_Node_Str";
    if (conjunction == null)     conjunction="String_Node_Str";
    if (query != null)     fields.add(new SearchField(i,field,query,conjunction));
  }
  this.fields=fields;
  return this.fields;
}

Fixed version (ground truth):
/** 
 * Get a list of search fields from the request object and parse them into a linear array of fileds. The field's index is preserved, so if it comes in as index 17 it will  be outputted as field 17.
 * @param request The http request object
 * @return Array of search fields
 * @throws UIException 
 */
public ArrayList<SearchField> getSearchFields(Request request) throws UIException {
  if (this.fields != null)   return this.fields;
  int numSearchField;
  try {
    String numSearchFieldStr=request.getParameter("String_Node_Str");
    numSearchField=Integer.valueOf(numSearchFieldStr);
  }
 catch (  NumberFormatException nfe) {
    numSearchField=FIELD_MAX_COUNT;
  }
  ArrayList<SearchField> fields=new ArrayList<SearchField>();
  for (int i=1; i <= numSearchField; i++) {
    String field=request.getParameter("String_Node_Str" + i);
    String query=URLDecode(request.getParameter("String_Node_Str" + i));
    String conjunction=request.getParameter("String_Node_Str" + i);
    if (field != null) {
      field=field.trim();
      if (field.length() == 0)       field=null;
    }
    if (query != null) {
      query=query.trim();
      if (query.length() == 0)       query=null;
    }
    if (conjunction != null) {
      conjunction=conjunction.trim();
      if (conjunction.length() == 0)       conjunction=null;
    }
    if (field == null)     field="String_Node_Str";
    if (conjunction == null)     conjunction="String_Node_Str";
    if (query != null)     fields.add(new SearchField(i,field,query,conjunction));
  }
  this.fields=fields;
  return this.fields;
}
Program: 3412
Project: 3412
Buggy source:
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Division search=body.addInteractiveDivision("String_Node_Str",contextPath + "String_Node_Str",Division.METHOD_POST,"String_Node_Str");
  search.setHead(T_head);
  search.addPara(T_para1);
  Para fields=search.addPara();
  fields.addText("String_Node_Str");
  fields.addButton("String_Node_Str").setValue(T_go);
}

Fixed version (ground truth):
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  Division search=body.addInteractiveDivision("String_Node_Str",contextPath + "String_Node_Str",Division.METHOD_GET,"String_Node_Str");
  search.setHead(T_head);
  search.addPara(T_para1);
  Para fields=search.addPara();
  fields.addText("String_Node_Str");
  fields.addButton("String_Node_Str").setValue(T_go);
}
Program: 3413
Project: 3413
Buggy source:
/** 
 * build the DRI page representing the body of the search query. This provides a widget to generate a new query and list of search results if present.
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  String queryString=getQuery();
  Division search=body.addDivision("String_Node_Str","String_Node_Str");
  search.setHead(T_head);
  Division query=search.addInteractiveDivision("String_Node_Str","String_Node_Str",Division.METHOD_POST,"String_Node_Str");
  List queryList=query.addList("String_Node_Str",List.TYPE_FORM);
  if (variableScope()) {
    Select scope=queryList.addItem().addSelect("String_Node_Str");
    scope.setLabel(T_search_scope);
    buildScopeList(scope);
  }
  Text text=queryList.addItem().addText("String_Node_Str");
  text.setLabel(T_full_text_search);
  text.setValue(queryString);
  buildSearchControls(query);
  query.addPara(null,"String_Node_Str").addButton("String_Node_Str").setValue(T_go);
  buildSearchResultsDivision(search);
}

Fixed version (ground truth):
/** 
 * build the DRI page representing the body of the search query. This provides a widget to generate a new query and list of search results if present.
 */
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
  String queryString=getQuery();
  Division search=body.addDivision("String_Node_Str","String_Node_Str");
  search.setHead(T_head);
  Division query=search.addInteractiveDivision("String_Node_Str","String_Node_Str",Division.METHOD_GET,"String_Node_Str");
  List queryList=query.addList("String_Node_Str",List.TYPE_FORM);
  if (variableScope()) {
    Select scope=queryList.addItem().addSelect("String_Node_Str");
    scope.setLabel(T_search_scope);
    buildScopeList(scope);
  }
  Text text=queryList.addItem().addText("String_Node_Str");
  text.setLabel(T_full_text_search);
  text.setValue(queryString);
  buildSearchControls(query);
  query.addPara(null,"String_Node_Str").addButton("String_Node_Str").setValue(T_go);
  buildSearchResultsDivision(search);
}
Program: 3414
Project: 3414
Buggy source:
/** 
 * Get the search query from the URL parameter, if none is found the empty string is returned.
 */
protected String getQuery(){
  Request request=ObjectModelHelper.getRequest(objectModel);
  String query=request.getParameter("String_Node_Str");
  if (query == null)   return "String_Node_Str";
  return query;
}

Fixed version (ground truth):
/** 
 * Get the search query from the URL parameter, if none is found the empty string is returned.
 */
protected String getQuery() throws UIException {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String query=URLDecode(request.getParameter("String_Node_Str"));
  if (query == null)   return "String_Node_Str";
  return query;
}
Program: 3415
Project: 3415
Buggy source:
/** 
 * Get the limit clause to perform search result truncation.  Will return something of the form: <code> LIMIT [limit] </code>
 */
private void buildRowLimitAndOffset(StringBuffer queryBuf,List params){
  if (limit > 0 || offset > 0) {
    queryBuf.insert(0,"String_Node_Str");
    queryBuf.append("String_Node_Str");
  }
  if (limit > 0) {
    queryBuf.append("String_Node_Str");
    if (offset > 0)     params.add(new Integer(limit + offset));
 else     params.add(new Integer(limit));
  }
  if (offset > -1) {
    queryBuf.insert(0,"String_Node_Str");
    queryBuf.append("String_Node_Str");
    params.add(new Integer(offset));
  }
}

Fixed version (ground truth):
/** 
 * Get the limit clause to perform search result truncation.  Will return something of the form: <code> LIMIT [limit] </code>
 */
private void buildRowLimitAndOffset(StringBuffer queryBuf,List params){
  if (limit > 0 || offset > 0) {
    queryBuf.insert(0,"String_Node_Str");
    queryBuf.append("String_Node_Str");
  }
  if (limit > 0) {
    queryBuf.append("String_Node_Str");
    if (offset > 0)     params.add(new Integer(limit + offset));
 else     params.add(new Integer(limit));
  }
  if (offset > 0) {
    queryBuf.insert(0,"String_Node_Str");
    queryBuf.append("String_Node_Str");
    params.add(new Integer(offset));
  }
}
Program: 3419
Project: 3419
Buggy source:
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  try {
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}

Fixed version (ground truth):
/** 
 * Decode the given string from URL transmission.
 * @param encodedString The encoded string.
 * @return The unencoded string
 */
public static String URLDecode(String encodedString) throws UIException {
  if (encodedString == null)   return null;
  try {
    return URLDecoder.decode(encodedString,Constants.DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException uee) {
    throw new UIException(uee);
  }
}
Program: 3426
Project: 3426
Buggy source:
/** 
 * figures out if the date is valid for the policy
 * @return true if policy has begun and hasn't expired yet (or no dates areset)
 */
public boolean isDateValid(){
  Date sd=getStartDate();
  Date ed=getEndDate();
  if ((sd == null) && (ed == null)) {
    return true;
  }
  Date now=new Date();
  if (sd != null) {
    if (now.before(sd)) {
      return false;
    }
  }
  if (ed != null) {
    if (now.after(sd)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * figures out if the date is valid for the policy
 * @return true if policy has begun and hasn't expired yet (or no dates areset)
 */
public boolean isDateValid(){
  Date sd=getStartDate();
  Date ed=getEndDate();
  if ((sd == null) && (ed == null)) {
    return true;
  }
  Date now=new Date();
  if (sd != null) {
    if (now.before(sd)) {
      return false;
    }
  }
  if (ed != null) {
    if (now.after(ed)) {
      return false;
    }
  }
  return true;
}