Search in sources :

Example 1 with ExchangeVersion

use of microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion in project nifi by apache.

the class ConsumeEWS method initializeIfNecessary.

protected ExchangeService initializeIfNecessary(ProcessContext context) throws ProcessException {
    ExchangeVersion ver = ExchangeVersion.valueOf(context.getProperty(EXCHANGE_VERSION).getValue());
    ExchangeService service = new ExchangeService(ver);
    final String timeoutInMillis = String.valueOf(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS));
    service.setTimeout(Integer.parseInt(timeoutInMillis));
    String userEmail = context.getProperty(USER).getValue();
    String password = context.getProperty(PASSWORD).getValue();
    ExchangeCredentials credentials = new WebCredentials(userEmail, password);
    service.setCredentials(credentials);
    Boolean useAutodiscover = context.getProperty(USE_AUTODISCOVER).asBoolean();
    if (useAutodiscover) {
        try {
            service.autodiscoverUrl(userEmail, new RedirectionUrlCallback());
        } catch (Exception e) {
            throw new ProcessException("Failure setting Autodiscover URL from email address.", e);
        }
    } else {
        String ewsURL = context.getProperty(EWS_URL).getValue();
        try {
            service.setUrl(new URI(ewsURL));
        } catch (URISyntaxException e) {
            throw new ProcessException("Failure setting EWS URL.", e);
        }
    }
    return service;
}
Also used : ExchangeService(microsoft.exchange.webservices.data.core.ExchangeService) ExchangeVersion(microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion) ProcessException(org.apache.nifi.processor.exception.ProcessException) ExchangeCredentials(microsoft.exchange.webservices.data.credential.ExchangeCredentials) URISyntaxException(java.net.URISyntaxException) WebCredentials(microsoft.exchange.webservices.data.credential.WebCredentials) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) MessagingException(javax.mail.MessagingException) EmailException(org.apache.commons.mail.EmailException) ProcessException(org.apache.nifi.processor.exception.ProcessException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 MessagingException (javax.mail.MessagingException)1 ExchangeService (microsoft.exchange.webservices.data.core.ExchangeService)1 ExchangeVersion (microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion)1 ExchangeCredentials (microsoft.exchange.webservices.data.credential.ExchangeCredentials)1 WebCredentials (microsoft.exchange.webservices.data.credential.WebCredentials)1 EmailException (org.apache.commons.mail.EmailException)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1