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);
}
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);
}
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;
}
Aggregations