use of org.ovirt.engine.core.common.businessentities.ActionGroup 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;
}
use of org.ovirt.engine.core.common.businessentities.ActionGroup in project ovirt-engine by oVirt.
the class CommandBase method checkSinglePermission.
public final boolean checkSinglePermission(PermissionSubject permSubject, Collection<String> messages) {
final Guid objectId = permSubject.getObjectId();
final VdcObjectType objectType = permSubject.getObjectType();
final ActionGroup objectActionGroup = permSubject.getActionGroup();
// if objectId is null we can't check permission
if (objectId == null) {
if (log.isDebugEnabled()) {
log.debug("The object to check is null for action '{}'.", getActionType());
}
messages.add(EngineMessage.USER_NOT_AUTHORIZED_TO_PERFORM_ACTION.name());
return false;
}
// Check that an action group is defined for this action;
if (objectActionGroup == null) {
if (log.isDebugEnabled()) {
log.debug("No action group is defined for action '{}'.", getActionType());
}
return false;
}
// Check the authorization:
if (!checkUserAuthorization(getCurrentUser().getId(), objectActionGroup, objectId, objectType)) {
messages.add(permSubject.getMessage().name());
return false;
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.ActionGroup in project ovirt-engine by oVirt.
the class DetachActionGroupsFromRoleCommand method validate.
@Override
protected boolean validate() {
if (getRole() == null) {
addValidationMessage(EngineMessage.ERROR_CANNOT_ATTACH_ACTION_GROUP_TO_ROLE_ATTACHED);
return false;
}
List<String> validationMessages = getReturnValue().getValidationMessages();
if (checkIfRoleIsReadOnly(validationMessages)) {
validationMessages.add(EngineMessage.VAR__TYPE__ROLE.toString());
validationMessages.add(EngineMessage.VAR__ACTION__DETACH_ACTION_TO.toString());
return false;
}
Guid roleId = getParameters().getRoleId();
List<ActionGroup> allGroups = getActionGroupsByRoleId(roleId);
List<ActionGroup> groupsToDetach = getParameters().getActionGroups();
// Check that target action group exists for this role
for (ActionGroup group : groupsToDetach) {
if (!allGroups.contains(group)) {
validationMessages.add(EngineMessage.ERROR_CANNOT_DETACH_ACTION_GROUP_TO_ROLE_NOT_ATTACHED.toString());
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.ActionGroup in project ovirt-engine by oVirt.
the class PermitMapperTest method postPopulate.
@Override
protected Permit postPopulate(Permit from) {
ActionGroup actionGroup = MappingTestHelper.shuffle(ActionGroup.class);
from.setId(Integer.toString(actionGroup.getId()));
from.setName(actionGroup.name().toLowerCase());
from.setAdministrative(actionGroup.getRoleType() == RoleType.ADMIN);
return from;
}
Aggregations