use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class Schema method getTriggerSQL.
public String[] getTriggerSQL() {
HsqlArrayList list = new HsqlArrayList();
Iterator it = tableLookup.map.values().iterator();
while (it.hasNext()) {
Table table = (Table) it.next();
String[] ddl = table.getTriggerSQL();
list.addAll(ddl);
}
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 Grantee method addToFullRights.
/**
* Full or partial rights are added to existing
*/
void addToFullRights(HashMap map) {
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Right add = (Right) map.get(key);
Right existing = (Right) fullRightsMap.get(key);
if (existing == null) {
existing = add.duplicate();
fullRightsMap.put(key, existing);
} else {
existing.add(add);
}
if (add.grantableRights == null) {
continue;
}
if (existing.grantableRights == null) {
existing.grantableRights = add.grantableRights.duplicate();
} else {
existing.grantableRights.add(add.grantableRights);
}
}
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class Grantee method getAllDirectPrivileges.
public OrderedHashSet getAllDirectPrivileges(SchemaObject object) {
if (object.getOwner() == this) {
OrderedHashSet set = new OrderedHashSet();
set.add(ownerRights);
return set;
}
Iterator rights = directRightsMap.get(object.getName());
if (rights.hasNext()) {
OrderedHashSet set = new OrderedHashSet();
while (rights.hasNext()) {
set.add(rights.next());
}
return set;
}
return Right.emptySet;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class Grantee method grant.
/**
* Grants the specified rights on the specified database object. <p>
*
* Keys stored in rightsMap for database tables are their HsqlName
* attribute. This allows rights to persist when a table is renamed. <p>
*/
void grant(SchemaObject object, Right right, Grantee grantor, boolean withGrant) {
final HsqlName name = object.getName();
final Right grantableRights = grantor.getAllGrantableRights(object);
Right existingRight = null;
if (right == Right.fullRights) {
if (grantableRights.isEmpty()) {
// has no rights
return;
}
right = grantableRights;
} else {
if (!grantableRights.contains(right)) {
throw Error.error(ErrorCode.X_0L000);
}
}
Iterator it = directRightsMap.get(name);
while (it.hasNext()) {
Right existing = (Right) it.next();
if (existing.grantor == grantor) {
existingRight = existing;
existingRight.add(right);
break;
}
}
if (existingRight == null) {
existingRight = right.duplicate();
existingRight.grantor = grantor;
existingRight.grantee = this;
directRightsMap.put(name, existingRight);
}
if (withGrant) {
if (existingRight.grantableRights == null) {
existingRight.grantableRights = right.duplicate();
} else {
existingRight.grantableRights.add(right);
}
}
if (!grantor.isSystem) {
// based on assumption that there is no need to access
grantor.grantedRightsMap.put(name, existingRight);
}
updateAllRights();
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class Grantee method revoke.
/**
* Revokes the specified rights on the specified database object. <p>
*
* If, after removing the specified rights, no rights remain on the
* database object, then the key/value pair for that object is removed
* from the rights map
*/
void revoke(SchemaObject object, Right right, Grantee grantor, boolean grantOption) {
final HsqlName name = object.getName();
Iterator it = directRightsMap.get(name);
Right existing = null;
while (it.hasNext()) {
existing = (Right) it.next();
if (existing.grantor == grantor) {
break;
}
}
if (existing == null) {
return;
}
if (existing.grantableRights != null) {
existing.grantableRights.remove(object, right);
}
if (grantOption) {
return;
}
if (right.isFull) {
directRightsMap.remove(name, existing);
grantor.grantedRightsMap.remove(name, existing);
updateAllRights();
return;
}
existing.remove(object, right);
if (existing.isEmpty()) {
directRightsMap.remove(name, existing);
grantor.grantedRightsMap.remove(object, existing);
}
updateAllRights();
return;
}
Aggregations