@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(); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException, ClassNotFoundException, NamespaceExistsException, NamespaceNotFoundException { if (createNamespaceOptCopyConfig == null) { getOptions(); } String namespace = cl.getArgs()[0]; shellState.getAccumuloClient().namespaceOperations().create(namespace); // Copy options if flag was set Iterable<Entry<String,String>> configuration = null; if (cl.hasOption(createNamespaceOptCopyConfig.getOpt())) { String copy = cl.getOptionValue(createNamespaceOptCopyConfig.getOpt()); if (shellState.getAccumuloClient().namespaceOperations().exists(namespace)) { configuration = shellState.getAccumuloClient().namespaceOperations().getProperties(copy); } } if (configuration != null) { for (Entry<String,String> entry : configuration) { if (Property.isValidTablePropertyKey(entry.getKey())) { shellState.getAccumuloClient().namespaceOperations().setProperty(namespace, entry.getKey(), entry.getValue()); } } } return 0; }
try { tableProps = shellState.getAccumuloClient().namespaceOperations() .getProperties(OptUtil.getNamespaceOpt(cl, shellState)); } catch (NamespaceNotFoundException e) { throw new IllegalArgumentException(e);
shellState.getContext(), Tables.getTableId(shellState.getContext(), tableName))); for (Entry<String,String> e : shellState.getAccumuloClient().namespaceOperations() .getProperties(n)) { namespaceConfig.put(e.getKey(), e.getValue()); acuconf = shellState.getAccumuloClient().tableOperations().getProperties(tableName); } else if (namespace != null) { acuconf = shellState.getAccumuloClient().namespaceOperations().getProperties(namespace);
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(); }
@Override public Map<String,String> getNamespaceProperties(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException { try { Map<String,String> props = new HashMap<>(); for (Map.Entry<String,String> entry : getConnector(login).namespaceOperations() .getProperties(namespaceName)) { props.put(entry.getKey(), entry.getValue()); } return props; } catch (Exception e) { handleExceptionNNF(e); return null; } }
private boolean checkHasProperty(String name, String propKey, String propVal, boolean nameIsTable) { try { Iterable<Entry<String,String>> iterable = nameIsTable ? c.tableOperations().getProperties(name) : c.namespaceOperations().getProperties(name); for (Entry<String,String> e : iterable) if (propKey.equals(e.getKey())) return propVal.equals(e.getValue()); return false; } catch (Exception e) { fail(); return false; } }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException, ClassNotFoundException, NamespaceExistsException, NamespaceNotFoundException { if (createNamespaceOptCopyConfig == null) { getOptions(); } String namespace = cl.getArgs()[0]; shellState.getConnector().namespaceOperations().create(namespace); // Copy options if flag was set Iterable<Entry<String,String>> configuration = null; if (cl.hasOption(createNamespaceOptCopyConfig.getOpt())) { String copy = cl.getOptionValue(createNamespaceOptCopyConfig.getOpt()); if (shellState.getConnector().namespaceOperations().exists(namespace)) { configuration = shellState.getConnector().namespaceOperations().getProperties(copy); } } if (configuration != null) { for (Entry<String,String> entry : configuration) { if (Property.isValidTablePropertyKey(entry.getKey())) { shellState.getConnector().namespaceOperations().setProperty(namespace, entry.getKey(), entry.getValue()); } } } return 0; }
shellState.getInstance(), Tables.getTableId(shellState.getInstance(), tableName))); for (Entry<String,String> e : shellState.getConnector().namespaceOperations() .getProperties(n)) { namespaceConfig.put(e.getKey(), e.getValue()); acuconf = shellState.getConnector().tableOperations().getProperties(tableName); } else if (namespace != null) { acuconf = shellState.getConnector().namespaceOperations().getProperties(namespace);
try { tableProps = shellState.getConnector().namespaceOperations() .getProperties(OptUtil.getNamespaceOpt(cl, shellState)); } catch (NamespaceNotFoundException e) { throw new IllegalArgumentException(e);
break; case 5: ops.getProperties(namespace); fail(); break;
loginAs(rootUser); if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || map(root_conn.namespaceOperations().getProperties(namespace)) .get(Property.TABLE_BLOOM_ERRORRATE.getKey()).equals("003.14159%")) throw e; loginAs(rootUser); if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !map(root_conn.namespaceOperations().getProperties(namespace)) .get(Property.TABLE_BLOOM_ERRORRATE.getKey()).equals("003.14159%")) throw e;
Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%"); loginAs(rootUser); Map<String,String> propies = map(root_conn.namespaceOperations().getProperties(namespace)); if (!propies.get(Property.TABLE_BLOOM_ERRORRATE.getKey()).equals("003.14159%")) throw new IllegalStateException("Should be able to set a table property"); Property.TABLE_BLOOM_ERRORRATE.getKey()); loginAs(rootUser); propies = map(root_conn.namespaceOperations().getProperties(namespace)); if (propies.get(Property.TABLE_BLOOM_ERRORRATE.getKey()).equals("003.14159%")) throw new IllegalStateException("Should be able to remove a table property");