mirror of https://github.com/apache/cassandra
replace ad-hoc checks in update/set keyspace with ThriftValidation.validateTable
patch by jbellis git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1032693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8499625733
commit
7a98d7bd2c
|
|
@ -815,13 +815,11 @@ public class CassandraServer implements Cassandra.Iface
|
|||
public String system_update_keyspace(KsDef ks_def) throws InvalidRequestException, TException
|
||||
{
|
||||
state().hasKeyspaceListAccess(Permission.WRITE);
|
||||
|
||||
|
||||
ThriftValidation.validateTable(ks_def.name);
|
||||
if (ks_def.getCf_defs() != null && ks_def.getCf_defs().size() > 0)
|
||||
throw new InvalidRequestException("Keyspace update must not contain any column family definitions.");
|
||||
|
||||
if (DatabaseDescriptor.getTableDefinition(ks_def.name) == null)
|
||||
throw new InvalidRequestException("Keyspace does not exist.");
|
||||
|
||||
try
|
||||
{
|
||||
KSMetaData ksm = new KSMetaData(
|
||||
|
|
@ -935,11 +933,8 @@ public class CassandraServer implements Cassandra.Iface
|
|||
|
||||
public void set_keyspace(String keyspace) throws InvalidRequestException, TException
|
||||
{
|
||||
if (DatabaseDescriptor.getTableDefinition(keyspace) == null)
|
||||
{
|
||||
throw new InvalidRequestException("Keyspace does not exist");
|
||||
}
|
||||
|
||||
ThriftValidation.validateTable(keyspace);
|
||||
|
||||
state().setKeyspace(keyspace);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ public class ThriftValidation
|
|||
}
|
||||
}
|
||||
|
||||
private static void validateTable(String tablename) throws KeyspaceNotDefinedException
|
||||
public static void validateTable(String tablename) throws KeyspaceNotDefinedException
|
||||
{
|
||||
if (!DatabaseDescriptor.getTables().contains(tablename))
|
||||
{
|
||||
throw new KeyspaceNotDefinedException("Keyspace " + tablename + " does not exist in this schema.");
|
||||
throw new KeyspaceNotDefinedException("Keyspace " + tablename + " does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue