Program: 51961
Project: 51961
Buggy source:
/** 
 * Given a local file or public URL to a zip file that has the Simple Archive Format, this method imports the contents to DSpace
 * @param filepath The filepath to local file or the public URL of the zip file
 * @param owningCollection The owning collection the items will belong to
 * @param otherCollections The collections the created items will be inserted to, apart from the owning one
 * @param resumeDir In case of a resume request, the directory that containsthe old mapfile and data 
 * @param inputType The input type of the data (bibtex, csv, etc.), in case of local file
 * @param context The context
 * @throws Exception
 */
@Override public void processUIImport(String filepath,Collection owningCollection,String[] otherCollections,String resumeDir,String inputType,Context context,final boolean template) throws Exception {
  final EPerson oldEPerson=context.getCurrentUser();
  final String[] theOtherCollections=otherCollections;
  final Collection theOwningCollection=owningCollection;
  final String theFilePath=filepath;
  final String theInputType=inputType;
  final String theResumeDir=resumeDir;
  final boolean useTemplateItem=template;
  Thread go=new Thread(){
    @Override public void run(){
      Context context=null;
      String importDir=null;
      EPerson eperson=null;
      try {
        context=new Context();
        eperson=ePersonService.find(context,oldEPerson.getID());
        context.setCurrentUser(eperson);
        context.setIgnoreAuthorization(true);
        boolean isResume=theResumeDir != null;
        List<Collection> collectionList=new ArrayList<>();
        if (theOtherCollections != null) {
          for (          String colID : theOtherCollections) {
            UUID colId=UUID.fromString(colID);
            if (!theOwningCollection.getID().equals(colId)) {
              Collection col=collectionService.find(context,colId);
              if (col != null) {
                collectionList.add(col);
              }
            }
          }
        }
        importDir=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ context.getCurrentUser().getID()+ File.separator+ (isResume ? theResumeDir : (new GregorianCalendar()).getTimeInMillis());
        File importDirFile=new File(importDir);
        if (!importDirFile.exists()) {
          boolean success=importDirFile.mkdirs();
          if (!success) {
            log.info("String_Node_Str");
            throw new Exception("String_Node_Str");
          }
        }
        String dataPath=null;
        String dataDir=null;
        if (theInputType.equals("String_Node_Str")) {
          dataPath=importDirFile + File.separator + "String_Node_Str";
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else         if (theInputType.equals("String_Node_Str")) {
          FileUtils.copyFileToDirectory(new File(theFilePath),importDirFile);
          dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else {
          dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
        if (isResume) {
          if (!theInputType.equals("String_Node_Str")) {
            (new File(dataPath)).delete();
          }
          (new File(importDirFile + File.separator + "String_Node_Str")).delete();
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          FileDeleteStrategy.FORCE.delete(new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
        }
        String sourcePath=null;
        if (theInputType.equals("String_Node_Str")) {
          OutputStream os=new FileOutputStream(dataPath);
          byte[] b=new byte[2048];
          int length;
          InputStream is=new URL(theFilePath).openStream();
          while ((length=is.read(b)) != -1) {
            os.write(b,0,length);
          }
          is.close();
          os.close();
          sourcePath=unzip(new File(dataPath),dataDir);
          FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else         if (theInputType.equals("String_Node_Str")) {
          sourcePath=unzip(new File(dataPath),dataDir);
          FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
        String mapFilePath=importDirFile + File.separator + "String_Node_Str";
        List<Collection> finalCollections=null;
        if (theOwningCollection != null) {
          finalCollections.add(theOwningCollection);
          finalCollections.addAll(collectionList);
        }
        setResume(isResume);
        if (theInputType.equals("String_Node_Str") || theInputType.equals("String_Node_Str")) {
          addItems(context,finalCollections,dataDir,mapFilePath,template);
        }
 else {
          addBTEItems(context,finalCollections,theFilePath,mapFilePath,useTemplateItem,theInputType,dataDir);
        }
        emailSuccessMessage(context,eperson,mapFilePath);
        context.complete();
      }
 catch (      Exception e) {
        e.printStackTrace();
        String exceptionString=ExceptionUtils.getStackTrace(e);
        try {
          File importDirFile=new File(importDir + File.separator + "String_Node_Str");
          PrintWriter errorWriter=new PrintWriter(importDirFile);
          errorWriter.print(exceptionString);
          errorWriter.close();
          emailErrorMessage(eperson,exceptionString);
          throw new Exception(e.getMessage());
        }
 catch (        Exception e2) {
        }
      }
 finally {
        try {
          context.complete();
        }
 catch (        SQLException sqle) {
          context.abort();
        }
      }
    }
  }
;
  go.isDaemon();
  go.start();
}

Fixed version (ground truth):
/** 
 * Given a local file or public URL to a zip file that has the Simple Archive Format, this method imports the contents to DSpace
 * @param filepath The filepath to local file or the public URL of the zip file
 * @param owningCollection The owning collection the items will belong to
 * @param otherCollections The collections the created items will be inserted to, apart from the owning one
 * @param resumeDir In case of a resume request, the directory that containsthe old mapfile and data 
 * @param inputType The input type of the data (bibtex, csv, etc.), in case of local file
 * @param context The context
 * @throws Exception
 */
@Override public void processUIImport(String filepath,Collection owningCollection,String[] otherCollections,String resumeDir,String inputType,Context context,final boolean template) throws Exception {
  final EPerson oldEPerson=context.getCurrentUser();
  final String[] theOtherCollections=otherCollections;
  final Collection theOwningCollection=owningCollection;
  final String theFilePath=filepath;
  final String theInputType=inputType;
  final String theResumeDir=resumeDir;
  final boolean useTemplateItem=template;
  Thread go=new Thread(){
    @Override public void run(){
      Context context=null;
      String importDir=null;
      EPerson eperson=null;
      try {
        context=new Context();
        eperson=ePersonService.find(context,oldEPerson.getID());
        context.setCurrentUser(eperson);
        context.setIgnoreAuthorization(true);
        boolean isResume=theResumeDir != null;
        List<Collection> collectionList=new ArrayList<>();
        if (theOtherCollections != null) {
          for (          String colID : theOtherCollections) {
            UUID colId=UUID.fromString(colID);
            if (!theOwningCollection.getID().equals(colId)) {
              Collection col=collectionService.find(context,colId);
              if (col != null) {
                collectionList.add(col);
              }
            }
          }
        }
        importDir=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ context.getCurrentUser().getID()+ File.separator+ (isResume ? theResumeDir : (new GregorianCalendar()).getTimeInMillis());
        File importDirFile=new File(importDir);
        if (!importDirFile.exists()) {
          boolean success=importDirFile.mkdirs();
          if (!success) {
            log.info("String_Node_Str");
            throw new Exception("String_Node_Str");
          }
        }
        String dataPath=null;
        String dataDir=null;
        if (theInputType.equals("String_Node_Str")) {
          dataPath=importDirFile + File.separator + "String_Node_Str";
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else         if (theInputType.equals("String_Node_Str")) {
          FileUtils.copyFileToDirectory(new File(theFilePath),importDirFile);
          dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else {
          dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
        if (isResume) {
          if (!theInputType.equals("String_Node_Str")) {
            (new File(dataPath)).delete();
          }
          (new File(importDirFile + File.separator + "String_Node_Str")).delete();
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          FileDeleteStrategy.FORCE.delete(new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
        }
        String sourcePath=null;
        if (theInputType.equals("String_Node_Str")) {
          OutputStream os=new FileOutputStream(dataPath);
          byte[] b=new byte[2048];
          int length;
          InputStream is=new URL(theFilePath).openStream();
          while ((length=is.read(b)) != -1) {
            os.write(b,0,length);
          }
          is.close();
          os.close();
          sourcePath=unzip(new File(dataPath),dataDir);
          FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
 else         if (theInputType.equals("String_Node_Str")) {
          sourcePath=unzip(new File(dataPath),dataDir);
          FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
          FileDeleteStrategy.FORCE.delete(new File(dataDir));
          dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
        }
        String mapFilePath=importDirFile + File.separator + "String_Node_Str";
        List<Collection> finalCollections=null;
        if (theOwningCollection != null) {
          finalCollections=new ArrayList<>();
          finalCollections.add(theOwningCollection);
          finalCollections.addAll(collectionList);
        }
        setResume(isResume);
        if (theInputType.equals("String_Node_Str") || theInputType.equals("String_Node_Str")) {
          addItems(context,finalCollections,dataDir,mapFilePath,template);
        }
 else {
          addBTEItems(context,finalCollections,theFilePath,mapFilePath,useTemplateItem,theInputType,dataDir);
        }
        emailSuccessMessage(context,eperson,mapFilePath);
        context.complete();
      }
 catch (      Exception e) {
        e.printStackTrace();
        String exceptionString=ExceptionUtils.getStackTrace(e);
        try {
          File importDirFile=new File(importDir + File.separator + "String_Node_Str");
          PrintWriter errorWriter=new PrintWriter(importDirFile);
          errorWriter.print(exceptionString);
          errorWriter.close();
          emailErrorMessage(eperson,exceptionString);
          throw new Exception(e.getMessage());
        }
 catch (        Exception e2) {
        }
      }
 finally {
        try {
          context.complete();
        }
 catch (        SQLException sqle) {
          context.abort();
        }
      }
    }
  }
;
  go.isDaemon();
  go.start();
}