use of com.redhat.cloud.notifications.recipients.itservice.pojo.response.Permission in project notifications-backend by RedHatInsights.
the class RbacRecipientUsersProvider method transformToUser.
List<User> transformToUser(List<ITUserResponse> itUserResponses) {
List<User> users = new ArrayList<>();
for (ITUserResponse itUserResponse : itUserResponses) {
User user = new User();
user.setUsername(itUserResponse.authentications.get(0).principal);
final List<Email> emails = itUserResponse.accountRelationships.get(0).emails;
for (Email email : emails) {
if (email != null && email.isPrimary != null && email.isPrimary) {
String address = email.address;
user.setEmail(address);
}
}
user.setAdmin(false);
if (itUserResponse.accountRelationships != null) {
for (AccountRelationship accountRelationship : itUserResponse.accountRelationships) {
if (accountRelationship.permissions != null) {
for (Permission permission : accountRelationship.permissions) {
if (ORG_ADMIN_PERMISSION.equals(permission.permissionCode)) {
user.setAdmin(true);
}
}
}
}
}
user.setActive(true);
user.setFirstName(itUserResponse.personalInformation.firstName);
user.setLastName(itUserResponse.personalInformation.lastNames);
users.add(user);
}
return users;
}
use of com.redhat.cloud.notifications.recipients.itservice.pojo.response.Permission in project notifications-backend by RedHatInsights.
the class RbacRecipientUsersProviderTest method createTestResponse.
private List<ITUserResponse> createTestResponse(String permissionCode) {
List<ITUserResponse> itUserResponses = new ArrayList<>();
ITUserResponse itUserResponse = new ITUserResponse();
final AccountRelationship accountRelationship = new AccountRelationship();
accountRelationship.permissions = new ArrayList<>();
Permission permission = new Permission();
permission.permissionCode = permissionCode;
accountRelationship.permissions.add(permission);
itUserResponse.authentications = new ArrayList<>();
final Authentication authentication = new Authentication();
authentication.principal = "somePrincipal";
authentication.providerName = "someProviderName";
itUserResponse.authentications.add(authentication);
itUserResponse.accountRelationships = new ArrayList<>();
itUserResponse.accountRelationships.add(accountRelationship);
accountRelationship.emails = new ArrayList<>();
itUserResponse.personalInformation = new PersonalInformation();
itUserResponse.personalInformation.firstName = "someFirstName";
itUserResponse.personalInformation.lastNames = "someLastName";
itUserResponses.add(itUserResponse);
return itUserResponses;
}
Aggregations