-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-11205 Add endpoint to expunge and archive historical data (#2233)
* PP-11205 Add endpoint to expunge and archive historical data - Added endpoint to expunge and archive historical data
- Loading branch information
Showing
14 changed files
with
368 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ov/pay/adminusers/expungeandarchive/resource/ExpungeAndArchiveHistoricalDataResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package uk.gov.pay.adminusers.expungeandarchive.resource; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.inject.Inject; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.slf4j.MDC; | ||
import uk.gov.pay.adminusers.expungeandarchive.service.ExpungeAndArchiveHistoricalDataService; | ||
|
||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
import java.util.UUID; | ||
|
||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | ||
import static uk.gov.service.payments.logging.LoggingKeys.MDC_REQUEST_ID_KEY; | ||
|
||
@Path("/v1/tasks") | ||
@Tag(name = "Tasks") | ||
public class ExpungeAndArchiveHistoricalDataResource { | ||
|
||
private final ExpungeAndArchiveHistoricalDataService expungeAndArchiveHistoricalDataService; | ||
|
||
@Inject | ||
public ExpungeAndArchiveHistoricalDataResource(ExpungeAndArchiveHistoricalDataService expungeAndArchiveHistoricalDataService) { | ||
this.expungeAndArchiveHistoricalDataService = expungeAndArchiveHistoricalDataService; | ||
} | ||
|
||
@POST | ||
@Produces(APPLICATION_JSON) | ||
@Operation( | ||
summary = "Deletes and archives historical data based on `expungeAndArchiveDataConfig`. " + | ||
"Currently, " + | ||
" 1. deletes historical users not attached to any service" + | ||
" 2. deletes historical invites" + | ||
" 3. deletes forgotten passwords" + | ||
" 4. archives services without transactions within the configured number of days and detaches users from service", | ||
responses = { | ||
@ApiResponse(responseCode = "200", description = "OK"), | ||
} | ||
) | ||
@Path("/expunge-and-archive-historical-data") | ||
public Response expungeAndArchiveHistoricalData() { | ||
String correlationId = MDC.get(MDC_REQUEST_ID_KEY) == null ? "ExpungeAndArchiveHistoricalDataResource-" + UUID.randomUUID() : MDC.get(MDC_REQUEST_ID_KEY); | ||
MDC.put(MDC_REQUEST_ID_KEY, correlationId); | ||
|
||
expungeAndArchiveHistoricalDataService.expungeAndArchiveHistoricalData(); | ||
|
||
MDC.remove(MDC_REQUEST_ID_KEY); | ||
return Response.ok().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.