Skip to content
Snippets Groups Projects

chore[aou-1869]: refactor export bibliograpy endpoint

Merged Homada.Boumedane requested to merge aou-1869_update_export_bibliograpy_controller into master
1 unresolved thread
@@ -74,7 +74,7 @@ public class ExportMetadataController extends SolidifyController {
private final IndexResourceService<String, PublicationIndexEntry> indexResourceService;
private final String indexName;
public ExportMetadataController(AouProperties aouProperties,QueryBuilderService queryBuilderService,
public ExportMetadataController(AouProperties aouProperties, QueryBuilderService queryBuilderService,
IndexResourceService<String, PublicationIndexEntry> indexResourceService,
ExportMetadataService exportMetadataService) {
this.queryBuilderService = queryBuilderService;
@@ -91,7 +91,8 @@ public class ExportMetadataController extends SolidifyController {
@RequestParam(name = "format") String format) {
ExportFormat exportFormat = ExportFormat.fromValue(format);
if (StringTool.isNullOrEmpty(commaSeparatedSearchIds) && StringTool.isNullOrEmpty(commaSeparatedPublicationIds) && StringTool.isNullOrEmpty(searchFrom)) {
if (StringTool.isNullOrEmpty(commaSeparatedSearchIds) && StringTool.isNullOrEmpty(commaSeparatedPublicationIds) && StringTool.isNullOrEmpty(
searchFrom)) {
throw new SolidifyHttpErrorException(HttpStatus.BAD_REQUEST, "Either one search id or one publication id or a date is required");
}
@@ -105,7 +106,8 @@ public class ExportMetadataController extends SolidifyController {
publicationIds.addAll(Arrays.stream(commaSeparatedPublicationIds.split(",")).map(String::trim).toList());
}
AouSearchCondition searchConditions = this.queryBuilderService.getSearchesOrPublicationsSearchCondition(searchFrom, searchIds, publicationIds);
AouSearchCondition searchConditions = this.queryBuilderService.getSearchesOrPublicationsSearchCondition(searchFrom, searchIds,
publicationIds);
List<FacetRequest> facetRequests = new ArrayList<>(); // not interested in facets here
List<SearchCondition> searchConditionList = this.queryBuilderService.replaceAliasesByIndexField(List.of(searchConditions));
@@ -120,7 +122,7 @@ public class ExportMetadataController extends SolidifyController {
// convert the string result to Inputstream
InputStream is = new BufferedInputStream(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8)));
return this.buildDownloadResponseEntity(is, this.getFileName(exportFormat), extractContentType(exportFormat), 0L);
return this.buildDownloadResponseEntity(is, this.getFileName(exportFormat), this.getContentType(exportFormat), 0L);
}
@@ -132,7 +134,7 @@ public class ExportMetadataController extends SolidifyController {
};
}
private String extractContentType(ExportFormat format) {
private String getContentType(ExportFormat format) {
return switch (format) {
case CSV -> "text/csv";
case XML -> "application/xml";
Loading