Search in sources :

Example 21 with User

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;
}
Also used : Group(org.ovirt.engine.api.model.Group) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) User(org.ovirt.engine.api.model.User) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) Groups(org.ovirt.engine.api.model.Groups) Domain(org.ovirt.engine.api.model.Domain)

Example 22 with User

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;
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Permission(org.ovirt.engine.api.model.Permission)

Example 23 with User

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");
}
Also used : User(org.ovirt.engine.api.model.User) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Example 24 with User

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");
}
Also used : User(org.ovirt.engine.api.model.User) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Example 25 with User

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");
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Aggregations

User (org.ovirt.engine.api.model.User)31 Test (org.junit.Test)12 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)9 Role (org.ovirt.engine.api.model.Role)7 Permission (org.ovirt.engine.api.model.Permission)6 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)6 Roles (org.ovirt.engine.api.model.Roles)5 Domain (org.ovirt.engine.api.model.Domain)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 Group (org.ovirt.engine.api.model.Group)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Groups (org.ovirt.engine.api.model.Groups)2 Session (org.ovirt.engine.api.model.Session)2 Ssh (org.ovirt.engine.api.model.Ssh)2 Users (org.ovirt.engine.api.model.Users)2 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 ArrayList (java.util.ArrayList)1 AuthorizedKey (org.ovirt.engine.api.model.AuthorizedKey)1 BaseResource (org.ovirt.engine.api.model.BaseResource)1