Example usage for java.security InvalidParameterException InvalidParameterException

List of usage examples for java.security InvalidParameterException InvalidParameterException

Introduction

In this page you can find the example usage for java.security InvalidParameterException InvalidParameterException.

Prototype

public InvalidParameterException(String msg) 

Source Link

Document

Constructs an InvalidParameterException with the specified detail message.

Usage

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * This method is equivalent to the/*from w  ww  . jav a  2s.  c  om*/
 * {@link #updatePost(Permlink, String, String, String[])} method, but lets
 * you define the <code>authorOfThePostToUpdate</code> account separately
 * instead of using the {@link SteemJConfig#getDefaultAccount()
 * DefaultAccount}.
 * 
 * @param authorOfThePostToUpdate
 *            The account that wants to perform the update. In most cases,
 *            this should be the author of the already existing post.
 * @param permlinkOfThePostToUpdate
 *            The permlink of the post to update. <b>Attention</b> If the
 *            permlink is not configured currently, SteemJ could accidently
 *            create a new post instead of updating an existing one.
 * @param title
 *            The new title of the post to set.
 * @param content
 *            The new content of the post to set.
 * @param tags
 *            The new tags of the post. <b>Attention</b> The first tag still
 *            needs to be the same as before otherwise SteemJ could
 *            accidently create a new post instead of updating an existing
 *            one.
 * @return The {@link CommentOperation} which has been created within this
 *         method. The returned Operation allows you to access the generated
 *         values.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public CommentOperation updatePost(AccountName authorOfThePostToUpdate, Permlink permlinkOfThePostToUpdate,
        String title, String content, String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (tags == null || tags.length < 1 || tags.length > 5) {
        throw new InvalidParameterException(TAG_ERROR_MESSAGE);
    }

    ArrayList<Operation> operations = new ArrayList<>();
    AccountName parentAuthor = new AccountName("");
    Permlink parentPermlink = new Permlink(tags[0]);

    String jsonMetadata = CondenserUtils.generateSteemitMetadata(content, tags,
            SteemJConfig.getSteemJAppName() + "/" + SteemJConfig.getSteemJVersion(), MARKDOWN);

    CommentOperation commentOperation = new CommentOperation(parentAuthor, parentPermlink,
            authorOfThePostToUpdate, permlinkOfThePostToUpdate, title, content, jsonMetadata);

    operations.add(commentOperation);

    DynamicGlobalProperty globalProperties = this.getDynamicGlobalProperties();

    SignedTransaction signedTransaction = new SignedTransaction(globalProperties.getHeadBlockId(), operations,
            null);

    signedTransaction.sign();

    this.broadcastTransaction(signedTransaction);

    return commentOperation;
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Use this method to update an existing comment.
 * /*from  w w  w .j  a v  a 2s . com*/
 * <b>Attention</b>
 * <ul>
 * <li>Updating a comment only works if Steem can identify the existing
 * comment - If this is not the case, this operation will create a new
 * comment instead of updating the existing one. The identification is based
 * on the <code>originalPermlinkOfYourComment</code>, the
 * <code>parentAuthor</code>, the <code>parentPermlink</code> and the first
 * tag of the <code>tags</code> array to be the same ones as of the post to
 * update.</li>
 * <li>This method will write data on the blockchain. As all writing
 * operations, a private key is required to sign the transaction. For a
 * update comment operation the private posting key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the author of
 * the comment to update - If no default account has been provided, this
 * method will throw an error. If you do not want to configure the author
 * account as a default account, please use the
 * {@link #updateComment(AccountName, AccountName, Permlink, Permlink, String, String[])}
 * method and provide the author account separately.</li>
 * </ul>
 * 
 * @param parentAuthor
 *            The author of the post or comment that you initially replied
 *            to.
 * @param parentPermlink
 *            The permlink of the post or comment that you initially replied
 *            to.
 * @param originalPermlinkOfTheCommentToUpdate
 *            The permlink of the comment to update.
 * @param content
 *            The new content of the comment to set.
 * @param tags
 *            The new tags of the comment. <b>Attention</b> The first tag
 *            still needs to be the same as before otherwise SteemJ could
 *            accidently create a new comment instead of updating an
 *            existing one.
 * @return The {@link CommentOperation} which has been created within this
 *         method. The returned Operation allows you to access the generated
 *         values.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public CommentOperation updateComment(AccountName parentAuthor, Permlink parentPermlink,
        Permlink originalPermlinkOfTheCommentToUpdate, String content, String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return updateComment(SteemJConfig.getInstance().getDefaultAccount(), parentAuthor, parentPermlink,
            originalPermlinkOfTheCommentToUpdate, content, tags);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * This method is like the//from www.j a  v  a 2s . c om
 * {@link #updateComment(AccountName, Permlink, Permlink, String, String[])}
 * method, but allows you to define the
 * <code>originalAuthorOfTheCommentToUpdate</code> account separately
 * instead of using the {@link SteemJConfig#getDefaultAccount()
 * DefaultAccount}.
 * 
 * @param originalAuthorOfTheCommentToUpdate
 *            The account that wants to perform the update. In most cases,
 *            this should be the author of the already existing comment.
 * @param parentAuthor
 *            The author of the post or comment that you initially replied
 *            to.
 * @param parentPermlink
 *            The permlink of the post or comment that you initially replied
 *            to.
 * @param originalPermlinkOfTheCommentToUpdate
 *            The permlink of the comment to update.
 * @param content
 *            The new content of the comment to set.
 * @param tags
 *            The new tags of the comment. <b>Attention</b> The first tag
 *            still needs to be the same as before otherwise SteemJ could
 *            accidently create a new comment instead of updating an
 *            existing one.
 * @return The {@link CommentOperation} which has been created within this
 *         method. The returned Operation allows you to access the generated
 *         values.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public CommentOperation updateComment(AccountName originalAuthorOfTheCommentToUpdate, AccountName parentAuthor,
        Permlink parentPermlink, Permlink originalPermlinkOfTheCommentToUpdate, String content, String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (tags == null || tags.length < 1 || tags.length > 5) {
        throw new InvalidParameterException(TAG_ERROR_MESSAGE);
    }
    ArrayList<Operation> operations = new ArrayList<>();

    String jsonMetadata = CondenserUtils.generateSteemitMetadata(content, tags,
            SteemJConfig.getSteemJAppName() + "/" + SteemJConfig.getSteemJVersion(), MARKDOWN);

    CommentOperation commentOperation = new CommentOperation(parentAuthor, parentPermlink,
            originalAuthorOfTheCommentToUpdate, originalPermlinkOfTheCommentToUpdate, "", content,
            jsonMetadata);

    operations.add(commentOperation);
    DynamicGlobalProperty globalProperties = this.getDynamicGlobalProperties();

    SignedTransaction signedTransaction = new SignedTransaction(globalProperties.getHeadBlockId(), operations,
            null);

    signedTransaction.sign();

    this.broadcastTransaction(signedTransaction);

    return commentOperation;
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Use this method to remove a comment or a post.
 * /*  w  ww.j  av  a  2 s .  c  o m*/
 * <b>Attention</b>
 * <ul>
 * <li>This method will write data on the blockchain. As all writing
 * operations, a private key is required to sign the transaction. For a
 * voting operation the private posting key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the author of
 * the comment or post to remove - If no default account has been provided,
 * this method will throw an error. If you do not want to configure the
 * author as a default account, please use the
 * {@link #deletePostOrComment(AccountName, Permlink)} method and provide
 * the author account separately.</li>
 * </ul>
 * 
 * 
 * @param postOrCommentPermlink
 *            The permanent link of the post or the comment to delete.
 *            <p>
 *            Example:<br>
 *            <code>new Permlink("steemj-v0-2-4-has-been-released-update-9")</code>
 *            </p>
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public void deletePostOrComment(Permlink postOrCommentPermlink)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    deletePostOrComment(SteemJConfig.getInstance().getDefaultAccount(), postOrCommentPermlink);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Transfer the currency of your choice from
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} to recipient.
 * Amount is automatically converted from normalized representation to base
 * representation. For example, to transfer 1.00 SBD to another account,
 * simply use://from   w  w  w . j  a va  2 s  . c  o m
 * <code>SteemJ.transfer(new AccountName("accountb"), new Asset(1.0, AssetSymbolType.SBD), "My memo");</code>
 *
 * <b>Attention</b>
 * <ul>
 * <li>This method will write data on the blockchain. As all writing
 * operations, a private key is required to sign the transaction. For a
 * transfer operation the private active key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the account to
 * transfer from. If no default account has been provided, this method will
 * throw an error. If you do not want to configure the following account as
 * a default account, please use the
 * {@link #transfer(AccountName, AccountName, Asset, String)} method and
 * provide the <code>from</code> account separately.</li>
 * </ul>
 *
 * @param to
 *            The account name of the account the
 *            {@link SteemJConfig#getDefaultAccount() DefaultAccount} should
 *            transfer currency to.
 * @param amount
 *            An {@link Asset} object containing the Asset type (see
 *            {@link eu.bittrade.libs.steemj.protocol.enums.AssetSymbolType}
 *            and the amount to transfer.
 * @param memo
 *            Message include with transfer (255 char max)
 * @return The TransferOperation broadcast.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public TransferOperation transfer(AccountName to, Asset amount, String memo)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return transfer(SteemJConfig.getInstance().getDefaultAccount(), to, amount, memo);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Claim all available Steem, SDB and VEST (Steam Power) rewards for the
 * default account.//from  www  . ja  v  a 2  s  .c o m
 *
 * <b>Attention</b>
 * <ul>
 * <li>This method will write data on the blockchain if a reward balance is
 * available to be claimed. As with all writing operations, a private key is
 * required to sign the transaction. See
 * {@link SteemJConfig#getPrivateKeyStorage() PrivateKeyStorage}.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the account
 * that will follow the <code>accountToFollow</code> - If no default account
 * has been provided, this method will throw an error. If you do not want to
 * configure the following account as a default account, please use the
 * {@link #follow(AccountName, AccountName)} method and provide the
 * following account separately.</li>
 * </ul>
 *
 * @return The ClaimOperation for reward balances found. This will only have
 *         been broadcast if one of the balances is non-zero.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 */
public ClaimRewardBalanceOperation claimRewards()
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return claimRewards(SteemJConfig.getInstance().getDefaultAccount());
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Use this method to delegate Steem Power (Vesting Shares) from the default
 * account to the <code>delegatee</code> account. The vesting shares are
 * still owned by the original account, but content voting rights and
 * bandwidth allocation are transferred to the receiving account. This sets
 * the delegation to `vesting_shares`, increasing it or decreasing it as
 * needed. (i.e. a delegation of 0 removes the delegation) When a delegation
 * is removed the shares are placed in limbo for a week to prevent a satoshi
 * of VESTS from voting on the same content twice.
 * /*from w  w  w.ja  va 2  s.  com*/
 * @param delegatee
 *            The account that the vesting shares are delegated to.
 * @param vestingShares
 *            The amount of vesting shares.
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 */
public void delegateVestingShares(AccountName delegatee, Asset vestingShares)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    delegateVestingShares(SteemJConfig.getInstance().getDefaultAccount(), delegatee, vestingShares);
}