Klasse RentalRepository

java.lang.Object
de.delinkedde.areashopreborn.persistence.RentalRepository

public final class RentalRepository extends Object
Persists rental listings, exclusive reservations, contracts, and payment journal entries.
  • Konstruktordetails

    • RentalRepository

      public RentalRepository(Database database)
      Creates the rental repository.
      Parameter:
      database - database connection provider
  • Methodendetails

    • findTerms

      public Optional<RentalTerms> findTerms(UUID listingId) throws SQLException
      Finds duration terms attached to a rental listing.
      Parameter:
      listingId - listing identifier
      Gibt zurück:
      terms when present
      Löst aus:
      SQLException - when the query fails
    • findActiveByRegion

      public Optional<RentalContract> findActiveByRegion(UUID regionId) throws SQLException
      Finds the active rental contract for a region.
      Parameter:
      regionId - region identifier
      Gibt zurück:
      active contract when present
      Löst aus:
      SQLException - when the query fails
    • findNonTerminalPayments

      public List<RentalRepository.IncompleteRentalPayment> findNonTerminalPayments() throws SQLException
      Lists rental payment journals whose external money outcome is not terminal.
      Gibt zurück:
      oldest incomplete payments with their contract and region identifiers
      Löst aus:
      SQLException - when the query fails
    • findNonTerminalPayments

      public List<RentalRepository.IncompleteRentalPayment> findNonTerminalPayments(int limit) throws SQLException
      Lists a bounded oldest-first batch of nonterminal rental payment journals.
      Parameter:
      limit - maximum payments returned
      Gibt zurück:
      oldest incomplete payment contexts
      Löst aus:
      SQLException - when the query fails
    • findRecoveryPayment

      public Optional<RentalRepository.RentalRecoveryPayment> findRecoveryPayment(UUID paymentId) throws SQLException
      Loads the complete context required for an evidence-based rental payment resolution.
      Parameter:
      paymentId - quarantined payment identifier
      Gibt zurück:
      recovery context when the payment exists
      Löst aus:
      SQLException - when the query fails
    • findDue

      public List<RentalContract> findDue(Instant now) throws SQLException
      Lists contracts whose expiration time has been reached.
      Parameter:
      now - cutoff time
      Gibt zurück:
      expired active contracts
      Löst aus:
      SQLException - when the query fails
    • findDue

      public List<RentalContract> findDue(Instant now, int limit) throws SQLException
      Lists at most one bounded scheduler batch of expired contracts.
      Parameter:
      now - cutoff time
      limit - positive maximum number of returned contracts
      Gibt zurück:
      oldest expired active contracts up to the limit
      Löst aus:
      SQLException - when the query fails
    • reserveExtension

      public boolean reserveExtension(RentalContract contract, UUID paymentId, int periods, BigDecimal amount) throws SQLException
      Reserves a contract extension and inserts its payment journal.
      Parameter:
      contract - current contract snapshot
      paymentId - payment identifier
      periods - additional periods
      amount - total charge
      Gibt zurück:
      whether the active contract was reserved
      Löst aus:
      SQLException - when persistence fails
    • activateExtension

      public void activateExtension(RentalContract contract, UUID paymentId, int periods) throws SQLException
      Commits a paid extension.
      Parameter:
      contract - previous contract snapshot
      paymentId - payment identifier
      periods - additional periods
      Löst aus:
      SQLException - when the pending contract changed concurrently
    • releaseExtension

      public void releaseExtension(UUID contractId, UUID paymentId, String detail) throws SQLException
      Restores an active contract after an extension payment failure and closes the payment journal as failed.
      Parameter:
      contractId - pending contract identifier
      paymentId - failed extension payment identifier
      detail - diagnostic failure detail
      Löst aus:
      SQLException - when the atomic recovery update fails
    • releaseExtension

      public void releaseExtension(UUID contractId, UUID paymentId, TransactionState paymentState, String detail) throws SQLException
      Restores an active contract and closes its extension payment with an explicit outcome.
      Parameter:
      contractId - pending contract identifier
      paymentId - extension payment identifier
      paymentState - TransactionState.FAILED or TransactionState.COMPENSATED
      detail - diagnostic failure detail
      Löst aus:
      SQLException - when the outcome is invalid or persistence fails
    • setAutoExtend

      public boolean setAutoExtend(UUID contractId, UUID renterId, boolean enabled) throws SQLException
      Updates automatic extension for a renter-owned active contract.
      Parameter:
      contractId - contract identifier
      renterId - expected renter used for authorization at the database boundary
      enabled - desired automatic extension state
      Gibt zurück:
      true when an active matching contract was updated
      Löst aus:
      SQLException - when the update fails
    • end

      public boolean end(RentalContract contract, RentalState terminalState) throws SQLException
      Ends a contract and republishes its original rental listing.
      Parameter:
      contract - active contract
      terminalState - cancellation or expiration state
      Gibt zurück:
      whether the contract was ended
      Löst aus:
      SQLException - when persistence fails
    • publish

      public void publish(Listing listing, RentalTerms terms) throws SQLException
      Atomically publishes a rental listing and its duration terms.
      Parameter:
      listing - rental listing
      terms - duration constraints
      Löst aus:
      SQLException - when the parcel is not a draft or persistence fails
    • reserve

      public boolean reserve(Listing listing, RentalContract contract, UUID paymentId, BigDecimal totalAmount) throws SQLException
      Exclusively reserves a rental listing and creates pending contract and payment journals.
      Parameter:
      listing - listing being rented
      contract - proposed contract
      paymentId - initial payment identifier
      totalAmount - full initial charge
      Gibt zurück:
      true when this caller acquired the listing
      Löst aus:
      SQLException - when persistence fails
    • activate

      public void activate(RentalContract contract, UUID paymentId) throws SQLException
      Activates a paid contract and closes its reserved listing.
      Parameter:
      contract - contract to activate
      paymentId - payment journal identifier
      Löst aus:
      SQLException - when the reservation no longer exists
    • release

      public void release(RentalContract contract, UUID paymentId, String detail) throws SQLException
      Releases an unpaid reservation and records its failure.
      Parameter:
      contract - pending contract
      paymentId - payment journal identifier
      detail - diagnostic failure detail
      Löst aus:
      SQLException - when persistence fails
    • release

      public void release(RentalContract contract, UUID paymentId, TransactionState paymentState, String detail) throws SQLException
      Releases an initial rental reservation with an explicit payment outcome.
      Parameter:
      contract - pending contract
      paymentId - payment journal identifier
      paymentState - TransactionState.FAILED or TransactionState.COMPENSATED
      detail - diagnostic failure detail
      Löst aus:
      SQLException - when the outcome is invalid or persistence fails
    • quarantinePayment

      public void quarantinePayment(UUID contractId, UUID regionId, UUID paymentId, String detail) throws SQLException
      Atomically quarantines an ambiguous rental payment and its affected estate state.

      The listing deliberately remains reserved or closed. Administrators must inspect the external Vault state before making the parcel available again.

      Parameter:
      contractId - affected rental contract
      regionId - affected estate region
      paymentId - ambiguous payment journal
      detail - bounded diagnostic detail
      Löst aus:
      SQLException - when any required journal or contract row is missing
    • resolvePaymentConfirmed

      public void resolvePaymentConfirmed(RentalRepository.RentalRecoveryPayment recovery, UUID administratorId, String evidence, Instant resolvedAt) throws SQLException
      Resolves a quarantined rental after an administrator verifies the external payment.
      Parameter:
      recovery - expected recovery snapshot
      administratorId - resolving administrator
      evidence - external payment reference
      resolvedAt - resolution timestamp
      Löst aus:
      SQLException - when any compare-and-set no longer matches
    • resolveRefundConfirmed

      public void resolveRefundConfirmed(RentalRepository.RentalRecoveryPayment recovery, UUID administratorId, String evidence, Instant resolvedAt) throws SQLException
      Resolves a quarantined rental after an administrator verifies the external refund.
      Parameter:
      recovery - expected recovery snapshot
      administratorId - resolving administrator
      evidence - external refund reference
      resolvedAt - resolution timestamp
      Löst aus:
      SQLException - when any compare-and-set no longer matches