List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static final ResourceBundle getBundle(String baseName)
From source file:org.skyinn.quasar.struts.action.BaseAction.java
/** * @see org.apache.struts.actions.LookupDispatchAction#getKeyMethodMap() */// www . j a v a 2 s . c o m protected Map getKeyMethodMap() { Map map = new HashMap(); String pkg = this.getClass().getPackage().getName(); ResourceBundle methods = ResourceBundle.getBundle(pkg + ".LookupMethods"); Enumeration keys = methods.getKeys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); map.put(key, methods.getString(key)); } return map; }
From source file:edu.ucsb.nceas.metacat.lsid.LSIDDataLookup.java
public InputStream lsidData(LSID lsid) throws LSIDServerException { String ns = lsid.getNamespace(); String id = lsid.getObject(); String ver = lsid.getRevision(); InputStream docStream = null; // example metacat query // http://metacat.nceas.ucsb.edu/knb/metacat?action=read&qformat=xml&docid=knb-lter-gce.109.6 ////w ww . j av a 2 s. com ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid"); String theServer = rb.getString("metacatserver"); logger.debug("the server is " + theServer); String url = theServer + "?action=read&qformat=xml&docid="; url = url + ns + "." + id + "." + ver; try { URL theDoc = new URL(url); docStream = theDoc.openStream(); } catch (MalformedURLException mue) { logger.error("MalformedURLException in LSIDDataLookup: " + mue); mue.printStackTrace(); } catch (IOException ioe) { logger.error("IOException in LSIDDataLookup: " + ioe); ioe.printStackTrace(); } return docStream; }
From source file:msearch.tool.MSFunktionen.java
public static String getCompileDate() { final ResourceBundle rb; String propToken = "DATE"; String msg = ""; try {/*from ww w . j a v a 2 s . c o m*/ ResourceBundle.clearCache(); rb = ResourceBundle.getBundle("version"); msg = rb.getString(propToken); } catch (Exception e) { MSLog.fehlerMeldung(807293847, MSLog.FEHLER_ART_PROG, MSFunktionen.class.getName(), e); } return msg; }
From source file:com.gisgraphy.domain.repository.AbstractTransactionalTestCase.java
/** * Default constructor - populates "rb" variable if properties file exists * for the class in src/test/resources. set autoWire=AUTOWIRE_BY_NAME; *///w ww . java 2 s . com public AbstractTransactionalTestCase() { super(); this.setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME); // Since a ResourceBundle is not required for each class, just // do a simple check to see if one exists String className = this.getClass().getName(); try { rb = ResourceBundle.getBundle(className); } catch (MissingResourceException mre) { // logger.info("No resource bundle found for: " + className); } }
From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java
public ApplicationContext() { mainStackPane = new StackPane(); mainPane = new BorderPane(); mainPane.setId("background");//important for css mainStackPane.getChildren().add(mainPane); messageProvider = new MessageProvider(ResourceBundle.getBundle("de.scoopgmbh.copper.gui.message")); final Preferences prefs = Preferences.userRoot().node("de.scoopgmbh.coppermonitor"); SettingsModel defaultSettings = new SettingsModel(); AuditralColorMapping newItem = new AuditralColorMapping(); newItem.color.setValue(Color.rgb(255, 128, 128)); newItem.loglevelRegEx.setValue("1"); defaultSettings.auditralColorMappings.add(newItem); byte[] defaultModelbytes; ByteArrayOutputStream os = null; try {/*from w ww .jav a2 s.c om*/ os = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(os); o.writeObject(defaultSettings); defaultModelbytes = os.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new RuntimeException(e); } } } settingsModelSingleton = defaultSettings; ByteArrayInputStream is = null; try { is = new ByteArrayInputStream(prefs.getByteArray(SETTINGS_KEY, defaultModelbytes)); ObjectInputStream o = new ObjectInputStream(is); Object object = o.readObject(); if (object instanceof SettingsModel) { settingsModelSingleton = (SettingsModel) object; } } catch (Exception e) { logger.error("", e); getIssueReporterSingleton() .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { throw new RuntimeException(e); } } } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { ByteArrayOutputStream os = null; try { os = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(os); o.writeObject(settingsModelSingleton); prefs.putByteArray(SETTINGS_KEY, os.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new RuntimeException(e); } } } } })); }
From source file:edu.harvard.iq.dataverse.DatasetFieldValue.java
public String getDisplayValue() { String retVal = ""; if (!StringUtils.isBlank(this.getValue()) && !DatasetField.NA_VALUE.equals(this.getValue())) { String format = this.datasetField.getDatasetFieldType().getDisplayFormat(); if (StringUtils.isBlank(format)) { format = "#VALUE"; }//from w ww. jav a 2 s . c o m String sanitizedValue = !this.datasetField.getDatasetFieldType().isSanitizeHtml() ? this.getValue() : MarkupChecker.sanitizeBasicHTML(this.getValue()); if (!this.datasetField.getDatasetFieldType().isSanitizeHtml() && this.datasetField.getDatasetFieldType().isEscapeOutputText()) { sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue); } // replace the special values in the format (note: we replace #VALUE last since we don't // want any issues if the value itself has #NAME in it) String displayValue = format .replace("#NAME", this.datasetField.getDatasetFieldType().getTitle() == null ? "" : this.datasetField.getDatasetFieldType().getTitle()) .replace("#EMAIL", ResourceBundle.getBundle("Bundle").getString("dataset.email.hiddenMessage")) .replace("#VALUE", sanitizedValue); retVal = displayValue; } return retVal; }
From source file:com.github.lindenb.jvarkit.util.command.Command.java
public Command() { try {//from w ww . ja v a 2 s .com this.messagesBundle = ResourceBundle.getBundle("messages"); } catch (Exception e) { LOG.warn("Cannot get messages bundle ", e); } /** set locale http://seqanswers.com/forums/showthread.php?p=174020#post174020 */ Locale.setDefault(Locale.US); System.setProperty("file.encoding", "UTF-8"); }
From source file:com.thomaskuenneth.openweathermapweather.WeatherUtils.java
private static String getAPIKey() { ResourceBundle bundle = ResourceBundle.getBundle("com.thomaskuenneth.openweathermapweather.api_key"); return bundle.getString("api_key"); }
From source file:com.github.jrh3k5.flume.mojo.plugin.AbstractFlumePluginMojoITest.java
/** * Set the {@code $maven.home} value in the system properties for the {@link BuildTool} object. * // www. j a v a 2 s. c o m * @throws Exception * If any errors occur during the setup. */ @Before public void setUpMavenHome() throws Exception { final ResourceBundle systemPropsBundle = ResourceBundle.getBundle("system"); final String mavenHome = systemPropsBundle.getString("maven.home"); if (mavenHome == null) { throw new IllegalStateException("maven.home is null; did the resources not filter correctly?"); } if (!new File(mavenHome).exists()) { throw new IllegalStateException(String.format("Configured maven.home '%s' does not exist.", mavenHome)); } System.setProperty("maven.home", mavenHome); }
From source file:com.persistent.cloudninja.utils.RoleBasedAccessControlInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { logger.info("Before handling the request"); boolean isRequestURLAccessAllowed = false; String cookieName = CloudNinjaConstants.AUTH_COOKIE_NAME; String userRole = "ROLE_USER"; String tenantId = "dummyTenantID"; String requestURI = ""; String path = ""; Cookie reqCookie = getCookie(request, cookieName); if (reqCookie != null) { tenantId = AuthFilterUtils.getFieldValueFromCookie(reqCookie, CloudNinjaConstants.COOKIE_TENANTID_PREFIX); userRole = AuthFilterUtils.getRoleFromCookie(reqCookie, CloudNinjaConstants.COOKIE_AUTHORITIES_PREFIX) .trim();/* w ww .j av a2 s . co m*/ requestURI = request.getRequestURI(); } if ("ROLE_USER".equalsIgnoreCase(userRole)) { path = getRequestURIMappingPath(requestURI, tenantId); if (userurls.containsValue(path)) { isRequestURLAccessAllowed = true; } } else if ("ROLE_ADMINISTRATOR".equalsIgnoreCase(userRole)) { path = getRequestURIMappingPath(requestURI, tenantId); if (adminurls.containsValue(path)) { isRequestURLAccessAllowed = true; } } if (isRequestURLAccessAllowed) { return super.preHandle(request, response, handler); } else { try { rsBundle = ResourceBundle.getBundle("acs"); String accessDeniedPage = rsBundle.getString("tenant.dashboard.accessdenied.page.url").trim(); String redirectUrl = request.getContextPath().concat("/").concat(tenantId).concat(accessDeniedPage); response.sendRedirect(redirectUrl); } catch (IOException e) { e.printStackTrace(); } isRequestURLAccessAllowed = true; return false; } }