List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:JAXRQueryPostal.java
/** * Establishes a connection to a registry. */*from w ww . j a va 2 s . c o m*/ * @param queryUrl the URL of the query registry * @param publishUrl the URL of the publish registry * @param uuidString the UUID string of the postal address scheme */ public void makeConnection(String queryUrl, String publishUrl, String uuidString) { /* * Specify proxy information in case you * are going beyond your firewall. */ ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); String httpProxyHost = bundle.getString("http.proxyHost"); String httpProxyPort = bundle.getString("http.proxyPort"); String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames"); /* * Define connection configuration properties. * For simple queries, you need the query URL. */ Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", queryUrl); props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost); props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort); // Define the taxonomy XML file (postalconcepts.xml) props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames); // Set properties for postal address mapping: postal address // classification scheme and mapping to JAXR scheme props.setProperty("javax.xml.registry.postalAddressScheme", uuidString); props.setProperty("javax.xml.registry.semanticEquivalences", "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|" + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|" + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|" + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|" + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|" + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry"); try { // Create the connection, passing it the // configuration properties ConnectionFactory factory = ConnectionFactory.newInstance(); factory.setProperties(props); connection = factory.createConnection(); System.out.println("Created connection to registry"); } catch (Exception e) { e.printStackTrace(); if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRPublishPostal.java
/** * Establishes a connection to a registry. *//from w ww . j a v a 2 s . c o m * @param queryUrl the URL of the query registry * @param publishUrl the URL of the publish registry */ public void makeConnection(String queryUrl, String publishUrl, String uuidString) { /* * Specify proxy information in case you * are going beyond your firewall. */ ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); String httpProxyHost = bundle.getString("http.proxyHost"); String httpProxyPort = bundle.getString("http.proxyPort"); String httpsProxyHost = bundle.getString("https.proxyHost"); String httpsProxyPort = bundle.getString("https.proxyPort"); String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames"); /* * Define connection configuration properties. * To publish, you need both the query URL and the * publish URL. */ Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", queryUrl); props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl); props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost); props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort); props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost); props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort); // Define the taxonomy XML file (postalconcepts.xml) props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames); // Set properties for postal address mapping using my scheme props.setProperty("javax.xml.registry.postalAddressScheme", uuidString); props.setProperty("javax.xml.registry.semanticEquivalences", "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|" + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|" + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|" + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|" + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|" + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry"); try { // Create the connection, passing it the // configuration properties ConnectionFactory factory = ConnectionFactory.newInstance(); factory.setProperties(props); connection = factory.createConnection(); System.out.println("Created connection to registry"); } catch (Exception e) { e.printStackTrace(); if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:com.github.jrh3k5.flume.mojo.plugin.AbstractFlumePluginMojoITest.java
/** * Set the {@code $maven.home} value in the system properties for the {@link BuildTool} object. * // w ww .ja v a2s. c om * @throws Exception * If any errors occur during the setup. */ @Before public void setUpMavenHome() throws Exception { final ResourceBundle systemPropsBundle = ResourceBundle.getBundle("system"); final String mavenHome = systemPropsBundle.getString("maven.home"); if (mavenHome == null) { throw new IllegalStateException("maven.home is null; did the resources not filter correctly?"); } if (!new File(mavenHome).exists()) { throw new IllegalStateException(String.format("Configured maven.home '%s' does not exist.", mavenHome)); } System.setProperty("maven.home", mavenHome); }
From source file:es.pode.modificador.presentacion.pendientes.ModificacionesPendientesControllerImpl.java
/** * @see es.pode.modificador.presentacion.pendientes.ModificacionesPendientesController#selectAction(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.pendientes.SelectActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w w w . j a v a 2 s . co m public final java.lang.String selectAction(ActionMapping mapping, es.pode.modificador.presentacion.pendientes.SelectActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String result = null; String actionSubmit = form.getAction(); java.util.Locale locale = (java.util.Locale) request.getSession() .getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); if (form.getAction() == (null)) { throw new ValidatorException("{modificacionesPendientes.exception}"); } else if (actionSubmit.equals(i18n.getString("modificacionesPendientes.crearTarea"))) { result = "Crear"; } else if (actionSubmit.equals(i18n.getString("modificacionesPendientes.importarTarea"))) { result = "Importar"; } else if (actionSubmit.equals(i18n.getString("modificacionesPendientes.eliminar"))) { // Para no perderla en la pantalla de confirmacion, la meto en sesion. request.getSession().setAttribute("identificadores", form.getIdentificadores()); result = "Eliminar"; } form.setIdiomaBuscadorBackingList( IdiomasBuscadorSingleton.getInstance().obtenerIdiomas(LdapUserDetailsUtils.getIdioma()), "idLocalizacion", "nombre"); return result; }
From source file:com.eyeq.pivot4j.ui.aggregator.AbstractAggregator.java
/** * @param context//from w w w .j a va 2 s . c om * @return */ protected String getAggregationLabel(RenderContext context) { ResourceBundle resources = context.getRenderer().getResourceBundle(); String label = null; if (resources != null) { label = resources.getString("label.aggregation.type." + getName()); } return label; }
From source file:com.silverpeas.bootstrap.SilverpeasContextBootStrapper.java
/** * Initialise the System.properties according to Silverpeas needs and configuration. * * @param sce/*www . j ava 2s.co m*/ */ @Override public void contextInitialized(ServletContextEvent sce) { ResourceBundle silverpeasInitialisationSettings = FileUtil.loadBundle( "org.silverpeas._silverpeasinitialize.settings._silverpeasinitializeSettings", new Locale("fr", "")); loadExternalJarLibraries(); String systemSettingsPath = silverpeasInitialisationSettings.getString("pathInitialize"); if (!StringUtil.isDefined(systemSettingsPath)) { Logger.getLogger("bootstrap").log(Level.SEVERE, "Repository Initialize for systemSettings.properties file is not defined in Settings."); } else { File pathInitialize = new File(systemSettingsPath); FileInputStream fis = null; try { fis = new FileInputStream(new File(pathInitialize, "systemSettings.properties")); Properties systemFileProperties = new Properties(System.getProperties()); systemFileProperties.load(fis); // Fix - empty proxy port and proxy host not supported by Spring Social if (!StringUtil.isDefined(systemFileProperties.getProperty("http.proxyPort"))) { systemFileProperties.remove("http.proxyPort"); } if (!StringUtil.isDefined(systemFileProperties.getProperty("http.proxyHost"))) { systemFileProperties.remove("http.proxyHost"); } System.setProperties(systemFileProperties); if (isTrustoreConfigured()) { registerSSLSocketFactory(); } } catch (FileNotFoundException e) { Logger.getLogger("bootstrap").log(Level.SEVERE, "File systemSettings.properties in directory {0} not found.", pathInitialize); } catch (IOException e) { Logger.getLogger("bootstrap").log(Level.SEVERE, "Unable to read systemSettings.properties."); } catch (GeneralSecurityException e) { Logger.getLogger("bootstrap").log(Level.SEVERE, "Unable to configure the trustore."); } finally { IOUtils.closeQuietly(fis); } } URLManager.setSilverpeasVersion(sce.getServletContext().getInitParameter("SILVERPEAS_VERSION")); springContextListener.contextInitialized(sce); }
From source file:uk.co.grahamcox.yui.LanguageModuleBuilder.java
/** * Get the module file requested//from ww w . jav a2s . com * @param group the group of the module * @param file the file of the module * @return the contents of the module * @throws java.io.IOException if an error occurs loading module content */ public String getModuleFile(String group, String file, String language) throws IOException { if (groups.containsKey(group)) { ModuleGroup moduleGroup = groups.get(group); Module module = moduleGroup.findModule(file); if (module != null) { StringBuilder moduleOutput = new StringBuilder(); moduleOutput.append("YUI.add('lang/").append(module.getName()); if (language != null && !language.isEmpty()) { moduleOutput.append("_").append(language); } moduleOutput.append("', function (Y) {\n"); moduleOutput.append("Y.Intl.add(\n"); moduleOutput.append("'").append(module.getName()).append("',\n"); moduleOutput.append("'").append(language).append("',\n"); moduleOutput.append("{\n"); String resourceKey = module.getMessagesFile().toString(); Locale locale; if (language == null || language.isEmpty()) { locale = Locale.getDefault(); } else { locale = Locale.forLanguageTag(language); } ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceKey, locale, new LanguageControl()); Enumeration<String> keys = resourceBundle.getKeys(); boolean isFirst = true; while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = resourceBundle.getString(key); if (!isFirst) { moduleOutput.append(","); } isFirst = false; moduleOutput.append("'").append(key).append("': '").append(value).append("'"); } moduleOutput.append("});\n"); moduleOutput.append("}, '").append(module.getVersion()).append("');"); return moduleOutput.toString(); } else { throw new UnknownModuleException(group, file); } } else { throw new UnknownGroupException(group); } }
From source file:cn.vlabs.duckling.vwb.ui.action.EditPageAction.java
public ActionForward saveexit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String htmlText = request.getParameter("fixDomStr"); Resource res = this.getSavedViewPort(request); VWBContext context = VWBContext.createContext(request, DPageCommand.INFO, res); if (!HtmlValidateUtil.checkHtmlTextValidate(htmlText)) { ResourceBundle rb = context.getBundle("templates/default"); writeToResponse(response, rb.getString("action.savepage.containInvalidateForm")); return null; }//from w w w. j a v a 2s . c om // ??? String lockVersion = request.getParameter("lockVersion"); DPage lockeddpage = (DPage) res; Date mverion = lockeddpage.getTime(); if (!lockVersion.equals(String.valueOf(mverion))) {// ? if (!context.hasAccess(response)) { return null; } // ?? String textWithoutMetaData = ""; if (htmlText != null) { textWithoutMetaData = new HtmlStringToDMLTranslator().translate(htmlText, context); } DPage dpage = new DPage(); dpage.setResourceId(res.getResourceId()); UserPrincipal p = (UserPrincipal) context.getCurrentUser(); dpage.setAuthor(p.getFullName() + "(" + p.getName() + ")"); dpage.setTitle(request.getParameter("title")); dpage.setContent(textWithoutMetaData); VWBContext.getContainer().getSaveTempDpageService().saveTempDpage(context.getSite().getId(), dpage, textWithoutMetaData); // ?? String editurl = context.getEditURL(res.getResourceId()); request.setAttribute("editurl", editurl); request.setAttribute("pageTitle", request.getParameter("title")); request.setAttribute("myinner", (htmlText)); boolean isDpageExists = VWBContext.getContainer().getDpageService() .isDpageExist(context.getSite().getId(), res.getResourceId()); String otherhtmlText = ""; if (isDpageExists) { DPage oldpage = (DPage) res; otherhtmlText = context.getHTML(oldpage); } request.setAttribute("otherinner", (otherhtmlText)); return layout(context, "ConflictContent.jsp"); } else { // ?? if (!context.hasAccess(response)) { return null; } // ? String textWithoutMetaData = ""; if (htmlText != null) { context.setUseDData(true); textWithoutMetaData = new HtmlStringToDMLTranslator().translate(htmlText, context); } int resourceid = res.getResourceId(); DPage dpage = new DPage(); dpage.setResourceId(res.getResourceId()); UserPrincipal p = (UserPrincipal) context.getCurrentUser(); dpage.setAuthor(p.getFullName() + "(" + p.getName() + ")"); dpage.setTitle(request.getParameter("title")); dpage.setContent(textWithoutMetaData); dpage.setSiteId(context.getSite().getId()); boolean isDpageExists = VWBContext.getContainer().getDpageService() .isDpageExist(context.getSite().getId(), resourceid); if (isDpageExists) { VWBContext.getContainer().getDpageService().updateDpage(dpage); } else { VWBContext.getContainer().getDpageService().createDpage(dpage); } // ? VWBContext.getContainer().getSaveTempDpageService().cleanTempPage(context.getSite().getId(), resourceid, p); // ?? VWBContext.getContainer().getDpageService().unlockPage(context.getSite().getId(), resourceid); // ? String url = context.getViewURL(resourceid); response.sendRedirect(url); } return null; }
From source file:es.pode.administracion.presentacion.adminusuarios.bajaGrupo.BajaControllerImpl.java
/** * @see es.pode.administracion.presentacion.adminusuarios.bajaGrupo.BajaController#bajaGrupo(org.apache.struts.action.ActionMapping, * es.pode.administracion.presentacion.adminusuarios.bajaGrupo.BajaGrupoForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *//* w w w . jav a2 s . co m*/ public final void bajaGrupo(ActionMapping mapping, es.pode.administracion.presentacion.adminusuarios.bajaGrupo.BajaGrupoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String listaId = request.getParameter("listaId"); if (log.isDebugEnabled()) log.debug("los ids de usuario que se quieren eliminar son " + listaId); Object[] objeto = listaId.split(" "); ResourceBundle ficheroRecursos = null; try { SrvAdminUsuariosService srvAdminUsuariosService = this.getSrvAdminUsuariosService(); ValidaBajaGrupoVO validaBaja = srvAdminUsuariosService.bajaGrupo(obtenerIds(objeto)); Locale locale = request.getLocale(); ficheroRecursos = this.getFicherRecursos(locale); form.setDescripcionBaja(ficheroRecursos.getString(validaBaja.getDescripcion())); form.setGruposDeleted(validaBaja.getItemsDeleted()); } catch (Exception e) { log.error("Se ha producido un error al eliminar el usuario " + e); throw new ValidatorException("{errors.borrarUsuario}"); } }
From source file:es.pode.empaquetador.presentacion.basico.asociar.AsociarControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.basico.asociar.AsociarController#selectActionURL(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.basico.asociar.SelectActionURLForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from ww w. ja va 2 s.co m public final java.lang.String selectActionURL(ActionMapping mapping, es.pode.empaquetador.presentacion.basico.asociar.SelectActionURLForm 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 accion = form.getAction(); String resultado = null; if (accion.equals(i18n.getString("portalempaquetado.Aceptar"))) { if (form.getUrl() == null || form.getUrl().equals("")) { if (logger.isDebugEnabled()) logger.debug("El texto del URL es null"); throw new ValidatorException("{portalempaquetado.basico.asociar.url.error.vacio}"); } resultado = "Aceptar"; } else { resultado = "Cancelar"; form.setTipo("URL"); } return resultado; }