use of org.ovirt.engine.api.model.Permission in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method map.
/**
* injects user/group base on permission owner type
* @param entity the permission to map
* @param user the permission owner
* @return permission
*/
public Permission map(org.ovirt.engine.core.common.businessentities.Permission entity, DbUser user) {
Permission template = new Permission();
if (entity.getAdElementId() != null) {
if (isUser(user)) {
template.setUser(new User());
template.getUser().setId(entity.getAdElementId().toString());
} else {
template.setGroup(new Group());
template.getGroup().setId(entity.getAdElementId().toString());
}
}
return map(entity, template);
}
use of org.ovirt.engine.api.model.Permission 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.Permission 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.Permission 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.Permission in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingSuperFieldAlternatives.
@Test
public void testMissingSuperFieldAlternatives() throws Exception {
Permission permission = new Permission();
permission.setVm(new Vm());
try {
CompletenessAssertor.validateParameters(permission, "user|vm.name");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Permission", "user|vm.name");
}
}
Aggregations