當前位置: 首頁>>代碼示例>>Java>>正文


Java Database.findRole方法代碼示例

本文整理匯總了Java中org.h2.engine.Database.findRole方法的典型用法代碼示例。如果您正苦於以下問題:Java Database.findRole方法的具體用法?Java Database.findRole怎麽用?Java Database.findRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.h2.engine.Database的用法示例。


在下文中一共展示了Database.findRole方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import org.h2.engine.Database; //導入方法依賴的package包/類
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (db.findUser(roleName) != null) {
        throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, roleName);
    }
    if (db.findRole(roleName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, roleName);
    }
    int id = getObjectId();
    Role role = new Role(db, id, roleName, false);
    db.addDatabaseObject(session, role);
    return 0;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:20,代碼來源:CreateRole.java

示例2: update

import org.h2.engine.Database; //導入方法依賴的package包/類
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (roleName.equals(Constants.PUBLIC_ROLE_NAME)) {
        throw DbException.get(ErrorCode.ROLE_CAN_NOT_BE_DROPPED_1, roleName);
    }
    Role role = db.findRole(roleName);
    if (role == null) {
        if (!ifExists) {
            throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, roleName);
        }
    } else {
        db.removeDatabaseObject(session, role);
    }
    return 0;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:19,代碼來源:DropRole.java

示例3: update

import org.h2.engine.Database; //導入方法依賴的package包/類
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (db.findRole(userName) != null) {
        throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, userName);
    }
    if (db.findUser(userName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, userName);
    }
    int id = getObjectId();
    User user = new User(db, id, userName, false);
    user.setAdmin(admin);
    user.setComment(comment);
    if (hash != null && salt != null) {
        user.setSaltAndHash(getByteArray(salt), getByteArray(hash));
    } else if (password != null) {
        char[] passwordChars = getCharArray(password);
        byte[] userPasswordHash;
        if (userName.length() == 0 && passwordChars.length == 0) {
            userPasswordHash = new byte[0];
        } else {
            userPasswordHash = SHA256.getKeyPasswordHash(userName, passwordChars);
        }
        user.setUserPasswordHash(userPasswordHash);
    } else {
        throw DbException.throwInternalError();
    }
    db.addDatabaseObject(session, user);
    return 0;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:36,代碼來源:CreateUser.java

示例4: setGranteeName

import org.h2.engine.Database; //導入方法依賴的package包/類
public void setGranteeName(String granteeName) {
    Database db = session.getDatabase();
    grantee = db.findUser(granteeName);
    if (grantee == null) {
        grantee = db.findRole(granteeName);
        if (grantee == null) {
            throw DbException.get(ErrorCode.USER_OR_ROLE_NOT_FOUND_1, granteeName);
        }
    }
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:11,代碼來源:GrantRevoke.java

示例5: update

import org.h2.engine.Database; //導入方法依賴的package包/類
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (roleNames != null) {
        for (String name : roleNames) {
            Role grantedRole = db.findRole(name);
            if (grantedRole == null) {
                throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, name);
            }
            if (operationType == CommandInterface.GRANT) {
                grantRole(grantedRole);
            } else if (operationType == CommandInterface.REVOKE) {
                revokeRole(grantedRole);
            } else {
                DbException.throwInternalError("type=" + operationType);
            }
        }
    } else {
        if (operationType == CommandInterface.GRANT) {
            grantRight();
        } else if (operationType == CommandInterface.REVOKE) {
            revokeRight();
        } else {
            DbException.throwInternalError("type=" + operationType);
        }
    }
    return 0;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:31,代碼來源:GrantRevoke.java


注:本文中的org.h2.engine.Database.findRole方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。