use of com.microsoft.graph.requests.UserCollectionPage in project msgraph-sdk-java by microsoftgraph.
the class UserTests method usersKeyPhotoValueTest.
@Test
public void usersKeyPhotoValueTest() {
// GET users('<<key>>')/photo/$value
final UserCollectionPage userCollectionPage = graphServiceClient.users().buildRequest().get();
for (User user : userCollectionPage.getCurrentPage()) {
if (user.photo != null) {
InputStream stream = graphServiceClient.users(userCollectionPage.getCurrentPage().get(0).id).photo().content().buildRequest().get();
assertNotNull(stream);
break;
}
}
}
use of com.microsoft.graph.requests.UserCollectionPage in project msgraph-sdk-java by microsoftgraph.
the class OutlookTests method testGetFindMeetingTimes.
@Test
public void testGetFindMeetingTimes() {
TestBase testBase = new TestBase();
// Get the first user in the tenant
User me = testBase.graphClient.me().buildRequest().get();
UserCollectionPage users = testBase.graphClient.users().buildRequest().get();
User tenantUser = users.getCurrentPage().get(0);
// Ensure that the user grabbed is not the logged-in user
if (tenantUser.mail.equals(me.mail)) {
tenantUser = users.getCurrentPage().get(1);
}
ArrayList<AttendeeBase> attendees = new ArrayList<AttendeeBase>();
AttendeeBase attendeeBase = new AttendeeBase();
EmailAddress email = new EmailAddress();
email.address = tenantUser.mail;
attendeeBase.emailAddress = email;
attendees.add(attendeeBase);
try {
DatatypeFactory.newInstance().newDuration("PT30M");
Duration duration = DatatypeFactory.newInstance().newDuration("PT30M");
MeetingTimeSuggestionsResult result = testBase.graphClient.me().findMeetingTimes(UserFindMeetingTimesParameterSet.newBuilder().withAttendees(attendees).withMeetingDuration(duration).withMaxCandidates(10).withReturnSuggestionReasons(true).withMinimumAttendeePercentage(10.0).build()).buildRequest().post();
assertNotNull(result);
} catch (Exception e) {
fail("Duration could not be created from String");
}
}
use of com.microsoft.graph.requests.UserCollectionPage in project OpenOLAT by OpenOLAT.
the class MicrosoftGraphDAO method searchUserByUserPrincipalName.
/**
* @param mail
* @param issuer
* @return
*/
public User searchUserByUserPrincipalName(List<String> principals, TeamsErrors errors) {
if (principals == null || principals.isEmpty())
return null;
StringBuilder sb = new StringBuilder();
for (String principal : principals) {
if (sb.length() > 0) {
sb.append(" or ");
}
sb.append("userPrincipalName eq '").append(principal).append("'");
}
try {
UserCollectionPage user = client().users().buildRequest().filter(sb.toString()).select("displayName,id,mail,otherMails").top(1).get();
List<User> users = user.getCurrentPage();
return users.isEmpty() ? null : users.get(0);
} catch (ClientException | NullPointerException | IllegalArgumentException e) {
errors.append(new TeamsError(TeamsErrorCodes.httpClientError));
log.error("Cannot find user with principal names", e);
return null;
}
}
use of com.microsoft.graph.requests.UserCollectionPage in project OpenOLAT by OpenOLAT.
the class MicrosoftGraphDAO method searchUsersByMail.
/**
* $filter=otherMails/any(x:x eq ‘xxx@abc.com’)
*
* @param email The E-mail (mandatory)
* @param institutionalEmail The institutional E-mail (optional)
* @return The first users found
*/
public List<User> searchUsersByMail(String email, String institutionalEmail, TeamsErrors errors) {
StringBuilder sb = new StringBuilder();
sb.append("mail eq '").append(email).append("'").append(" or otherMails/any(x:x eq '").append(email).append("')");
if (StringHelper.containsNonWhitespace(institutionalEmail)) {
sb.append(" or mail eq '").append(institutionalEmail).append("'").append(" or otherMails/any(x:x eq '").append(institutionalEmail).append("')");
}
try {
UserCollectionPage user = client().users().buildRequest().filter(sb.toString()).select("displayName,id,mail,otherMails").get();
return user.getCurrentPage();
} catch (ClientException | NullPointerException | IllegalArgumentException e) {
log.error("Cannot find user with email: {} {}", email, institutionalEmail, e);
errors.append(new TeamsError(TeamsErrorCodes.httpClientError));
return new ArrayList<>();
}
}
use of com.microsoft.graph.requests.UserCollectionPage in project msgraph-beta-sdk-java by microsoftgraph.
the class UserTests method castTest.
@Test
public void castTest() {
final GroupCollectionPage groups = graphServiceClient.groups().buildRequest().top(1).get();
final Group group = groups.getCurrentPage().get(0);
final UserCollectionPage usersPage = graphServiceClient.groups(group.id).membersAsUser().buildRequest().get();
assertNotNull(usersPage);
final DirectoryObjectCollectionWithReferencesPage testUserCollection = graphServiceClient.groups(group.id).members().buildRequest().top(1).get();
final DirectoryObject testUser = testUserCollection.getCurrentPage().get(0);
final User user = graphServiceClient.groups(group.id).membersAsUser(testUser.id).buildRequest().get();
assertNotNull(user);
}
Aggregations