Program: 11859
Project: 11859
Buggy source:
/** 
 * <p>Creates the   {@link ExportData} instance and delegates the export work tothe  {@link #doExport(Monitor,ModelExporter.ExportData)} method.</p><p>The  {@link Diagnostic} returned by this method should be used to providethe user some information regarding a <b>successfull</b> export.  If the export fails, an exception should be thrown.<p>
 * @param monitor
 * @return {@link Diagnostic}
 * @throws Exception
 */
public Diagnostic export(Monitor monitor) throws Exception {
  Map<String,GenPackage> nsURIToReferencedGenPackage=null;
  Map<GenPackage,URI> referencedGenPackageToArtifactURI=null;
  if (referencedGenPackageToInfoMap != null) {
    referencedGenPackageToArtifactURI=new HashMap<GenPackage,URI>(referencedGenPackageToInfoMap.size());
    nsURIToReferencedGenPackage=new HashMap<String,GenPackage>(referencedGenPackageToInfoMap.size());
    List<GenPackage> referencedGenPackages=computeValidReferencedGenPackages();
    for (    GenPackage genPackage : referencedGenPackages) {
      URI artifactURI=getReferencedGenPackageExportInfo(genPackage).getArtifactURI();
      referencedGenPackageToArtifactURI.put(genPackage,artifactURI);
      nsURIToReferencedGenPackage.put(genPackage.getNSURI(),genPackage);
    }
  }
  Map<GenPackage,URI> genPackageToArtifactURI=null;
  Map<GenPackage,List<GenPackage>> genPackageToReferencedGenPackages=null;
  if (ePackageToInfoMap != null && ePackageToGenPackageMap != null) {
    genPackageToArtifactURI=new HashMap<GenPackage,URI>(ePackageToInfoMap.size());
    genPackageToReferencedGenPackages=new HashMap<GenPackage,List<GenPackage>>(ePackageToInfoMap.size());
    List<EPackage> ePackages=computeEPackagesToConvert();
    for (    EPackage ePackage : ePackages) {
      GenPackage genPackage=ePackageToGenPackageMap.get(ePackage);
      if (genPackage != null) {
        if (nsURIToReferencedGenPackage != null) {
          List<EPackage> requiredEPackages=ConverterUtil.computeRequiredPackages(ePackage);
          List<GenPackage> requiredGenPackages=new ConverterUtil.GenPackageList(requiredEPackages.size());
          for (          EPackage requiredEPackage : requiredEPackages) {
            GenPackage referencedGenPackage=nsURIToReferencedGenPackage.get(requiredEPackage.getNsURI());
            if (referencedGenPackage != null) {
              requiredGenPackages.add(referencedGenPackage);
            }
          }
          if (!requiredGenPackages.isEmpty()) {
            genPackageToReferencedGenPackages.put(genPackage,requiredGenPackages);
          }
        }
        EPackageExportInfo exportInfo=getEPackageExportInfo(ePackage);
        String artifactLocation=exportInfo.getArtifactLocation();
        if (artifactLocation != null) {
          genPackageToArtifactURI.put(genPackage,computeArtifactURI(artifactLocation));
        }
      }
    }
  }
  if (genPackageToArtifactURI == null || genPackageToArtifactURI.isEmpty()) {
    throw new DiagnosticException(new BasicDiagnostic(Diagnostic.ERROR,ExporterPlugin.ID,0,ExporterPlugin.INSTANCE.getString("String_Node_Str"),null));
  }
 else {
    ExportData exportData=new ExportData();
    exportData.genPackageToArtifactURI=genPackageToArtifactURI;
    exportData.referencedGenPackagesToArtifactURI=referencedGenPackageToArtifactURI != null && !referencedGenPackageToArtifactURI.isEmpty() ? referencedGenPackageToArtifactURI : Collections.<GenPackage,URI>emptyMap();
    exportData.genPackageToReferencedGenPackages=genPackageToReferencedGenPackages != null && !genPackageToReferencedGenPackages.isEmpty() ? genPackageToReferencedGenPackages : Collections.<GenPackage,List<GenPackage>>emptyMap();
    return doExport(monitor,exportData);
  }
}

Fixed version (ground truth):
/** 
 * <p>Creates the   {@link ExportData} instance and delegates the export work tothe  {@link #doExport(Monitor,ModelExporter.ExportData)} method.</p><p>The  {@link Diagnostic} returned by this method should be used to providethe user some information regarding a <b>successful</b> export.  If the export fails, an exception should be thrown.<p>
 * @param monitor
 * @return {@link Diagnostic}
 * @throws Exception
 */
public Diagnostic export(Monitor monitor) throws Exception {
  Map<String,GenPackage> nsURIToReferencedGenPackage=null;
  Map<GenPackage,URI> referencedGenPackageToArtifactURI=null;
  if (referencedGenPackageToInfoMap != null) {
    referencedGenPackageToArtifactURI=new HashMap<GenPackage,URI>(referencedGenPackageToInfoMap.size());
    nsURIToReferencedGenPackage=new HashMap<String,GenPackage>(referencedGenPackageToInfoMap.size());
    List<GenPackage> referencedGenPackages=computeValidReferencedGenPackages();
    for (    GenPackage genPackage : referencedGenPackages) {
      URI artifactURI=getReferencedGenPackageExportInfo(genPackage).getArtifactURI();
      referencedGenPackageToArtifactURI.put(genPackage,artifactURI);
      nsURIToReferencedGenPackage.put(genPackage.getNSURI(),genPackage);
    }
  }
  Map<GenPackage,URI> genPackageToArtifactURI=null;
  Map<GenPackage,List<GenPackage>> genPackageToReferencedGenPackages=null;
  if (ePackageToInfoMap != null && ePackageToGenPackageMap != null) {
    genPackageToArtifactURI=new HashMap<GenPackage,URI>(ePackageToInfoMap.size());
    genPackageToReferencedGenPackages=new HashMap<GenPackage,List<GenPackage>>(ePackageToInfoMap.size());
    List<EPackage> ePackages=computeEPackagesToConvert();
    for (    EPackage ePackage : ePackages) {
      GenPackage genPackage=ePackageToGenPackageMap.get(ePackage);
      if (genPackage != null) {
        if (nsURIToReferencedGenPackage != null) {
          List<EPackage> requiredEPackages=ConverterUtil.computeRequiredPackages(ePackage);
          List<GenPackage> requiredGenPackages=new ConverterUtil.GenPackageList(requiredEPackages.size());
          for (          EPackage requiredEPackage : requiredEPackages) {
            GenPackage referencedGenPackage=nsURIToReferencedGenPackage.get(requiredEPackage.getNsURI());
            if (referencedGenPackage != null) {
              requiredGenPackages.add(referencedGenPackage);
            }
          }
          if (!requiredGenPackages.isEmpty()) {
            genPackageToReferencedGenPackages.put(genPackage,requiredGenPackages);
          }
        }
        EPackageExportInfo exportInfo=getEPackageExportInfo(ePackage);
        String artifactLocation=exportInfo.getArtifactLocation();
        if (artifactLocation != null) {
          genPackageToArtifactURI.put(genPackage,computeArtifactURI(artifactLocation));
        }
      }
    }
  }
  if (genPackageToArtifactURI == null || genPackageToArtifactURI.isEmpty()) {
    throw new DiagnosticException(new BasicDiagnostic(Diagnostic.ERROR,ExporterPlugin.ID,0,ExporterPlugin.INSTANCE.getString("String_Node_Str"),null));
  }
 else {
    ExportData exportData=new ExportData();
    exportData.genPackageToArtifactURI=genPackageToArtifactURI;
    exportData.referencedGenPackagesToArtifactURI=referencedGenPackageToArtifactURI != null && !referencedGenPackageToArtifactURI.isEmpty() ? referencedGenPackageToArtifactURI : Collections.<GenPackage,URI>emptyMap();
    exportData.genPackageToReferencedGenPackages=genPackageToReferencedGenPackages != null && !genPackageToReferencedGenPackages.isEmpty() ? genPackageToReferencedGenPackages : Collections.<GenPackage,List<GenPackage>>emptyMap();
    return doExport(monitor,exportData);
  }
}