List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:edu.toronto.cs.phenotips.measurements.internal.DefaultMeasurementsChartConfigurationsFactory.java
/** * Read and return a setting from the configuration, parsing it as a {@code double} number, falling back on the * provided default value.//from w w w. j a va 2 s . co m * * @param settingName the name of the setting to read * @param defaultValue the default value to use when there's no value specified in the configuration, or the * specified value is not a valid double number * @param configuration the configuration bundle with all the settings * @return the configured value, if one is configured as a valid {@code double} number, or the default value * otherwise */ private double getDoubleSetting(String settingName, double defaultValue, ResourceBundle configuration) { double result = defaultValue; if (configuration.containsKey(settingName)) { try { result = Double.parseDouble(configuration.getString(settingName)); if (Double.isNaN(result) || Double.isInfinite(result)) { this.logger.warn("Invalid chart settings for [{}]: value should be finite, was [{}]", settingName, configuration.getString(settingName)); result = defaultValue; } } catch (NumberFormatException ex) { // Fall back to the default value this.logger.warn("Invalid chart settings for [{}]: invalid double [{}]", settingName, configuration.getString(settingName)); } } return result; }
From source file:de.hska.ld.core.service.impl.UserServiceImpl.java
@Override public void register(User user) { User userFoundByUsername = findByUsername(user.getUsername()); User userFoundByEmail = findByEmail(user.getEmail()); setNewUserFields(user, userFoundByUsername, userFoundByEmail); user.setRegistrationConfirmationKey(UUID.randomUUID().toString()); user.setEnabled(false);/* ww w.ja va 2 s . c o m*/ user = super.save(user); ResourceBundle bundle = ResourceBundle.getBundle("messages", LocaleContextHolder.getLocale()); String subject = bundle.getString("email.user.registration.subject"); String text = bundle.getString("email.user.registration.text"); String confirmationUrl = env.getProperty("module.core.auth.registrationConfirmUrl") + user.getForgotPasswordConfirmationKey(); //sendConfirmationMail(user, subject, text, confirmationUrl); }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.CrearElementoControllerImpl.java
public final void submit02(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.Submit02Form form, HttpServletRequest request, HttpServletResponse response) throws Exception { CrearElementoSession sesElem = this.getCrearElementoSession(request); java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String identificador = form.getIdentifier(); String accion = form.getAction(); if (accion.equals(i18n.getString("portal_empaquetado_crearElemento.aceptar2"))) { sesElem.setIdRef(identificador); }/*from w w w . j a v a 2 s.c o m*/ }
From source file:JAXRPublish.java
/** * Creates an organization, its classification, and its * services, and saves it to the registry. */*from ww w. j a va2s. c o m*/ * @param username the username for the registry * @param password the password for the registry */ public void executePublish(String username, String password) { RegistryService rs = null; BusinessLifeCycleManager blcm = null; BusinessQueryManager bqm = null; try { rs = connection.getRegistryService(); blcm = rs.getBusinessLifeCycleManager(); bqm = rs.getBusinessQueryManager(); 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("org.name")); Organization org = blcm.createOrganization(s); s = blcm.createInternationalString(bundle.getString("org.description")); org.setDescription(s); // Create primary contact, set name User primaryContact = blcm.createUser(); PersonName pName = blcm.createPersonName(bundle.getString("person.name")); primaryContact.setPersonName(pName); // Set primary contact phone number TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setNumber(bundle.getString("phone.number")); Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>(); phoneNums.add(tNum); primaryContact.setTelephoneNumbers(phoneNums); // Set primary contact email address EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("email.address")); Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>(); emailAddresses.add(emailAddress); primaryContact.setEmailAddresses(emailAddresses); // Set primary contact for organization org.setPrimaryContact(primaryContact); // Set classification scheme to NAICS, using // well-known UUID of ntis-gov:naics:1997 String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics, LifeCycleManager.CLASSIFICATION_SCHEME); if (cScheme != null) { // Create and add classification InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name")); Classification classification = blcm.createClassification(cScheme, sn, bundle.getString("classification.value")); Collection<Classification> classifications = new ArrayList<Classification>(); classifications.add(classification); org.addClassifications(classifications); } else { System.out.println("Classification scheme not found, " + "not classifying organization"); } // Create services and service Collection<Service> services = new ArrayList<Service>(); s = blcm.createInternationalString(bundle.getString("service.name")); Service service = blcm.createService(s); s = blcm.createInternationalString(bundle.getString("service.description")); service.setDescription(s); // Create service bindings Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>(); ServiceBinding binding = blcm.createServiceBinding(); s = blcm.createInternationalString(bundle.getString("svcbinding.description")); binding.setDescription(s); // Allow us to publish a fictitious URI without an error binding.setValidateURI(false); binding.setAccessURI(bundle.getString("svcbinding.accessURI")); 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()); } } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:de.hska.ld.core.service.impl.UserServiceImpl.java
@Override public void forgotPassword(String userUsernameOrEmail) { User user = repository.findByUsernameOrEmail(userUsernameOrEmail); if (user != null) { user.setForgotPasswordConfirmationKey(UUID.randomUUID().toString()); user = super.save(user); ResourceBundle bundle = ResourceBundle.getBundle("messages", LocaleContextHolder.getLocale()); String subject = bundle.getString("email.user.forgotPassword.subject"); String text = bundle.getString("email.user.forgotPassword.text"); String confirmationUrl = env.getProperty("module.core.auth.forgotPasswordConfirmUrl") + user.getForgotPasswordConfirmationKey(); sendConfirmationMail(user, subject, text, confirmationUrl); }/*from ww w . j a v a2 s. co m*/ }
From source file:de.hska.ld.core.service.impl.UserServiceImpl.java
@Override public void changeEmail(User user, String emailToBeConfirmed) { User userFoundByEmail = findByEmail(emailToBeConfirmed); if (userFoundByEmail == null) { user.setEmailToBeConfirmed(emailToBeConfirmed); user.setChangeEmailConfirmationKey(UUID.randomUUID().toString()); user = super.save(user); ResourceBundle bundle = ResourceBundle.getBundle("messages", LocaleContextHolder.getLocale()); String subject = bundle.getString("email.user.changeEmail.subject"); String text = bundle.getString("email.user.changeEmail.text"); String confirmationUrl = env.getProperty("module.core.auth.changeEmailConfirmUrl") + user.getChangeEmailConfirmationKey(); sendConfirmationMail(user.getFullName(), user.getEmailToBeConfirmed(), subject, text, confirmationUrl); } else {/* w w w. j a v a 2s .c o m*/ throw new AlreadyExistsException("email"); } }
From source file:com.sunrun.crportal.util.CRPortalUtil.java
public static Properties resourceBundleToProperties(ResourceBundle rb) { Properties properties = new Properties(); Enumeration<String> keys = rb.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); properties.put(key, rb.getString(key)); }/*from w w w .j a v a2 s . c o m*/ return properties; }
From source file:de.ingrid.portal.portlets.mdek.MdekAdminLoginPortlet.java
public void doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response) throws PortletException, IOException { Context context = getContext(request); ResourceBundle resourceBundle = getPortletConfig().getResourceBundle(request.getLocale()); context.put("MESSAGES", resourceBundle); setDefaultViewPage(TEMPLATE_START);//from www. java 2s.com PortletPreferences prefs = request.getPreferences(); String myTitleKey = prefs.getValue("titleKey", "mdek.title.adminlogin"); response.setTitle(resourceBundle.getString(myTitleKey)); String error = (String) getPortletContext().getAttribute("ige.error"); if (error != null) { context.put("igeError", error); // clear error ! getPortletContext().removeAttribute("ige.error"); } Map<String, List> catalogInfo = buildConnectedCatalogList(); context.put("catalogList", catalogInfo.get(CATALOG)); context.put("userLists", catalogInfo.get(USER_OF_CATALOG)); super.doView(request, response); }
From source file:org.cybercat.automation.core.ConfigurationManager.java
/** * Creates default users described in MetaData.properties file. * //from www.j av a 2 s . c om * @throws PageModelException */ public void initXmlRepository() throws PageModelException { PersistenceManager persistence = context.getBean(PersistenceManager.class); ResourceBundle resource = ResourceManager.getTestMetaData(); List<Identity> users = persistence.load(Identity.class); Enumeration<String> keys = resource.getKeys(); String key; while (keys.hasMoreElements()) { key = keys.nextElement(); if (key.contains("registred.users") && (!users.contains(Identity.parseFromString(resource.getString(key))))) { persistence.save(Identity.parseFromString(resource.getString(key))); } } }
From source file:es.pode.administracion.presentacion.planificador.listarTareasPendientes.TareasPendientesControllerImpl.java
/** * Copiamos todos los campos de la tarea recibida y los metemos en la nueva tarea cambiando * la fecha a Date/*w w w . jav a 2 s . com*/ * */ private TareaDate cambiarFormatoTarea(TareaVO tarea, Locale locale) { TareaDate tareaDate = new TareaDate(); tareaDate.setCron(tarea.getCron()); if (tarea.getFechaInicio() != null) tareaDate.setFechaInicio(tarea.getFechaInicio().getTime()); tareaDate.setGrupoTrabajo(tarea.getGrupoTrabajo()); tareaDate.setGrupoTrigger(tarea.getGrupoTrigger()); ResourceBundle ficheroRecursos = ResourceBundle.getBundle("application-resources", locale); if (tarea.getPeriodicidad().equals("N")) tarea.setPeriodicidad(ficheroRecursos.getString("tareas.vacia")); else if (tarea.getPeriodicidad().equals("D")) tarea.setPeriodicidad(ficheroRecursos.getString("crearTarea.D")); else if (tarea.getPeriodicidad().equals("S")) tarea.setPeriodicidad(ficheroRecursos.getString("crearTarea.S")); else if (tarea.getPeriodicidad().equals("M")) tarea.setPeriodicidad(ficheroRecursos.getString("crearTarea.M")); else if (tarea.getPeriodicidad().equals("A")) tarea.setPeriodicidad(ficheroRecursos.getString("crearTarea.A")); tareaDate.setPeriodicidad(tarea.getPeriodicidad()); tareaDate.setTipoTarea(tarea.getTipoTarea()); tareaDate.setTrabajo(tarea.getTrabajo()); tareaDate.setTrigger(tarea.getTrigger()); tareaDate.setUsuario(tarea.getUsuario()); /** * Recortamos el nombre de la tarea quitandole lo agregado al nombre original * Lo agregado son dos # seguidas de la fecha en la que se ejecuta la tarea * La fecha se compone de "ao+mes+dia+hora+minutos+segundos" * */ int posicion = tarea.getTrabajo().indexOf("!!"); if (posicion > 0) tareaDate.setTrabajo(tarea.getTrabajo().substring(0, posicion)); else tareaDate.setTrabajo(tarea.getTrabajo()); //tareaDate.setTrabajo(tarea.getTrabajo()); tareaDate.setUsuario(tarea.getUsuario()); return tareaDate; }