Search in sources :

Example 1 with Privilege

use of org.jooq.Privilege in project jOOQ by jOOQ.

the class DefaultParseContext method parseRevoke.

private final DDLQuery parseRevoke() {
    parseKeyword("REVOKE");
    boolean grantOptionFor = parseKeywordIf("GRANT OPTION FOR");
    Privilege privilege = parsePrivilege();
    List<Privilege> privileges = null;
    while (parseIf(',')) {
        if (privileges == null) {
            privileges = new ArrayList<>();
            privileges.add(privilege);
        }
        privileges.add(parsePrivilege());
    }
    parseKeyword("ON");
    parseKeywordIf("TABLE");
    Table<?> table = parseTableName();
    RevokeOnStep s1 = grantOptionFor ? privileges == null ? dsl.revokeGrantOptionFor(privilege) : dsl.revokeGrantOptionFor(privileges) : privileges == null ? dsl.revoke(privilege) : dsl.revoke(privileges);
    parseKeyword("FROM");
    User user = parseKeywordIf("PUBLIC") ? null : parseUser();
    RevokeFromStep s2 = s1.on(table);
    return user == null ? s2.fromPublic() : s2.from(user);
}
Also used : DSL.currentUser(org.jooq.impl.DSL.currentUser) User(org.jooq.User) RevokeFromStep(org.jooq.RevokeFromStep) Privilege(org.jooq.Privilege) RevokeOnStep(org.jooq.RevokeOnStep)

Example 2 with Privilege

use of org.jooq.Privilege in project jOOQ by jOOQ.

the class DefaultParseContext method parseGrant.

private final DDLQuery parseGrant() {
    parseKeyword("GRANT");
    Privilege privilege = parsePrivilege();
    List<Privilege> privileges = null;
    while (parseIf(',')) {
        if (privileges == null) {
            privileges = new ArrayList<>();
            privileges.add(privilege);
        }
        privileges.add(parsePrivilege());
    }
    parseKeyword("ON");
    parseKeywordIf("TABLE");
    Table<?> table = parseTableName();
    parseKeyword("TO");
    User user = parseKeywordIf("PUBLIC") ? null : parseUser();
    GrantOnStep s1 = privileges == null ? dsl.grant(privilege) : dsl.grant(privileges);
    GrantToStep s2 = s1.on(table);
    GrantWithGrantOptionStep s3 = user == null ? s2.toPublic() : s2.to(user);
    return parseKeywordIf("WITH GRANT OPTION") ? s3.withGrantOption() : s3;
}
Also used : DSL.currentUser(org.jooq.impl.DSL.currentUser) User(org.jooq.User) GrantWithGrantOptionStep(org.jooq.GrantWithGrantOptionStep) Privilege(org.jooq.Privilege) GrantToStep(org.jooq.GrantToStep) GrantOnStep(org.jooq.GrantOnStep)

Aggregations

Privilege (org.jooq.Privilege)2 User (org.jooq.User)2 DSL.currentUser (org.jooq.impl.DSL.currentUser)2 GrantOnStep (org.jooq.GrantOnStep)1 GrantToStep (org.jooq.GrantToStep)1 GrantWithGrantOptionStep (org.jooq.GrantWithGrantOptionStep)1 RevokeFromStep (org.jooq.RevokeFromStep)1 RevokeOnStep (org.jooq.RevokeOnStep)1