Example usage for java.util MissingResourceException MissingResourceException

List of usage examples for java.util MissingResourceException MissingResourceException

Introduction

In this page you can find the example usage for java.util MissingResourceException MissingResourceException.

Prototype

public MissingResourceException(String s, String className, String key) 

Source Link

Document

Constructs a MissingResourceException with the specified information.

Usage

From source file:com.microsoft.tfs.client.common.ui.webaccessintegration.javascript.JavascriptResourceLoader.java

public static String loadJavascriptFile(final String resourceID, final String charsetName) throws IOException {
    Check.notNull(resourceID, "resourceID"); //$NON-NLS-1$
    Check.notNull(charsetName, "charsetName"); //$NON-NLS-1$

    final InputStream stream = JavascriptResourceLoader.class.getResourceAsStream(resourceID);

    if (stream == null) {
        throw new MissingResourceException(MessageFormat.format("Could not load resource {0}", resourceID), //$NON-NLS-1$
                resourceID, ""); //$NON-NLS-1$
    }// w ww .j a v a  2s  .com

    /*
     * Read the resource as a string and return it.
     */
    try {
        try {
            return IOUtils.toString(stream, charsetName);
        } catch (final IOException e) {
            log.error("Error reading from stream", e); //$NON-NLS-1$
            throw e;
        }
    } finally {
        try {
            stream.close();
        } catch (final IOException e) {
            log.error("Error closing resource stream", e); //$NON-NLS-1$
        }
    }
}

From source file:org.pz.platypus.Platypus.java

/**
 * add the input file to the file list/*from  www . ja  va2 s .  co  m*/
 *
 * @param clArgs command line containing the name of the input file
 * @param gdd GDD containing the FileLits for this program
 */
static private void addInputFileToFileList(CommandLineArgs clArgs, GDD gdd) {
    final String inputFile = clArgs.lookup("inputFile");
    final FileList startingFileList = gdd.getInputFileList();
    try {
        startingFileList.addFilename(inputFile);
    } catch (FilenameLookupException fle) {
        // in theory, this cannot happen.
        throw new MissingResourceException(null, null, null);
    }
}

From source file:org.megam.api.Nodes.java

public <N> N list(String nodeName, String dummy) throws APIInvokeException {
    if (client == null) {
        throw new MissingResourceException("Make sure an APIClient is instantiated before you call Node.",
                "APIClient", "client");
    }// w  ww .  j a  v  a  2s .  c o  m
    try {
        String pass_parms_in_input_info = "";
        logger.debug("Node Entry <------->");
        String jsonString = client.execute("GET",
                client.builder(GET + "/" + nodeName, pass_parms_in_input_info));
        System.out.println(GET + "/" + nodeName);
        System.out.println(pass_parms_in_input_info);
        System.out.println(jsonString);
        return (N) new NodeResult(jsonString);
    } catch (APIContentException apce) {
        throw new APIInvokeException("", apce);
    }
}

From source file:be.vlaanderen.sesam.config.service.internal.ConfigurationServiceImpl.java

public void init() {
    if (rules == null) {
        throw new MissingResourceException("Need a set of rules", "List<Rule>", "(n/a)");
    }//ww w.j  av  a  2 s  .c om
    updateChangeConsumers();
}

From source file:org.megam.api.AppDefns.java

public <A> A list(String appdefns_id, String nodeName) throws APIInvokeException {
    try {//from w w w . ja  v  a  2s .  c o m
        logger.debug("AppDefns Entry <------->");
        if (client == null) {
            throw new MissingResourceException("Make sure an APIClient is instantiated before you call Node.",
                    "APIClient", "client");
        }
        String pass_parms_in_input_info = "";
        String jsonString = client.execute("GET",
                client.builder(GET + "/nodeName/" + appdefns_id, pass_parms_in_input_info));
        System.out.println(jsonString);
        return (A) new AppDefnResult(jsonString);
    } catch (APIContentException apce) {
        throw new APIInvokeException("", apce);
    }
}

From source file:org.megam.api.Requests.java

public <R> R post(NodeResult node) throws APIInvokeException {
    if (client == null) {
        throw new MissingResourceException("Make sure an APIClient is instantiated before you call Node.",
                "APIClient", "client");
    }/* w  ww .  jav  a 2  s . c  om*/
    try {
        AppDefnResult res = (AppDefnResult) new AppDefns(client).list((String) node.getJson().get("appdefnsid"),
                (String) node.getJson().get("node_name"));
        Gson gson = new Gson();
        RequestInfo req_info = gson.fromJson(res.json(), RequestInfo.class);
        String pass_parms_in_input_info = req_info.json();
        String jsonString = client.execute("POST", client.builder(POST, pass_parms_in_input_info));
        return (R) new RequestResult(jsonString);
    } catch (APIContentException apce) {
        throw new APIInvokeException("", apce);
    }
}

From source file:org.pz.platypus.Platypus.java

/**
 * tries to determine the prefix in the config file for the output plugin. (such as: pdf)
 * First checks the -format option on the command line. If it's not specified there,
 * checks the extension of the output file. Prefix is the lower-case version of the string,
 * and it is stored in the Gdd.//from   w  w w  . ja  va  2 s.  com
 *
 * @param ClArgs the command line args
 * @param Gdd the GDD
 * @throws MissingResourceException if the output file format cannot be determined.
 */
static public void findOutputFilePluginType(CommandLineArgs ClArgs, GDD Gdd) {
    String pluginType = ClArgs.lookup("format");
    if (pluginType == null || pluginType.isEmpty()) {

        final String outputFilename = ClArgs.lookup("outputFile");
        if (outputFilename == null || outputFilename.isEmpty()) {
            Gdd.getLogger().severe(Gdd.getLit("ERROR.UNKNOWN.OUTPUTFORMAT"));
            throw new MissingResourceException(null, null, null);
        }

        int i = outputFilename.lastIndexOf('.');
        if (i == -1 || outputFilename.endsWith(".")) {
            Gdd.getLogger().severe(Gdd.getLit("ERROR.UNKNOWN.OUTPUTFORMAT"));
            throw new MissingResourceException(null, null, null);
        }

        pluginType = outputFilename.substring(i + 1);
    }
    Gdd.setOutputPluginPrefix(pluginType.toLowerCase());
}

From source file:org.apache.fop.events.DefaultEventBroadcaster.java

/**
 * Loads an event model and returns its instance.
 * @param resourceBaseClass base class to use for loading resources
 * @return the newly loaded event model.
 *//*  w  ww  . ja  v a 2s  .  co  m*/
private static EventModel loadModel(Class resourceBaseClass) {
    String resourceName = "event-model.xml";
    InputStream in = resourceBaseClass.getResourceAsStream(resourceName);
    if (in == null) {
        throw new MissingResourceException("File " + resourceName + " not found",
                DefaultEventBroadcaster.class.getName(), "");
    }
    try {
        return EventModelParser.parse(new StreamSource(in));
    } catch (TransformerException e) {
        throw new MissingResourceException("Error reading " + resourceName + ": " + e.getMessage(),
                DefaultEventBroadcaster.class.getName(), "");
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:com.bigtobster.pgnextractalt.chess.ChessFilterer.java

/**
 * Executes the currently loaded filter//w ww . j av  a 2  s.c om
 *
 * @return The number of games filtered
 */
@SuppressWarnings({ "InstanceMethodNamingConvention", "FeatureEnvy" })
public int run() {
    if (this.filter == null) {
        throw new MissingResourceException("Missing filter", Filter.class.toString(),
                Filter.class.getSimpleName());
    }
    final int preGameCount = this.chessContext.getGames().size();
    this.chessContext.setGames(this.filter.filter(this.chessContext.getGames()));
    final int postGameCount = this.chessContext.getGames().size();
    return preGameCount - postGameCount;
}

From source file:org.apache.pdfbox.encoding.Encoding.java

/**
 * Loads a glyph list from a given location and populates the NAME_TO_CHARACTER hashmap
 * for character lookups./*from w  ww.ja  va 2  s  .c o  m*/
 * @param location - The string location of the glyphlist file
 */
private static void loadGlyphList(String location) {
    BufferedReader glyphStream = null;
    try {
        InputStream resource = ResourceLoader.loadResource(location);
        if (resource == null) {
            throw new MissingResourceException("Glyphlist not found: " + location, Encoding.class.getName(),
                    location);
        }
        glyphStream = new BufferedReader(new InputStreamReader(resource));
        String line = null;
        while ((line = glyphStream.readLine()) != null) {
            line = line.trim();
            //lines starting with # are comments which we can ignore.
            if (!line.startsWith("#")) {
                int semicolonIndex = line.indexOf(';');
                if (semicolonIndex >= 0) {
                    String unicodeValue = null;
                    try {
                        String characterName = line.substring(0, semicolonIndex);
                        unicodeValue = line.substring(semicolonIndex + 1, line.length());
                        StringTokenizer tokenizer = new StringTokenizer(unicodeValue, " ", false);
                        StringBuilder value = new StringBuilder();
                        while (tokenizer.hasMoreTokens()) {
                            int characterCode = Integer.parseInt(tokenizer.nextToken(), 16);
                            value.append((char) characterCode);
                        }
                        if (NAME_TO_CHARACTER.containsKey(characterName)) {
                            LOG.warn("duplicate value for characterName=" + characterName + "," + value);
                        } else {
                            NAME_TO_CHARACTER.put(characterName, value.toString());
                        }
                    } catch (NumberFormatException nfe) {
                        LOG.error("malformed unicode value " + unicodeValue, nfe);
                    }
                }
            }
        }
    } catch (IOException io) {
        LOG.error("error while reading the glyph list.", io);
    } finally {
        if (glyphStream != null) {
            try {
                glyphStream.close();
            } catch (IOException e) {
                LOG.error("error when closing the glyph list.", e);
            }

        }
    }
}