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:org.flite.cach3.aop.LogicalCacheImpl.java

public void setBulk(Map<String, Object> contents, Duration duration) {
    if (duration == null || Duration.UNDEFINED == duration) {
        throw new InvalidParameterException("UNDEFINED is not an allowed value");
    }/*from  www . j  av a2 s.  co  m*/
    if (contents.size() == 0) {
        return;
    }

    // Only do this on SET, because we want the GET to be super-optimized.
    warnOfDuplication(contents.keySet(), duration);

    final Cache<String, Object> cache = caches.get(duration);
    for (final Map.Entry<String, Object> entry : contents.entrySet()) {
        final String key = entry.getKey();
        final Object value = entry.getValue() == null ? new PertinentNegativeNull() : entry.getValue();
        //            System.out.println("Key: " + key + "; Value: " + value.toString() + "; Duration: " + duration);
        nanny.put(key, duration);
        cache.put(key, value);
    }
}

From source file:ch.admin.suis.msghandler.servlet.PingServlet.java

private String handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws InvalidParameterException {

    response.setContentType(TEXT);/*from  w  w  w.ja  v a2s. c  o  m*/

    if (StringUtils.isNotBlank(request.getParameter(PARAM_TYPE))) {
        String paramValue = request.getParameter(PARAM_TYPE);
        if (paramValue.equalsIgnoreCase(TYPE_MINIMAL)) {
            return "ok";
        } else if (paramValue.equalsIgnoreCase(TYPE_HEAP_SPACE)) {
            return calcHeapSpace();
        } else if (paramValue.equalsIgnoreCase(TYPE_PERM_SPACE)) {
            return calcPermSpace();
        } else if (paramValue.equalsIgnoreCase(TYPE_HTML)) {
            response.setContentType(HTML);
            return createFullHtml();
        } else {
            throw new InvalidParameterException(
                    "Invalid parameter. Valid parameters: type={minimal,heapSpace,permSpace,html}");
        }
    }

    response.setContentType(HTML);
    return createFullHtml();
}

From source file:net.sf.sail.webapp.spring.impl.CustomContextLoader.java

/**
 * The behaviour of this method is the same as the superclass except for
 * setting of the config locations.// w  w w  . j a  v  a2 s  .c om
 * 
 * @throws ClassNotFoundException
 * 
 * @see org.springframework.web.context.ContextLoader#createWebApplicationContext(javax.servlet.ServletContext,
 *      org.springframework.context.ApplicationContext)
 */
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext servletContext,
        ApplicationContext parent) throws BeansException {

    Class<?> contextClass = determineContextClass(servletContext);
    if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) {
        throw new ApplicationContextException("Custom context class [" + contextClass.getName()
                + "] is not of type ConfigurableWebApplicationContext");
    }

    ConfigurableWebApplicationContext webApplicationContext = (ConfigurableWebApplicationContext) BeanUtils
            .instantiateClass(contextClass);
    webApplicationContext.setParent(parent);
    webApplicationContext.setServletContext(servletContext);

    String configClass = servletContext.getInitParameter(CONFIG_CLASS_PARAM);
    if (configClass != null) {
        try {
            SpringConfiguration springConfig = (SpringConfiguration) BeanUtils
                    .instantiateClass(Class.forName(configClass));
            webApplicationContext.setConfigLocations(springConfig.getRootApplicationContextConfigLocations());
        } catch (ClassNotFoundException e) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(CONFIG_CLASS_PARAM + " <" + configClass + "> not found.", e);
            }
            throw new InvalidParameterException("ClassNotFoundException: " + configClass);
        }
    } else {
        throw new InvalidParameterException("No value defined for the required: " + CONFIG_CLASS_PARAM);
    }

    webApplicationContext.refresh();
    return webApplicationContext;
}

From source file:sh.calaba.driver.server.CalabashNodeConfiguration.java

/**
 * Reads the the driver configuration from the specified URI. The file is expected to be in JSON
 * format./*from w  w w  . j av  a 2s.co m*/
 * 
 * @param driverConfigFileURI The file name of the driver configuration file URI.
 * @return The Calabash node configuration.
 * @throws CalabashConfigurationException On IO and Parsing errors.
 * @throws InvalidParameterException if parameter is null or empty
 */
public static CalabashNodeConfiguration readFromURI(URI driverConfigFileURI)
        throws CalabashConfigurationException {
    if (driverConfigFileURI == null) {
        throw new InvalidParameterException("Calabash-Driver Configuration-URI is missing.");
    }
    if (driverConfigFileURI.getHost() == null || driverConfigFileURI.getPath() == null) {
        throw new InvalidParameterException("Calabash-Driver Configuration-URI is invalid.");
    }
    String driverConfiguration;
    try {
        HttpClient client = getDefaultHttpClient();
        HttpGet request = new HttpGet(driverConfigFileURI);
        HttpResponse response = client.execute(request);

        driverConfiguration = IOUtils.toString(response.getEntity().getContent());
    } catch (IOException e1) {
        logger.error("Error occured while reading config from URI:", e1);
        throw new CalabashConfigurationException(
                "Error reading file content. Did you have specified the right URI?", e1);
    } catch (KeyManagementException e) {
        logger.error("Error occured while creating httpclient:", e);
        throw new CalabashConfigurationException("Error occured while creating httpclient", e);
    } catch (NoSuchAlgorithmException e) {
        logger.error("Error occured while creating httpclient:", e);
        throw new CalabashConfigurationException("Error occured while creating httpclient", e);
    }

    try {
        return new CalabashNodeConfiguration(new JSONObject(driverConfiguration));
    } catch (JSONException e) {
        logger.error("Error occured while parsing config file: ", e);
        throw new CalabashConfigurationException("Error occured during parsing json file from URI: '"
                + driverConfigFileURI + "'. Pls make sure you are using a valid JSON file!", e);
    }
}

From source file:eu.bittrade.libs.steemj.communication.CommunicationHandler.java

/**
 * Initialize a new <code>client</code> by selecting one of the configured
 * endpoints.//  w  w  w  . j a v a2 s.co  m
 * 
 * @throws SteemCommunicationException
 *             If no {@link AbstractClient} implementation for the given
 *             schema is available.
 */
public void initializeNewClient() throws SteemCommunicationException {
    if (client != null) {
        try {
            client.closeConnection();
        } catch (IOException e) {
            throw new SteemCommunicationException("Could not close the current client connection.", e);
        }
    }
    // Get a new endpoint URI based on the number of retries.
    Pair<URI, Boolean> endpoint = SteemJConfig.getInstance().getNextEndpointURI(numberOfConnectionTries);

    if (endpoint.getLeft().getScheme().toLowerCase().matches("(http){1}[s]?")) {
        client = new HttpClient();
    } else if (endpoint.getLeft().getScheme().toLowerCase().matches("(ws){1}[s]?")) {
        client = new WebsocketClient();
    } else {
        throw new InvalidParameterException("No client implementation for the following protocol available: "
                + endpoint.getLeft().getScheme().toLowerCase());
    }
}

From source file:org.pentaho.common.ui.services.SolutionUrlContentGenerator.java

@Override
public void createContent() throws Exception {
    OutputStream out = null;//from   w ww  .j a v  a2  s . c o  m
    if (outputHandler == null) {
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0004_NO_OUTPUT_HANDLER")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getString("SolutionUrlContentGenerator.ERROR_0004_NO_OUTPUT_HANDLER")); //$NON-NLS-1$
    }

    IParameterProvider params = parameterProviders.get("path"); //$NON-NLS-1$

    String urlPath = params.getStringParameter("path", null); //$NON-NLS-1$

    ActionInfo pathInfo = ActionInfo.parseActionString(urlPath);

    if (pathInfo == null) {
        // there is no path so we don't know what to return
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0001_NO_FILEPATH")); //$NON-NLS-1$
        return;
    }

    if (urlPath.startsWith("system/")) { //$NON-NLS-1$
        // don't allow access into the system solution
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0005_BAD_FILEPATH")); //$NON-NLS-1$
        return;
    }

    if (PentahoSystem.debug) {
        debug("SolutionResourceContentGenerator urlPath=" + urlPath); //$NON-NLS-1$
    }
    int type = TYPE_UNKNOWN;

    // work out what this thing is
    String filename = pathInfo.getActionName();
    String extension = ""; //$NON-NLS-1$
    int index = filename.lastIndexOf('.');
    if (index != -1) {
        extension = filename.substring(index + 1);
    }

    // is this a plugin file type?
    if (type == TYPE_UNKNOWN) {
        IPluginManager pluginManager = getPluginManager();
        if (pluginManager != null) {
            IContentGenerator contentGenerator = null;
            try {
                contentGenerator = pluginManager.getContentGenerator(extension, null);
            } catch (NoSuchBeanDefinitionException e) {
                // could not find a content generator to use for this extension, leave contentGenerator null
                contentGenerator = null;
            }
            if (contentGenerator != null) {
                // set up the path parameters
                IParameterProvider requestParams = parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
                if (requestParams instanceof SimpleParameterProvider) {
                    ((SimpleParameterProvider) requestParams).setParameter("solution", //$NON-NLS-1$
                            pathInfo.getSolutionName());
                    ((SimpleParameterProvider) requestParams).setParameter("path", pathInfo.getPath()); //$NON-NLS-1$
                    ((SimpleParameterProvider) requestParams).setParameter("name", pathInfo.getActionName()); //$NON-NLS-1$
                    ((SimpleParameterProvider) requestParams).setParameter("action", pathInfo.getActionName()); //$NON-NLS-1$
                }
                // delegate over to the content generator for this file type
                contentGenerator.setCallbacks(callbacks);
                contentGenerator.setInstanceId(instanceId);
                contentGenerator.setItemName(itemName);
                contentGenerator.setLoggingLevel(loggingLevel);
                contentGenerator.setMessagesList(messages);
                contentGenerator.setOutputHandler(outputHandler);
                contentGenerator.setParameterProviders(parameterProviders);
                contentGenerator.setSession(userSession);
                contentGenerator.setUrlFactory(urlFactory);
                contentGenerator.createContent();
                return;
            }
        }
    }

    // get the mime-type
    String mimeType = MimeHelper.getMimeTypeFromFileName(filename);
    if (mimeType != null && mimeType.equals(MimeHelper.MIMETYPE_XACTION)) {
        mimeType = null;
    }

    // is this a static file type?
    if ((pathInfo.getPath().startsWith("resources/web/") || pathInfo.getPath().equals("resources/web")) //$NON-NLS-1$//$NON-NLS-2$
            && mimeType != null) {
        // this is a static file type
        type = TYPE_STATIC;
    }

    if (type == TYPE_UNKNOWN) {
        // should not handle this file type
        warn(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0002_CANNOT_HANDLE_TYPE", urlPath)); //$NON-NLS-1$
        return;
    }

    IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", instanceId, mimeType); //$NON-NLS-1$ //$NON-NLS-2$
    if (contentItem == null) {
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0006_NO_OUTPUT_ITEM")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getString("SolutionUrlContentGenerator.ERROR_0006_NO_OUTPUT_ITEM")); //$NON-NLS-1$
    }

    contentItem.setMimeType(mimeType);

    out = contentItem.getOutputStream(itemName);
    if (out == null) {
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0007_NO_OUTPUT_STREAM")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getString("SolutionUrlContentGenerator.ERROR_0007_NO_OUTPUT_STREAM")); //$NON-NLS-1$
    }

    // TODO support cache control settings

    InputStream in = createRepositoryFileInputStream(urlPath);
    if (in == null) {
        error(Messages.getErrorString("SolutionUrlContentGenerator.ERROR_0003_RESOURCE_NOT_FOUND", urlPath)); //$NON-NLS-1$
        return;
    }

    try {
        byte[] buffer = new byte[4096];
        int n = in.read(buffer);
        while (n != -1) {
            out.write(buffer, 0, n);
            n = in.read(buffer);
        }
    } finally {
        out.close();
    }

}

From source file:ua.at.tsvetkov.data_processor.ProcessingCentre.java

public T execute() {
    if (!isCorrectClass()) {
        throw new InvalidParameterException(INVALID_CLASS_PARAMETER);
    }// w w  w .j ava  2s .co  m
    cacheFileName = request.getCacheFileName();
    try {
        if (cacheFileName != null && cacheFileName.length() > 0) {
            saveToFile();
        } else {
            inputStream = request.getInputStream();
        }
        if (request.getStatusCode() == FILE_SUCCESS || request.getStatusCode() == HttpStatus.SC_OK) {
            createProcessor();
        }
        if (processor != null) {
            processor.parse(inputStream);
            sendMessage(request.getStatusCode(), (T) processor.getResult());
        } else {
            sendMessage(request.getStatusCode(), null);
            //            sendMessage(request.getStatusCode(), inputStream); WTF???
        }
    } catch (Exception e) {
        Log.e(e);
        sendMessage(ERROR, null);
    } finally {
        try {
            if (inputStream != null)
                inputStream.close();
            request.close();
        } catch (Exception e) {
            Log.e(e);
        }
    }
    if (DataProcessor.getInstance().getConfiguration().isLogEnabled()
            && DataProcessor.getInstance().getConfiguration().isShowProcessingTime()) {
        long time = System.currentTimeMillis() - request.getStartTime();
        Log.v("Processing time = " + time + " ms. [ " + request + " ]");
    }
    if (processor != null)
        return (T) processor.getResult();
    else
        return null;
}

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

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

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

        Repository repository = Repository.getDefaultRepository(this);
        ThemeContainer themes = repository.getThemes();
        themes.deleteTheme(m_themeNameArgument);

        finish();//from w  ww  .j  ava 2 s .c  om

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

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

From source file:com.facebook.presto.accumulo.examples.TpcHClerkSearch.java

@Override
public int run(AccumuloConfig config, CommandLine cmd) throws Exception {
    String[] searchTerms = cmd.getOptionValues(CLERK_ID);

    ZooKeeperInstance inst = new ZooKeeperInstance(config.getInstance(), config.getZooKeepers());
    Connector conn = inst.getConnector(config.getUsername(), new PasswordToken(config.getPassword()));

    // Ensure both tables exists
    validateExists(conn, DATA_TABLE);// w  w w.j a v a2s  .  co  m
    validateExists(conn, INDEX_TABLE);

    long start = System.currentTimeMillis();

    // Create a scanner against the index table
    BatchScanner idxScanner = conn.createBatchScanner(INDEX_TABLE, new Authorizations(), 10);
    LinkedList<Range> searchRanges = new LinkedList<Range>();

    // Create a search Range from the command line args
    for (String searchTerm : searchTerms) {
        if (clerkRegex.matcher(searchTerm).matches()) {
            searchRanges.add(new Range(searchTerm));
        } else {
            throw new InvalidParameterException(
                    format("Search term %s does not match regex Clerk#[0-9]{9}", searchTerm));
        }
    }

    // Set the search ranges for our scanner
    idxScanner.setRanges(searchRanges);

    // A list to hold all of the order IDs
    LinkedList<Range> orderIds = new LinkedList<Range>();
    String orderId;

    // Process all of the records returned by the batch scanner
    for (Map.Entry<Key, Value> record : idxScanner) {
        // Get the order ID and add it to the list of order IDs
        orderIds.add(new Range(record.getKey().getColumnQualifier()));
    }

    // Close the batch scanner
    idxScanner.close();

    // If clerkIDs is empty, log a message and return 0
    if (orderIds.isEmpty()) {
        System.out.println("Found no orders with the given Clerk ID(s)");
        return 0;
    } else {
        System.out.println(format("Searching data table for %d orders", orderIds.size()));
    }

    // Initialize the batch scanner to scan the data table with
    // the previously found order IDs as the ranges
    BatchScanner dataScanner = conn.createBatchScanner(DATA_TABLE, new Authorizations(), 10);
    dataScanner.setRanges(orderIds);
    dataScanner.addScanIterator(new IteratorSetting(1, WholeRowIterator.class));

    Text row = new Text(); // The row ID
    Text colQual = new Text(); // The column qualifier of the current record

    Long orderkey = null;
    Long custkey = null;
    String orderstatus = null;
    Double totalprice = null;
    Date orderdate = null;
    String orderpriority = null;
    String clerk = null;
    Long shippriority = null;
    String comment = null;

    int numTweets = 0;
    // Process all of the records returned by the batch scanner
    for (Map.Entry<Key, Value> entry : dataScanner) {
        entry.getKey().getRow(row);
        orderkey = decode(Long.class, row.getBytes(), row.getLength());
        SortedMap<Key, Value> rowMap = WholeRowIterator.decodeRow(entry.getKey(), entry.getValue());
        for (Map.Entry<Key, Value> record : rowMap.entrySet()) {
            // Get the column qualifier from the record's key
            record.getKey().getColumnQualifier(colQual);

            switch (colQual.toString()) {
            case CUSTKEY_STR:
                custkey = decode(Long.class, record.getValue().get());
                break;
            case ORDERSTATUS_STR:
                orderstatus = decode(String.class, record.getValue().get());
                break;
            case TOTALPRICE_STR:
                totalprice = decode(Double.class, record.getValue().get());
                break;
            case ORDERDATE_STR:
                orderdate = decode(Date.class, record.getValue().get());
                break;
            case ORDERPRIORITY_STR:
                orderpriority = decode(String.class, record.getValue().get());
                break;
            case CLERK_STR:
                clerk = decode(String.class, record.getValue().get());
                break;
            case SHIPPRIORITY_STR:
                shippriority = decode(Long.class, record.getValue().get());
                break;
            case COMMENT_STR:
                comment = decode(String.class, record.getValue().get());
                break;
            default:
                throw new RuntimeException("Unknown column qualifier " + colQual);
            }
        }

        ++numTweets;
        // Write the screen name and text to stdout
        System.out.println(format("%d|%d|%s|%f|%s|%s|%s|%d|%s", orderkey, custkey, orderstatus, totalprice,
                orderdate, orderpriority, clerk, shippriority, comment));

        custkey = null;
        shippriority = null;
        orderstatus = null;
        orderpriority = null;
        clerk = null;
        comment = null;
        totalprice = null;
        orderdate = null;
    }

    // Close the batch scanner
    dataScanner.close();

    long finish = System.currentTimeMillis();

    System.out.format("Found %d orders in %s ms\n", numTweets, (finish - start));
    return 0;
}