@Test public void testCreateDatasetFile() throws InternalServerErrorException, InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(201); exampleCreateDatasetFile(); }
public String createDatasetFile(String providerId, String id, String name, String nameCode, boolean isSample, String schema, String description, String namespace, String metadataFormat, String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy, FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy, CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory, String recordXPath, Map<String, MetadataTransformation> metadataTransformations) throws InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS).queryParam( DatasetOptionListContainer.PROVIDERID, providerId); DirectoryImporterDataSource directoryImporterDataSource = new DirectoryImporterDataSource(null, id, description, schema, namespace, metadataFormat, extractStrategy, retrieveStrategy, characterEncoding, sourceDirectory, recordIdPolicy, metadataTransformations, recordXPath, null); directoryImporterDataSource.setIsoVariant(isoVariant); directoryImporterDataSource.setExportDir(exportDir); directoryImporterDataSource.setIsSample(isSample); DefaultDataSourceContainer defaultDataSourceContainer = new DefaultDataSourceContainer(directoryImporterDataSource, nameCode, name, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(defaultDataSourceContainer, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult(), errorMessage.getResult().substring(errorMessage.getResult().indexOf("<") + 1, errorMessage.getResult().indexOf(">"))); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createDatasetFile(..) success!"); Result result = response.readEntity(Result.class); return result.getResult().substring(result.getResult().indexOf("<") + 1, result.getResult().indexOf(">")); }
DatasetsAccessor { public String createDatasetFile(String providerId, String id, String name, String nameCode, boolean isSample, String schema, String description, String namespace, String metadataFormat, String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy, FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy, CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory, String recordXPath, Map<String, MetadataTransformation> metadataTransformations) throws InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS).queryParam( DatasetOptionListContainer.PROVIDERID, providerId); DirectoryImporterDataSource directoryImporterDataSource = new DirectoryImporterDataSource(null, id, description, schema, namespace, metadataFormat, extractStrategy, retrieveStrategy, characterEncoding, sourceDirectory, recordIdPolicy, metadataTransformations, recordXPath, null); directoryImporterDataSource.setIsoVariant(isoVariant); directoryImporterDataSource.setExportDir(exportDir); directoryImporterDataSource.setIsSample(isSample); DefaultDataSourceContainer defaultDataSourceContainer = new DefaultDataSourceContainer(directoryImporterDataSource, nameCode, name, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(defaultDataSourceContainer, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult(), errorMessage.getResult().substring(errorMessage.getResult().indexOf("<") + 1, errorMessage.getResult().indexOf(">"))); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createDatasetFile(..) success!"); Result result = response.readEntity(Result.class); return result.getResult().substring(result.getResult().indexOf("<") + 1, result.getResult().indexOf(">")); } }
DatasetsAccessor { public String createDatasetFile(String providerId, String id, String name, String nameCode, boolean isSample, String schema, String description, String namespace, String metadataFormat, String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy, FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy, CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory, String recordXPath, Map<String, MetadataTransformation> metadataTransformations) throws InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS).queryParam( DatasetOptionListContainer.PROVIDERID, providerId); DirectoryImporterDataSource directoryImporterDataSource = new DirectoryImporterDataSource(null, id, description, schema, namespace, metadataFormat, extractStrategy, retrieveStrategy, characterEncoding, sourceDirectory, recordIdPolicy, metadataTransformations, recordXPath, null); directoryImporterDataSource.setIsoVariant(isoVariant); directoryImporterDataSource.setExportDir(exportDir); directoryImporterDataSource.setIsSample(isSample); DefaultDataSourceContainer defaultDataSourceContainer = new DefaultDataSourceContainer(directoryImporterDataSource, nameCode, name, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(defaultDataSourceContainer, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult(), errorMessage.getResult().substring(errorMessage.getResult().indexOf("<") + 1, errorMessage.getResult().indexOf(">"))); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createDatasetFile(..) success!"); Result result = response.readEntity(Result.class); return result.getResult().substring(result.getResult().indexOf("<") + 1, result.getResult().indexOf(">")); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); }
DatasetsAccessor { public String createDatasetFile(String providerId, String id, String name, String nameCode, boolean isSample, String schema, String description, String namespace, String metadataFormat, String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy, FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy, CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory, String recordXPath, Map<String, MetadataTransformation> metadataTransformations) throws InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS).queryParam( DatasetOptionListContainer.PROVIDERID, providerId); DirectoryImporterDataSource directoryImporterDataSource = new DirectoryImporterDataSource(null, id, description, schema, namespace, metadataFormat, extractStrategy, retrieveStrategy, characterEncoding, sourceDirectory, recordIdPolicy, metadataTransformations, recordXPath, null); directoryImporterDataSource.setIsoVariant(isoVariant); directoryImporterDataSource.setExportDir(exportDir); directoryImporterDataSource.setIsSample(isSample); DefaultDataSourceContainer defaultDataSourceContainer = new DefaultDataSourceContainer(directoryImporterDataSource, nameCode, name, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(defaultDataSourceContainer, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult(), errorMessage.getResult().substring(errorMessage.getResult().indexOf("<") + 1, errorMessage.getResult().indexOf(">"))); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createDatasetFile(..) success!"); Result result = response.readEntity(Result.class); return result.getResult().substring(result.getResult().indexOf("<") + 1, result.getResult().indexOf(">")); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); DataSourceContainer getDataset(String datasetId); void deleteDataset(String datasetId); List<DataSourceContainer> getDatasetList(String providerId, int offset, int number); String createDatasetOai(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); String createDatasetFile(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetOai(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetFile(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void copyDataset(String id, String newId); String getDatasetLastIngestionDate(String id); int getDatasetRecordCount(String id); void exportDataset(String id, String format); }
DatasetsAccessor { public String createDatasetFile(String providerId, String id, String name, String nameCode, boolean isSample, String schema, String description, String namespace, String metadataFormat, String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy, FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy, CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory, String recordXPath, Map<String, MetadataTransformation> metadataTransformations) throws InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS).queryParam( DatasetOptionListContainer.PROVIDERID, providerId); DirectoryImporterDataSource directoryImporterDataSource = new DirectoryImporterDataSource(null, id, description, schema, namespace, metadataFormat, extractStrategy, retrieveStrategy, characterEncoding, sourceDirectory, recordIdPolicy, metadataTransformations, recordXPath, null); directoryImporterDataSource.setIsoVariant(isoVariant); directoryImporterDataSource.setExportDir(exportDir); directoryImporterDataSource.setIsSample(isSample); DefaultDataSourceContainer defaultDataSourceContainer = new DefaultDataSourceContainer(directoryImporterDataSource, nameCode, name, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(defaultDataSourceContainer, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult(), errorMessage.getResult().substring(errorMessage.getResult().indexOf("<") + 1, errorMessage.getResult().indexOf(">"))); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createDatasetFile(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createDatasetFile(..) success!"); Result result = response.readEntity(Result.class); return result.getResult().substring(result.getResult().indexOf("<") + 1, result.getResult().indexOf(">")); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); DataSourceContainer getDataset(String datasetId); void deleteDataset(String datasetId); List<DataSourceContainer> getDatasetList(String providerId, int offset, int number); String createDatasetOai(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); String createDatasetFile(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetOai(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetFile(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void copyDataset(String id, String newId); String getDatasetLastIngestionDate(String id); int getDatasetRecordCount(String id); void exportDataset(String id, String format);  }