Program: 24554
Project: 24554
Buggy source:
public static SaveDataResponse saveDataSource(boolean update,DatasetType type,String originalDSset,DataSourceUI dataSourceUI,int pageSize) throws ServerSideException {
  SaveDataResponse saveDataResponse=new SaveDataResponse();
  try {
    DefaultRepoxManager repoxManagerEuropeana=(DefaultRepoxManager)ConfigSingleton.getRepoxContextUtil().getRepoxManager();
    ResponseState urlStatus=Util.getUrlStatus(dataSourceUI);
    if (urlStatus != null) {
      saveDataResponse.setResponseState(urlStatus);
      return saveDataResponse;
    }
    MetadataTransformationManager metadataTransformationManager=ConfigSingleton.getRepoxContextUtil().getRepoxManager().getMetadataTransformationManager();
    Map<String,MetadataTransformation> metadataTransformations=new HashMap<String,MetadataTransformation>();
    for (    TransformationUI transformationUI : dataSourceUI.getMetadataTransformations()) {
      MetadataTransformation loadedTransformation=metadataTransformationManager.loadMetadataTransformation(transformationUI.getIdentifier());
      metadataTransformations.put(transformationUI.getIdentifier(),loadedTransformation);
    }
    List<ExternalRestService> externalRestServices=saveExternalServices(dataSourceUI);
    if (update) {
      DataSourceContainer dataSourceContainer=repoxManagerEuropeana.getDataManager().getDataSourceContainer(dataSourceUI.getDataSourceSet());
      DataSourceContainer originalDSC=repoxManagerEuropeana.getDataManager().getDataSourceContainer(originalDSset);
      if (dataSourceContainer != null && !originalDSC.getDataSource().getId().equals(dataSourceUI.getDataSourceSet())) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
      DataSource createdDataSource=null;
      try {
        if (type == DatasetType.OAI) {
          createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceOai(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getOaiSource(),dataSourceUI.getOaiSet(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
        }
 else         if (type == DatasetType.SRU) {
          createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceSruRecordUpdate(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
        }
 else         if (type == DatasetType.FOLDER) {
          if (dataSourceUI.getRetrieveStartegy().equals(FolderFileRetrieveStrategy.FOLDERFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceFolder(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getDirPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(FtpFileRetrieveStrategy.FTPFILERETRIEVESTRATEGY)) {
            if (dataSourceUI.getUser() != null && !dataSourceUI.getUser().isEmpty()) {
              if (!FileUtilSecond.checkFtpServer(dataSourceUI.getServer(),"String_Node_Str",dataSourceUI.getFolderPath(),dataSourceUI.getUser(),dataSourceUI.getPassword())) {
                saveDataResponse.setResponseState(ResponseState.FTP_CONNECTION_FAILED);
                return saveDataResponse;
              }
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceFtp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getServer(),dataSourceUI.getUser(),dataSourceUI.getPassword(),dataSourceUI.getFolderPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(HttpFileRetrieveStrategy.HTTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceHttp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getHttpURL(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
        }
 else         if (type == DatasetType.Z39) {
          if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950IdSequence(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getZ39MaximumId(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            File z3950=null;
            if (!Z39FileUpload.ignoreUploadFile()) {
              z3950=Z39FileUpload.getZ39TempFile();
              Z39FileUpload.deleteTempFile();
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950IdList(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),z3950 != null ? z3950.getAbsolutePath() : "String_Node_Str",dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Format formatter=new SimpleDateFormat("String_Node_Str");
            String earliestDateString=formatter.format(dataSourceUI.getZ39EarlistDate());
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950Timestamp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),earliestDateString,dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
        }
        if (dataSourceUI.getExternalServicesRunType() != null)         createdDataSource.setExternalServicesRunType(ExternalServiceStates.ContainerType.valueOf(dataSourceUI.getExternalServicesRunType()));
        replaceExportPathWithUpdatedId(originalDSset,dataSourceUI,createdDataSource);
        ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().setDataSetSampleState(dataSourceUI.isSample(),createdDataSource);
        createdDataSource.getTags().clear();
        for (        DataSetTagUI dataSetTagUI : dataSourceUI.getTags()) {
          createdDataSource.getTags().add(new DataSourceTag(dataSetTagUI.getName()));
        }
        ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().saveData();
        saveDataResponse.setPage(PagingUtil.getDataPage(createdDataSource.getId(),pageSize));
        saveDataResponse.setResponseState(ResponseState.SUCCESS);
      }
 catch (      ParseException e) {
        saveDataResponse.setResponseState(ResponseState.OTHER);
      }
catch (      ObjectNotFoundException e) {
        saveDataResponse.setResponseState(ResponseState.NOT_FOUND);
      }
catch (      InvalidArgumentsException e) {
        saveDataResponse.setResponseState(ResponseState.INVALID_ARGUMENTS);
      }
catch (      IncompatibleInstanceException e) {
        saveDataResponse.setResponseState(ResponseState.INCOMPATIBLE_TYPE);
      }
      return saveDataResponse;
    }
 else {
      DataSourceContainer dataSourceContainerTest=repoxManagerEuropeana.getDataManager().getDataSourceContainer(dataSourceUI.getDataSourceSet());
      if (dataSourceContainerTest != null) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
      DataSource createdDataSource=null;
      try {
        if (type == DatasetType.OAI) {
          createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceOai(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getOaiSource(),dataSourceUI.getOaiSet(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
        }
 else         if (type == DatasetType.SRU) {
          createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceSruRecordUpdate(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
        }
 else         if (type == DatasetType.FOLDER) {
          if (dataSourceUI.getRetrieveStartegy().equals(FolderFileRetrieveStrategy.FOLDERFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceFolder(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getDirPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(FtpFileRetrieveStrategy.FTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            if (dataSourceUI.getUser() != null && !dataSourceUI.getUser().isEmpty()) {
              if (!FileUtilSecond.checkFtpServer(dataSourceUI.getServer(),"String_Node_Str",dataSourceUI.getFolderPath(),dataSourceUI.getUser(),dataSourceUI.getPassword())) {
                saveDataResponse.setResponseState(ResponseState.FTP_CONNECTION_FAILED);
                return saveDataResponse;
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceFtp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getServer(),dataSourceUI.getUser(),dataSourceUI.getPassword(),dataSourceUI.getFolderPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(HttpFileRetrieveStrategy.HTTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceHttp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getHttpURL(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
        }
 else         if (type == DatasetType.Z39) {
          if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950IdSequence(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getZ39MaximumId(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            File z3950=null;
            if (!Z39FileUpload.ignoreUploadFile()) {
              z3950=Z39FileUpload.getZ39TempFile();
              Z39FileUpload.deleteTempFile();
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950IdList(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),z3950.getAbsolutePath(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Format formatter=new SimpleDateFormat("String_Node_Str");
            String earliestDateString=formatter.format(dataSourceUI.getZ39EarlistDate());
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950Timestamp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),earliestDateString,dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
        }
      }
 catch (      SQLException e) {
        saveDataResponse.setResponseState(ResponseState.ERROR_DATABASE);
        return saveDataResponse;
      }
catch (      ObjectNotFoundException e) {
        saveDataResponse.setResponseState(ResponseState.NOT_FOUND);
        return saveDataResponse;
      }
catch (      AlreadyExistsException e) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
catch (      InvalidArgumentsException e) {
        saveDataResponse.setResponseState(ResponseState.INVALID_ARGUMENTS);
        return saveDataResponse;
      }
catch (      ParseException e) {
        saveDataResponse.setResponseState(ResponseState.OTHER);
        return saveDataResponse;
      }
      if (dataSourceUI.getExternalServicesRunType() != null)       createdDataSource.setExternalServicesRunType(ExternalServiceStates.ContainerType.valueOf(dataSourceUI.getExternalServicesRunType()));
      createdDataSource.setExportDir(dataSourceUI.getExportDirectory());
      ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().setDataSetSampleState(dataSourceUI.isSample(),createdDataSource);
      createdDataSource.getTags().clear();
      for (      DataSetTagUI dataSetTagUI : dataSourceUI.getTags()) {
        createdDataSource.getTags().add(new DataSourceTag(dataSetTagUI.getName()));
      }
      ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().saveData();
      saveDataResponse.setPage(PagingUtil.getDataPage(createdDataSource.getId(),pageSize));
      saveDataResponse.setResponseState(ResponseState.SUCCESS);
      return saveDataResponse;
    }
  }
 catch (  DocumentException e) {
    saveDataResponse.setResponseState(ResponseState.OTHER);
    return saveDataResponse;
  }
catch (  IOException e) {
    saveDataResponse.setResponseState(ResponseState.OTHER);
    return saveDataResponse;
  }
}

Fixed version (ground truth):
public static SaveDataResponse saveDataSource(boolean update,DatasetType type,String originalDSset,DataSourceUI dataSourceUI,int pageSize) throws ServerSideException {
  SaveDataResponse saveDataResponse=new SaveDataResponse();
  try {
    DefaultRepoxManager repoxManagerEuropeana=(DefaultRepoxManager)ConfigSingleton.getRepoxContextUtil().getRepoxManager();
    ResponseState urlStatus=Util.getUrlStatus(dataSourceUI);
    if (urlStatus != null) {
      saveDataResponse.setResponseState(urlStatus);
      return saveDataResponse;
    }
    MetadataTransformationManager metadataTransformationManager=ConfigSingleton.getRepoxContextUtil().getRepoxManager().getMetadataTransformationManager();
    Map<String,MetadataTransformation> metadataTransformations=new HashMap<String,MetadataTransformation>();
    for (    TransformationUI transformationUI : dataSourceUI.getMetadataTransformations()) {
      MetadataTransformation loadedTransformation=metadataTransformationManager.loadMetadataTransformation(transformationUI.getIdentifier());
      metadataTransformations.put(transformationUI.getIdentifier(),loadedTransformation);
    }
    List<ExternalRestService> externalRestServices=saveExternalServices(dataSourceUI);
    if (update) {
      DataSourceContainer dataSourceContainer=repoxManagerEuropeana.getDataManager().getDataSourceContainer(dataSourceUI.getDataSourceSet());
      DataSourceContainer originalDSC=repoxManagerEuropeana.getDataManager().getDataSourceContainer(originalDSset);
      if (dataSourceContainer != null && !originalDSC.getDataSource().getId().equals(dataSourceUI.getDataSourceSet())) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
      DataSource createdDataSource=null;
      try {
        if (type == DatasetType.OAI) {
          createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceOai(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getOaiSource(),dataSourceUI.getOaiSet(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
        }
 else         if (type == DatasetType.SRU) {
          createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceSruRecordUpdate(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
        }
 else         if (type == DatasetType.FOLDER) {
          if (dataSourceUI.getRetrieveStartegy().equals(FolderFileRetrieveStrategy.FOLDERFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceFolder(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getDirPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(FtpFileRetrieveStrategy.FTPFILERETRIEVESTRATEGY)) {
            if (dataSourceUI.getUser() != null && !dataSourceUI.getUser().isEmpty()) {
              if (!FileUtilSecond.checkFtpServer(dataSourceUI.getServer(),"String_Node_Str",dataSourceUI.getFolderPath(),dataSourceUI.getUser(),dataSourceUI.getPassword())) {
                saveDataResponse.setResponseState(ResponseState.FTP_CONNECTION_FAILED);
                return saveDataResponse;
              }
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceFtp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getServer(),dataSourceUI.getUser(),dataSourceUI.getPassword(),dataSourceUI.getFolderPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(HttpFileRetrieveStrategy.HTTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceHttp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getHttpURL(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat(),dataSourceUI.isUseLastUpdateDate());
          }
        }
 else         if (type == DatasetType.Z39) {
          if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950IdSequence(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getZ39MaximumId(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            File z3950=null;
            if (!Z39FileUpload.ignoreUploadFile()) {
              z3950=Z39FileUpload.getZ39TempFile();
              Z39FileUpload.deleteTempFile();
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950IdList(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),z3950 != null ? z3950.getAbsolutePath() : "String_Node_Str",dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Format formatter=new SimpleDateFormat("String_Node_Str");
            String earliestDateString=formatter.format(dataSourceUI.getZ39EarlistDate());
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().updateDataSourceZ3950Timestamp(originalDSset,dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),earliestDateString,dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices,dataSourceUI.isUseLastUpdateDate());
          }
        }
        if (dataSourceUI.getExternalServicesRunType() != null)         createdDataSource.setExternalServicesRunType(ExternalServiceStates.ContainerType.valueOf(dataSourceUI.getExternalServicesRunType()));
        replaceExportPathWithUpdatedId(originalDSset,dataSourceUI,createdDataSource);
        ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().setDataSetSampleState(dataSourceUI.isSample(),createdDataSource);
        createdDataSource.getTags().clear();
        for (        DataSetTagUI dataSetTagUI : dataSourceUI.getTags()) {
          createdDataSource.getTags().add(new DataSourceTag(dataSetTagUI.getName()));
        }
        ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().saveData();
        saveDataResponse.setPage(PagingUtil.getDataPage(createdDataSource.getId(),pageSize));
        saveDataResponse.setResponseState(ResponseState.SUCCESS);
      }
 catch (      ParseException e) {
        saveDataResponse.setResponseState(ResponseState.OTHER);
      }
catch (      ObjectNotFoundException e) {
        saveDataResponse.setResponseState(ResponseState.NOT_FOUND);
      }
catch (      InvalidArgumentsException e) {
        saveDataResponse.setResponseState(ResponseState.INVALID_ARGUMENTS);
      }
catch (      IncompatibleInstanceException e) {
        saveDataResponse.setResponseState(ResponseState.INCOMPATIBLE_TYPE);
      }
catch (      AlreadyExistsException e) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
      }
      return saveDataResponse;
    }
 else {
      DataSourceContainer dataSourceContainerTest=repoxManagerEuropeana.getDataManager().getDataSourceContainer(dataSourceUI.getDataSourceSet());
      if (dataSourceContainerTest != null) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
      DataSource createdDataSource=null;
      try {
        if (type == DatasetType.OAI) {
          createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceOai(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getOaiSource(),dataSourceUI.getOaiSet(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
        }
 else         if (type == DatasetType.SRU) {
          createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceSruRecordUpdate(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
        }
 else         if (type == DatasetType.FOLDER) {
          if (dataSourceUI.getRetrieveStartegy().equals(FolderFileRetrieveStrategy.FOLDERFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceFolder(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getDirPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(FtpFileRetrieveStrategy.FTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            if (dataSourceUI.getUser() != null && !dataSourceUI.getUser().isEmpty()) {
              if (!FileUtilSecond.checkFtpServer(dataSourceUI.getServer(),"String_Node_Str",dataSourceUI.getFolderPath(),dataSourceUI.getUser(),dataSourceUI.getPassword())) {
                saveDataResponse.setResponseState(ResponseState.FTP_CONNECTION_FAILED);
                return saveDataResponse;
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceFtp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getServer(),dataSourceUI.getUser(),dataSourceUI.getPassword(),dataSourceUI.getFolderPath(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
 else           if (dataSourceUI.getRetrieveStartegy().equals(HttpFileRetrieveStrategy.HTTPFILERETRIEVESTRATEGY)) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceHttp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getSourceMDFormat(),dataSourceUI.getIsoVariant(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,dataSourceUI.getRecordRootName(),dataSourceUI.getHttpURL(),metadataTransformations,externalRestServices,dataSourceUI.getMarcFormat());
          }
        }
 else         if (type == DatasetType.Z39) {
          if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950IdSequence(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),dataSourceUI.getZ39MaximumId(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            File z3950=null;
            if (!Z39FileUpload.ignoreUploadFile()) {
              z3950=Z39FileUpload.getZ39TempFile();
              Z39FileUpload.deleteTempFile();
            }
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950IdList(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),z3950.getAbsolutePath(),dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
 else           if (dataSourceUI.getZ39HarvestMethod().equals("String_Node_Str")) {
            Format formatter=new SimpleDateFormat("String_Node_Str");
            String earliestDateString=formatter.format(dataSourceUI.getZ39EarlistDate());
            Map<String,String> namespaces=new HashMap<String,String>();
            if (dataSourceUI.getRecordIdPolicy().equals(IdExtractedRecordIdPolicy.IDEXTRACTED)) {
              for (int i=0; i < dataSourceUI.getNamespaceList().size(); i+=2) {
                namespaces.put(dataSourceUI.getNamespaceList().get(i),dataSourceUI.getNamespaceList().get(i + 1));
              }
            }
            createdDataSource=repoxManagerEuropeana.getDataManager().createDataSourceZ3950Timestamp(dataSourceUI.getDataSetParent().getId(),dataSourceUI.getDataSourceSet(),dataSourceUI.getDescription(),dataSourceUI.getNameCode(),dataSourceUI.getName(),dataSourceUI.getExportDirectory(),dataSourceUI.getSchema(),dataSourceUI.getMetadataNamespace(),dataSourceUI.getZ39Address(),dataSourceUI.getZ39Port(),dataSourceUI.getZ39Database(),dataSourceUI.getZ39User(),dataSourceUI.getZ39Password(),dataSourceUI.getZ39RecordSyntax(),dataSourceUI.getCharacterEncoding(),earliestDateString,dataSourceUI.getRecordIdPolicy(),dataSourceUI.getIdXPath(),namespaces,metadataTransformations,externalRestServices);
          }
        }
      }
 catch (      SQLException e) {
        saveDataResponse.setResponseState(ResponseState.ERROR_DATABASE);
        return saveDataResponse;
      }
catch (      ObjectNotFoundException e) {
        saveDataResponse.setResponseState(ResponseState.NOT_FOUND);
        return saveDataResponse;
      }
catch (      AlreadyExistsException e) {
        saveDataResponse.setResponseState(ResponseState.ALREADY_EXISTS);
        return saveDataResponse;
      }
catch (      InvalidArgumentsException e) {
        saveDataResponse.setResponseState(ResponseState.INVALID_ARGUMENTS);
        return saveDataResponse;
      }
catch (      ParseException e) {
        saveDataResponse.setResponseState(ResponseState.OTHER);
        return saveDataResponse;
      }
      if (dataSourceUI.getExternalServicesRunType() != null)       createdDataSource.setExternalServicesRunType(ExternalServiceStates.ContainerType.valueOf(dataSourceUI.getExternalServicesRunType()));
      createdDataSource.setExportDir(dataSourceUI.getExportDirectory());
      ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().setDataSetSampleState(dataSourceUI.isSample(),createdDataSource);
      createdDataSource.getTags().clear();
      for (      DataSetTagUI dataSetTagUI : dataSourceUI.getTags()) {
        createdDataSource.getTags().add(new DataSourceTag(dataSetTagUI.getName()));
      }
      ConfigSingleton.getRepoxContextUtil().getRepoxManager().getDataManager().saveData();
      saveDataResponse.setPage(PagingUtil.getDataPage(createdDataSource.getId(),pageSize));
      saveDataResponse.setResponseState(ResponseState.SUCCESS);
      return saveDataResponse;
    }
  }
 catch (  DocumentException e) {
    saveDataResponse.setResponseState(ResponseState.OTHER);
    return saveDataResponse;
  }
catch (  IOException e) {
    saveDataResponse.setResponseState(ResponseState.OTHER);
    return saveDataResponse;
  }
}