use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class BackendEntityAssignedPermissionsResourceTest method testAddIncompletePermission.
@Test
public void testAddIncompletePermission() throws Exception {
Permission model = new Permission();
model.setDataCenter(new DataCenter());
model.getDataCenter().setId(GUIDS[2].toString());
model.setRole(new Role());
model.getRole().setId(GUIDS[3].toString());
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Permission", "add", "user|group.id");
}
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class BackendEntityAssignedPermissionsResourceTest method testAddGroupPermission.
@Test
public void testAddGroupPermission() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AddPermission, PermissionsOperationsParameters.class, new String[] { "Group.Id", "Permission.AdElementId", "Permission.ObjectId", "Permission.RoleId" }, new Object[] { GUIDS[1], GUIDS[1], targetId, GUIDS[3] }, true, true, GUIDS[0], QueryType.GetPermissionById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Permission model = new Permission();
model.setRole(new Role());
model.getRole().setId(GUIDS[3].toString());
model.setGroup(new Group());
model.getGroup().setId(GUIDS[1].toString());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Permission);
verifyModel((Permission) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class PermissionMapper method map.
@Mapping(from = Permission.class, to = org.ovirt.engine.core.common.businessentities.Permission.class)
public static org.ovirt.engine.core.common.businessentities.Permission map(Permission model, org.ovirt.engine.core.common.businessentities.Permission template) {
org.ovirt.engine.core.common.businessentities.Permission entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.Permission();
if (model.isSetId()) {
entity.setId(GuidUtils.asGuid(model.getId()));
}
if (model.isSetRole()) {
Role role = model.getRole();
if (role.isSetId()) {
entity.setRoleId(GuidUtils.asGuid(role.getId()));
}
if (role.isSetName()) {
entity.setRoleName(role.getName());
}
}
entity.setObjectId(map(model, template != null ? template.getObjectId() : null));
entity.setObjectType(map(model, template != null ? template.getObjectType() : null));
return entity;
}
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 = Role.class)
public static Role map(org.ovirt.engine.core.common.businessentities.Permission entity, Role template) {
Role model = template != null ? template : new Role();
model.setName(entity.getRoleName());
model.setId(entity.getRoleId().toString());
return model;
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class V3RoleInAdapter method adapt.
@Override
public Role adapt(V3Role from) {
Role to = new Role();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetAdministrative()) {
to.setAdministrative(from.isAdministrative());
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetMutable()) {
to.setMutable(from.isMutable());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetPermits()) {
to.setPermits(new Permits());
to.getPermits().getPermits().addAll(adaptIn(from.getPermits().getPermits()));
}
if (from.isSetUser()) {
to.setUser(adaptIn(from.getUser()));
}
return to;
}
Aggregations