private static Map<String, String> mapExternalRoleMapping(RegistrationRoleMappings model) { return model.getRegistrationRoleMappings() .stream() .collect(Collectors.toMap( registrationMap -> registrationMap.isSetFrom() ? registrationMap.getFrom().getName() : null, registrationMap -> registrationMap.isSetTo() ? RoleMapper.map(registrationMap.getTo(), null).getName() : null)); }
public static void validateAdd(Role role) { if (role == null) { throw new ValidationException("Parameter 'role' is mandatory but was not provided."); } if (role.getName()==null) { throw new ValidationException("Parameter 'role.name' is mandatory but was not provided."); } if (role.getPermits()==null || role.getPermits().getPermits()==null || role.getPermits().getPermits().size() == 0 || role.getPermits().getPermits().get(0).getId()==null) { throw new ValidationException("Parameter 'role.permits.id' is mandatory but was not provided."); } }
throw new ValidationException("Parameter 'permission' is mandatory but was not provided."); if ( (permission.getRole()==null || permission.getRole().getId()==null) && (permission.getRole()==null || permission.getRole().getName()==null) ) { throw new ValidationException("Parameters 'permission.role.id' or 'permission.role.name' are mandatory but both were not provided.");
@Override protected void verify(Role model, Role transform) { assertNotNull(transform); assertEquals(model.getId(), transform.getId()); assertEquals(model.getName(), transform.getName()); assertEquals(model.getDescription(), transform.getDescription()); assertEquals(model.isMutable(), transform.isMutable()); assertEquals(model.isAdministrative(), transform.isAdministrative()); } }
@Mapping(from = Role.class, to = org.ovirt.engine.core.common.businessentities.Role.class) public static org.ovirt.engine.core.common.businessentities.Role map(Role model, org.ovirt.engine.core.common.businessentities.Role template) { org.ovirt.engine.core.common.businessentities.Role entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.Role(); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); } if (model.isSetName()) { entity.setName(model.getName()); } if (model.isSetDescription()) { entity.setDescription(model.getDescription()); } if (model.isSetMutable()) { entity.setReadonly(!model.isMutable()); } if (model.isSetAdministrative()) { entity.setType(model.isAdministrative() ? RoleType.ADMIN : RoleType.USER); } return entity; } }
@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; }
to.setName(from.getName());