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:sh.isaac.api.chronicle.VersionType.java

/**
 * Parses the.// w w w .  j  a  v  a  2 s .  c  o  m
 *
 * @param nameOrEnumId the name or enum id
 * @param exceptionOnParseFail the exception on parse fail
 * @return the version type
 */
public static VersionType parse(String nameOrEnumId, boolean exceptionOnParseFail) {
    if (nameOrEnumId == null) {
        return null;
    }

    final String clean = nameOrEnumId.toLowerCase(Locale.ENGLISH).trim();

    if (StringUtils.isBlank(clean)) {
        return null;
    }

    for (final VersionType ct : values()) {
        if (ct.name().toLowerCase(Locale.ENGLISH).equals(clean)
                || ct.niceName.toLowerCase(Locale.ENGLISH).equals(clean) || (ct.ordinal() + "").equals(clean)) {
            return ct;
        }
    }

    if (exceptionOnParseFail) {
        throw new InvalidParameterException("Could not determine VersionType from " + nameOrEnumId);
    }

    return UNKNOWN;
}

From source file:org.cesecore.authorization.user.AccessUserAspectData.java

@Override
public void setMatchValue(String matchValue) {
    if (matchValue == null) {
        throw new InvalidParameterException("Invalid to set matchValue == null");
    }/*  w ww  .  j a  v  a  2s.  co m*/
    this.matchValue = matchValue;
}

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

protected String generateBaseKeySingle(final Object[] args, final AnnotationInfo info,
        final String methodString) throws Exception {
    final String keyTemplate = info.getAsString(AType.KEY_TEMPLATE, null);
    if (StringUtils.isBlank(keyTemplate)) {
        return getObjectId(CacheBase.getIndexObject(info.getAsInteger(AType.KEY_INDEX), args, methodString));
    }//from  ww w.ja va 2 s.c  om

    final VelocityContext context = factory.getNewExtendedContext();
    context.put("args", args);

    final StringWriter writer = new StringWriter(250);
    Velocity.evaluate(context, writer, this.getClass().getSimpleName(), keyTemplate);
    final String result = writer.toString();
    if (keyTemplate.equals(result)) {
        throw new InvalidParameterException("Calculated key is equal to the velocityTemplate.");
    }
    return result;
}

From source file:eu.bittrade.libs.steemj.protocol.Price.java

/**
 * Validate this <code>Price</code> object.
 * /*from   w  ww  .  j av a2  s .  c  o m*/
 * @throws InvalidParameterException
 *             If the <code>base</code>, the <code>quote</code> or both
 *             objects have not been provided, contain the same symbol or
 *             have an amount less than 1.
 */
private void validate() {
    if (SteemJUtils.setIfNotNull(this.base, "The base asset needs to be provided.").getSymbol() == SteemJUtils
            .setIfNotNull(this.quote, "The quote asset needs to be provided.").getSymbol()) {
        throw new InvalidParameterException(
                "The base asset needs to have a different type than the quote asset.");
    } else if (this.base.getAmount() <= 0) {
        throw new InvalidParameterException("The base asset amount needs to be greater than 0.");
    } else if (this.quote.getAmount() <= 0) {
        throw new InvalidParameterException("The quote asset amount needs to be greater than 0.");
    }
}

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

/**
 * Set the amount of Steem Dollers that should be collected. Please note
 * that it is not possible to collect more than that what is available. You
 * can check the available amount by requesting the Account information
 * using {@link eu.bittrade.libs.steemj.SteemJ#getAccounts(List)
 * getAccounts(List)} method./*  ww  w. j  a  v  a  2s  . c  o m*/
 * 
 * @param rewardSbd
 *            The amount of Steem Dollers to collect.
 * @throws InvalidParameterException
 *             If the provided <code>rewardSbd</code> is null, does not have
 *             the symbol type SBD or the amount to claim is negative.
 */
public void setRewardSbd(Asset rewardSbd) {
    if (rewardSbd == null) {
        throw new InvalidParameterException("The SBD reward can't be null.");
    }

    this.rewardSbd = rewardSbd;
}

From source file:nl.utwente.mirex.TrecRunBaselines.java

/**
 * Runs the MapReduce job "trec baseline runs"
 * @param args 0: path to parsed document collection (use AnchorExtract); 1: (non-existing) path that will contain run resutls; 2: MIREX query file
 * @usage. //w w  w.  j  a v a  2s.  co  m
 * <code> % hadoop jar mirex-0.2.jar nl.utwente.mirex.TrecRunBaselines /user/hadoop/ClueWeb09_Anchors/* /user/hadoop/BaselineOut /user/hadoop/wt09-topics-stats.txt </code> 
 */
public static void main(String[] args) throws Exception {
    if (args.length != 3 && args.length != 4) {
        System.out.printf("Usage: %s [inputFormat] inputFiles topicFile outputFile\n",
                TrecRun.class.getSimpleName());
        System.out.println("          inputFormat: either WARC or KEYVAL; default WARC");
        System.exit(1);
    }

    int argc = 0;
    String inputFormat = "WARC";
    if (args.length > 3) {
        inputFormat = args[argc++].toUpperCase();
    }
    String inputFiles = args[argc++];
    String outputFile = args[argc++];
    String topicFile = args[argc++];

    // Set job configuration
    Job job = new Job();
    job.setJobName("MirexBaselineRuns");
    job.setJarByClass(TrecRunBaselines.class);

    // Set intermediate output (override defaults)
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(Text.class);

    // Set output (override defaults)
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    // Set map-reduce classes
    job.setMapperClass(Map.class);
    job.setCombinerClass(Reduce.class);
    job.setReducerClass(Reduce.class);

    // Set input-output format
    if (inputFormat.equals("KEYVAL")) {
        job.setInputFormatClass(KeyValueTextInputFormat.class);
    } else if (inputFormat.equals("WARC")) {
        job.setInputFormatClass(WarcTextConverterInputFormat.class);
    } else {
        throw new InvalidParameterException("inputFormat must bei either WARC or KEYVAL");
    }
    job.setOutputFormatClass(TextOutputFormat.class);

    // Set input-output paths
    FileInputFormat.setInputPaths(job, new Path(inputFiles));
    FileOutputFormat.setOutputPath(job, new Path(outputFile));

    // Set job specific distributed cache file (query file)
    DistributedCache.addCacheFile(new Path(topicFile).toUri(), job.getConfiguration());

    // Run the job
    job.waitForCompletion(true);
}

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

static AnnotationInfo getAnnotationInfo(final ReadThroughSingleCache annotation, final String targetMethodName,
        final int jitterDefault) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", ReadThroughSingleCache.class.getName()));
    }/*from   ww  w  .ja  va2 s  .  c om*/

    final String namespace = annotation.namespace();
    if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) {
        throw new InvalidParameterException(
                String.format("Namespace for annotation [%s] must be defined on [%s]",
                        ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

    final String keyPrefix = annotation.keyPrefix();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyPrefix)) {
        if (StringUtils.isBlank(keyPrefix)) {
            throw new InvalidParameterException(String.format(
                    "KeyPrefix for annotation [%s] must not be defined as an empty string on [%s]",
                    ReadThroughSingleCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyPrefix(keyPrefix));
    }

    final Integer keyIndex = annotation.keyIndex();
    if (keyIndex != AnnotationConstants.DEFAULT_KEY_INDEX && keyIndex < -1) {
        throw new InvalidParameterException(
                String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]",
                        ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    final boolean keyIndexDefined = keyIndex >= -1;

    final String keyTemplate = annotation.keyTemplate();
    if (StringUtils.isBlank(keyTemplate)) {
        throw new InvalidParameterException(
                String.format("KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]",
                        ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    final boolean keyTemplateDefined = !AnnotationConstants.DEFAULT_STRING.equals(keyTemplate);

    if (keyIndexDefined == keyTemplateDefined) {
        throw new InvalidParameterException(String.format(
                "Exactly one of [keyIndex,keyTemplate] must be defined for annotation [%s] on [%s]",
                ReadThroughSingleCache.class.getName(), targetMethodName));
    }

    if (keyIndexDefined) {
        result.add(new AType.KeyIndex(keyIndex));
    }

    if (keyTemplateDefined) {
        result.add(new AType.KeyTemplate(keyTemplate));
    }

    final int expiration = annotation.expiration();
    if (expiration < 0) {
        throw new InvalidParameterException(
                String.format("Expiration for annotation [%s] must be 0 or greater on [%s]",
                        ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Expiration(expiration));

    final int jitter = annotation.jitter();
    if (jitter < -1 || jitter > 99) {
        throw new InvalidParameterException(
                String.format("Jitter for annotation [%s] must be -1 <= jitter <= 99 on [%s]",
                        ReadThroughSingleCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Jitter(jitter == -1 ? jitterDefault : jitter));

    return result;
}

From source file:net.nelz.simplesm.aop.ReadThroughMultiCacheAdvice.java

protected MapHolder convertIdObjectsToKeyMap(final List<Object> idObjects, final AnnotationData data)
        throws Exception {
    final MapHolder holder = new MapHolder();
    for (final Object obj : idObjects) {
        if (obj == null) {
            throw new InvalidParameterException("One of the passed in key objects is null");
        }//from w w w.  ja  v a  2  s .com

        final Method method = getKeyMethod(obj);
        final String cacheKey = buildCacheKey(generateObjectId(method, obj), data);
        if (holder.getObj2Key().get(obj) == null) {
            holder.getObj2Key().put(obj, cacheKey);
        }
        if (holder.getKey2Obj().get(cacheKey) == null) {
            holder.getKey2Obj().put(cacheKey, obj);
        }
    }

    return holder;
}

From source file:com.mobdb.android.MobDB.java

/**
 * Send's DELETE SQL request to mobDB //from   w  w  w .j  a va 2  s  . c  o m
 * @param appKey String value Application key
 * @param deleteRowdata DeleteRowData object
 * @param bargraph String value for Analytics tag name
 * @param secure boolean value to set SSL communication
 * @param listener MobDBResponseListener object
 * @throws InvalidParameterException
 */
public synchronized void execute(String appKey, DeleteRowData deleteRowdata, String bargraph, boolean secure,
        MobDBResponseListener listener) throws InvalidParameterException {
    try {
        execute(appKey, new String[] { deleteRowdata.getQueryString() }, null, bargraph, secure, listener);
    } catch (Exception e) {
        // TODO: handle exception
        throw new InvalidParameterException(e.toString());
    }
}

From source file:org.cesecore.authorization.user.AccessUserAspectData.java

@Override
public void setCaId(Integer caId) {
    if (caId == null) {
        throw new InvalidParameterException("Invalid to set caId == null");
    }/*from   w  ww. ja va 2 s  .  c o  m*/
    this.caId = caId;
}