List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:br.bireme.web.AuthenticationServlet.java
/** * Processes requests for both HTTP/*from w ww. j av a 2 s.c om*/ * <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(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding(CODEC); final String username = request.getParameter("email"); final String password = request.getParameter("password"); final String lang = request.getParameter("lang"); final ServletContext context = getServletContext(); final HttpSession session = request.getSession(); final ResourceBundle messages = Tools.getMessages(lang); boolean isAccountsWorking = true; RequestDispatcher dispatcher; session.removeAttribute("collCenter"); session.removeAttribute("user"); if (isAccountsWorking) { if ((username == null) || (username.isEmpty()) || (password == null) || (password.isEmpty())) { response.sendRedirect( "index.jsp?lang=" + lang + "&errMsg=" + messages.getString("login_is_required")); return; } try { final Authentication auth = new Authentication(context.getInitParameter("accounts_host")); final JSONObject user = auth.getUser(username, password); Set<String> centerIds = auth.getCenterIds(user); //if (auth.isAuthenticated(user) && (centerIds != null)) { if (auth.isAuthenticated(user)) { if (centerIds == null) { centerIds = new HashSet<String>(); } centerIds.add(auth.getColCenter(user)); // cc may not belong to a net (it not appear in centerIds) session.setAttribute("user", username); // Login user. session.setAttribute("centerIds", centerIds); dispatcher = context.getRequestDispatcher("/CenterFilterServlet?lang=" + lang); } else { session.removeAttribute("user"); session.removeAttribute("centerIds"); dispatcher = context.getRequestDispatcher( "/index.jsp?lang=" + lang + "&errMsg=" + messages.getString("authentication_failed")); } dispatcher.forward(request, response); } catch (Exception ex) { dispatcher = context.getRequestDispatcher("/index.jsp?lang=" + lang + "&errMsg=" + messages.getString("exception_found") + "<br/><br/>" + ex.getMessage()); dispatcher.forward(request, response); } } else { final Set<String> ccs = new HashSet<String>(); ccs.add("PE1.1"); ccs.add("BR1.1"); dispatcher = context.getRequestDispatcher("/CenterFilterServlet?lang=" + lang); session.setAttribute("user", username); // Login user. session.setAttribute("centerIds", ccs); dispatcher.forward(request, response); } }
From source file:ispok.pres.bb.NewVisitor.java
public String complete() { FacesContext fc = FacesContext.getCurrentInstance(); Locale locale = fc.getViewRoot().getLocale(); ResourceBundle rb = ResourceBundle.getBundle("ispok/pres/inter/ispok", locale); fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, rb.getString("visitor_added"), firstName + " " + lastName)); clear();// w w w . j av a 2 s. c o m return "/admin/management/visitors/visitors.xhtml"; }
From source file:edu.toronto.cs.phenotips.measurements.internal.DefaultMeasurementsChartConfigurationsFactory.java
@Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); }//from w w w .java2s . c om String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<MeasurementsChartConfiguration>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; }
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 {/*from w w w .j ava2 s . com*/ 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:es.pode.administracion.presentacion.planificador.eliminarTarea.EliminarTareasControllerImpl.java
public void eliminarTareasAdm(ActionMapping mapping, EliminarTareasAdmForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { TrabajoVO[] trabajos = null;/* w w w . ja va 2 s.c o m*/ Boolean resultado; String resultadoString = null; String mensaje = null; //String listaTrabajo = request.getParameter("listaTrabajo"); String[] nombresTrabajoArray = form.getListaTrabajoPlana().split("#"); ResourceBundle ficheroRecursos = null; try { Locale locale = request.getLocale(); ficheroRecursos = this.getFicheroRecursos(locale); trabajos = new TrabajoVO[nombresTrabajoArray.length]; for (int i = 0; i < nombresTrabajoArray.length; i++) { trabajos[i] = new TrabajoVO(); trabajos[i].setTrabajo(nombresTrabajoArray[i]); } resultado = this.getSrvPlanificadorService().eliminarTareasAdm(trabajos); if (resultado.booleanValue() == true) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasOk"); resultadoString = ficheroRecursos.getString("tareas.OK"); } else if (resultado.booleanValue() == false) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasError"); resultadoString = ficheroRecursos.getString("tareas.ERROR"); } form.setDescripcionBaja(mensaje); form.setResultado(resultadoString); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.fileprofile.FileProfileMainHandler.java
/** * Before being able to create a File Profile, certain objects must exist. * Check that here.//from w ww . j a va 2s. c om */ private void checkPreReqData(HttpServletRequest p_request, HttpSession p_session, Hashtable p_l10nProfilePairs) throws EnvoyServletException { if (p_l10nProfilePairs == null || p_l10nProfilePairs.size() < 1) { ResourceBundle bundle = getBundle(p_session); StringBuffer message = new StringBuffer(); message.append(bundle.getString("msg_prereq_warning_1")); message.append(": "); message.append(bundle.getString("lb_loc_profile")); message.append(". "); message.append(bundle.getString("msg_prereq_warning_2")); p_request.setAttribute("preReqData", message.toString()); } }
From source file:com.igormaznitsa.nbmindmap.nb.swing.PlainTextEditor.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.// ww w.ja v a 2 s . com */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { mainToolBar = new javax.swing.JToolBar(); buttonLoad = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); buttonCopy = new javax.swing.JButton(); buttonPaste = new javax.swing.JButton(); buttonClearAll = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); labelCursorPos = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); labelWrapMode = new javax.swing.JLabel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(16, 0), new java.awt.Dimension(16, 0), new java.awt.Dimension(16, 32767)); setLayout(new java.awt.BorderLayout()); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); buttonLoad.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/disk16.png"))); // NOI18N java.util.ResourceBundle bundle = java.util.ResourceBundle .getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle"); // NOI18N buttonLoad.setText(bundle.getString("PlainTextEditor.buttonImport")); // NOI18N buttonLoad.setToolTipText(bundle.getString("PlainTextEditor.buttonLoad.toolTipText")); // NOI18N buttonLoad.setFocusable(false); buttonLoad.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonLoad.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonLoadActionPerformed(evt); } }); mainToolBar.add(buttonLoad); buttonSave.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/file_save16.png"))); // NOI18N buttonSave.setText(bundle.getString("PlaintextEditor.buttonExport")); // NOI18N buttonSave.setToolTipText(bundle.getString("PlainTextEditor.buttonSave.toolTipText")); // NOI18N buttonSave.setFocusable(false); buttonSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonSaveActionPerformed(evt); } }); mainToolBar.add(buttonSave); buttonCopy.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/page_copy16.png"))); // NOI18N buttonCopy.setText(bundle.getString("PlainTextEditor.buttonCopy.text")); // NOI18N buttonCopy.setToolTipText(bundle.getString("PlainTextEditor.buttonCopy.toolTipText")); // NOI18N buttonCopy.setFocusable(false); buttonCopy.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonCopy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonCopy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonCopyActionPerformed(evt); } }); mainToolBar.add(buttonCopy); buttonPaste.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/paste_plain16.png"))); // NOI18N buttonPaste.setText(bundle.getString("PlainTextEditor.buttonPaste.text")); // NOI18N buttonPaste.setToolTipText(bundle.getString("PlainTextEditor.buttonPaste.toolTipText")); // NOI18N buttonPaste.setFocusable(false); buttonPaste.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonPaste.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonPaste.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonPasteActionPerformed(evt); } }); mainToolBar.add(buttonPaste); buttonClearAll.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/cross16.png"))); // NOI18N buttonClearAll.setText(bundle.getString("PlainTextEditor.buttonClearAll.text")); // NOI18N buttonClearAll.setToolTipText(bundle.getString("PlainTextEditor.buttonClearAll.toolTipText")); // NOI18N buttonClearAll.setFocusable(false); buttonClearAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonClearAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonClearAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonClearAllActionPerformed(evt); } }); mainToolBar.add(buttonClearAll); add(mainToolBar, java.awt.BorderLayout.PAGE_START); jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); labelCursorPos.setText("...:..."); // NOI18N jPanel1.add(labelCursorPos); jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL); jSeparator2.setPreferredSize(new java.awt.Dimension(8, 16)); jPanel1.add(jSeparator2); labelWrapMode.setText("..."); // NOI18N labelWrapMode.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); labelWrapMode.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { labelWrapModeMouseClicked(evt); } }); jPanel1.add(labelWrapMode); jPanel1.add(filler1); add(jPanel1, java.awt.BorderLayout.PAGE_END); }
From source file:gov.nih.nci.firebird.data.AbstractRegistrationForm.java
/** * Create a Validation Failure object using the provided values. * * @param resources the Resource bundle to retrieve messages from. * @param key the Message key of the error. * @param arguments any optional argument replacements. * @return the Validation Failure object *///from w ww . j a v a 2s .c o m public ValidationFailure createValidationFailure(ResourceBundle resources, String key, Object... arguments) { String messageTemplate = resources.getString(key); return new ValidationFailure(MessageFormat.format(messageTemplate, arguments)); }
From source file:it.attocchi.jsf2.PageBase.java
protected String getResourceBundle(String resourceName, String key) { ResourceBundle bundle = getFacesContext().getApplication().getResourceBundle(getFacesContext(), resourceName);/*from ww w . j ava2s.c o m*/ return bundle.getString(key); }
From source file:JAXRPublishHelloOrg.java
/** * Creates an organization, its classification, and its * services, and saves it to the registry. */*from w w w. jav a2 s .c om*/ * @param username the username for the registry * @param password the password for the registry */ public void executePublish(String uuidString, String username, String password) { RegistryService rs = null; BusinessLifeCycleManager blcm = null; BusinessQueryManager bqm = null; try { // Get registry service and managers rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); blcm = rs.getBusinessLifeCycleManager(); System.out.println("Got registry service, query " + "manager, and life cycle manager"); // Get authorization from the registry PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray()); HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>(); creds.add(passwdAuth); connection.setCredentials(creds); System.out.println("Established security credentials"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Create organization name and description InternationalString s = blcm.createInternationalString(bundle.getString("wsdlorg.name")); Organization org = blcm.createOrganization(s); s = blcm.createInternationalString(bundle.getString("wsdlorg.description")); org.setDescription(s); // Create primary contact, set name User primaryContact = blcm.createUser(); PersonName pName = blcm.createPersonName(bundle.getString("wsdlorg.person.name")); primaryContact.setPersonName(pName); s = blcm.createInternationalString(bundle.getString("wsdlorg.person.description")); primaryContact.setDescription(s); // Set primary contact phone number TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setNumber(bundle.getString("wsdlorg.phone")); Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>(); phoneNums.add(tNum); primaryContact.setTelephoneNumbers(phoneNums); // Set primary contact email address EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("wsdlorg.email.address")); Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>(); emailAddresses.add(emailAddress); primaryContact.setEmailAddresses(emailAddresses); // Set primary contact for organization org.setPrimaryContact(primaryContact); // Create services and service Collection<Service> services = new ArrayList<Service>(); s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.name")); Service service = blcm.createService(s); s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.description")); service.setDescription(s); // Create service bindings Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>(); ServiceBinding binding = blcm.createServiceBinding(); s = blcm.createInternationalString(bundle.getString("wsdlorg.svcbnd.description")); binding.setDescription(s); binding.setAccessURI(bundle.getString("wsdlorg.svcbnd.uri")); /* * Find the uddi-org:types classification scheme defined * by the UDDI specification, using well-known key id. */ String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4"; ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types, LifeCycleManager.CLASSIFICATION_SCHEME); /* * Create a classification, specifying the scheme * and the taxonomy name and value defined for WSDL * documents by the UDDI specification. */ Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes, blcm.createInternationalString("wsdlSpec"), "wsdlSpec"); // Define classifications Collection<Classification> classifications = new ArrayList<Classification>(); classifications.add(wsdlSpecClassification); // Find the concept by its UUID Concept specConcept = (Concept) bqm.getRegistryObject(uuidString, LifeCycleManager.CONCEPT); // If we found the concept, we can save the organization if (specConcept != null) { String name = getName(specConcept); Collection links = specConcept.getExternalLinks(); System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(specConcept)); if (links.size() > 0) { ExternalLink link = (ExternalLink) links.iterator().next(); System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'"); } // Now set the specification link for the service binding SpecificationLink specLink = blcm.createSpecificationLink(); specLink.setSpecificationObject(specConcept); binding.addSpecificationLink(specLink); serviceBindings.add(binding); // Add service bindings to service service.addServiceBindings(serviceBindings); // Add service to services, then add services to organization services.add(service); org.addServices(services); // Add organization and submit to registry // Retrieve key if successful Collection<Organization> orgs = new ArrayList<Organization>(); orgs.add(org); BulkResponse response = blcm.saveOrganizations(orgs); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Organization saved"); Collection keys = response.getCollection(); for (Object k : keys) { Key orgKey = (Key) k; String id = orgKey.getId(); System.out.println("Organization key is " + id); } } else { for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on save: " + exception.toString()); } } } else { System.out.println("Specified concept not found, " + "organization not saved"); } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }