From 43603eb52e50bebe3db28c151099d3cc3fc8542d Mon Sep 17 00:00:00 2001 From: sugarylump Date: Wed, 26 Jun 2024 16:12:31 +0100 Subject: [PATCH] Added CSV exports IsIndexed implementations --- .../resources/config/roda-roles.properties | 16 ++++++++++++++++ .../api/v2/controller/AuditLogController.java | 13 ++++++++++++- .../wui/api/v2/controller/DIPController.java | 10 +++++++++- .../api/v2/controller/DIPFileController.java | 13 ++++++++++++- .../DisposalConfirmationController.java | 10 +++++++++- .../wui/api/v2/controller/FilesController.java | 10 +++++++++- .../api/v2/controller/JobReportController.java | 14 ++++++++++++-- .../wui/api/v2/controller/JobsController.java | 10 +++++++++- .../api/v2/controller/MembersController.java | 13 ++++++++++++- .../v2/controller/NotificationController.java | 18 ++++++++++++------ .../PreservationAgentController.java | 10 +++++++++- .../PreservationEventController.java | 10 +++++++++- .../controller/RepresentationController.java | 13 ++++++++++++- .../RepresentationInformationController.java | 10 +++++++++- .../wui/api/v2/controller/RiskController.java | 13 ++++++++++++- .../v2/controller/RiskIncidenceController.java | 13 ++++++++++++- .../TransferredResourceController.java | 10 +++++++++- 17 files changed, 184 insertions(+), 22 deletions(-) diff --git a/roda-core/roda-core/src/main/resources/config/roda-roles.properties b/roda-core/roda-core/src/main/resources/config/roda-roles.properties index 7eb0823714..388ec38ca2 100644 --- a/roda-core/roda-core/src/main/resources/config/roda-roles.properties +++ b/roda-core/roda-core/src/main/resources/config/roda-roles.properties @@ -296,6 +296,22 @@ core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(DisposalConfirmati # Generic export roles core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedAIP) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedFile) = representation.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(LogEntry) = log_entry.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(DisposalConfirmation) = disposal_confirmation.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedReport) = job.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(Job) = job.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(RODAMember) = member.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(Notification) = notification.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedPreservationAgent) = preservation_metadata.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedPreservationEvent) = preservation_metadata.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedRepresentation) = representation.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(RepresentationInformation) = ri.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedRisk) = risk.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(TransferredResource) = transfer.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(DIPFile) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(IndexedDIP) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.exportToCSV(RiskIncidence) = incidence.read # Old roles - deprecated - and soon to be deleted core.roles.org.roda.wui.api.controllers.Browser.appraisal = aip.appraisal diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AuditLogController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AuditLogController.java index 3ee42e2a76..76d5bb2b87 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AuditLogController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AuditLogController.java @@ -24,18 +24,21 @@ import org.roda.wui.api.v2.model.GenericOkResponse; import org.roda.wui.api.v2.services.AuditLogService; import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.AuditLogRestService; import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -49,7 +52,7 @@ */ @RestController @RequestMapping(path = "/api/v2/audit-logs") -public class AuditLogController implements AuditLogRestService { +public class AuditLogController implements AuditLogRestService, Exportable { @Autowired HttpServletRequest request; @@ -122,4 +125,12 @@ public String importLogEntry( controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_FILENAME_PARAM, filename); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, LogEntry.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java index fcdf009e18..57d87a4ce5 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java @@ -53,7 +53,7 @@ */ @RestController @RequestMapping(path = "/api/v2/dips") -public class DIPController implements DIPRestService { +public class DIPController implements DIPRestService, Exportable { @Autowired private HttpServletRequest request; @@ -171,4 +171,12 @@ public Job updatePermissions(@RequestBody UpdatePermissionsRequest updateRequest RodaConstants.CONTROLLER_DETAILS_PARAM, updateRequest.getDetails()); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedDIP.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java index 9ba6a4b9dd..67602c4749 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java @@ -12,13 +12,16 @@ import org.roda.core.data.v2.ip.DIPFile; import org.roda.core.model.utils.UserUtility; import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.DIPFileRestService; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import jakarta.servlet.http.HttpServletRequest; @@ -27,7 +30,7 @@ */ @RestController @RequestMapping(path = "/api/v2/dip-files") -public class DIPFileController implements DIPFileRestService { +public class DIPFileController implements DIPFileRestService, Exportable { @Autowired HttpServletRequest request; @@ -62,4 +65,12 @@ public List suggest(SuggestRequest suggestRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); return indexService.suggest(suggestRequest, DIPFile.class, requestContext); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils + .okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, DIPFile.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java index 73fa09ec6f..810bb6433f 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java @@ -56,7 +56,7 @@ */ @RestController @RequestMapping(path = "/api/v2/disposal/confirmations") -public class DisposalConfirmationController implements DisposalConfirmationRestService { +public class DisposalConfirmationController implements DisposalConfirmationRestService, Exportable { @Autowired HttpServletRequest request; @@ -299,4 +299,12 @@ public DisposalConfirmationForm retrieveDisposalConfirmationForm() { controllerAssistant.registerAction(requestContext, state); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, + DisposalConfirmation.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java index 1b28099638..1fb863f723 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java @@ -77,7 +77,7 @@ @RestController @RequestMapping(path = "/api/v2/files") -public class FilesController implements FileRestService { +public class FilesController implements FileRestService, Exportable { @Autowired private HttpServletRequest request; @@ -425,4 +425,12 @@ public List retrieveFileRuleProperties() { controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedFile.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobReportController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobReportController.java index 26673b45af..f9db4add66 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobReportController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobReportController.java @@ -12,15 +12,17 @@ import org.roda.core.data.v2.jobs.IndexedReport; import org.roda.core.model.utils.UserUtility; import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.JobReportRestService; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; -import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; /** @@ -28,7 +30,7 @@ */ @RestController @RequestMapping(path = "/api/v2/job-reports") -public class JobReportController implements JobReportRestService { +public class JobReportController implements JobReportRestService, Exportable { @Autowired private HttpServletRequest request; @@ -62,4 +64,12 @@ public List suggest(SuggestRequest suggestRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); return indexService.suggest(suggestRequest, IndexedReport.class, requestContext); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedReport.class, requestContext)); + } } \ No newline at end of file diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobsController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobsController.java index 9310c429e7..bdf13b561a 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobsController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobsController.java @@ -63,7 +63,7 @@ @RestController @RequestMapping(path = "/api/v2/jobs") -public class JobsController implements JobsRestService { +public class JobsController implements JobsRestService, Exportable { @Autowired private HttpServletRequest request; @@ -329,4 +329,12 @@ public List suggest(SuggestRequest suggestRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); return indexService.suggest(suggestRequest, Job.class, requestContext); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils + .okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, Job.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java index fe5dfefd4c..bcdfa8699e 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java @@ -55,6 +55,7 @@ import org.roda.wui.api.v2.model.GenericOkResponse; import org.roda.wui.api.v2.services.IndexService; import org.roda.wui.api.v2.services.MembersService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.api.v2.utils.CommonServicesUtils; import org.roda.wui.client.management.recaptcha.RecaptchaException; import org.roda.wui.client.services.MembersRestService; @@ -65,10 +66,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.ldap.NamingException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtException; @@ -81,7 +84,7 @@ */ @RestController @RequestMapping(path = "/api/v2/members") -public class MembersController implements MembersRestService { +public class MembersController implements MembersRestService, Exportable { private static final Logger LOGGER = LoggerFactory.getLogger(MembersController.class); @Autowired @@ -775,4 +778,12 @@ public List suggest(SuggestRequest suggestRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); return indexService.suggest(suggestRequest, RODAMember.class, requestContext); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, RODAMember.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/NotificationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/NotificationController.java index 8a512820e2..07aa063813 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/NotificationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/NotificationController.java @@ -7,40 +7,38 @@ import org.roda.core.data.exceptions.NotImplementedException; import org.roda.core.data.exceptions.RODAException; import org.roda.core.data.utils.JsonUtils; -import org.roda.core.data.v2.common.Pair; import org.roda.core.data.v2.generics.LongResponse; import org.roda.core.data.v2.index.CountRequest; import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.IndexResult; import org.roda.core.data.v2.index.SuggestRequest; -import org.roda.core.data.v2.index.filter.Filter; -import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.log.LogEntryState; import org.roda.core.data.v2.notifications.Notification; import org.roda.core.data.v2.notifications.NotificationAcknowledgeRequest; -import org.roda.core.data.v2.notifications.Notifications; import org.roda.core.model.utils.UserUtility; -import org.roda.wui.api.v1.utils.ApiUtils; import org.roda.wui.api.v2.exceptions.RESTException; import org.roda.wui.api.v2.model.GenericOkResponse; import org.roda.wui.api.v2.services.IndexService; import org.roda.wui.api.v2.services.NotificationsService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.NotificationRestService; import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import jakarta.servlet.http.HttpServletRequest; @RestController @RequestMapping(path = "/api/v2/notifications") -public class NotificationController implements NotificationRestService { +public class NotificationController implements NotificationRestService, Exportable { @Autowired private NotificationsService notificationsService; @@ -110,4 +108,12 @@ public LongResponse count(@RequestBody CountRequest countRequest) { public List suggest(SuggestRequest suggestRequest) { throw new RESTException(new NotImplementedException()); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, Notification.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationAgentController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationAgentController.java index f2bf41cb08..4c72bd9eef 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationAgentController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationAgentController.java @@ -47,7 +47,7 @@ */ @RestController @RequestMapping(path = "/api/v2/preservation/agents") -public class PreservationAgentController implements PreservationAgentRestService { +public class PreservationAgentController implements PreservationAgentRestService, Exportable { @Autowired HttpServletRequest request; @@ -118,4 +118,12 @@ public ResponseEntity downloadPreservationAgent( id); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, + IndexedPreservationAgent.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationEventController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationEventController.java index 2c5585c6ed..d1f5975900 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationEventController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/PreservationEventController.java @@ -58,7 +58,7 @@ */ @RestController @RequestMapping(path = "/api/v2/preservation/events") -public class PreservationEventController implements PreservationEventRestService { +public class PreservationEventController implements PreservationEventRestService, Exportable { @Autowired HttpServletRequest request; @@ -229,4 +229,12 @@ public ResponseEntity getPreservationEventsDetails( RodaConstants.CONTROLLER_INDEX_PRESERVATION_EVENT_ID_PARAM, id); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, + IndexedPreservationEvent.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java index 588025dfbc..ba39c3889f 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java @@ -41,6 +41,7 @@ import org.roda.wui.api.v2.exceptions.RESTException; import org.roda.wui.api.v2.services.IndexService; import org.roda.wui.api.v2.services.RepresentationService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.api.v2.utils.CommonServicesUtils; import org.roda.wui.client.services.RepresentationRestService; import org.roda.wui.common.ControllerAssistant; @@ -50,9 +51,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import jakarta.servlet.http.HttpServletRequest; @@ -62,7 +65,7 @@ @RestController @RequestMapping(path = "/api/v2/representations") -public class RepresentationController implements RepresentationRestService { +public class RepresentationController implements RepresentationRestService, Exportable { private static final Logger LOGGER = LoggerFactory.getLogger(RepresentationController.class); @Autowired private HttpServletRequest request; @@ -386,4 +389,12 @@ public List retrieveRepresentationRuleProperties() { controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, + IndexedRepresentation.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java index 4f69f804f2..a559f42299 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java @@ -65,7 +65,7 @@ */ @RestController @RequestMapping(path = "/api/v2/representation-information") -public class RepresentationInformationController implements RepresentationInformationRestService { +public class RepresentationInformationController implements RepresentationInformationRestService, Exportable { @Autowired HttpServletRequest request; @@ -369,4 +369,12 @@ public ResponseEntity downloadRepresentationInformation( id); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, + RepresentationInformation.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java index 94acd92f18..7a57ae8c95 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java @@ -30,15 +30,18 @@ import org.roda.wui.api.v2.exceptions.RESTException; import org.roda.wui.api.v2.services.IndexService; import org.roda.wui.api.v2.services.RiskService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.api.v2.utils.CommonServicesUtils; import org.roda.wui.client.services.RiskRestService; import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import jakarta.servlet.http.HttpServletRequest; @@ -47,7 +50,7 @@ */ @RestController @RequestMapping(path = "/api/v2/risks") -public class RiskController implements RiskRestService { +public class RiskController implements RiskRestService, Exportable { @Autowired private HttpServletRequest request; @@ -332,4 +335,12 @@ public RiskMitigationProperties retrieveRiskMitigationProperties() { controllerAssistant.registerAction(requestContext, state); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedRisk.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java index 50c4f3aec9..8b52957ac4 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java @@ -23,15 +23,18 @@ import org.roda.wui.api.v2.exceptions.RESTException; import org.roda.wui.api.v2.services.IndexService; import org.roda.wui.api.v2.services.RiskIncidenceService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.api.v2.utils.CommonServicesUtils; import org.roda.wui.client.services.RiskIncidenceRestService; import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import jakarta.servlet.http.HttpServletRequest; @@ -40,7 +43,7 @@ */ @RestController @RequestMapping(path = "/api/v2/incidences") -public class RiskIncidenceController implements RiskIncidenceRestService { +public class RiskIncidenceController implements RiskIncidenceRestService, Exportable { @Autowired private HttpServletRequest request; @@ -146,4 +149,12 @@ public RiskIncidence updateRiskIncidence(@RequestBody RiskIncidence incidence) { RodaConstants.CONTROLLER_INCIDENCE_PARAM, incidence); } } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, RiskIncidence.class, requestContext)); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/TransferredResourceController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/TransferredResourceController.java index a935e12752..097ac209b8 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/TransferredResourceController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/TransferredResourceController.java @@ -60,7 +60,7 @@ @RestController @RequestMapping(path = "/api/v2/transfers") @Tag(name = TransferredResourceController.SWAGGER_ENDPOINT) -public class TransferredResourceController implements TransferredResourceRestService { +public class TransferredResourceController implements TransferredResourceRestService, Exportable { public static final String SWAGGER_ENDPOINT = "v2 transfers"; @Autowired @@ -328,4 +328,12 @@ public List suggest(SuggestRequest suggestRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); return indexService.suggest(suggestRequest, TransferredResource.class, requestContext); } + + @Override + public ResponseEntity exportToCSV(String findRequestString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + // delegate + return ApiUtils.okResponse( + indexService.exportToCSV(requestContext.getUser(), findRequestString, TransferredResource.class, requestContext)); + } }