Last active
October 7, 2016 10:39
-
-
Save c0rp-aubakirov/bcceebbe023839de3ef1d455824d9caa to your computer and use it in GitHub Desktop.
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
/** | |
* Used for device activation, method is manually transacted | |
* Method returns uniqueNumber, this number is used on mobile devices | |
* <br/> | |
* to use GetToken service | |
*/ | |
public DoActivationResponse doActivation(arguments...) throws InvalidDeviceAssignedToOtherUserException, | |
InvalidMemorableWordAttemptsException, | |
CredentialException, | |
InvalidUserHasAnotherDevicedAssignedException, | |
NetBankingSystemException, | |
InvalidSecretWordException, | |
GeneralSecurityException { | |
boolean transcationRollbacked = false; | |
boolean transactionSuccessful = false; | |
try { | |
ut.begin(); | |
// TRANSACTION_CODE_HERE | |
ut.commit(); | |
transactionSuccessful = true; | |
return response; | |
/** | |
* This is block of hibernate transaction exceptions | |
* We want to catch them separately do deal with them | |
**/ | |
} catch (HeuristicMixedException | NotSupportedException | IllegalStateException | HeuristicRollbackException | SystemException | RollbackException e) { | |
log.error("\n\t Something terrible has happened. Young Skywalker is in pain. Terrible pain\n\n"); | |
log.error(e); | |
throw new NetBankingSystemException(); | |
/** | |
* We trying to catch exception about wrong password and increment login attempts | |
* Because otherwise login attempts changes would be rollbacked | |
*/ | |
} catch (InvalidPasswordException | PinLockedException e) { | |
rollbackTransaction(); | |
transcationRollbacked = true; | |
try { | |
incerementLoginAttempts(fullPhoneNumber); | |
} catch (NotSupportedException | HeuristicRollbackException | HeuristicMixedException | RollbackException | SystemException e1) { | |
rollbackTransaction(); | |
transcationRollbacked = true; | |
throw new NetBankingSystemException(); | |
} | |
throw e; | |
/** | |
* Finally we decide if rollback or proceed | |
* There is no transaction exceptions here | |
**/ | |
} finally { | |
if (!transactionSuccessful && !transcationRollbacked) { | |
rollbackTransaction(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment