Klasse PurchaseRepository
java.lang.Object
de.delinkedde.areashopreborn.persistence.PurchaseRepository
Persists purchase journals and atomic ownership transitions.
All methods are synchronous and must run through the database executor.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungFinds a purchase journal by its stable identifier.findByIdempotencyKey(String idempotencyKey) Finds a purchase by its caller-controlled idempotency key.Lists purchase journals whose cross-system workflow did not reach a terminal state.findNonTerminal(int limit) Lists a bounded oldest-first batch of nonterminal purchase journals.voidinsert(PurchaseTransaction transaction) Inserts a new purchase journal entry.voidpersistOwnership(UUID transactionId, UUID regionId, UUID listingId, UUID buyerId) Atomically changes ownership, closes the listing, and advances the journal.voidquarantine(UUID transactionId, UUID regionId, String failureCode, String failureDetail) Atomically quarantines a purchase journal and its region for administrator inspection.voidreleaseReservation(UUID transactionId, UUID listingId, UUID regionId, RegionState restoredRegionState, TransactionState transactionState, String failureCode, String failureDetail) Releases a reservation and records a failed or compensated transaction.booleanreserve(PurchaseTransaction transaction, RegionState previousRegionState, Instant reservedUntil, int maximumOwnedParcels) Atomically reserves a listing and region and inserts the purchase journal.voidresolvePayoutConfirmed(PurchaseTransaction transaction, UUID administratorId, String evidence, Instant resolvedAt) Atomically records an administrator-attested payout and closes a quarantined purchase.voidupdateState(UUID transactionId, TransactionState state, String failureCode, String failureDetail) Updates durable transaction progress and optional failure details.
-
Konstruktordetails
-
PurchaseRepository
Creates a purchase repository.- Parameter:
database- SQLite database owner
-
-
Methodendetails
-
insert
Inserts a new purchase journal entry.- Parameter:
transaction- transaction snapshot- Löst aus:
SQLException- when persistence fails
-
findByIdempotencyKey
public Optional<PurchaseTransaction> findByIdempotencyKey(String idempotencyKey) throws SQLException Finds a purchase by its caller-controlled idempotency key.- Parameter:
idempotencyKey- unique request key- Gibt zurück:
- matching durable transaction when present
- Löst aus:
SQLException- when the query fails
-
findById
Finds a purchase journal by its stable identifier.- Parameter:
transactionId- transaction identifier- Gibt zurück:
- matching transaction when present
- Löst aus:
SQLException- when the query fails
-
findNonTerminal
Lists purchase journals whose cross-system workflow did not reach a terminal state.- Gibt zurück:
- oldest nonterminal transactions first
- Löst aus:
SQLException- when the query fails
-
findNonTerminal
Lists a bounded oldest-first batch of nonterminal purchase journals.- Parameter:
limit- maximum journals returned- Gibt zurück:
- oldest nonterminal transactions first
- Löst aus:
SQLException- when the query fails
-
quarantine
public void quarantine(UUID transactionId, UUID regionId, String failureCode, String failureDetail) throws SQLException Atomically quarantines a purchase journal and its region for administrator inspection.- Parameter:
transactionId- transaction identifierregionId- affected region identifierfailureCode- stable recovery reasonfailureDetail- diagnostic detail- Löst aus:
SQLException- when the quarantine cannot be persisted
-
reserve
public boolean reserve(PurchaseTransaction transaction, RegionState previousRegionState, Instant reservedUntil, int maximumOwnedParcels) throws SQLException Atomically reserves a listing and region and inserts the purchase journal.- Parameter:
transaction- transaction to journalpreviousRegionState- expected region state before reservationreservedUntil- reservation expirymaximumOwnedParcels- effective buyer limit, or-1for unlimited- Gibt zurück:
truewhen the reservation was acquired- Löst aus:
SQLException- when persistence fails
-
releaseReservation
public void releaseReservation(UUID transactionId, UUID listingId, UUID regionId, RegionState restoredRegionState, TransactionState transactionState, String failureCode, String failureDetail) throws SQLException Releases a reservation and records a failed or compensated transaction.- Parameter:
transactionId- transaction identifierlistingId- listing identifierregionId- region identifierrestoredRegionState- region state before reservationtransactionState- terminal transaction statefailureCode- stable failure codefailureDetail- diagnostic detail- Löst aus:
SQLException- when persistence fails
-
updateState
public void updateState(UUID transactionId, TransactionState state, String failureCode, String failureDetail) throws SQLException Updates durable transaction progress and optional failure details.- Parameter:
transactionId- transaction identifierstate- new progress statefailureCode- stable failure code, ornullfailureDetail- diagnostic detail, ornull- Löst aus:
SQLException- when persistence fails
-
resolvePayoutConfirmed
public void resolvePayoutConfirmed(PurchaseTransaction transaction, UUID administratorId, String evidence, Instant resolvedAt) throws SQLException Atomically records an administrator-attested payout and closes a quarantined purchase.The compare-and-set requires the transaction to remain in manual review and SQLite to name the buyer as current region owner. The evidence is retained in the transaction detail and the immutable audit log.
- Parameter:
transaction- expected quarantined transactionadministratorId- resolving administratorevidence- external verification referenceresolvedAt- resolution timestamp- Löst aus:
SQLException- when state changed concurrently or persistence fails
-
persistOwnership
public void persistOwnership(UUID transactionId, UUID regionId, UUID listingId, UUID buyerId) throws SQLException Atomically changes ownership, closes the listing, and advances the journal.- Parameter:
transactionId- transaction identifierregionId- region identifierlistingId- listing identifierbuyerId- new owner identifier- Löst aus:
SQLException- when the atomic transition fails
-