Search in sources :

Example 1 with AddGroupParameters

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

the class UserListModel method onAdd.

public void onAdd(final boolean closeWindow) {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null) {
        cancel();
        return;
    }
    List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
    for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
        if (dbUserEntity.getIsSelected()) {
            selectedItems.add(dbUserEntity);
        }
    }
    List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
    List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
    ActionParametersBase parameters = null;
    for (EntityModel<DbUser> item : selectedItems) {
        if (item.getEntity().isGroup()) {
            actionsList.add(ActionType.AddGroup);
            DbGroup grp = new DbGroup();
            grp.setExternalId(item.getEntity().getExternalId());
            grp.setName(item.getEntity().getFirstName());
            grp.setNamespace(item.getEntity().getNamespace());
            grp.setId(item.getEntity().getId());
            grp.setDomain(item.getEntity().getDomain());
            parameters = new AddGroupParameters(grp);
        } else {
            actionsList.add(ActionType.AddUser);
            parameters = new AddUserParameters(item.getEntity());
        }
        parametersList.add(parameters);
    }
    model.startProgress();
    IFrontendActionAsyncCallback lastCallback = result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        // Refresh user list.
        syncSearch();
        if (closeWindow) {
            cancel();
        }
    };
    Collection<EntityModel<DbUser>> currentItems = model.getItems();
    List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
    for (EntityModel<DbUser> user : selectedItems) {
        callbacksList.add(nopCallback);
        currentItems.remove(user);
    }
    callbacksList.remove(callbacksList.size() - 1);
    callbacksList.add(lastCallback);
    // Refresh display
    model.setItems(null);
    model.setItems(currentItems);
    Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) ActionType(org.ovirt.engine.core.common.action.ActionType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 2 with AddGroupParameters

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

the class BackendGroupsResource method add.

@Override
public Response add(Group group) {
    List<String> authzProvidersNames = getBackendCollection(String.class, QueryType.GetDomainList, new QueryParametersBase());
    validateParameters(group, "name");
    if (AuthzUtils.getAuthzNameFromEntityName(group.getName(), authzProvidersNames) == null) {
        validateParameters(group, "domain.id|name");
    }
    String directoryName = getAuthzProviderName(group, authzProvidersNames);
    DirectoryGroup directoryGroup = findDirectoryGroup(directoryName, group);
    if (directoryGroup == null) {
        return Response.status(Status.BAD_REQUEST).entity("No such group: " + group.getName() + " in directory " + directoryName).build();
    }
    AddGroupParameters parameters = new AddGroupParameters();
    parameters.setGroupToAdd(new DbGroup(directoryGroup));
    QueryIdResolver<Guid> resolver = new QueryIdResolver<>(QueryType.GetDbGroupById, IdQueryParameters.class);
    return performCreate(ActionType.AddGroup, parameters, resolver, BaseResource.class);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters)

Example 3 with AddGroupParameters

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

the class AddPermissionCommand method addGroup.

private DbGroup addGroup(DbGroup groupToAdd) {
    // Try to add the user with the external id:
    if (groupToAdd.getDomain() != null && groupToAdd.getExternalId() != null) {
        AddGroupParameters parameters = new AddGroupParameters(groupToAdd);
        ActionReturnValue result = runInternalAction(ActionType.AddGroup, parameters, cloneContextAndDetachFromParent());
        if (result.getSucceeded()) {
            Guid id = result.getActionReturnValue();
            if (id != null) {
                return dbGroupDao.get(id);
            }
            return null;
        }
    }
    // There is no such group in the directory:
    return null;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Guid(org.ovirt.engine.core.compat.Guid) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters)

Aggregations

AddGroupParameters (org.ovirt.engine.core.common.action.AddGroupParameters)3 Guid (org.ovirt.engine.core.compat.Guid)3 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 Scheduler (com.google.gwt.core.client.Scheduler)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)1 ActionUtils (org.ovirt.engine.core.common.ActionUtils)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AddUserParameters (org.ovirt.engine.core.common.action.AddUserParameters)1 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)1 IdParameters (org.ovirt.engine.core.common.action.IdParameters)1 Tags (org.ovirt.engine.core.common.businessentities.Tags)1 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)1