Search in sources :

Example 6 with ActionGroupsToRoleParameter

use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.

the class AddRoleWithActionGroupsCommand method executeCommand.

@Override
protected void executeCommand() {
    prepareRoleForCommand();
    TransactionSupport.executeInNewTransaction(() -> {
        roleDao.save(getRole());
        getCompensationContext().snapshotNewEntity(getRole());
        getCompensationContext().stateChanged();
        return null;
    });
    ActionReturnValue attachAction = runInternalAction(ActionType.AttachActionGroupsToRole, new ActionGroupsToRoleParameter(getRole().getId(), getParameters().getActionGroups()));
    if (!attachAction.isValid() || !attachAction.getSucceeded()) {
        List<String> failedMsgs = getReturnValue().getExecuteFailedMessages();
        for (String msg : attachAction.getValidationMessages()) {
            failedMsgs.add(msg);
        }
        setSucceeded(false);
        return;
    }
    setSucceeded(true);
    getReturnValue().setActionReturnValue(getRole().getId());
}
Also used : ActionGroupsToRoleParameter(org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Aggregations

ActionGroupsToRoleParameter (org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter)6 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)5 ArrayList (java.util.ArrayList)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 RoleWithActionGroupsParameters (org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters)1 RolesOperationsParameters (org.ovirt.engine.core.common.action.RolesOperationsParameters)1 Role (org.ovirt.engine.core.common.businessentities.Role)1 SelectionTreeNodeModel (org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)1