Class ExchangeServiceBase

    • Constructor Detail

      • ExchangeServiceBase

        protected ExchangeServiceBase()
        Initializes a new instance. This constructor performs the initialization of the HTTP connection manager, so it should be called by every other constructor.
      • ExchangeServiceBase

        protected ExchangeServiceBase​(org.apache.http.impl.client.CloseableHttpClient httpClient,
                                      org.apache.http.impl.client.CloseableHttpClient httpPoolingClient)
      • ExchangeServiceBase

        protected ExchangeServiceBase​(ExchangeVersion requestedServerVersion,
                                      org.apache.http.impl.client.CloseableHttpClient httpClient,
                                      org.apache.http.impl.client.CloseableHttpClient httpPoolingClient)
    • Method Detail

      • setMaximumPoolingConnections

        public void setMaximumPoolingConnections​(int maximumPoolingConnections)
        Sets the maximum number of connections for the pooling connection manager which is used for subscriptions.

        Default is 10.

        Parameters:
        maximumPoolingConnections - Maximum number of pooling connections
      • createConnectionSocketFactoryRegistry

        protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> createConnectionSocketFactoryRegistry()
        Create registry with configured ConnectionSocketFactory instances. Override this method to change how to work with different schemas.
        Returns:
        registry object
      • doOnSerializeCustomSoapHeaders

        public void doOnSerializeCustomSoapHeaders​(XMLStreamWriter writer)
        Calls the custom SOAP header serialisation event handlers, if defined.
        Parameters:
        writer - The XmlWriter to which to write the custom SOAP headers.
      • prepareHttpWebRequestForUrl

        protected HttpWebRequest prepareHttpWebRequestForUrl​(URI url,
                                                             boolean acceptGzipEncoding,
                                                             boolean allowAutoRedirect)
                                                      throws ServiceLocalException,
                                                             URISyntaxException
        Creates an HttpWebRequest instance and initialises it with the appropriate parameters, based on the configuration of this service object.
        Parameters:
        url - The URL that the HttpWebRequest should target.
        acceptGzipEncoding - If true, ask server for GZip compressed content.
        allowAutoRedirect - If true, redirection response will be automatically followed.
        Returns:
        An initialised instance of HttpWebRequest.
        Throws:
        ServiceLocalException - the service local exception
        URISyntaxException - the uRI syntax exception
      • prepareHttpPoolingWebRequestForUrl

        protected HttpWebRequest prepareHttpPoolingWebRequestForUrl​(URI url,
                                                                    boolean acceptGzipEncoding,
                                                                    boolean allowAutoRedirect)
                                                             throws ServiceLocalException,
                                                                    URISyntaxException
        Creates an HttpWebRequest instance from a pooling connection manager and initialises it with the appropriate parameters, based on the configuration of this service object.

        This is used for subscriptions.

        Parameters:
        url - The URL that the HttpWebRequest should target.
        acceptGzipEncoding - If true, ask server for GZip compressed content.
        allowAutoRedirect - If true, redirection response will be automatically followed.
        Returns:
        An initialised instance of HttpWebRequest.
        Throws:
        ServiceLocalException - the service local exception
        URISyntaxException - the uRI syntax exception
      • internalProcessHttpErrorResponse

        protected void internalProcessHttpErrorResponse​(HttpWebRequest httpWebResponse,
                                                        Exception webException,
                                                        TraceFlags responseHeadersTraceFlag,
                                                        TraceFlags responseTraceFlag)
                                                 throws Exception
        This method doesn't handle 500 ISE errors. This is handled by the caller since 500 ISE typically indicates that a SOAP fault has occurred and the handling of a SOAP fault is currently service specific.
        Parameters:
        httpWebResponse - HTTP web response
        webException - web exception
        responseHeadersTraceFlag - trace flag for response headers
        responseTraceFlag - trace flag for respone
        Throws:
        Exception - on error
      • checkURIPath

        public static boolean checkURIPath​(String location)
        Parameters:
        location - file path
        Returns:
        false if location is null,true if this abstract pathname is absolute
      • isTraceEnabledFor

        public boolean isTraceEnabledFor​(TraceFlags traceFlags)
        Determines whether tracing is enabled for specified trace flag(s).
        Parameters:
        traceFlags - The trace flags.
        Returns:
        True if tracing is enabled for specified trace flag(s).
      • traceXml

        public void traceXml​(TraceFlags traceType,
                             ByteArrayOutputStream stream)
        Logs the specified XML to the TraceListener if tracing is enabled.
        Parameters:
        traceType - Kind of trace entry.
        stream - The stream containing XML.
      • convertDateTimeToUniversalDateTimeString

        public String convertDateTimeToUniversalDateTimeString​(Date dt)
        Converts the date time to universal date time string.
        Parameters:
        dt - the date
        Returns:
        String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format.
      • setCustomUserAgent

        protected void setCustomUserAgent​(String userAgent)
        Sets the user agent to a custom value
        Parameters:
        userAgent - User agent string to set on the service
      • isTraceEnabled

        public boolean isTraceEnabled()
        Gets a value indicating whether tracing is enabled.
        Returns:
        True is tracing is enabled
      • setTraceEnabled

        public void setTraceEnabled​(boolean traceEnabled)
        Sets a value indicating whether tracing is enabled.
        Parameters:
        traceEnabled - true to enable tracing
      • setTraceListener

        public void setTraceListener​(ITraceListener traceListener)
        Sets the trace listener.
        Parameters:
        traceListener - the trace listener.
      • setCredentials

        public void setCredentials​(ExchangeCredentials credentials)
        Sets the credential used to authenticate with the Exchange Web Services. Setting the Credentials property automatically sets the UseDefaultCredentials to false.
        Parameters:
        credentials - Exchange credential.
      • getUseDefaultCredentials

        public boolean getUseDefaultCredentials()
        Gets a value indicating whether the credential of the user currently logged into Windows should be used to authenticate with the Exchange Web Services.
        Returns:
        true if credential of the user currently logged in are used
      • setUseDefaultCredentials

        public void setUseDefaultCredentials​(boolean value)
        Sets a value indicating whether the credential of the user currently logged into Windows should be used to authenticate with the Exchange Web Services. Setting UseDefaultCredentials to true automatically sets the Credentials property to null.
        Parameters:
        value - the new use default credential
      • getTimeout

        public int getTimeout()
        Gets the timeout used when sending HTTP request and when receiving HTTP response, in milliseconds.
        Returns:
        timeout in milliseconds
      • setTimeout

        public void setTimeout​(int timeout)
        Sets the timeout used when sending HTTP request and when receiving HTTP respones, in milliseconds. Defaults to 100000.
        Parameters:
        timeout - timeout in milliseconds
      • isPreAuthenticate

        public boolean isPreAuthenticate()
        Gets a value that indicates whether HTTP pre-authentication should be performed.
        Returns:
        true indicates pre-authentication is set
      • setPreAuthenticate

        public void setPreAuthenticate​(boolean preAuthenticate)
        Sets a value that indicates whether HTTP pre-authentication should be performed.
        Parameters:
        preAuthenticate - true to enable pre-authentication
      • getAcceptGzipEncoding

        public boolean getAcceptGzipEncoding()
        Gets a value indicating whether GZip compression encoding should be accepted. This value will tell the server that the client is able to handle GZip compression encoding. The server will only send Gzip compressed content if it has been configured to do so.
        Returns:
        true if compression is used
      • setAcceptGzipEncoding

        public void setAcceptGzipEncoding​(boolean acceptGzipEncoding)
        Gets a value indicating whether GZip compression encoding should be accepted. This value will tell the server that the client is able to handle GZip compression encoding. The server will only send Gzip compressed content if it has been configured to do so.
        Parameters:
        acceptGzipEncoding - true to enable compression
      • getUserAgent

        public String getUserAgent()
        Gets the user agent.
        Returns:
        The user agent.
      • setUserAgent

        public void setUserAgent​(String userAgent)
        Sets the user agent.
        Parameters:
        userAgent - The user agent
      • getServerInfo

        public ExchangeServerInfo getServerInfo()
        Gets information associated with the server that processed the last request. Will be null if no request have been processed.
        Returns:
        the server info
      • setServerInfo

        public void setServerInfo​(ExchangeServerInfo serverInfo)
        Sets information associated with the server that processed the last request.
        Parameters:
        serverInfo - Server Information
      • getWebProxy

        public WebProxy getWebProxy()
        Gets the web proxy that should be used when sending request to EWS.
        Returns:
        Proxy the Proxy Information
      • setWebProxy

        public void setWebProxy​(WebProxy value)
        Sets the web proxy that should be used when sending request to EWS. Set this property to null to use the default web proxy.
        Parameters:
        value - the Proxy Information
      • getHttpHeaders

        public Map<String,​StringgetHttpHeaders()
        Gets a collection of HTTP headers that will be sent with each request to EWS.
        Returns:
        httpHeaders
      • getSessionKey

        public static byte[] getSessionKey()
        Gets the session key.
        Returns:
        session key