use of org.ovirt.engine.api.model.Role 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.Role in project ovirt-engine by oVirt.
the class RoleMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.Role.class, to = Role.class)
public static Role map(org.ovirt.engine.core.common.businessentities.Role entity, Role template) {
Role model = template != null ? template : new Role();
model.setName(entity.getName());
model.setDescription(entity.getDescription());
model.setId(entity.getId().toString());
model.setMutable(!entity.isReadonly());
model.setAdministrative(RoleType.ADMIN.equals(entity.getType()));
return model;
}
use of org.ovirt.engine.api.model.Role 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");
}
use of org.ovirt.engine.api.model.Role 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.Role 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");
}
}
Aggregations