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.baasbox.service.storage.DocumentService.java

/**
 * /*from  w  w w .j av a 2 s .c o  m*/
 * @param collectionName
 * @param rid
 * @param bodyJson
 * @return the updated document, null if the document is not found or belongs to another collection
 * @throws InvalidCollectionException
 * @throws DocumentNotFoundException 
 * @throws IllegalArgumentException 
 * @throws ODatabaseException 
 * @throws UpdateOldVersionException 
 */
public static ODocument update(String collectionName, String rid, JsonNode bodyJson)
        throws InvalidCollectionException, InvalidModelException, ODatabaseException, IllegalArgumentException,
        DocumentNotFoundException, UpdateOldVersionException {
    ODocument doc = get(collectionName, rid);
    if (doc == null)
        throw new InvalidParameterException(rid + " is not a valid document");
    //update the document
    DocumentDao dao = DocumentDao.getInstance(collectionName);
    dao.update(doc, (ODocument) (new ODocument()).fromJSON(bodyJson.toString()));

    return doc;//.toJSON("fetchPlan:*:0 _audit:1,rid");
}

From source file:org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper.java

/**
 * Build a ReplaceOnValueHelper out of the given json string.
 *
 * @param jsonString the json string./* w  w  w. j av a  2s .c o  m*/
 * @return a ReplaceOnValueHelper out of the given json string.
 */
public ReplaceOnValueHelper build(String jsonString, boolean strict) {
    if (StringUtils.isEmpty(jsonString)) {
        throw new InvalidParameterException(jsonString + " is not a valid json");
    }
    try {
        final ObjectMapper mapper = new ObjectMapper();
        final ReplaceOnValueHelper replaceOnValueHelper = mapper.readValue(jsonString,
                ReplaceOnValueHelper.class);
        replaceOnValueHelper.setStrict(strict);
        if (replaceOnValueHelper.isValid()) {
            return replaceOnValueHelper;
        } else {
            throw new IllegalArgumentException();
        }
    } catch (IOException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}

From source file:org.sakaiproject.contentreview.tool.MainController.java

@RequestMapping(value = "/webhooks", method = RequestMethod.POST)
public void webhooks(HttpServletRequest request, HttpServletResponse response, Model model,
        @RequestParam Integer providerId, @RequestParam(required = false) String custom) {
    if (providerId == null) {
        throw new InvalidParameterException("Missing providerName");
    }/*w  ww  . j a  va2s. c  om*/
    log.info("webhook provider and custom: " + custom);
    contentReviewService.webhookEvent(request, providerId, Optional.ofNullable(custom));
}

From source file:eu.bittrade.libs.steemj.plugins.apis.tags.models.DiscussionQuery.java

/**
 * @param tag/*from w w  w.  j  av a 2  s .  co  m*/
 *            the tag to set
 */
public void setTag(String tag) {
    if (this.getFilterTags() != null && this.getFilterTags().indexOf(tag) != this.getFilterTags().size()) {
        throw new InvalidParameterException(
                "Expect " + this.getTag() + " to be the last element in the filter list.");
    }
    this.tag = tag;
}

From source file:org.transdroid.search.RssFeedSearch.PretomeAdapter.java

@Override
protected String getUrl(String query, SortOrder order) {
    String token = SettingsHelper.getSiteToken(prefs, TorrentSite.Pretome);
    if (token == null) {
        throw new InvalidParameterException(
                "No RSS feed token was provided, while this is required for this private site.");
    }//from ww  w  . j  a va  2 s  .  c om

    // NOTE: Torrent Reactor doesn't support sorting in the RSS feed
    try {
        return String.format(Locale.US,
                "https://pretome.info/rss.php?st=1&tf=all&search=%2$s&sort=%3$s&type=d&key=%1$s&full", token,
                URLEncoder.encode(query, "UTF-8"), order == SortOrder.BySeeders ? "7" : "0");
    } catch (UnsupportedEncodingException e) {
        return null;
    }
}

From source file:org.flite.cach3.config.VelocityContextFactory.java

public Object addVelocityContextItems(final Map<String, Object> items) {
    final Object result = null;
    if (items == null || items.size() == 0) {
        return result;
    }/*from  w ww .j  a v a  2  s.  c o m*/

    for (final Map.Entry<String, Object> entry : items.entrySet()) {
        if (entry == null) {
            continue;
        }
        final String key = entry.getKey();
        final Object value = entry.getValue();
        try {
            if (StringUtils.isBlank(key)) {
                throw new InvalidParameterException(
                        String.format("Invalid VelocityContext item name: [%s]", key));
            }
            if (SYSTEM_ITEMS.contains(key.toLowerCase())) {
                throw new InvalidParameterException(
                        String.format("VelocityContext item name reserved for Cach3 system usage: [%s]", key));
            }
            if (value == null) {
                throw new InvalidParameterException(
                        "Null items disallowed from being added to the VelocityContext");
            }

            baseContext.put(key, value);
        } catch (Exception ex) {
            LOG.warn("Problem adding an item to the VelocityContext", ex);
        }
    }
    return result;
}

From source file:org.transdroid.search.HoundDawgs.HoundDawgsAdapter.java

private HttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.HoundDawgs);
    String password = SettingsHelper.getSitePass(context, TorrentSite.HoundDawgs);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }// w w w  . ja v  a2 s  .c om

    // Setup http client
    HttpClient httpclient = HttpHelper.buildDefaultSearchHttpClient(false);

    // First log in
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("username", username),
            new BasicNameValuePair("password", password), new BasicNameValuePair("Login", "login"))));
    HttpResponse loginResult = httpclient.execute(loginPost);
    String loginHtml = HttpHelper.convertStreamToString(loginResult.getEntity().getContent());
    final String LOGIN_ERROR = "<li><a href=\"login.php\">Login</a></li>";
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK
            || loginHtml.indexOf(LOGIN_ERROR) >= 0) {
        // Failed to sign in
        throw new LoginException("Login failure for HoundDawgs with user " + username);
    }

    return httpclient;

}

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

public static String buildCacheKey(final String objectId, final String namespace, final String prefix) {
    if (objectId == null || objectId.length() < 1) {
        throw new InvalidParameterException("Ids for objects in the cache must be at least 1 character long.");
    }/*from w  w  w  .  j  a  v a2s  .c  om*/
    final StringBuilder result = new StringBuilder(namespace).append(SEPARATOR);
    if (StringUtils.isNotBlank(prefix)) {
        result.append(prefix);
    }
    result.append(objectId);
    if (result.length() > 255) {
        throw new InvalidParameterException(
                "Ids for objects in the cache must not exceed 255 characters: [" + result.toString() + "]");
    }
    final String resultString = result.toString();
    if (StringUtils.containsAny(resultString, WS)) {
        throw new InvalidParameterException(
                "Ids for objects in the cache must not have whitespace: [" + result.toString() + "]");
    }
    return resultString;
}

From source file:com.rany.albeg.wein.rssr.RssReader.java

public void read(String rssFeedUrl) throws InvalidParameterException {

    if (rssFeedUrl == null || rssFeedUrl.trim().length() == 0)
        throw new InvalidParameterException("You are passing an empty URL String to read(String rssFeedUrl).");

    if (mReadyToRead)
        new ReadRssAsyncTask().execute(rssFeedUrl);
    else/*from   w ww .ja  va2  s  .  co  m*/
        Log.w(TAG, "RSS read refused. read() did not finish yet.");
}

From source file:org.transdroid.search.Danishbits.DanishbitsAdapter.java

private HttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.Danishbits);
    String password = SettingsHelper.getSitePass(context, TorrentSite.Danishbits);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }//  ww w  .ja v  a2 s .co  m

    // Setup http client
    HttpClient httpclient = HttpHelper.buildDefaultSearchHttpClient(false);

    // First log in
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("username", username),
            new BasicNameValuePair("password", password), new BasicNameValuePair("Login", "login"))));
    HttpResponse loginResult = httpclient.execute(loginPost);
    String loginHtml = HttpHelper.convertStreamToString(loginResult.getEntity().getContent());
    final String LOGIN_ERROR = "<form id=\"loginform\" method=\"post\" action=\"login.php\">";
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK
            || loginHtml.indexOf(LOGIN_ERROR) >= 0) {
        // Failed to sign in
        throw new LoginException("Login failure for HoundDawgs with user " + username);
    }

    return httpclient;

}