@Override public Properties getMessages(String baseBundlename, Locale locale) throws IOException { if (messages.get(baseBundlename) == null || messages.get(baseBundlename).get(locale) == null) { Properties messages = new Properties(); if (!Locale.ENGLISH.equals(locale)) { messages.putAll(getMessages(baseBundlename, Locale.ENGLISH)); } ListIterator<Theme> itr = themes.listIterator(themes.size()); while (itr.hasPrevious()) { Properties m = itr.previous().getMessages(baseBundlename, locale); if (m != null) { messages.putAll(m); } } this.messages.putIfAbsent(baseBundlename, new ConcurrentHashMap<Locale, Properties>()); this.messages.get(baseBundlename).putIfAbsent(locale, messages); return messages; } else { return messages.get(baseBundlename).get(locale); } }
public EmbeddedKafka(Map<String, String> customProps) throws Exception { super(); Map<String, String> defaultProps = Maps.newHashMap(); defaultProps.put("broker.id", "0"); defaultProps.put("host.name", "127.0.0.1"); defaultProps.put("port", "9092"); defaultProps.put("advertised.host.name", "127.0.0.1"); defaultProps.put("advertised.port", "9092"); defaultProps.put("log.dir", createTempDir().getAbsolutePath()); defaultProps.put("zookeeper.connect", package$.MODULE$.ZookeeperConnectionString()); defaultProps.put("replica.high.watermark.checkpoint.interval.ms", "5000"); defaultProps.put("log.flush.interval.messages", "1"); defaultProps.put("replica.socket.timeout.ms", "500"); defaultProps.put("controlled.shutdown.enable", "false"); defaultProps.put("auto.leader.rebalance.enable", "false"); Properties props = new Properties(); props.putAll(defaultProps); props.putAll(customProps); final KafkaConfig kafkaConfig = new KafkaConfig(props); zookeeper = new EmbeddedZookeeper((String) props.get("zookeeper.connect")); awaitCond(aVoid -> zookeeper.isRunning(), 3000, 100); server = new KafkaServer(kafkaConfig, SystemTime$.MODULE$); Thread.sleep(2000); log.info("Starting the Kafka server at {}", kafkaConfig.zkConnect()); server.startup(); Thread.sleep(2000); }
public static Properties getSystemProperties() { Properties res = ourSystemProperties; if (res == null) { res = new Properties(); res.putAll(System.getProperties()); for (Iterator<Object> itr = res.keySet().iterator(); itr.hasNext(); ) { final String propertyName = itr.next().toString(); if (propertyName.startsWith("idea.")) { itr.remove(); } } for (Map.Entry<String, String> entry : System.getenv().entrySet()) { String key = entry.getKey(); if (key.startsWith("=")) { continue; } if (SystemInfo.isWindows) { key = key.toUpperCase(); } res.setProperty("env." + key, entry.getValue()); } ourSystemProperties = res; } return res; }
/** * list the configurations of resource model providers. * * @return a list of maps containing: * <ul> * <li>type - provider type name * <li>props - configuration properties * </ul> */ @Override public synchronized List<Map<String, Object>> listResourceModelConfigurations() { Map propertiesMap = projectConfig.getProperties(); Properties properties = new Properties(); properties.putAll(propertiesMap); return listResourceModelConfigurations(properties); }
private Properties decryptPwd(Properties initProps) { String encryptionKey = initProps.getProperty("encryptKeyFile"); if (initProps.getProperty("password") != null && encryptionKey != null) { // this means the password is encrypted and use the file to decode it try { try (Reader fr = new InputStreamReader(new FileInputStream(encryptionKey), UTF_8)) { char[] chars = new char[100]; // max 100 char password int len = fr.read(chars); if (len < 6) throw new DataImportHandlerException( SEVERE, "There should be a password of length 6 atleast " + encryptionKey); Properties props = new Properties(); props.putAll(initProps); String password = null; try { password = CryptoKeys.decodeAES(initProps.getProperty("password"), new String(chars, 0, len)) .trim(); } catch (SolrException se) { throw new DataImportHandlerException(SEVERE, "Error decoding password", se.getCause()); } props.put("password", password); initProps = props; } } catch (IOException e) { throw new DataImportHandlerException( SEVERE, "Could not load encryptKeyFile " + encryptionKey); } } return initProps; }
/** * Adds the keys/properties from an application-specific properties file to the System Properties. * The application-specific properties file MUST reside in a directory listed on the CLASSPATH. * * @param propsFileName The name of an application-specific properties file. */ public static void addToSystemPropertiesFromPropsFile(String propsFileName) { Properties props = ResourceLoader.getAsProperties(propsFileName), sysProps = System.getProperties(); // Add the keys/properties from the application-specific properties to the System Properties. sysProps.putAll(props); }
@Override protected Properties getSubstituteProperties() { Map<String, Object> p = getOverlay().getUserProps(); if (p == null || p.isEmpty()) return super.getSubstituteProperties(); Properties result = new Properties(super.getSubstituteProperties()); result.putAll(p); return result; }
/** sometimes call by sample application, at that time normally set some properties directly */ private Configure() { Properties p = new Properties(); Map args = new HashMap(); args.putAll(System.getenv()); args.putAll(System.getProperties()); p.putAll(args); this.property = p; reload(false); }
private static void runOrApplyFileTemplate( Project project, VirtualFile file, String templateName, Properties properties, Properties conditions, boolean interactive) throws IOException { FileTemplateManager manager = FileTemplateManager.getInstance(); FileTemplate fileTemplate = manager.getJ2eeTemplate(templateName); Properties allProperties = manager.getDefaultProperties(project); if (!interactive) { allProperties.putAll(properties); } allProperties.putAll(conditions); String text = fileTemplate.getText(allProperties); Pattern pattern = Pattern.compile("\\$\\{(.*)\\}"); Matcher matcher = pattern.matcher(text); StringBuffer builder = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(builder, "\\$" + matcher.group(1).toUpperCase() + "\\$"); } matcher.appendTail(builder); text = builder.toString(); TemplateImpl template = (TemplateImpl) TemplateManager.getInstance(project).createTemplate("", "", text); for (int i = 0; i < template.getSegmentsCount(); i++) { if (i == template.getEndSegmentNumber()) continue; String name = template.getSegmentName(i); String value = "\"" + properties.getProperty(name, "") + "\""; template.addVariable(name, value, value, true); } if (interactive) { OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file); Editor editor = FileEditorManager.getInstance(project).openTextEditor(descriptor, true); editor.getDocument().setText(""); TemplateManager.getInstance(project).startTemplate(editor, template); } else { VfsUtil.saveText(file, template.getTemplateText()); } }
/** * Get combined property of all interpreters in this group * * @return */ public Properties getProperty() { Properties p = new Properties(); for (List<Interpreter> intpGroupForASession : this.values()) { for (Interpreter intp : intpGroupForASession) { p.putAll(intp.getProperty()); } // it's okay to break here while every List<Interpreters> will have the same property set break; } return p; }
private static Properties addDeserializerToConfig( Properties properties, Deserializer<?> keyDeserializer, Deserializer<?> valueDeserializer) { Properties newProperties = new Properties(); newProperties.putAll(properties); if (keyDeserializer != null) newProperties.put( ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass().getName()); if (keyDeserializer != null) newProperties.put( ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass().getName()); return newProperties; }
public void writeProperties(Map<?, ?> properties) { Properties props = new Properties(); props.putAll(properties); try { FileOutputStream stream = new FileOutputStream(this); try { props.store(stream, "comment"); } finally { stream.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
Properties runProperties() { Properties props = new Properties(); props.putAll(this.properties); Properties sysProps = System.getProperties(); Set<String> names = sysProps.stringPropertyNames(); for (String name : names) { if (name.startsWith("jboss") || name.startsWith("wildfly") || name.startsWith("swarm")) { props.put(name, sysProps.get(name)); } } return props; }
@Override public Properties getProperties() throws IOException { if (properties == null) { Properties properties = new Properties(); ListIterator<Theme> itr = themes.listIterator(themes.size()); while (itr.hasPrevious()) { Properties p = itr.previous().getProperties(); if (p != null) { properties.putAll(p); } } this.properties = properties; return properties; } else { return properties; } }
/** * Get a PropertiesHolder that contains the actually visible properties for a Locale, after * merging all specified resource bundles. Either fetches the holder from the cache or freshly * loads it. * * <p>Only used when caching resource bundle contents forever, i.e. with cacheSeconds < 0. * Therefore, merged properties are always cached forever. */ protected PropertiesHolder getMergedPluginProperties(Locale locale) { PropertiesHolder mergedHolder = this.cachedMergedPluginProperties.get(locale); if (mergedHolder != null) { return mergedHolder; } Properties mergedProps = new Properties(); mergedHolder = new PropertiesHolder(mergedProps, -1); for (String basename : pluginBaseNames) { List filenames = calculateAllFilenames(basename, locale); for (int j = filenames.size() - 1; j >= 0; j--) { String filename = (String) filenames.get(j); PropertiesHolder propHolder = getProperties(filename); if (propHolder.getProperties() != null) { mergedProps.putAll(propHolder.getProperties()); } } } this.cachedMergedPluginProperties.put(locale, mergedHolder); return mergedHolder; }
public Object getService(Properties properties) throws ApiException { Object response = null; String key = (String) properties.get("key"); try { ApiService service = this.getApiCatalogManager().getApiService(key); if (null == service) { throw new ApiException( IApiErrorCodes.API_SERVICE_INVALID, "Service '" + key + "' does not exist"); } if (!service.isActive()) { throw new ApiException( IApiErrorCodes.API_SERVICE_ACTIVE_FALSE, "Service '" + key + "' is not active"); } this.checkServiceAuthorization(service, properties, true); Properties serviceParameters = new Properties(); serviceParameters.putAll(service.getParameters()); Iterator<Object> paramIter = properties.keySet().iterator(); List<String> reservedParameters = Arrays.asList(SystemConstants.API_RESERVED_PARAMETERS); while (paramIter.hasNext()) { Object paramName = paramIter.next(); String paramNameString = paramName.toString(); if (reservedParameters.contains(paramNameString) || service.isFreeParameter(paramNameString)) { serviceParameters.put(paramNameString, properties.get(paramName)); } } response = this.getResponseBuilder().createResponse(service.getMaster(), serviceParameters); } catch (ApiException e) { throw e; } catch (Throwable t) { ApsSystemUtils.logThrowable( t, this, "getService", "Error invocating service - key '" + key + "'"); throw new ApiException(IApiErrorCodes.SERVER_ERROR, "Internal error"); } return response; }
/** * Constructor. * * @param currencySymbol currency symbol * @param additionalDictionary additional descriptions * @param showResourceNotFoundWarning warn when no resource key not found * @param dateFormatSeparator date format separator; for example: '-' or '/' */ public NorwegianOnlyResourceFactory( String currencySymbol, Properties additionalDictionary, boolean showResourceNotFoundWarning, char dateFormatSeparator) { Properties dictionary = new Properties(); dictionary.putAll(additionalDictionary); // grid... dictionary.setProperty("of", "av"); dictionary.setProperty("page", "Side"); dictionary.setProperty("Remove Filter", "Fjern Filter"); dictionary.setProperty("This column is not sorteable", "Denne kolonnen kan ikke sorteres"); dictionary.setProperty("Sorting not allowed", "Sortering ikke tillatt"); dictionary.setProperty( "Maximum number of sorted columns", "Maksimalt antall av sorterte kolonner"); dictionary.setProperty("Sorting not applicable", "Sortering er ikke mulig"); dictionary.setProperty("Selected Row", "Valgt Rad"); dictionary.setProperty("Selected Rows", "Valgte Rader"); dictionary.setProperty( "Cancel changes and reload data?", "Avbryt Endringer og hent data på nytt?"); dictionary.setProperty("Attention", "Advarsel"); dictionary.setProperty("Loading data...", "Henter data..."); dictionary.setProperty("Error while loading data", "Feil under henting av data"); dictionary.setProperty("Loading Data Error", "Feil ved henting av data på nytt"); dictionary.setProperty("Delete Rows?", "Slett Rader?"); dictionary.setProperty("Delete Confirmation", "Slett Bekreftelse"); dictionary.setProperty("Error while deleting rows.", "Feil under sletting av rader."); dictionary.setProperty("Deleting Error", "Slette Feil"); dictionary.setProperty("Error while saving", "Feil under lagring"); dictionary.setProperty("Saving Error", "Lagrings Feil"); dictionary.setProperty("A mandatory column is empty.", "En obligatorisk kolonne er tom"); dictionary.setProperty("Value not valid", "Verdi er ikke gyldig"); dictionary.setProperty("sorting conditions", "Sorterings betingelser"); dictionary.setProperty("filtering conditions", "Filtrerings betingelser"); dictionary.setProperty( "filtering and sorting settings", "Filtrering and sorterings innstillinger"); dictionary.setProperty( "Filtering/Sorting data (CTRL+F)", "Filtrering/Sortering av data (CTRL+F)"); dictionary.setProperty("upload file", "Last opp File"); dictionary.setProperty("download file", "Last Ned File"); // export... dictionary.setProperty("grid export", "Tabell Eksport"); dictionary.setProperty("export", "Eksport"); dictionary.setProperty("exportmnemonic", "X"); dictionary.setProperty("column", "Kolonne"); dictionary.setProperty("sel.", "Velg"); dictionary.setProperty("you must select at least one column", "Du må velge minst en kolonne"); dictionary.setProperty("columns to export", "Kolonner for eksport"); dictionary.setProperty("export type", "Eksport format"); // import... dictionary.setProperty("grid import", "Tabell Import"); dictionary.setProperty("file to import", "File for å importere"); dictionary.setProperty("import", "Import"); dictionary.setProperty("importmnemonic", "M"); dictionary.setProperty("columns to import", "Kolonner for import"); dictionary.setProperty("import type", "Import format"); dictionary.setProperty("error while importing data", "Feil med import av data"); dictionary.setProperty("import completed", "Import ferdig."); // quick filter... dictionary.setProperty("To value", "Til verdi"); dictionary.setProperty("Filter by", "Filtrer ved"); dictionary.setProperty("From value", "Fra verdi"); dictionary.setProperty("equals", "lik"); dictionary.setProperty("contains", "inneholder"); dictionary.setProperty("starts with", "starter med"); dictionary.setProperty("ends with", "ender med"); // select/deselect all dictionary.setProperty("select all", "Velg alle"); dictionary.setProperty("deselect all", "Velg bort alle"); // copy/cut/paste dictionary.setProperty("copy", "Kopier"); dictionary.setProperty("copymnemonic", "K"); dictionary.setProperty("cut", "Kutt"); dictionary.setProperty("cutmnemonic", "U"); dictionary.setProperty("paste", "Lim inn"); dictionary.setProperty("pastemnemonic", "L"); // lookup... dictionary.setProperty("Code is not correct.", "Kode er ikke korrekt."); dictionary.setProperty("Code Validation", "Kode Validering"); dictionary.setProperty("Code Selection", "Kode Valg"); // form... dictionary.setProperty("Confirm deliting data?", "Bekreft sletting av data?"); dictionary.setProperty( "Error while saving: incorrect data.", "Feil under lagring: ukorrekte data."); dictionary.setProperty("Error while validating data:", "Feil under validering av data:"); dictionary.setProperty("Validation Error", "Validering feil"); dictionary.setProperty("Error on deleting:", "Feil under sletting:"); dictionary.setProperty("Error on Loading", "Feil under Henting"); dictionary.setProperty("Error while loading data:", "Feil under henting av data:"); dictionary.setProperty( "Error on setting value to the input control having the attribute name", "Feil ved setting av verdi for input kontroll med attributt navn"); // toolbar buttons... dictionary.setProperty("Delete record (CTRL+D)", "Slett post (CTRL+D)"); dictionary.setProperty("Edit record (CTRL+E)", "Editer post (CTRL+E)"); dictionary.setProperty("New record (CTRL+I)", "Ny post (CTRL+I)"); dictionary.setProperty( "Reload record/Cancel current operation (CTRL+Z)", "Hent post på nytt/Avbryt pågående operasjon (CTRL+Z)"); dictionary.setProperty("Save record (CTRL+S)", "Lagre post (CTRL+S)"); dictionary.setProperty("Copy record (CTRL+C)", "Kopier post (CTRL+C)"); dictionary.setProperty("Export record (CTRL+X)", "Eksporter poster (CTRL+X)"); dictionary.setProperty("Import records (CTRL+M)", "Importer poster (CTRL+M)"); dictionary.setProperty("Load the first block of records", "Hent første blokk of poster"); dictionary.setProperty("Select the previous row in grid", "Velg forrige rad i tabell"); dictionary.setProperty("Select the next row in grid", "Velg neste rad i tabell"); dictionary.setProperty("Load the previous block of records", "Last forrige blokk av poster"); dictionary.setProperty("Load the next block of records", "Hent neste blokk av poster"); dictionary.setProperty("Load the last block of records", "Hent den siste blokk av poster"); dictionary.setProperty("Insert", "Sett inn"); dictionary.setProperty("Edit", "Editer"); dictionary.setProperty("Copy", "Kopier"); dictionary.setProperty("Delete", "Slett"); dictionary.setProperty("Save", "Lagre"); dictionary.setProperty("Reload", "Hent"); dictionary.setProperty("Export", "Eksporter"); dictionary.setProperty("Filter", "Filter"); // MDI Frame... dictionary.setProperty("file", "File"); dictionary.setProperty("exit", "Avslutt"); dictionary.setProperty("filemnemonic", "F"); dictionary.setProperty("exitmnemonic", "A"); dictionary.setProperty("change user", "Endre Bruker"); dictionary.setProperty("changeusermnemonic", "U"); dictionary.setProperty("changelanguagemnemonic", "S"); dictionary.setProperty("help", "Hjelp"); dictionary.setProperty("about", "Om"); dictionary.setProperty("helpmnemonic", "H"); dictionary.setProperty("aboutmnemonic", "O"); dictionary.setProperty( "are you sure to quit application?", "Er du sikker på å avslutte program?"); dictionary.setProperty("quit application", "Avslutt program"); dictionary.setProperty("forcegcmnemonic", "T"); dictionary.setProperty("Force GC", "Tving GC"); dictionary.setProperty("Java Heap", "Java Minne"); dictionary.setProperty("used", "brukt"); dictionary.setProperty("allocated", "allokert"); dictionary.setProperty("change language", "Endre Språk"); dictionary.setProperty("changemnemonic", "S"); dictionary.setProperty("cancelmnemonic", "A"); dictionary.setProperty("cancel", "Avbryt"); dictionary.setProperty("yes", "Ja"); dictionary.setProperty("no", "Nei"); dictionary.setProperty("Functions", "Funksjoner"); dictionary.setProperty("Error while executing function", "Feil under eksekvering av funksjon"); dictionary.setProperty("Error", "Feil"); dictionary.setProperty("infoPanel", "Info"); dictionary.setProperty("imageButton", "Om"); dictionary.setProperty("Window", "Vindu"); dictionary.setProperty("windowmnemonic", "V"); dictionary.setProperty("Close All", "Lukk Alt"); dictionary.setProperty("closeallmnemonic", "A"); dictionary.setProperty("closemnemonic", "A"); dictionary.setProperty("Press ENTER to find function", "Trykk ENTER for å finne funksjon"); dictionary.setProperty("Find Function", "Finn Funksjon"); dictionary.setProperty("Operation in progress...", "Operasjon under utførelse..."); dictionary.setProperty("close window", "Lukk Vindu"); dictionary.setProperty("reduce to icon", "Reduser til ikon"); dictionary.setProperty("save changes?", "Lagre endringer?"); dictionary.setProperty("confirm window closing", "Bekreft stenging av vindu"); dictionary.setProperty("change background", "Endre bakgrunn"); dictionary.setProperty("reset background", "Tibakestill bakgrunn"); dictionary.setProperty("switch", "Bytt"); dictionary.setProperty("switchmnemonic", "S"); dictionary.setProperty("window name", "Vindu navn"); dictionary.setProperty("opened windows", "Åpne vinduer"); dictionary.setProperty("tile horizontally", "Ordne horisontalt"); dictionary.setProperty("tilehorizontallymnemonic", "H"); dictionary.setProperty("tile vertically", "Ordne vertikalt"); dictionary.setProperty("tileverticallymnemonic", "V"); dictionary.setProperty("cascade", "Overlappe"); dictionary.setProperty("cascademnemonic", "C"); dictionary.setProperty("minimize", "Minimer"); dictionary.setProperty("minimizemnemonic", "M"); dictionary.setProperty("minimize all", "Minimer alle"); dictionary.setProperty("minimizeallmnemonic", "A"); // server... dictionary.setProperty("Client request not supported", "Klient forespørsel ikke tillatt"); dictionary.setProperty("User disconnected", "Bruker frakoblet"); dictionary.setProperty( "Updating not performed: the record was previously updated.", "Oppdatering ikke utført: posten har blitt oppdatert tidligere."); // wizard... dictionary.setProperty("back", "Tilbake"); dictionary.setProperty("next", "Neste"); dictionary.setProperty("finish", "Ferdig"); // image panel... dictionary.setProperty("image selection", "Bilde valg"); // tip of the day panel... dictionary.setProperty( "show 'tip of the day' after launching", "Vis 'dagens tips' etter oppstart"); dictionary.setProperty("previous tip", "Forrige tips"); dictionary.setProperty("next tip", "Neste tips"); dictionary.setProperty("close", "Lukk"); dictionary.setProperty("tip of the day", "Dagens tips"); dictionary.setProperty("select tip", "Velg tip"); dictionary.setProperty("tip name", "Tips navn"); dictionary.setProperty("tips list", "Tips list"); // progress panel... dictionary.setProperty("progress", "Framdrift"); // licence agreement... dictionary.setProperty( "i accept the terms in the licence agreement", "Jeg aksepteter lisensbetingelsene"); dictionary.setProperty("ok", "Ok"); dictionary.setProperty( "i do not accept the terms in the licence agreement", "Jeg aksepteter ikke lisensbetingelsene"); // property grid control dictionary.setProperty("property name", "Navn"); dictionary.setProperty("property value", "Verdi"); // grid profile dictionary.setProperty("grid profile management", "Tabell profil administrasjon"); dictionary.setProperty( "restore default grid profile", "Tilbakestill til standard tabell profil"); dictionary.setProperty("create new grid profile", "Opprett ny tabell profil"); dictionary.setProperty("profile description", "Profil beskrivelse"); dictionary.setProperty("remove current grid profile", "Fjern nåværende tabell profil"); dictionary.setProperty("select grid profile", "Velg tabell profil"); dictionary.setProperty("default profile", "Standard profil"); // search box dictionary.setProperty("search", "Søk"); dictionary.setProperty("not found", "Ikke funnet"); // drag... dictionary.setProperty("drag", "Dra"); dictionary.setProperty("Caps lock pressed", "Caps lock trykkes"); // pivot table... dictionary.setProperty("pivot table settings", "Pivot tabell innstillinger"); dictionary.setProperty("row fields", "Rad felter"); dictionary.setProperty("column fields", "Kolonne felt"); dictionary.setProperty("data fields", "Data felter"); dictionary.setProperty("filtering conditions", "Filtrerings betingeler"); dictionary.setProperty("field", "Felt"); dictionary.setProperty("checked", "Kontrollert"); dictionary.setProperty( "at least one data field must be selected", "Minst et datafelt må bli valgt."); dictionary.setProperty("at least one row field must be selected", "Minst en rad må bli valgt."); dictionary.setProperty( "at least one column field must be selected", "Minst en kolonne må bli valgt."); dictionary.setProperty("expand all", "Ekspandere alle"); dictionary.setProperty("collapse all", "Kollapse alle"); dictionary.setProperty(Consts.EQ, "Equals to"); dictionary.setProperty(Consts.GE, "Greater or equals to"); dictionary.setProperty(Consts.GT, "Greater than"); dictionary.setProperty(Consts.IS_NOT_NULL, "Is filled"); dictionary.setProperty(Consts.IS_NULL, "Is not filled"); dictionary.setProperty(Consts.LE, "Less or equals to"); dictionary.setProperty(Consts.LIKE, "Contains"); dictionary.setProperty(Consts.LT, "Less than"); dictionary.setProperty(Consts.NEQ, "Not equals to"); dictionary.setProperty(Consts.IN, "Contains values"); dictionary.setProperty(Consts.ASC_SORTED, "Ascending"); dictionary.setProperty(Consts.DESC_SORTED, "Descending"); dictionary.setProperty(Consts.NOT_IN, "Not contains values"); resources = new Resources( dictionary, currencySymbol, '.', ',', Resources.DMY, true, dateFormatSeparator, "HH:mm", "NO", showResourceNotFoundWarning); }
public Properties toProperties() { Properties props = new Properties(); props.putAll(this); return props; }
private static Properties readOneConfigurationFile(String filename) { Properties propsFromFile = null; VirtualFile appRoot = VirtualFile.open(applicationPath); VirtualFile conf = appRoot.child("conf/" + filename); if (confs.contains(conf)) { throw new RuntimeException( "Detected recursive @include usage. Have seen the file " + filename + " before"); } try { propsFromFile = IO.readUtf8Properties(conf.inputstream()); } catch (RuntimeException e) { if (e.getCause() instanceof IOException) { Logger.fatal("Cannot read " + filename); fatalServerErrorOccurred(); } } confs.add(conf); // OK, check for instance specifics configuration Properties newConfiguration = new OrderSafeProperties(); Pattern pattern = Pattern.compile("^%([a-zA-Z0-9_\\-]+)\\.(.*)$"); for (Object key : propsFromFile.keySet()) { Matcher matcher = pattern.matcher(key + ""); if (!matcher.matches()) { newConfiguration.put(key, propsFromFile.get(key).toString().trim()); } } for (Object key : propsFromFile.keySet()) { Matcher matcher = pattern.matcher(key + ""); if (matcher.matches()) { String instance = matcher.group(1); if (instance.equals(id)) { newConfiguration.put(matcher.group(2), propsFromFile.get(key).toString().trim()); } } } propsFromFile = newConfiguration; // Resolve ${..} pattern = Pattern.compile("\\$\\{([^}]+)}"); for (Object key : propsFromFile.keySet()) { String value = propsFromFile.getProperty(key.toString()); Matcher matcher = pattern.matcher(value); StringBuffer newValue = new StringBuffer(100); while (matcher.find()) { String jp = matcher.group(1); String r; if (jp.equals("application.path")) { r = Play.applicationPath.getAbsolutePath(); } else if (jp.equals("play.path")) { r = Play.frameworkPath.getAbsolutePath(); } else { r = System.getProperty(jp); if (r == null) { r = System.getenv(jp); } if (r == null) { Logger.warn("Cannot replace %s in configuration (%s=%s)", jp, key, value); continue; } } matcher.appendReplacement(newValue, r.replaceAll("\\\\", "\\\\\\\\")); } matcher.appendTail(newValue); propsFromFile.setProperty(key.toString(), newValue.toString()); } // Include Map<Object, Object> toInclude = new HashMap<Object, Object>(16); for (Object key : propsFromFile.keySet()) { if (key.toString().startsWith("@include.")) { try { String filenameToInclude = propsFromFile.getProperty(key.toString()); toInclude.putAll(readOneConfigurationFile(filenameToInclude)); } catch (Exception ex) { Logger.warn("Missing include: %s", key); } } } propsFromFile.putAll(toInclude); return propsFromFile; }
private BuildResult doRun( final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) { // Capture the current state of things that we will change during execution InputStream originalStdIn = System.in; Properties originalSysProperties = new Properties(); originalSysProperties.putAll(System.getProperties()); File originalUserDir = new File(originalSysProperties.getProperty("user.dir")); Map<String, String> originalEnv = new HashMap<String, String>(System.getenv()); // Augment the environment for the execution System.setIn(getStdin()); processEnvironment.maybeSetProcessDir(getWorkingDir()); for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) { processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue()); } Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties(); System.getProperties().putAll(implicitJvmSystemProperties); DefaultStartParameter parameter = new DefaultStartParameter(); parameter.setCurrentDir(getWorkingDir()); parameter.setShowStacktrace(ShowStacktrace.ALWAYS); CommandLineParser parser = new CommandLineParser(); DefaultCommandLineConverter converter = new DefaultCommandLineConverter(); converter.configure(parser); ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs()); BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine); Map<String, String> properties = new HashMap<String, String>(); new LayoutToPropertiesConverter().convert(layout, properties); converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties); new PropertiesToStartParameterConverter().convert(properties, parameter); converter.convert(parsedCommandLine, parameter); DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled( new Factory<DefaultGradleLauncherFactory>() { public DefaultGradleLauncherFactory create() { return (DefaultGradleLauncherFactory) GradleLauncher.getFactory(); } }); factory.addListener(listener); GradleLauncher gradleLauncher = factory.newInstance(parameter); gradleLauncher.addStandardOutputListener(outputListener); gradleLauncher.addStandardErrorListener(errorListener); try { return gradleLauncher.run(); } finally { // Restore the environment System.setProperties(originalSysProperties); processEnvironment.maybeSetProcessDir(originalUserDir); for (String envVar : getEnvironmentVars().keySet()) { String oldValue = originalEnv.get(envVar); if (oldValue != null) { processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue); } else { processEnvironment.maybeRemoveEnvironmentVariable(envVar); } } factory.removeListener(listener); System.setIn(originalStdIn); } }