List of usage examples for java.util Locale toString
@Override public final String toString()
Locale
object, consisting of language, country, variant, script, and extensions as below: language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensionsLanguage is always lower case, country is always upper case, script is always title case, and extensions are always lower case.
From source file:org.keyboardplaying.xtt.ui.i18n.I18nHelper.java
/** * Sets the locale for the messages to display. * * @param locale/*from w w w .ja v a 2s . c o m*/ * the locale to use */ public void setLocale(Locale locale) { updateResourceBundle(locale); preferences.set(LOCALE_PREFKEY, locale.toString()); for (I14ed internationalized : i14ed) { internationalized.updateMessages(this); } }
From source file:com.vmware.identity.MetadataController.java
/** * Handle default tenant request sent with a wrong binding *//*w w w . jav a 2s . c o m*/ @RequestMapping(value = "/SAML2/Metadata") public void metadataDefaultTenantBindingError(Locale locale, HttpServletResponse response) throws IOException { logger.info("Metadata binding error! The client locale is {}, DEFAULT tenant", locale.toString()); // use validation result code to return error to client ValidationResult vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, "BadRequest", "Binding"); String message = vr.getMessage(messageSource, locale); response.sendError(vr.getResponseCode(), message); logger.info("Responded with ERROR " + vr.getResponseCode() + ", message " + message); }
From source file:com.vmware.identity.WebssoMetadataController.java
/** * Handle default tenant request sent with a wrong binding *//*from ww w . j a v a 2s . c o m*/ @RequestMapping(value = "/websso/SAML2/Metadata") public void metadataDefaultTenantBindingError(Locale locale, HttpServletResponse response) throws IOException { logger.info("Metadata binding error! The client locale is {}, DEFAULT tenant", locale.toString()); // use validation result code to return error to client ValidationResult vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, "BadRequest", "Binding"); String message = vr.getMessage(messageSource, locale); response.sendError(vr.getResponseCode(), message); logger.info("Responded with ERROR " + vr.getResponseCode() + ", message " + message); }
From source file:org.apache.tapestry.engine.DefaultComponentMessagesSource.java
private MultiKey buildKey(IResourceLocation location, Locale locale) { return new MultiKey(new Object[] { location, locale.toString() }, false); }
From source file:edu.cornell.mannlib.vitro.webapp.filters.WebappDaoFactorySDBPrep.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (request.getAttribute("WebappDaoFactorySDBPrep.setup") != null) { // don't run multiple times filterChain.doFilter(request, response); return;/*w ww. j a va 2s.c o m*/ } for (Pattern skipPattern : skipPatterns) { Matcher match = skipPattern.matcher(((HttpServletRequest) request).getRequestURI()); if (match.matches()) { log.debug("request matched a skipPattern, skipping VitroRequestPrep"); filterChain.doFilter(request, response); return; } } OntModelSelector oms = ModelContext.getUnionOntModelSelector(_ctx); OntModelSelector baseOms = ModelContext.getBaseOntModelSelector(_ctx); String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace"); WebappDaoFactory wadf = null; VitroRequest vreq = new VitroRequest((HttpServletRequest) request); List<String> langs = new ArrayList<String>(); log.debug("Accept-Language: " + vreq.getHeader("Accept-Language")); Enumeration<Locale> locs = vreq.getLocales(); while (locs.hasMoreElements()) { Locale locale = locs.nextElement(); langs.add(locale.toString().replace("_", "-")); } if (langs.isEmpty()) { langs.add("en"); } WebappDaoFactoryConfig config = new WebappDaoFactoryConfig(); config.setDefaultNamespace(defaultNamespace); config.setPreferredLanguages(langs); RDFServiceFactory factory = RDFServiceUtils.getRDFServiceFactory(_ctx); //RDFService rdfService = factory.getRDFService(); RDFService unfilteredRDFService = factory.getShortTermRDFService(); RDFService rdfService = null; if (!"false" .equals(ConfigurationProperties.getBean(vreq).getProperty("RDFService.languageFilter", "true"))) { rdfService = new LanguageFilteringRDFService(unfilteredRDFService, langs); } else { rdfService = unfilteredRDFService; } Dataset dataset = new RDFServiceDataset(rdfService); wadf = new WebappDaoFactorySDB(rdfService, oms, config); WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService, baseOms, config, SDBDatasetMode.ASSERTIONS_ONLY); vreq.setRDFService(rdfService); vreq.setUnfilteredRDFService(unfilteredRDFService); vreq.setWebappDaoFactory(wadf); vreq.setAssertionsWebappDaoFactory(assertions); vreq.setFullWebappDaoFactory(wadf); vreq.setUnfilteredWebappDaoFactory( new WebappDaoFactorySDB(rdfService, ModelContext.getUnionOntModelSelector(_ctx))); vreq.setDataset(dataset); vreq.setOntModelSelector(baseOms); vreq.setJenaOntModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getDefaultModel())); request.setAttribute("WebappDaoFactorySDBPrep.setup", 1); try { filterChain.doFilter(request, response); return; } finally { if (wadf != null) { wadf.close(); } } }
From source file:com.vmware.identity.MetadataController.java
/** * Handle GET request for the metadata for default tenant *//*from ww w . jav a2 s . c o m*/ @RequestMapping(value = "/SAML2/Metadata", method = RequestMethod.GET) public void metadataDefaultTenant(Locale locale, Model model, HttpServletResponse response) throws IOException { logger.info("Welcome to Metadata handler! The client locale is {}, DEFAULT tenant", locale.toString()); metadata(locale, Shared.getDefaultTenant(), model, response); }
From source file:com.vmware.identity.WebssoMetadataController.java
/** * Handle GET request for the metadata for default tenant *///from w w w . j a v a 2 s . c om @RequestMapping(value = "/websso/SAML2/Metadata", method = RequestMethod.GET) public void metadataDefaultTenant(Locale locale, Model model, HttpServletResponse response) throws IOException { logger.info("Welcome to Metadata handler! The client locale is {}, DEFAULT tenant", locale.toString()); metadata(locale, Shared.getDefaultTenant(), model, response); }
From source file:net.kamhon.ieagle.util.MessageFactory.java
public PropertyResourceBundleMorpher getResourceBundle(String key, Locale locale) throws SystemErrorException { processIsAlwaysReload();/* w w w . j a v a2 s .c o m*/ setResources(key, locale); return (PropertyResourceBundleMorpher) MESSAGE_RESOURCES.get(key + locale.toString()); }
From source file:net.cit.tetrad.resource.MailResource.java
public void sendMail(final String from, final String[] to, final String subject, final Map<String, Object> map) throws Exception { log.debug(" Send Email Start " + to); if (globalHostName.isEmpty()) globalHostName = mainDao.getGlobalHostname(); MimeMessagePreparator preparator = new MimeMessagePreparator() { public void prepare(MimeMessage mimeMessage) throws Exception { Locale locale = Locale.getDefault(); String vmFileName = "net/cit/tetrad/template/mongofail.vm"; String subjectStr = subject; if (locale.toString().equals("ko_KR") || locale.toString().equals("ko")) { vmFileName = "net/cit/tetrad/template/mongofail_ko_KR.vm"; subjectStr = " ? "; }/*from www.jav a 2 s. c o m*/ String mailBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, vmFileName, "UTF-8", map); MimeMessageHelper message = new MimeMessageHelper(mimeMessage); message.setTo(to); message.setFrom(from); message.setSubject("[" + globalHostName + "] " + subjectStr); message.setText(mailBody, true); } }; mailSender.send(preparator); log.debug(" End Email Start " + to); }
From source file:com.h57.sample.controller.HomeController.java
/** * Does some simple work to find the current shiro subject gets a list of * services, and the date.//www. ja va 2 s . com */ @RequestMapping(method = RequestMethod.GET, value = { "/", "/index" }) public String home(Locale locale, Model model, HttpServletRequest request) { logger.info("Welcome home! the client locale is " + locale.toString()); // This gets the current subject from shiro Subject currentUser = SecurityUtils.getSubject(); // I was going to have more services, who knows .. maybe we will add // more. List<String> services = new ArrayList<String>(); // My SQL class org.apache.commons.dbcp.BasicDataSource if (dataSource instanceof BasicDataSource) { services.add("Data Source: " + ((BasicDataSource) dataSource).getUrl()); } else if (dataSource instanceof SimpleDriverDataSource) { services.add("Data Source: " + ((SimpleDriverDataSource) dataSource).getUrl()); } services.add("My SQL: " + dataSource.getClass()); // Just to prove we can do it. Date date = new Date(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate); // Lets get an identity object Identity thisIdentity = null; // Remembered (from cookie) is different from authenticated in Shiro if (currentUser.isRemembered()) { logger.info("Remembered PRINCIPAL: " + currentUser.getPrincipal()); thisIdentity = identityService.getIdentity(currentUser.getPrincipal().toString()); // Authenticated, we really do believe they are who they claim to // be! } else if (currentUser.isAuthenticated()) { logger.info("Authenticated PRINCIPAL: " + currentUser.getPrincipal()); thisIdentity = identityService.getIdentity(currentUser.getPrincipal().toString()); } // Pass this to the jsp. model.addAttribute("currentUser", currentUser); model.addAttribute("identity", thisIdentity); model.addAttribute("serverTime", formattedDate); model.addAttribute("services", services); return "home"; }