use of org.olat.modules.teams.TeamsUser in project OpenOLAT by OpenOLAT.
the class TeamsServiceImpl method lookupUser.
@Override
public User lookupUser(Identity identity, TeamsErrors errors) {
TeamsUser teamsUser = teamsUserDao.getUser(identity);
if (teamsUser != null) {
User user = new User();
user.id = teamsUser.getIdentifier();
user.displayName = teamsUser.getDisplayName();
return user;
}
String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
String institutionalEmail = identity.getUser().getProperty(UserConstants.INSTITUTIONALEMAIL, null);
List<User> users = graphDao.searchUsersByMail(email, institutionalEmail, errors);
if (users.size() > 1) {
users = reduceToPrefered(email, users);
}
if (users.size() == 1) {
User user = users.get(0);
teamsUserDao.createUser(identity, user.id, user.displayName);
dbInstance.commit();
return user;
}
List<String> principals = new ArrayList<>();
if (StringHelper.containsNonWhitespace(email)) {
principals.add(email);
}
if (StringHelper.containsNonWhitespace(institutionalEmail)) {
principals.add(institutionalEmail);
}
Authentication authentication = securityManager.findAuthentication(identity, MicrosoftAzureADFSProvider.PROVIDER, BaseSecurity.DEFAULT_ISSUER);
if (authentication != null && StringHelper.containsNonWhitespace(authentication.getAuthusername())) {
principals.add(authentication.getAuthusername());
}
User user = graphDao.searchUserByUserPrincipalName(principals, errors);
if (user == null) {
log.debug("Cannot find user with email: {} or institutional email: {} (users found {})", email, institutionalEmail, users.size());
} else {
teamsUserDao.createUser(identity, user.id, user.displayName);
dbInstance.commit();
}
return user;
}
use of org.olat.modules.teams.TeamsUser in project OpenOLAT by OpenOLAT.
the class TeamsAttendeeDAOTest method deleteAttendee.
@Test
public void deleteAttendee() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-attendee-4");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-attendee-5");
Identity idRef = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-attendee-5");
TeamsUser user1 = teamsUserDao.createUser(id1, UUID.randomUUID().toString(), "Teams attendee 3");
TeamsUser user2 = teamsUserDao.createUser(id2, UUID.randomUUID().toString(), "Teams attendee 4");
TeamsUser userRef = teamsUserDao.createUser(idRef, UUID.randomUUID().toString(), "Teams attendee 5");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
TeamsMeeting meeting = teamsMeetingDao.createMeeting("Online-Meeting - attendee - 3", new Date(), new Date(), entry, subIdent, null, id1);
TeamsMeeting meetingRef = teamsMeetingDao.createMeeting("Online-Meeting - attendee - 4", new Date(), new Date(), entry, subIdent, null, idRef);
dbInstance.commitAndCloseSession();
TeamsAttendee attendee1 = teamsAttendeeDao.createAttendee(id1, user1, "Role", new Date(), meeting);
TeamsAttendee attendee2 = teamsAttendeeDao.createAttendee(id2, user2, "Role", new Date(), meeting);
TeamsAttendee attendeeRef = teamsAttendeeDao.createAttendee(idRef, userRef, "Role", new Date(), meetingRef);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(attendee1);
Assert.assertNotNull(attendee2);
Assert.assertNotNull(attendeeRef);
boolean hasAttended = teamsAttendeeDao.hasAttendee(id1, meeting);
Assert.assertTrue(hasAttended);
teamsAttendeeDao.deleteMeetingsAttendees(meeting);
dbInstance.commitAndCloseSession();
boolean stillAttended = teamsAttendeeDao.hasAttendee(idRef, meetingRef);
Assert.assertTrue(stillAttended);
}
use of org.olat.modules.teams.TeamsUser in project OpenOLAT by OpenOLAT.
the class TeamsUserDAOTest method createUser.
@Test
public void createUser() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-user-1");
String identifier = UUID.randomUUID().toString();
String displayName = "Teams User 1";
TeamsUser user = teamsUserDao.createUser(id, identifier, displayName);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(user);
Assert.assertNotNull(user.getKey());
Assert.assertNotNull(user.getCreationDate());
Assert.assertNotNull(user.getLastModified());
Assert.assertEquals(id, user.getIdentity());
Assert.assertEquals(identifier, user.getIdentifier());
Assert.assertEquals(displayName, user.getDisplayName());
}
use of org.olat.modules.teams.TeamsUser in project OpenOLAT by OpenOLAT.
the class TeamsUserDAOTest method getUser.
@Test
public void getUser() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-user-2");
String identifier = UUID.randomUUID().toString();
String displayName = "Teams User 2";
TeamsUser user = teamsUserDao.createUser(id, identifier, displayName);
dbInstance.commitAndCloseSession();
TeamsUser reloadedUser = teamsUserDao.getUser(id);
Assert.assertNotNull(reloadedUser);
Assert.assertNotNull(reloadedUser.getCreationDate());
Assert.assertNotNull(reloadedUser.getLastModified());
Assert.assertEquals(user, reloadedUser);
Assert.assertEquals(id, reloadedUser.getIdentity());
Assert.assertEquals(identifier, reloadedUser.getIdentifier());
Assert.assertEquals(displayName, reloadedUser.getDisplayName());
}
use of org.olat.modules.teams.TeamsUser in project OpenOLAT by OpenOLAT.
the class TeamsAttendeeDAOTest method createAttendee.
@Test
public void createAttendee() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("teams-attendee-1");
String identifier = UUID.randomUUID().toString();
String displayName = "Teams attendee 1";
TeamsUser user = teamsUserDao.createUser(id, identifier, displayName);
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
String name = "Online-Meeting - attendee - 1";
String subIdent = UUID.randomUUID().toString();
TeamsMeeting meeting = teamsMeetingDao.createMeeting(name, new Date(), new Date(), entry, subIdent, null, id);
dbInstance.commitAndCloseSession();
TeamsAttendee attendee = teamsAttendeeDao.createAttendee(id, user, "Role", new Date(), meeting);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(attendee);
Assert.assertNotNull(attendee.getKey());
Assert.assertNotNull(attendee.getCreationDate());
Assert.assertNotNull(attendee.getLastModified());
Assert.assertNotNull(attendee.getJoinDate());
Assert.assertEquals(id, attendee.getIdentity());
Assert.assertEquals(user, attendee.getTeamsUser());
Assert.assertEquals(meeting, attendee.getMeeting());
}
Aggregations