Example usage for org.springframework.dao CannotAcquireLockException getMessage

List of usage examples for org.springframework.dao CannotAcquireLockException getMessage

Introduction

In this page you can find the example usage for org.springframework.dao CannotAcquireLockException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:com.gst.portfolio.savings.api.SavingsAccountTransactionsApiResource.java

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String transaction(@PathParam("savingsId") final Long savingsId,
        @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) {
    try {/*from   w w  w  . j  av  a2  s.c om*/
        final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);

        CommandProcessingResult result = null;
        if (is(commandParam, "deposit")) {
            final CommandWrapper commandRequest = builder.savingsAccountDeposit(savingsId).build();
            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
        } else if (is(commandParam, "withdrawal")) {
            final CommandWrapper commandRequest = builder.savingsAccountWithdrawal(savingsId).build();
            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
        } else if (is(commandParam, "postInterestAsOn")) {
            final CommandWrapper commandRequest = builder.savingsAccountInterestPosting(savingsId).build();
            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
        }

        if (result == null) {
            //
            throw new UnrecognizedQueryParamException("command", commandParam,
                    new Object[] { "deposit", "withdrawal" });
        }

        return this.toApiJsonSerializer.serialize(result);
    } catch (ObjectOptimisticLockingFailureException lockingFailureException) {
        throw new PlatformDataIntegrityException("error.msg.savings.concurrent.operations",
                "Concurrent Transactions being made on this savings account: "
                        + lockingFailureException.getMessage());
    } catch (CannotAcquireLockException cannotAcquireLockException) {
        throw new PlatformDataIntegrityException(
                "error.msg.savings.concurrent.operations.unable.to.acquire.lock",
                "Unable to acquir lock for this transaction: " + cannotAcquireLockException.getMessage());
    }
}

From source file:org.apache.fineract.portfolio.savings.api.SavingsAccountTransactionsApiResource.java

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String transaction(@PathParam("savingsId") final Long savingsId,
        @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) {
    try {//from w w  w . ja va  2 s .  co  m
        final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);

        CommandProcessingResult result = null;
        if (is(commandParam, "deposit")) {
            final CommandWrapper commandRequest = builder.savingsAccountDeposit(savingsId).build();
            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
        } else if (is(commandParam, "withdrawal")) {
            final CommandWrapper commandRequest = builder.savingsAccountWithdrawal(savingsId).build();
            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
        }

        if (result == null) {
            //
            throw new UnrecognizedQueryParamException("command", commandParam,
                    new Object[] { "deposit", "withdrawal" });
        }

        return this.toApiJsonSerializer.serialize(result);
    } catch (ObjectOptimisticLockingFailureException lockingFailureException) {
        throw new PlatformDataIntegrityException("error.msg.savings.concurrent.operations",
                "Concurrent Transactions being made on this savings account: "
                        + lockingFailureException.getMessage());
    } catch (CannotAcquireLockException cannotAcquireLockException) {
        throw new PlatformDataIntegrityException(
                "error.msg.savings.concurrent.operations.unable.to.acquire.lock",
                "Unable to acquir lock for this transaction: " + cannotAcquireLockException.getMessage());
    }
}