private static void mergeExtraOptions(PropertiesConfiguration baseOptions, PropertiesConfiguration extraOptions) { if (isNull(extraOptions) || extraOptions.size() == 0) { return; } trace("loadOptions: have to merge extra Options"); Iterator<String> allKeys = extraOptions.getKeys(); while (allKeys.hasNext()) { String key = allKeys.next(); if ("sxversion".equals(key)) { baseOptions.setProperty("sxversion_saved", extraOptions.getProperty(key)); continue; } if ("sxbuild".equals(key)) { baseOptions.setProperty("sxbuild_saved", extraOptions.getProperty(key)); continue; } Object value = baseOptions.getProperty(key); if (isNull(value)) { baseOptions.addProperty(key, extraOptions.getProperty(key)); trace("Option added: %s", key); } else { Object extraValue = extraOptions.getProperty(key); if (!value.getClass().getName().equals(extraValue.getClass().getName()) || !value.toString().equals(extraValue.toString())) { baseOptions.setProperty(key, extraValue); trace("Option changed: %s = %s", key, extraValue); } } } }
private void writeNLP(final String name, final boolean zipConfig, final String projectVersion, final String productVersion) throws IOException { File nlp = new File(nlProjectFolder, name + ".nlp"); if (!nlp.exists() && !nlp.createNewFile()) { logger.error("Error, cannot create the NLP file"); } if (!nlp.isFile()) { throw new IllegalArgumentException("NLP file must be a file"); } PropertiesConfiguration nlpProperties = new PropertiesConfiguration(); nlpProperties.getLayout().setGlobalSeparator("="); nlpProperties.addProperty("project.name", name); nlpProperties.addProperty("project.version", projectVersion); nlpProperties.addProperty("project.original.version", projectVersion); nlpProperties.addProperty("product.name", "NeoLoad"); nlpProperties.addProperty("product.original.name", "NeoLoad"); nlpProperties.addProperty("product.version", productVersion); nlpProperties.addProperty("product.original.version", productVersion); nlpProperties.addProperty("project.id", UUID.randomUUID().toString()); nlpProperties.addProperty("project.config.path", zipConfig ? CONFIG_ZIP : CONFIG_FOLDER); nlpProperties.addProperty("project.config.storage", zipConfig ? "ZIP" : "FOLDER"); nlpProperties.addProperty("team.server.enabled", "false"); try (final Writer out = new FileWriter(nlp)) { nlpProperties.setHeader("Project description file"); nlpProperties.write(out); } catch (ConfigurationException e) { logger.error("Error while saving NLP file", e); } }
void addNewUser(String username, String hash, String... roles) throws Exception { if (userConfig.getString(username) != null) { throw new IllegalArgumentException("User already exist: " + username); } userConfig.addProperty(username, hash); addRoles(username, roles); }
void addNewUser(String username, String hash, String... roles) throws Exception { if (userConfig.getString(username) != null) { throw new IllegalArgumentException("User already exist: " + username); } userConfig.addProperty(username, hash); addRoles(username, roles); }
roleConfig.clearProperty(entry.getA()); if (entry.getB().size() > 0) { roleConfig.addProperty(entry.getA(), entry.getB());
roleConfig.clearProperty(entry.getA()); if (entry.getB().size() > 0) { roleConfig.addProperty(entry.getA(), entry.getB());