List of usage examples for java.security InvalidParameterException InvalidParameterException
public InvalidParameterException(String msg)
From source file:com.facebook.presto.accumulo.examples.TpcHClerkSearch.java
private void validateExists(Connector conn, String table) { if (!conn.tableOperations().exists(table)) { throw new InvalidParameterException(format("Error: Table %s does not exist", DATA_TABLE)); }//from w w w. java 2s . co m }
From source file:org.flite.cach3.aop.UpdateMultiCacheAdvice.java
static AnnotationInfo getAnnotationInfo(final UpdateMultiCache 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.", UpdateMultiCache.class.getName())); }// ww w . j a v a 2 s . co m 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]", UpdateMultiCache.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]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.KeyPrefix(keyPrefix)); } final Integer keyIndex = annotation.keyIndex(); if (keyIndex < -1) { throw new InvalidParameterException( String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.KeyIndex(keyIndex)); final String keyTemplate = annotation.keyTemplate(); if (!AnnotationConstants.DEFAULT_STRING.equals(keyTemplate)) { if (StringUtils.isBlank(keyTemplate)) { throw new InvalidParameterException(String.format( "KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.KeyTemplate(keyTemplate)); } final int dataIndex = annotation.dataIndex(); if (dataIndex < -1) { throw new InvalidParameterException( String.format("DataIndex for annotation [%s] must be -1 or greater on [%s]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.DataIndex(dataIndex)); final String dataTemplate = annotation.dataTemplate(); if (!AnnotationConstants.DEFAULT_STRING.equals(dataTemplate)) { if (StringUtils.isBlank(dataTemplate)) { throw new InvalidParameterException(String.format( "DataTemplate for annotation [%s] must not be defined as an empty string on [%s]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.DataTemplate(dataTemplate)); } final Class dataTemplateType = annotation.dataTemplateType(); if (!String.class.equals(dataTemplateType)) { result.add(new AType.DataTemplateType(dataTemplateType)); } final int expiration = annotation.expiration(); if (expiration < 0) { throw new InvalidParameterException( String.format("Expiration for annotation [%s] must be 0 or greater on [%s]", UpdateMultiCache.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]", UpdateMultiCache.class.getName(), targetMethodName)); } result.add(new AType.Jitter(jitter == -1 ? jitterDefault : jitter)); return result; }
From source file:uk.ac.ebi.mdk.apps.tool.FindMismatches.java
public Reconstruction getReconstruction(File file) { try {//from www . j a v a2 s .c om return ReconstructionIOHelper.read(file); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (ClassNotFoundException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } throw new InvalidParameterException("Reconstruction " + file + " was not read!"); }
From source file:com.jhash.oimadmin.Utils.java
public static void extractJarFile(String directory, String jarFileName) { File baseDir = new File(directory); if (baseDir.exists()) { if (!baseDir.isDirectory()) { throw new InvalidParameterException("Destination directory " + directory + " to expand Jar file " + jarFileName + " is not a directory"); }//from w w w. j av a 2 s . c om if (!baseDir.canWrite() || !baseDir.canWrite() || !baseDir.canExecute()) { throw new InvalidParameterException("Destination directory " + directory + " to expand Jar file " + jarFileName + " does not have rwx access for user"); } } else { baseDir.mkdirs(); } try (JarFile jar = new JarFile(jarFileName)) { Enumeration enumEntries = jar.entries(); while (enumEntries.hasMoreElements()) { JarEntry file = (JarEntry) enumEntries.nextElement(); File f = new File(directory + File.separator + file.getName()); if (file.isDirectory()) { // if its a directory, create it f.mkdirs(); continue; } try (java.io.InputStream is = jar.getInputStream(file); java.io.FileOutputStream fos = new java.io.FileOutputStream(f)) { // get the input stream while (is.available() > 0) { // write contents of 'is' to 'fos' fos.write(is.read()); } fos.close(); is.close(); } catch (Exception exception) { throw new OIMAdminException("Failed to write the jar file entry " + file + " to location " + f, exception); } } } catch (Exception exception) { throw new OIMAdminException("Failed to extract jar file " + jarFileName + " to directory " + directory, exception); } }
From source file:eu.bittrade.libs.steemj.protocol.operations.ClaimRewardBalanceOperation.java
@Override public void validate(ValidationType validationType) { if (!ValidationType.SKIP_VALIDATION.equals(validationType)) { if ((rewardSbd.getAmount() + rewardSteem.getAmount() + rewardVests.getAmount()) <= 0) { throw new InvalidParameterException("Must claim something."); }/*from www.j ava2 s . c om*/ if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) { if (!rewardSbd.getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol())) { throw new InvalidParameterException("The SBD reward must be of symbol type SBD."); } else if (rewardSbd.getAmount() < 0) { throw new InvalidParameterException("Cannot claim a negative SBD amount"); } else if (!rewardVests.getSymbol().equals(SteemJConfig.getInstance().getVestsSymbol())) { throw new InvalidParameterException("The VESTS reward must be of symbol type VESTS."); } else if (rewardVests.getAmount() < 0) { throw new InvalidParameterException("Cannot claim a negative VESTS amount"); } else if (!rewardSteem.getSymbol().equals(SteemJConfig.getInstance().getTokenSymbol())) { throw new InvalidParameterException("The STEEM reward must be of symbol type STEEM."); } else if (rewardSteem.getAmount() < 0) { throw new InvalidParameterException("Cannot claim a negative STEEM amount"); } } } }
From source file:org.nlp2rdf.webservice.NIFParameters.java
public static String requiredParameter(String parameterName, HttpServletRequest hsr, String... requiredValues) { String value = requiredParameter(parameterName, hsr); if (!oneOf(value, requiredValues)) { throw new InvalidParameterException("Wrong value for parameter " + parameterName + ", value was: " + value + ", but must be one of ( " + StringUtils.join(requiredValues, ", ") + " ) "); }//from w w w. j ava 2 s .c o m return value; }
From source file:com.drextended.actionhandler.action.CompositeAction.java
/** * Specific type of action which can contain a few other actions, show them as menu items, * and fire an action, if corresponding item clicked. * * @param titleProvider provider for corresponding menu item's title * @param actions action item, which contains menu item titles and actions, * which will be fired if corresponding menu item selected * @param displayDialogForSingleAction True for show a menu, false for fire action directly * if there is only single action in a menu. * @param showNonAcceptedActions true for show non accepted actions in menu as disabled, * false to hide them *///from w w w. j ava 2 s. c o m public CompositeAction(TitleProvider<M> titleProvider, boolean displayDialogForSingleAction, boolean showNonAcceptedActions, ActionItem... actions) { if (actions == null) throw new InvalidParameterException("Provide at least one action"); mActions = actions; mTitleProvider = titleProvider; mDisplayDialogForSingleAction = displayDialogForSingleAction; mShowNonAcceptedActions = showNonAcceptedActions; for (ActionItem item : mActions) { if (item.action instanceof BaseAction) { // add listeners to menu actions BaseAction baseAction = (BaseAction) item.action; baseAction.addActionFiredListener(this); baseAction.addActionErrorListener(this); baseAction.addActionDismissListener(this); baseAction.addActionFireInterceptor(this); } } }
From source file:org.xwiki.rendering.block.AbstractBlock.java
@Override public void replaceChild(List<Block> newBlocks, Block oldBlock) { int position = indexOfChild(oldBlock); if (position == -1) { throw new InvalidParameterException("Provided Block to replace is not a child"); }/* w w w. j a v a 2 s . c om*/ List<Block> blocks = getChildren(); // Remove old child blocks.remove(position); oldBlock.setParent(null); // Insert new children Block previousBlock = oldBlock.getPreviousSibling(); if (newBlocks.isEmpty()) { previousBlock.setNextSiblingBlock(oldBlock.getNextSibling()); } Block lastBlock = null; for (Block block : newBlocks) { block.setParent(this); block.setPreviousSiblingBlock(previousBlock); if (previousBlock != null) { previousBlock.setNextSiblingBlock(block); } previousBlock = block; lastBlock = block; } Block nextBlock = oldBlock.getNextSibling(); if (nextBlock != null) { nextBlock.setPreviousSiblingBlock(lastBlock); } if (lastBlock != null) { lastBlock.setNextSiblingBlock(nextBlock); } blocks.addAll(position, newBlocks); oldBlock.setNextSiblingBlock(null); oldBlock.setPreviousSiblingBlock(null); }
From source file:eu.bittrade.libs.steemj.protocol.operations.EscrowApproveOperation.java
@Override public void validate(ValidationType validationType) { if (!ValidationType.SKIP_VALIDATION.equals(validationType) && !(who.equals(to) || who.equals(agent))) { throw new InvalidParameterException( "The to account or the agent account must approve this escrow operation."); }//from ww w .j a v a 2s . c om }
From source file:com.fluidops.iwb.provider.SilkProvider.java
private static void assertConsistency(Config c) throws InvalidParameterException { // presence of sourceDataset if (c.sourceDataset == null) throw new InvalidParameterException("Source dataset undefined"); if (StringUtil.isNullOrEmpty(c.sourceDataset.variable)) throw new InvalidParameterException( "Source dataset parameter 'variable' invalid: " + c.sourceDataset.variable); if (StringUtil.isNullOrEmpty(c.sourceDataset.restrictTo)) throw new InvalidParameterException( "Source dataset parameter 'restrictTo' null or empty" + c.sourceDataset.restrictTo); // presence of targetDataset if (c.targetDataset == null) throw new InvalidParameterException("Target dataset undefined"); if (StringUtil.isNullOrEmpty(c.targetDataset.variable)) throw new InvalidParameterException( "Target dataset parameter 'variable' invalid: " + c.targetDataset.variable); if (StringUtil.isNullOrEmpty(c.targetDataset.restrictTo)) throw new InvalidParameterException( "Target dataset parameter 'restrictTo' invalid: " + c.targetDataset.restrictTo); // consistency across sourceDataset and targetDataset if (c.sourceDataset.variable.equals(c.targetDataset.variable)) throw new InvalidParameterException("Variables in sourceDataset and targetDataset must differ"); // if the filter threshold is set, it must be a number in-between 0 and 1 if (!StringUtil.isNullOrEmpty(c.filterTreshold)) { try {//from www . j av a 2 s .co m Double d = Double.valueOf(c.filterTreshold); if (d < 0 || d > 1) throw new InvalidParameterException("Filter threshold must be in range 0--1, but is: " + d); } catch (Exception e) { throw new InvalidParameterException("Problem casting filterThreshold: " + e.getMessage()); } } // linkage rule if (StringUtil.isNullOrEmpty(c.linkageRule)) throw new InvalidParameterException("Linkage rule not specified or empty"); }