@NotNull
    private ContractBean getContractById(Long contractId) throws ActionException, InvalidContractStatusException {
        // Must exist
        ContractBean contract = tryAction(() -> storage.getContract(contractId));
        if (contract == null) {
            throw ExceptionFactory.actionException(Messages.i18n.format("ContractDoesNotExist"));
        }

        // Must be in AwaitingApproval state (no need to approve otherwise!)
        if (contract.getStatus() != ContractStatus.AwaitingApproval) {
            throw ExceptionFactory.invalidContractStatus(ContractStatus.AwaitingApproval, contract.getStatus());
        }
        return contract;
    }
Actions like publish, register, re-register, etc.

NB: Might fold this into respective services later.

@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ActionService.java