Search in sources :

Example 1 with RoleType

use of org.ovirt.engine.core.common.businessentities.RoleType in project ovirt-engine by oVirt.

the class AddRoleWithActionGroupsCommand method validate.

@Override
protected boolean validate() {
    if (getParameters().getActionGroups().isEmpty()) {
        addValidationMessage(EngineMessage.ACTION_LIST_CANNOT_BE_EMPTY);
        return false;
    }
    if (roleDao.getByName(getRoleName()) != null) {
        addValidationMessage(EngineMessage.VAR__ACTION__ADD);
        addValidationMessage(EngineMessage.VAR__TYPE__ROLE);
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_NAME_ALREADY_USED);
        return false;
    }
    RoleType roleType = getRole().getType();
    if (roleType == null) {
        addValidationMessage(EngineMessage.ROLE_TYPE_CANNOT_BE_EMPTY);
        return false;
    }
    if (roleType != RoleType.ADMIN) {
        List<ActionGroup> actionGroups = getParameters().getActionGroups();
        for (ActionGroup group : actionGroups) {
            if (group.getRoleType() == RoleType.ADMIN) {
                addValidationMessage(EngineMessage.CANNOT_ADD_ACTION_GROUPS_TO_ROLE_TYPE);
                return false;
            }
        }
    }
    return true;
}
Also used : ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) RoleType(org.ovirt.engine.core.common.businessentities.RoleType)

Aggregations

ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)1 RoleType (org.ovirt.engine.core.common.businessentities.RoleType)1