use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class UserMapper method map.
@Mapping(from = DirectoryUser.class, to = User.class)
public static User map(DirectoryUser entity, User template) {
User model = template != null ? template : new User();
model.setName(entity.getFirstName());
model.setUserName(entity.getName() + "@" + entity.getDirectoryName());
model.setId(DirectoryEntryIdUtils.encode(entity.getId()));
model.setLastName(entity.getLastName());
model.setEmail(entity.getEmail());
model.setDepartment(entity.getDepartment());
model.setPrincipal(entity.getPrincipal());
model.setNamespace(entity.getNamespace());
if (entity.getGroups() != null) {
model.setGroups(new Groups());
for (DirectoryGroup directoryGroup : entity.getGroups()) {
Group group = new Group();
group.setName(directoryGroup.getName());
model.getGroups().getGroups().add(group);
}
}
if (!StringUtils.isEmpty(entity.getDirectoryName())) {
Domain dom = new Domain();
dom.setName(entity.getDirectoryName());
dom.setId(DirectoryEntryIdUtils.encode(dom.getName()));
model.setDomain(dom);
}
return model;
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class PermissionMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.Permission.class, to = Permission.class)
public static Permission map(org.ovirt.engine.core.common.businessentities.Permission entity, Permission template) {
Permission model = template != null ? template : new Permission();
model.setId(entity.getId().toString());
if (entity.getRoleId() != null) {
model.setRole(new Role());
model.getRole().setId(entity.getRoleId().toString());
}
if (entity.getAdElementId() != null && (template == null || !template.isSetGroup())) {
model.setUser(new User());
model.getUser().setId(entity.getAdElementId().toString());
}
if (entity.getObjectId() != null) {
setObjectId(model, entity);
}
return model;
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteSuperFieldAlternatives.
@Test
public void testCompleteSuperFieldAlternatives() throws Exception {
Permission permission = new Permission();
permission.setUser(new User());
permission.getUser().setName("joe");
CompletenessAssertor.validateParameters(permission, "vm|user.name");
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteBothAlternatives.
@Test
public void testCompleteBothAlternatives() throws Exception {
Permission permission = new Permission();
permission.setUser(new User());
permission.getUser().setName("joe");
CompletenessAssertor.validateParameters(permission, "vm|user.name|id");
}
use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteListSubFieldAlternatives.
@Test
public void testCompleteListSubFieldAlternatives() 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");
CompletenessAssertor.validateParameters(user, "roles.id|name");
}
Aggregations