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:com.abiquo.api.tasks.util.DatacenterTaskBuilder.java

/**
 * Translate a {@link VirtualMachineStateTransition} to {@link StateTransition}
 * //from w  ww .  ja v a  2 s  .c om
 * @param transition The transition to translate
 * @return The {@link StateTransition} translation
 */
protected StateTransition toCommonsTransition(final VirtualMachineStateTransition transition) {
    switch (transition) {
    case ALLOCATE:
        return StateTransition.ALLOCATE;

    case CONFIGURE:
        return StateTransition.CONFIGURE;

    case DEALLOCATE:
        return StateTransition.DEALLOCATE;

    case DECONFIGURE:
        return StateTransition.DECONFIGURE;

    case PAUSE:
        return StateTransition.PAUSE;

    case POWEROFF:
        return StateTransition.POWEROFF;

    case POWERON:
        return StateTransition.POWERON;

    case RECONFIGURE:
        return StateTransition.RECONFIGURE;

    case RESET:
        return StateTransition.RESET;

    case RESUME:
        return StateTransition.RESUME;

    case SNAPSHOT:
        return StateTransition.SNAPSHOT;

    default:
        throw new InvalidParameterException("Error unknown transition: " + transition);
    }
}

From source file:com.richtodd.android.quiltdesign.app.BlockEditActivity.java

@Override
public void onAlertDialogPositiveClick(DialogFragment dialog, String key) throws Exception {

    if (key.equals(KEY_CONFIRM_DELETE)) {
        getBlockEditFragment().setSaveSuppressed(true);

        Repository repository = Repository.getDefaultRepository(this);
        BlockContainer blocks = repository.getBlocks();
        blocks.deleteBlock(m_blockNameArgument);

        finish();//from www  .j  a  v a 2 s  .  co m

    } else if (key.equals(KEY_FILE_EXISTS)) {
        showEditNameDialog();

    } else {
        throw new InvalidParameterException("Unknown key " + key);
    }
}

From source file:org.easyxml.xml.Element.java

/**
 * //from ww  w. j  av  a  2  s.c o m
 * Constructor with Element tag name, its parent element and innerText.
 * 
 * @param name
 *            - Tag name of the element.
 * 
 * @param parent
 *            - Container of this element.
 * 
 * @param value
 *            - InnerText, notice that is would be escaped before stored to
 *            this.value.
 */

public Element(String name, Element parent, String value) {

    if (StringUtils.isBlank(name)) {

        throw new InvalidParameterException("Name of an element cannot be null or blank!");

    }

    if (!StringUtils.containsNone(name, EntityReferenceKeys)) {

        throw new InvalidParameterException(
                String.format("\"{s}\" cannot contain any of the 5 chars: \'<\', \'>\', \'&\', \'\'\', \'\"\'"

                        , name));

    }

    this.name = name;

    setValue(value);

    if (parent != null) {

        setParent(parent);

        // Update the Children map of the parent element after setting name

        this.parent.addChildElement(this);

    }

}

From source file:org.kuali.kfs.module.purap.document.service.impl.PurApWorkflowIntegrationServiceImpl.java

/**
 * DON'T CALL THIS IF THE DOC HAS NOT BEEN SAVED
 *
 * @see org.kuali.kfs.module.purap.document.service.PurApWorkflowIntegrationService#willDocumentStopAtGivenFutureRouteNode(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument,
 *      org.kuali.kfs.module.purap.PurapWorkflowConstants.NodeDetails)
 *//*from  w  w  w  .j ava 2  s.  c  om*/
@Override
public boolean willDocumentStopAtGivenFutureRouteNode(PurchasingAccountsPayableDocument document,
        String givenNodeName) {
    if (givenNodeName == null) {
        throw new InvalidParameterException("Given Node Detail object was null");
    }
    try {
        String activeNode = null;
        Set<String> currentNodes = document.getDocumentHeader().getWorkflowDocument().getCurrentNodeNames();

        if (CollectionUtils.isNotEmpty(currentNodes)) {
            String[] nodeNames = currentNodes.toArray(new String[0]);

            if (nodeNames.length == 1) {
                activeNode = nodeNames[0];
            }
        }

        if (isGivenNodeAfterCurrentNode(document, activeNode, givenNodeName)) {
            if (document.getDocumentHeader().getWorkflowDocument().isInitiated()) {
                // document is only initiated so we need to pass xml for workflow to simulate route properly
                RoutingReportCriteria.Builder builder = RoutingReportCriteria.Builder.createByDocumentTypeName(
                        document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
                builder.setXmlContent(document.getXmlForRouteReport());
                builder.setRoutingPrincipalId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
                builder.setTargetNodeName(givenNodeName);
                RoutingReportCriteria reportCriteria = builder.build();
                boolean value = SpringContext.getBean(WorkflowDocumentActionsService.class)
                        .documentWillHaveAtLeastOneActionRequest(reportCriteria,
                                Arrays.asList(KewApiConstants.ACTION_REQUEST_APPROVE_REQ,
                                        KewApiConstants.ACTION_REQUEST_COMPLETE_REQ),
                                false);
                return value;
            } else {
                /* Document has had at least one workflow action taken so we need to pass the doc id so the simulation will use
                 * the existing actions taken and action requests in determining if rules will fire or not. We also need to call
                 * a save routing data so that the xml Workflow uses represents what is currently on the document
                 */
                RoutingReportCriteria.Builder builder = RoutingReportCriteria.Builder
                        .createByDocumentId(document.getDocumentNumber());
                builder.setXmlContent(document.getXmlForRouteReport());
                builder.setTargetNodeName(givenNodeName);
                RoutingReportCriteria reportCriteria = builder.build();
                boolean value = SpringContext.getBean(WorkflowDocumentActionsService.class)
                        .documentWillHaveAtLeastOneActionRequest(reportCriteria,
                                Arrays.asList(KewApiConstants.ACTION_REQUEST_APPROVE_REQ,
                                        KewApiConstants.ACTION_REQUEST_COMPLETE_REQ),
                                false);
                return value;
            }
        }
        return false;
    } catch (Exception e) {
        String errorMessage = "Error trying to test document id '" + document.getDocumentNumber()
                + "' for action requests at node name '" + givenNodeName + "'";
        LOG.error("isDocumentStoppingAtRouteLevel() " + errorMessage, e);
        throw new RuntimeException(errorMessage, e);
    }
}

From source file:org.flite.cach3.aop.CacheBase.java

protected static Object applyTemplate(final VelocityContext context, final String template) {
    final StringWriter writer = new StringWriter(1024);
    Velocity.evaluate(context, writer, CacheBase.class.getSimpleName(), template);
    Object value = writer.toString();
    if (template.equals(value)) {
        throw new InvalidParameterException("Calculated key is equal to the velocityTemplate.");
    }//from   w  w  w .ja v a2  s  .c o m

    return value;
}

From source file:de.knurt.fam.core.persistence.dao.ibatis.UserDao4ibatis.java

/** {@inheritDoc} */
@Override/*  w w w .  ja v a2 s . c  om*/
public List<User> getUsersWithRealName(String firstname, String sirname) throws InvalidParameterException {
    String regexp = "^[^=><'\"]+$";
    if (GenericValidator.matchRegexp(firstname, regexp) && GenericValidator.matchRegexp(sirname, regexp)) {
        String where = String.format("fname = \"%s\" AND sname = \"%s\"", firstname, sirname);
        return this.getWhere(where);
    } else {
        throw new InvalidParameterException(firstname + "; " + sirname + " is not a real name");
    }
}

From source file:eu.bittrade.libs.steemj.protocol.operations.CustomBinaryOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (id.length() > 32) {
            throw new InvalidParameterException("The id must be less than 32 characters long.");
        } else if (requiredOwnerAuths.size() + requiredActiveAuths.size() + requiredPostingAuths.size() <= 0) {
            throw new InvalidParameterException("At least on account must be specified.");
        }//from  ww w  . j ava  2  s  .c  o m
    }
}

From source file:eu.bittrade.libs.steemj.protocol.operations.LimitOrderCreateOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)
            && !ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)
            && (!SteemJConfig.getInstance().getTokenSymbol().equals(amountToSell)
                    && SteemJConfig.getInstance().getDollarSymbol().equals(minToReceive))
            || (SteemJConfig.getInstance().getDollarSymbol().equals(amountToSell)
                    && SteemJConfig.getInstance().getTokenSymbol().equals(minToReceive))) {
        // TODO: (amount_to_sell / min_to_receive).validate();
        throw new InvalidParameterException("Limit order must be for the STEEM:SBD market.");
    }//ww  w.  java 2  s  .  c  o m
}

From source file:org.holoeverywhere.widget.datetimepicker.date.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *               {@link #VIEW_PARAMS_HEIGHT}
 *//*from   ww w. j  av a 2  s.c om*/
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = DateTimePickerUtils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mNodeProvider.invalidateParent();
}

From source file:eu.bittrade.libs.steemj.protocol.operations.LimitOrderCreate2Operation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)
            && !ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
        if (!amountToSell.getSymbol().equals(this.getExchangeRate().getBase().getSymbol())) {
            throw new InvalidParameterException("The sell asset must be the base of the price.");
        } else if (exchangeRate.multiply(amountToSell).getAmount() <= 0) {
            throw new InvalidParameterException("The Amount to sell cannot round to 0 when traded.");
        } else if (!((amountToSell.getSymbol().equals(SteemJConfig.getInstance().getTokenSymbol()) && this
                .getExchangeRate().getQuote().getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol()))
                || (amountToSell.getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol())
                        && this.getExchangeRate().getQuote().getSymbol()
                                .equals(SteemJConfig.getInstance().getTokenSymbol())))) {
            throw new InvalidParameterException("Limit order must be for the STEEM:SBD market.");
        }//www .  ja  va  2s. c  om
    }
}