/**
   * Méthode métier du moteur d'importExport créant toutes les publications massives définies au
   * niveau du fichier d'import xml passé en paramètre au moteur d'importExport.
   *
   * @param userDetail - contient les informations sur l'utilisateur du moteur d'importExport
   * @param repositoriesType - objet mappé par castor contenant toutes les informations de création
   *     des publications du path défini
   * @return un objet ComponentReport contenant les informations de création des publications
   *     unitaires et nécéssaire au rapport détaillé
   */
  public void processImport(
      RepositoriesType repositoriesType,
      ImportSettings settings,
      ImportReportManager reportManager) {
    List<RepositoryType> listRep_Type = repositoriesType.getListRepositoryType();
    Iterator<RepositoryType> itListRep_Type = listRep_Type.iterator();
    AttachmentImportExport attachmentIE = new AttachmentImportExport();
    VersioningImportExport versioningIE = new VersioningImportExport(settings.getUser());
    PdcImportExport pdcIE = new PdcImportExport();

    while (itListRep_Type.hasNext()) {
      RepositoryType rep_Type = itListRep_Type.next();

      String componentId = rep_Type.getComponentId();
      int topicId = rep_Type.getTopicId();
      String sPath = rep_Type.getPath();

      // Création du rapport de repository
      MassiveReport massiveReport = new MassiveReport();
      reportManager.addMassiveReport(massiveReport, componentId);
      massiveReport.setRepositoryPath(sPath);

      ComponentInst componentInst =
          OrganisationControllerFactory.getOrganisationController().getComponentInst(componentId);
      if (componentInst == null) {
        // le composant n'existe pas
        massiveReport.setError(UnitReport.ERROR_NOT_EXISTS_COMPONENT);
      } else {
        reportManager.setComponentName(componentId, componentInst.getLabel());

        File path = new File(sPath);
        if (!path.isDirectory()) {
          // La variable path ne peut contenir qu'un dossier
          massiveReport.setError(UnitReport.ERROR_NOT_EXISTS_OR_INACCESSIBLE_DIRECTORY);
        } else {
          GEDImportExport gedIE =
              ImportExportFactory.createGEDImportExport(settings.getUser(), componentId);

          Iterator<File> itListcontenuPath = getPathContent(path);
          while (itListcontenuPath.hasNext()) {
            File file = itListcontenuPath.next();
            if (file.isFile()) {
              settings.setFolderId(String.valueOf(topicId));
              importFile(file, reportManager, massiveReport, gedIE, pdcIE, settings);
            } else if (file.isDirectory()) {
              switch (rep_Type.getMassiveTypeInt()) {
                case RepositoryType.NO_RECURSIVE:
                  // on ne fait rien
                  break;
                case RepositoryType.RECURSIVE_NOREPLICATE:
                  // traitement récursif spécifique
                  settings.setPathToImport(file.getAbsolutePath());
                  processImportRecursiveNoReplicate(
                      reportManager,
                      massiveReport,
                      gedIE,
                      attachmentIE,
                      versioningIE,
                      pdcIE,
                      settings);
                  break;
                case RepositoryType.RECURSIVE_REPLICATE:
                  try {
                    NodeDetail nodeDetail = gedIE.addSubTopicToTopic(file, topicId, massiveReport);
                    // Traitement récursif spécifique
                    settings.setPathToImport(file.getAbsolutePath());
                    settings.setFolderId(nodeDetail.getNodePK().getId());
                    processImportRecursiveReplicate(
                        reportManager, massiveReport, gedIE, pdcIE, settings);
                  } catch (ImportExportException ex) {
                    massiveReport.setError(UnitReport.ERROR_NOT_EXISTS_OR_INACCESSIBLE_DIRECTORY);
                  }
                  break;
              }
            }
          }
        }
      }
    }
  }