use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.
the class AttachActionGroupsToRoleCommandTest method generateParameters.
@Override
protected ActionGroupsToRoleParameter generateParameters() {
Guid roleId = Guid.newGuid();
ArrayList<ActionGroup> groups = new ArrayList<>(Arrays.asList(ActionGroup.DELETE_HOST, ActionGroup.CONFIGURE_ENGINE));
return new ActionGroupsToRoleParameter(roleId, groups);
}
use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.
the class BackendPermitResource method remove.
@Override
public Response remove() {
get();
ActionGroup entity = parent.lookupId(id);
if (entity == null) {
notFound();
return null;
}
return performAction(ActionType.DetachActionGroupsFromRole, new ActionGroupsToRoleParameter(parent.roleId, asList(entity)));
}
use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.
the class BackendPermitsResource method add.
@Override
public Response add(Permit permit) {
validateParameters(permit, "name|id");
ArrayList<ActionGroup> actionGroups = new ArrayList<>();
addIfNotExists(actionGroups, map(permit));
return performCreate(ActionType.AttachActionGroupsToRole, new ActionGroupsToRoleParameter(roleId, actionGroups), new PermitIdResolver(actionGroups.get(0)));
}
use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.
the class RoleListModel method onSave.
public void onSave() {
RoleModel model = (RoleModel) getWindow();
if (model.getProgress() != null) {
return;
}
role = commandType != CommandType.Edit ? new Role() : getSelectedItem();
role.setType(model.getIsAdminRole().getEntity() ? RoleType.ADMIN : RoleType.USER);
if (!model.validate()) {
return;
}
role.setName(model.getName().getEntity());
role.setDescription(model.getDescription().getEntity());
ArrayList<ActionGroup> actions = new ArrayList<>();
HashMap<ActionGroup, ActionGroup> actionDistinctSet = new HashMap<>();
for (SelectionTreeNodeModel sm : model.getPermissionGroupModels()) {
for (SelectionTreeNodeModel smChild : sm.getChildren()) {
if (smChild.getIsSelectedNullable() == null || smChild.getIsSelectedNullable()) {
for (SelectionTreeNodeModel smGrandChild : smChild.getChildren()) {
if (smGrandChild.getIsSelectedNullable()) {
ActionGroup actionGroup = ActionGroup.valueOf(smGrandChild.getTitle());
if (actionDistinctSet.containsKey(actionGroup)) {
continue;
}
actionDistinctSet.put(actionGroup, actionGroup);
actions.add(actionGroup);
}
}
}
}
}
ActionReturnValue returnValue;
model.startProgress();
if (commandType != CommandType.Edit) {
// Add a new role.
RoleWithActionGroupsParameters tempVar = new RoleWithActionGroupsParameters();
tempVar.setRole(role);
tempVar.setActionGroups(actions);
Frontend.getInstance().runAction(ActionType.AddRoleWithActionGroups, tempVar, result -> {
RoleListModel localModel = (RoleListModel) result.getState();
localModel.postOnSaveNew(result.getReturnValue());
}, this);
} else {
detachActionGroup = new ArrayList<>(publicAttachedActions);
detachActionGroup.removeAll(actions);
attachActionGroup = actions;
attachActionGroup.removeAll(publicAttachedActions);
Frontend.getInstance().runAction(ActionType.UpdateRole, new RolesOperationsParameters(role), result -> {
RoleListModel roleListModel = (RoleListModel) result.getState();
ActionReturnValue retVal = result.getReturnValue();
if (retVal != null && retVal.getSucceeded()) {
if (roleListModel.detachActionGroup.size() > 0) {
ActionGroupsToRoleParameter tempVar2 = new ActionGroupsToRoleParameter();
tempVar2.setActionGroups(roleListModel.detachActionGroup);
tempVar2.setRoleId(roleListModel.role.getId());
Frontend.getInstance().runAction(ActionType.DetachActionGroupsFromRole, tempVar2);
}
if (roleListModel.attachActionGroup.size() > 0) {
ActionGroupsToRoleParameter tempVar3 = new ActionGroupsToRoleParameter();
tempVar3.setActionGroups(roleListModel.attachActionGroup);
tempVar3.setRoleId(roleListModel.role.getId());
Frontend.getInstance().runAction(ActionType.AttachActionGroupsToRole, tempVar3);
}
roleListModel.getWindow().stopProgress();
roleListModel.cancel();
} else {
roleListModel.getWindow().stopProgress();
}
}, this);
}
}
use of org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter in project ovirt-engine by oVirt.
the class DetachActionGroupsFromRoleCommandTest method generateParameters.
@Override
protected ActionGroupsToRoleParameter generateParameters() {
Guid roleId = Guid.newGuid();
ArrayList<ActionGroup> groups = new ArrayList<>(Arrays.asList(ActionGroup.DELETE_HOST, ActionGroup.CONFIGURE_ENGINE));
return new ActionGroupsToRoleParameter(roleId, groups);
}
Aggregations