use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.
the class DeleteNamespaceCommand method doTableOp.
protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception {
boolean resetContext = false;
String currentTable = shellState.getTableName();
NamespaceId namespaceId = Namespaces.getNamespaceId(shellState.getContext(), namespace);
List<String> tables = Namespaces.getTableNames(shellState.getContext(), namespaceId);
resetContext = tables.contains(currentTable);
if (force)
for (String table : shellState.getAccumuloClient().tableOperations().list()) if (table.startsWith(namespace + "."))
shellState.getAccumuloClient().tableOperations().delete(table);
shellState.getAccumuloClient().namespaceOperations().delete(namespace);
if (resetContext) {
shellState.setTableName("");
}
}
use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.
the class RenameNamespaceCommand method execute.
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException {
String old = cl.getArgs()[0];
String newer = cl.getArgs()[1];
boolean resetContext = false;
TableId currentTableId = null;
if (shellState.getTableName() != null && !shellState.getTableName().isEmpty()) {
NamespaceId namespaceId = Namespaces.getNamespaceId(shellState.getContext(), old);
List<TableId> tableIds = Namespaces.getTableIds(shellState.getContext(), namespaceId);
currentTableId = shellState.getContext().getTableId(shellState.getTableName());
resetContext = tableIds.contains(currentTableId);
}
shellState.getAccumuloClient().namespaceOperations().rename(old, newer);
if (resetContext) {
shellState.setTableName(shellState.getContext().getTableName(currentTableId));
}
return 0;
}
use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.
the class ClientServiceHandler method getNamespaceConfiguration.
@Override
public Map<String, String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException {
NamespaceId namespaceId;
try {
namespaceId = Namespaces.getNamespaceId(context, ns);
} catch (NamespaceNotFoundException e) {
String why = "Could not find namespace while getting configuration.";
throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why);
}
AccumuloConfiguration config = context.getNamespaceConfiguration(namespaceId);
return conf(credentials, config);
}
use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.
the class ClientServiceHandler method revokeTablePermission.
@Override
public void revokeTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException {
TableId tableId = checkTableId(context, tableName, TableOperation.PERMISSION);
NamespaceId namespaceId;
try {
namespaceId = context.getNamespaceId(tableId);
} catch (TableNotFoundException e) {
throw new TException(e);
}
security.revokeTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId);
}
use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.
the class ClientServiceHandler method grantNamespacePermission.
@Override
public void grantNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException {
NamespaceId namespaceId = checkNamespaceId(context, ns, TableOperation.PERMISSION);
security.grantNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission));
}
Aggregations