List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static final ResourceBundle getBundle(String baseName)
From source file:au.org.ala.delta.model.format.AttributeFormatter.java
private void initCaptions() { ResourceBundle bundle = ResourceBundle.getBundle("au/org/ala/delta/resources/delta-common"); _orMoreCaption = bundle.getString("AttributeFormatter.OrMore"); _orLessCaption = bundle.getString("AttributeFormatter.OrLess"); _notRecordedCaption = bundle.getString("AttributeFormatter.NotRecorded"); _notApplicableCaption = bundle.getString("AttributeFormatter.NotApplicable"); _orWord = bundle.getString("AttributeFormatter.DefaultOrWord"); }
From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.scan("com.dominion.salud.nomenclator.configuration"); ctx.setServletContext(servletContext); ctx.refresh();//from w w w . jav a2 s .c o m logger.info(" Registrando servlets de configuracion"); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dispatcher.setInitParameter("contextClass", ctx.getClass().getName()); dispatcher.setLoadOnStartup(1); logger.info(" Agregando mapping: /"); dispatcher.addMapping("/"); logger.info(" Agregando mapping: /controller/*"); dispatcher.addMapping("/controller/*"); logger.info(" Agregando mapping: /services/*"); dispatcher.addMapping("/services/*"); servletContext.addListener(new ContextLoaderListener(ctx)); logger.info(" Servlets de configuracion registrados correctamente"); // Configuracion general logger.info(" Iniciando la configuracion del modulo"); NOMENCLATORConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator) ? servletContext.getRealPath("/") : servletContext.getRealPath("/") + File.separator; NOMENCLATORConstantes._TEMP = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "temp" + File.separator; NOMENCLATORConstantes._VERSION = ResourceBundle.getBundle("version").getString("version"); NOMENCLATORConstantes._LOGS = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs"; NOMENCLATORConstantes._CONTEXT_NAME = servletContext.getServletContextName(); NOMENCLATORConstantes._CONTEXT_PATH = servletContext.getContextPath(); NOMENCLATORConstantes._CONTEXT_SERVER = servletContext.getServerInfo(); NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("nomenclator.enable.technical.information")) ? Boolean.parseBoolean(ResourceBundle.getBundle("application") .getString("nomenclator.enable.technical.information")) : false; PropertyConfigurator.configureAndWatch("log4j"); logger.info(" Configuracion general del sistema"); logger.info(" nomenclator.home: " + NOMENCLATORConstantes._HOME); logger.info(" nomenclator.temp: " + NOMENCLATORConstantes._TEMP); logger.info(" nomenclator.version: " + NOMENCLATORConstantes._VERSION); logger.info(" nomenclator.logs: " + NOMENCLATORConstantes._LOGS); logger.info(" nomenclator.context.name: " + NOMENCLATORConstantes._CONTEXT_NAME); logger.info(" nomenclator.context.path: " + NOMENCLATORConstantes._CONTEXT_PATH); logger.info(" nomenclator.context.server: " + NOMENCLATORConstantes._CONTEXT_SERVER); logger.info(" Parametrizacion del sistema"); logger.info(" nomenclator.enable.technical.information: " + NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION); logger.info(" Modulo configurado correctamente"); logger.info("MODULO INICIADO CORRECTAMENTE"); }
From source file:com.streamreduce.datasource.BootstrapDatabaseDataPopulator.java
private void bootstrapSystemInfo() { ResourceBundle resourceBundle = ResourceBundle.getBundle("application"); SystemInfo systemStatus = systemStatusDAO.getLatest(); if (systemStatus == null) { systemStatus = new SystemInfo(); }/*from w ww . java 2s. com*/ systemStatus.setAppVersion(resourceBundle.getString("nodeable.version")); systemStatus.setBuildNumber(resourceBundle.getString("nodeable.build")); systemStatusDAO.save(systemStatus); }
From source file:de.ingrid.external.gemet.GEMETService.java
public void init() throws Exception { ResourceBundle gemetProps = ResourceBundle.getBundle("gemet"); this.doRDF = Boolean.parseBoolean(gemetProps.getString("service.request.rdf")); this.analyzeMaxWords = Integer.parseInt(gemetProps.getString("service.analyzeMaxWords")); this.ignorePassedMatchingType = Boolean .parseBoolean(gemetProps.getString("service.ignorePassedMatchingType")); try {//w w w .j a v a 2s. c o m this.alternateLanguage = gemetProps.getString("service.alternateLanguage"); } catch (Exception ex) { // catch missing property etc., we set to null if problems if (log.isDebugEnabled()) { log.debug("Problems reading 'service.alternateLanguage' from gemet.properties, we set to null."); } this.alternateLanguage = null; } finally { // set to null if empty string to indicate no alternate language ! if (this.alternateLanguage != null && this.alternateLanguage.length() == 0) this.alternateLanguage = null; } this.gemetClient = new GEMETClient(gemetProps); this.gemetMapper = new GEMETMapper(); }
From source file:cz.muni.fi.pv168.MainForm.java
private DataSource prepareDataSource() { /*//from w ww . j a va 2 s . com * BasicDataSource ds = new BasicDataSource(); Properties properties = * new Properties(); FileInputStream in = null; try { in = new * FileInputStream("database.properties"); } catch * (FileNotFoundException ex) { * Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, "File * Not Found", ex); } try { properties.load(in); } catch (IOException * ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, * "Can Not Read Properties File", ex); } String drivers = * properties.getProperty("jdbc.drivers"); if (null == drivers) { * System.setProperty("jdbs.drivers", drivers); } String url = * properties.getProperty("jdbc.url"); String username = * properties.getProperty("jdbc.username"); String password = * properties.getProperty("jdbc.password"); ds.setUrl(url); * ds.setUsername(username); ds.setPassword(password); return ds; */ ResourceBundle databaseProperties = ResourceBundle.getBundle("cz.muni.fi.pv168.database"); String url = databaseProperties.getString("jdbc.url"); String username = databaseProperties.getString("jdbc.username"); String password = databaseProperties.getString("jdbc.password"); BasicDataSource ds = new BasicDataSource(); ds.setUrl(url); ds.setUsername(username); ds.setPassword(password); try { DBUtils.tryCreateTables(ds); } catch (SQLException ex) { JOptionPane.showMessageDialog(jMenu1, localization.getString("db_connection_failure"), localization.getString("error"), JOptionPane.ERROR_MESSAGE); } carManager.setDataSource(ds); customerManager.setDataSource(ds); rentManager.setDataSource(ds); return ds; }
From source file:com.google.code.pentahoflashcharts.charts.PentahoOFC4JChartHelper.java
@SuppressWarnings("unchecked") private static Map createChartFactoryMap() { Properties chartFactories = new Properties(); // First, get known chart factories... try {/*w ww.j av a 2s . c o m*/ ResourceBundle pluginBundle = ResourceBundle.getBundle(PLUGIN_BUNDLE_NAME); if (pluginBundle != null) { // Copy the bundle here... Enumeration keyEnum = pluginBundle.getKeys(); String bundleKey = null; while (keyEnum.hasMoreElements()) { bundleKey = (String) keyEnum.nextElement(); chartFactories.put(bundleKey, pluginBundle.getString(bundleKey)); } } } catch (Exception ex) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_NO_CHART_FACTORY_PROPERTIES_BUNDLE")); //$NON-NLS-1$ } // Get overrides... // // Note - If the override wants to remove an existing "known" plugin, // simply adding an empty value will cause the "known" plugin to be removed. // if (PentahoSystem.getObjectFactory() == null || !PentahoSystem.getObjectFactory().objectDefined(ISolutionRepository.class.getSimpleName())) { // this is ok return chartFactories; } ISolutionRepository solutionRepository = PentahoSystem.get(ISolutionRepository.class, new StandaloneSession("system")); //$NON-NLS-1$ try { if (solutionRepository.resourceExists(SOLUTION_PROPS)) { InputStream is = solutionRepository.getResourceInputStream(SOLUTION_PROPS, false); Properties overrideChartFactories = new Properties(); overrideChartFactories.load(is); chartFactories.putAll(overrideChartFactories); // load over the top of the known properties } } catch (FileNotFoundException ignored) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_NO_CHART_FACTORY_PROPERTIES")); //$NON-NLS-1$ } catch (IOException ignored) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_BAD_CHART_FACTORY_PROPERTIES"), ignored); //$NON-NLS-1$ } return chartFactories; }
From source file:es.mityc.firmaJava.libreria.utilidades.CopiaFicherosManager.java
/** * Constructor/*from w w w. ja va2s. com*/ */ public CopiaFicherosManager() { try { props = ResourceBundle.getBundle(STR_RESCOPFIL); } catch (MissingResourceException ex) { log.error(I18n.getResource(ConstantesXADES.LIBRERIAXADES_FIRMAMOZILLA_ERROR_16), ex); } }
From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditor.java
/** * Creates a new editor.//from w ww . ja v a 2 s .c o m * * @param shell2 the display. * @param chart2edit the chart to edit. */ public SWTChartEditor(Shell shell2, JFreeChart chart2edit) { this.shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM); this.shell.setSize(400, 500); this.chart = chart2edit; this.shell.setText( ResourceBundle.getBundle("org.jfree.chart.LocalizationBundle").getString("Chart_Properties")); GridLayout layout = new GridLayout(2, true); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; this.shell.setLayout(layout); Composite main = new Composite(this.shell, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + localizationResources.getString("Title") + " "); this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle()); item1.setControl(this.titleEditor); // build second tab TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + localizationResources.getString("Plot") + " "); this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot()); item2.setControl(this.plotEditor); // build the third tab TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + localizationResources.getString("Other") + " "); this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); item3.setControl(this.otherEditor); // ok and cancel buttons Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); ok.setText(" Ok "); ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateChart(SWTChartEditor.this.chart); SWTChartEditor.this.shell.dispose(); } }); Button cancel = new Button(this.shell, SWT.PUSH); cancel.setText(" Cancel "); cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { SWTChartEditor.this.shell.dispose(); } }); }
From source file:it.infn.ct.security.utilities.LDAPUtils.java
public static LDAPUser findUserByMail(String mail) { NamingEnumeration results = null; DirContext ctx = null;/*from w w w. j a v a 2 s . c o m*/ LDAPUser user = null; try { ctx = getContext(); SearchControls controls = new SearchControls(); String retAttrs[] = { "cn" }; controls.setReturningAttributes(retAttrs); controls.setSearchScope(SearchControls.SUBTREE_SCOPE); ResourceBundle rb = ResourceBundle.getBundle("ldap"); results = ctx.search(rb.getString("peopleRoot"), "(mail=" + mail + ")", controls); if (results.hasMore()) { SearchResult searchResult = (SearchResult) results.next(); Attributes attributes = searchResult.getAttributes(); user = new LDAPUser(); if (attributes.get("cn") != null) user = getUser((String) attributes.get("cn").get()); } } catch (NameNotFoundException ex) { _log.error(ex); } catch (NamingException e) { _log.error(e); } finally { if (results != null) { try { results.close(); } catch (Exception e) { // Never mind this. } } if (ctx != null) { try { ctx.close(); } catch (Exception e) { // Never mind this. } } } return user; }
From source file:com.thejustdo.servlet.CargaMasivaServlet.java
/** * Processes requests for both HTTP//from w w w. j a va 2 s.com * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.info(String.format("Welcome to the MULTI-PART!!!")); ResourceBundle messages = ResourceBundle.getBundle("com.thejustdo.resources.messages"); // 0. If no user logged, nothing can be done. if (!SecureValidator.checkUserLogged(request, response)) { return; } // 1. Check that we have a file upload request. boolean isMultipart = ServletFileUpload.isMultipartContent(request); log.info(String.format("Is multipart?: %s", isMultipart)); // 2. Getting all the parameters. String social_reason = request.getParameter("razon_social"); String nit = request.getParameter("nit"); String name = request.getParameter("name"); String phone = request.getParameter("phone"); String email = request.getParameter("email"); String office = (String) request.getSession().getAttribute("actualOffice"); String open_amount = (String) request.getParameter("valor_tarjeta"); String open_user = (String) request.getSession().getAttribute("actualUser"); List<String> errors = new ArrayList<String>(); // 6. Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // 7. Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = this.getServletConfig().getServletContext(); File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); log.info(String.format("Temporal repository: %s", repository.getAbsolutePath())); factory.setRepository(repository); // 8. Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); try { utx.begin(); EntityManager em = emf.createEntityManager(); // Parse the request List<FileItem> items = upload.parseRequest(request); // 8.0 A set of generated box codes must be maintained. Map<String, String> matrix = new HashMap<String, String>(); // ADDED: Validation 'o file extension. String filename = null; // Runing through the parameters. for (FileItem fi : items) { if (fi.isFormField()) { if ("razon_social".equalsIgnoreCase(fi.getFieldName())) { social_reason = fi.getString(); continue; } if ("nit".equalsIgnoreCase(fi.getFieldName())) { nit = fi.getString(); continue; } if ("name".equalsIgnoreCase(fi.getFieldName())) { name = fi.getString(); continue; } if ("phone".equalsIgnoreCase(fi.getFieldName())) { phone = fi.getString(); continue; } if ("email".equalsIgnoreCase(fi.getFieldName())) { email = fi.getString(); continue; } if ("valor_tarjeta".equalsIgnoreCase(fi.getFieldName())) { open_amount = fi.getString(); continue; } } else { filename = fi.getName(); } } // 3. If we got no file, then a error is generated and re-directed to the exact same page. if (!isMultipart) { errors.add(messages.getString("error.massive.no_file")); log.log(Level.SEVERE, errors.toString()); } // 4. If any of the others paramaeters are missing, then a error must be issued. if ((social_reason == null) || ("".equalsIgnoreCase(social_reason.trim()))) { errors.add(messages.getString("error.massive.no_social_reason")); log.log(Level.SEVERE, errors.toString()); } if ((nit == null) || ("".equalsIgnoreCase(nit.trim()))) { errors.add(messages.getString("error.massive.no_nit")); log.log(Level.SEVERE, errors.toString()); } if ((name == null) || ("".equalsIgnoreCase(name.trim()))) { errors.add(messages.getString("error.massive.no_name")); log.log(Level.SEVERE, errors.toString()); } if ((phone == null) || ("".equalsIgnoreCase(phone.trim()))) { errors.add(messages.getString("error.massive.no_phone")); log.log(Level.SEVERE, errors.toString()); } if ((email == null) || ("".equalsIgnoreCase(email.trim()))) { errors.add(messages.getString("error.massive.no_email")); log.log(Level.SEVERE, errors.toString()); } // If no filename or incorrect extension. if ((filename == null) || (!(filename.endsWith(Constants.MASSIVE_EXT.toLowerCase(Locale.FRENCH))) && !(filename.endsWith(Constants.MASSIVE_EXT.toUpperCase())))) { errors.add(messages.getString("error.massive.invalid_ext")); log.log(Level.SEVERE, errors.toString()); } // 5. If any errors found, we must break the flow. if (errors.size() > 0) { request.setAttribute(Constants.ERROR, errors); //Redirect the response request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } for (FileItem fi : items) { if (!fi.isFormField()) { // 8.1 Processing the file and building the Beneficiaries. List<Beneficiary> beneficiaries = processFile(fi); log.info(String.format("Beneficiaries built: %d", beneficiaries.size())); // 8.2 If any beneficiaries, then an error is generated. if ((beneficiaries == null) || (beneficiaries.size() < 0)) { errors.add(messages.getString("error.massive.empty_file")); log.log(Level.SEVERE, errors.toString()); request.setAttribute(Constants.ERROR, errors); //Redirect the response request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } // 8.3 Building main parts. Buyer b = buildGeneralBuyer(em, social_reason, nit, name, phone, email); // 8.3.1 The DreamBox has to be re-newed per beneficiary. DreamBox db; for (Beneficiary _b : beneficiaries) { // 8.3.2 Completing each beneficiary. log.info(String.format("Completying the beneficiary: %d", _b.getIdNumber())); db = buildDreamBox(em, b, office, open_amount, open_user); matrix.put(db.getNumber() + "", _b.getGivenNames() + " " + _b.getLastName()); _b.setOwner(b); _b.setBox(db); em.merge(_b); } } } // 8.4 Commiting to persistence layer. utx.commit(); // 8.5 Re-directing to the right jsp. request.getSession().setAttribute("boxes", matrix); request.getSession().setAttribute("boxamount", open_amount + ""); //Redirect the response generateZIP(request, response); } catch (Exception ex) { errors.add(messages.getString("error.massive.couldnot_process")); log.log(Level.SEVERE, errors.toString()); request.setAttribute(Constants.ERROR, errors); request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } }