List of usage examples for java.security InvalidParameterException InvalidParameterException
public InvalidParameterException(String msg)
From source file:net.sf.zekr.engine.addonmgr.AddOnManagerUtils.java
/** * Is the resource is installed in the shared directory * //from w ww. ja v a 2s. c o m * @param resource * @return true if installed in the shared directory */ public static Boolean isResourceShared(Resource resource) { if (resource instanceof CandidateResource) throw new InvalidParameterException("CandidateResource is not a valid resource for this method"); else { String installationPath = resource.getFile().getAbsolutePath(); return installationPath.contains(getSharedInstallationFolder(resource)); } }
From source file:com.predic8.membrane.annot.bean.MCUtil.java
@SuppressWarnings("unchecked") public static <T> T fromXML(Class<T> clazz, final String xml) { final String MAGIC = "magic.xml"; FileSystemXmlApplicationContext fsxacApplicationContext = new FileSystemXmlApplicationContextExtension( MAGIC, xml);/*from w w w . j a v a 2 s.co m*/ fsxacApplicationContext.setConfigLocation(MAGIC); fsxacApplicationContext.refresh(); Object bean = null; if (fsxacApplicationContext.containsBean("main")) { bean = fsxacApplicationContext.getBean("main"); } else { Collection<T> beans = fsxacApplicationContext.getBeansOfType(clazz).values(); if (beans.size() > 1) throw new InvalidParameterException( "There is more than one bean of type '" + clazz.getName() + "'."); bean = beans.iterator().next(); } if (bean == null) throw new InvalidParameterException("Did not find bean with ID 'main'."); if (!clazz.isAssignableFrom(bean.getClass())) throw new InvalidParameterException("Bean 'main' is not a " + clazz.getName() + " ."); return (T) bean; }
From source file:org.openanzo.jdbc.opgen.RdbStatement.java
/** * Create a new RdbStatement from the given XML emement data * // w w w. j a v a 2 s . c o m * @param sqlPackageName * package name for statement * @param xmlElement * XML element containing data */ public RdbStatement(String sqlPackageName, Element xmlElement) { this.sqlPackageName = sqlPackageName; if (!xmlElement.getNodeName().equals(element)) throw new InvalidParameterException("XML element not of type '" + element + "'"); sql = getText(xmlElement); if (sql == null) throw new InvalidParameterException("Node has no text: " + xmlElement); if (sql.trim().equals("EMPTY")) { sql = ""; } Node nameNode = xmlElement.getAttributes().getNamedItem(nameAttribute); if (nameNode == null) throw new InvalidParameterException( "'" + nameAttribute + "' is a required attribute for '" + element + "' element."); name = nameNode.getNodeValue(); Node inputsNode = xmlElement.getAttributes().getNamedItem(inputsAttribute); if (inputsNode != null) { String paramList = inputsNode.getNodeValue(); inputs = getParams(paramList); } else { inputs = new ArrayList<Parameter>(0); } Node templateParamsNode = xmlElement.getAttributes().getNamedItem(templateParamsAttribute); if (templateParamsNode != null) { String paramList = templateParamsNode.getNodeValue(); templateParams = getParams(paramList); } else { templateParams = new ArrayList<Parameter>(0); } Node outputsNode = xmlElement.getAttributes().getNamedItem(outputsAttribute); if (outputsNode != null) { String paramList = outputsNode.getNodeValue(); outputs = getParams(paramList); } else { outputs = new ArrayList<Parameter>(0); } Node resultsNode = xmlElement.getAttributes().getNamedItem(resultsAttribute); if (resultsNode != null) { results = Result.getResultsEnum(resultsNode); } Node dpNode = xmlElement.getAttributes().getNamedItem(PREPARE); if (dpNode != null) { prepare = Boolean.parseBoolean(dpNode.getNodeValue()); } initialize(); }
From source file:org.alfresco.rm.rest.api.impl.RecordsImpl.java
@Override public Node fileOrLinkRecord(String recordId, TargetContainer target, Parameters parameters) { if (StringUtils.isBlank(target.getTargetParentId()) && StringUtils.isBlank(target.getRelativePath())) { throw new InvalidParameterException("No target folder information was provided"); }/*w ww . j a v a2s . c o m*/ // Get record NodeRef record = nodes.validateNode(recordId); // Get record folder to file/link the record to String parentContainerId = target.getTargetParentId(); if (parentContainerId == null || parentContainerId.isEmpty()) { // If target container not provided get fileplan parentContainerId = authenticationUtil.runAsSystem(new RunAsWork<String>() { @Override public String doWork() { return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID).getId(); } }); } NodeRef parentRecordFolder = nodes.getOrCreatePath(parentContainerId, target.getRelativePath(), ContentModel.TYPE_CONTENT); // Check if the target is a record folder if (!dictionaryService.isSubClass(nodeService.getType(parentRecordFolder), RecordsManagementModel.TYPE_RECORD_FOLDER)) { throw new InvalidArgumentException("The provided target parent is not a record folder"); } // Get the current parent type to decide if we link or move the record NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef(); if (dictionaryService.isSubClass(nodeService.getType(primaryParent), RecordsManagementModel.TYPE_RECORD_FOLDER)) { recordService.link(record, parentRecordFolder); } else { try { fileFolderService.moveFrom(record, primaryParent, parentRecordFolder, null); } catch (FileExistsException e) { throw new IntegrityException(e.getMessage(), null); } catch (FileNotFoundException e) { throw new ConcurrencyFailureException("The record was deleted while filing it", e); } } // Get the record info return nodes.getFolderOrDocument(recordId, parameters); }
From source file:eu.bittrade.libs.steemj.base.models.ChainProperties.java
/** * Define the interest rate for SBD in percent, while 0 equals 0% and 10000 * equals 100.00%.//from w w w .j a v a2 s. co m * * @param sdbInterestRate * The SBD interest rate to set. * @throws InvalidParameterException * If the SBD interest rate is less than 0% or more than 100% * (10000). */ public void setSdbInterestRate(int sdbInterestRate) { if (sdbInterestRate < 0 || sdbInterestRate > 10000) { throw new InvalidParameterException( "The SBD interest rate needs to be somewhere between 0 and 10000 (100%)."); } this.sdbInterestRate = sdbInterestRate; }
From source file:eu.bittrade.libs.steemj.protocol.operations.ClaimRewardBalanceOperation.java
/** * Set the amount of Steem 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.// w ww. j av a2 s .com * * @param rewardSteem * The amount of Steem to collect. * @throws InvalidParameterException * If the provided <code>rewardSteem</code> is null, does not * have the symbol type STEEM or the amount to claim is * negative. */ public void setRewardSteem(Asset rewardSteem) { if (rewardSteem == null) { throw new InvalidParameterException("The STEEM reward can't be null."); } this.rewardSteem = rewardSteem; }
From source file:com.predic8.membrane.core.transport.http.HttpEndpointListener.java
void setOpenStatus(Socket socket, boolean isOpen) { if (isOpen)/*from ww w . j a v a 2 s .c o m*/ throw new InvalidParameterException("isOpen"); openSockets.remove(socket); }
From source file:org.flite.cach3.aop.L2UpdateSingleCacheAdvice.java
static AnnotationInfo getAnnotationInfo(final L2UpdateSingleCache annotation, final String targetMethodName) { final AnnotationInfo result = new AnnotationInfo(); if (annotation == null) { throw new InvalidParameterException( String.format("No annotation of type [%s] found.", L2UpdateSingleCache.class.getName())); }//from w w w. jav 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]", L2UpdateSingleCache.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]", L2UpdateSingleCache.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]", L2UpdateSingleCache.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]", L2UpdateSingleCache.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]", L2UpdateSingleCache.class.getName(), targetMethodName)); } if (keyIndexDefined) { if (keyIndex < -1) { throw new InvalidParameterException( String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]", L2UpdateSingleCache.class.getName(), targetMethodName)); } result.add(new AType.KeyIndex(keyIndex)); } if (keyTemplateDefined) { 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]", L2UpdateSingleCache.class.getName(), targetMethodName)); } result.add(new AType.DataIndex(dataIndex)); final Duration window = annotation.window(); if (window == Duration.UNDEFINED) { throw new InvalidParameterException( String.format("Window for annotation [%s] must be a defined value on [%s]", L2UpdateSingleCache.class.getName(), targetMethodName)); } result.add(new AType.Window(window)); return result; }
From source file:org.flite.cach3.aop.CacheBase.java
public static Object validateReturnValueAsKeyObject(final Object returnValue, final Method methodToCache) throws Exception { if (returnValue == null) { throw new InvalidParameterException(String.format( "The result of the method [%s] is null, which will not give an appropriate cache key.", methodToCache.toString())); }//w ww .j a v a 2 s . com return returnValue; }
From source file:net.blogracy.controller.MediaController.java
/** * Create a new Album for the user. Adds the album to the user's recordDB * entry Adds the action to the ActivityStream (verb: create) * /* ww w .ja v a2s .co m*/ * @param userId * @param photoAlbumName */ public synchronized String createPhotoAlbum(String userId, String photoAlbumTitle) { if (userId == null) throw new InvalidParameterException("userId cannot be null"); if (photoAlbumTitle == null || photoAlbumTitle.isEmpty()) return null; String albumHash = null; try { albumHash = sharing.hash(userId + photoAlbumTitle); Album album = new AlbumImpl(); album.setTitle(photoAlbumTitle); album.setId(albumHash); album.setOwnerId(userId); List<Type> types = new ArrayList<Type>(); types.add(Type.IMAGE); album.setMediaType(types); // Album is empty where created album.setMediaItemCount(0); final List<ActivityEntry> feed = activities.getFeed(userId); final ActivityEntry entry = new ActivityEntryImpl(); entry.setVerb("create"); ActivityObject mediaAlbumObject = new ActivityObjectImpl(); mediaAlbumObject.setObjectType("collection"); mediaAlbumObject.setContent(photoAlbumTitle); entry.setObject(mediaAlbumObject); entry.setPublished(ISO_DATE_FORMAT.format(new Date())); entry.setContent(photoAlbumTitle); feed.add(0, entry); String feedUri = activities.seedActivityStream(userId, feed); // Append another album into the user's recordDB JSONObject recordDb = DistributedHashTable.getSingleton().getRecord(userId); if (recordDb == null) recordDb = new JSONObject(); JSONArray albums = recordDb.optJSONArray("albums"); if (albums != null) { // Simply append new album albums.put(new JSONObject(CONVERTER.convertToString(album))); } else { albums = new JSONArray(); albums.put(new JSONObject(CONVERTER.convertToString(album))); } DistributedHashTable.getSingleton().store(userId, feedUri, entry.getPublished(), albums, recordDb.optJSONArray("mediaItems")); } catch (Exception e) { e.printStackTrace(); } return albumHash; }