use of org.hsqldb_voltpatches.lib.MultiValueHashMap in project voltdb by VoltDB.
the class Grantee method getRightsSQL.
public HsqlArrayList getRightsSQL() {
HsqlArrayList list = new HsqlArrayList();
String roleString = getDirectRolesAsString();
if (roleString.length() != 0) {
list.add("GRANT " + roleString + " TO " + getStatementName());
}
MultiValueHashMap rightsMap = getRights();
Iterator dbObjects = rightsMap.keySet().iterator();
while (dbObjects.hasNext()) {
Object nameObject = dbObjects.next();
Iterator rights = rightsMap.get(nameObject);
while (rights.hasNext()) {
Right right = (Right) rights.next();
StringBuffer sb = new StringBuffer(128);
HsqlName hsqlname = (HsqlName) nameObject;
switch(hsqlname.type) {
case SchemaObject.TABLE:
case SchemaObject.VIEW:
Table table = granteeManager.database.schemaManager.findUserTable(null, hsqlname.name, hsqlname.schema.name);
if (table != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(right.getTableRightsSQL(table));
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("TABLE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.SEQUENCE:
NumberSequence sequence = (NumberSequence) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.SEQUENCE);
if (sequence != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("SEQUENCE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.DOMAIN:
Type domain = (Type) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.DOMAIN);
if (domain != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("DOMAIN ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.TYPE:
Type type = (Type) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.DOMAIN);
if (type != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("TYPE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
}
if (sb.length() == 0) {
continue;
}
sb.append(' ').append(Tokens.T_TO).append(' ');
sb.append(getStatementName());
list.add(sb.toString());
}
}
return list;
}
Aggregations