use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteListSubField.
@Test
public void testCompleteListSubField() throws Exception {
User user = new User();
user.setRoles(new Roles());
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(0).setId("0");
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(1).setId("0");
CompletenessAssertor.validateParameters(user, "roles.id");
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingListSubField.
@Test
public void testMissingListSubField() throws Exception {
User user = new User();
user.setRoles(new Roles());
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(0).setId("0");
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(1).setName("0");
try {
CompletenessAssertor.validateParameters(user, "roles.id");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "User", "roles.id");
}
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class BackendVmSessionsResource method setSessionUser.
/**
* The console user, if exists, is a real ovirt-user. Use its name to get ID and href information, and set them
* inside the user object, inside the session. If user is not found in database, those information won't be set.
*/
private void setSessionUser(Session session) {
// Get the user entity and don't fail if user is not found in database:
DbUser entity = getEntity(DbUser.class, QueryType.GetDbUserByUserNameAndDomain, new GetDbUserByUserNameAndDomainQueryParameters(session.getUser().getUserName(), session.getUser().getDomain().getName()), "", false, false);
// Map the database user to model user:
if (entity != null) {
User user = BackendApiResource.getInstance().getUsersResource().getUserResource(entity.getId().toString()).get();
/**
* TODO: It's enough to set user ID and href, we don't have to set also domain, please consider this
* when moving to API version 5.
*/
if (user != null) {
session.getUser().setId(user.getId());
session.getUser().setHref(user.getHref());
session.getUser().getDomain().setId(user.getDomain().getId());
session.getUser().getDomain().setHref(user.getDomain().getHref());
}
}
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class BackendUsersResource method mapDbUserCollection.
protected Users mapDbUserCollection(List<DbUser> entities) {
Users collection = new Users();
for (DbUser entity : entities) {
User user = map(entity);
user = populate(user, entity);
user = addLinks(user, BaseResource.class);
collection.getUsers().add(user);
}
return collection;
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class BackendEntityAssignedPermissionsResourceTest method getModel.
@Override
protected Permission getModel() {
Permission model = new Permission();
model.setUser(new User());
model.getUser().setId(GUIDS[1].toString());
model.setRole(new Role());
model.getRole().setId(GUIDS[3].toString());
return model;
}
Aggregations