Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
399 additions
and
55 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
51 changes: 51 additions & 0 deletions
51
src/main/java/alfio/job/executor/RetryFailedReservationConfirmationExecutor.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,51 @@ | ||
/** | ||
* This file is part of alf.io. | ||
* | ||
* alf.io is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* alf.io is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with alf.io. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package alfio.job.executor; | ||
|
||
import alfio.manager.ReservationFinalizer; | ||
import alfio.manager.support.RetryFinalizeReservation; | ||
import alfio.manager.system.AdminJobExecutor; | ||
import alfio.model.system.AdminJobSchedule; | ||
import alfio.util.Json; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
public class RetryFailedReservationConfirmationExecutor implements AdminJobExecutor { | ||
|
||
private final ReservationFinalizer reservationFinalizer; | ||
private final Json json; | ||
|
||
public RetryFailedReservationConfirmationExecutor(ReservationFinalizer reservationFinalizer, | ||
Json json) { | ||
this.reservationFinalizer = reservationFinalizer; | ||
this.json = json; | ||
} | ||
|
||
@Override | ||
public Set<JobName> getJobNames() { | ||
return EnumSet.of(JobName.RETRY_RESERVATION_CONFIRMATION); | ||
} | ||
|
||
@Override | ||
public String process(AdminJobSchedule schedule) { | ||
var metadata = schedule.getMetadata(); | ||
var retryFinalizeReservation = (String) metadata.get("payload"); | ||
reservationFinalizer.retryFinalizeReservation(json.fromJsonString(retryFinalizeReservation, RetryFinalizeReservation.class)); | ||
return null; | ||
} | ||
} |
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
89 changes: 89 additions & 0 deletions
89
src/main/java/alfio/manager/support/RetryFinalizeReservation.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,89 @@ | ||
/** | ||
* This file is part of alf.io. | ||
* | ||
* alf.io is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* alf.io is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with alf.io. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package alfio.manager.support; | ||
|
||
import alfio.model.system.command.FinalizeReservation; | ||
import alfio.model.transaction.PaymentProxy; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class RetryFinalizeReservation { | ||
|
||
private final String reservationId; | ||
private final PaymentProxy paymentProxy; | ||
private final boolean sendReservationConfirmationEmail; | ||
private final boolean sendTickets; | ||
private final String username; | ||
private final boolean tcAccepted; | ||
private final boolean privacyPolicyAccepted; | ||
|
||
@JsonCreator | ||
public RetryFinalizeReservation(@JsonProperty("reservationId") String reservationId, | ||
@JsonProperty("paymentProxy") PaymentProxy paymentProxy, | ||
@JsonProperty("sendReservationConfirmationEmail") boolean sendReservationConfirmationEmail, | ||
@JsonProperty("sendTickets") boolean sendTickets, | ||
@JsonProperty("username") String username, | ||
@JsonProperty("tcAccepted") boolean tcAccepted, | ||
@JsonProperty("privacyPolicyAccepted") boolean privacyPolicyAccepted) { | ||
this.reservationId = reservationId; | ||
this.paymentProxy = paymentProxy; | ||
this.sendReservationConfirmationEmail = sendReservationConfirmationEmail; | ||
this.sendTickets = sendTickets; | ||
this.username = username; | ||
this.tcAccepted = tcAccepted; | ||
this.privacyPolicyAccepted = privacyPolicyAccepted; | ||
} | ||
|
||
public String getReservationId() { | ||
return reservationId; | ||
} | ||
|
||
public PaymentProxy getPaymentProxy() { | ||
return paymentProxy; | ||
} | ||
|
||
public boolean isSendReservationConfirmationEmail() { | ||
return sendReservationConfirmationEmail; | ||
} | ||
|
||
public boolean isSendTickets() { | ||
return sendTickets; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public boolean isTcAccepted() { | ||
return tcAccepted; | ||
} | ||
|
||
public boolean isPrivacyPolicyAccepted() { | ||
return privacyPolicyAccepted; | ||
} | ||
|
||
public static RetryFinalizeReservation fromFinalizeReservation(FinalizeReservation finalizeReservation) { | ||
var paymentSpecification = finalizeReservation.getPaymentSpecification(); | ||
return new RetryFinalizeReservation(paymentSpecification.getReservationId(), | ||
finalizeReservation.getPaymentProxy(), | ||
finalizeReservation.isSendReservationConfirmationEmail(), | ||
finalizeReservation.isSendTickets(), | ||
finalizeReservation.getUsername(), | ||
paymentSpecification.isTcAccepted(), | ||
paymentSpecification.isPrivacyAccepted()); | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
src/main/java/alfio/manager/system/AdminJobManagerScheduler.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,68 @@ | ||
/** | ||
* This file is part of alf.io. | ||
* | ||
* alf.io is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* alf.io is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with alf.io. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package alfio.manager.system; | ||
|
||
import alfio.config.Initializer; | ||
import alfio.util.ClockProvider; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
@Component | ||
@Profile("!" + Initializer.PROFILE_DISABLE_JOBS) | ||
public class AdminJobManagerScheduler { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(AdminJobManagerScheduler.class); | ||
private final AdminJobManager adminJobManager; | ||
private final ClockProvider clockProvider; | ||
|
||
public AdminJobManagerScheduler(AdminJobManager adminJobManager, | ||
ClockProvider clockProvider) { | ||
this.adminJobManager = adminJobManager; | ||
this.clockProvider = clockProvider; | ||
} | ||
|
||
@Scheduled(fixedDelay = 1000L) | ||
void processPendingExtensionRetry() { | ||
log.trace("Processing pending extensions retry"); | ||
adminJobManager.processPendingExtensionRetry(ZonedDateTime.now(clockProvider.getClock())); | ||
log.trace("done processing pending extensions retry"); | ||
} | ||
|
||
@Scheduled(fixedDelay = 1000L) | ||
void processPendingReservationsRetry() { | ||
log.trace("Processing pending reservations retry"); | ||
adminJobManager.processPendingReservationsRetry(ZonedDateTime.now(clockProvider.getClock())); | ||
log.trace("done processing pending reservations retry"); | ||
} | ||
|
||
@Scheduled(fixedDelay = 60 * 1000) | ||
void processPendingRequests() { | ||
log.trace("Processing pending requests"); | ||
adminJobManager.processPendingRequests(); | ||
log.trace("done processing pending requests"); | ||
} | ||
|
||
@Scheduled(cron = "#{environment.acceptsProfiles('dev') ? '0 * * * * *' : '0 0 0 * * *'}") | ||
void cleanupExpiredRequests() { | ||
adminJobManager.cleanupExpiredRequests(); | ||
} | ||
} |
Oops, something went wrong.