diff --git a/schedule/schedule-appengine/src/main/i18n/locale-en.json b/schedule/schedule-appengine/src/main/i18n/locale-en.json
index 4c36ac30..21061847 100644
--- a/schedule/schedule-appengine/src/main/i18n/locale-en.json
+++ b/schedule/schedule-appengine/src/main/i18n/locale-en.json
@@ -41,6 +41,10 @@
"CHECKOUT_ERROR": "System was unable to determine the result of your checkout operation",
"CHECKOUT_NOT_COMPLETE_RETRY_SELECTION": "You did not finish your checkout. You can change your selections and try again",
"CHECKOUT_PAYMENT_NOT_COMPLETE_RETRY_SELECTION": "You did not complete your payment. You can change your selections and try again",
+ "CLEAR_ACTIVITY_PACKAGE_SELECTION": "Clear Package selection",
+ "CLEAR_ACTIVITY_PACKAGE_SELECTION_PROMPT": "Do you want to remove all Activity Packages?",
+ "CLEAR_ACTIVITY_SELECTION": "Clear Activity selection",
+ "CLEAR_ACTIVITY_SELECTION_PROMPT": "Do you want to remove all Activities?",
"CLICK_TO_DESELECT": "Click to deselect",
"CLICK_TO_SELECT": "Click to select",
"COLOUR": "Colour",
@@ -125,10 +129,6 @@
"PROCEED_TO_BOOKING_VIA_JASIFY": "Booking is done via Jasify. A new window will be opened where you will be able to Sign In or Create an account and proceed to your checkout",
"PROFILE_SETTINGS": "Profile Settings",
"REMOVE": "Remove",
- "CLEAR_PACKAGE_SELECTION": "Clear Package Selection",
- "CLEAR_PACKAGE_SELECTION_PROMPT": "Do you want to remove all Packages?",
- "CLEAR_ACTIVITY_SELECTION": "Clear Activity Selection",
- "CLEAR_ACTIVITY_SELECTION_PROMPT": "Do you want to remove all Activities?",
"REMOVE_ACTIVITY": "Do you want to remove this Activity?",
"REMOVE_ACTIVITY_PACKAGE": "Do you want to remove this Activity Package?",
"REPEAT_DAILY": "Repeat daily",
diff --git a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/SchemaMigration.java b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/SchemaMigration.java
index 5ac34eca..097d020f 100644
--- a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/SchemaMigration.java
+++ b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/SchemaMigration.java
@@ -191,7 +191,9 @@ void initializeDevSystem() {
UserServiceFactory.getUserService().create(admin, "admin");
} catch (UsernameExistsException | EmailExistsException e) {
// Don't really care
+ log.warn(e.getMessage());
}
+
if (EnvironmentUtil.isContinuousIntegrationEnvironment()) {
log.warn("CONTINUOUS INTEGRATION: Creating test values for OAuth2ProviderConfig");
for (OAuth2ProviderEnum provider : OAuth2ProviderEnum.values()) {
diff --git a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/AccountUtil.java b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/AccountUtil.java
index 932664ac..a58c8a21 100644
--- a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/AccountUtil.java
+++ b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/AccountUtil.java
@@ -7,6 +7,8 @@
import com.jasify.schedule.appengine.meta.balance.UserAccountMeta;
import com.jasify.schedule.appengine.meta.common.OrganizationMeta;
import com.jasify.schedule.appengine.meta.users.UserMeta;
+import com.jasify.schedule.appengine.model.ModelOperation;
+import com.jasify.schedule.appengine.model.TransactionOperator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,8 +28,8 @@ public final class AccountUtil {
public static final String PROFIT_AND_LOSS_ACCOUNT = "P&L";
public static final String USER_ACCOUNT_PREFIX = "u";
public static final String ORGANIZATION_ACCOUNT_PREFIX = "o";
- private static final Logger log = LoggerFactory.getLogger(AccountUtil.class);
public static final String DEFAULT_CURRENCY = "CHF";
+ private static final Logger log = LoggerFactory.getLogger(AccountUtil.class);
private AccountUtil() {
}
@@ -41,25 +43,21 @@ public static Key profitAndLossAccountKey() {
}
public static Account profitAndLossAccount() {
- com.google.appengine.api.datastore.Transaction tx = Datastore.beginTransaction();
- try {
- Key id = profitAndLossAccountKey();
- Account account = Datastore.getOrNull(AccountMeta.get(), id);
- if (account == null) {
- account = new Account(id);
- account.setCurrency(DEFAULT_CURRENCY);
- log.info("Created P&L account:{}", account);
- Datastore.put(tx, account);
+ return TransactionOperator.executeNoEx(new ModelOperation
() {
+ @Override
+ public Account execute(com.google.appengine.api.datastore.Transaction tx) {
+ Key id = profitAndLossAccountKey();
+ Account account = Datastore.getOrNull(AccountMeta.get(), id);
+ if (account == null) {
+ account = new Account(id);
+ account.setCurrency(DEFAULT_CURRENCY);
+ log.info("Created P&L account:{}", account);
+ Datastore.put(tx, account);
+ tx.commit();
+ }
+ return account;
}
-
- tx.commit();
- return account;
- } finally {
-
- if (tx.isActive())
- tx.rollback();
-
- }
+ });
}
/**
@@ -122,28 +120,21 @@ public static Key memberAccountIdMustExist(Key memberId) {
return memberAccountMustExist(memberId).getId();
}
- public static Account memberAccountMustExist(Key memberId) {
- Key memberAccountId = AccountUtil.memberIdToAccountId(memberId);
- com.google.appengine.api.datastore.Transaction tx = Datastore.beginTransaction();
- Account account;
- try {
-
- account = Datastore.getOrNull(AccountMeta.get(), memberAccountId);
- if (account == null) {
- account = AccountUtil.newMemberAccount(memberId);
- log.info("Created member account:{} for member:{}", memberAccountId, memberId);
- Datastore.put(tx, account);
+ public static Account memberAccountMustExist(final Key memberId) {
+ final Key memberAccountId = AccountUtil.memberIdToAccountId(memberId);
+
+ return TransactionOperator.executeNoEx(new ModelOperation() {
+ @Override
+ public Account execute(com.google.appengine.api.datastore.Transaction tx) {
+ Account account = Datastore.getOrNull(AccountMeta.get(), memberAccountId);
+ if (account == null) {
+ account = AccountUtil.newMemberAccount(memberId);
+ log.info("Created member account:{} for member:{}", memberAccountId, memberId);
+ Datastore.put(tx, account);
+ tx.commit();
+ }
+ return account;
}
-
- tx.commit();
-
- } finally {
-
- if (tx.isActive())
- tx.rollback();
-
- }
-
- return account;
+ });
}
}
diff --git a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/DefaultBalanceService.java b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/DefaultBalanceService.java
index 3b6e30cb..5b0513b2 100644
--- a/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/DefaultBalanceService.java
+++ b/schedule/schedule-appengine/src/main/java/com/jasify/schedule/appengine/model/balance/DefaultBalanceService.java
@@ -1,5 +1,6 @@
package com.jasify.schedule.appengine.model.balance;
+import com.google.api.client.repackaged.com.google.common.base.Throwables;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory;
@@ -93,7 +94,6 @@ public void subscription(Subscription subscription) throws EntityNotFoundExcepti
}
private void subscription(Subscription subscription, Account payer, Account beneficiary, boolean unpaid) throws EntityNotFoundException {
-
//TODO: Validate balance is there before we start.
linkToTransfer(subscription);
@@ -133,7 +133,6 @@ public void activityPackageExecution(Key activityPackageExecutionId) throws Enti
}
private void activityPackageExecution(ActivityPackageExecution execution, Account payer, Account beneficiary, boolean unpaid) throws EntityNotFoundException {
-
//TODO: Validate balance is there before we start.
linkToTransfer(execution);
@@ -186,20 +185,20 @@ public void applyTransfer(Transfer transfer) {
* @param hasTransfer that is to be credited to the user
* @return the newly allocated or restored transferId
*/
- private Key linkToTransfer(HasTransfer hasTransfer) {
+ private Key linkToTransfer(final HasTransfer hasTransfer) {
Key transferId = hasTransfer.getTransferRef().getKey();
if (transferId == null) {
transferId = Datastore.allocateId(transferMeta);
hasTransfer.getTransferRef().setKey(transferId);
- com.google.appengine.api.datastore.Transaction tx = Datastore.beginTransaction();
- try {
- Datastore.put(tx, hasTransfer);
- tx.commit();
- } finally {
- if (tx.isActive())
- tx.rollback();
- }
+ TransactionOperator.executeNoEx(new ModelOperation