use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class BackendApiResource method setAuthenticatedUser.
/**
* Set a link to the user of the current session
* (the 'authenticated user') in the API object.
* This link enables users a convenient way to see
* which is the logged-in user, using the system.
*/
private void setAuthenticatedUser(Api api) {
QueryReturnValue returnValue = runQuery(QueryType.GetUserBySessionId, new QueryParametersBase());
DbUser authenticatedUser = (DbUser) returnValue.getReturnValue();
User user = new User();
user.setId(authenticatedUser.getId().toString());
LinkHelper.addLinks(user);
api.setAuthenticatedUser(user);
api.setEffectiveUser(user);
// currently the authenticated and effective users are the same one,
// but if and when impersonation is introduced, they may be different.
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class BackendSSHPublicKeysResource method addParents.
@Override
public SshPublicKey addParents(SshPublicKey pubkey) {
User parent = pubkey.getUser();
if (parent == null) {
parent = new User();
pubkey.setUser(parent);
}
parent.setId(userId.toString());
return pubkey;
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingListSubFieldAlternatives.
@Test
public void testMissingListSubFieldAlternatives() 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).setDescription("0");
try {
CompletenessAssertor.validateParameters(user, "roles.id|name");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "User", "roles.id|name");
}
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class V3UserInAdapter method adapt.
@Override
public User adapt(V3User from) {
User to = new User();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetDepartment()) {
to.setDepartment(from.getDepartment());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetDomain()) {
to.setDomain(adaptIn(from.getDomain()));
}
if (from.isSetDomainEntryId()) {
to.setDomainEntryId(from.getDomainEntryId());
}
if (from.isSetEmail()) {
to.setEmail(from.getEmail());
}
if (from.isSetGroups()) {
to.setGroups(new Groups());
to.getGroups().getGroups().addAll(adaptIn(from.getGroups().getGroups()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetLastName()) {
to.setLastName(from.getLastName());
}
if (from.isSetLoggedIn()) {
to.setLoggedIn(from.isLoggedIn());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetNamespace()) {
to.setNamespace(from.getNamespace());
}
if (from.isSetPassword()) {
to.setPassword(from.getPassword());
}
if (from.isSetPrincipal()) {
to.setPrincipal(from.getPrincipal());
}
if (from.isSetRoles()) {
to.setRoles(new Roles());
to.getRoles().getRoles().addAll(adaptIn(from.getRoles().getRoles()));
}
if (from.isSetUserName()) {
to.setUserName(from.getUserName());
}
return to;
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class HostMapper method map.
@Mapping(from = VdsStatic.class, to = Ssh.class)
public static Ssh map(VdsStatic entity, Ssh template) {
Ssh model = template != null ? template : new Ssh();
model.setPort(entity.getSshPort());
model.setUser(new User());
model.getUser().setUserName(entity.getSshUsername());
model.setFingerprint(entity.getSshKeyFingerprint());
return model;
}
Aggregations