private void printSystemConfiguration(File outputDirectory) throws IOException { TreeMap<String,String> conf = new TreeMap<>(); TreeMap<String,String> site = new TreeMap<>(siteConfig); for (Entry<String,String> prop : site.entrySet()) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (!prop.getValue().equals(defaultValue) && !systemConfig.containsKey(prop.getKey())) { conf.put(prop.getKey(), prop.getValue()); } } TreeMap<String,String> system = new TreeMap<>(systemConfig); for (Entry<String,String> prop : system.entrySet()) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (!prop.getValue().equals(defaultValue)) { conf.put(prop.getKey(), prop.getValue()); } } File siteBackup = new File(outputDirectory, ACCUMULO_SITE_BACKUP_FILE); try (FileWriter fw = new FileWriter(siteBackup)) { for (Entry<String,String> prop : conf.entrySet()) { fw.write(prop.getKey() + "=" + prop.getValue() + "\n"); } } }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") private void printNameSpaceConfiguration(AccumuloClient accumuloClient, String namespace, File outputDirectory) throws IOException, AccumuloException, AccumuloSecurityException, NamespaceNotFoundException { File namespaceScript = new File(outputDirectory, namespace + NS_FILE_SUFFIX); FileWriter nsWriter = new FileWriter(namespaceScript); nsWriter.write(createNsFormat.format(new String[] {namespace})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : accumuloClient.namespaceOperations().getProperties(namespace)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> entry : props.entrySet()) { String defaultValue = getDefaultConfigValue(entry.getKey()); if (defaultValue == null || !defaultValue.equals(entry.getValue())) { if (!entry.getValue().equals(siteConfig.get(entry.getKey())) && !entry.getValue().equals(systemConfig.get(entry.getKey()))) { nsWriter.write(nsConfigFormat .format(new String[] {namespace, entry.getKey() + "=" + entry.getValue()})); } } } nsWriter.close(); }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") private void printTableConfiguration(AccumuloClient accumuloClient, String tableName, File outputDirectory) throws AccumuloException, TableNotFoundException, IOException { File tableBackup = new File(outputDirectory, tableName + ".cfg"); FileWriter writer = new FileWriter(tableBackup); writer.write(createTableFormat.format(new String[] {tableName})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : accumuloClient.tableOperations().getProperties(tableName)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> prop : props.entrySet()) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (defaultValue == null || !defaultValue.equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { writer.write(configFormat .format(new String[] {tableName, prop.getKey() + "=" + prop.getValue()})); } } } } writer.close(); } }
private void printSystemConfiguration(Connector connector, File outputDirectory) throws IOException, AccumuloException, AccumuloSecurityException { Configuration conf = new Configuration(false); TreeMap<String,String> site = new TreeMap<>(siteConfig); for (Entry<String,String> prop : site.entrySet()) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (!prop.getValue().equals(defaultValue) && !systemConfig.containsKey(prop.getKey())) { conf.set(prop.getKey(), prop.getValue()); } } TreeMap<String,String> system = new TreeMap<>(systemConfig); for (Entry<String,String> prop : system.entrySet()) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (!prop.getValue().equals(defaultValue)) { conf.set(prop.getKey(), prop.getValue()); } } File siteBackup = new File(outputDirectory, ACCUMULO_SITE_BACKUP_FILE); FileOutputStream fos = new FileOutputStream(siteBackup); try { conf.writeXml(fos); } finally { fos.close(); } }
private void printNameSpaceConfiguration(Connector connector, String namespace, File outputDirectory) throws IOException, AccumuloException, AccumuloSecurityException, NamespaceNotFoundException { File namespaceScript = new File(outputDirectory, namespace + NS_FILE_SUFFIX); FileWriter nsWriter = new FileWriter(namespaceScript); nsWriter.write(createNsFormat.format(new String[] {namespace})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : connector.namespaceOperations().getProperties(namespace)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> entry : props.entrySet()) { String defaultValue = getDefaultConfigValue(entry.getKey()); if (defaultValue == null || !defaultValue.equals(entry.getValue())) { if (!entry.getValue().equals(siteConfig.get(entry.getKey())) && !entry.getValue().equals(systemConfig.get(entry.getKey()))) { nsWriter.write(nsConfigFormat .format(new String[] {namespace, entry.getKey() + "=" + entry.getValue()})); } } } nsWriter.close(); }
private void printTableConfiguration(Connector connector, String tableName, File outputDirectory) throws AccumuloException, TableNotFoundException, IOException, AccumuloSecurityException { File tableBackup = new File(outputDirectory, tableName + ".cfg"); FileWriter writer = new FileWriter(tableBackup); writer.write(createTableFormat.format(new String[] {tableName})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : connector.tableOperations().getProperties(tableName)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> prop : props.entrySet()) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (defaultValue == null || !defaultValue.equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { writer.write(configFormat .format(new String[] {tableName, prop.getKey() + "=" + prop.getValue()})); } } } } writer.close(); } }