public final class EwsUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AutodiscoverSoapNamespace
The Constant AutodiscoverSoapNamespace.
|
static String |
AutodiscoverSoapNamespacePrefix
The Constant AutodiscoverSoapNamespacePrefix.
|
static String |
DomainRegex
Regular expression for legal domain names.
|
static LazyMember<Map<Class<?>,Map<String,String>>> |
ENUM_TO_SCHEMA_DICTIONARIES
Dictionary of enum type to enum-value-to-schema-name maps.
|
static String |
EwsErrorsNamespace
The Constant EwsErrorsNamespace.
|
static String |
EwsErrorsNamespacePrefix
The Constant EwsErrorsNamespacePrefix.
|
static String |
EwsMessagesNamespace
The Constant EwsMessagesNamespace.
|
static String |
EwsMessagesNamespacePrefix
The Constant EwsMessagesNamespacePrefix.
|
static String |
EwsSoap12Namespace
The Constant EwsSoap12Namespace.
|
static String |
EwsSoapNamespace
The Constant EwsSoapNamespace.
|
static String |
EwsSoapNamespacePrefix
The Constant EwsSoapNamespacePrefix.
|
static String |
EwsTypesNamespace
The Constant EwsTypesNamespace.
|
static String |
EwsTypesNamespacePrefix
The Constant EwsTypesNamespacePrefix.
|
static String |
EwsXmlSchemaInstanceNamespace
The Constant EwsXmlSchemaInstanceNamespace.
|
static String |
EwsXmlSchemaInstanceNamespacePrefix
The Constant EwsXmlSchemaInstanceNamespacePrefix.
|
static String |
PassportSoapFaultNamespace
The Constant PassportSoapFaultNamespace.
|
static String |
PassportSoapFaultNamespacePrefix
The Constant PassportSoapFaultNamespacePrefix.
|
static String |
WSAddressingNamespace
The Constant WSAddressingNamespace.
|
static String |
WSAddressingNamespacePrefix
The Constant WSAddressingNamespacePrefix.
|
static String |
WSSecuritySecExtNamespace |
static String |
WSSecuritySecExtNamespacePrefix
The Constant WSSecuritySecExtNamespacePrefix.
|
static String |
WSSecurityUtilityNamespace |
static String |
WSSecurityUtilityNamespacePrefix
The Constant WSSecurityUtilityNamespacePrefix.
|
static String |
WSTrustFebruary2005Namespace
The Constant WSTrustFebruary2005Namespace.
|
static String |
WSTrustFebruary2005NamespacePrefix
The Constant WSTrustFebruary2005NamespacePrefix.
|
static String |
XSFalse
The Constant XSFalse.
|
static String |
XSTrue
The Constant XSTrue.
|
Modifier and Type | Method and Description |
---|---|
static String |
boolToXSBool(Boolean value)
Convert bool to XML Schema bool.
|
static int |
countMatchingChars(String str,
IPredicate<Character> charPredicate)
Count characters in string that match a condition.
|
static <TServiceObject extends ServiceObject> |
createEwsObjectFromXmlElementName(Class<?> itemClass,
ExchangeService service,
String xmlElementName)
Creates the ews object from xml element name.
|
static Item |
createItemFromItemClass(ItemAttachment itemAttachment,
Class<?> itemClass,
boolean isNew)
Creates the item from item class.
|
static Item |
createItemFromXmlElementName(ItemAttachment itemAttachment,
String xmlElementName)
Creates the item from xml element name.
|
static String |
dateTimeToXSDate(Date date)
Convert DateTime to XML Schema date.
|
static String |
dateTimeToXSDateTime(Date date)
Dates the DateTime into an XML schema date time.
|
static String |
domainFromEmailAddress(String emailAddress)
Gets the domain name from an email address.
|
static void |
ewsAssert(boolean condition,
String caller,
String message)
Asserts that the specified condition if true.
|
static <TItem extends Item> |
findFirstItemOfType(Class<TItem> cls,
Iterable<Item> items)
Finds the first item of type TItem (not a descendant type) in the
specified collection.
|
static <T> void |
forEach(Iterable<T> collection,
IAction<T> action)
Call an action for each member of a collection.
|
static String |
formatHttpRequestHeaders(HttpWebRequest request)
Format request HTTP headers.
|
static String |
formatHttpResponseHeaders(HttpWebRequest response)
Format http response headers.
|
static String |
formatLogMessage(String entryKind,
String logEntry)
.
|
static String |
formatLogMessageWithXmlContent(String traceTypeStr,
ByteArrayOutputStream stream)
Format XML content in a MemoryStream for message.
|
static String |
getBuildVersion()
Gets the builds the version.
|
static int |
getDim(Object array) |
static <T> Object |
getEnumeratedObjectAt(Iterable<T> objects,
int index)
Gets the enumerated object at.
|
static <T> int |
getEnumeratedObjectCount(Iterator<T> objects)
Gets the enumerated object count.
|
static Class<?> |
getItemTypeFromXmlElementName(String xmlElementName) |
static XmlNamespace |
getNamespaceFromUri(String namespaceUri)
Gets the namespace from uri.
|
static String |
getNamespacePrefix(XmlNamespace xmlNamespace)
Gets the namespace prefix from an XmlNamespace enum value.
|
static String |
getNamespaceUri(XmlNamespace xmlNamespace)
Gets the namespace URI from an XmlNamespace enum value.
|
static String |
getTimeSpanToXSDuration(TimeSpan timeOffset)
Takes a System.TimeSpan structure and converts it into an xs:duration
string as defined by the W3 Consortiums Recommendation
"XML Schema Part 2: Datatypes Second Edition",
http://www.w3.org/TR/xmlschema-2/#duration
|
static TimeSpan |
getXSDurationToTimeSpan(String xsDuration)
Takes an xs:duration string as defined by the W3 Consortiums
Recommendation "XML Schema Part 2: Datatypes Second Edition",
http://www.w3.org/TR/xmlschema-2/#duration, and converts it into a
System.TimeSpan structure This method uses the following approximations:
1 year = 365 days 1 month = 30 days Additionally, it only allows for four
decimal points of seconds precision.
|
static <T> T |
parse(Class<T> cls,
String value)
Parses the.
|
static <T extends Enum<?>> |
parseEnumValueList(Class<T> c,
List<T> list,
String value,
char... separators)
Parses an enum value list.
|
static String |
serializeEnum(Object value)
Converts an enum to a string, using the mapping dictionaries if
appropriate.
|
static String |
timeSpanToXSTime(TimeSpan timeSpan)
Time span to xs time.
|
static <T> boolean |
trueForAll(Iterable<T> collection,
IPredicate<T> predicate)
Determines whether every element in the collection
matches the conditions defined by the specified predicate.
|
static void |
validateClassVersion(ExchangeService service,
ExchangeVersion minimumServerVersion,
String className)
Validates class version against the request version.
|
static void |
validateDomainNameAllowNull(String domainName,
String paramName)
Validates domain name (null value allowed)
|
static void |
validateEnumVersionValue(Enum<?> enumValue,
ExchangeVersion requestVersion)
Validate enum version value.
|
static void |
validateMethodVersion(ExchangeService service,
ExchangeVersion minimumServerVersion,
String methodName)
Validate method version.
|
static void |
validateNonBlankStringParam(String param,
String paramName)
Validates string parameter to be
non-empty string (null value not allowed).
|
static void |
validateNonBlankStringParamAllowNull(String param,
String paramName)
Validates string parameter to be non-empty string (null value allowed).
|
static void |
validateParam(Object param,
String paramName)
Validates parameter (null value not allowed).
|
static void |
validateParamAllowNull(Object param,
String paramName)
Validates parameter (and allows null value).
|
static void |
validateParamCollection(EventType[] eventTypes,
String paramName)
Validate param collection.
|
static <T> void |
validateParamCollection(Iterator<T> collection,
String paramName)
Validates parameter collection.
|
static void |
validatePropertyVersion(ExchangeService service,
ExchangeVersion minimumServerVersion,
String propertyName)
Validates property version against the request version.
|
static void |
validateServiceObjectVersion(ServiceObject serviceObject,
ExchangeVersion requestVersion)
Validates service object version against the request version.
|
public static final String XSFalse
public static final String XSTrue
public static final String EwsTypesNamespacePrefix
public static final String EwsMessagesNamespacePrefix
public static final String EwsErrorsNamespacePrefix
public static final String EwsSoapNamespacePrefix
public static final String EwsXmlSchemaInstanceNamespacePrefix
public static final String PassportSoapFaultNamespacePrefix
public static final String WSTrustFebruary2005NamespacePrefix
public static final String WSAddressingNamespacePrefix
public static final String AutodiscoverSoapNamespacePrefix
public static final String WSSecurityUtilityNamespacePrefix
public static final String WSSecuritySecExtNamespacePrefix
public static final String EwsTypesNamespace
public static final String EwsMessagesNamespace
public static final String EwsErrorsNamespace
public static final String EwsSoapNamespace
public static final String EwsSoap12Namespace
public static final String EwsXmlSchemaInstanceNamespace
public static final String PassportSoapFaultNamespace
public static final String WSTrustFebruary2005Namespace
public static final String WSAddressingNamespace
public static final String AutodiscoverSoapNamespace
public static final String WSSecurityUtilityNamespace
public static final String WSSecuritySecExtNamespace
public static final LazyMember<Map<Class<?>,Map<String,String>>> ENUM_TO_SCHEMA_DICTIONARIES
public static final String DomainRegex
public static String getBuildVersion()
public static void ewsAssert(boolean condition, String caller, String message)
condition
- Assertion.caller
- The caller.message
- The message to use if assertion fails.public static String getNamespacePrefix(XmlNamespace xmlNamespace)
xmlNamespace
- The XML namespacepublic static String getNamespaceUri(XmlNamespace xmlNamespace)
xmlNamespace
- The XML namespace.public static XmlNamespace getNamespaceFromUri(String namespaceUri)
namespaceUri
- the namespace uripublic static <TServiceObject extends ServiceObject> TServiceObject createEwsObjectFromXmlElementName(Class<?> itemClass, ExchangeService service, String xmlElementName) throws Exception
TServiceObject
- the generic typeitemClass
- the item classservice
- the servicexmlElementName
- the xml element nameException
- the exceptionpublic static Item createItemFromItemClass(ItemAttachment itemAttachment, Class<?> itemClass, boolean isNew) throws Exception
itemAttachment
- the item attachmentitemClass
- the item classisNew
- the is newException
- the exceptionpublic static Item createItemFromXmlElementName(ItemAttachment itemAttachment, String xmlElementName) throws Exception
itemAttachment
- the item attachmentxmlElementName
- the xml element nameException
- the exceptionpublic static Class<?> getItemTypeFromXmlElementName(String xmlElementName)
public static <TItem extends Item> TItem findFirstItemOfType(Class<TItem> cls, Iterable<Item> items)
TItem
- TItem is the type of the item to find.cls
- the clsitems
- the itempublic static String formatLogMessage(String entryKind, String logEntry) throws XMLStreamException, IOException
entryKind
- the entry kindlogEntry
- the log entryXMLStreamException
- the XML stream exceptionIOException
- signals that an I/O exception has occurred.public static String formatHttpResponseHeaders(HttpWebRequest response) throws EWSHttpException
response
- the responseEWSHttpException
- the EWS http exceptionpublic static String formatHttpRequestHeaders(HttpWebRequest request) throws URISyntaxException, EWSHttpException
request
- The HTTP request.URISyntaxException
EWSHttpException
public static String formatLogMessageWithXmlContent(String traceTypeStr, ByteArrayOutputStream stream)
traceTypeStr
- Kind of the entry.stream
- The memory stream.public static String boolToXSBool(Boolean value)
value
- Bool value.public static <T extends Enum<?>> void parseEnumValueList(Class<T> c, List<T> list, String value, char... separators)
T
- the generic typec
- the clist
- the listvalue
- the valueseparators
- the separatorspublic static String serializeEnum(Object value)
value
- The enum value to be serializedpublic static <T> T parse(Class<T> cls, String value) throws ParseException
T
- the generic typecls
- the clsvalue
- the valueParseException
- the parse exceptionpublic static void validateParamCollection(EventType[] eventTypes, String paramName) throws Exception
eventTypes
- the event typesparamName
- the param nameException
- the exceptionpublic static String dateTimeToXSDate(Date date)
date
- the datepublic static String dateTimeToXSDateTime(Date date)
date
- the datepublic static String getTimeSpanToXSDuration(TimeSpan timeOffset)
timeOffset
- structure to convertpublic static TimeSpan getXSDurationToTimeSpan(String xsDuration)
xsDuration
- xs:duration string to convertpublic static String timeSpanToXSTime(TimeSpan timeSpan)
timeSpan
- the time spanpublic static String domainFromEmailAddress(String emailAddress) throws FormatException
emailAddress
- The email address.FormatException
- the format exceptionpublic static void validateParamAllowNull(Object param, String paramName) throws Exception
param
- The param.paramName
- Name of the param.Exception
- the exceptionpublic static void validateParam(Object param, String paramName) throws Exception
param
- The param.paramName
- Name of the param.Exception
- the exceptionpublic static <T> void validateParamCollection(Iterator<T> collection, String paramName) throws Exception
T
- the generic typecollection
- The collection.paramName
- Name of the param.Exception
- the exceptionpublic static void validateNonBlankStringParamAllowNull(String param, String paramName) throws ArgumentException, ServiceLocalException
param
- The string parameter.paramName
- Name of the parameter.ArgumentException
ServiceLocalException
public static void validateNonBlankStringParam(String param, String paramName) throws ArgumentNullException, ArgumentException, ServiceLocalException
param
- The string parameter.paramName
- Name of the parameter.ArgumentNullException
ArgumentException
ServiceLocalException
public static void validateEnumVersionValue(Enum<?> enumValue, ExchangeVersion requestVersion) throws ServiceVersionException
enumValue
- the enum valuerequestVersion
- the request versionServiceVersionException
- the service version exceptionpublic static void validateServiceObjectVersion(ServiceObject serviceObject, ExchangeVersion requestVersion) throws ServiceVersionException
serviceObject
- The service object.requestVersion
- The request version.ServiceVersionException
- Raised if this service object type requires a later version
of Exchange.public static void validatePropertyVersion(ExchangeService service, ExchangeVersion minimumServerVersion, String propertyName) throws ServiceVersionException
service
- The Exchange service.minimumServerVersion
- The minimum server versionpropertyName
- The property nameServiceVersionException
- The service version exceptionpublic static void validateMethodVersion(ExchangeService service, ExchangeVersion minimumServerVersion, String methodName) throws ServiceVersionException
service
- the serviceminimumServerVersion
- the minimum server versionmethodName
- the method nameServiceVersionException
- the service version exceptionpublic static void validateClassVersion(ExchangeService service, ExchangeVersion minimumServerVersion, String className) throws ServiceVersionException
service
- the serviceminimumServerVersion
- The minimum server version that supports the method.className
- Name of the class.ServiceVersionException
public static void validateDomainNameAllowNull(String domainName, String paramName) throws ArgumentException
domainName
- Domain name.paramName
- Parameter name.ArgumentException
public static <T> int getEnumeratedObjectCount(Iterator<T> objects)
T
- the generic typeobjects
- The objects.public static <T> Object getEnumeratedObjectAt(Iterable<T> objects, int index)
T
- the generic typeobjects
- the objectsindex
- the indexpublic static int countMatchingChars(String str, IPredicate<Character> charPredicate) throws ServiceLocalException
str
- The string.charPredicate
- Predicate to evaluate for each character in the string.ServiceLocalException
public static <T> boolean trueForAll(Iterable<T> collection, IPredicate<T> predicate) throws ServiceLocalException
T
- Entry type.collection
- The collection.predicate
- Predicate that defines the conditions to check against the elements.ServiceLocalException
Copyright © 2012–2015 Microsoft. All rights reserved.