Example usage for java.security.spec InvalidParameterSpecException InvalidParameterSpecException

List of usage examples for java.security.spec InvalidParameterSpecException InvalidParameterSpecException

Introduction

In this page you can find the example usage for java.security.spec InvalidParameterSpecException InvalidParameterSpecException.

Prototype

public InvalidParameterSpecException(String msg) 

Source Link

Document

Constructs an InvalidParameterSpecException with the specified detail message.

Usage

From source file:Main.java

/**
 * Builds map from list of strings//from w  w  w.ja  v a 2  s  . c om
 *
 * @param args key-value pairs for build a map. Must be a multiple of 2
 * @return Result map. If args not multiple of 2, last argument will be ignored
 */
public static Map<String, Object> mapFrom(Object... args) {
    if (args.length % 2 != 0) {
        Log.w("VKUtil", "Params must be paired. Last one is ignored");
    }
    LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(args.length / 2);
    for (int i = 0; i + 1 < args.length; i += 2) {
        if (!(args[i] instanceof String))
            Log.e("VK SDK", "Error while using mapFrom",
                    new InvalidParameterSpecException("Key must be string"));
        result.put((String) args[i], args[i + 1]);
    }
    return result;
}

From source file:org.moe.cli.manager.PrebuildCocoaPodsManager.java

private void executePrepareCommands(File zipRoot, String prepareCommand)
        throws InvalidParameterSpecException, IOException, InterruptedException {
    File root = zipRoot;//w  w w  . j a  v  a2  s  . c  o  m
    File[] children = zipRoot.listFiles();
    if (children.length == 1 && !children[0].getName().endsWith(".framework")) {
        root = new File(zipRoot, children[0].getName());
    } else if (children.length == 2) {
        if (children[0].getName().equals("__MACOSX")) {
            root = new File(zipRoot, children[1].getName());
        } else if (children[1].getName().equals("__MACOSX")) {
            root = new File(zipRoot, children[2].getName());
        }
    }
    if (root != null && root.exists()) {
        String[] commandArray = prepareCommand.split("\n");
        for (String command : commandArray) {
            String[] cmd = { "/bin/sh", "-c", command.replace("\n", "") };

            Process process = Runtime.getRuntime().exec(cmd, null, root);
            process.waitFor();

            if (process.exitValue() != 0) {
                throw new InvalidParameterSpecException(
                        "An error occured during execution of preparation commands");
            }
        }
    }
}