nus-yam/ex-repair huggingface dataset:
Program: 52535
Project: 52535
Buggy source:
/** 
 * Write out the AIP for the given item to the given directory. A new directory will be created with the Handle (URL-encoded) as the directory name, and inside, a mets.xml file written, together with the bitstreams.
 * @param context   DSpace context to use
 * @param item      Item to write
 * @param dest      destination directory
 */
public static void writeAIP(Context context,Item item,String dest) throws SQLException, IOException, AuthorizeException, MetsException {
  System.out.println("String_Node_Str" + item.getHandle());
  java.io.File aipDir=new java.io.File(dest + URLEncoder.encode("String_Node_Str" + item.getHandle(),"String_Node_Str"));
  if (!aipDir.mkdir()) {
    throw new IOException("String_Node_Str" + aipDir.toString());
  }
  FileOutputStream out=new FileOutputStream(aipDir.toString() + java.io.File.separator + "String_Node_Str");
  writeMETS(context,item,out);
  out.close();
  Bundle[] bundles=item.getBundles();
  for (int i=0; i < bundles.length; i++) {
    Bitstream[] bitstreams=bundles[i].getBitstreams();
    for (int b=0; b < bitstreams.length; b++) {
      if (bitstreams[b].getFormat().getID() != licenseFormat) {
        out=new FileOutputStream(aipDir.toString() + java.io.File.separator + bitstreams[b].getChecksum());
        InputStream in=bitstreams[b].retrieve();
        Utils.bufferedCopy(in,out);
        out.close();
        in.close();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Write out the AIP for the given item to the given directory. A new directory will be created with the Handle (URL-encoded) as the directory name, and inside, a mets.xml file written, together with the bitstreams.
 * @param context   DSpace context to use
 * @param item      Item to write
 * @param dest      destination directory
 */
public static void writeAIP(Context context,Item item,String dest) throws SQLException, IOException, AuthorizeException, MetsException {
  System.out.println("String_Node_Str" + item.getHandle());
  java.io.File aipDir=new java.io.File(dest + URLEncoder.encode("String_Node_Str" + item.getHandle(),"String_Node_Str"));
  if (!aipDir.mkdir()) {
    throw new IOException("String_Node_Str" + aipDir.toString());
  }
  FileOutputStream out=new FileOutputStream(aipDir.toString() + java.io.File.separator + "String_Node_Str");
  writeMETS(context,item,out);
  out.close();
  Bundle[] bundles=item.getBundles();
  for (int i=0; i < bundles.length; i++) {
    Bitstream[] bitstreams=bundles[i].getBitstreams();
    for (int b=0; b < bitstreams.length; b++) {
      if (bitstreams[b].getFormat().getID() != licenseFormat && AuthorizeManager.authorizeActionBoolean(context,bitstreams[b],Constants.READ)) {
        out=new FileOutputStream(aipDir.toString() + java.io.File.separator + bitstreams[b].getChecksum());
        InputStream in=bitstreams[b].retrieve();
        Utils.bufferedCopy(in,out);
        out.close();
        in.close();
      }
    }
  }
}
Program: 52537
Project: 52537
Buggy source:
/** 
 * Given a contents file and an item, stuffing it with bitstreams from the contents file
 */
private void processContentsFile(Context c,Item i,String path,String filename) throws SQLException, IOException, AuthorizeException {
  String contentspath=path + File.separatorChar + filename;
  String line="String_Node_Str";
  System.out.println("String_Node_Str" + contentspath);
  BufferedReader is=new BufferedReader(new FileReader(contentspath));
  while ((line=is.readLine()) != null) {
    String bundleMarker="String_Node_Str";
    int markerIndex=line.indexOf(bundleMarker);
    if (markerIndex == -1) {
      processContentFileEntry(c,i,path,line,null);
      System.out.println("String_Node_Str" + line);
    }
 else {
      String bundleName=line.substring(markerIndex + bundleMarker.length());
      String bitstreamName=line.substring(0,markerIndex);
      processContentFileEntry(c,i,path,bitstreamName,bundleName);
      System.out.println("String_Node_Str" + bitstreamName + "String_Node_Str"+ bundleName);
    }
  }
  is.close();
}

Fixed version (ground truth):
/** 
 * Given a contents file and an item, stuffing it with bitstreams from the contents file
 */
private void processContentsFile(Context c,Item i,String path,String filename) throws SQLException, IOException, AuthorizeException {
  String contentspath=path + File.separatorChar + filename;
  String line="String_Node_Str";
  System.out.println("String_Node_Str" + contentspath);
  BufferedReader is=new BufferedReader(new FileReader(contentspath));
  while ((line=is.readLine()) != null) {
    if ("String_Node_Str".equals(line.trim()))     continue;
    String bundleMarker="String_Node_Str";
    int markerIndex=line.indexOf(bundleMarker);
    if (markerIndex == -1) {
      processContentFileEntry(c,i,path,line,null);
      System.out.println("String_Node_Str" + line);
    }
 else {
      String bundleName=line.substring(markerIndex + bundleMarker.length());
      String bitstreamName=line.substring(0,markerIndex);
      processContentFileEntry(c,i,path,bitstreamName,bundleName);
      System.out.println("String_Node_Str" + bitstreamName + "String_Node_Str"+ bundleName);
    }
  }
  is.close();
}
Program: 52538
Project: 52538
Buggy source:
private void addDCValue(Item i,Node n) throws TransformerException {
  String value=getStringValue(n);
  String element=getAttributeValue(n,"String_Node_Str");
  String qualifier=getAttributeValue(n,"String_Node_Str");
  String language=getAttributeValue(n,"String_Node_Str");
  System.out.println("String_Node_Str" + element + "String_Node_Str"+ qualifier+ "String_Node_Str"+ value);
  if (qualifier.equals("String_Node_Str"))   qualifier=null;
  if (language.equals("String_Node_Str")) {
    language=ConfigurationManager.getProperty("String_Node_Str");
  }
  if (language == null) {
    language="String_Node_Str";
  }
  i.addDC(element,qualifier,language,value);
}

Fixed version (ground truth):
private void addDCValue(Item i,Node n) throws TransformerException {
  String value=getStringValue(n);
  String element=getAttributeValue(n,"String_Node_Str");
  String qualifier=getAttributeValue(n,"String_Node_Str");
  String language=getAttributeValue(n,"String_Node_Str");
  System.out.println("String_Node_Str" + element + "String_Node_Str"+ qualifier+ "String_Node_Str"+ value);
  if (qualifier.equals("String_Node_Str") || "String_Node_Str".equals(qualifier))   qualifier=null;
  if (language.equals("String_Node_Str")) {
    language=ConfigurationManager.getProperty("String_Node_Str");
  }
  if (language == null) {
    language="String_Node_Str";
  }
  i.addDC(element,qualifier,language,value);
}
Program: 52543
Project: 52543
Buggy source:
/** 
 * Give the community a logo.  Passing in <code>null</code> removes any existing logo.  You will need to set the format of the new logo bitstream before it will work, for example to "JPEG".  Note that <code>update(/code> will need to be called for the change to take effect.  Setting a logo and not calling <code>update</code> later may result in a previous logo lying around as an "orphaned" bitstream.
 * @param is   the stream to use as the new logo
 * @return   the new logo bitstream, or <code>null</code> if there is nologo (<code>null</code> was passed in)
 */
public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (logo != null) {
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
    communityRow.setColumnNull("String_Node_Str");
    logo.delete();
  }
  if (is != null) {
    Bitstream newLogo=Bitstream.create(ourContext,is);
    communityRow.setColumn("String_Node_Str",newLogo.getID());
    logo=newLogo;
    List policies=AuthorizeManager.getPoliciesActionFilter(ourContext,this,Constants.READ);
    AuthorizeManager.addPolicies(ourContext,policies,newLogo);
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID() + "String_Node_Str"+ newLogo.getID()));
  }
  return logo;
}

Fixed version (ground truth):
/** 
 * Give the community a logo.  Passing in <code>null</code> removes any existing logo.  You will need to set the format of the new logo bitstream before it will work, for example to "JPEG".  Note that <code>update(/code> will need to be called for the change to take effect.  Setting a logo and not calling <code>update</code> later may result in a previous logo lying around as an "orphaned" bitstream.
 * @param is   the stream to use as the new logo
 * @return   the new logo bitstream, or <code>null</code> if there is nologo (<code>null</code> was passed in)
 */
public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (logo != null) {
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
    communityRow.setColumnNull("String_Node_Str");
    logo.delete();
    logo=null;
  }
  if (is != null) {
    Bitstream newLogo=Bitstream.create(ourContext,is);
    communityRow.setColumn("String_Node_Str",newLogo.getID());
    logo=newLogo;
    List policies=AuthorizeManager.getPoliciesActionFilter(ourContext,this,Constants.READ);
    AuthorizeManager.addPolicies(ourContext,policies,newLogo);
    log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID() + "String_Node_Str"+ newLogo.getID()));
  }
  return logo;
}
Program: 52544
Project: 52544
Buggy source:
/** 
 * Show an item page
 * @param context     Context object
 * @param request     the HTTP request
 * @param response    the HTTP response
 * @param item        the item
 * @param handle      the item's handle
 */
private void displayItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item,String handle) throws ServletException, IOException, SQLException, AuthorizeException {
  if (item.isWithdrawn()) {
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  AuthorizeManager.authorizeAction(context,item,Constants.READ);
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + handle));
  if (item.canEdit()) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  Collection[] collections=item.getCollections();
  request.setAttribute("String_Node_Str",collections[0]);
  Community[] comms=collections[0].getCommunities();
  request.setAttribute("String_Node_Str",comms[0]);
  request.setAttribute("String_Node_Str",getParents(comms[0],true));
  boolean displayAll=false;
  String modeParam=request.getParameter("String_Node_Str");
  if (modeParam != null && modeParam.equalsIgnoreCase("String_Node_Str")) {
    displayAll=true;
  }
  request.setAttribute("String_Node_Str",new Boolean(displayAll));
  request.setAttribute("String_Node_Str",item);
  request.setAttribute("String_Node_Str",collections);
  JSPManager.showJSP(request,response,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Show an item page
 * @param context     Context object
 * @param request     the HTTP request
 * @param response    the HTTP response
 * @param item        the item
 * @param handle      the item's handle
 */
private void displayItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item,String handle) throws ServletException, IOException, SQLException, AuthorizeException {
  if (item.isWithdrawn()) {
    JSPManager.showJSP(request,response,"String_Node_Str");
    return;
  }
  AuthorizeManager.authorizeAction(context,item,Constants.READ);
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + handle));
  if (item.canEdit()) {
    request.setAttribute("String_Node_Str",new Boolean(true));
  }
  Collection[] collections=item.getCollections();
  request.setAttribute("String_Node_Str",item.getOwningCollection());
  Community[] comms=item.getOwningCollection().getCommunities();
  request.setAttribute("String_Node_Str",comms[0]);
  request.setAttribute("String_Node_Str",getParents(comms[0],true));
  boolean displayAll=false;
  String modeParam=request.getParameter("String_Node_Str");
  if (modeParam != null && modeParam.equalsIgnoreCase("String_Node_Str")) {
    displayAll=true;
  }
  request.setAttribute("String_Node_Str",new Boolean(displayAll));
  request.setAttribute("String_Node_Str",item);
  request.setAttribute("String_Node_Str",collections);
  JSPManager.showJSP(request,response,"String_Node_Str");
}
Program: 52545
Project: 52545
Buggy source:
/** 
 * Get the communities this item is in.  Returns an unordered array of the communities that house the collections this item is in.
 * @return  the communities this item is in.
 */
public Community[] getCommunities() throws SQLException {
  List communities=new ArrayList();
  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 row=tri.next();
    Community fromCache=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      communities.add(fromCache);
    }
 else {
      communities.add(new Community(ourContext,row));
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}

Fixed version (ground truth):
/** 
 * Get the communities this item is in.  Returns an unordered array of the communities that house the collections this item is in, including parent communities of the owning collections.
 * @return  the communities this item is in.
 */
public Community[] getCommunities() throws SQLException {
  List communities=new ArrayList();
  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 row=tri.next();
    Community owner=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (owner == null) {
      owner=new Community(ourContext,row);
    }
    communities.add(owner);
    Community[] parents=owner.getAllParents();
    for (int i=0; i < parents.length; i++) {
      communities.add(parents[i]);
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}
Program: 52547
Project: 52547
Buggy source:
/** 
 * Get the communities this collection appears in
 * @return   array of <code>Community</code> objects
 */
public Community[] getCommunities() throws SQLException {
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  List communities=new ArrayList();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community fromCache=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      communities.add(fromCache);
    }
 else {
      communities.add(new Community(ourContext,row));
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}

Fixed version (ground truth):
/** 
 * Get the communities this collection appears in
 * @return   array of <code>Community</code> objects
 */
public Community[] getCommunities() throws SQLException {
  TableRowIterator tri=DatabaseManager.query(ourContext,"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str" + getID() + "String_Node_Str");
  List communities=new ArrayList();
  while (tri.hasNext()) {
    TableRow row=tri.next();
    Community owner=(Community)ourContext.fromCache(Community.class,row.getIntColumn("String_Node_Str"));
    if (owner == null) {
      owner=new Community(ourContext,row);
    }
    communities.add(owner);
    Community[] parents=owner.getAllParents();
    for (int i=0; i < parents.length; i++) {
      communities.add(parents[i]);
    }
  }
  Community[] communityArray=new Community[communities.size()];
  communityArray=(Community[])communities.toArray(communityArray);
  return communityArray;
}
Program: 52548
Project: 52548
Buggy source:
/** 
 * Delete the community, including the metadata and logo.  Collections and subcommunities that are then orphans are deleted.
 */
public void delete() throws SQLException, AuthorizeException, IOException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.DELETE);
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  DSIndexer.unIndexContent(ourContext,this);
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  ourContext.removeCached(this,getID());
  Collection[] cols=getCollections();
  for (int i=0; i < cols.length; i++) {
    removeCollection(cols[i]);
  }
  Community[] comms=getSubcommunities();
  for (int j=0; j < comms.length; j++) {
    removeSubcommunity(comms[j]);
  }
  setLogo(null);
  AuthorizeManager.removeAllPolicies(ourContext,this);
  DatabaseManager.delete(ourContext,communityRow);
}

Fixed version (ground truth):
/** 
 * Delete the community, including the metadata and logo.  Collections and subcommunities that are then orphans are deleted.
 */
public void delete() throws SQLException, AuthorizeException, IOException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.DELETE);
  Community parent=getParentCommunity();
  if (parent != null) {
    parent.removeSubcommunity(this);
    return;
  }
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  DSIndexer.unIndexContent(ourContext,this);
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  ourContext.removeCached(this,getID());
  Collection[] cols=getCollections();
  for (int i=0; i < cols.length; i++) {
    removeCollection(cols[i]);
  }
  Community[] comms=getSubcommunities();
  for (int j=0; j < comms.length; j++) {
    removeSubcommunity(comms[j]);
  }
  setLogo(null);
  AuthorizeManager.removeAllPolicies(ourContext,this);
  DatabaseManager.delete(ourContext,communityRow);
}
Program: 52550
Project: 52550
Buggy source:
/** 
 * Delete an eperson
 */
public void delete() throws SQLException, AuthorizeException {
  if (!AuthorizeManager.isAdmin(myContext)) {
    throw new AuthorizeException("String_Node_Str");
  }
  HistoryManager.saveHistory(myContext,this,HistoryManager.REMOVE,myContext.getCurrentUser(),myContext.getExtraLogInfo());
  myContext.removeCached(this,getID());
  DatabaseManager.updateQuery(myContext,"String_Node_Str" + getID());
  DatabaseManager.delete(myContext,myRow);
  log.info(LogManager.getHeader(myContext,"String_Node_Str","String_Node_Str" + getID()));
}

Fixed version (ground truth):
/** 
 * Delete an eperson
 */
public void delete() throws SQLException, AuthorizeException, EPersonDeletionException {
  if (!AuthorizeManager.isAdmin(myContext)) {
    throw new AuthorizeException("String_Node_Str");
  }
  HistoryManager.saveHistory(myContext,this,HistoryManager.REMOVE,myContext.getCurrentUser(),myContext.getExtraLogInfo());
  Vector constraintList=getDeleteConstraints();
  if (constraintList.size() > 0)   throw new EPersonDeletionException(constraintList);
  myContext.removeCached(this,getID());
  DatabaseManager.updateQuery(myContext,"String_Node_Str" + getID());
  DatabaseManager.updateQuery(myContext,"String_Node_Str" + getID());
  DatabaseManager.delete(myContext,myRow);
  log.info(LogManager.getHeader(myContext,"String_Node_Str","String_Node_Str" + getID()));
}
Program: 52551
Project: 52551
Buggy source:
/** 
 * Process the input from the upload bitstream page
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processUploadBitstream(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  FileUploadRequest wrapper=new FileUploadRequest(request);
  Bitstream b=null;
  Item item=Item.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  File temp=wrapper.getFile("String_Node_Str");
  InputStream is=new BufferedInputStream(new FileInputStream(temp));
  checkEditAuthorization(context,item);
  Bundle[] bundles=item.getBundles();
  if (bundles.length < 1) {
    b=item.createSingleBitstream(is,"String_Node_Str");
  }
 else {
    b=bundles[0].createBitstream(is);
  }
  String noPath=wrapper.getFilesystemName("String_Node_Str");
  while (noPath.indexOf('/') > -1) {
    noPath=noPath.substring(noPath.indexOf('/') + 1);
  }
  while (noPath.indexOf('\\') > -1) {
    noPath=noPath.substring(noPath.indexOf('\\') + 1);
  }
  b.setName(noPath);
  b.setSource(wrapper.getFilesystemName("String_Node_Str"));
  BitstreamFormat bf=FormatIdentifier.guessFormat(context,b);
  b.setFormat(bf);
  b.update();
  item.update();
  showEditForm(context,request,response,item);
  temp.delete();
  context.complete();
}

Fixed version (ground truth):
/** 
 * Process the input from the upload bitstream page
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processUploadBitstream(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  FileUploadRequest wrapper=new FileUploadRequest(request);
  Bitstream b=null;
  Item item=Item.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  File temp=wrapper.getFile("String_Node_Str");
  InputStream is=new BufferedInputStream(new FileInputStream(temp));
  checkEditAuthorization(context,item);
  Bundle[] bundles=item.getBundles("String_Node_Str");
  if (bundles.length < 1) {
    b=item.createSingleBitstream(is,"String_Node_Str");
  }
 else {
    b=bundles[0].createBitstream(is);
  }
  String noPath=wrapper.getFilesystemName("String_Node_Str");
  while (noPath.indexOf('/') > -1) {
    noPath=noPath.substring(noPath.indexOf('/') + 1);
  }
  while (noPath.indexOf('\\') > -1) {
    noPath=noPath.substring(noPath.indexOf('\\') + 1);
  }
  b.setName(noPath);
  b.setSource(wrapper.getFilesystemName("String_Node_Str"));
  BitstreamFormat bf=FormatIdentifier.guessFormat(context,b);
  b.setFormat(bf);
  b.update();
  item.update();
  showEditForm(context,request,response,item);
  temp.delete();
  context.complete();
}
Program: 52554
Project: 52554
Buggy source:
/** 
 * Render full item record
 */
private void renderFull() throws IOException, java.sql.SQLException {
  JspWriter out=pageContext.getOut();
  DCValue[] values=item.getDC(Item.ANY,Item.ANY,Item.ANY);
  out.println("String_Node_Str");
  HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  for (int i=0; i < values.length; i++) {
    boolean hidden=false;
    if (values[i].element.equals("String_Node_Str") && (values[i].qualifier != null && values[i].qualifier.equals("String_Node_Str"))) {
      hidden=true;
    }
    if (!hidden) {
      out.print("String_Node_Str");
      out.print(values[i].element);
      if (values[i].qualifier != null) {
        out.print("String_Node_Str" + values[i].qualifier);
      }
      out.print("String_Node_Str");
      out.print(values[i].value);
      out.print("String_Node_Str");
      if (values[i].language == null) {
        out.print("String_Node_Str");
      }
 else {
        out.print(values[i].language);
      }
      out.println("String_Node_Str");
    }
  }
  listCollections();
  out.println("String_Node_Str");
  listBitstreams();
}

Fixed version (ground truth):
/** 
 * Render full item record
 */
private void renderFull() throws IOException, java.sql.SQLException {
  JspWriter out=pageContext.getOut();
  DCValue[] values=item.getDC(Item.ANY,Item.ANY,Item.ANY);
  out.println("String_Node_Str");
  HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  for (int i=0; i < values.length; i++) {
    boolean hidden=false;
    if (values[i].element.equals("String_Node_Str") && (values[i].qualifier != null && values[i].qualifier.equals("String_Node_Str"))) {
      hidden=true;
    }
    if (!hidden) {
      out.print("String_Node_Str");
      out.print(values[i].element);
      if (values[i].qualifier != null) {
        out.print("String_Node_Str" + values[i].qualifier);
      }
      out.print("String_Node_Str");
      out.print(Utils.addEntities(values[i].value));
      out.print("String_Node_Str");
      if (values[i].language == null) {
        out.print("String_Node_Str");
      }
 else {
        out.print(values[i].language);
      }
      out.println("String_Node_Str");
    }
  }
  listCollections();
  out.println("String_Node_Str");
  listBitstreams();
}
Program: 52557
Project: 52557
Buggy source:
protected void doDSGet(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  int sortBy=EPerson.LASTNAME;
  String sbParam=request.getParameter("String_Node_Str");
  if (sbParam != null && sbParam.equals("String_Node_Str")) {
    sortBy=EPerson.LASTNAME;
  }
 else   if (sbParam != null && sbParam.equals("String_Node_Str")) {
    sortBy=EPerson.EMAIL;
  }
  int first=UIUtil.getIntParameter(request,"String_Node_Str");
  if (first == -1)   first=0;
  EPerson[] epeople=EPerson.findAll(context,sortBy);
  request.setAttribute("String_Node_Str",new Integer(sortBy));
  request.setAttribute("String_Node_Str",new Integer(first));
  request.setAttribute("String_Node_Str",epeople);
  JSPManager.showJSP(request,response,"String_Node_Str");
}

Fixed version (ground truth):
protected void doDSGet(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  int sortBy=EPerson.LASTNAME;
  String sbParam=request.getParameter("String_Node_Str");
  if (sbParam != null && sbParam.equals("String_Node_Str")) {
    sortBy=EPerson.LASTNAME;
  }
 else   if (sbParam != null && sbParam.equals("String_Node_Str")) {
    sortBy=EPerson.EMAIL;
  }
 else   if (sbParam != null && sbParam.equals("String_Node_Str")) {
    sortBy=EPerson.ID;
  }
  int first=UIUtil.getIntParameter(request,"String_Node_Str");
  if (first == -1)   first=0;
  EPerson[] epeople=EPerson.findAll(context,sortBy);
  request.setAttribute("String_Node_Str",new Integer(sortBy));
  request.setAttribute("String_Node_Str",new Integer(first));
  request.setAttribute("String_Node_Str",epeople);
  JSPManager.showJSP(request,response,"String_Node_Str");
}
Program: 52558
Project: 52558
Buggy source:
/** 
 * Create a workflow group for the given step if one does not already exist. Returns either the newly created group or the previously existing one. Note that while the new group is created in the database, the association between the group and the collection is not written until <code>update</code> is called.
 * @param step  the step (1-3) of the workflow to create or get the groupfor
 * @return  the workflow group associated with this collection
 */
public Group createWorkflowGroup(int step) throws SQLException, AuthorizeException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (workflowGroup[step - 1] == null) {
    workflowGroup[step - 1]=Group.create(ourContext);
    workflowGroup[step - 1].setName("String_Node_Str" + getID() + "String_Node_Str"+ step);
    workflowGroup[step - 1].update();
  }
  return workflowGroup[step - 1];
}

Fixed version (ground truth):
/** 
 * Create a workflow group for the given step if one does not already exist. Returns either the newly created group or the previously existing one. Note that while the new group is created in the database, the association between the group and the collection is not written until <code>update</code> is called.
 * @param step  the step (1-3) of the workflow to create or get the groupfor
 * @return  the workflow group associated with this collection
 */
public Group createWorkflowGroup(int step) throws SQLException, AuthorizeException {
  AuthorizeManager.authorizeAction(ourContext,this,Constants.WRITE);
  if (workflowGroup[step - 1] == null) {
    Group g=Group.create(ourContext);
    g.setName("String_Node_Str" + getID() + "String_Node_Str"+ step);
    g.update();
    setWorkflowGroup(step,g);
  }
  return workflowGroup[step - 1];
}
Program: 52560
Project: 52560
Buggy source:
/** 
 * Do a query, restricted to a community
 * @param querystring
 * @param community
 * @return HashMap results, same as full doQuery, only hits in a Community
 */
public static QueryResults doQuery(Context c,QueryArgs args,Community comm) throws IOException, ParseException {
  String querystring=args.getQuery();
  querystring=checkEmptyQuery(querystring);
  String location="String_Node_Str" + (comm.getID());
  String newquery=new String("String_Node_Str" + querystring + "String_Node_Str"+ location+ "String_Node_Str");
  args.setQuery(newquery);
  return doQuery(c,args);
}

Fixed version (ground truth):
/** 
 * Do a query, restricted to a community
 * @param querystring
 * @param community
 * @return HashMap results, same as full doQuery, only hits in a Community
 */
public static QueryResults doQuery(Context c,QueryArgs args,Community comm) throws IOException {
  String querystring=args.getQuery();
  querystring=checkEmptyQuery(querystring);
  String location="String_Node_Str" + (comm.getID());
  String newquery=new String("String_Node_Str" + querystring + "String_Node_Str"+ location+ "String_Node_Str");
  args.setQuery(newquery);
  return doQuery(c,args);
}
Program: 52562
Project: 52562
Buggy source:
/** 
 * Format SQL according to the browse type.
 */
private static String formatSql(BrowseScope scope,String sql,String subqueryValue,boolean after){
  boolean before=!after;
  int browseType=scope.getBrowseType();
  boolean ascending=scope.getAscending();
  int numberDesired=before ? scope.getNumberBefore() : scope.getTotal();
  String beforeOperator="String_Node_Str";
  String afterOperator="String_Node_Str";
  if (browseType == ITEMS_BY_AUTHOR_BROWSE)   afterOperator="String_Node_Str";
  if (subqueryValue != null) {
    beforeOperator="String_Node_Str";
    afterOperator="String_Node_Str";
  }
  if (!ascending) {
    beforeOperator="String_Node_Str";
    afterOperator="String_Node_Str";
  }
  String beforeSubqueryOperator="String_Node_Str";
  String afterSubqueryOperator="String_Node_Str";
  if (browseType == ITEMS_BY_AUTHOR_BROWSE)   afterSubqueryOperator="String_Node_Str";
  if (!ascending) {
    beforeSubqueryOperator="String_Node_Str";
    afterSubqueryOperator="String_Node_Str";
  }
  String order=before ? "String_Node_Str" : "String_Node_Str";
  if (!ascending)   order=before ? "String_Node_Str" : "String_Node_Str";
  List args=new ArrayList();
  args.add(before ? beforeSubqueryOperator : afterSubqueryOperator);
  args.add(before ? beforeOperator : afterOperator);
  args.add(order);
  args.add(new Integer(numberDesired));
  return MessageFormat.format(sql,args.toArray());
}

Fixed version (ground truth):
/** 
 * Format SQL according to the browse type.
 */
private static String formatSql(BrowseScope scope,String sql,String subqueryValue,boolean after){
  boolean before=!after;
  int browseType=scope.getBrowseType();
  boolean ascending=scope.getAscending();
  int numberDesired=before ? scope.getNumberBefore() : scope.getTotal();
  String beforeOperator="String_Node_Str";
  String afterOperator="String_Node_Str";
  if (browseType == ITEMS_BY_AUTHOR_BROWSE)   afterOperator="String_Node_Str";
  if (subqueryValue != null) {
    beforeOperator="String_Node_Str";
    afterOperator="String_Node_Str";
  }
  if (!ascending) {
    beforeOperator="String_Node_Str";
    afterOperator="String_Node_Str";
  }
  if (browseType == ITEMS_BY_DATE_BROWSE) {
    if (!ascending) {
      beforeOperator="String_Node_Str";
      afterOperator="String_Node_Str";
    }
 else {
      beforeOperator="String_Node_Str";
      afterOperator="String_Node_Str";
    }
  }
  String beforeSubqueryOperator="String_Node_Str";
  String afterSubqueryOperator="String_Node_Str";
  if (browseType == ITEMS_BY_AUTHOR_BROWSE)   afterSubqueryOperator="String_Node_Str";
  if (!ascending) {
    beforeSubqueryOperator="String_Node_Str";
    afterSubqueryOperator="String_Node_Str";
  }
  String order=before ? "String_Node_Str" : "String_Node_Str";
  if (!ascending)   order=before ? "String_Node_Str" : "String_Node_Str";
  List args=new ArrayList();
  args.add(before ? beforeSubqueryOperator : afterSubqueryOperator);
  args.add(before ? beforeOperator : afterOperator);
  args.add(order);
  args.add(new Integer(numberDesired));
  return MessageFormat.format(sql,args.toArray());
}
Program: 52565
Project: 52565
Buggy source:
static String stripAsterisk(String myquery){
  Perl5Util util=new Perl5Util();
  myquery=util.substitute("String_Node_Str",myquery);
  myquery=util.substitute("String_Node_Str",myquery);
  return myquery;
}

Fixed version (ground truth):
static String stripAsterisk(String myquery){
  Perl5Util util=new Perl5Util();
  myquery=util.substitute("String_Node_Str",myquery);
  myquery=util.substitute("String_Node_Str",myquery);
  myquery=util.substitute("String_Node_Str",myquery);
  myquery=util.substitute("String_Node_Str",myquery);
  return myquery;
}
Program: 52566
Project: 52566
Buggy source:
/** 
 * Command line interface to setPolicies - run to see arguments
 */
public static void main(String[] argv) throws Exception {
  Context c=new Context();
  c.setIgnoreAuthorization(true);
  Collection[] collections=Collection.findAll(c);
  for (int i=0; i < collections.length; i++) {
    Collection t=collections[i];
    System.out.println("String_Node_Str" + t + "String_Node_Str"+ t.getMetadata("String_Node_Str"));
    if (checkForPolicy(c,t,Constants.READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.READ);
    }
    if (checkForPolicy(c,t,Constants.DEFAULT_ITEM_READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.DEFAULT_ITEM_READ);
    }
    if (checkForPolicy(c,t,Constants.DEFAULT_BITSTREAM_READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.DEFAULT_BITSTREAM_READ);
    }
  }
  Community[] communities=Community.findAll(c);
  for (int i=0; i < collections.length; i++) {
    Community t=communities[i];
    System.out.println("String_Node_Str" + t + "String_Node_Str"+ t.getMetadata("String_Node_Str"));
    if (checkForPolicy(c,t,Constants.READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.READ);
    }
  }
  c.complete();
}

Fixed version (ground truth):
/** 
 * Command line interface to setPolicies - run to see arguments
 */
public static void main(String[] argv) throws Exception {
  Context c=new Context();
  c.setIgnoreAuthorization(true);
  Collection[] collections=Collection.findAll(c);
  for (int i=0; i < collections.length; i++) {
    Collection t=collections[i];
    System.out.println("String_Node_Str" + t + "String_Node_Str"+ t.getMetadata("String_Node_Str"));
    if (checkForPolicy(c,t,Constants.READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.READ);
    }
    if (checkForPolicy(c,t,Constants.DEFAULT_ITEM_READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.DEFAULT_ITEM_READ);
    }
    if (checkForPolicy(c,t,Constants.DEFAULT_BITSTREAM_READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.DEFAULT_BITSTREAM_READ);
    }
  }
  Community[] communities=Community.findAll(c);
  for (int i=0; i < communities.length; i++) {
    Community t=communities[i];
    System.out.println("String_Node_Str" + t + "String_Node_Str"+ t.getMetadata("String_Node_Str"));
    if (checkForPolicy(c,t,Constants.READ)) {
      System.out.println("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str");
      addAnonymousPolicy(c,t,Constants.READ);
    }
  }
  c.complete();
}
Program: 52567
Project: 52567
Buggy source:
/** 
 * Reinstate a withdrawn item
 */
public void reinstate() throws SQLException, AuthorizeException, IOException {
  String timestamp=DCDate.getCurrent().toString();
  String collectionProv="String_Node_Str";
  Collection[] colls=getCollections();
  for (int i=0; i < colls.length; i++) {
    collectionProv=collectionProv + colls[i].getMetadata("String_Node_Str") + "String_Node_Str"+ colls[i].getID()+ "String_Node_Str";
    AuthorizeManager.authorizeAction(ourContext,colls[i],Constants.ADD);
  }
  itemRow.setColumn("String_Node_Str",false);
  itemRow.setColumn("String_Node_Str",true);
  EPerson e=ourContext.getCurrentUser();
  String prov="String_Node_Str" + e.getFullName() + "String_Node_Str"+ e.getEmail()+ "String_Node_Str"+ timestamp+ "String_Node_Str"+ "String_Node_Str"+ collectionProv+ InstallItem.getBitstreamProvenanceMessage(this);
  addDC("String_Node_Str","String_Node_Str","String_Node_Str",prov);
  update();
  HistoryManager.saveHistory(ourContext,this,HistoryManager.MODIFY,e,ourContext.getExtraLogInfo());
  Browse.itemAdded(ourContext,this);
  DSIndexer.indexContent(ourContext,this);
  if (colls.length > 0) {
    inheritCollectionDefaultPolicies(colls[0]);
  }
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + e.getEmail() + "String_Node_Str"+ getID()));
}

Fixed version (ground truth):
/** 
 * Reinstate a withdrawn item
 */
public void reinstate() throws SQLException, AuthorizeException, IOException {
  String timestamp=DCDate.getCurrent().toString();
  String collectionProv="String_Node_Str";
  Collection[] colls=getCollections();
  for (int i=0; i < colls.length; i++) {
    collectionProv=collectionProv + colls[i].getMetadata("String_Node_Str") + "String_Node_Str"+ colls[i].getID()+ "String_Node_Str";
    AuthorizeManager.authorizeAction(ourContext,colls[i],Constants.ADD);
  }
  itemRow.setColumn("String_Node_Str",false);
  itemRow.setColumn("String_Node_Str",true);
  EPerson e=ourContext.getCurrentUser();
  String prov="String_Node_Str" + e.getFullName() + "String_Node_Str"+ e.getEmail()+ "String_Node_Str"+ timestamp+ "String_Node_Str"+ "String_Node_Str"+ collectionProv+ InstallItem.getBitstreamProvenanceMessage(this);
  addDC("String_Node_Str","String_Node_Str","String_Node_Str",prov);
  update();
  HistoryManager.saveHistory(ourContext,this,HistoryManager.MODIFY,e,ourContext.getExtraLogInfo());
  DSIndexer.indexContent(ourContext,this);
  if (colls.length > 0) {
    inheritCollectionDefaultPolicies(colls[0]);
  }
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + e.getEmail() + "String_Node_Str"+ getID()));
}
Program: 52568
Project: 52568
Buggy source:
/** 
 * Create a new item, with a new internal ID.  This method is not public, since items need to be created as workspace items.  Authorisation is the responsibility of the caller.
 * @param context  DSpace context object
 * @return  the newly created item
 */
static Item create(Context context) throws SQLException {
  TableRow row=DatabaseManager.create(context,"String_Node_Str");
  Item i=new Item(context,row);
  HistoryManager.saveHistory(context,i,HistoryManager.CREATE,context.getCurrentUser(),context.getExtraLogInfo());
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + row.getIntColumn("String_Node_Str")));
  return i;
}

Fixed version (ground truth):
/** 
 * Create a new item, with a new internal ID.  This method is not public, since items need to be created as workspace items.  Authorisation is the responsibility of the caller.
 * @param context  DSpace context object
 * @return  the newly created item
 */
static Item create(Context context) throws SQLException, AuthorizeException {
  TableRow row=DatabaseManager.create(context,"String_Node_Str");
  Item i=new Item(context,row);
  i.update();
  HistoryManager.saveHistory(context,i,HistoryManager.CREATE,context.getCurrentUser(),context.getExtraLogInfo());
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + row.getIntColumn("String_Node_Str")));
  return i;
}
Program: 52570
Project: 52570
Buggy source:
public String buildQuery(HttpServletRequest request){
  String newquery="String_Node_Str";
  String query1=request.getParameter("String_Node_Str");
  String query2=request.getParameter("String_Node_Str");
  String query3=request.getParameter("String_Node_Str");
  String field1=request.getParameter("String_Node_Str");
  String field2=request.getParameter("String_Node_Str");
  String field3=request.getParameter("String_Node_Str");
  String conjunction1=request.getParameter("String_Node_Str");
  String conjunction2=request.getParameter("String_Node_Str");
  if (query1.length() > 0) {
    if (!field1.equals("String_Node_Str")) {
      newquery=newquery + field1 + "String_Node_Str";
    }
    newquery=newquery + '"' + query1+ '"';
  }
  if (query2.length() > 0) {
    newquery=newquery + "String_Node_Str" + conjunction1+ "String_Node_Str";
    if (!field2.equals("String_Node_Str")) {
      newquery=newquery + field2 + "String_Node_Str";
    }
    newquery=newquery + '"' + query2+ '"';
  }
  newquery=newquery + "String_Node_Str";
  if (query3.length() > 0) {
    newquery=newquery + "String_Node_Str" + conjunction2+ "String_Node_Str";
    if (!field3.equals("String_Node_Str")) {
      newquery=newquery + field3 + "String_Node_Str";
    }
    newquery=newquery + "String_Node_Str" + query3+ "String_Node_Str";
  }
  return (newquery);
}

Fixed version (ground truth):
public String buildQuery(HttpServletRequest request){
  String newquery="String_Node_Str";
  String query1=request.getParameter("String_Node_Str");
  String query2=request.getParameter("String_Node_Str");
  String query3=request.getParameter("String_Node_Str");
  String field1=request.getParameter("String_Node_Str");
  String field2=request.getParameter("String_Node_Str");
  String field3=request.getParameter("String_Node_Str");
  String conjunction1=request.getParameter("String_Node_Str");
  String conjunction2=request.getParameter("String_Node_Str");
  if (query1.length() > 0) {
    newquery=newquery + buildQueryPart(query1,field1);
  }
  if (query2.length() > 0) {
    newquery=newquery + "String_Node_Str" + conjunction1+ "String_Node_Str";
    newquery=newquery + buildQueryPart(query2,field2);
  }
  newquery=newquery + "String_Node_Str";
  if (query3.length() > 0) {
    newquery=newquery + "String_Node_Str" + conjunction2+ "String_Node_Str";
    newquery=newquery + buildQueryPart(query3,field3);
  }
  return (newquery);
}
Program: 52571
Project: 52571
Buggy source:
/** 
 * Delete the collection, including the metadata and logo.  Items that are then orphans are deleted. Groups associated with this collection (workflow participants and submitters) are NOT deleted.
 */
void delete() throws SQLException, AuthorizeException, IOException {
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  DSIndexer.unIndexContent(ourContext,this);
  ourContext.removeCached(this,getID());
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  ItemIterator items=getItems();
  while (items.hasNext()) {
    removeItem(items.next());
  }
  setLogo(null);
  DatabaseManager.delete(ourContext,collectionRow);
  AuthorizeManager.removeAllPolicies(ourContext,this);
  Group g=null;
  g=getWorkflowGroup(1);
  if (g != null) {
    g.delete();
  }
  g=getWorkflowGroup(2);
  if (g != null) {
    g.delete();
  }
  g=getWorkflowGroup(3);
  if (g != null) {
    g.delete();
  }
}

Fixed version (ground truth):
/** 
 * Delete the collection, including the metadata and logo.  Items that are then orphans are deleted. Groups associated with this collection (workflow participants and submitters) are NOT deleted.
 */
void delete() throws SQLException, AuthorizeException, IOException {
  log.info(LogManager.getHeader(ourContext,"String_Node_Str","String_Node_Str" + getID()));
  DSIndexer.unIndexContent(ourContext,this);
  ourContext.removeCached(this,getID());
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  ItemIterator items=getItems();
  while (items.hasNext()) {
    removeItem(items.next());
  }
  setLogo(null);
  AuthorizeManager.removeAllPolicies(ourContext,this);
  WorkflowItem[] wfarray=WorkflowItem.findByCollection(ourContext,this);
  for (int x=0; x < wfarray.length; x++) {
    Item myItem=wfarray[x].getItem();
    wfarray[x].deleteWrapper();
    myItem.delete();
  }
  WorkspaceItem[] wsarray=WorkspaceItem.findByCollection(ourContext,this);
  for (int x=0; x < wsarray.length; x++) {
    wsarray[x].deleteAll();
  }
  DatabaseManager.delete(ourContext,collectionRow);
  Group g=null;
  g=getWorkflowGroup(1);
  if (g != null) {
    g.delete();
  }
  g=getWorkflowGroup(2);
  if (g != null) {
    g.delete();
  }
  g=getWorkflowGroup(3);
  if (g != null) {
    g.delete();
  }
}
Program: 52572
Project: 52572
Buggy source:
/** 
 * delete the WorkflowItem, retaining the Item
 */
public void deleteWrapper() throws SQLException, IOException, AuthorizeException {
  ourContext.removeCached(this,getID());
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  DatabaseManager.delete(ourContext,wfRow);
}

Fixed version (ground truth):
/** 
 * delete the WorkflowItem, retaining the Item
 */
public void deleteWrapper() throws SQLException, IOException, AuthorizeException {
  ourContext.removeCached(this,getID());
  HistoryManager.saveHistory(ourContext,this,HistoryManager.REMOVE,ourContext.getCurrentUser(),ourContext.getExtraLogInfo());
  WorkflowManager.deleteTasks(ourContext,this);
  DatabaseManager.delete(ourContext,wfRow);
}
Program: 52573
Project: 52573
Buggy source:
private static void deleteTasks(Context c,WorkflowItem wi) throws SQLException {
  String myrequest="String_Node_Str" + wi.getID();
  DatabaseManager.updateQuery(c,myrequest);
}

Fixed version (ground truth):
static void deleteTasks(Context c,WorkflowItem wi) throws SQLException {
  String myrequest="String_Node_Str" + wi.getID();
  DatabaseManager.updateQuery(c,myrequest);
}