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(Tokens.T_TABLE).append(' ');
sb.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(Tokens.T_SEQUENCE).append(' ');
sb.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(Tokens.T_DOMAIN).append(' ');
sb.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(Tokens.T_TYPE).append(' ');
sb.append(
hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.PROCEDURE :
case SchemaObject.FUNCTION :
case SchemaObject.SPECIFIC_ROUTINE :
SchemaObject routine =
(SchemaObject) granteeManager.database
.schemaManager
.findSchemaObject(hsqlname.name,
hsqlname.schema.name,
hsqlname.type);
if (routine != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_EXECUTE).append(' ');
sb.append(Tokens.T_ON).append(' ');
sb.append(Tokens.T_SPECIFIC).append(' ');
if (routine.getType() == SchemaObject.PROCEDURE) {
sb.append(Tokens.T_PROCEDURE);
} else {
sb.append(Tokens.T_FUNCTION);
}
sb.append(' ');
sb.append(
hsqlname.getSchemaQualifiedStatementName());
}
break;
}
if (sb.length() == 0) {