List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
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 ///*from w w w. j ava 2s . c om*/ 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:es.pode.empaquetador.presentacion.avanzado.organizaciones.principal.OrganizacionPrincipalControllerImpl.java
public final void fijarOrganizacionPrincipal(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.organizaciones.principal.FijarOrganizacionPrincipalForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String action = form.getAction(); if (action.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.principalAceptar"))) { String idOrganizacion = form.getIdentifier(); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List subman = sesEmpaq.getSubmanifestPath(); if (subman != null && subman.size() > 0) { OdeVO ultimo = (OdeVO) subman.get(subman.size() - 1); Integer index = subman.size() - 1; String identificador = index == 0 ? sesEmpaq.getIdLocalizador() : ultimo.getIdentifier(); this.getSrvGestorManifestService().fijarOrganizacionPorDefecto(identificador, idOrganizacion); } else {//from ww w . j a va 2 s . c om throw new ValidatorException("{portal_empaquetado.exception}"); } } }
From source file:com.gcrm.util.ExceptionInterceptor.java
/** * Intercepts exception/*w w w .ja va 2s .c o m*/ * * @param action * target action * @return Action result */ public String intercept(ActionInvocation action) throws Exception { String result = Action.SUCCESS; try { result = action.invoke(); } catch (Exception e) { result = Action.INPUT; logger.error(e.getMessage(), e); ActionSupport actionSupport = (ActionSupport) action.getAction(); String errorMessage = e.getMessage(); ResourceBundle rb = CommonUtil.getResourceBundle(); if (e instanceof DataIntegrityViolationException) { errorMessage = rb.getString("error.message.head") + ":" + rb.getString("error.message.violationException"); } else if (e instanceof AccessDeniedException) { result = "accessDenied"; } actionSupport.addActionError(errorMessage); } return result; }
From source file:ca.uhn.fhir.i18n.HapiLocalizer.java
private String findFormatString(String theQualifiedKey) { String formatString = null;/*ww w.j a v a 2 s . co m*/ for (ResourceBundle nextBundle : myBundle) { if (nextBundle.containsKey(theQualifiedKey)) { formatString = nextBundle.getString(theQualifiedKey); } if (isNotBlank(formatString)) { break; } } if (formatString == null) { ourLog.warn("Unknown localization key: {}", theQualifiedKey); formatString = UNKNOWN_I18N_KEY_MESSAGE; } return formatString; }
From source file:edu.ucsb.nceas.metacat.lsid.LSIDDataLookup.java
public String getDocType(LSID lsid) { // example//from w w w . j a v a 2 s. c o m //http://metacat.nceas.ucsb.edu/knb/metacat?action=getrevisionanddoctype&docid=knb-lter-gce.109.6 // returns rev;doctype String _docType = null; String ns = lsid.getNamespace(); String id = lsid.getObject(); String ver = lsid.getRevision(); InputStream docStream = null; ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid"); String theServer = rb.getString("metacatserver"); logger.debug("the server is " + theServer); String url = theServer + "?action=getrevisionanddoctype&docid="; url = url + ns + "." + id + "." + ver; try { URL theDoc = new URL(url); docStream = theDoc.openStream(); StringTokenizer _st = new StringTokenizer(LSIDAuthorityMetaData.getStringFromInputStream(docStream), ";"); _st.nextToken(); _docType = _st.nextToken(); docStream.close(); } catch (MalformedURLException mue) { logger.error("MalformedURLException in LSIDDataLookup: " + mue); mue.printStackTrace(); } catch (IOException ioe) { logger.error("IOException in LSIDDataLookup: " + ioe); ioe.printStackTrace(); } return _docType; }
From source file:cn.mypandora.controller.MyUpload.java
/** * @param part/*from w ww . jav a2s . c o m*/ * @return void * @Title: upload * @Description: */ @RequestMapping(value = "/upload", method = RequestMethod.POST) public void upload(@RequestParam("myFile") Part part, @RequestParam("choosePath") String choosePath) { try { /* ? */ /* ? */ ResourceBundle resourceBundle = ResourceBundle.getBundle("upload"); String savePath = resourceBundle.getString(choosePath != null ? choosePath : "defaultPath") + getFileName(part); // String webRootPath = request.getServletContext().getRealPath("/upload"); String webRootPath = System.getProperty("contentPath"); part.write(webRootPath + savePath); // ?? UploadFile file = new UploadFile(); file.setFileSize(part.getSize()); file.setFileName(getFileName(part)); file.setSaveName(getFileName(part)); file.setFileType(1); file.setSavePath(savePath); file.setCreateTime(new Timestamp(1234567890L)); file.setUpdateTime(new Timestamp(1234567891L)); baseUploadService.saveFile(file); // return file; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.ecyrd.jspwiki.ui.TemplateManager.java
/** * Extract all i18n strings in the javascript domain. (javascript.*) * Returns a javascript snippet which defines the LoacalizedStings array. * * @param wiki context/*from w w w . j ava2s .com*/ * @return Javascript snippet which defines the LocaliedStrings array * @author Dirk Frederickx * @since 2.5.108 */ private static String getJSLocalizedStrings(WikiContext context) { StringBuffer sb = new StringBuffer(); sb.append("var LocalizedStrings = {\n"); ResourceBundle rb = context.getBundle("templates.default"); boolean first = true; for (Enumeration en = rb.getKeys(); en.hasMoreElements();) { String key = (String) en.nextElement(); if (key.startsWith("javascript")) { if (first) { first = false; } else { sb.append(",\n"); } sb.append("\"" + key + "\":\"" + rb.getString(key) + "\""); } } sb.append("\n};\n"); return (sb.toString()); }
From source file:gwtupload.server.UploadServlet.java
/** * Returns the localized text of a key.//from ww w . j a va 2 s.c om */ public static String getMessage(String key, Object... pars) { Locale loc = getThreadLocalRequest() == null || getThreadLocalRequest().getLocale() == null ? new Locale("en") : getThreadLocalRequest().getLocale(); ResourceBundle res = ResourceBundle.getBundle(UploadServlet.class.getName(), loc); String msg = res.getString(key); if ("zh".equals(loc.getLanguage()) && "CN".equals(loc.getCountry())) { msg = convertEncodingFormat(msg, "ISO-8859-1", "UTF-8"); } return new MessageFormat(msg, loc).format(pars); }
From source file:br.com.tcc.rest.config.TccExceptionHandler.java
private String getBundleMessage(String key) { ResourceBundle bundle = ResourceBundle.getBundle("tcc-messages"); String message = key;/*from w w w .ja v a 2 s. c o m*/ if (bundle.containsKey(key)) { message = bundle.getString(key); } return message; }
From source file:es.pode.modificador.presentacion.configurar.cambios.add.TipoAnadirControllerImpl.java
/** * @see es.pode.modificador.presentacion.configurar.cambios.add.TipoAnadirController#selectAction(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.add.SelectActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*w w w . j a v a 2 s . c om*/ public final java.lang.String selectAction(ActionMapping mapping, es.pode.modificador.presentacion.configurar.cambios.add.SelectActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String tipoAniadir = form.getTipoAniadir(); Boolean alcance = form.getAlcance(); String action = form.getAction(); String result = ""; String CONTINUAR = "Continuar"; String CANCELAR = "Cancelar"; java.util.Locale locale = (java.util.Locale) request.getSession() .getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); if (action.equals(i18n.getString("tipoAnadirAlcance.continuar"))) { if (tipoAniadir == null) { throw new ValidatorException("{tipoAnadirTipo.exception}"); } else { this.getCambioSession(request).setTipoAniadir((form.getTipoAniadir())); } if (alcance == null) { throw new ValidatorException("{tipoAnadirAlcance.exception}"); } else { this.getCambioSession(request).setAlcance(form.getAlcance()); } result = CONTINUAR; } else { result = CANCELAR; } return result; }