use of com.microsoft.graph.models.Organization in project OpenOLAT by OpenOLAT.
the class MicrosoftGraphDAO method check.
public ConnectionInfos check(String clientId, String clientSecret, String tenantGuid, String producerId, TeamsErrors errors) {
try {
MicrosoftGraphAccessTokenManager accessTokenManager = new MicrosoftGraphAccessTokenManager(clientId, clientSecret, tenantGuid);
AuthenticationTokenProvider authProvider = new AuthenticationTokenProvider(accessTokenManager);
GraphServiceClient<Request> client = client(authProvider);
Organization org = getOrganisation(tenantGuid, client);
String organisation = org == null ? null : org.displayName;
String producerDisplayName = null;
if (StringHelper.containsNonWhitespace(producerId)) {
User producer = searchUserById(producerId, client, errors);
producerDisplayName = producer == null ? null : producer.displayName;
}
return new ConnectionInfos(organisation, producerDisplayName);
} catch (ClientException e) {
errors.append(extractMsalFrom(e));
log.error("", e);
return null;
} catch (NullPointerException | IllegalArgumentException e) {
errors.append(new TeamsError(TeamsErrorCodes.httpClientError));
log.error("", e);
return null;
} catch (Exception e) {
errors.append(new TeamsError(e.getMessage()));
log.error("", e);
return null;
}
}
use of com.microsoft.graph.models.Organization in project OpenOLAT by OpenOLAT.
the class MicrosoftGraphDAO method check.
public final ConnectionInfos check(TeamsErrors errors) {
try {
GraphServiceClient<Request> client = client();
String tenantId = teamsModule.getTenantGuid();
Organization org = getOrganisation(tenantId, client);
String organisation = org == null ? null : org.displayName;
String producerDisplayName = null;
if (StringHelper.containsNonWhitespace(teamsModule.getProducerId())) {
User producer = searchUserById(teamsModule.getProducerId(), client, errors);
producerDisplayName = producer == null ? null : producer.displayName;
}
return new ConnectionInfos(organisation, producerDisplayName);
} catch (ClientException | NullPointerException | IllegalArgumentException e) {
errors.append(new TeamsError(TeamsErrorCodes.httpClientError));
log.error("", e);
return null;
} catch (Exception e) {
errors.append(new TeamsError(e.getMessage(), ""));
log.error("", e);
return null;
}
}
Aggregations