Refactor: Rename ValidationException to ProposalValidationException

This commit is contained in:
Manfred Karrer 2019-03-18 21:56:25 -05:00
parent 3dc99391e9
commit d02609af2a
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
21 changed files with 70 additions and 72 deletions

View File

@ -19,7 +19,7 @@ package bisq.core.dao;
import bisq.core.btc.exceptions.TransactionVerificationException;
import bisq.core.btc.exceptions.WalletException;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.ballot.BallotListPresentation;
import bisq.core.dao.governance.ballot.BallotListService;
import bisq.core.dao.governance.blindvote.BlindVoteConsensus;
@ -228,7 +228,7 @@ public class DaoFacade implements DaoSetupService {
public ProposalWithTransaction getCompensationProposalWithTransaction(String name,
String link,
Coin requestedBsq)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return compensationProposalFactory.createProposalWithTransaction(name,
link,
requestedBsq);
@ -237,7 +237,7 @@ public class DaoFacade implements DaoSetupService {
public ProposalWithTransaction getReimbursementProposalWithTransaction(String name,
String link,
Coin requestedBsq)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return reimbursementProposalFactory.createProposalWithTransaction(name,
link,
requestedBsq);
@ -247,7 +247,7 @@ public class DaoFacade implements DaoSetupService {
String link,
Param param,
String paramValue)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return changeParamProposalFactory.createProposalWithTransaction(name,
link,
param,
@ -257,27 +257,27 @@ public class DaoFacade implements DaoSetupService {
public ProposalWithTransaction getConfiscateBondProposalWithTransaction(String name,
String link,
String lockupTxId)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return confiscateBondProposalFactory.createProposalWithTransaction(name,
link,
lockupTxId);
}
public ProposalWithTransaction getBondedRoleProposalWithTransaction(Role role)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return roleProposalFactory.createProposalWithTransaction(role);
}
public ProposalWithTransaction getGenericProposalWithTransaction(String name,
String link)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return genericProposalFactory.createProposalWithTransaction(name, link);
}
public ProposalWithTransaction getRemoveAssetProposalWithTransaction(String name,
String link,
Asset asset)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return removeAssetProposalFactory.createProposalWithTransaction(name, link, asset);
}

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.blindvote;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Tx;
@ -53,7 +53,7 @@ public class BlindVoteValidator {
}
}
private void validateDataFields(BlindVote blindVote) throws ValidationException {
private void validateDataFields(BlindVote blindVote) throws ProposalValidationException {
try {
checkNotNull(blindVote.getEncryptedVotes(), "encryptedProposalList must not be null");
checkArgument(blindVote.getEncryptedVotes().length > 0,
@ -68,7 +68,7 @@ public class BlindVoteValidator {
//TODO should we use a min/max for stake, atm its just dust limit as the min. value
} catch (Throwable e) {
log.warn(e.toString());
throw new ValidationException(e);
throw new ProposalValidationException(e);
}
}

View File

@ -21,7 +21,6 @@ import bisq.core.btc.exceptions.TransactionVerificationException;
import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.OpReturnType;
import bisq.core.dao.state.model.governance.Proposal;
@ -68,7 +67,7 @@ public abstract class BaseProposalFactory<R extends Proposal> {
protected ProposalWithTransaction createProposalWithTransaction(String name,
String link)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.name = name;
this.link = link;
// As we don't know the txId yes we create a temp proposal with txId set to an empty string.

View File

@ -1,4 +1,4 @@
package bisq.core.dao.exceptions;
package bisq.core.dao.governance.proposal;
import bisq.core.dao.state.model.blockchain.Tx;
@ -9,7 +9,7 @@ import lombok.Getter;
import javax.annotation.Nullable;
@Getter
public class ValidationException extends Exception {
public class ProposalValidationException extends Exception {
@Nullable
private Coin requestedBsq;
@Nullable
@ -17,31 +17,31 @@ public class ValidationException extends Exception {
@Nullable
private Tx tx;
public ValidationException(String message, Coin requestedBsq, Coin minRequestAmount) {
public ProposalValidationException(String message, Coin requestedBsq, Coin minRequestAmount) {
super(message);
this.requestedBsq = requestedBsq;
this.minRequestAmount = minRequestAmount;
}
public ValidationException(Throwable cause) {
public ProposalValidationException(Throwable cause) {
super(cause);
}
public ValidationException(String message) {
public ProposalValidationException(String message) {
super(message);
}
public ValidationException(String message, Throwable throwable) {
public ProposalValidationException(String message, Throwable throwable) {
super(message, throwable);
}
public ValidationException(String message, Tx tx) {
public ProposalValidationException(String message, Tx tx) {
super(message);
this.tx = tx;
}
public ValidationException(Throwable cause, Tx tx) {
public ProposalValidationException(Throwable cause, Tx tx) {
super(cause);
this.tx = tx;
}

View File

@ -17,7 +17,6 @@
package bisq.core.dao.governance.proposal;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Tx;
@ -51,17 +50,17 @@ public class ProposalValidator {
try {
validateDataFields(proposal);
return true;
} catch (ValidationException e) {
} catch (ProposalValidationException e) {
return false;
}
}
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
notEmpty(proposal.getName(), "name must not be empty");
notEmpty(proposal.getLink(), "link must not be empty");
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}

View File

@ -21,7 +21,7 @@ import bisq.core.btc.exceptions.TransactionVerificationException;
import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalConsensus;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
@ -64,7 +64,7 @@ public class CompensationProposalFactory extends BaseProposalFactory<Compensatio
public ProposalWithTransaction createProposalWithTransaction(String name,
String link,
Coin requestedBsq)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.requestedBsq = requestedBsq;
this.bsqAddress = bsqWalletService.getUnusedBsqAddressAsString();

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.compensation;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -42,7 +42,7 @@ public class CompensationValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
@ -61,7 +61,7 @@ public class CompensationValidator extends ProposalValidator {
"Requested BSQ must not be less than " + (minCompensationRequestAmount.value / 100L) + " BSQ");
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.confiscatebond;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
@ -58,7 +58,7 @@ public class ConfiscateBondProposalFactory extends BaseProposalFactory<Confiscat
public ProposalWithTransaction createProposalWithTransaction(String name,
String link,
String lockupTxId)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.lockupTxId = lockupTxId;
return super.createProposalWithTransaction(name, link);

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.confiscatebond;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -37,14 +37,14 @@ public class ConfiscateBondValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
ConfiscateBondProposal confiscateBondProposal = (ConfiscateBondProposal) proposal;
//TODO
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.generic;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
@ -55,7 +55,7 @@ public class GenericProposalFactory extends BaseProposalFactory<GenericProposal>
}
public ProposalWithTransaction createProposalWithTransaction(String name, String link)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
return super.createProposalWithTransaction(name, link);
}

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.generic;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -37,14 +37,14 @@ public class GenericProposalValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
GenericProposal genericProposalProposal = (GenericProposal) proposal;
//TODO
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.param;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
@ -61,7 +61,7 @@ public class ChangeParamProposalFactory extends BaseProposalFactory<ChangeParamP
String link,
Param param,
String paramValue)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.param = param;
this.paramValue = paramValue;

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.param;
import bisq.core.app.BisqEnvironment;
import bisq.core.btc.wallet.Restrictions;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
@ -64,7 +64,7 @@ public class ChangeParamValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
@ -72,7 +72,7 @@ public class ChangeParamValidator extends ProposalValidator {
validateParamValue(changeParamProposal.getParam(), changeParamProposal.getParamValue());
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}

View File

@ -21,7 +21,7 @@ import bisq.core.btc.exceptions.TransactionVerificationException;
import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalConsensus;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
@ -64,7 +64,7 @@ public class ReimbursementProposalFactory extends BaseProposalFactory<Reimbursem
public ProposalWithTransaction createProposalWithTransaction(String name,
String link,
Coin requestedBsq)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.requestedBsq = requestedBsq;
this.bsqAddress = bsqWalletService.getUnusedBsqAddressAsString();

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.reimbursement;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -42,7 +42,7 @@ public class ReimbursementValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
@ -60,7 +60,7 @@ public class ReimbursementValidator extends ProposalValidator {
checkArgument(requestedBsq.compareTo(minReimbursementRequestAmount) >= 0,
"Requested BSQ must not be less than " + (minReimbursementRequestAmount.value / 100L) + " BSQ");
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.removeAsset;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
@ -60,7 +60,7 @@ public class RemoveAssetProposalFactory extends BaseProposalFactory<RemoveAssetP
public ProposalWithTransaction createProposalWithTransaction(String name,
String link,
Asset asset)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.asset = asset;
return super.createProposalWithTransaction(name, link);

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.removeAsset;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -37,14 +37,14 @@ public class RemoveAssetValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
RemoveAssetProposal removeAssetProposal = (RemoveAssetProposal) proposal;
//TODO
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.role;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.proposal.BaseProposalFactory;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
@ -57,7 +57,7 @@ public class RoleProposalFactory extends BaseProposalFactory<RoleProposal> {
}
public ProposalWithTransaction createProposalWithTransaction(Role role)
throws ValidationException, InsufficientMoneyException, TxException {
throws ProposalValidationException, InsufficientMoneyException, TxException {
this.role = role;
return super.createProposalWithTransaction(role.getName(), role.getLink());

View File

@ -17,7 +17,7 @@
package bisq.core.dao.governance.proposal.role;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.ProposalValidator;
import bisq.core.dao.state.DaoStateService;
@ -40,7 +40,7 @@ public class RoleValidator extends ProposalValidator {
}
@Override
public void validateDataFields(Proposal proposal) throws ValidationException {
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
@ -51,7 +51,7 @@ public class RoleValidator extends ProposalValidator {
notEmpty(role.getName(), "role.name must not be empty");
} catch (Throwable throwable) {
throw new ValidationException(throwable);
throw new ProposalValidationException(throwable);
}
}
}

View File

@ -18,7 +18,7 @@
package bisq.core.util;
import bisq.core.app.BisqEnvironment;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.param.Param;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
@ -136,19 +136,19 @@ public class BsqFormatter extends BSFormatter {
return super.parseToCoin(input, btcCoinFormat);
}
public void validateBtcInput(String input) throws ValidationException {
public void validateBtcInput(String input) throws ProposalValidationException {
validateCoinInput(input, btcCoinFormat);
}
public void validateBsqInput(String input) throws ValidationException {
public void validateBsqInput(String input) throws ProposalValidationException {
validateCoinInput(input, this.coinFormat);
}
private void validateCoinInput(String input, MonetaryFormat coinFormat) throws ValidationException {
private void validateCoinInput(String input, MonetaryFormat coinFormat) throws ProposalValidationException {
try {
coinFormat.parse(cleanDoubleInput(input));
} catch (Throwable t) {
throw new ValidationException("Invalid format for a " + coinFormat.code() + " value");
throw new ProposalValidationException("Invalid format for a " + coinFormat.code() + " value");
}
}
@ -193,7 +193,7 @@ public class BsqFormatter extends BSFormatter {
}
}
public String parseParamValueToString(Param param, String inputValue) throws ValidationException {
public String parseParamValueToString(Param param, String inputValue) throws ProposalValidationException {
switch (param.getParamType()) {
case UNDEFINED:
return Res.get("shared.na");
@ -210,7 +210,7 @@ public class BsqFormatter extends BSFormatter {
if (validationResult.isValid)
return inputValue;
else
throw new ValidationException(validationResult.errorMessage);
throw new ProposalValidationException(validationResult.errorMessage);
default:
log.warn("Param type {} not handled in switch case at parseParamValueToString", param.getParamType());
return Res.get("shared.na");

View File

@ -33,7 +33,7 @@ import bisq.core.btc.exceptions.InsufficientBsqException;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.proposal.ProposalValidationException;
import bisq.core.dao.governance.bond.Bond;
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.governance.proposal.ProposalType;
@ -305,7 +305,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> implements
btcFormatter.formatCoinWithCode(e.missing))).show();
}
} catch (ValidationException e) {
} catch (ProposalValidationException e) {
String message;
if (e.getMinRequestAmount() != null) {
message = Res.get("validation.bsq.amountBelowMinAmount",
@ -359,7 +359,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> implements
@Nullable
private ProposalWithTransaction getProposalWithTransaction(ProposalType type)
throws InsufficientMoneyException, ValidationException, TxException {
throws InsufficientMoneyException, ProposalValidationException, TxException {
checkNotNull(proposalDisplay, "proposalDisplay must not be null");
@ -385,10 +385,10 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> implements
"proposalDisplay.paramValueTextField must no tbe null");
Param selectedParam = proposalDisplay.paramComboBox.getSelectionModel().getSelectedItem();
if (selectedParam == null)
throw new ValidationException("selectedParam is null");
throw new ProposalValidationException("selectedParam is null");
String paramValueAsString = proposalDisplay.paramValueTextField.getText();
if (paramValueAsString == null || paramValueAsString.isEmpty())
throw new ValidationException("paramValue is null or empty");
throw new ProposalValidationException("paramValue is null or empty");
try {
String paramValue = bsqFormatter.parseParamValueToString(selectedParam, paramValueAsString);