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

/**
 * Use this method to cancel a previous vote for a post or a comment.
 * /* www  .j a  v  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 voter - If
 * no default account has been provided, this method will throw an error. If
 * you do not want to configure the voter as a default account, please use
 * the {@link #vote(AccountName, AccountName, Permlink, short)} method and
 * provide the voter account separately.</li>
 * </ul>
 * 
 * @param postOrCommentAuthor
 *            The author of the post or the comment to cancel the vote for.
 *            <p>
 *            Example:<br>
 *            <code>new AccountName("dez1337")</code>
 *            </p>
 * @param postOrCommentPermlink
 *            The permanent link of the post or the comment to cancel the
 *            vote for.
 *            <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 cancelVote(AccountName postOrCommentAuthor, Permlink postOrCommentPermlink)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(
                "Using the cancelVote method without providing an account requires to have a default account configured.");
    }
    cancelVote(SteemJConfig.getInstance().getDefaultAccount(), postOrCommentAuthor, postOrCommentPermlink);
}

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

/**
 * Use this method to follow the <code>accountToFollow</code>.
 * /*from   w w w. j  a  va2  s .co 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
 * follow 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 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>
 * 
 * @param accountToFollow
 *            The account name of the account the
 *            {@link SteemJConfig#getDefaultAccount() DefaultAccount} should
 *            follow.
 * @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 follow(AccountName accountToFollow)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    follow(SteemJConfig.getInstance().getDefaultAccount(), accountToFollow);
}

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

/**
 * Use this method to unfollow the <code>accountToUnfollow</code>.
 * //from  www  . j  av  a  2s. 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
 * unfollow 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 account
 * that will no longer 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>
 * 
 * @param accountToUnfollow
 *            The account name of the account the
 *            {@link SteemJConfig#getDefaultAccount() DefaultAccount} should
 *            no longer follow.
 * @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 unfollow(AccountName accountToUnfollow)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    unfollow(SteemJConfig.getInstance().getDefaultAccount(), accountToUnfollow);
}

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

/**
 * Use this method to reblog a post./*  w ww . j av  a  2 s. c om*/
 * 
 * <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
 * reblog 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} that will resteem
 * the post defined by the <code>accountThatResteemsThePost</code> and
 * <code>authorOfThePostToResteem</code> parameters. - 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 #reblog(AccountName, Permlink)} method and provide the account who
 * wants to reblog the post separately.</li>
 * <li>Please be aware that there is no way to undo a reblog operation - If
 * a post has been reblogged it has been reblogged.
 * </ul>
 * 
 * @param authorOfThePostToReblog
 *            The author of the post to reblog.
 * @param permlinkOfThePostToReblog
 *            The permlink of the post to reblog.
 * @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 reblog(AccountName authorOfThePostToReblog, Permlink permlinkOfThePostToReblog)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    reblog(SteemJConfig.getInstance().getDefaultAccount(), authorOfThePostToReblog, permlinkOfThePostToReblog);
}

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

/**
 * Use this method to create a new post.
 * /*  ww  w .  j av  a 2  s .  co  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
 * create post operation the private posting key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>In case the {@link SteemJConfig#getSteemJWeight() SteemJWeight} is
 * set to a positive value this method will add a comment options operation.
 * Due to this, the {@link SteemJConfig#getSteemJWeight() SteemJWeight}
 * percentage will be paid to the SteemJ account.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the account
 * that will publish the post - 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 #createPost(AccountName, String, String, String[])} method and
 * provide the author account separately.</li>
 * </ul>
 * 
 * @param title
 *            The title of the post to publish.
 * @param content
 *            The content of the post to publish.
 * @param tags
 *            A list of tags while the first tag in this list is the main
 *            tag. You can provide up to five tags but at least one needs to
 *            be provided.
 * @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 createPost(String title, String content, String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return createPost(SteemJConfig.getInstance().getDefaultAccount(), title, content, tags);
}

From source file:com.rfo.basic.Run.java

public static int newVarIndex(ArrayList<String> names, String name) {
    int index = Collections.binarySearch(names, name);
    if (index >= 0) {
        throw new InvalidParameterException("newVarIndex: variable " + name + " already exists");
    }//from  w ww  .j a  v  a2 s  .  c  om
    return -(index + 1); // return the absolute index
    //      Alternate ending to add log:
    //      index = -(index + 1);                        // make the index absolute
    //      Log.v(LOGTAG, CLASSTAG + " newVarIndex() create var " + name + " at index " + index + "/" + vNames.size() + "(start=" + vStart + ")");
    //      return index;
}

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

/**
 * This method is equivalent to the//from  ww w .j ava 2s.c o  m
 * {@link #createPost(String, String, String[])} method, but lets you define
 * the <code>authorThatPublishsThePost</code> account separately instead of
 * using the {@link SteemJConfig#getDefaultAccount() DefaultAccount}.
 * 
 * @param authorThatPublishsThePost
 *            The account who wants to publish the post.
 * @param title
 *            The title of the post to publish.
 * @param content
 *            The content of the post to publish.
 * @param tags
 *            A list of tags while the first tag in this list is the main
 *            tag. You can provide up to five tags but at least one needs to
 *            be provided.
 * @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 createPost(AccountName authorThatPublishsThePost, 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<>();

    // Generate the permanent link from the title by replacing all unallowed
    // characters.
    Permlink permlink = new Permlink(CondenserUtils.createPermlinkString(title));
    // On new posts the parentPermlink is the main tag.
    Permlink parentPermlink = new Permlink(tags[0]);
    // One new posts the parentAuthor is empty.
    AccountName parentAuthor = new AccountName("");

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

    CommentOperation commentOperation = new CommentOperation(parentAuthor, parentPermlink,
            authorThatPublishsThePost, permlink, title, content, jsonMetadata);

    operations.add(commentOperation);

    boolean allowVotes = true;
    boolean allowCurationRewards = true;
    short percentSteemDollars = (short) 10000;
    Asset maxAcceptedPayout = new Asset(1000000000, AssetSymbolType.SBD);

    CommentOptionsOperation commentOptionsOperation;
    // Only add a BeneficiaryRouteType if it makes sense.
    if (SteemJConfig.getInstance().getSteemJWeight() > 0) {
        BeneficiaryRouteType beneficiaryRouteType = new BeneficiaryRouteType(SteemJConfig.getSteemJAccount(),
                SteemJConfig.getInstance().getSteemJWeight());

        ArrayList<BeneficiaryRouteType> beneficiaryRouteTypes = new ArrayList<>();
        beneficiaryRouteTypes.add(beneficiaryRouteType);

        CommentPayoutBeneficiaries commentPayoutBeneficiaries = new CommentPayoutBeneficiaries();
        commentPayoutBeneficiaries.setBeneficiaries(beneficiaryRouteTypes);

        ArrayList<CommentOptionsExtension> commentOptionsExtensions = new ArrayList<>();
        commentOptionsExtensions.add(commentPayoutBeneficiaries);

        commentOptionsOperation = new CommentOptionsOperation(authorThatPublishsThePost, permlink,
                maxAcceptedPayout, percentSteemDollars, allowVotes, allowCurationRewards,
                commentOptionsExtensions);
    } else {
        commentOptionsOperation = new CommentOptionsOperation(authorThatPublishsThePost, permlink,
                maxAcceptedPayout, percentSteemDollars, allowVotes, allowCurationRewards, null);
    }

    operations.add(commentOptionsOperation);

    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 create a new comment.
 * /*ww w  .  ja  v  a  2  s . c  om*/
 * <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
 * create comment operation the private posting key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>In case the {@link SteemJConfig#getSteemJWeight() SteemJWeight} is
 * set to a positive value this method will add a comment options operation.
 * Due to this, the {@link SteemJConfig#getSteemJWeight() SteemJWeight}
 * percentage will be paid to the SteemJ account.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the account
 * that will publish the comment - 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 #createComment(AccountName, AccountName, Permlink, String, String[])}
 * method and provide the author account separately.</li>
 * </ul>
 * 
 * @param authorOfThePostOrCommentToReplyTo
 *            The author of the post or comment to reply to.
 * @param permlinkOfThePostOrCommentToReplyTo
 *            The permlink of the post or comment to reply to.
 * @param content
 *            The content to publish.
 * @param tags
 *            A list of tags while the first tag in this list is the main
 *            tag. You can provide up to five tags but at least one needs to
 *            be provided.
 * @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 createComment(AccountName authorOfThePostOrCommentToReplyTo,
        Permlink permlinkOfThePostOrCommentToReplyTo, String content, String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return createComment(SteemJConfig.getInstance().getDefaultAccount(), authorOfThePostOrCommentToReplyTo,
            permlinkOfThePostOrCommentToReplyTo, content, tags);
}

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

/**
 * This method is equivalent to the/* ww  w.  ja  v  a2  s.  c  o m*/
 * {@link #createComment(AccountName, Permlink, String, String[])} method,
 * but lets you define the <code>authorThatPublishsTheComment</code> account
 * separately instead of using the {@link SteemJConfig#getDefaultAccount()
 * DefaultAccount}.
 * 
 * @param authorThatPublishsTheComment
 *            The account that wants to publish the comment.
 * @param authorOfThePostOrCommentToReplyTo
 *            The author of the post or comment to reply to.
 * @param permlinkOfThePostOrCommentToReplyTo
 *            The permlink of the post or comment to reply to.
 * @param content
 *            The content to publish.
 * @param tags
 *            A list of tags while the first tag in this list is the main
 *            tag. You can provide up to five tags but at least one needs to
 *            be provided.
 * @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 createComment(AccountName authorThatPublishsTheComment,
        AccountName authorOfThePostOrCommentToReplyTo, Permlink permlinkOfThePostOrCommentToReplyTo,
        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<>();

    // Generate the permanent link by adding the current timestamp and a
    // UUID.
    Permlink permlink = new Permlink("re-" + authorOfThePostOrCommentToReplyTo.getName().replaceAll("\\.", "")
            + "-" + permlinkOfThePostOrCommentToReplyTo.getLink() + "-" + System.currentTimeMillis() + "t"
            + UUID.randomUUID().toString() + "uid");

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

    CommentOperation commentOperation = new CommentOperation(authorOfThePostOrCommentToReplyTo,
            permlinkOfThePostOrCommentToReplyTo, authorThatPublishsTheComment, permlink, "", content,
            jsonMetadata);

    operations.add(commentOperation);

    boolean allowVotes = true;
    boolean allowCurationRewards = true;
    short percentSteemDollars = (short) 10000;
    Asset maxAcceptedPayout = new Asset(1000000000, AssetSymbolType.SBD);

    CommentOptionsOperation commentOptionsOperation;
    // Only add a BeneficiaryRouteType if it makes sense.
    if (SteemJConfig.getInstance().getSteemJWeight() > 0) {
        BeneficiaryRouteType beneficiaryRouteType = new BeneficiaryRouteType(SteemJConfig.getSteemJAccount(),
                SteemJConfig.getInstance().getSteemJWeight());

        ArrayList<BeneficiaryRouteType> beneficiaryRouteTypes = new ArrayList<>();
        beneficiaryRouteTypes.add(beneficiaryRouteType);

        CommentPayoutBeneficiaries commentPayoutBeneficiaries = new CommentPayoutBeneficiaries();
        commentPayoutBeneficiaries.setBeneficiaries(beneficiaryRouteTypes);

        ArrayList<CommentOptionsExtension> commentOptionsExtensions = new ArrayList<>();
        commentOptionsExtensions.add(commentPayoutBeneficiaries);

        commentOptionsOperation = new CommentOptionsOperation(authorThatPublishsTheComment, permlink,
                maxAcceptedPayout, percentSteemDollars, allowVotes, allowCurationRewards,
                commentOptionsExtensions);
    } else {
        commentOptionsOperation = new CommentOptionsOperation(authorThatPublishsTheComment, permlink,
                maxAcceptedPayout, percentSteemDollars, allowVotes, allowCurationRewards, null);
    }

    operations.add(commentOptionsOperation);

    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 post.
 * //from   ww  w .  j av  a2 s. c om
 * <b>Attention</b>
 * <ul>
 * <li>Updating a post only works if Steem can identify the existing post -
 * If this is not the case, this operation will create a new post instead of
 * updating the existing one. The identification is based on the
 * <code>permlinkOfThePostToUpdate</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 post 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 post 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 #updatePost(AccountName, Permlink, String, String, String[])}
 * method and provide the author account separately.</li>
 * </ul>
 * 
 * @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(Permlink permlinkOfThePostToUpdate, String title, String content,
        String[] tags)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE);
    }

    return updatePost(SteemJConfig.getInstance().getDefaultAccount(), permlinkOfThePostToUpdate, title, content,
            tags);
}