use of org.hsqldb_voltpatches.lib.Iterator 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;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class ScriptWriterBase method writeExistingData.
protected void writeExistingData() throws IOException {
// start with blank schema - SET SCHEMA to log
currentSession.loggedSchema = null;
Iterator schemas = database.schemaManager.allSchemaNameIterator();
while (schemas.hasNext()) {
String schema = (String) schemas.next();
Iterator tables = database.schemaManager.databaseObjectIterator(schema, SchemaObject.TABLE);
while (tables.hasNext()) {
Table t = (Table) tables.next();
// write all memory table data
// write cached table data unless index roots have been written
// write all text table data apart from readonly text tables
// unless index roots have been written
boolean script = false;
switch(t.getTableType()) {
case TableBase.MEMORY_TABLE:
script = true;
break;
case TableBase.CACHED_TABLE:
script = includeCachedData;
break;
case TableBase.TEXT_TABLE:
script = includeCachedData && !t.isReadOnly();
break;
}
try {
if (script) {
schemaToLog = t.getName().schema;
writeTableInit(t);
RowIterator it = t.rowIterator(currentSession);
while (it.hasNext()) {
writeRow(currentSession, t, it.getNextRow().getData());
}
writeTableTerm(t);
}
} catch (Exception e) {
throw Error.error(ErrorCode.FILE_IO_ERROR, e.toString());
}
}
}
writeDataTerm();
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class GranteeManager method removeDbObjects.
public void removeDbObjects(OrderedHashSet nameSet) {
Iterator it = nameSet.iterator();
while (it.hasNext()) {
HsqlName name = (HsqlName) it.next();
for (int i = 0; i < map.size(); i++) {
Grantee g = (Grantee) map.get(i);
g.revokeDbObject(name);
}
}
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class GranteeManager method getRightstSQL.
public String[] getRightstSQL() {
HsqlArrayList list = new HsqlArrayList();
Iterator grantees = getGrantees().iterator();
while (grantees.hasNext()) {
Grantee grantee = (Grantee) grantees.next();
String name = grantee.getNameString();
// _SYSTEM user, DBA Role grants not persisted
if (GranteeManager.isImmutable(name)) {
continue;
}
HsqlArrayList subList = grantee.getRightsSQL();
list.addAll(subList);
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class GranteeManager method getSQL.
public String[] getSQL() {
HsqlArrayList list = new HsqlArrayList();
// roles
Iterator it = getRoles().iterator();
while (it.hasNext()) {
Grantee grantee = (Grantee) it.next();
// ADMIN_ROLE_NAME is not persisted
if (!GranteeManager.isReserved(grantee.getNameString())) {
list.add(grantee.getSQL());
}
}
// users
it = getGrantees().iterator();
for (; it.hasNext(); ) {
Grantee grantee = (Grantee) it.next();
if (grantee instanceof User) {
list.add(grantee.getSQL());
}
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
Aggregations