Search in sources :

Example 81 with Iterator

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;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Example 82 with Iterator

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);
        }
    }
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) SchemaObject(org.hsqldb_voltpatches.SchemaObject)

Example 83 with Iterator

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;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet)

Example 84 with Iterator

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();
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 85 with Iterator

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;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Aggregations

Iterator (org.hsqldb_voltpatches.lib.Iterator)102 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)64 SchemaObject (org.hsqldb_voltpatches.SchemaObject)57 Table (org.hsqldb_voltpatches.Table)55 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)51 Constraint (org.hsqldb_voltpatches.Constraint)50 TextTable (org.hsqldb_voltpatches.TextTable)39 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)28 HsqlException (org.hsqldb_voltpatches.HsqlException)18 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)14 NumberType (org.hsqldb_voltpatches.types.NumberType)10 HashSet (org.hsqldb_voltpatches.lib.HashSet)9 Type (org.hsqldb_voltpatches.types.Type)9 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6 IntervalType (org.hsqldb_voltpatches.types.IntervalType)6