nus-yam/ex-repair huggingface dataset:
Program: 3657
Project: 3657
Buggy source:
protected static int countTotalInIndex(BrowseScope scope,int numberOfResults) throws SQLException {
  int browseType=scope.getBrowseType();
  if ((browseType == ITEMS_BY_AUTHOR_BROWSE) && (scope.hasNoLimit() || ((scope.getTotal() > numberOfResults))))   return numberOfResults;
  PreparedStatement statement=null;
  Object obj=scope.getScope();
  try {
    String table=BrowseTables.getTable(scope);
    StringBuffer buffer=new StringBuffer().append("String_Node_Str").append(getTargetColumns(scope)).append("String_Node_Str").append(table);
    boolean hasWhere=false;
    if (browseType == ITEMS_BY_AUTHOR_BROWSE) {
      hasWhere=true;
      buffer.append("String_Node_Str");
    }
    String connector=hasWhere ? "String_Node_Str" : "String_Node_Str";
    String sql=buffer.append(getScopeClause(scope,connector)).toString();
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + sql + "String_Node_Str");
    statement=createStatement(scope,sql);
    if (browseType == ITEMS_BY_AUTHOR_BROWSE)     statement.setString(1,(String)scope.getFocus());
    return getIntValue(statement);
  }
  finally {
    if (statement != null)     statement.close();
  }
}

Fixed version (ground truth):
protected static int countTotalInIndex(BrowseScope scope,int numberOfResults) throws SQLException {
  int browseType=scope.getBrowseType();
  if ((browseType == ITEMS_BY_AUTHOR_BROWSE) && (scope.hasNoLimit() || ((scope.getTotal() > numberOfResults))))   return numberOfResults;
  PreparedStatement statement=null;
  Object obj=scope.getScope();
  try {
    String table=BrowseTables.getTable(scope);
    StringBuffer buffer=new StringBuffer().append("String_Node_Str").append((getTargetColumns(scope) == "String_Node_Str") ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str").append(table);
    boolean hasWhere=false;
    if (browseType == ITEMS_BY_AUTHOR_BROWSE) {
      hasWhere=true;
      buffer.append("String_Node_Str");
    }
    String connector=hasWhere ? "String_Node_Str" : "String_Node_Str";
    String sql=buffer.append(getScopeClause(scope,connector)).toString();
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + sql + "String_Node_Str");
    statement=createStatement(scope,sql);
    if (browseType == ITEMS_BY_AUTHOR_BROWSE)     statement.setString(1,(String)scope.getFocus());
    return getIntValue(statement);
  }
  finally {
    if (statement != null)     statement.close();
  }
}
Program: 3659
Project: 3659
Buggy source:
/** 
 * Returns a normalized String corresponding to TITLE. The normalization is effected by: + first removing leading spaces, if any + then removing the first leading occurences of "a", "an" and "the" (in any case). + removing any whitespace following an occurence of a stop word This simple strategy is only expected to be used for English words.
 */
public static String normalizeEnglish(String title){
  if (title == null)   return null;
  if (title.length() == 0)   return title;
  int startAt=firstWhitespace(title);
  boolean modified=(startAt != 0);
  boolean usedStopWord=false;
  String stop=null;
  for (int i=0; i < STOP_WORDS.length; i++) {
    stop=STOP_WORDS[i];
    int stoplen=stop.length();
    boolean found=title.toLowerCase().startsWith(stop.toLowerCase(),startAt) && title.length() >= (startAt + stoplen + 1) && Character.isWhitespace(title.charAt(startAt + stoplen));
    if (found) {
      modified=true;
      usedStopWord=true;
      startAt+=stoplen;
      int firstw=firstWhitespace(title,startAt);
      if (firstw != 0)       startAt=firstw;
      break;
    }
  }
  if (!modified)   return title;
  if (!usedStopWord)   return title.substring(startAt);
  return new StringBuffer(title.substring(startAt)).append("String_Node_Str").append(stop).toString();
}

Fixed version (ground truth):
/** 
 * Returns a normalized String corresponding to TITLE. The normalization is effected by: + first removing leading spaces, if any + then removing the first leading occurences of "a", "an" and "the" (in any case). + removing any whitespace following an occurence of a stop word This simple strategy is only expected to be used for English words.
 */
public static String normalizeEnglish(String oldtitle){
  if (oldtitle == null)   return null;
  if (oldtitle.length() == 0)   return oldtitle;
  String title=oldtitle.toLowerCase();
  int startAt=firstWhitespace(title);
  boolean modified=(startAt != 0);
  boolean usedStopWord=false;
  String stop=null;
  for (int i=0; i < STOP_WORDS.length; i++) {
    stop=STOP_WORDS[i];
    int stoplen=stop.length();
    boolean found=title.toLowerCase().startsWith(stop.toLowerCase(),startAt) && title.length() >= (startAt + stoplen + 1) && Character.isWhitespace(title.charAt(startAt + stoplen));
    if (found) {
      modified=true;
      usedStopWord=true;
      startAt+=stoplen;
      int firstw=firstWhitespace(title,startAt);
      if (firstw != 0)       startAt=firstw;
      break;
    }
  }
  if (!modified)   return title;
  if (!usedStopWord)   return title.substring(startAt);
  return new StringBuffer(title.substring(startAt)).append("String_Node_Str").append(stop).toString();
}
Program: 3660
Project: 3660
Buggy source:
/** 
 * Process input from remove item page
 * @param context   current context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processRemoveItem(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
  WorkspaceItem workspaceItem;
  try {
    int wsID=Integer.parseInt(request.getParameter("String_Node_Str"));
    workspaceItem=WorkspaceItem.find(context,wsID);
  }
 catch (  NumberFormatException nfe) {
    workspaceItem=null;
  }
  if (workspaceItem == null) {
    log.warn(LogManager.getHeader(context,"String_Node_Str",UIUtil.getRequestLogInfo(request)));
    JSPManager.showIntegrityError(request,response);
    return;
  }
  if (buttonPressed.equals("String_Node_Str")) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + workspaceItem.getID() + "String_Node_Str"+ workspaceItem.getItem().getID()));
    workspaceItem.deleteWrapper();
    showMainPage(context,request,response);
    context.complete();
  }
 else {
    showMainPage(context,request,response);
  }
}

Fixed version (ground truth):
/** 
 * Process input from remove item page
 * @param context   current context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processRemoveItem(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
  WorkspaceItem workspaceItem;
  try {
    int wsID=Integer.parseInt(request.getParameter("String_Node_Str"));
    workspaceItem=WorkspaceItem.find(context,wsID);
  }
 catch (  NumberFormatException nfe) {
    workspaceItem=null;
  }
  if (workspaceItem == null) {
    log.warn(LogManager.getHeader(context,"String_Node_Str",UIUtil.getRequestLogInfo(request)));
    JSPManager.showIntegrityError(request,response);
    return;
  }
  if (buttonPressed.equals("String_Node_Str")) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + workspaceItem.getID() + "String_Node_Str"+ workspaceItem.getItem().getID()));
    workspaceItem.deleteAll();
    showMainPage(context,request,response);
    context.complete();
  }
 else {
    showMainPage(context,request,response);
  }
}
Program: 3661
Project: 3661
Buggy source:
/** 
 * Delete the item.  Bundles and bitstreams are also deleted if they are not also included in another item.  The Dublin Core metadata is deleted.
 */
void delete() throws SQLException, AuthorizeException, IOException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.DELETE);
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  ourContext.removeCached(this,getID());
  if (isArchived()) {
    Browse.itemRemoved(ourContext,getID());
  }
  removeDCFromDatabase();
  Bundle[] bundles=getBundles();
  for (int i=0; i < bundles.length; i++) {
    removeBundle(bundles[i]);
  }
  AuthorizeManager.removeAllPolicies(ourContext,this);
  DatabaseManager.updateQuery(ourContext,"String_Node_Str" + Constants.ITEM + "String_Node_Str"+ getID());
  DatabaseManager.delete(ourContext,itemRow);
}

Fixed version (ground truth):
/** 
 * Delete the item.  Bundles and bitstreams are also deleted if they are not also included in another item.  The Dublin Core metadata is deleted.
 */
void delete() throws SQLException, AuthorizeException, IOException {
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  ourContext.removeCached(this,getID());
  if (isArchived()) {
    Browse.itemRemoved(ourContext,getID());
  }
  removeDCFromDatabase();
  Bundle[] bundles=getBundles();
  for (int i=0; i < bundles.length; i++) {
    removeBundle(bundles[i]);
  }
  AuthorizeManager.removeAllPolicies(ourContext,this);
  DatabaseManager.updateQuery(ourContext,"String_Node_Str" + Constants.ITEM + "String_Node_Str"+ getID());
  DatabaseManager.delete(ourContext,itemRow);
}
Program: 3663
Project: 3663
Buggy source:
/** 
 * Process information from "enter new password"
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processNewPassword(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String key=request.getParameter("String_Node_Str");
  EPerson eperson=AccountManager.getEPerson(context,key);
  if (eperson == null) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + key));
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  boolean passwordOK=EditProfileServlet.confirmAndSetPassword(eperson,request);
  if (passwordOK) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + eperson.getEmail()));
    AccountManager.deleteToken(context,key);
    JSPManager.showJSP(request,response,"String_Node_Str");
    context.complete();
  }
 else {
    request.setAttribute("String_Node_Str",new Boolean(true));
    request.setAttribute("String_Node_Str",key);
    request.setAttribute("String_Node_Str",eperson);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Process information from "enter new password"
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processNewPassword(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String key=request.getParameter("String_Node_Str");
  EPerson eperson=AccountManager.getEPerson(context,key);
  if (eperson == null) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + key));
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  context.setCurrentUser(eperson);
  boolean passwordOK=EditProfileServlet.confirmAndSetPassword(eperson,request);
  if (passwordOK) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + eperson.getEmail()));
    AccountManager.deleteToken(context,key);
    JSPManager.showJSP(request,response,"String_Node_Str");
    context.complete();
  }
 else {
    request.setAttribute("String_Node_Str",new Boolean(true));
    request.setAttribute("String_Node_Str",key);
    request.setAttribute("String_Node_Str",eperson);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
}
Program: 3664
Project: 3664
Buggy source:
/** 
 * Get all the items in this collection.  The order is indeterminate.
 * @return  an iterator over the items in the collection.
 */
public ItemIterator getItems() throws SQLException {
  TableRowIterator rows=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  return new ItemIterator(ourContext,rows);
}

Fixed version (ground truth):
/** 
 * Get all the items in this collection.  The order is indeterminate.
 * @return  an iterator over the items in the collection.
 */
public ItemIterator getItems() throws SQLException {
  TableRowIterator rows=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  return new ItemIterator(ourContext,rows);
}
Program: 3666
Project: 3666
Buggy source:
/** 
 * Get repeated values from a form.  If "foo" is passed in, values in the form of parameters "foo_0", "foo_1", etc. are returned.
 * @param request   the HTTP request containing the form information
 * @param param     the repeated parameter
 * @return a List of Strings
 */
private List getRepeatedParameter(HttpServletRequest request,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  while (!foundLast) {
    String s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null) {
      vals.add(s);
    }
 else {
      foundLast=true;
    }
    i++;
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Get repeated values from a form.  If "foo" is passed in, values in the form of parameters "foo_0", "foo_1", etc. are returned.
 * @param request   the HTTP request containing the form information
 * @param param     the repeated parameter
 * @return a List of Strings
 */
private List getRepeatedParameter(HttpServletRequest request,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  while (!foundLast) {
    String s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null) {
      vals.add(s.trim());
    }
 else {
      foundLast=true;
    }
    i++;
  }
  return vals;
}
Program: 3671
Project: 3671
Buggy source:
/** 
 * Get repeated values from a form.  If "foo" is passed in, values in the form of parameters "foo_0", "foo_1", etc. are returned.
 * @param request   the HTTP request containing the form information
 * @param param     the repeated parameter
 * @return a List of Strings
 */
private List getRepeatedParameter(HttpServletRequest request,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  while (!foundLast) {
    String s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null && !s.equals("String_Node_Str")) {
      vals.add(s);
    }
    foundLast=(s == null);
    i++;
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Get repeated values from a form.  If "foo" is passed in, values in the form of parameters "foo_0", "foo_1", etc. are returned.
 * @param request   the HTTP request containing the form information
 * @param param     the repeated parameter
 * @return a List of Strings
 */
private List getRepeatedParameter(HttpServletRequest request,String param){
  List vals=new LinkedList();
  int i=0;
  boolean foundLast=false;
  while (!foundLast) {
    String s=request.getParameter(param + "String_Node_Str" + i);
    if (s != null) {
      vals.add(s);
    }
 else {
      foundLast=true;
    }
    i++;
  }
  return vals;
}
Program: 3674
Project: 3674
Buggy source:
/** 
 * Process information from "enter new password"
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processNewPassword(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String key=request.getParameter("String_Node_Str");
  EPerson eperson=AccountManager.getEPerson(context,key);
  if (eperson == null) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + key));
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  boolean passwordOK=EditProfileServlet.confirmAndSetPassword(eperson,request);
  if (passwordOK) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + eperson.getEmail()));
    AccountManager.deleteToken(context,key);
    JSPManager.showJSP(request,response,"String_Node_Str");
    context.complete();
  }
 else {
    request.setAttribute("String_Node_Str",new Boolean(true));
    request.setAttribute("String_Node_Str",key);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Process information from "enter new password"
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processNewPassword(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  String key=request.getParameter("String_Node_Str");
  EPerson eperson=AccountManager.getEPerson(context,key);
  if (eperson == null) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + key));
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  boolean passwordOK=EditProfileServlet.confirmAndSetPassword(eperson,request);
  if (passwordOK) {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + eperson.getEmail()));
    AccountManager.deleteToken(context,key);
    JSPManager.showJSP(request,response,"String_Node_Str");
    context.complete();
  }
 else {
    request.setAttribute("String_Node_Str",new Boolean(true));
    request.setAttribute("String_Node_Str",key);
    request.setAttribute("String_Node_Str",eperson);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
}
Program: 3675
Project: 3675
Buggy source:
/** 
 * Update the ResourcePolicy
 */
public void update() throws SQLException, AuthorizeException {
  DatabaseManager.update(myContext,myRow);
}

Fixed version (ground truth):
/** 
 * Update the ResourcePolicy
 */
public void update() throws SQLException {
  DatabaseManager.update(myContext,myRow);
}
Program: 3676
Project: 3676
Buggy source:
/** 
 * Return the request that the system should be dealing with, given the request that the browse just sent.  If the incoming request is from a redirect resulting from successful authentication, a request object corresponding to the original request that prompted authentication is returned.  Otherwise, the request passed in is returned.
 * @param request   the incoming HTTP request
 * @return   the HTTP request the DSpace system should deal with
 */
public static HttpServletRequest getRealRequest(HttpServletRequest request){
  HttpSession session=request.getSession();
  if (session.getAttribute("String_Node_Str") != null) {
    log.info("String_Node_Str");
    RequestInfo requestInfo=(RequestInfo)session.getAttribute("String_Node_Str");
    HttpServletRequest actualRequest=requestInfo.wrapRequest(request);
    session.removeAttribute("String_Node_Str");
    session.removeAttribute("String_Node_Str");
    session.removeAttribute("String_Node_Str");
    return actualRequest;
  }
 else {
    return request;
  }
}

Fixed version (ground truth):
/** 
 * Return the request that the system should be dealing with, given the request that the browse just sent.  If the incoming request is from a redirect resulting from successful authentication, a request object corresponding to the original request that prompted authentication is returned.  Otherwise, the request passed in is returned.
 * @param request   the incoming HTTP request
 * @return   the HTTP request the DSpace system should deal with
 */
public static HttpServletRequest getRealRequest(HttpServletRequest request){
  HttpSession session=request.getSession();
  if (session.getAttribute("String_Node_Str") != null) {
    RequestInfo requestInfo=(RequestInfo)session.getAttribute("String_Node_Str");
    HttpServletRequest actualRequest;
    if (requestInfo == null) {
      actualRequest=request;
    }
 else {
      actualRequest=requestInfo.wrapRequest(request);
    }
    session.removeAttribute("String_Node_Str");
    session.removeAttribute("String_Node_Str");
    session.removeAttribute("String_Node_Str");
    return actualRequest;
  }
 else {
    return request;
  }
}
Program: 3677
Project: 3677
Buggy source:
private static void doState(Context c,WorkflowItem wi,int newstate,EPerson newowner) throws SQLException, IOException, AuthorizeException {
  Collection mycollection=wi.getCollection();
  Group mygroup=null;
  wi.setState(newstate);
switch (newstate) {
case WFSTATE_REVIEWPOOL:
    wi.setOwner(null);
  mygroup=mycollection.getWorkflowGroup(1);
if (mygroup != null) {
  createTasks(c,wi,mygroup);
  wi.update();
  notifyGroupOfTask(c,mygroup,wi);
}
 else {
  doState(c,wi,WFSTATE_ADMINPOOL,null);
}
break;
case WFSTATE_REVIEW:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_ADMINPOOL:
wi.setOwner(null);
mygroup=mycollection.getWorkflowGroup(2);
if (mygroup != null) {
createTasks(c,wi,mygroup);
notifyGroupOfTask(c,mygroup,wi);
}
 else {
doState(c,wi,WFSTATE_EDITPOOL,null);
}
break;
case WFSTATE_ADMIN:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_EDITPOOL:
wi.setOwner(null);
mygroup=mycollection.getWorkflowGroup(3);
if (mygroup != null) {
createTasks(c,wi,mygroup);
notifyGroupOfTask(c,mygroup,wi);
}
 else {
doState(c,wi,WFSTATE_ARCHIVE,newowner);
}
break;
case WFSTATE_EDIT:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_ARCHIVE:
try {
deleteTasks(c,wi);
mycollection=wi.getCollection();
Item myitem=archive(c,wi);
notifyOfArchive(c,myitem,mycollection);
DSIndexer.indexItem(c,myitem);
}
 catch (IOException e) {
throw e;
}
catch (SQLException e) {
throw e;
}
break;
}
if (wi != null) wi.update();
}

Fixed version (ground truth):
private static void doState(Context c,WorkflowItem wi,int newstate,EPerson newowner) throws SQLException, IOException, AuthorizeException {
  Collection mycollection=wi.getCollection();
  Group mygroup=null;
  wi.setState(newstate);
switch (newstate) {
case WFSTATE_REVIEWPOOL:
    wi.setOwner(null);
  mygroup=mycollection.getWorkflowGroup(1);
if (mygroup != null) {
  createTasks(c,wi,mygroup);
  wi.update();
  notifyGroupOfTask(c,mygroup,wi);
}
 else {
  doState(c,wi,WFSTATE_ADMINPOOL,null);
}
break;
case WFSTATE_REVIEW:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_ADMINPOOL:
wi.setOwner(null);
mygroup=mycollection.getWorkflowGroup(2);
if (mygroup != null) {
createTasks(c,wi,mygroup);
notifyGroupOfTask(c,mygroup,wi);
}
 else {
doState(c,wi,WFSTATE_EDITPOOL,null);
}
break;
case WFSTATE_ADMIN:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_EDITPOOL:
wi.setOwner(null);
mygroup=mycollection.getWorkflowGroup(3);
if (mygroup != null) {
createTasks(c,wi,mygroup);
notifyGroupOfTask(c,mygroup,wi);
}
 else {
doState(c,wi,WFSTATE_ARCHIVE,newowner);
}
break;
case WFSTATE_EDIT:
deleteTasks(c,wi);
wi.setOwner(newowner);
break;
case WFSTATE_ARCHIVE:
try {
deleteTasks(c,wi);
mycollection=wi.getCollection();
Item myitem=archive(c,wi);
notifyOfArchive(c,myitem,mycollection);
}
 catch (IOException e) {
throw e;
}
catch (SQLException e) {
throw e;
}
break;
}
if (wi != null) wi.update();
}
Program: 3678
Project: 3678
Buggy source:
/** 
 * Set the e-person that originally submitted this item.  This is a public method since it is handled by the WorkspaceItem class in the ingest package. <code>update</code> must be called to write the change to the database.
 * @param sub  the submitter
 */
public void setSubmitter(EPerson sub){
  submitter=sub;
}

Fixed version (ground truth):
/** 
 * Set the e-person that originally submitted this item.  This is a public method since it is handled by the WorkspaceItem class in the ingest package. <code>update</code> must be called to write the change to the database.
 * @param sub  the submitter
 */
public void setSubmitter(EPerson sub){
  submitter=sub;
  if (submitter != null) {
    itemRow.setColumn("String_Node_Str",submitter.getID());
  }
 else {
    itemRow.setColumnNull("String_Node_Str");
  }
}
Program: 3679
Project: 3679
Buggy source:
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  processRequest(request,response,true);
}

Fixed version (ground truth):
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  processRequest(request,response);
}
Program: 3680
Project: 3680
Buggy source:
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  processRequest(request,response,false);
}

Fixed version (ground truth):
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  processRequest(request,response);
}
Program: 3681
Project: 3681
Buggy source:
/** 
 * Process an incoming request
 * @param request    the request object
 * @param response   the response object
 * @param isPost     if true, this is a POST
 */
private void processRequest(HttpServletRequest request,HttpServletResponse response,boolean isPost) throws ServletException, IOException {
  Context context=null;
  UIUtil.storeOriginalURL(request);
  try {
    context=UIUtil.obtainContext(request);
    request=Authenticate.getRealRequest(request);
    if (isPost) {
      doDSPost(context,request,response);
    }
 else {
      doDSGet(context,request,response);
    }
  }
 catch (  SQLException se) {
    log.warn(LogManager.getHeader(context,"String_Node_Str",se.toString()),se);
    UIUtil.sendAlert(request,se);
    JSPManager.showInternalError(request,response);
  }
catch (  AuthorizeException ae) {
    if (context.getCurrentUser() == null) {
      Authenticate.startAuthentication(context,request,response);
    }
 else {
      log.info(LogManager.getHeader(context,"String_Node_Str",ae.toString()));
      JSPManager.showAuthorizeError(request,response,ae);
    }
  }
  if (context != null && context.isValid()) {
    context.abort();
  }
}

Fixed version (ground truth):
/** 
 * Process an incoming request
 * @param request    the request object
 * @param response   the response object
 */
private void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  Context context=null;
  UIUtil.storeOriginalURL(request);
  try {
    context=UIUtil.obtainContext(request);
    request=Authenticate.getRealRequest(request);
    if (log.isDebugEnabled()) {
      log.debug(LogManager.getHeader(context,"String_Node_Str",UIUtil.getRequestLogInfo(request)));
    }
    if (request.getMethod().equals("String_Node_Str")) {
      doDSPost(context,request,response);
    }
 else {
      doDSGet(context,request,response);
    }
  }
 catch (  SQLException se) {
    log.warn(LogManager.getHeader(context,"String_Node_Str",se.toString()),se);
    UIUtil.sendAlert(request,se);
    JSPManager.showInternalError(request,response);
  }
catch (  AuthorizeException ae) {
    if (context.getCurrentUser() == null) {
      Authenticate.startAuthentication(context,request,response);
    }
 else {
      log.info(LogManager.getHeader(context,"String_Node_Str",ae.toString()));
      JSPManager.showAuthorizeError(request,response,ae);
    }
  }
  if (context != null && context.isValid()) {
    context.abort();
  }
}
Program: 3682
Project: 3682
Buggy source:
protected void doDSGet(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  X509Certificate[] certs=(X509Certificate[])request.getAttribute("String_Node_Str");
  if (certs.length == 0) {
    if (request.getParameter("String_Node_Str") != null) {
      log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
      JSPManager.showJSP(request,response,"String_Node_Str");
    }
 else {
      JSPManager.showJSP(request,response,"String_Node_Str");
    }
  }
 else {
    try {
      if (X509Manager.isValid(certs[0])) {
        EPerson eperson=X509Manager.getUser(context,certs[0]);
        if (eperson != null && eperson.getActive()) {
          Authenticate.loggedIn(context,request,eperson);
          log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
          Authenticate.resumeInterruptedRequest(request,response);
          return;
        }
 else {
          log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
          JSPManager.showJSP(request,response,"String_Node_Str");
        }
      }
 else {
        log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
        JSPManager.showJSP(request,response,"String_Node_Str");
      }
    }
 catch (    CertificateException ce) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"),ce);
      JSPManager.showInternalError(request,response);
    }
  }
}

Fixed version (ground truth):
protected void doDSGet(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  X509Certificate[] certs=(X509Certificate[])request.getAttribute("String_Node_Str");
  if (certs == null || certs.length == 0) {
    if (request.getParameter("String_Node_Str") != null) {
      log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
      JSPManager.showJSP(request,response,"String_Node_Str");
    }
 else {
      JSPManager.showJSP(request,response,"String_Node_Str");
    }
  }
 else {
    try {
      if (X509Manager.isValid(certs[0])) {
        EPerson eperson=X509Manager.getUser(context,certs[0]);
        if (eperson != null && eperson.getActive()) {
          Authenticate.loggedIn(context,request,eperson);
          log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
          Authenticate.resumeInterruptedRequest(request,response);
          return;
        }
 else {
          log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
          JSPManager.showJSP(request,response,"String_Node_Str");
        }
      }
 else {
        log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
        JSPManager.showJSP(request,response,"String_Node_Str");
      }
    }
 catch (    CertificateException ce) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"),ce);
      JSPManager.showInternalError(request,response);
    }
  }
}
Program: 3683
Project: 3683
Buggy source:
/** 
 * Set the EPerson's password
 * @param s   the new email
 */
public void setPassword(String s){
  String encoded=encodePassword(s);
  myRow.setColumn("String_Node_Str",encoded);
}

Fixed version (ground truth):
/** 
 * Set the EPerson's password
 * @param s   the new email
 */
public void setPassword(String s){
  String encoded=Utils.getMD5(s);
  myRow.setColumn("String_Node_Str",encoded);
}
Program: 3684
Project: 3684
Buggy source:
/** 
 * Check EPerson's password
 * @param attempt the password attempt
 * @return boolean successful/unsuccessful
 */
public boolean checkPassword(String attempt){
  String encoded=encodePassword(attempt);
  if (attempt.equals(myRow.getStringColumn("String_Node_Str")))   return true;
  return false;
}

Fixed version (ground truth):
/** 
 * Check EPerson's password
 * @param attempt the password attempt
 * @return boolean successful/unsuccessful
 */
public boolean checkPassword(String attempt){
  String encoded=Utils.getMD5(attempt);
  return (encoded.equals(myRow.getStringColumn("String_Node_Str")));
}
Program: 3685
Project: 3685
Buggy source:
/** 
 * Construct an item with the given table row
 * @param context  the context this object exists in
 * @param row      the corresponding row in the table
 */
Item(Context context,TableRow row) throws SQLException {
  ourContext=context;
  itemRow=row;
  dublinCoreChanged=false;
  dublinCore=new ArrayList();
  bundlesChanged=false;
  bundles=new ArrayList();
  submitter=null;
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + itemRow.getIntColumn("String_Node_Str") + "String_Node_Str");
  while (tri.hasNext()) {
    TableRow r=(TableRow)tri.next();
    bundles.add(new Bundle(ourContext,r));
  }
  tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + itemRow.getIntColumn("String_Node_Str"));
  while (tri.hasNext()) {
    TableRow resultRow=(TableRow)tri.next();
    TableRow typeRow=DatabaseManager.find(ourContext,"String_Node_Str",resultRow.getIntColumn("String_Node_Str"));
    DCValue dcv=new DCValue();
    dcv.element=typeRow.getStringColumn("String_Node_Str");
    dcv.qualifier=typeRow.getStringColumn("String_Node_Str");
    dcv.value=resultRow.getStringColumn("String_Node_Str");
    dcv.language=resultRow.getStringColumn("String_Node_Str");
    dublinCore.add(dcv);
  }
}

Fixed version (ground truth):
/** 
 * Construct an item with the given table row
 * @param context  the context this object exists in
 * @param row      the corresponding row in the table
 */
Item(Context context,TableRow row) throws SQLException {
  ourContext=context;
  itemRow=row;
  dublinCoreChanged=false;
  dublinCore=new ArrayList();
  bundlesChanged=false;
  bundles=new ArrayList();
  submitter=null;
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + itemRow.getIntColumn("String_Node_Str") + "String_Node_Str");
  while (tri.hasNext()) {
    TableRow r=(TableRow)tri.next();
    bundles.add(new Bundle(ourContext,r));
  }
  tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + itemRow.getIntColumn("String_Node_Str") + "String_Node_Str");
  while (tri.hasNext()) {
    TableRow resultRow=(TableRow)tri.next();
    TableRow typeRow=DatabaseManager.find(ourContext,"String_Node_Str",resultRow.getIntColumn("String_Node_Str"));
    DCValue dcv=new DCValue();
    dcv.element=typeRow.getStringColumn("String_Node_Str");
    dcv.qualifier=typeRow.getStringColumn("String_Node_Str");
    dcv.value=resultRow.getStringColumn("String_Node_Str");
    dcv.language=resultRow.getStringColumn("String_Node_Str");
    dublinCore.add(dcv);
  }
}
Program: 3686
Project: 3686
Buggy source:
/** 
 * Clear Dublin Core metadata values.  As with <code>addDC</code> above, passing in <code>null</code> only matches fields where the qualifier or language is actually <code>null</code>.  <code>Item.ANY</code> will match any element, qualifier or language, including <code>null</code>. Thus, <code>item.clearDC(Item.ANY, Item.ANY, Item.ANY)</code> will remove all Dublin Core metadata associated with an item.
 * @param element     the Dublin Core element to remove, or<code>Item.ANY</code>
 * @param qualifier   the qualifier.  <code>null</code> means unqualified,and <code>Item.ANY</code> means any qualifier (including unqualified.)
 * @param lang       the ISO639 language code, optionally followed byan underscore and the ISO3166 country code. <code>null</code> means only values with no language are removed, and <code>Item.ANY</code> means values with any country code or no country code are removed.
 */
public void clearDC(String element,String qualifier,String lang) throws AuthorizeException {
  List values=new ArrayList();
  Iterator i=dublinCore.iterator();
  while (i.hasNext()) {
    DCValue dcv=(DCValue)i.next();
    if (!match(element,qualifier,lang,dcv)) {
      values.add(dcv.value);
    }
  }
  dublinCore=values;
}

Fixed version (ground truth):
/** 
 * Clear Dublin Core metadata values.  As with <code>addDC</code> above, passing in <code>null</code> only matches fields where the qualifier or language is actually <code>null</code>.  <code>Item.ANY</code> will match any element, qualifier or language, including <code>null</code>. Thus, <code>item.clearDC(Item.ANY, Item.ANY, Item.ANY)</code> will remove all Dublin Core metadata associated with an item.
 * @param element     the Dublin Core element to remove, or<code>Item.ANY</code>
 * @param qualifier   the qualifier.  <code>null</code> means unqualified,and <code>Item.ANY</code> means any qualifier (including unqualified.)
 * @param lang       the ISO639 language code, optionally followed byan underscore and the ISO3166 country code. <code>null</code> means only values with no language are removed, and <code>Item.ANY</code> means values with any country code or no country code are removed.
 */
public void clearDC(String element,String qualifier,String lang) throws AuthorizeException {
  List values=new ArrayList();
  Iterator i=dublinCore.iterator();
  while (i.hasNext()) {
    DCValue dcv=(DCValue)i.next();
    if (!match(element,qualifier,lang,dcv)) {
      values.add(dcv);
    }
  }
  dublinCore=values;
}
Program: 3687
Project: 3687
Buggy source:
/** 
 * Assign an ID to row
 */
private static synchronized void assignId(TableRow row) throws SQLException {
  String table=canonicalize(row.getTable());
  String pk=getPrimaryKeyColumn(table);
  Integer id=(Integer)ids.get(table);
  int nid=id == null ? -1 : id.intValue() + 1;
  if (id == null) {
    String sql=MessageFormat.format("String_Node_Str",new Object[]{pk,table});
    Statement statement=null;
    try {
      statement=getConnection().createStatement();
      ResultSet results=statement.executeQuery(sql);
      nid=results.next() ? results.getInt(1) : -1;
    }
  finally {
      if (statement != null) {
        try {
          statement.close();
        }
 catch (        SQLException sqle) {
        }
      }
    }
  }
  row.setColumn(pk,nid);
  ids.put(table,new Integer(nid));
}

Fixed version (ground truth):
/** 
 * Assign an ID to row
 */
private static synchronized void assignId(TableRow row) throws SQLException {
  String table=canonicalize(row.getTable());
  String pk=getPrimaryKeyColumn(table);
  Integer id=(Integer)ids.get(table);
  int current_id=id == null ? -1 : id.intValue();
  if (id == null) {
    String sql=MessageFormat.format("String_Node_Str",new Object[]{pk,table});
    Statement statement=null;
    try {
      statement=getConnection().createStatement();
      ResultSet results=statement.executeQuery(sql);
      current_id=results.next() ? results.getInt(1) : -1;
    }
  finally {
      if (statement != null) {
        try {
          statement.close();
        }
 catch (        SQLException sqle) {
        }
      }
    }
  }
  int new_id=current_id + 1;
  row.setColumn(pk,new_id);
  ids.put(table,new Integer(new_id));
}
Program: 3688
Project: 3688
Buggy source:
@Test public void testPerson() throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException {
  Person p=new Person();
  p.setEntityAccessStatus("String_Node_Str");
  p.setEntityId(EntityBase.generateNewID());
  p.setTypeId(0);
  p.setEmail("String_Node_Str");
  p.setFirstName("String_Node_Str");
  p.setLastName("String_Node_Str");
  p.setPhone("String_Node_Str");
  p.save();
  User personOwner=new User();
  personOwner.setFirstName("String_Node_Str");
  personOwner.setLastName("String_Node_Str");
  personOwner.setPhone("String_Node_Str");
  personOwner.setEntityId(EntityBase.generateNewID());
  personOwner.setPassword(EntityBase.generateNewID());
  personOwner.save();
  Person person=(Person)Person.selectByPersonEmail("String_Node_Str");
  Person p1=new Person();
  p1.setEntityAccessStatus("String_Node_Str");
  p1.setEntityId(EntityBase.generateNewID());
  p1.setTypeId(0);
  p1.setPhone("String_Node_Str");
  p1.setFirstName("String_Node_Str");
  assert(person != null);
  p1.setLastName("String_Node_Str");
  p1.setEmail("String_Node_Str");
  p1.setOwner(personOwner);
  p1.save();
  p.delete(true);
  p1.delete(true);
  Person p6=Person.selectByPersonEmail("String_Node_Str");
  assert(p6 == null);
  Person p7=Person.selectByPersonEmail("String_Node_Str");
  assert(p7 == null);
}

Fixed version (ground truth):
@Test public void testPerson() throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException {
  String Id1=EntityBase.generateNewID();
  String Id2=EntityBase.generateNewID();
  String Id3=EntityBase.generateNewID();
  Person p=new Person();
  p.setEntityAccessStatus("String_Node_Str");
  p.setEntityId(Id1);
  p.setTypeId(0);
  p.setEmail("String_Node_Str");
  p.setFirstName("String_Node_Str");
  p.setLastName("String_Node_Str");
  p.setPhone("String_Node_Str");
  p.save();
  User personOwner=new User();
  personOwner.setFirstName("String_Node_Str");
  personOwner.setLastName("String_Node_Str");
  personOwner.setEmail(Id2);
  personOwner.setPhone("String_Node_Str");
  personOwner.setEntityId(Id2);
  personOwner.setPassword(EntityBase.generateNewID());
  personOwner.save();
  Person person=(Person)Person.selectByID(Id1);
  assert(person != null);
  Person p1=new Person();
  p1.setEntityAccessStatus("String_Node_Str");
  p1.setEntityId(Id3);
  p1.setTypeId(0);
  p1.setPhone("String_Node_Str");
  p1.setFirstName("String_Node_Str");
  p1.setLastName("String_Node_Str");
  p1.setEmail("String_Node_Str");
  p1.setOwner(personOwner);
  p1.save();
  Person p4=(Person)Person.selectByID(Id3);
  User u1=(User)User.selectByUsername(Id2);
  assert(p4 != null);
  assert(u1 != null);
  p4.delete(true);
  Person p5=(Person)Person.selectByID(Id3);
  assert(p5 == null);
  User u2=(User)User.selectByUsername(Id2);
  assert(u2 != null);
  u2.delete(true);
  p.delete(true);
  Person p6=(Person)Person.selectByID(Id1);
  User u6=(User)User.selectByUsername(Id2);
  assert(p6 == null);
  assert(u6 == null);
}
Program: 3689
Project: 3689
Buggy source:
@Test public void testPerson() throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException {
  Person p=new Person();
  p.setEntityAccessStatus("String_Node_Str");
  p.setEntityId(EntityBase.generateNewID());
  p.setTypeId(0);
  p.setEmail("String_Node_Str");
  p.setFirstName("String_Node_Str");
  p.setLastName("String_Node_Str");
  p.setPhone("String_Node_Str");
  p.save();
  User personOwner=new User();
  personOwner.setFirstName("String_Node_Str");
  personOwner.setLastName("String_Node_Str");
  personOwner.setPhone("String_Node_Str");
  personOwner.setEntityId(EntityBase.generateNewID());
  personOwner.setPassword(EntityBase.generateNewID());
  personOwner.save();
  Person person=(Person)Person.selectByPersonEmail("String_Node_Str");
  Person p1=new Person();
  p1.setEntityAccessStatus("String_Node_Str");
  p1.setEntityId(EntityBase.generateNewID());
  p1.setTypeId(0);
  p1.setPhone("String_Node_Str");
  p1.setFirstName("String_Node_Str");
  assert(person != null);
  p1.setLastName("String_Node_Str");
  p1.setEmail("String_Node_Str");
  p1.setOwner(personOwner);
  p1.save();
  p.delete(true);
  p1.delete(true);
  Person p6=Person.selectByPersonEmail("String_Node_Str");
  assert(p6 == null);
  Person p7=Person.selectByPersonEmail("String_Node_Str");
  assert(p7 == null);
}

Fixed version (ground truth):
@Test public void testPerson() throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException {
  String Id1=EntityBase.generateNewID();
  String Id2=EntityBase.generateNewID();
  String Id3=EntityBase.generateNewID();
  Person p=new Person();
  p.setEntityAccessStatus("String_Node_Str");
  p.setEntityId(Id1);
  p.setTypeId(0);
  p.setEmail("String_Node_Str");
  p.setFirstName("String_Node_Str");
  p.setLastName("String_Node_Str");
  p.setPhone("String_Node_Str");
  p.save();
  User personOwner=new User();
  personOwner.setFirstName("String_Node_Str");
  personOwner.setLastName("String_Node_Str");
  personOwner.setEmail(Id2);
  personOwner.setPhone("String_Node_Str");
  personOwner.setEntityId(Id2);
  personOwner.setPassword(EntityBase.generateNewID());
  personOwner.save();
  Person person=(Person)Person.selectByID(Id1);
  assert(person != null);
  Person p1=new Person();
  p1.setEntityAccessStatus("String_Node_Str");
  p1.setEntityId(Id3);
  p1.setTypeId(0);
  p1.setPhone("String_Node_Str");
  p1.setFirstName("String_Node_Str");
  p1.setLastName("String_Node_Str");
  p1.setEmail("String_Node_Str");
  p1.setOwner(personOwner);
  p1.save();
  Person p4=(Person)Person.selectByID(Id3);
  User u1=(User)User.selectByUsername(Id2);
  assert(p4 != null);
  assert(u1 != null);
  p4.delete(true);
  Person p5=(Person)Person.selectByID(Id3);
  assert(p5 == null);
  User u2=(User)User.selectByUsername(Id2);
  assert(u2 != null);
  u2.delete(true);
  p.delete(true);
  Person p6=(Person)Person.selectByID(Id1);
  User u6=(User)User.selectByUsername(Id2);
  assert(p6 == null);
  assert(u6 == null);
  ;
}
Program: 3691
Project: 3691
Buggy source:
@Path("String_Node_Str") @PUT @Consumes("String_Node_Str") public String addUser(String json){
  String strName=null;
  try {
    JSONObject content=new JSONObject(json);
    User u=new User();
    u.createNewID();
    if (content.getString("String_Node_Str") != null) {
      u.setFirstName(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setLastName(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setPhone(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setPhone(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setPassword(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setEmail(content.getString("String_Node_Str"));
    }
 else {
      return "String_Node_Str";
    }
    u.save();
    strName=(String)content.get("String_Node_Str");
  }
 catch (  Exception ex) {
    return ex.toString();
  }
  return "String_Node_Str" + strName;
}

Fixed version (ground truth):
@Path("String_Node_Str") @PUT @Consumes("String_Node_Str") public String addUser(String json){
  String strName=null;
  try {
    JSONObject content=new JSONObject(json);
    User u=new User();
    u.createNewID();
    if (content.getString("String_Node_Str") != null) {
      u.setFirstName(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setLastName(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setPhone(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setEmail(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setPassword(content.getString("String_Node_Str"));
    }
    if (content.getString("String_Node_Str") != null) {
      u.setUserName(content.getString("String_Node_Str"));
    }
 else {
      return "String_Node_Str";
    }
    u.save();
    strName=(String)content.get("String_Node_Str");
  }
 catch (  Exception ex) {
    return ex.toString();
  }
  return "String_Node_Str" + strName;
}