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.transdroid.core.gui.navigation.SetStorageLocationDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (currentLocation == null)
        throw new InvalidParameterException(
                "Please first set the current trackers text using setCurrentLocation before opening the dialog.");
    if (onStorageLocationUpdatedListener == null)
        throw new InvalidParameterException(
                "Please first set the callback listener using setOnStorageLocationUpdated before opening the dialog.");
    final View locationFrame = getActivity().getLayoutInflater().inflate(R.layout.dialog_storagelocation, null,
            false);/*from  ww w  .ja va  2s  . c  o  m*/
    final EditText locationText = (EditText) locationFrame.findViewById(R.id.location_edit);
    locationText.setText(currentLocation);
    return new AlertDialog.Builder(getActivity()).setView(locationFrame)
            .setPositiveButton(R.string.status_update, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // User is done editing and requested to update given the text input
                    onStorageLocationUpdatedListener
                            .onStorageLocationUpdated(locationText.getText().toString());
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:com.google.code.pentahoflashcharts.StaticContentGenerator.java

@Override
public void createContent() throws Exception {
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);

    IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            "text/plain"); //$NON-NLS-1$

    if (contentItem == null) {
        error("StaticContentGenerator.ERROR_0001_NO_CONTENT_ITEM"); //$NON-NLS-1$
        throw new InvalidParameterException("StaticContentGenerator.ERROR_0001_NO_CONTENT_ITEM"); //$NON-NLS-1$
    }/*from  www .  jav  a  2s .  com*/

    OutputStream out = null;
    out = contentItem.getOutputStream(null);
    if (out == null) {
        error("StaticContentGenerator.ERROR_0002_NO_OUTPUT_STREAM"); //$NON-NLS-1$
        throw new InvalidParameterException("StaticContentGenerator.ERROR_0002_NO_OUTPUT_STREAM"); //$NON-NLS-1$
    }
    IParameterProvider pathParams = parameterProviders.get("path"); //$NON-NLS-1$
    if (pathParams != null) {
        String urlPath = pathParams.getStringParameter("path", null); //$NON-NLS-1$
        if (urlPath.startsWith("/")) { //$NON-NLS-1$
            urlPath = urlPath.substring(1);
        }
        if (StringUtils.isNotEmpty(urlPath)) {
            allowBrowserCache(resLoader);
            contentItem.setMimeType(MimeHelper.getMimeTypeFromFileName(urlPath));
            InputStream is = resLoader.getResourceAsStream(StaticContentGenerator.class,
                    RESOURCE_PATH + urlPath);
            IOUtils.copy(is, out);
            return;
        }
    }
}

From source file:org.apache.camel.component.neo4j.Neo4jEndpoint.java

public Neo4jEndpoint(String endpointUri, String remaining, Neo4jComponent component,
        Map<String, Object> params) {
    super(endpointUri.split("\\?")[0], component);

    if (!params.isEmpty()) {
        if (params.containsKey(USER) && params.containsKey(PASSWORD))
            graphDatabase = new SpringCypherRestGraphDatabase(remaining, params.get(USER).toString(),
                    params.get(PASSWORD).toString());
        else//from  w w  w .  ja va  2s .  c o m
            throw new InvalidParameterException("The only valid parameters are: [user,password].");
    } else
        graphDatabase = new SpringCypherRestGraphDatabase(remaining);
}

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

/**
 * Reads the the driver configuration form the specified file. The file is expected to be in JSON
 * format.//from w ww  .j ava2 s. c o  m
 * 
 * @param driverConfigurationFile The file name of the driver configuration file.
 * @return The Calabash node configuration.
 * @throws CalabashConfigurationException On IO and Parsing errors.
 * @throws InvalidParameterException if parameter is null or empty
 */
public static CalabashNodeConfiguration readFromFile(File driverConfigurationFile)
        throws CalabashConfigurationException {
    if (driverConfigurationFile == null) {
        throw new InvalidParameterException(
                "Calabash-Driver Configuration-File is missing. Pls specifiy name like: calabashNode.json");
    }
    String driverConfiguration;
    try {
        driverConfiguration = FileUtils.readFileToString(driverConfigurationFile);
    } catch (IOException e1) {
        throw new CalabashConfigurationException(
                "Error reading file content. Did you have specified the right file name and path?", e1);
    }

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

From source file:org.sakuli.actions.settings.ScreenBasedSettings.java

@PostConstruct
public void setDefaults() {
    setMinSimilarity(currentSimilarity);

    WaitScanRate = 10f;//  ww w .jav a  2 s .co m
    ObserveScanRate = 10f;

    ClickDelay = props.getClickDelay();
    RobotDesktop.stdAutoDelay = props.getTypeDelayMs();
    //if stdAutoDelay is set TypeDelay is no longer needed!
    TypeDelay = 0;

    OcrDataPath = sakuliProps.getTessDataLibFolder().toAbsolutePath().toString();
    OcrTextSearch = true;
    OcrTextRead = true;

    Highlight = props.isAutoHighlightEnabled();
    if (props.getDefaultHighlightSeconds() < 1) {
        /**
         * because of the mehtode {@link org.sikuli.script.ScreenHighlighter#closeAfter(float)}
         * */
        throw new InvalidParameterException("the property '" + ActionProperties.DEFAULT_HIGHLIGHT_SEC
                + "' has to be greater as 1, but was " + props.getDefaultHighlightSeconds());
    }
    DefaultHighlightTime = props.getDefaultHighlightSeconds();
    WaitAfterHighlight = 0.1f;

    /***
     * Logging for sikuliX => {@link SysOutOverSLF4J} will send the logs to SLF4J
     */
    Logger sikuliLogger = LoggerFactory.getLogger(Debug.class);
    if (sikuliLogger.isInfoEnabled()) {
        LOGGER.debug("sikuli log level INFO enabled");
        ActionLogs = true;
        InfoLogs = true;
        ProfileLogs = true;
    }
    if (sikuliLogger.isDebugEnabled()) {
        LOGGER.debug("sikuli log level DEBUG enabled");
        DebugLogs = true;
    }
}

From source file:org.saiku.plugin.SaikuContentGenerator.java

@Override
public void createContent() throws Exception {

    if (outputHandler == null) {
        LOG.error("Outputhandler is null");
        throw new InvalidParameterException("Outputhandler is null");
    }//from  w  w  w . ja v a 2  s .  co m

    IParameterProvider requestParams = parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
    if (requestParams == null) {
        LOG.error("Parameter provider is null");
        throw new NullPointerException("Parameter provider is null");
    }
    String solution = requestParams.getStringParameter("solution", null); //$NON-NLS-1$
    String path = requestParams.getStringParameter("path", null); //$NON-NLS-1$
    String action = requestParams.getStringParameter("action", null); //$NON-NLS-1$
    String fullPath = ActionInfo.buildSolutionPath(solution, path, action);
    ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
    if (repository == null) {
        LOG.error("Access to Repository has failed");
        throw new NullPointerException("Access to Repository has failed");
    }

    if (requestParams.getStringParameter("query", null) != null) {
        String query = requestParams.getStringParameter("query", null); //$NON-NLS-1$
        String base = PentahoSystem.getApplicationContext().getSolutionRootPath();
        String parentPath = ActionInfo.buildSolutionPath(solution, path, "");
        ISolutionFile parentFile = repository.getSolutionFile(parentPath, ISolutionRepository.ACTION_CREATE);
        String filePath = parentPath + ISolutionRepository.SEPARATOR + action;
        ISolutionFile fileToSave = repository.getSolutionFile(fullPath, ISolutionRepository.ACTION_UPDATE);

        if (action != null && !action.endsWith(".saiku")) {
            action += ".saiku";
        }
        //         System.out.println("fileToSave:" + fileToSave);
        //         System.out.println("!repository.resourceExists(filePath):" + !repository.resourceExists(filePath));
        //         System.out.println("parentFile:" + parentFile);

        if (fileToSave != null || (!repository.resourceExists(filePath) && parentFile != null)) {
            repository.publish(base, '/' + parentPath, action, query.getBytes(), true);
            LOG.debug(PluginConfig.PLUGIN_NAME + " : Published " + solution + " / " + path + " / " + action);
        } else {
            throw new Exception("Error ocurred while saving query to solution repository");
        }

        OutputStream out = null;
        IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                getMimeType());
        if (contentItem == null) {
            LOG.error("content item is null"); //$NON-NLS-1$
            throw new NullPointerException("content item is null"); //$NON-NLS-1$
        }

        out = contentItem.getOutputStream(null);
        contentItem.setMimeType("text/html");

        out.flush();
        out.close();
    } else if (repository.resourceExists(fullPath)) {
        String doc = repository.getResourceAsString(fullPath);

        if (doc == null) {
            LOG.error("Error retrieving saiku document from solution repository");
            throw new NullPointerException("Error retrieving saiku document from solution repository");
        }
        try {
            IServiceManager serviceManager = (IServiceManager) PentahoSystem.get(IServiceManager.class,
                    PentahoSessionHolder.getSession());
            document = doc;
            IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                    getMimeType());

            if (contentItem == null) {
                LOG.error("content item is null"); //$NON-NLS-1$
                throw new NullPointerException("content item is null"); //$NON-NLS-1$
            }

            OutputStream out = contentItem.getOutputStream(null);
            createContent(out);

        } catch (Exception e) {
            LOG.error("Error loading solution file", e);
            throw new Exception("Error loading solution file", e);
        }

    } else {
        super.createContent();
    }

}

From source file:org.pentaho.pat.plugin.PatContentGenerator.java

@Override
public void createContent() throws Exception {

    if (outputHandler == null) {
        LOG.error(Messages.getString("ContentGenerator.OutputHandler.Null")); //$NON-NLS-1$
        throw new InvalidParameterException(Messages.getString("ContentGenerator.OutputHandler.Null")); //$NON-NLS-1$
    }//from   w  w w  .ja  va 2s  .  c  o m

    IParameterProvider requestParams = parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
    if (requestParams == null) {
        LOG.error(Messages.getString("ContentGenerator.Params.ProviderIsNull")); //$NON-NLS-1$
        throw new NullPointerException(Messages.getString("ContentGenerator.Params.ProviderIsNull")); //$NON-NLS-1$
    }
    String solution = requestParams.getStringParameter("solution", null); //$NON-NLS-1$
    String path = requestParams.getStringParameter("path", null); //$NON-NLS-1$
    String action = requestParams.getStringParameter("action", null); //$NON-NLS-1$
    String fullPath = ActionInfo.buildSolutionPath(solution, path, action);
    ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
    if (repository == null) {
        LOG.error(Messages.getString("ContentGenerator.RepositoryAccessFailed")); //$NON-NLS-1$
        throw new NullPointerException(Messages.getString("ContentGenerator.RepositoryAccessFailed")); //$NON-NLS-1$
    }
    if (repository.resourceExists(fullPath)) {
        Document doc = repository.getResourceAsDocument(fullPath);
        solutionFile = PatSolutionFile.convertDocument(doc);
        if (solutionFile == null) {
            LOG.error(Messages.getString("ContentGenerator.CantParseSolutionfile")); //$NON-NLS-1$
            throw new NullPointerException(Messages.getString("ContentGenerator.CantParseSolutionfile")); //$NON-NLS-1$
        }
        try {
            IServiceManager serviceManager = (IServiceManager) PentahoSystem.get(IServiceManager.class,
                    PentahoSessionHolder.getSession());
            QueryServlet targetQueryBean = (QueryServlet) serviceManager.getServiceBean("gwt", "query.rpc");
            SessionServlet targetSessionBean = (SessionServlet) serviceManager.getServiceBean("gwt",
                    "session.rpc");
            String sessionId = targetSessionBean.createSession();
            targetQueryBean.addBootstrapQuery(sessionId, solutionFile.getConnectionId(),
                    solutionFile.getTitle(), solutionFile.getQueryXml());
            super.createContent();
        } catch (Exception e) {
            LOG.error(Messages.getString("ContentGenerator.CantInjectQuery"), e); //$NON-NLS-1$
            throw new NullPointerException(Messages.getString("ContentGenerator.CantInjectQuery")); //$NON-NLS-1$
        }

    } else if (requestParams.getStringParameter("query", null) != null) {
        OutputStream out = null;

        IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                getMimeType());

        if (contentItem == null) {
            LOG.error(Messages.getString("ContentGenerator.NoContentItem")); //$NON-NLS-1$
            throw new NullPointerException(Messages.getString("ContentGenerator.NoContentItem")); //$NON-NLS-1$
        }

        out = contentItem.getOutputStream(null);

        byte[] resultExcel = ExportController.exportExcel(requestParams.getStringParameter("query", null));
        if (resultExcel != null && resultExcel.length > 0) {
            contentItem.setMimeType("application/vnd.ms-excel");
            out.write(resultExcel);
        }

        out.flush();
        out.close();
    } else {
        super.createContent();
        LOG.debug(PluginConfig.PAT_PLUGIN_NAME + " : CONTENT GENERATOR - DEFAULT OUTPUT");
    }

}

From source file:org.easyxml.xml.Document.java

/**
 * //from w  w  w .ja  va  2 s  .com
 * Set the DefaultContainer
 * 
 * @param container
 *            - The Element to be regarded as DefaultContainer.
 */

protected void setDefaultContainer(Element container) {

    try {

        if (container == null) {

            throw new InvalidParameterException("The container is not valid!");

        }

        // Iterate through the DOM tree to make sure the container is a
        // descendant of this XmlDocument

        if (container != this) {

            Element parent = container;

            do {

                parent = parent.getParent();

                if (parent == this)

                    break;

                else if (parent == null)

                    throw new InvalidParameterException("The root of the element must be this XmlDocument !");

            } while (parent != null);

            this.defaultContainer = container;

        }

    } catch (InvalidParameterException e) {

        e.printStackTrace();

    }

}

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

@Around("invalidateAssign()")
public Object cacheInvalidateAssign(final ProceedingJoinPoint pjp) throws Throwable {
    final Object result = pjp.proceed();

    // This is injected caching.  If anything goes wrong in the caching, LOG the crap outta it,
    // but do not let it surface up past the AOP injection itself.
    try {/*from  ww  w  .  jav  a 2  s  . co m*/
        final Method methodToCache = getMethodToCache(pjp);
        final InvalidateAssignCache annotation = methodToCache.getAnnotation(InvalidateAssignCache.class);
        final AnnotationData annotationData = AnnotationDataBuilder.buildAnnotationData(annotation,
                InvalidateAssignCache.class, methodToCache);

        final String cacheKey = buildCacheKey(annotationData.getAssignedKey(), annotationData);
        if (cacheKey == null || cacheKey.trim().length() == 0) {
            throw new InvalidParameterException("Unable to find a cache key");
        }
        cache.delete(cacheKey);
    } catch (Throwable ex) {
        LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error.", ex);
    }
    return result;
}

From source file:org.sejda.model.pdf.transition.PdfPageTransition.java

/**
 * Creates a new {@link PdfPageTransition} instance.
 * //from   ww  w .  j ava 2  s  .  c  o m
 * @param style
 * @param transitionDuration
 * @param displayDuration
 * @return the newly created instance.
 * @throws InvalidParameterException
 *             if the input transition or display duration is not positive. if the input style is null.
 */
public static PdfPageTransition newInstance(PdfPageTransitionStyle style, int transitionDuration,
        int displayDuration) {

    if (transitionDuration < 1) {
        throw new InvalidParameterException("Input transition duration must be positive.");
    }
    if (displayDuration < 1) {
        throw new InvalidParameterException("Input display duration must be positive.");
    }
    if (style == null) {
        throw new InvalidParameterException("Input style cannot be null.");
    }
    return new PdfPageTransition(style, transitionDuration, displayDuration);
}