Example usage for java.util MissingResourceException getMessage

List of usage examples for java.util MissingResourceException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.sipfoundry.sipxconfig.setting.ModelMessageSource.java

/**
 * Handle MissignResourceException - base class logs scary looking error on the WARN level. We
 * actually OK with having this on INFO level, since not having a bundle for model is OK in
 * most cases.// w w w.j av a  2  s . c o m
 */
protected ResourceBundle doGetBundle(String basename, Locale locale) {
    try {
        return super.doGetBundle(basename, locale);
    } catch (MissingResourceException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("ResourceBundle [" + basename + "] not found for MessageSource: " + e.getMessage());
        }
        return null;
    }

}

From source file:org.displaytag.properties.TableProperties.java

/**
 * Loads user properties (displaytag.properties) according to the given locale. User properties are not guarantee to
 * exist, so the method can return <code>null</code> (no exception will be thrown).
 * @param locale requested Locale// w w  w .  j  ava  2s .  c o m
 * @return loaded properties
 */
private static ResourceBundle loadUserProperties(Locale locale) {
    ResourceBundle bundle = null;
    try {
        bundle = ResourceBundle.getBundle(LOCAL_PROPERTIES, locale);
    } catch (MissingResourceException e) {
        // if no resource bundle is found, try using the context classloader
        try {
            bundle = ResourceBundle.getBundle(LOCAL_PROPERTIES, locale,
                    Thread.currentThread().getContextClassLoader());
        } catch (MissingResourceException mre) {
            if (log.isDebugEnabled()) {
                log.debug(Messages.getString("TableProperties.propertiesnotfound", //$NON-NLS-1$
                        new Object[] { mre.getMessage() }));
            }
        }
    }

    return bundle;
}

From source file:com.autentia.tnt.bean.reports.ReportParameterDefinition.java

private String getTraslateValue(String value) {
    String traslateValue = "";
    try {/*from  w  ww.jav  a  2 s  . c om*/
        ResourceBundle resource = ResourceBundle.getBundle("com.autentia.tnt.resources.report",
                FacesUtils.getViewLocale());
        traslateValue = resource.getString(value.trim());
    } catch (MissingResourceException ex) {
        log.error(ex.getMessage());
    }
    return traslateValue;
}

From source file:org.artifactory.common.wicket.component.links.BaseTitledLink.java

@Override
public String getTitle() {
    try {//from   ww w .  j av a2 s  .  c  o m
        if (getDefaultModelObjectAsString() == null) {
            LOG.error(getClass().getSimpleName() + " title model is null, using id instead.");

            return "??" + getId() + "??";
        }

        return getDefaultModelObjectAsString();

    } catch (MissingResourceException e) {
        LOG.error(getClass().getSimpleName() + " can't find text resource, using id instead { " + e.getMessage()
                + " }.");

        return "??" + getId() + "??";
    }
}

From source file:org.alfresco.web.forms.xforms.Schema2XFormsProperties.java

public ResourceBundle getResourceBundle(final Form form, final Locale locale) {
    final LinkedList<ResourceBundle> bundles = new LinkedList<ResourceBundle>();
    for (String location : this.locations) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        location = location.replace("${form.name}",
                (NamespaceService.CONTENT_MODEL_PREFIX + ':' + form.getName()));
        if (location.startsWith("alfresco:")) {
            location = location.substring("alfresco:".length());
            loader = new ClassLoader(loader) {
                public InputStream getResourceAsStream(String name) {
                    LOGGER.debug("loading resource " + name);
                    final ResultSet results = searchService.query(Repository.getStoreRef(),
                            SearchService.LANGUAGE_LUCENE, "PATH:\"" + name + "\"");
                    try {
                        LOGGER.debug("search returned " + results.length() + " results");
                        if (results.length() == 1) {
                            final NodeRef nr = results.getNodeRef(0);
                            final ContentReader reader = contentService.getReader(nr,
                                    ContentModel.PROP_CONTENT);
                            return reader.getContentInputStream();
                        } else {
                            return super.getResourceAsStream(name);
                        }/*  w w  w.  ja  va  2 s . c o  m*/
                    } finally {
                        results.close();
                    }
                }
            };
        } else if (location.startsWith("classpath:")) {
            location = location.substring("classpath:".length());
        }

        LOGGER.debug("using loader " + loader + " for location " + location);
        try {
            final ResourceBundle rb = ResourceBundle.getBundle(location, locale, loader);
            LOGGER.debug("found bundle " + rb + " for location " + location);
            bundles.addFirst(rb);
        } catch (MissingResourceException mse) {
            LOGGER.debug("unable to located bundle at " + location + ": " + mse.getMessage());
        }
    }

    ResourceBundle result = null;
    for (ResourceBundle rb : bundles) {
        result = (result == null ? rb : new ResourceBundleWrapper(rb, result));
    }
    return result;
}

From source file:org.b3log.latke.service.LangPropsServiceImpl.java

@Override
public JSONObject getLabels(final Locale locale) {
    final JSONObject ret = new JSONObject();
    ResourceBundle langBundle;//from ww w  .  ja va 2  s.c  o m

    try {
        langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, locale);
    } catch (final MissingResourceException e) {
        LOGGER.log(Level.WARN, "{0}, using default locale[{1}]  instead",
                new Object[] { e.getMessage(), Latkes.getLocale() });

        langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, Latkes.getLocale());
    }

    final Enumeration<String> keys = langBundle.getKeys();
    final JSONArray labels = new JSONArray();

    ret.put(Label.LABELS, labels);

    while (keys.hasMoreElements()) {
        final JSONObject label = new JSONObject();
        final String key = keys.nextElement();

        label.put(Label.LABEL_ID, key);
        label.put(Label.LABEL_TEXT, langBundle.getString(key));

        labels.put(label);
    }

    return ret;
}

From source file:org.b3log.latke.service.LangPropsServiceImpl.java

@Override
public Map<String, String> getAll(final Locale locale) {
    Map<String, String> ret = LANGS.get(locale);

    if (null == ret) {
        ret = new HashMap<String, String>();
        ResourceBundle langBundle;

        try {/*from w  w w  .j  a  va 2s .  c o  m*/
            langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, locale);
        } catch (final MissingResourceException e) {
            LOGGER.log(Level.WARN, "{0}, using default locale[{1}] instead",
                    new Object[] { e.getMessage(), Latkes.getLocale() });

            try {
                langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, Latkes.getLocale());
            } catch (final MissingResourceException ex) {
                LOGGER.log(Level.WARN, "{0}, using default lang.properties instead",
                        new Object[] { e.getMessage() });
                langBundle = ResourceBundle.getBundle(Keys.LANGUAGE);
            }
        }

        final Enumeration<String> keys = langBundle.getKeys();

        while (keys.hasMoreElements()) {
            final String key = keys.nextElement();
            final String value = langBundle.getString(key);

            ret.put(key, value);
        }

        LANGS.put(locale, ret);
    }

    return ret;
}

From source file:org.b3log.latke.service.LangPropsService.java

/**
 * Gets all language properties as labels from lang_(by the specified
 * locale).properties file. If not found lang_(locale).properties
 * configurations, using {@link Latkes#getLocale()} instead.
 *
 * @param locale the specified locale/*from   www  .  j  av  a2s .c  o  m*/
 * @return for example,
 * <pre>
 * {
 *     "msgs": {
 *         "localeNotFound":
 *             "Unsupported locale, using default locale(zh_CN) instead."
 *     },
 *     "labels": [
 *         {"labelId": "projectName", "labelText": "B3log Web"},
 *         ....
 *     ]
 * }
 * </pre>
 */
public JSONObject getLabels(final Locale locale) {
    final JSONObject ret = new JSONObject();
    ResourceBundle langBundle;

    try {
        langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, locale);
    } catch (final MissingResourceException e) {
        LOGGER.log(Level.WARNING, "{0}, using default locale[{1}]  instead",
                new Object[] { e.getMessage(), Latkes.getLocale() });

        langBundle = ResourceBundle.getBundle(Keys.LANGUAGE, Latkes.getLocale());
    }

    final Enumeration<String> keys = langBundle.getKeys();
    final JSONArray labels = new JSONArray();

    ret.put(Label.LABELS, labels);

    while (keys.hasMoreElements()) {
        final JSONObject label = new JSONObject();
        final String key = keys.nextElement();

        label.put(Label.LABEL_ID, key);
        label.put(Label.LABEL_TEXT, langBundle.getString(key));

        labels.put(label);
    }

    return ret;
}

From source file:net.erdfelt.android.sdkfido.configer.Configer.java

public Configer(Object o) {
    this.obj = o;
    this.bub = BeanUtilsBean.getInstance();

    // Setup default persistent storage file
    this.persistFile = new File(RC_DIR, "config.properties");

    // Load descriptive definitions
    try {/* w  w w  .  j av a  2  s . c o m*/
        defsBundle = ResourceBundle.getBundle(o.getClass().getName());
        Enumeration<String> keys = defsBundle.getKeys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            if (key.startsWith("scope.")) {
                String scope = key.substring("scope.".length());
                scopes.add(scope);
            }
        }
    } catch (MissingResourceException e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
    }

    // Identify all of the configurable fields
    walkFields(null, o.getClass(), null);

    // Identify the method to use for accepting raw arguments
    findRawArgsMethod(o.getClass());
}

From source file:com.cws.esolutions.security.filters.SSLEnforcementFilter.java

public void init(final FilterConfig filterConfig) throws ServletException {
    final String methodName = SSLEnforcementFilter.CNAME
            + "#init(FilterConfig filterConfig) throws ServletException";

    if (DEBUG) {//from   ww  w.  j  ava  2s. c  o  m
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("FilterConfig: {}", filterConfig);
    }

    ResourceBundle rBundle = null;

    try {
        if (filterConfig.getInitParameter(SSLEnforcementFilter.FILTER_CONFIG_PARAM_NAME) == null) {
            ERROR_RECORDER.error("Filter configuration not found. Using default !");

            rBundle = ResourceBundle.getBundle(SSLEnforcementFilter.FILTER_CONFIG_FILE_NAME);
        } else {
            rBundle = ResourceBundle
                    .getBundle(filterConfig.getInitParameter(SSLEnforcementFilter.FILTER_CONFIG_PARAM_NAME));
        }

        this.ignoreHosts = (StringUtils.isNotEmpty(rBundle.getString(SSLEnforcementFilter.IGNORE_HOST_LIST)))
                ? rBundle.getString(SSLEnforcementFilter.IGNORE_HOST_LIST).trim().split(",")
                : null;
        this.ignoreURIs = (StringUtils.isNotEmpty(rBundle.getString(SSLEnforcementFilter.IGNORE_URI_LIST)))
                ? rBundle.getString(SSLEnforcementFilter.IGNORE_HOST_LIST).trim().split(",")
                : null;

        if (DEBUG) {
            if (this.ignoreHosts != null) {
                for (String str : this.ignoreHosts) {
                    DEBUGGER.debug(str);
                }
            }

            if (this.ignoreURIs != null) {
                for (String str : this.ignoreURIs) {
                    DEBUGGER.debug(str);
                }
            }
        }
    } catch (MissingResourceException mre) {
        ERROR_RECORDER.error(mre.getMessage(), mre);

        throw new UnavailableException(mre.getMessage());
    }
}