Skip to content

Commit

Permalink
Added CSV exports IsIndexed implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
SugaryLump committed Jul 1, 2024
1 parent e2e5845 commit 43603eb
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -122,4 +125,12 @@ public String importLogEntry(
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_FILENAME_PARAM, filename);
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, LogEntry.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -171,4 +171,12 @@ public Job updatePermissions(@RequestBody UpdatePermissionsRequest updateRequest
RodaConstants.CONTROLLER_DETAILS_PARAM, updateRequest.getDetails());
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedDIP.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -62,4 +65,12 @@ public List<String> suggest(SuggestRequest suggestRequest) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
return indexService.suggest(suggestRequest, DIPFile.class, requestContext);
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils
.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, DIPFile.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -299,4 +299,12 @@ public DisposalConfirmationForm retrieveDisposalConfirmationForm() {
controllerAssistant.registerAction(requestContext, state);
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString,
DisposalConfirmation.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -425,4 +425,12 @@ public List<String> retrieveFileRuleProperties() {
controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS);
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedFile.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
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;

/**
* @author António Lindo <[email protected]>
*/
@RestController
@RequestMapping(path = "/api/v2/job-reports")
public class JobReportController implements JobReportRestService {
public class JobReportController implements JobReportRestService, Exportable {
@Autowired
private HttpServletRequest request;

Expand Down Expand Up @@ -62,4 +64,12 @@ public List<String> suggest(SuggestRequest suggestRequest) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
return indexService.suggest(suggestRequest, IndexedReport.class, requestContext);
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, IndexedReport.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -329,4 +329,12 @@ public List<String> suggest(SuggestRequest suggestRequest) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
return indexService.suggest(suggestRequest, Job.class, requestContext);
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils
.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString, Job.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -775,4 +778,12 @@ public List<String> suggest(SuggestRequest suggestRequest) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
return indexService.suggest(suggestRequest, RODAMember.class, requestContext);
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, RODAMember.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,4 +108,12 @@ public LongResponse count(@RequestBody CountRequest countRequest) {
public List<String> suggest(SuggestRequest suggestRequest) {
throw new RESTException(new NotImplementedException());
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(
indexService.exportToCSV(requestContext.getUser(), findRequestString, Notification.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -118,4 +118,12 @@ public ResponseEntity<StreamingResponseBody> downloadPreservationAgent(
id);
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString,
IndexedPreservationAgent.class, requestContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -229,4 +229,12 @@ public ResponseEntity<StreamingResponseBody> getPreservationEventsDetails(
RodaConstants.CONTROLLER_INDEX_PRESERVATION_EVENT_ID_PARAM, id);
}
}

@Override
public ResponseEntity<StreamingResponseBody> exportToCSV(String findRequestString) {
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
// delegate
return ApiUtils.okResponse(indexService.exportToCSV(requestContext.getUser(), findRequestString,
IndexedPreservationEvent.class, requestContext));
}
}
Loading

0 comments on commit 43603eb

Please sign in to comment.